导航菜单

页面标题

页面副标题

Hopscotch v9.7.2 - InAppNotificationActivity.java 源代码

正在查看: Hopscotch v9.7.2 应用的 InAppNotificationActivity.java JAVA 源代码文件

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


package com.clevertap.android.sdk;

import android.R;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import com.clevertap.android.sdk.inapp.CTInAppNotification;
import com.facebook.common.util.ByteConstants;
import java.lang.ref.WeakReference;
import java.util.HashMap;

public final class InAppNotificationActivity extends androidx.fragment.app.n implements com.clevertap.android.sdk.inapp.j0, k0 {
    private static boolean isAlertVisible = false;
    private CleverTapInstanceConfig config;
    private CTInAppNotification inAppNotification;
    private WeakReference<com.clevertap.android.sdk.inapp.j0> listenerWeakReference;
    private c1 pushPermissionManager;
    private WeakReference<e> pushPermissionResultCallbackWeakReference;
    private Bundle returnBundle = null;
    private boolean invokedInAppDismissCallback = false;

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

        @Override
        public final void onClick(DialogInterface dialogInterface, int i) {
            Bundle bundle = new Bundle();
            InAppNotificationActivity inAppNotificationActivity = InAppNotificationActivity.this;
            bundle.putString("wzrk_id", inAppNotificationActivity.inAppNotification.i());
            bundle.putString("wzrk_c2a", inAppNotificationActivity.inAppNotification.g().get(0).i());
            inAppNotificationActivity.T0(bundle, null);
            String b = inAppNotificationActivity.inAppNotification.g().get(0).b();
            if (b != null) {
                inAppNotificationActivity.W0(bundle, b);
                return;
            }
            if (inAppNotificationActivity.inAppNotification.l0()) {
                inAppNotificationActivity.a1(inAppNotificationActivity.inAppNotification.c());
            } else if (inAppNotificationActivity.inAppNotification.g().get(0).n() == null || !inAppNotificationActivity.inAppNotification.g().get(0).n().equalsIgnoreCase("rfp")) {
                inAppNotificationActivity.U0(bundle);
            } else {
                inAppNotificationActivity.a1(inAppNotificationActivity.inAppNotification.g().get(0).z());
            }
        }
    }

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

        @Override
        public final void onClick(DialogInterface dialogInterface, int i) {
            Bundle bundle = new Bundle();
            InAppNotificationActivity inAppNotificationActivity = InAppNotificationActivity.this;
            bundle.putString("wzrk_id", inAppNotificationActivity.inAppNotification.i());
            bundle.putString("wzrk_c2a", inAppNotificationActivity.inAppNotification.g().get(1).i());
            inAppNotificationActivity.T0(bundle, null);
            String b = inAppNotificationActivity.inAppNotification.g().get(1).b();
            if (b != null) {
                inAppNotificationActivity.W0(bundle, b);
            } else if (inAppNotificationActivity.inAppNotification.g().get(1).n() == null || !inAppNotificationActivity.inAppNotification.g().get(1).n().equalsIgnoreCase("rfp")) {
                inAppNotificationActivity.U0(bundle);
            } else {
                inAppNotificationActivity.a1(inAppNotificationActivity.inAppNotification.g().get(1).z());
            }
        }
    }

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

        @Override
        public final void onClick(DialogInterface dialogInterface, int i) {
            Bundle bundle = new Bundle();
            InAppNotificationActivity inAppNotificationActivity = InAppNotificationActivity.this;
            bundle.putString("wzrk_id", inAppNotificationActivity.inAppNotification.i());
            bundle.putString("wzrk_c2a", inAppNotificationActivity.inAppNotification.g().get(2).i());
            inAppNotificationActivity.T0(bundle, null);
            String b = inAppNotificationActivity.inAppNotification.g().get(2).b();
            if (b != null) {
                inAppNotificationActivity.W0(bundle, b);
            } else {
                inAppNotificationActivity.U0(bundle);
            }
        }
    }

    public static class d {
        public static final int[] a;

        static {
            int[] iArr = new int[com.clevertap.android.sdk.inapp.c0.values().length];
            a = iArr;
            try {
                iArr[com.clevertap.android.sdk.inapp.c0.CTInAppTypeCoverHTML.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeInterstitialHTML.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeHalfInterstitialHTML.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeCover.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeInterstitial.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeHalfInterstitial.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeCoverImageOnly.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeInterstitialImageOnly.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeHalfInterstitialImageOnly.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                a[com.clevertap.android.sdk.inapp.c0.CTInAppTypeAlert.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
        }
    }

    public interface e {
        void b();

        void c();
    }

    @Override
    public final void C(CTInAppNotification cTInAppNotification) {
        V0();
    }

    @Override
    public final void F(CTInAppNotification cTInAppNotification, Bundle bundle, HashMap<String, String> hashMap) {
        T0(bundle, hashMap);
    }

    @Override
    public final void F0(boolean z) {
        a1(z);
    }

    @Override
    public final void P(Context context, CTInAppNotification cTInAppNotification, Bundle bundle) {
        U0(bundle);
    }

    public final com.clevertap.android.sdk.inapp.e S0() {
        AlertDialog alertDialog;
        com.clevertap.android.sdk.inapp.c0 F = this.inAppNotification.F();
        switch (d.a[F.ordinal()]) {
            case 1:
                return new com.clevertap.android.sdk.inapp.n();
            case 2:
                return new com.clevertap.android.sdk.inapp.r();
            case 3:
                return new com.clevertap.android.sdk.inapp.p();
            case 4:
                return new com.clevertap.android.sdk.inapp.s();
            case 5:
                return new com.clevertap.android.sdk.inapp.z();
            case 6:
                return new com.clevertap.android.sdk.inapp.v();
            case 7:
                return new com.clevertap.android.sdk.inapp.t();
            case 8:
                return new com.clevertap.android.sdk.inapp.b0();
            case 9:
                return new com.clevertap.android.sdk.inapp.w();
            case 10:
                if (this.inAppNotification.g().size() > 0) {
                    alertDialog = new AlertDialog.Builder(this, R.style.Theme.Material.Light.Dialog.Alert).setCancelable(false).setTitle(this.inAppNotification.Y()).setMessage(this.inAppNotification.O()).setPositiveButton(this.inAppNotification.g().get(0).i(), new a()).create();
                    if (this.inAppNotification.g().size() == 2) {
                        alertDialog.setButton(-2, this.inAppNotification.g().get(1).i(), new b());
                    }
                    if (this.inAppNotification.g().size() > 2) {
                        alertDialog.setButton(-3, this.inAppNotification.g().get(2).i(), new c());
                    }
                } else {
                    alertDialog = null;
                }
                if (alertDialog == null) {
                    this.config.z().getClass();
                    y0.d("InAppNotificationActivity: Alert Dialog is null, not showing Alert InApp");
                    return null;
                }
                alertDialog.show();
                isAlertVisible = true;
                com.clevertap.android.sdk.inapp.j0 X0 = X0();
                if (X0 == null) {
                    return null;
                }
                X0.C(this.inAppNotification);
                return null;
            default:
                this.config.z().n("InAppNotificationActivity: Unhandled InApp Type: " + F);
                return null;
        }
    }

    public final void T0(Bundle bundle, HashMap<String, String> hashMap) {
        com.clevertap.android.sdk.inapp.j0 X0 = X0();
        if (X0 != null) {
            X0.F(this.inAppNotification, bundle, hashMap);
        }
    }

    public final void U0(Bundle bundle) {
        this.returnBundle = bundle;
        finish();
    }

    public final void V0() {
        com.clevertap.android.sdk.inapp.j0 X0 = X0();
        if (X0 != null) {
            X0.C(this.inAppNotification);
        }
    }

    public final void W0(Bundle bundle, String str) {
        try {
            startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str.replace("\n", "").replace("\r", ""))));
        } catch (Throwable unused) {
        }
        U0(bundle);
    }

    public final com.clevertap.android.sdk.inapp.j0 X0() {
        com.clevertap.android.sdk.inapp.j0 j0Var;
        try {
            j0Var = this.listenerWeakReference.get();
        } catch (Throwable unused) {
            j0Var = null;
        }
        if (j0Var == null) {
            y0 z = this.config.z();
            String d2 = this.config.d();
            String str = "InAppActivityListener is null for notification: " + this.inAppNotification.L();
            z.getClass();
            y0.o(d2, str);
        }
        return j0Var;
    }

    public final void Y0() {
        if (isAlertVisible) {
            isAlertVisible = false;
        }
        com.clevertap.android.sdk.inapp.j0 X0 = X0();
        if (X0 != null && getBaseContext() != null && this.inAppNotification != null) {
            X0.P(getBaseContext(), this.inAppNotification, this.returnBundle);
        }
        this.invokedInAppDismissCallback = true;
    }

    public final void Z0() {
        this.pushPermissionResultCallbackWeakReference.get().c();
    }

    @SuppressLint({"NewApi"})
    public final void a1(boolean z) {
        this.pushPermissionManager.d(z, this.pushPermissionResultCallbackWeakReference.get());
    }

    @Override
    @SuppressLint({"WrongConstant"})
    public final void finish() {
        super.finish();
        if (Build.VERSION.SDK_INT >= 34) {
            overrideActivityTransition(1, R.anim.fade_in, R.anim.fade_out);
        } else {
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
        if (this.invokedInAppDismissCallback) {
            return;
        }
        Y0();
    }

    @Override
    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        int i = getResources().getConfiguration().orientation;
        if (i == 2) {
            getWindow().addFlags(ByteConstants.KB);
        }
        try {
            Bundle extras = getIntent().getExtras();
            if (extras == null) {
                throw new IllegalArgumentException();
            }
            this.inAppNotification = (CTInAppNotification) extras.getParcelable("inApp");
            boolean z = extras.getBoolean("displayHardPermissionDialog", false);
            Bundle bundle2 = extras.getBundle("configBundle");
            if (bundle2 != null) {
                this.config = (CleverTapInstanceConfig) bundle2.getParcelable("config");
            }
            this.listenerWeakReference = new WeakReference<>(u.G(this, this.config, null).t().l());
            this.pushPermissionResultCallbackWeakReference = new WeakReference<>(u.G(this, this.config, null).t().l());
            this.pushPermissionManager = new c1(this, this.config);
            if (z) {
                a1(extras.getBoolean("shouldShowFallbackSettings", false));
                return;
            }
            CTInAppNotification cTInAppNotification = this.inAppNotification;
            if (cTInAppNotification == null) {
                finish();
                return;
            }
            if (cTInAppNotification.m0() && !this.inAppNotification.k0()) {
                if (i == 2) {
                    y0.a("App in Landscape, dismissing portrait InApp Notification");
                    finish();
                    U0(null);
                    return;
                }
                y0.a("App in Portrait, displaying InApp Notification anyway");
            }
            if (!this.inAppNotification.m0() && this.inAppNotification.k0()) {
                if (i == 1) {
                    y0.a("App in Portrait, dismissing landscape InApp Notification");
                    finish();
                    U0(null);
                    return;
                }
                y0.a("App in Landscape, displaying InApp Notification anyway");
            }
            if (bundle != null) {
                if (isAlertVisible) {
                    S0();
                    return;
                }
                return;
            }
            com.clevertap.android.sdk.inapp.e S0 = S0();
            if (S0 != null) {
                Bundle bundle3 = new Bundle();
                bundle3.putParcelable("inApp", this.inAppNotification);
                bundle3.putParcelable("config", this.config);
                S0.setArguments(bundle3);
                FragmentManager supportFragmentManager = getSupportFragmentManager();
                supportFragmentManager.getClass();
                androidx.fragment.app.a aVar = new androidx.fragment.app.a(supportFragmentManager);
                aVar.m(R.animator.fade_in, R.animator.fade_out, 0, 0);
                aVar.k(R.id.content, S0, this.config.d() + ":CT_INAPP_CONTENT_FRAGMENT", 1);
                aVar.q();
            }
        } catch (Throwable th) {
            y0.m("Cannot find a valid notification bundle to show!", th);
            finish();
        }
    }

    @Override
    @SuppressLint({"WrongConstant"})
    public final void onDestroy() {
        super.onDestroy();
        if (Build.VERSION.SDK_INT >= 34) {
            overrideActivityTransition(1, R.anim.fade_in, R.anim.fade_out);
        } else {
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
        if (this.invokedInAppDismissCallback) {
            return;
        }
        Y0();
    }

    @Override
    public final void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        o.a(this, this.config);
        o.b = false;
        o.b(this, this.config);
        if (i == 102) {
            if (iArr.length <= 0 || iArr[0] != 0) {
                this.pushPermissionResultCallbackWeakReference.get().c();
            } else {
                this.pushPermissionResultCallbackWeakReference.get().b();
            }
            U0(null);
        }
    }

    @Override
    public final void onResume() {
        super.onResume();
        if (!this.pushPermissionManager.c() || Build.VERSION.SDK_INT < 33) {
            return;
        }
        if (androidx.core.content.a.a(this, "android.permission.POST_NOTIFICATIONS") == 0) {
            this.pushPermissionResultCallbackWeakReference.get().b();
        } else {
            this.pushPermissionResultCallbackWeakReference.get().c();
        }
        U0(null);
    }

    @Override
    public final void setTheme(int i) {
        super.setTheme(R.style.Theme.Translucent.NoTitleBar);
    }
}