APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:ImmoApp
版本号:2.1.0
包名称:ch.immodigi.immoapp

MD5 校验值:37839b176a456a1c70755b7b7d2315b2

反编译源代码说明

SplashScreen.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.capacitorjs.plugins.splashscreen;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.os.Handler;
import android.util.Property;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.splashscreen.SplashScreen;
import androidx.core.splashscreen.SplashScreenViewProvider;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import com.capacitorjs.plugins.splashscreen.SplashScreen;
import com.getcapacitor.Logger;

public class SplashScreen {
    private SplashScreenConfig config;
    private View content;
    private Context context;
    private Dialog dialog;
    private ViewTreeObserver.OnPreDrawListener onPreDrawListener;
    private ProgressBar spinnerBar;
    private View splashImage;
    private WindowManager windowManager;
    private boolean isVisible = false;
    private boolean isHiding = false;

    public SplashScreen(Context context, SplashScreenConfig splashScreenConfig) {
        this.context = context;
        this.config = splashScreenConfig;
    }

    public void showOnLaunch(AppCompatActivity appCompatActivity) {
        if (this.config.getLaunchShowDuration().intValue() == 0) {
            return;
        }
        SplashScreenSettings splashScreenSettings = new SplashScreenSettings();
        splashScreenSettings.setShowDuration(this.config.getLaunchShowDuration());
        splashScreenSettings.setAutoHide(this.config.isLaunchAutoHide());
        try {
            showWithAndroid12API(appCompatActivity, splashScreenSettings);
        } catch (Exception unused) {
            Logger.warn("Android 12 Splash API failed... using previous method.");
            this.onPreDrawListener = null;
            splashScreenSettings.setFadeInDuration(this.config.getLaunchFadeInDuration());
            if (this.config.isUsingDialog()) {
                showDialog(appCompatActivity, splashScreenSettings, null, true);
            } else {
                show(appCompatActivity, splashScreenSettings, null, true);
            }
        }
    }

