导航菜单

页面标题

页面副标题

友礼甄好 v1.4.6 - Main1Activity.java 源代码

正在查看: 友礼甄好 v1.4.6 应用的 Main1Activity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.cscmjy.youlimall;

import android.app.Activity;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.media.MediaRecorder;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.vectordrawable.graphics.drawable.PathInterpolatorCompat;
import androidx.webkit.WebViewClientCompat;
import com.alibaba.fastjson.support.spring.FastJsonJsonView;
import com.alipay.sdk.app.AlipayApi;
import com.alipay.sdk.app.H5PayCallback;
import com.alipay.sdk.app.PayTask;
import com.alipay.sdk.m.q.e;
import com.alipay.sdk.m.v.l;
import com.alipay.sdk.m.y.d;
import com.alipay.sdk.util.H5PayResultModel;
import com.allenliu.versionchecklib.callback.APKDownloadListener;
import com.allenliu.versionchecklib.v2.AllenVersionChecker;
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
import com.allenliu.versionchecklib.v2.builder.UIData;
import com.allenliu.versionchecklib.v2.callback.CustomDownloadingDialogListener;
import com.allenliu.versionchecklib.v2.callback.CustomVersionDialogListener;
import com.cscmjy.youlimall.AppEvent;
import com.cscmjy.youlimall.utils.ExtendMap;
import com.cscmjy.youlimall.utils.LocalWebServer;
import com.cscmjy.youlimall.utils.ResponseParse;
import com.cscmjy.youlimall.utils.WebRTCAudioRecorder;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.gyf.immersionbar.ImmersionBar;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.ServerSocket;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;

