导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - SettingActivity.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 SettingActivity.java JAVA 源代码文件

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


package com.luanxingyuan.app.activity;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.content.FileProvider;
import butterknife.BindView;
import butterknife.OnClick;
import com.faceunity.wrapper.faceunity;
import com.luanxingyuan.app.base.AppManager;
import com.luanxingyuan.app.base.BaseActivity;
import com.luanxingyuan.app.base.BaseResponse;
import com.luanxingyuan.app.bean.UpdateBean;
import com.luanxingyuan.app.util.FileUtil;
import com.luanxingyuan.app.util.LogUtil;
import com.luanxingyuan.app.util.MyDataCleanManager;
import com.luanxingyuan.app.util.ParamUtil;
import com.luanxingyuan.app.util.ToastUtil;
import com.tencent.open.SocialConstants;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import o6.n;

public class SettingActivity extends BaseActivity {

    @BindView
    TextView mCacheNumberTv;

    @BindView
    TextView mCheckTv;

    @BindView
    ImageView mSoundGroupIv;

    @BindView
    ImageView mSoundIv;

    @BindView
    ImageView mVibrateGroupIv;

    @BindView
    ImageView mVibrateIv;
    private g mHandler = new g(this);
    private final int DONE = 1;

    class a extends Thread {
        a() {
        }

        @Override
        public void run() {
            try {
                MyDataCleanManager.clearAllCache(SettingActivity.this.getApplicationContext());
                SettingActivity.this.mHandler.sendEmptyMessage(1);
            } catch (Exception e8) {
                e8.printStackTrace();
            }
        }
    }

    class b extends r6.a<BaseResponse<UpdateBean>> {
        b() {
        }

        @Override
        public void onError(x8.e eVar, Exception exc, int i8) {
            super.onError(eVar, exc, i8);
            ToastUtil.showToast(SettingActivity.this.getApplicationContext(), 2131821363);
            SettingActivity.this.dismissLoadingDialog();
        }

        public void onResponse(BaseResponse<UpdateBean> baseResponse, int i8) {
            UpdateBean updateBean;
            SettingActivity.this.dismissLoadingDialog();
            if (baseResponse == null || baseResponse.m_istatus != 1 || (updateBean = baseResponse.m_object) == null) {
                return;
            }
            String str = updateBean.t_version;
            if (TextUtils.isEmpty(str) || TextUtils.isEmpty("8.1.1")) {
                return;
            }
            if ("8.1.1".equals(str)) {
                ToastUtil.showToast(SettingActivity.this.getApplicationContext(), 2131820618);
            } else {
                SettingActivity.this.showUpdateDialog(updateBean);
            }
        }
    }

    class c implements View.OnClickListener {

        final Dialog f6986a;

        final UpdateBean f6987b;

        final TextView f6988c;

        c(Dialog dialog, UpdateBean updateBean, TextView textView) {
            this.f6986a = dialog;
            this.f6987b = updateBean;
            this.f6988c = textView;
        }

        @Override
        public void onClick(View view) {
            this.f6986a.setCancelable(false);
            SettingActivity.this.downloadApkFile(this.f6987b, this.f6986a, this.f6988c);
        }
    }

    class d extends z7.b {

        final TextView f6990c;

        final Dialog f6991d;

        d(String str, String str2, TextView textView, Dialog dialog) {
            super(str, str2);
            this.f6990c = textView;
            this.f6991d = dialog;
        }

        public void onResponse(File file, int i8) {
            try {
                this.f6991d.dismiss();
                if (file != null && file.exists() && file.isFile()) {
                    SettingActivity.this.checkIsAndroidO(file);
                } else {
                    ToastUtil.showToast(SettingActivity.this.getApplicationContext(), 2131821399);
                }
            } catch (Exception e8) {
                e8.printStackTrace();
                this.f6991d.dismiss();
                ToastUtil.showToast(SettingActivity.this.getApplicationContext(), 2131821399);
            }
        }

        public void inProgress(float f8, long j8, int i8) {
            super/*z7.a*/.inProgress(f8, j8, i8);
            this.f6990c.setText(((int) (f8 * 100.0f)) + SettingActivity.this.getResources().getString(2131821142));
        }

        public void onError(x8.e eVar, Exception exc, int i8) {
        }
    }

    class e implements View.OnClickListener {

        final Dialog f6993a;

        e(Dialog dialog) {
            this.f6993a = dialog;
        }