    private void showWithAndroid12API(final AppCompatActivity appCompatActivity, final SplashScreenSettings splashScreenSettings) {
        if (appCompatActivity == null || appCompatActivity.isFinishing()) {
            return;
        }
        appCompatActivity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                SplashScreen.this.m87x7dae4726(appCompatActivity, splashScreenSettings);
            }
        });
    }

    public void m87x7dae4726(AppCompatActivity appCompatActivity, final SplashScreenSettings splashScreenSettings) {
        androidx.core.splashscreen.SplashScreen installSplashScreen = androidx.core.splashscreen.SplashScreen.installSplashScreen(appCompatActivity);
        installSplashScreen.setKeepOnScreenCondition(new SplashScreen.KeepOnScreenCondition() {
            @Override
            public final boolean shouldKeepOnScreen() {
                return SplashScreen.this.m85xf6980ba4();
            }
        });
        installSplashScreen.setOnExitAnimationListener(new SplashScreen.OnExitAnimationListener() {
            @Override
            public final void onSplashScreenExit(SplashScreenViewProvider splashScreenViewProvider) {
                SplashScreen.this.m86x3a232965(splashScreenSettings, splashScreenViewProvider);
            }
        });
        this.content = appCompatActivity.findViewById(android.R.id.content);
        this.onPreDrawListener = new AnonymousClass2(splashScreenSettings);
        this.content.getViewTreeObserver().addOnPreDrawListener(this.onPreDrawListener);
    }

    public boolean m85xf6980ba4() {
        return this.isVisible || this.isHiding;
    }

    public void m86x3a232965(SplashScreenSettings splashScreenSettings, final SplashScreenViewProvider splashScreenViewProvider) {
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(splashScreenViewProvider.getView(), (Property<View, Float>) View.ALPHA, 1.0f, 0.0f);
        ofFloat.setInterpolator(new LinearInterpolator());
        ofFloat.setDuration(splashScreenSettings.getFadeOutDuration().intValue());
        ofFloat.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animator) {
                SplashScreen.this.isHiding = false;
                splashScreenViewProvider.remove();
            }
        });
        ofFloat.start();
        this.isHiding = true;
        this.isVisible = false;
    }

    public class AnonymousClass2 implements ViewTreeObserver.OnPreDrawListener {
        final SplashScreenSettings val$settings;

        AnonymousClass2(SplashScreenSettings splashScreenSettings) {
            this.val$settings = splashScreenSettings;
        }

        @Override
        public boolean onPreDraw() {
            if (SplashScreen.this.isVisible || SplashScreen.this.isHiding) {
                return false;
            }
            SplashScreen.this.isVisible = true;
            Handler handler = new Handler(SplashScreen.this.context.getMainLooper());
            final SplashScreenSettings splashScreenSettings = this.val$settings;
            handler.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    SplashScreen.AnonymousClass2.this.m88x2c898a93(splashScreenSettings);
                }
            }, this.val$settings.getShowDuration().intValue());
            return false;
        }

        public void m88x2c898a93(SplashScreenSettings splashScreenSettings) {
            if (splashScreenSettings.isAutoHide()) {
                SplashScreen.this.isVisible = false;
                SplashScreen.this.onPreDrawListener = null;
                SplashScreen.this.content.getViewTreeObserver().removeOnPreDrawListener(this);
            }
        }
    }

    public void show(AppCompatActivity appCompatActivity, SplashScreenSettings splashScreenSettings, SplashListener splashListener) {
        if (this.config.isUsingDialog()) {
            showDialog(appCompatActivity, splashScreenSettings, splashListener, false);
        } else {
            show(appCompatActivity, splashScreenSettings, splashListener, false);
        }
    }

    private void showDialog(final AppCompatActivity appCompatActivity, final SplashScreenSettings splashScreenSettings, final SplashListener splashListener, final boolean z) {
        if (appCompatActivity == null || appCompatActivity.isFinishing()) {
            return;
        }
        if (this.isVisible) {
            splashListener.completed();
        } else {
            appCompatActivity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    SplashScreen.this.m84xe3550160(appCompatActivity, splashScreenSettings, z, splashListener);
                }
            });
        }
    }

    public void m84xe3550160(final AppCompatActivity appCompatActivity, SplashScreenSettings splashScreenSettings, final boolean z, final SplashListener splashListener) {
        int i;
        if (this.config.isImmersive()) {
            this.dialog = new Dialog(appCompatActivity, R.style.capacitor_immersive_style);
        } else if (this.config.isFullScreen()) {
            this.dialog = new Dialog(appCompatActivity, R.style.capacitor_full_screen_style);
        } else {
            this.dialog = new Dialog(appCompatActivity, R.style.capacitor_default_style);
        }
        if (this.config.getLayoutName() != null) {
            i = this.context.getResources().getIdentifier(this.config.getLayoutName(), "layout", this.context.getPackageName());
            if (i == 0) {
                Logger.warn("Layout not found, using default");
            }
        } else {
            i = 0;
        }
        if (i != 0) {
            this.dialog.setContentView(i);
        } else {
            Drawable splashDrawable = getSplashDrawable();
            LinearLayout linearLayout = new LinearLayout(this.context);
            linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
            linearLayout.setOrientation(1);
            if (splashDrawable != null) {
                linearLayout.setBackground(splashDrawable);
            }
            this.dialog.setContentView(linearLayout);
        }
        this.dialog.setCancelable(false);
        if (!this.dialog.isShowing()) {
            this.dialog.show();
        }
        this.isVisible = true;
        if (splashScreenSettings.isAutoHide()) {
            new Handler(this.context.getMainLooper()).postDelayed(new Runnable() {
                @Override
                public final void run() {
                    SplashScreen.this.m83x9fc9e39f(appCompatActivity, z, splashListener);
                }
            }, splashScreenSettings.getShowDuration().intValue());
        } else if (splashListener != null) {
            splashListener.completed();
        }
    }

    public void m83x9fc9e39f(AppCompatActivity appCompatActivity, boolean z, SplashListener splashListener) {
        hideDialog(appCompatActivity, z);
        if (splashListener != null) {
            splashListener.completed();
        }
    }

    public void hide(SplashScreenSettings splashScreenSettings) {
        hide(splashScreenSettings.getFadeOutDuration().intValue(), false);
    }

    public void hideDialog(AppCompatActivity appCompatActivity) {
        hideDialog(appCompatActivity, false);
    }

    public void onPause() {
        tearDown(true);
    }

    public void onDestroy() {
        tearDown(true);
    }

    private void buildViews() {
        int i;
        if (this.splashImage == null) {
            if (this.config.getLayoutName() != null) {
                i = this.context.getResources().getIdentifier(this.config.getLayoutName(), "layout", this.context.getPackageName());
                if (i == 0) {
                    Logger.warn("Layout not found, defaulting to ImageView");
                }
            } else {
                i = 0;
            }
            if (i != 0) {
                LayoutInflater layoutInflater = ((Activity) this.context).getLayoutInflater();
                FrameLayout frameLayout = new FrameLayout(this.context);
                frameLayout.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
                this.splashImage = layoutInflater.inflate(i, (ViewGroup) frameLayout, false);
            } else {
                Drawable splashDrawable = getSplashDrawable();
                if (splashDrawable != 0) {
                    if (splashDrawable instanceof Animatable) {
                        ((Animatable) splashDrawable).start();
                    }
                    if (splashDrawable instanceof LayerDrawable) {
                        LayerDrawable layerDrawable = (LayerDrawable) splashDrawable;
                        for (int i2 = 0; i2 < layerDrawable.getNumberOfLayers(); i2++) {
                            Object drawable = layerDrawable.getDrawable(i2);
                            if (drawable instanceof Animatable) {
                                ((Animatable) drawable).start();
                            }
                        }
                    }
                    ImageView imageView = new ImageView(this.context);
                    this.splashImage = imageView;
                    if (Build.VERSION.SDK_INT >= 28) {
                        imageView.setLayerType(1, null);
                    } else {
                        legacyStopFlickers(imageView);
                    }
                    imageView.setScaleType(this.config.getScaleType());
                    imageView.setImageDrawable(splashDrawable);
                }
            }
            this.splashImage.setFitsSystemWindows(true);
            if (this.config.getBackgroundColor() != null) {
                this.splashImage.setBackgroundColor(this.config.getBackgroundColor().intValue());
            }
        }
        if (this.spinnerBar == null) {
            if (this.config.getSpinnerStyle() != null) {
                this.spinnerBar = new ProgressBar(this.context, null, this.config.getSpinnerStyle().intValue());
            } else {
                this.spinnerBar = new ProgressBar(this.context);
            }
            this.spinnerBar.setIndeterminate(true);
            Integer spinnerColor = this.config.getSpinnerColor();
            if (spinnerColor != null) {
                this.spinnerBar.setIndeterminateTintList(new ColorStateList(new int[][]{new int[]{android.R.attr.state_enabled}, new int[]{-16842910}, new int[]{-16842912}, new int[]{android.R.attr.state_pressed}}, new int[]{spinnerColor.intValue(), spinnerColor.intValue(), spinnerColor.intValue(), spinnerColor.intValue()}));
            }
        }
    }

    private void legacyStopFlickers(ImageView imageView) {
        imageView.setDrawingCacheEnabled(true);
    }

    private Drawable getSplashDrawable() {
        try {
            return this.context.getResources().getDrawable(this.context.getResources().getIdentifier(this.config.getResourceName(), "drawable", this.context.getPackageName()), this.context.getTheme());
        } catch (Resources.NotFoundException unused) {
            Logger.warn("No splash screen found, not displaying");
            return null;
        }
    }

    private void show(final AppCompatActivity appCompatActivity, final SplashScreenSettings splashScreenSettings, SplashListener splashListener, boolean z) {
        this.windowManager = (WindowManager) appCompatActivity.getSystemService("window");
        if (appCompatActivity.isFinishing()) {
            return;
        }
        buildViews();
        if (this.isVisible) {
            splashListener.completed();
        } else {
            final AnonymousClass3 anonymousClass3 = new AnonymousClass3(splashScreenSettings, z, splashListener);
            new Handler(this.context.getMainLooper()).post(new Runnable() {
                @Override
                public final void run() {
                    SplashScreen.this.m82lambda$show$7$comcapacitorjspluginssplashscreenSplashScreen(appCompatActivity, splashScreenSettings, anonymousClass3);
                }
            });
        }
    }

    public class AnonymousClass3 implements Animator.AnimatorListener {
        final boolean val$isLaunchSplash;
        final SplashScreenSettings val$settings;
        final SplashListener val$splashListener;

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }

        @Override
        public void onAnimationStart(Animator animator) {
        }

        AnonymousClass3(SplashScreenSettings splashScreenSettings, boolean z, SplashListener splashListener) {
            this.val$settings = splashScreenSettings;
            this.val$isLaunchSplash = z;
            this.val$splashListener = splashListener;
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            SplashScreen.this.isVisible = true;
            if (this.val$settings.isAutoHide()) {
                Handler handler = new Handler(SplashScreen.this.context.getMainLooper());
                final SplashScreenSettings splashScreenSettings = this.val$settings;
                final boolean z = this.val$isLaunchSplash;
                final SplashListener splashListener = this.val$splashListener;
                handler.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        SplashScreen.AnonymousClass3.this.m89x2c605a3c(splashScreenSettings, z, splashListener);
                    }
                }, this.val$settings.getShowDuration().intValue());
                return;
            }
            SplashListener splashListener2 = this.val$splashListener;
            if (splashListener2 != null) {
                splashListener2.completed();
            }
        }

        public void m89x2c605a3c(SplashScreenSettings splashScreenSettings, boolean z, SplashListener splashListener) {
            SplashScreen.this.hide(splashScreenSettings.getFadeOutDuration().intValue(), z);
            if (splashListener != null) {
                splashListener.completed();
            }
        }
    }

    public void m82lambda$show$7$comcapacitorjspluginssplashscreenSplashScreen(final AppCompatActivity appCompatActivity, SplashScreenSettings splashScreenSettings, Animator.AnimatorListener animatorListener) {
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        layoutParams.gravity = 17;
        layoutParams.flags = appCompatActivity.getWindow().getAttributes().flags;
        layoutParams.format = -3;
        try {
            this.windowManager.addView(this.splashImage, layoutParams);
            if (this.config.isImmersive()) {
                if (Build.VERSION.SDK_INT >= 30) {
                    appCompatActivity.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            SplashScreen.this.m80lambda$show$5$comcapacitorjspluginssplashscreenSplashScreen(appCompatActivity);
                        }
                    });
                } else {
                    legacyImmersive();
                }
            } else if (this.config.isFullScreen()) {
                if (Build.VERSION.SDK_INT >= 30) {
                    appCompatActivity.runOnUiThread(new Runnable() {
                        @Override
                        public final void run() {
                            SplashScreen.this.m81lambda$show$6$comcapacitorjspluginssplashscreenSplashScreen(appCompatActivity);
                        }
                    });
                } else {
                    legacyFullscreen();
                }
            }
            this.splashImage.setAlpha(0.0f);
            this.splashImage.animate().alpha(1.0f).setInterpolator(new LinearInterpolator()).setDuration(splashScreenSettings.getFadeInDuration().intValue()).setListener(animatorListener).start();
            this.splashImage.setVisibility(0);
            ProgressBar progressBar = this.spinnerBar;
            if (progressBar != null) {
                progressBar.setVisibility(4);
                if (this.spinnerBar.getParent() != null) {
                    this.windowManager.removeView(this.spinnerBar);
                }
                layoutParams.height = -2;
                layoutParams.width = -2;
                this.windowManager.addView(this.spinnerBar, layoutParams);
                if (this.config.isShowSpinner()) {
                    this.spinnerBar.setAlpha(0.0f);
                    this.spinnerBar.animate().alpha(1.0f).setInterpolator(new LinearInterpolator()).setDuration(splashScreenSettings.getFadeInDuration().intValue()).start();
                    this.spinnerBar.setVisibility(0);
                }
            }
        } catch (IllegalArgumentException | IllegalStateException unused) {
            Logger.debug("Could not add splash view");
        }
    }

    public void m80lambda$show$5$comcapacitorjspluginssplashscreenSplashScreen(AppCompatActivity appCompatActivity) {
        WindowCompat.setDecorFitsSystemWindows(appCompatActivity.getWindow(), false);
        WindowInsetsController windowInsetsController = this.splashImage.getWindowInsetsController();
        windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
        windowInsetsController.setSystemBarsBehavior(2);
    }

    public void m81lambda$show$6$comcapacitorjspluginssplashscreenSplashScreen(AppCompatActivity appCompatActivity) {
        WindowCompat.setDecorFitsSystemWindows(appCompatActivity.getWindow(), false);
        this.splashImage.getWindowInsetsController().hide(WindowInsetsCompat.Type.statusBars());
    }

    private void legacyImmersive() {
        this.splashImage.setSystemUiVisibility(5894);
    }

    private void legacyFullscreen() {
        this.splashImage.setSystemUiVisibility(4);
    }

    public void hide(final int i, boolean z) {
        if (z && this.isVisible) {
            Logger.debug("SplashScreen was automatically hidden after the launch timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout).Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen");
        }
        if (this.isHiding) {
            return;
        }
        if (this.onPreDrawListener != null) {
            this.isVisible = false;
            View view = this.content;
            if (view != null) {
                view.getViewTreeObserver().removeOnPreDrawListener(this.onPreDrawListener);
            }
            this.onPreDrawListener = null;
            return;
        }
        View view2 = this.splashImage;
        if (view2 == null || view2.getParent() == null) {
            return;
        }
        this.isHiding = true;
        final Animator.AnimatorListener animatorListener = new Animator.AnimatorListener() {
            @Override
            public void onAnimationRepeat(Animator animator) {
            }

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                SplashScreen.this.tearDown(false);
            }

            @Override
            public void onAnimationCancel(Animator animator) {
                SplashScreen.this.tearDown(false);
            }
        };
        new Handler(this.context.getMainLooper()).post(new Runnable() {
            @Override
            public final void run() {
                SplashScreen.this.m78lambda$hide$8$comcapacitorjspluginssplashscreenSplashScreen(i, animatorListener);
            }
        });
    }

    public void m78lambda$hide$8$comcapacitorjspluginssplashscreenSplashScreen(int i, Animator.AnimatorListener animatorListener) {
        ProgressBar progressBar = this.spinnerBar;
        if (progressBar != null) {
            progressBar.setAlpha(1.0f);
            this.spinnerBar.animate().alpha(0.0f).setInterpolator(new LinearInterpolator()).setDuration(i).start();
        }
        this.splashImage.setAlpha(1.0f);
        this.splashImage.animate().alpha(0.0f).setInterpolator(new LinearInterpolator()).setDuration(i).setListener(animatorListener).start();
    }

    private void hideDialog(final AppCompatActivity appCompatActivity, boolean z) {
        if (z && this.isVisible) {
            Logger.debug("SplashScreen was automatically hidden after the launch timeout. You should call `SplashScreen.hide()` as soon as your web app is loaded (or increase the timeout).Read more at https://capacitorjs.com/docs/apis/splash-screen#hiding-the-splash-screen");
        }
        if (this.isHiding) {
            return;
        }
        if (this.onPreDrawListener != null) {
            this.isVisible = false;
            View view = this.content;
            if (view != null) {
                view.getViewTreeObserver().removeOnPreDrawListener(this.onPreDrawListener);
            }
            this.onPreDrawListener = null;
            return;
        }
        this.isHiding = true;
        appCompatActivity.runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                SplashScreen.this.m79x21e1482a(appCompatActivity);
            }
        });
    }

    public void m79x21e1482a(AppCompatActivity appCompatActivity) {
        Dialog dialog = this.dialog;
        if (dialog == null || !dialog.isShowing()) {
            return;
        }
        if (!appCompatActivity.isFinishing() && !appCompatActivity.isDestroyed()) {
            this.dialog.dismiss();
        }
        this.dialog = null;
        this.isHiding = false;
        this.isVisible = false;
    }

    public void tearDown(boolean z) {
        ProgressBar progressBar = this.spinnerBar;
        if (progressBar != null && progressBar.getParent() != null) {
            this.spinnerBar.setVisibility(4);
            if (z) {
                this.windowManager.removeView(this.spinnerBar);
            }
        }
        View view = this.splashImage;
        if (view != null && view.getParent() != null) {
            this.splashImage.setVisibility(4);
            this.windowManager.removeView(this.splashImage);
        }
        if ((Build.VERSION.SDK_INT >= 30 && this.config.isFullScreen()) || this.config.isImmersive()) {
            WindowCompat.setDecorFitsSystemWindows(((Activity) this.context).getWindow(), true);
        }
        this.isHiding = false;
        this.isVisible = false;
    }
}