public class Main1Activity extends AppCompatActivity {
    public static final int FAIL_REQUEST = 2;
    private static final int FILECHOOSER_RESULTCODE = 2;
    public static final int HIDE_LOADING = 4;
    public static String HOST_DOMAIN = "";
    public static String HTTP_API_URL = "https://nhapi.youli.me/api/";
    public static String HTTP_UPDATE_URL = "https://nhapi.youli.me/api/edition";
    public static String LOCAL_CACHE_CAMERA = "youlime_camera_cache";
    public static String LOCAL_CACHE_DISKALLOW = "youlime_diskallow_cache";
    public static String LOCAL_CACHE_PRIVILEGES = "youlime_localprivileges_cache";
    public static String LOCAL_CACHE_TOKEN = "youlime_token_cache";
    public static String LOCAL_CACHE_USERNAME = "youlime_username_cache";
    private static final int QRCODERSACE_RESULTCODE = 49374;
    private static int REQUEST_PERMISSION_CODE = 1;
    private static final int REQUEST_RECORD_AUDIO_PERMISSION = 200;
    public static final int REQUEST_SELECT_FILE = 100;
    public static final int SHOW_LOADING = 3;
    private static LocalWebServer localwebserver;
    private WebRTCAudioRecorder audioRecorder;
    DownloadBuilder builder;
    private LocationManager lm;
    private ValueCallback<Uri> mUploadMessage;
    private String token;
    public ValueCallback<Uri[]> uploadMessage;
    String url1;
    WebView web_view;
    public int SHOW_CHECKVER = 0;
    public String upload_voice_uid = "0";
    public String PAY_BACK_URL = "";
    int startX = 0;
    public int pdheight = 0;
    public String PublocationString = "";
    public MediaRecorder mMediaRecorder = null;
    public String fileName = "";
    public String filePath = "";
    public String audioSaveDir = "audiotmp";
    public int webPort = 8080;
    String returnUrl = "";
    private ExtendMap<String, Object> resultMap1 = new ExtendMap<>();
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            super.handleMessage(message);
            int i = message.what;
            if (i == 2 || i == 3 || i == 4) {
                return;
            }
            if (i == 10) {
                Main1Activity.this.resultMap1 = ResponseParse.parseMapData(message.obj.toString());
                if (Main1Activity.this.resultMap1.getInt("edition") > 146) {
                    AllenVersionChecker allenVersionChecker = AllenVersionChecker.getInstance();
                    Main1Activity main1Activity = Main1Activity.this;
                    DownloadBuilder downloadOnly = allenVersionChecker.downloadOnly(main1Activity.crateUIData("请升级版本", main1Activity.resultMap1.getString("url"), Main1Activity.this.resultMap1.getString("edition")));
                    downloadOnly.setCustomVersionDialogListener(Main1Activity.this.createCustomDialog(false)).setCustomDownloadingDialogListener(Main1Activity.this.createCustomDownloadingDialog()).setDirectDownload(false).setForceRedownload(true).setApkDownloadListener(new APKDownloadListener() {
                        @Override
                        public void onDownloadFail() {
                        }

                        @Override
                        public void onDownloadSuccess(File file) {
                        }

                        @Override
                        public void onDownloading(int i2) {
                        }
                    }).setShowDownloadingDialog(true);
                    downloadOnly.executeMission(Main1Activity.this);
                    return;
                }
                if (Main1Activity.this.SHOW_CHECKVER == 1) {
                    Log.e("checkver", "is new");
                    Looper.prepare();
                    Toast.makeText(Main1Activity.this, "当前已是最新版本", 0).show();
                    Looper.loop();
                    return;
                }
                return;
            }
            Main1Activity main1Activity2 = Main1Activity.this;
            main1Activity2.setStatusBarColor(main1Activity2, message.what);
        }
    };

    @Override
    protected void onCreate(Bundle bundle) {
        String str;
        super.onCreate(bundle);
        this.audioRecorder = new WebRTCAudioRecorder(this);
        try {
            File file = new File(getFilesDir(), "dist");
            if (file.exists()) {
                while (!isPortAvailable(this.webPort)) {
                    this.webPort++;
                }
                LocalWebServer localWebServer = new LocalWebServer(this.webPort, this, file.getAbsolutePath());
                localwebserver = localWebServer;
                localWebServer.start(PathInterpolatorCompat.MAX_NUM_POINTS, false);
                HOST_DOMAIN = "http://localhost:" + this.webPort + "/index.html";
            } else {
                HOST_DOMAIN = "file:///android_asset/dist/index.html";
            }
        } catch (Exception unused) {
        }
        getWindow().addFlags(128);
        if (getIntent().getStringExtra("web_view_url").equals("normal")) {
            str = HOST_DOMAIN + "?uuid=" + getAndroidID(this) + "&mr=" + Math.random();
        } else {
            str = HOST_DOMAIN + "?uuid=" + getAndroidID(this) + "&mr=" + Math.random() + "/#/msg/list";
        }
        setContentView(R.layout.activity_main);
        checkVersion();
        EventBus.getDefault().register(this);
        getWindowManager().getDefaultDisplay();
        this.lm = (LocationManager) getSystemService("location");
        this.pdheight = DisplayUtil.getStatusBarHeight(this);
        this.web_view = (WebView) findViewById(R.id.web_view);
        ImmersionBar.with(this).navigationBarEnable(false).statusBarDarkFont(false).navigationBarDarkIcon(false).init();
        this.web_view.getSettings().setJavaScriptEnabled(true);
        this.web_view.getSettings().setMixedContentMode(0);
        this.web_view.getSettings().setBlockNetworkImage(false);
        this.web_view.getSettings().setMediaPlaybackRequiresUserGesture(false);
        this.web_view.getSettings().setUseWideViewPort(true);
        this.web_view.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        this.web_view.getSettings().setLoadWithOverviewMode(true);
        this.web_view.getSettings().setSupportZoom(false);
        this.web_view.getSettings().setDomStorageEnabled(true);
        this.web_view.getSettings().setAllowFileAccess(true);
        this.web_view.getSettings().setCacheMode(1);
        this.web_view.getSettings().setTextZoom(100);
        this.web_view.addJavascriptInterface(new JavaScriptInterface(), "Youlisoft");
        this.web_view.setWebViewClient(new WebViewClientCompat() {
            @Override
            public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
                sslErrorHandler.proceed();
            }

            @Override
            public boolean shouldOverrideUrlLoading(final WebView webView, String str2) {
                if ((str2.startsWith("http") || str2.startsWith("https")) && !new PayTask(Main1Activity.this).payInterceptorWithUrl(str2, true, new H5PayCallback() {
                    @Override
                    public void onPayResult(H5PayResultModel h5PayResultModel) {
                        final String returnUrl = h5PayResultModel.getReturnUrl();
                        if (TextUtils.isEmpty(returnUrl)) {
                            return;
                        }
                        Main1Activity.this.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                webView.loadUrl(returnUrl);
                            }
                        });
                    }
                })) {
                    webView.loadUrl(str2);
                }
                return true;
            }

            @Override
            public void onPageStarted(WebView webView, String str2, Bitmap bitmap) {
                super.onPageStarted(webView, str2, bitmap);
                Log.e("zuoquanurl", str2 + "---");
            }

            @Override
            public void onPageFinished(WebView webView, String str2) {
                Log.e("zuoquanurl", str2 + "---");
                Main1Activity.this.url1 = str2;
            }
        });
        this.web_view.setWebChromeClient(new WebChromeClient() {
            protected void openFileChooser(ValueCallback valueCallback, String str2) {
                Main1Activity.this.mUploadMessage = valueCallback;
                Intent intent = new Intent("android.intent.action.GET_CONTENT");
                intent.addCategory("android.intent.category.OPENABLE");
                intent.setType("image/*");
                Main1Activity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 2);
            }

            @Override
            public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
                if (Main1Activity.this.uploadMessage != null) {
                    Main1Activity.this.uploadMessage.onReceiveValue(null);
                    Main1Activity.this.uploadMessage = null;
                }
                Main1Activity.this.uploadMessage = valueCallback;
                try {
                    Main1Activity.this.startActivityForResult(fileChooserParams.createIntent(), 100);
                    return true;
                } catch (ActivityNotFoundException unused2) {
                    Main1Activity.this.uploadMessage = null;
                    Toast.makeText(Main1Activity.this.getBaseContext(), "Cannot Open File Chooser", 1).show();
                    return false;
                }
            }

            protected void openFileChooser(ValueCallback<Uri> valueCallback, String str2, String str3) {
                Main1Activity.this.mUploadMessage = valueCallback;
                Intent intent = new Intent("android.intent.action.GET_CONTENT");
                intent.addCategory("android.intent.category.OPENABLE");
                intent.setType("image/*");
                Main1Activity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 2);
            }

            protected void openFileChooser(ValueCallback<Uri> valueCallback) {
                Main1Activity.this.mUploadMessage = valueCallback;
                Intent intent = new Intent("android.intent.action.GET_CONTENT");
                intent.addCategory("android.intent.category.OPENABLE");
                intent.setType("image/*");
                Main1Activity.this.startActivityForResult(Intent.createChooser(intent, "File Chooser"), 2);
            }
        });
        Log.i("web_view_url", str);
        this.web_view.loadUrl(str);
    }

    private boolean checkRecordPermission() {
        if (ContextCompat.checkSelfPermission(this, "android.permission.RECORD_AUDIO") == 0) {
            return true;
        }
        ActivityCompat.requestPermissions(this, new String[]{"android.permission.RECORD_AUDIO", "android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
        return false;
    }

    public static boolean isPortAvailable(int i) {
        try {
            ServerSocket serverSocket = new ServerSocket(i);
            try {
                serverSocket.setReuseAddress(true);
                serverSocket.close();
                return true;
            } finally {
            }
        } catch (IOException unused) {
            return false;
        }
    }

    public void startNewRecord() {
        if (checkRecordPermission()) {
            Log.e("startRecordingCallback info=>", "startRecordingCallback");
            final String str = "javascript:startRecordingCallback()";
            this.web_view.post(new Runnable() {
                @Override
                public void run() {
                    Main1Activity.this.web_view.loadUrl(str);
                }
            });
            this.audioRecorder.startRecording();
        }
    }

    public void stopNewRecord(String str) {
        try {
            this.audioRecorder.stopRecording();
            String recordingFilePath = this.audioRecorder.getRecordingFilePath();
            Log.i("saveFile", recordingFilePath);
            if (str.equals("stop")) {
                uploadFile(recordingFilePath);
            } else {
                File file = new File(recordingFilePath);
                if (file.exists()) {
                    file.delete();
                }
            }
        } catch (RuntimeException e) {
            Log.e("audiorecording", e.toString());
            File file2 = new File(this.audioRecorder.getRecordingFilePath());
            if (file2.exists()) {
                file2.delete();
            }
        }
    }

    private void uploadFile(String str) {
        OkHttpClient okHttpClient = new OkHttpClient();
        Log.i("starting upload", "开始上传");
        final File file = new File(str);
        okHttpClient.newCall(new Request.Builder().url(HTTP_API_URL + "uploadvoice").post(new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse("multipart/form-data"), file)).addFormDataPart("uid", this.upload_voice_uid).build()).build()).enqueue(new Callback() {
            public void onFailure(Call call, IOException iOException) {
                Log.e("上传失败", iOException.toString());
                if (file.exists()) {
                    file.delete();
                }
                Main1Activity.this.filePath = "";
            }

            public void onResponse(Call call, Response response) throws IOException {
                Log.i("res", "上传成功");
                String string = response.body().string();
                Log.e("stopRecordingCallback info=>", "stopRecordingCallback=>voiceid" + string);
                final String str2 = "javascript:stopRecordingCallback('voiceid|" + string + "')";
                Main1Activity.this.web_view.post(new Runnable() {
                    @Override
                    public void run() {
                        Main1Activity.this.web_view.loadUrl(str2);
                    }
                });
                if (file.exists()) {
                    file.delete();
                }
                Main1Activity.this.filePath = "";
            }
        });
    }

    public void startLocation() {
        Criteria criteria = new Criteria();
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        final LocationManager locationManager = (LocationManager) getSystemService("location");
        locationManager.requestLocationUpdates(locationManager.getBestProvider(criteria, true), 1000L, 0.0f, new LocationListener() {
            @Override
            public void onProviderDisabled(String str) {
            }

            @Override
            public void onProviderEnabled(String str) {
            }

            @Override
            public void onStatusChanged(String str, int i, Bundle bundle) {
            }

            @Override
            public void onLocationChanged(Location location) {
                Main1Activity.this.updateShow(location);
                locationManager.removeUpdates(this);
            }
        });
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        if (i != 200) {
            return;
        }
        if (iArr[0] == 0) {
            startLocation();
        } else {
            Toast.makeText(this, "未开启定位权限,请手动到设置去开启权限", 1).show();
        }
    }

    public static boolean isKeyboardShown(View view) {
        Rect rect = new Rect();
        view.getWindowVisibleDisplayFrame(rect);
        int height = view.getRootView().getHeight();
        return ((double) (height - rect.bottom)) > ((double) height) * 0.15d;
    }

    public static int getKeyboardHeight(View view) {
        Rect rect = new Rect();
        view.getWindowVisibleDisplayFrame(rect);
        return view.getRootView().getHeight() - rect.bottom;
    }

    public void updateShow(Location location) {
        if (location != null) {
            double longitude = location.getLongitude();
            if (longitude <= 0.0d) {
                longitude = location.getLongitude() * (-1.0d);
            }
            String str = longitude + "|" + location.getLatitude();
            Log.i("callbacklocation", str);
            this.PublocationString = str;
            final String str2 = "javascript:getLocationCallBack('" + str + "')";
            this.web_view.post(new Runnable() {
                @Override
                public void run() {
                    Main1Activity.this.web_view.loadUrl(str2);
                }
            });
        }
    }

    public void openGPS2() {
        startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), 0);
    }

    public boolean isGpsAble(LocationManager locationManager) {
        return locationManager.isProviderEnabled("gps");
    }

    public String urlEncode(String str) {
        try {
            return URLEncoder.encode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return str;
        }
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        return super.dispatchTouchEvent(motionEvent);
    }

    public void doScan() {
        new IntentIntegrator(this).initiateScan();
    }

    private boolean isAvilible(String str) {
        Log.e("packageName", str);
        List<PackageInfo> installedPackages = getPackageManager().getInstalledPackages(0);
        ArrayList arrayList = new ArrayList();
        if (installedPackages != null) {
            for (int i = 0; i < installedPackages.size(); i++) {
                arrayList.add(installedPackages.get(i).packageName);
            }
        }
        return arrayList.contains(str);
    }

    public void openGaode(String str, double d, double d2) {
        Log.e("in open", "gd");
        if (isAvilible("com.autonavi.minimap")) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            intent.setData(Uri.parse("androidamap://route/plan/?dlat=" + d2 + "&dlon=" + d + "&dname=" + str + "&dev=0&t=0"));
            startActivity(intent);
            return;
        }
        Toast.makeText(this, "尚未安装高德地图", 1).show();
    }

    public void openBaidu(String str, double d, double d2) {
        Log.e("in open", "gd");
        if (isAvilible("com.baidu.BaiduMap")) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            intent.setData(Uri.parse("baidumap://map/direction?origin=我的位置&destination=name:" + str + "|latlng:" + d2 + "," + d + "&coord_type=wgs84&mode=driving&src=andr.baidu.openAPIdemo"));
            startActivity(intent);
            return;
        }
        Toast.makeText(this, "尚未安装百度地图", 1).show();
    }

    public void openTengxun(String str, double d, double d2) {
        Log.e("in open", "tx");
        if (isAvilible("com.tencent.map")) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.addCategory("android.intent.category.DEFAULT");
            intent.setData(Uri.parse("qqmap://map/routeplan?type=drive&policy=0&from=我的位置&fromcoord=CurrentLocation&to=" + str + "&tocoord=" + d2 + "," + d + "&referer=6DYBZ-FRVC3-XW23G-3H75U-DS6I3-AZFGP"));
            startActivity(intent);
            return;
        }
        Toast.makeText(this, "尚未安装腾讯地图", 1).show();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getFloor(String str) {
        if (str.equals(d.u)) {
            Log.e("zuoquan", d.u);
            if (this.web_view.canGoBack()) {
                this.web_view.goBack();
            }
        }
        if (str.equals("start")) {
            Log.d("lzw", "DisplayUtil.return_url_1=" + DisplayUtil.return_url_1);
            this.web_view.loadUrl(DisplayUtil.return_url_1);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getFinish(AppEvent.Finish finish) {
        Log.e("zuoquan", finish.returnUrl + "gggg");
        this.returnUrl = finish.returnUrl;
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4 && this.web_view.canGoBack()) {
            this.web_view.goBack();
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    public void checkVersion() {
        Log.e("statusbar------------>", "staring checkVersion------------");
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    URL url = new URL(Main1Activity.HTTP_UPDATE_URL + "?edition=146");
                    Log.e("geturl", Main1Activity.HTTP_UPDATE_URL);
                    HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
                    httpsURLConnection.setDoInput(true);
                    httpsURLConnection.setDoOutput(true);
                    httpsURLConnection.setRequestMethod("GET");
                    httpsURLConnection.setUseCaches(false);
                    httpsURLConnection.setConnectTimeout(5000);
                    httpsURLConnection.setReadTimeout(5000);
                    httpsURLConnection.setRequestProperty("Content-Type", FastJsonJsonView.DEFAULT_CONTENT_TYPE);
                    int responseCode = httpsURLConnection.getResponseCode();
                    if (responseCode == 200) {
                        System.out.println(responseCode);
                        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
                        StringBuffer stringBuffer = new StringBuffer();
                        while (true) {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                break;
                            } else {
                                stringBuffer.append(readLine);
                            }
                        }
                        Log.i("jsondata", stringBuffer.toString());
                        JSONObject jSONObject = new JSONObject(stringBuffer.toString());
                        if (jSONObject.get("status").toString().equals("200")) {
                            Main1Activity.this.handler.handleMessage(Message.obtain(Main1Activity.this.handler, 10, jSONObject.getString(e.m)));
                        }
                    } else {
                        System.out.println(responseCode);
                    }
                    httpsURLConnection.disconnect();
                } catch (Exception e) {
                    Log.e("e:", String.valueOf(e));
                }
            }
        }).start();
    }

    public void OpenUrl(String str) {
        try {
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(Uri.parse(str));
            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setStatusBarColor(Activity activity, int i) {
        int i2;
        switch (i) {
            case 919:
                i2 = R.color.colorUser;
                break;
            case 920:
                i2 = R.color.colorCulture;
                break;
            case 921:
                i2 = R.color.colorWallet;
                break;
            case 922:
                i2 = R.color.colorTeam;
                break;
            case 923:
                i2 = R.color.colorUser;
                break;
            case 924:
                i2 = R.color.colorWhite;
                break;
            default:
                i2 = R.color.colorUser;
                break;
        }
        if (i == 923) {
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.web_view.getLayoutParams();
            layoutParams.topMargin = 0;
            this.web_view.setLayoutParams(layoutParams);
            ImmersionBar.with(activity).reset().navigationBarEnable(false).statusBarDarkFont(true).navigationBarDarkIcon(true).init();
            Log.e("statusbar", "home");
            return;
        }
        LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.web_view.getLayoutParams();
        layoutParams2.topMargin = this.pdheight;
        Log.e("height", "" + this.pdheight + "");
        this.web_view.setLayoutParams(layoutParams2);
        ImmersionBar.with(activity).reset().statusBarColor(i2).navigationBarEnable(false).statusBarDarkFont(true).navigationBarDarkIcon(true).init();
    }

    private class JavaScriptInterface {
        JavaScriptInterface() {
        }

        @JavascriptInterface
        public void tapBuy(String str) {
            Log.e("tapbuy", str);
            final ExtendMap<String, Object> parseMapData = ResponseParse.parseMapData(ResponseParse.parseMapData(str).getString(l.c));
            DisplayUtil.return_url_1 = parseMapData.getString("return_url");
            DisplayUtil.return_url_s = parseMapData.getString("user_url");
            DisplayUtil.pay_type_v = parseMapData.getInt("pay_type");
            Main1Activity.this.PAY_BACK_URL = parseMapData.getString("return_url");
            if (DisplayUtil.pay_type_v == 1) {
                Intent intent = new Intent(Main1Activity.this, (Class<?>) NullActivity.class);
                DisplayUtil.type = ResponseParse.parseMapData(parseMapData.getString(e.m)).getInt("type");
                intent.putExtra("json", parseMapData.getString(e.m));
                Log.e("gotopay:", parseMapData.getString(e.m));
                Main1Activity.this.startActivity(intent);
                return;
            }
            if (DisplayUtil.pay_type_v == 7) {
                IWXAPI createWXAPI = WXAPIFactory.createWXAPI(Main1Activity.this, parseMapData.getString(AlipayApi.c));
                WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
                req.userName = parseMapData.getString("miniAppId");
                req.path = parseMapData.getString("path");
                req.miniprogramType = 0;
                createWXAPI.sendReq(req);
                return;
            }
            if (DisplayUtil.pay_type_v == 8) {
                try {
                    Main1Activity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("alipays://platformapi/startapp?appId=" + parseMapData.getString("miniAppId") + "&page=" + Main1Activity.this.urlEncode(parseMapData.getString("path")))));
                    Main1Activity.this.web_view.post(new Runnable() {
                        @Override
                        public void run() {
                            Main1Activity.this.web_view.loadUrl(parseMapData.getString("user_url"));
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                    Toast.makeText(Main1Activity.this, "请先安装支付宝客户端", 0).show();
                }
            }
        }

        @JavascriptInterface
        public void tapQuit() {
            System.exit(0);
        }

        @JavascriptInterface
        public void tapCheckVer() {
            Main1Activity.this.SHOW_CHECKVER = 1;
            Main1Activity.this.checkVersion();
        }

        @JavascriptInterface
        public void startRecording(String str) {
            Log.i("startRecording", "开始录音");
            Main1Activity.this.upload_voice_uid = str;
            if (ActivityCompat.checkSelfPermission(Main1Activity.this, "android.permission.RECORD_AUDIO") != 0) {
                ActivityCompat.requestPermissions(Main1Activity.this, new String[]{"android.permission.RECORD_AUDIO"}, 10);
            } else {
                Main1Activity.this.startNewRecord();
            }
        }

        @JavascriptInterface
        public void stopRecording(String str) {
            Log.i("stopRecording", "停止录音");
            Main1Activity.this.stopNewRecord(str);
        }

        @JavascriptInterface
        public void setToken(String str) {
            try {
                FileOutputStream openFileOutput = Main1Activity.this.openFileOutput(Main1Activity.LOCAL_CACHE_TOKEN, 0);
                openFileOutput.write(str.getBytes());
                openFileOutput.close();
                Log.e("write", str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }

        @android.webkit.JavascriptInterface
        public void getToken() {
            throw new UnsupportedOperationException("Method not decompiled: com.cscmjy.youlimall.Main1Activity.JavaScriptInterface.getToken():void");
        }

        @JavascriptInterface
        public void setDISKRIVILEGES(String str) {
            try {
                FileOutputStream openFileOutput = Main1Activity.this.openFileOutput(Main1Activity.LOCAL_CACHE_DISKALLOW, 0);
                openFileOutput.write(str.getBytes());
                openFileOutput.close();
                Log.e("write", str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }

        @android.webkit.JavascriptInterface
        public void getDISKPRIVILEGES() {
            throw new UnsupportedOperationException("Method not decompiled: com.cscmjy.youlimall.Main1Activity.JavaScriptInterface.getDISKPRIVILEGES():void");
        }

        @JavascriptInterface
        public void setRememberAP(String str) {
            Log.e("cacheUsername", str);
            try {
                FileOutputStream openFileOutput = Main1Activity.this.openFileOutput(Main1Activity.LOCAL_CACHE_USERNAME, 0);
                openFileOutput.write(str.getBytes());
                openFileOutput.close();
                Log.e("write", str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }

        @JavascriptInterface
        public void getRememberAP() {
            BufferedReader bufferedReader;
            IOException e;
            FileNotFoundException e2;
            BufferedReader bufferedReader2 = null;
            try {
            } catch (Throwable th) {
                th = th;
            }
            try {
                try {
                    bufferedReader = new BufferedReader(new InputStreamReader(Main1Activity.this.openFileInput(Main1Activity.LOCAL_CACHE_USERNAME)));
                } catch (IOException e3) {
                    e3.printStackTrace();
                }
                try {
                    StringBuffer stringBuffer = new StringBuffer();
                    while (true) {
                        String readLine = bufferedReader.readLine();
                        if (readLine == null) {
                            break;
                        } else {
                            stringBuffer.append(readLine);
                        }
                    }
                    String stringBuffer2 = stringBuffer.toString();
                    if (stringBuffer2 != "") {
                        Log.e("androidGetAPCallBack", stringBuffer2);
                        final String str = "javascript:androidGetAPCallBack('" + stringBuffer2 + "')";
                        Main1Activity.this.web_view.post(new Runnable() {
                            @Override
                            public void run() {
                                Main1Activity.this.web_view.loadUrl(str);
                            }
                        });
                    }
                    bufferedReader.close();
                } catch (FileNotFoundException e4) {
                    e2 = e4;
                    e2.printStackTrace();
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                } catch (IOException e5) {
                    e = e5;
                    e.printStackTrace();
                    if (bufferedReader != null) {
                        bufferedReader.close();
                    }
                }
            } catch (FileNotFoundException e6) {
                bufferedReader = null;
                e2 = e6;
            } catch (IOException e7) {
                bufferedReader = null;
                e = e7;
            } catch (Throwable th2) {
                th = th2;
                if (0 != 0) {
                    try {
                        bufferedReader2.close();
                    } catch (IOException e8) {
                        e8.printStackTrace();
                    }
                }
                throw th;
            }
        }

        @JavascriptInterface
        public void setCameraPrivileves(String str) {
            try {
                FileOutputStream openFileOutput = Main1Activity.this.openFileOutput(Main1Activity.LOCAL_CACHE_CAMERA, 0);
                openFileOutput.write(str.getBytes());
                openFileOutput.close();
                Log.e("write", str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }

        @android.webkit.JavascriptInterface
        public void getCameraPrivileges() {
            throw new UnsupportedOperationException("Method not decompiled: com.cscmjy.youlimall.Main1Activity.JavaScriptInterface.getCameraPrivileges():void");
        }

        @JavascriptInterface
        public void setLOCPRIVILEGES(String str) {
            try {
                FileOutputStream openFileOutput = Main1Activity.this.openFileOutput(Main1Activity.LOCAL_CACHE_PRIVILEGES, 0);
                openFileOutput.write(str.getBytes());
                openFileOutput.close();
                Log.e("write", str);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
        }

        @android.webkit.JavascriptInterface
        public void getLOCPRIVILEGES() {
            throw new UnsupportedOperationException("Method not decompiled: com.cscmjy.youlimall.Main1Activity.JavaScriptInterface.getLOCPRIVILEGES():void");
        }

        @JavascriptInterface
        public void refreshSite() {
            StringBuilder append = new StringBuilder().append(Main1Activity.HOST_DOMAIN).append("?uuid=");
            Main1Activity main1Activity = Main1Activity.this;
            final String sb = append.append(main1Activity.getAndroidID(main1Activity)).append("&mr=").append(Math.random()).toString();
            Main1Activity.this.web_view.post(new Runnable() {
                @Override
                public void run() {
                    Main1Activity.this.web_view.clearCache(true);
                    Main1Activity.this.web_view.loadUrl(sb);
                }
            });
        }

        @JavascriptInterface
        public void scanQrcode() {
            Main1Activity.this.doScan();
        }

        @JavascriptInterface
        public void checkKeyboard() {
            View findViewById = Main1Activity.this.getWindow().getDecorView().findViewById(R.id.web_view);
            int height = findViewById.getRootView().getHeight();
            boolean isKeyboardShown = Main1Activity.isKeyboardShown(findViewById);
            int keyboardHeight = Main1Activity.getKeyboardHeight(findViewById);
            Log.e("keyboard info=>", "keyboardHeight=>" + keyboardHeight + " isKeyboardShown=>" + isKeyboardShown);
            Log.e("keyboard info=>", "keyboardHeight=>" + keyboardHeight + " isKeyboardShown=>" + isKeyboardShown);
            final String str = "javascript:setKeybordHeight('" + keyboardHeight + "','" + height + "')";
            Main1Activity.this.web_view.post(new Runnable() {
                @Override
                public void run() {
                    Main1Activity.this.web_view.loadUrl(str);
                }
            });
        }

        @JavascriptInterface
        public void getNowVersion() {
            final String str = "javascript:setNowVersion('1.4.6')";
            Main1Activity.this.web_view.post(new Runnable() {
                @Override
                public void run() {
                    Main1Activity.this.web_view.loadUrl(str);
                }
            });
        }

        @JavascriptInterface
        public void hiddenKeyboard() {
            InputMethodManager inputMethodManager = (InputMethodManager) Main1Activity.this.getSystemService("input_method");
            View currentFocus = Main1Activity.this.getCurrentFocus();
            if (currentFocus != null) {
                inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
            }
        }

        @JavascriptInterface
        public void getLocation() {
            Log.e("startlocation", "-->");
            Main1Activity main1Activity = Main1Activity.this;
            if (!main1Activity.isGpsAble(main1Activity.lm)) {
                Toast.makeText(Main1Activity.this, "请打开定位权限", 0).show();
                Main1Activity.this.openGPS2();
            }
            if (ContextCompat.checkSelfPermission(Main1Activity.this, "android.permission.ACCESS_FINE_LOCATION") != 0) {
                ActivityCompat.requestPermissions(Main1Activity.this, new String[]{"android.permission.ACCESS_FINE_LOCATION"}, 200);
            } else {
                Main1Activity.this.startLocation();
            }
        }

        @JavascriptInterface
        public void openNav(String str) {
            Log.e("navtext", str);
            String[] split = str.split("\\|");
            String str2 = split[0];
            if (str2.equals("gaode")) {
                Main1Activity.this.openGaode(split[4], Double.parseDouble(split[5]), Double.parseDouble(split[6]));
            } else if (str2.equals("baidu")) {
                Main1Activity.this.openBaidu(split[4], Double.parseDouble(split[5]), Double.parseDouble(split[6]));
            } else if (str2.equals("tengxun")) {
                Main1Activity.this.openTengxun(split[4], Double.parseDouble(split[5]), Double.parseDouble(split[6]));
            }
        }

        @JavascriptInterface
        public void setBarColor(String str) {
            Log.e("colortext", str);
            if (str.equals("colorUser")) {
                Log.e("user", "2");
                Main1Activity main1Activity = Main1Activity.this;
                main1Activity.sendHandlerMessage(919, main1Activity.handler);
            } else if (str.equals("colorWhite")) {
                Log.e("user", "2");
                Main1Activity main1Activity2 = Main1Activity.this;
                main1Activity2.sendHandlerMessage(924, main1Activity2.handler);
            } else if (str.equals("colorHome")) {
                Log.e("user", "home");
                Main1Activity main1Activity3 = Main1Activity.this;
                main1Activity3.sendHandlerMessage(923, main1Activity3.handler);
            } else {
                Main1Activity main1Activity4 = Main1Activity.this;
                main1Activity4.sendHandlerMessage(918, main1Activity4.handler);
            }
        }

        @JavascriptInterface
        public void tapCopy(String str) {
            ((ClipboardManager) Main1Activity.this.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", str));
            Toast.makeText(Main1Activity.this, "内容已复制到粘贴板", 0).show();
        }

        @JavascriptInterface
        public void callPhone(String str) {
            Log.e("callPhone", str);
            Intent intent = new Intent("android.intent.action.DIAL");
            intent.setData(Uri.parse("tel:" + str));
            Main1Activity.this.startActivity(intent);
        }

        @JavascriptInterface
        public void tapOpenUrl(String str) {
            try {
                Intent intent = new Intent("android.intent.action.VIEW");
                intent.setData(Uri.parse(str));
                Main1Activity.this.startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        @JavascriptInterface
        public void tapWeixinPay(String str, String str2, String str3) {
            Log.e("wxpay", str + " >> " + str2 + " >> " + str3);
            IWXAPI createWXAPI = WXAPIFactory.createWXAPI(Main1Activity.this, str);
            WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
            req.userName = str2;
            req.path = str3;
            req.miniprogramType = 0;
            createWXAPI.sendReq(req);
            Log.e("minifq", "end");
        }

        public boolean hasPreferredApplication(Context context, Intent intent) {
            return !"android".equals(context.getPackageManager().resolveActivity(intent, 65536).activityInfo.packageName);
        }

        @JavascriptInterface
        public void openTeam(String str) {
            Log.e("zuoquan", "vaule2");
        }

        @JavascriptInterface
        public void saveImage(String str) {
            Log.e("zuoquan", str);
            if (TextUtils.isEmpty(str)) {
                Toast.makeText(Main1Activity.this, "图片链接为空", 0).show();
            } else {
                Main1Activity.this.checkPermission();
                SaveImageUtils.donwloadImg(Main1Activity.this, str);
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LocalWebServer localWebServer = localwebserver;
        if (localWebServer != null) {
            localWebServer.stop();
        }
        EventBus.getDefault().unregister(this);
    }

    public void checkPermission() {
        if (Build.VERSION.SDK_INT >= 30 && !Environment.isExternalStorageManager()) {
            startActivity(new Intent("android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION"));
        }
        if (ActivityCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
                Toast.makeText(this, "请允许访问存储,方便保存图片", 0).show();
            }
            ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, REQUEST_PERMISSION_CODE);
            return;
        }
        Log.e("zuoquan", "checkPermission: 已经授权!");
    }

    public String getAndroidID(Context context) {
        String string = Settings.Secure.getString(context.getContentResolver(), "android_id");
        return string == null ? "" : string;
    }

    @Override
    protected void onActivityResult(int i, int i2, Intent intent) {
        ValueCallback<Uri[]> valueCallback;
        if (i == 49374) {
            IntentResult parseActivityResult = IntentIntegrator.parseActivityResult(i, i2, intent);
            if (parseActivityResult != null) {
                if (parseActivityResult.getContents() == null) {
                    Toast.makeText(this, "没有扫码到任何内容", 0).show();
                    return;
                } else {
                    this.web_view.loadUrl("javascript:androidScanCallBack('" + (parseActivityResult.getContents() + "\n") + "')");
                    return;
                }
            }
            super.onActivityResult(i, i2, intent);
            return;
        }
        super.onActivityResult(i, i2, intent);
        if (i != 100 || (valueCallback = this.uploadMessage) == null) {
            return;
        }
        valueCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(i2, intent));
        this.uploadMessage = null;
    }

    public UIData crateUIData(String str, String str2, String str3) {
        UIData create = UIData.create();
        create.setDownloadUrl(str2);
        create.setContent(str);
        create.setTitle(str3);
        return create;
    }

    public void sendHandlerMessage(int i, Handler handler) {
        Message message = new Message();
        message.what = i;
        handler.sendMessage(message);
    }

    public CustomVersionDialogListener createCustomDialog(final boolean z) {
        return new CustomVersionDialogListener() {
            @Override
            public final Dialog getCustomVersionDialog(Context context, UIData uIData) {
                return Main1Activity.lambda$createCustomDialog$0(z, context, uIData);
            }
        };
    }

    static Dialog lambda$createCustomDialog$0(boolean z, Context context, UIData uIData) {
        MyDialog myDialog = new MyDialog(context, R.style.MyDialog, R.layout.dialog_my_layout);
        ((TextView) myDialog.findViewById(R.id.tv_msg)).setText(uIData.getContent());
        ((TextView) myDialog.findViewById(R.id.tvVersion)).setText(uIData.getTitle());
        myDialog.setCanceledOnTouchOutside(z);
        myDialog.setCancelable(z);
        ((TextView) myDialog.findViewById(R.id.versionchecklib_version_dialog_cancel)).setVisibility(0);
        return myDialog;
    }

    public CustomDownloadingDialogListener createCustomDownloadingDialog() {
        return new CustomDownloadingDialogListener() {
            @Override
            public Dialog getCustomDownloadingDialog(Context context, int i, UIData uIData) {
                MyDialog myDialog = new MyDialog(context, R.style.MyDialog, R.layout.dialog_my_progress);
                myDialog.setCanceledOnTouchOutside(true);
                return myDialog;
            }

            @Override
            public void updateUI(final Dialog dialog, int i, UIData uIData) {
                TextView textView = (TextView) dialog.findViewById(R.id.tv_msg);
                ((ProgressBar) dialog.findViewById(R.id.pb)).setProgress(i);
                textView.setText(i + "%");
                TextView textView2 = (TextView) dialog.findViewById(R.id.jump);
                textView2.setVisibility(8);
                textView2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        dialog.dismiss();
                    }
                });
            }
        };
    }
}