        @Override
        public void onClick(View view) {
            this.f6993a.dismiss();
        }
    }

    class f implements View.OnClickListener {

        final Dialog f6995a;

        f(Dialog dialog) {
            this.f6995a = dialog;
        }

        @Override
        public void onClick(View view) {
            if (Build.VERSION.SDK_INT >= 26) {
                SettingActivity.this.startActivityForResult(new Intent("android.settings.MANAGE_UNKNOWN_APP_SOURCES"), 10086);
            }
            this.f6995a.dismiss();
        }
    }

    private static class g extends Handler {

        private WeakReference<SettingActivity> f6997a;

        g(SettingActivity settingActivity) {
            this.f6997a = new WeakReference<>(settingActivity);
        }

        @Override
        public void handleMessage(Message message) {
            super.handleMessage(message);
            SettingActivity settingActivity = this.f6997a.get();
            if (settingActivity != null) {
                settingActivity.clearDone();
                settingActivity.dismissLoadingDialog();
            }
        }
    }

    public void checkIsAndroidO(File file) {
        boolean canRequestPackageInstalls;
        if (Build.VERSION.SDK_INT < 26) {
            installApk(file);
            return;
        }
        canRequestPackageInstalls = getPackageManager().canRequestPackageInstalls();
        LogUtil.i("=====未知来源安装权限: " + canRequestPackageInstalls);
        if (canRequestPackageInstalls) {
            installApk(file);
        } else {
            showUnkownPermissionDialog();
        }
    }

    private void checkUpdate() {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        x7.a.h().c(m6.a.X()).e("param", ParamUtil.getParam(hashMap)).f().c(new b());
    }

    public void clearDone() {
        this.mCacheNumberTv.setText(getResources().getString(2131820703));
        ToastUtil.showToast(getApplicationContext(), 2131820755);
    }

    public void downloadApkFile(UpdateBean updateBean, Dialog dialog, TextView textView) {
        String str = updateBean.t_download_url;
        if (TextUtils.isEmpty(str)) {
            ToastUtil.showToast(getApplicationContext(), 2131821399);
            return;
        }
        File file = new File(FileUtil.YCHAT_DIR);
        if (file.exists() || file.mkdir()) {
            String str2 = m6.b.f15477n;
            File file2 = new File(str2);
            if (file2.exists()) {
                FileUtil.deleteFiles(file2.getPath());
            } else if (!file2.mkdir()) {
                return;
            }
            x7.a.c().c(str).f().c(new d(str2, "chatNew.apk", textView, dialog));
        }
    }

    private void initView() {
        this.mSoundIv.setSelected(n.n(getApplicationContext()));
        this.mSoundGroupIv.setSelected(n.o(getApplicationContext()));
        this.mVibrateIv.setSelected(n.p(getApplicationContext()));
        this.mVibrateGroupIv.setSelected(n.q(getApplicationContext()));
        if (!TextUtils.isEmpty("8.1.1")) {
            this.mCheckTv.setText("8.1.1(202508021)");
        }
        try {
            this.mCacheNumberTv.setText(MyDataCleanManager.getTotalCacheSize(getApplicationContext()));
            this.mCacheNumberTv.setVisibility(0);
        } catch (Exception e8) {
            e8.printStackTrace();
        }
    }

    private void installApk(File file) {
        Intent intent = new Intent("android.intent.action.VIEW");
        if (Build.VERSION.SDK_INT >= 24) {
            intent.setFlags(faceunity.FUAITYPE_HUMAN_PROCESSOR_DETECT);
            Uri uriForFile = FileProvider.getUriForFile(getApplicationContext(), getPackageName() + ".fileProvider", file);
            intent.addFlags(1);
            intent.setDataAndType(uriForFile, "application/vnd.android.package-archive");
        } else {
            intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
        }
        startActivity(intent);
    }

    private void setUnkownDialogView(View view, Dialog dialog) {
        ((TextView) view.findViewById(2131296454)).setOnClickListener(new e(dialog));
        ((TextView) view.findViewById(2131297231)).setOnClickListener(new f(dialog));
    }

    private void setUpdateDialogView(View view, Dialog dialog, UpdateBean updateBean) {
        TextView textView = (TextView) view.findViewById(2131296608);
        String str = updateBean.t_version_depict;
        if (!TextUtils.isEmpty(str)) {
            textView.setText(str);
        }
        TextView textView2 = (TextView) view.findViewById(2131297397);
        textView2.setOnClickListener(new c(dialog, updateBean, textView2));
    }

