导航菜单

页面标题

页面副标题

Fancy Optimizer v4.6.3 - RuntimePermissionRequestActivity.java 源代码

正在查看: Fancy Optimizer v4.6.3 应用的 RuntimePermissionRequestActivity.java JAVA 源代码文件

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


package com.thinkyeah.common.runtimepermissionguide.ui;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.tapjoy.sdk.R;
import com.thinkyeah.common.ui.dialog.c;
import com.thinkyeah.common.ui.view.TitleBar;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import qk.b;
import vj.h;
import wk.d;

public class RuntimePermissionRequestActivity extends d {
    public static final h p = h.f(RuntimePermissionRequestActivity.class);
    public String[] l;
    public ArrayList m;
    public ArrayList n;

    @StringRes
    public int o;

    public static class a extends c<RuntimePermissionRequestActivity> {

        public class DialogInterfaceOnClickListenerC0014a implements DialogInterface.OnClickListener {
            public DialogInterfaceOnClickListenerC0014a() {
            }

            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ?? r1 = (RuntimePermissionRequestActivity) a.this.getActivity();
                if (r1.isFinishing()) {
                    return;
                }
                r1.T2("SuggestGrantRuntimePermissionDialogFragment");
                r1.X2(false);
            }
        }

        public class b implements DialogInterface.OnClickListener {
            public b() {
            }

            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ?? r1 = (RuntimePermissionRequestActivity) a.this.getActivity();
                if (r1.isFinishing()) {
                    return;
                }
                h hVar = RuntimePermissionRequestActivity.p;
                r1.Y2();
            }
        }

        @NonNull
        public final Dialog onCreateDialog(Bundle bundle) {
            int i = getArguments().getInt("arg_key_title");
            c.a aVar = new c.a(getActivity());
            aVar.g(2131886958);
            aVar.k = getString(2131887387, new Object[]{getString(i)});
            aVar.e(2131886957, new b());
            aVar.d(R.string.cancel, new DialogInterfaceOnClickListenerC0014a());
            return aVar.a();
        }
    }

    public final void X2(boolean z) {
        ArrayList<String> arrayList = this.m;
        ArrayList<String> arrayList2 = this.n;
        h hVar = ok.a.f;
        Intent intent = new Intent(getPackageName() + ".RUNTIME_PERMISSION_RESULT");
        intent.setPackage(getPackageName());
        intent.putStringArrayListExtra("granted_runtime_permission", arrayList);
        intent.putStringArrayListExtra("denied_runtime_permission", arrayList2);
        intent.putExtra("permission_request_result", z);
        LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
        if (z) {
            for (String str : this.l) {
                String str2 = "choose_always_denied_" + ok.a.b(str).e;
                SharedPreferences sharedPreferences = getSharedPreferences("runtime_permission", 0);
                SharedPreferences.Editor edit = sharedPreferences == null ? null : sharedPreferences.edit();
                if (edit != null) {
                    edit.putBoolean(str2, false);
                    edit.apply();
                }
            }
        }
        finish();
    }

    public final void Y2() {
        boolean z;
        String[] strArr = this.l;
        int length = strArr.length;
        int i = 0;
        while (true) {
            if (i >= length) {
                z = false;
                break;
            }
            String str = "choose_always_denied_" + ok.a.b(strArr[i]).e;
            SharedPreferences sharedPreferences = getSharedPreferences("runtime_permission", 0);
            if (sharedPreferences == null ? false : sharedPreferences.getBoolean(str, false)) {
                z = true;
                break;
            }
            i++;
        }
        if (!z) {
            ActivityCompat.requestPermissions(this, this.l, 11145);
            return;
        }
        Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", Uri.fromParts("package", getPackageName(), null));
        intent.addCategory("android.intent.category.DEFAULT");
        startActivityForResult(intent, 11145);
        ArrayList arrayList = new ArrayList();
        for (String str2 : this.l) {
            arrayList.add(ok.a.b(str2));
        }
        new Handler().postDelayed(new b(this, arrayList), 500L);
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        if (i != 11145) {
            super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i2, intent);
            return;
        }
        String[] strArr = this.l;
        int length = strArr.length;
        boolean z = false;
        int i3 = 0;
        while (true) {
            if (i3 >= length) {
                z = true;
                break;
            } else if (ContextCompat.checkSelfPermission(this, strArr[i3]) != 0) {
                break;
            } else {
                i3++;
            }
        }
        X2(z);
    }

    @Override
    public final void onCreate(Bundle bundle) {
        boolean z;
        super.onCreate(bundle);
        Intent intent = getIntent();
        if (intent == null) {
            finish();
            return;
        }
        this.l = intent.getStringArrayExtra("key_permission_groups");
        this.o = intent.getIntExtra("key_from_activity", 0);
        if (this.l == null) {
            return;
        }
        this.m = new ArrayList();
        this.n = new ArrayList();
        String[] strArr = this.l;
        int length = strArr.length;
        int i = 0;
        while (true) {
            if (i >= length) {
                z = true;
                break;
            } else {
                if (ContextCompat.checkSelfPermission(this, strArr[i]) != 0) {
                    z = false;
                    break;
                }
                i++;
            }
        }
        if (z) {
            this.m.addAll(Arrays.asList(this.l));
            X2(true);
            return;
        }
        boolean booleanExtra = intent.getBooleanExtra("transparent_mode", false);
        if (!booleanExtra) {
            setTheme(2131952025);
        }
        setContentView(2131558513);
        int intExtra = intent.getIntExtra("background_color", 0);
        if (intExtra != 0) {
            findViewById(2131362104).setBackgroundColor(intExtra);
        }
        if (booleanExtra) {
            findViewById(2131363196).setVisibility(8);
            findViewById(2131362104).setBackgroundColor(ContextCompat.getColor(this, 2131100637));
        } else {
            ArrayList arrayList = new ArrayList();
            TitleBar.a configure = ((TitleBar) findViewById(2131363196)).getConfigure();
            configure.e(this.o);
            configure.g(new qk.a(this));
            TitleBar titleBar = TitleBar.this;
            titleBar.h = arrayList;
            titleBar.z = 0.0f;
            configure.a();
        }
        if (!getIntent().getBooleanExtra("show_suggestion_dialog", true)) {
            Y2();
            return;
        }
        int i2 = this.o;
        a aVar = new a();
        Bundle bundle2 = new Bundle();
        bundle2.putInt("arg_key_title", i2);
        aVar.setArguments(bundle2);
        aVar.setCancelable(false);
        aVar.j0(this, "SuggestGrantRuntimePermissionDialogFragment");
    }

    public final void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
        super/*androidx.fragment.app.FragmentActivity*/.onRequestPermissionsResult(i, strArr, iArr);
        h hVar = p;
        hVar.c("==> onRequestPermissionsResult");
        if (i == 11145) {
            for (int i2 = 0; i2 < iArr.length; i2++) {
                if (iArr[i2] == 0) {
                    this.m.add(strArr[i2]);
                } else {
                    this.n.add(strArr[i2]);
                }
            }
            ArrayList arrayList = this.n;
            if (arrayList == null || arrayList.isEmpty()) {
                hVar.c("All perms granted");
                X2(true);
                return;
            }
            Iterator it = this.n.iterator();
            while (it.hasNext()) {
                String str = (String) it.next();
                if (ActivityCompat.shouldShowRequestPermissionRationale(this, str)) {
                    hVar.c("Perms denied");
                } else {
                    hVar.c("Choose Don't Ask Again");
                    String str2 = "choose_always_denied_" + ok.a.b(str).e;
                    SharedPreferences sharedPreferences = getSharedPreferences("runtime_permission", 0);
                    SharedPreferences.Editor edit = sharedPreferences == null ? null : sharedPreferences.edit();
                    if (edit != null) {
                        edit.putBoolean(str2, true);
                        edit.apply();
                    }
                }
            }
            X2(false);
        }
    }
}