    private void showUnkownPermissionDialog() {
        Dialog dialog = new Dialog(this, 2131886281);
        View inflate = LayoutInflater.from(this).inflate(2131493079, (ViewGroup) null);
        setUnkownDialogView(inflate, dialog);
        dialog.setContentView(inflate);
        Point point = new Point();
        getWindowManager().getDefaultDisplay().getSize(point);
        Window window = dialog.getWindow();
        if (window != null) {
            window.getAttributes().width = point.x;
            window.setGravity(17);
        }
        dialog.setCanceledOnTouchOutside(false);
        if (isFinishing()) {
            return;
        }
        dialog.show();
    }

    public void showUpdateDialog(UpdateBean updateBean) {
        Dialog dialog = new Dialog(this, 2131886281);
        View inflate = LayoutInflater.from(this).inflate(2131493085, (ViewGroup) null);
        setUpdateDialogView(inflate, dialog, updateBean);
        dialog.setContentView(inflate);
        Point point = new Point();
        getWindowManager().getDefaultDisplay().getSize(point);
        Window window = dialog.getWindow();
        if (window != null) {
            window.getAttributes().width = point.x;
            window.setGravity(17);
        }
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(false);
        if (isFinishing()) {
            return;
        }
        dialog.show();
    }

    public void clearAppCache() {
        new a().start();
    }

    @Override
    protected View getContentView() {
        return inflate(2131492963);
    }

    @Override
    public void onActivityResult(int i8, int i9, Intent intent) {
        boolean canRequestPackageInstalls;
        super.onActivityResult(i8, i9, intent);
        if (i8 != 10086 || Build.VERSION.SDK_INT < 26) {
            return;
        }
        canRequestPackageInstalls = getPackageManager().canRequestPackageInstalls();
        File file = new File(m6.b.f15477n, "chatNew.apk");
        if (file.exists() && canRequestPackageInstalls) {
            installApk(file);
        }
    }

    @OnClick
    public void onClick(View view) {
        switch (view.getId()) {
            case 2131296347:
                Intent intent = new Intent(getApplicationContext(), (Class<?>) CommonWebViewActivity.class);
                intent.putExtra("title", getResources().getString(2131820606));
                intent.putExtra(SocialConstants.PARAM_URL, "file:///android_asset/agree.html");
                startActivity(intent);
                break;
            case 2131296405:
                startActivity(new Intent(this, (Class<?>) BlackListActivity.class));
                break;
            case 2131296493:
                showLoadingDialog();
                checkUpdate();
                break;
            case 2131296500:
                showLoadingDialog();
                clearAppCache();
                break;
            case 2131296661:
                AppManager.f().c(null, false);
                break;
            case 2131296787:
                startActivity(new Intent(this, (Class<?>) HelpCenterActivity.class));
                break;
            case 2131297023:
                startActivity(new Intent(getApplicationContext(), (Class<?>) OpinionActivity.class));
                break;
            case 2131297087:
                Intent intent2 = new Intent(getApplicationContext(), (Class<?>) CommonWebViewActivity.class);
                intent2.putExtra("title", getResources().getString(2131821217));
                intent2.putExtra(SocialConstants.PARAM_URL, "file:///android_asset/private.html");
                startActivity(intent2);
                break;
            case 2131297247:
                this.mSoundGroupIv.setSelected(!r5.isSelected());
                n.H(getApplicationContext(), this.mSoundGroupIv.isSelected());
                o6.l.f();
                break;
            case 2131297248:
                this.mSoundIv.setSelected(!r5.isSelected());
                n.G(getApplicationContext(), this.mSoundIv.isSelected());
                o6.l.f();
                break;
            case 2131297415:
                this.mVibrateGroupIv.setSelected(!r5.isSelected());
                n.J(getApplicationContext(), this.mVibrateGroupIv.isSelected());
                o6.l.f();
                break;
            case 2131297416:
                this.mVibrateIv.setSelected(!r5.isSelected());
                n.I(getApplicationContext(), this.mVibrateIv.isSelected());
                o6.l.f();
                break;
            case 2131297495:
                startActivity(new Intent(this, (Class<?>) YoungModeActivity.class));
                break;
        }
    }

    @Override
    protected void onContentAdded() {
        setTitle(2131821311);
        initView();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        g gVar = this.mHandler;
        if (gVar != null) {
            gVar.removeCallbacksAndMessages(null);
            this.mHandler = null;
        }
    }
}