Sunflower v2.7.0版本的 MD5 值为:0696e8ce118febedd4bd019622cb23b1

以下内容为反编译后的 LaunchActivity.java 源代码,内容仅作参考


package im.grnuohmoqd.ui;

import android.app.ActivityManager;
import android.app.NotificationManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bjz.comm.net.utils.AppPreferenceUtil;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.internal.ImagesContract;
import im.grnuohmoqd.javaBean.fc.FollowedFcListBean;
import im.grnuohmoqd.javaBean.fc.HomeFcListBean;
import im.grnuohmoqd.javaBean.fc.RecommendFcListBean;
import im.grnuohmoqd.keepalive.DaemonService;
import im.grnuohmoqd.messenger.AccountInstance;
import im.grnuohmoqd.messenger.AndroidUtilities;
import im.grnuohmoqd.messenger.ApplicationLoader;
import im.grnuohmoqd.messenger.BuildVars;
import im.grnuohmoqd.messenger.ChatObject;
import im.grnuohmoqd.messenger.ContactsController;
import im.grnuohmoqd.messenger.FileLoader;
import im.grnuohmoqd.messenger.FileLog;
import im.grnuohmoqd.messenger.ImageLoader;
import im.grnuohmoqd.messenger.LocaleController;
import im.grnuohmoqd.messenger.LocationController;
import im.grnuohmoqd.messenger.MediaController;
import im.grnuohmoqd.messenger.MediaDataController;
import im.grnuohmoqd.messenger.MessageObject;
import im.grnuohmoqd.messenger.MessagesController;
import im.grnuohmoqd.messenger.MessagesStorage;
import im.grnuohmoqd.messenger.NotificationCenter;
import im.grnuohmoqd.messenger.R;
import im.grnuohmoqd.messenger.SendMessagesHelper;
import im.grnuohmoqd.messenger.SharedConfig;
import im.grnuohmoqd.messenger.UserConfig;
import im.grnuohmoqd.messenger.UserObject;
import im.grnuohmoqd.messenger.Utilities;
import im.grnuohmoqd.messenger.browser.Browser;
import im.grnuohmoqd.messenger.camera.CameraController;
import im.grnuohmoqd.messenger.utils.PlayerUtils;
import im.grnuohmoqd.tgnet.ConnectionsManager;
import im.grnuohmoqd.tgnet.RequestDelegate;
import im.grnuohmoqd.tgnet.TLObject;
import im.grnuohmoqd.tgnet.TLRPC;
import im.grnuohmoqd.tgnet.TLRPCCall;
import im.grnuohmoqd.ui.DialogsActivity;
import im.grnuohmoqd.ui.NewLocationActivity;
import im.grnuohmoqd.ui.PhoneBookSelectActivity;
import im.grnuohmoqd.ui.WallpapersListActivity;
import im.grnuohmoqd.ui.actionbar.ActionBarLayout;
import im.grnuohmoqd.ui.actionbar.AlertDialog;
import im.grnuohmoqd.ui.actionbar.BaseFragment;
import im.grnuohmoqd.ui.actionbar.DrawerLayoutContainer;
import im.grnuohmoqd.ui.actionbar.Theme;
import im.grnuohmoqd.ui.actionbar.XAlertDialog;
import im.grnuohmoqd.ui.adapters.DrawerLayoutAdapter;
import im.grnuohmoqd.ui.cells.DrawerUserCell;
import im.grnuohmoqd.ui.cells.LanguageCell;
import im.grnuohmoqd.ui.cells.ThemesHorizontalListCell;
import im.grnuohmoqd.ui.components.AlertsCreator;
import im.grnuohmoqd.ui.components.AudioPlayerAlert;
import im.grnuohmoqd.ui.components.BlockingUpdateView;
import im.grnuohmoqd.ui.components.EmbedBottomSheet;
import im.grnuohmoqd.ui.components.JoinGroupAlert;
import im.grnuohmoqd.ui.components.LayoutHelper;
import im.grnuohmoqd.ui.components.PasscodeView;
import im.grnuohmoqd.ui.components.PipRoundVideoView;
import im.grnuohmoqd.ui.components.RecyclerListView;
import im.grnuohmoqd.ui.components.SharingLocationsAlert;
import im.grnuohmoqd.ui.components.StickersAlert;
import im.grnuohmoqd.ui.components.TermsOfServiceView;
import im.grnuohmoqd.ui.components.ThemeEditorView;
import im.grnuohmoqd.ui.components.UpdateAppAlertDialog;
import im.grnuohmoqd.ui.components.toast.ToastUtils;
import im.grnuohmoqd.ui.hui.chats.NewProfileActivity;
import im.grnuohmoqd.ui.hui.contacts.AddContactsInfoActivity;
import im.grnuohmoqd.ui.hui.contacts.NewFriendsActivity;
import im.grnuohmoqd.ui.hui.discoveryweb.DiscoveryJumpPausedFloatingView;
import im.grnuohmoqd.ui.hui.friendscircle_v1.helper.DatabaseInstance;
import im.grnuohmoqd.ui.hui.friendscircle_v1.helper.FcDBHelper;
import im.grnuohmoqd.ui.hui.friendscircle_v1.ui.ImagePreviewActivity;
import im.grnuohmoqd.ui.hui.login.LoginContronllerActivity;
import im.grnuohmoqd.ui.hui.visualcall.AVideoCallInterface;
import im.grnuohmoqd.ui.hui.visualcall.PermissionUtils;
import im.grnuohmoqd.ui.hui.visualcall.RingUtils;
import im.grnuohmoqd.ui.hui.visualcall.VisualCallActivity;
import im.grnuohmoqd.ui.hui.visualcall.VisualCallReceiveActivity;
import im.grnuohmoqd.ui.hui.visualcall.VisualCallRequestParaBean;
import im.grnuohmoqd.ui.utils.AppUpdater;
import im.grnuohmoqd.ui.utils.OpenInstallUitl;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class LaunchActivity extends AppCompatActivity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {
    private static final int PLAY_SERVICES_REQUEST_CHECK_SETTINGS = 140;
    private ActionBarLayout actionBarLayout;
    private View backgroundTablet;
    private BlockingUpdateView blockingUpdateView;
    private AlertDialog checkUpdateDialog;
    private ArrayList<TLRPC.User> contactsToSend;
    private Uri contactsToSendUri;
    private int currentAccount;
    private int currentConnectionState;
    private String documentsMimeType;
    private ArrayList<String> documentsOriginalPathsArray;
    private ArrayList<String> documentsPathsArray;
    private ArrayList<Uri> documentsUrisArray;
    private DrawerLayoutAdapter drawerLayoutAdapter;
    protected DrawerLayoutContainer drawerLayoutContainer;
    private HashMap<String, String> englishLocaleStrings;
    private boolean finished;
    private ActionBarLayout layersActionBarLayout;
    private boolean loadingLocaleDialog;
    private TLRPC.TL_theme loadingTheme;
    private String loadingThemeFileName;
    private Theme.ThemeInfo loadingThemeInfo;
    private AlertDialog loadingThemeProgressDialog;
    private String loadingThemeWallpaperName;
    private AlertDialog localeDialog;
    private Runnable lockRunnable;
    private byte mBytJumpFromBack = 0;
    private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener;
    private Intent passcodeSaveIntent;
    private boolean passcodeSaveIntentIsNew;
    private boolean passcodeSaveIntentIsRestore;
    private PasscodeView passcodeView;
    private ArrayList<SendMessagesHelper.SendingMediaInfo> photoPathsArray;
    private AlertDialog proxyErrorDialog;
    private ActionBarLayout rightActionBarLayout;
    private String sendingText;
    private FrameLayout shadowTablet;
    private FrameLayout shadowTabletSide;
    private RecyclerListView sideMenu;
    private HashMap<String, String> systemLocaleStrings;
    private boolean tabletFullSize;
    private TermsOfServiceView termsOfServiceView;
    private UpdateAppAlertDialog updateAppAlertDialog;
    private String videoPath;
    private ActionMode visibleActionMode;
    private AlertDialog visibleDialog;
    private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
    private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
    private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<>();

    public static void lambda$onCreate$1(View view) {
    }

    @Deprecated
    private void queryProxyAccount(Intent intent) {
    }

    @Override
    public void onCreate(Bundle bundle) {
        Uri data;
        ApplicationLoader.postInitApplication();
        queryProxyAccount(getIntent());
        OpenInstallUitl.getInstance().getInstallOrWakeUp(getIntent());
        AndroidUtilities.checkDisplaySize(this, getResources().getConfiguration());
        int i = UserConfig.selectedAccount;
        this.currentAccount = i;
        AppUpdater.getInstance(i).loadUpdateConfig();
        if (!UserConfig.getInstance(this.currentAccount).isClientActivated()) {
            Intent intent = getIntent();
            if (intent != null && intent.getAction() != null) {
                if ("android.intent.action.SEND".equals(intent.getAction()) || "android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) {
                    super.onCreate(bundle);
                    finish();
                    return;
                } else if ("android.intent.action.VIEW".equals(intent.getAction()) && (data = intent.getData()) != null) {
                    String lowerCase = data.toString().toLowerCase();
                    if (!lowerCase.startsWith("hchat:proxy") && !lowerCase.startsWith("hchat://proxy") && !lowerCase.startsWith("hchat:socks")) {
                        lowerCase.startsWith("hchat://socks");
                    }
                }
            }
            SharedPreferences globalMainSettings = MessagesController.getGlobalMainSettings();
            globalMainSettings.getLong("intro_crashed_time", 0L);
            if (intent.getBooleanExtra("fromIntro", false)) {
                globalMainSettings.edit().putLong("intro_crashed_time", 0L).commit();
            }
        }
        requestWindowFeature(1);
        setTheme(R.style.Theme_TMessages);
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                setTaskDescription(new ActivityManager.TaskDescription((String) null, (Bitmap) null, Theme.getColor(Theme.key_actionBarDefault) | (-16777216)));
            } catch (Exception unused) {
            }
            try {
                getWindow().setNavigationBarColor(-16777216);
            } catch (Exception unused2) {
            }
        }
        getWindow().setBackgroundDrawableResource(R.drawable.transparent);
        if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
            try {
                getWindow().setFlags(8192, 8192);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
        super.onCreate(bundle);
        if (Build.VERSION.SDK_INT >= 21) {
            Window window = getWindow();
            window.getDecorView().setSystemUiVisibility(1280);
            window.setStatusBarColor(0);
        }
        if (Build.VERSION.SDK_INT >= 24) {
            AndroidUtilities.isInMultiwindow = isInMultiWindowMode();
        }
        Theme.createChatResources(this, false);
        if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.appLocked) {
            SharedConfig.lastPauseTime = ConnectionsManager.getInstance(this.currentAccount).getCurrentTime();
        }
        int identifier = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (identifier > 0) {
            AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(identifier);
        }
        this.actionBarLayout = new ActionBarLayout(this);
        DrawerLayoutContainer drawerLayoutContainer = new DrawerLayoutContainer(this);
        this.drawerLayoutContainer = drawerLayoutContainer;
        drawerLayoutContainer.setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
        char c = 65535;
        setContentView(this.drawerLayoutContainer, new ViewGroup.LayoutParams(-1, -1));
        if (AndroidUtilities.isTablet()) {
            getWindow().setSoftInputMode(16);
            RelativeLayout relativeLayout = new RelativeLayout(this) {
                private boolean inLayout;

                @Override
                public void requestLayout() {
                    if (this.inLayout) {
                        return;
                    }
                    super.requestLayout();
                }

                @Override
                protected void onMeasure(int i2, int i3) {
                    this.inLayout = true;
                    int size = View.MeasureSpec.getSize(i2);
                    int size2 = View.MeasureSpec.getSize(i3);
                    setMeasuredDimension(size, size2);
                    if (AndroidUtilities.isInMultiwindow || (AndroidUtilities.isSmallTablet() && getResources().getConfiguration().orientation != 2)) {
                        LaunchActivity.this.tabletFullSize = true;
                        LaunchActivity.this.actionBarLayout.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                    } else {
                        LaunchActivity.this.tabletFullSize = false;
                        int i4 = (size / 100) * 35;
                        if (i4 < AndroidUtilities.dp(320.0f)) {
                            i4 = AndroidUtilities.dp(320.0f);
                        }
                        LaunchActivity.this.actionBarLayout.measure(View.MeasureSpec.makeMeasureSpec(i4, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                        LaunchActivity.this.shadowTabletSide.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1.0f), 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                        LaunchActivity.this.rightActionBarLayout.measure(View.MeasureSpec.makeMeasureSpec(size - i4, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                    }
                    LaunchActivity.this.backgroundTablet.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                    LaunchActivity.this.shadowTablet.measure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
                    LaunchActivity.this.layersActionBarLayout.measure(View.MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(530.0f), size), 1073741824), View.MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(528.0f), size2), 1073741824));
                    this.inLayout = false;
                }

                @Override
                protected void onLayout(boolean z, int i2, int i3, int i4, int i5) {
                    int i6 = i4 - i2;
                    int i7 = i5 - i3;
                    if (AndroidUtilities.isInMultiwindow || (AndroidUtilities.isSmallTablet() && getResources().getConfiguration().orientation != 2)) {
                        LaunchActivity.this.actionBarLayout.layout(0, 0, LaunchActivity.this.actionBarLayout.getMeasuredWidth(), LaunchActivity.this.actionBarLayout.getMeasuredHeight());
                    } else {
                        int i8 = (i6 / 100) * 35;
                        if (i8 < AndroidUtilities.dp(320.0f)) {
                            i8 = AndroidUtilities.dp(320.0f);
                        }
                        LaunchActivity.this.shadowTabletSide.layout(i8, 0, LaunchActivity.this.shadowTabletSide.getMeasuredWidth() + i8, LaunchActivity.this.shadowTabletSide.getMeasuredHeight());
                        LaunchActivity.this.actionBarLayout.layout(0, 0, LaunchActivity.this.actionBarLayout.getMeasuredWidth(), LaunchActivity.this.actionBarLayout.getMeasuredHeight());
                        LaunchActivity.this.rightActionBarLayout.layout(i8, 0, LaunchActivity.this.rightActionBarLayout.getMeasuredWidth() + i8, LaunchActivity.this.rightActionBarLayout.getMeasuredHeight());
                    }
                    int measuredWidth = (i6 - LaunchActivity.this.layersActionBarLayout.getMeasuredWidth()) / 2;
                    int measuredHeight = (i7 - LaunchActivity.this.layersActionBarLayout.getMeasuredHeight()) / 2;
                    LaunchActivity.this.layersActionBarLayout.layout(measuredWidth, measuredHeight, LaunchActivity.this.layersActionBarLayout.getMeasuredWidth() + measuredWidth, LaunchActivity.this.layersActionBarLayout.getMeasuredHeight() + measuredHeight);
                    LaunchActivity.this.backgroundTablet.layout(0, 0, LaunchActivity.this.backgroundTablet.getMeasuredWidth(), LaunchActivity.this.backgroundTablet.getMeasuredHeight());
                    LaunchActivity.this.shadowTablet.layout(0, 0, LaunchActivity.this.shadowTablet.getMeasuredWidth(), LaunchActivity.this.shadowTablet.getMeasuredHeight());
                }
            };
            this.drawerLayoutContainer.addView(relativeLayout, LayoutHelper.createFrame(-1, -1.0f));
            this.backgroundTablet = new View(this);
            BitmapDrawable bitmapDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.catstile);
            bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
            this.backgroundTablet.setBackgroundDrawable(bitmapDrawable);
            relativeLayout.addView(this.backgroundTablet, LayoutHelper.createRelative(-1, -1));
            relativeLayout.addView(this.actionBarLayout);
            ActionBarLayout actionBarLayout = new ActionBarLayout(this);
            this.rightActionBarLayout = actionBarLayout;
            actionBarLayout.init(rightFragmentsStack);
            this.rightActionBarLayout.setDelegate(this);
            relativeLayout.addView(this.rightActionBarLayout);
            FrameLayout frameLayout = new FrameLayout(this);
            this.shadowTabletSide = frameLayout;
            frameLayout.setBackgroundColor(1076449908);
            relativeLayout.addView(this.shadowTabletSide);
            FrameLayout frameLayout2 = new FrameLayout(this);
            this.shadowTablet = frameLayout2;
            frameLayout2.setVisibility(layerFragmentsStack.isEmpty() ? 8 : 0);
            this.shadowTablet.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
            relativeLayout.addView(this.shadowTablet);
            this.shadowTablet.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public final boolean onTouch(View view, MotionEvent motionEvent) {
                    return LaunchActivity.this.lambda$onCreate$0$LaunchActivity(view, motionEvent);
                }
            });
            this.shadowTablet.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    LaunchActivity.lambda$onCreate$1(view);
                }
            });
            ActionBarLayout actionBarLayout2 = new ActionBarLayout(this);
            this.layersActionBarLayout = actionBarLayout2;
            actionBarLayout2.setRemoveActionBarExtraHeight(true);
            this.layersActionBarLayout.setBackgroundView(this.shadowTablet);
            this.layersActionBarLayout.setUseAlphaAnimations(true);
            this.layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
            this.layersActionBarLayout.init(layerFragmentsStack);
            this.layersActionBarLayout.setDelegate(this);
            this.layersActionBarLayout.setDrawerLayoutContainer(this.drawerLayoutContainer);
            this.layersActionBarLayout.setVisibility(layerFragmentsStack.isEmpty() ? 8 : 0);
            relativeLayout.addView(this.layersActionBarLayout);
        } else {
            this.drawerLayoutContainer.addView(this.actionBarLayout, new ViewGroup.LayoutParams(-1, -1));
        }
        RecyclerListView recyclerListView = new RecyclerListView(this);
        this.sideMenu = recyclerListView;
        ((DefaultItemAnimator) recyclerListView.getItemAnimator()).setDelayAnimations(false);
        this.sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
        this.sideMenu.setLayoutManager(new LinearLayoutManager(this, 1, false));
        RecyclerListView recyclerListView2 = this.sideMenu;
        DrawerLayoutAdapter drawerLayoutAdapter = new DrawerLayoutAdapter(this);
        this.drawerLayoutAdapter = drawerLayoutAdapter;
        recyclerListView2.setAdapter(drawerLayoutAdapter);
        this.drawerLayoutContainer.setDrawerLayout(this.sideMenu);
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) this.sideMenu.getLayoutParams();
        Point realScreenSize = AndroidUtilities.getRealScreenSize();
        layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320.0f) : Math.min(AndroidUtilities.dp(320.0f), Math.min(realScreenSize.x, realScreenSize.y) - AndroidUtilities.dp(56.0f));
        layoutParams.height = -1;
        this.sideMenu.setLayoutParams(layoutParams);
        this.drawerLayoutContainer.setParentActionBarLayout(this.actionBarLayout);
        this.actionBarLayout.setDrawerLayoutContainer(this.drawerLayoutContainer);
        this.actionBarLayout.init(mainFragmentsStack);
        this.actionBarLayout.setDelegate(this);
        Theme.loadWallpaper();
        PasscodeView passcodeView = new PasscodeView(this);
        this.passcodeView = passcodeView;
        this.drawerLayoutContainer.addView(passcodeView, LayoutHelper.createFrame(-1, -1.0f));
        checkCurrentAccount();
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
        this.currentConnectionState = ConnectionsManager.getInstance(this.currentAccount).getConnectionState();
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needShowAlert);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.reloadInterface);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.suggestedLangpack);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewTheme);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.needSetDayNightTheme);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetPasscode);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.notificationsCountUpdated);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.receivedAVideoCallRequest);
        if (this.actionBarLayout.fragmentsStack.isEmpty()) {
            if (!UserConfig.getInstance(this.currentAccount).isClientActivated()) {
                this.actionBarLayout.addFragmentToStack(new LoginContronllerActivity());
                this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
            } else {
                this.actionBarLayout.addFragmentToStack(new IndexActivity());
                this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
            }
            if (bundle != null) {
                try {
                    String string = bundle.getString("fragment");
                    if (string != null) {
                        Bundle bundle2 = bundle.getBundle("args");
                        switch (string.hashCode()) {
                            case -1529105743:
                                if (string.equals("wallpapers")) {
                                    c = 5;
                                    break;
                                }
                                break;
                            case -1349522494:
                                if (string.equals("chat_profile")) {
                                    c = 4;
                                    break;
                                }
                                break;
                            case 3052376:
                                if (string.equals("chat")) {
                                    c = 0;
                                    break;
                                }
                                break;
                            case 98629247:
                                if (string.equals("group")) {
                                    c = 2;
                                    break;
                                }
                                break;
                            case 738950403:
                                if (string.equals("channel")) {
                                    c = 3;
                                    break;
                                }
                                break;
                            case 1434631203:
                                if (string.equals("settings")) {
                                    c = 1;
                                    break;
                                }
                                break;
                        }
                        if (c != 0) {
                            if (c == 1) {
                                SettingsActivity settingsActivity = new SettingsActivity();
                                this.actionBarLayout.addFragmentToStack(settingsActivity);
                                settingsActivity.restoreSelfArgs(bundle);
                            } else if (c != 2) {
                                if (c != 3) {
                                    if (c != 4) {
                                        if (c == 5) {
                                            WallpapersListActivity wallpapersListActivity = new WallpapersListActivity(0);
                                            this.actionBarLayout.addFragmentToStack(wallpapersListActivity);
                                            wallpapersListActivity.restoreSelfArgs(bundle);
                                        }
                                    } else if (bundle2 != null) {
                                        ProfileActivity profileActivity = new ProfileActivity(bundle2);
                                        if (this.actionBarLayout.addFragmentToStack(profileActivity)) {
                                            profileActivity.restoreSelfArgs(bundle);
                                        }
                                    }
                                } else if (bundle2 != null) {
                                    ChannelCreateActivity channelCreateActivity = new ChannelCreateActivity(bundle2);
                                    if (this.actionBarLayout.addFragmentToStack(channelCreateActivity)) {
                                        channelCreateActivity.restoreSelfArgs(bundle);
                                    }
                                }
                            } else if (bundle2 != null) {
                                GroupCreateFinalActivity groupCreateFinalActivity = new GroupCreateFinalActivity(bundle2);
                                if (this.actionBarLayout.addFragmentToStack(groupCreateFinalActivity)) {
                                    groupCreateFinalActivity.restoreSelfArgs(bundle);
                                }
                            }
                        } else if (bundle2 != null) {
                            ChatActivity chatActivity = new ChatActivity(bundle2);
                            if (this.actionBarLayout.addFragmentToStack(chatActivity)) {
                                chatActivity.restoreSelfArgs(bundle);
                            }
                        }
                    }
                } catch (Exception e2) {
                    FileLog.e(e2);
                }
            }
        } else {
            boolean z = this.actionBarLayout.fragmentsStack.get(0) instanceof IndexActivity;
            if (AndroidUtilities.isTablet()) {
                if (this.actionBarLayout.fragmentsStack.size() <= 1) {
                    this.layersActionBarLayout.fragmentsStack.isEmpty();
                }
                if (this.layersActionBarLayout.fragmentsStack.size() == 1) {
                    boolean z2 = this.layersActionBarLayout.fragmentsStack.get(0) instanceof LoginContronllerActivity;
                }
            }
            if (this.actionBarLayout.fragmentsStack.size() == 1) {
                boolean z3 = this.actionBarLayout.fragmentsStack.get(0) instanceof LoginContronllerActivity;
            }
            this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        }
        if (this.actionBarLayout.fragmentsStack.size() >= 1) {
            this.actionBarLayout.showLastFragment();
        }
        checkLayout();
        checkSystemBarColors();
        handleIntent(getIntent(), false, bundle != null, false);
        try {
            String str = Build.DISPLAY;
            String str2 = Build.USER;
            String lowerCase2 = str != null ? str.toLowerCase() : "";
            String lowerCase3 = str2 != null ? lowerCase2.toLowerCase() : "";
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("OS name " + lowerCase2 + " " + lowerCase3);
            }
            if (lowerCase2.contains("flyme") || lowerCase3.contains("flyme")) {
                AndroidUtilities.incorrectDisplaySizeFix = true;
                final View rootView = getWindow().getDecorView().getRootView();
                ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
                ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public final void onGlobalLayout() {
                        LaunchActivity.lambda$onCreate$2(rootView);
                    }
                };
                this.onGlobalLayoutListener = onGlobalLayoutListener;
                viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener);
            }
        } catch (Exception e3) {
            FileLog.e(e3);
        }
        MediaController.getInstance().setBaseActivity(this, true);
        startService(new Intent(getApplicationContext(), (Class<?>) DaemonService.class));
    }

    public boolean lambda$onCreate$0$LaunchActivity(View view, MotionEvent motionEvent) {
        if (!this.actionBarLayout.fragmentsStack.isEmpty() && motionEvent.getAction() == 1) {
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            int[] iArr = new int[2];
            this.layersActionBarLayout.getLocationOnScreen(iArr);
            int i = iArr[0];
            int i2 = iArr[1];
            if (!this.layersActionBarLayout.checkTransitionAnimation() && (x <= i || x >= i + this.layersActionBarLayout.getWidth() || y <= i2 || y >= i2 + this.layersActionBarLayout.getHeight())) {
                if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                    while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                        ActionBarLayout actionBarLayout = this.layersActionBarLayout;
                        actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(0));
                    }
                    this.layersActionBarLayout.closeLastFragment(true);
                }
                return true;
            }
        }
        return false;
    }

    public static void lambda$onCreate$2(View view) {
        int measuredHeight = view.getMeasuredHeight();
        FileLog.d("height = " + measuredHeight + " displayHeight = " + AndroidUtilities.displaySize.y);
        if (Build.VERSION.SDK_INT >= 21) {
            measuredHeight -= AndroidUtilities.statusBarHeight;
        }
        if (measuredHeight <= AndroidUtilities.dp(100.0f) || measuredHeight >= AndroidUtilities.displaySize.y || AndroidUtilities.dp(100.0f) + measuredHeight <= AndroidUtilities.displaySize.y) {
            return;
        }
        AndroidUtilities.displaySize.y = measuredHeight;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("fix display size y to " + AndroidUtilities.displaySize.y);
        }
    }

    private void checkSystemBarColors() {
        checkSystemBarColors(true);
    }

    private void checkSystemBarColors(boolean z) {
        if (Build.VERSION.SDK_INT < 23 || Build.VERSION.SDK_INT < 26 || !z) {
            return;
        }
        Window window = getWindow();
        int color = Theme.getColor(Theme.key_windowBackgroundGray);
        if (window.getNavigationBarColor() != color) {
            window.setNavigationBarColor(color);
            AndroidUtilities.setLightNavigationBar(getWindow(), AndroidUtilities.computePerceivedBrightness(color) >= 0.721f);
        }
    }

    public void switchToAccount(int i, boolean z) {
        if (i == UserConfig.selectedAccount) {
            return;
        }
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("Launch ===> switchToAccount start  newAccount = " + i + " oldAccount = " + this.currentAccount + " userConfigAccount = " + UserConfig.selectedAccount + " removeAll = " + z);
        }
        ConnectionsManager.getInstance(this.currentAccount).setAppPaused(true, false);
        UserConfig.selectedAccount = i;
        UserConfig.getInstance(0).saveConfig(false);
        checkCurrentAccount();
        if (AndroidUtilities.isTablet()) {
            this.layersActionBarLayout.removeAllFragments();
            this.rightActionBarLayout.removeAllFragments();
            if (!this.tabletFullSize) {
                this.shadowTabletSide.setVisibility(0);
                if (this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                    this.backgroundTablet.setVisibility(0);
                }
                this.rightActionBarLayout.setVisibility(8);
            }
            this.layersActionBarLayout.setVisibility(8);
        }
        if (z) {
            this.actionBarLayout.removeAllFragments();
        } else {
            this.actionBarLayout.removeFragmentFromStack(0);
        }
        this.actionBarLayout.addFragmentToStack(new IndexActivity(), 0);
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        this.actionBarLayout.showLastFragment();
        if (AndroidUtilities.isTablet()) {
            this.layersActionBarLayout.showLastFragment();
            this.rightActionBarLayout.showLastFragment();
        }
        if (!ApplicationLoader.mainInterfacePaused) {
            ConnectionsManager.getInstance(this.currentAccount).setAppPaused(false, false);
        }
        if (UserConfig.getInstance(i).unacceptedTermsOfService != null) {
            showTosActivity(i, UserConfig.getInstance(i).unacceptedTermsOfService);
        }
        AppPreferenceUtil.putString("PublishFcBean", "");
        FcDBHelper.getInstance().deleteAll(HomeFcListBean.class);
        FcDBHelper.getInstance().deleteAll(RecommendFcListBean.class);
        FcDBHelper.getInstance().deleteAll(FollowedFcListBean.class);
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("Launch ===> switchToAccount end  newAccount = " + i + " oldAccount =   = " + this.currentAccount + " userConfigAccount = " + UserConfig.selectedAccount + " removeAll = " + z);
        }
        DiscoveryJumpPausedFloatingView.getInstance().hide(true);
    }

    private void switchToAvailableAccountOrLogout() {
        int i = 0;
        while (true) {
            if (i >= 3) {
                i = -1;
                break;
            } else if (UserConfig.getInstance(i).isClientActivated()) {
                break;
            } else {
                i++;
            }
        }
        TermsOfServiceView termsOfServiceView = this.termsOfServiceView;
        if (termsOfServiceView != null) {
            termsOfServiceView.setVisibility(8);
        }
        if (i != -1) {
            switchToAccount(i, true);
            return;
        }
        ConnectionsManager.getInstance(this.currentAccount).setAppPaused(true, false);
        UserConfig.selectedAccount = 0;
        UserConfig.getInstance(0).saveConfig(false);
        checkCurrentAccount();
        if (AndroidUtilities.isTablet()) {
            this.layersActionBarLayout.removeAllFragments();
            this.rightActionBarLayout.removeAllFragments();
            if (!this.tabletFullSize) {
                this.shadowTabletSide.setVisibility(0);
                if (this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                    this.backgroundTablet.setVisibility(0);
                }
                this.rightActionBarLayout.setVisibility(8);
            }
            this.layersActionBarLayout.setVisibility(8);
        }
        this.actionBarLayout.removeAllFragments();
        LoginContronllerActivity loginContronllerActivity = new LoginContronllerActivity();
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("LaunchActivity ===> switchToAvailableAccountOrLogout() , logoutAccount = 0 UserConfig.selectedAccount = " + UserConfig.selectedAccount + " This.currentAccount = " + this.currentAccount + " loginPage.currentAccount = " + loginContronllerActivity.getCurrentAccount());
        }
        this.actionBarLayout.addFragmentToStack(loginContronllerActivity, 0);
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        this.actionBarLayout.showLastFragment();
        if (AndroidUtilities.isTablet()) {
            this.layersActionBarLayout.showLastFragment();
            this.rightActionBarLayout.showLastFragment();
        }
        if (ApplicationLoader.mainInterfacePaused) {
            return;
        }
        ConnectionsManager.getInstance(this.currentAccount).setAppPaused(false, false);
    }

    public int getMainFragmentsCount() {
        return mainFragmentsStack.size();
    }

    private void checkCurrentAccount() {
        if (this.currentAccount != UserConfig.selectedAccount) {
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.appDidLogout);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.mainUserInfoChanged);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.didUpdateConnectionState);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.needShowAlert);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.openArticle);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.hasNewContactsToImport);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.needShowPlayServicesAlert);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.fileDidLoad);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.fileDidFailToLoad);
            NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.folderWebView);
        }
        int i = UserConfig.selectedAccount;
        this.currentAccount = i;
        NotificationCenter.getInstance(i).addObserver(this, NotificationCenter.appDidLogout);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.mainUserInfoChanged);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.didUpdateConnectionState);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.needShowAlert);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.openArticle);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.hasNewContactsToImport);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.needShowPlayServicesAlert);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.fileDidLoad);
        NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.fileDidFailToLoad);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.folderWebView);
        updateCurrentConnectionState(this.currentAccount);
    }

    private void checkLayout() {
        if (!AndroidUtilities.isTablet() || this.rightActionBarLayout == null) {
            return;
        }
        if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == 2)) {
            this.tabletFullSize = false;
            if (this.actionBarLayout.fragmentsStack.size() >= 2) {
                while (1 < this.actionBarLayout.fragmentsStack.size()) {
                    BaseFragment baseFragment = this.actionBarLayout.fragmentsStack.get(1);
                    if (baseFragment instanceof ChatActivity) {
                        ((ChatActivity) baseFragment).setIgnoreAttachOnPause(true);
                    }
                    baseFragment.onPause();
                    this.actionBarLayout.fragmentsStack.remove(1);
                    this.rightActionBarLayout.fragmentsStack.add(baseFragment);
                }
                if (this.passcodeView.getVisibility() != 0) {
                    this.actionBarLayout.showLastFragment();
                    this.rightActionBarLayout.showLastFragment();
                }
            }
            ActionBarLayout actionBarLayout = this.rightActionBarLayout;
            actionBarLayout.setVisibility(actionBarLayout.fragmentsStack.isEmpty() ? 8 : 0);
            this.backgroundTablet.setVisibility(this.rightActionBarLayout.fragmentsStack.isEmpty() ? 0 : 8);
            this.shadowTabletSide.setVisibility(this.actionBarLayout.fragmentsStack.isEmpty() ? 8 : 0);
            return;
        }
        this.tabletFullSize = true;
        if (!this.rightActionBarLayout.fragmentsStack.isEmpty()) {
            while (this.rightActionBarLayout.fragmentsStack.size() > 0) {
                BaseFragment baseFragment2 = this.rightActionBarLayout.fragmentsStack.get(0);
                if (baseFragment2 instanceof ChatActivity) {
                    ((ChatActivity) baseFragment2).setIgnoreAttachOnPause(true);
                }
                baseFragment2.onPause();
                this.rightActionBarLayout.fragmentsStack.remove(0);
                this.actionBarLayout.fragmentsStack.add(baseFragment2);
            }
            if (this.passcodeView.getVisibility() != 0) {
                this.actionBarLayout.showLastFragment();
            }
        }
        this.shadowTabletSide.setVisibility(8);
        this.rightActionBarLayout.setVisibility(8);
        this.backgroundTablet.setVisibility(this.actionBarLayout.fragmentsStack.isEmpty() ? 0 : 8);
    }

    private void showUpdateActivity(int i, TLRPC.TL_help_appUpdate tL_help_appUpdate, boolean z) {
        if (this.blockingUpdateView == null) {
            BlockingUpdateView blockingUpdateView = new BlockingUpdateView(this) {
                @Override
                public void setVisibility(int i2) {
                    super.setVisibility(i2);
                    if (i2 == 8) {
                        LaunchActivity.this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    }
                }
            };
            this.blockingUpdateView = blockingUpdateView;
            this.drawerLayoutContainer.addView(blockingUpdateView, LayoutHelper.createFrame(-1, -1.0f));
        }
        this.blockingUpdateView.show(i, tL_help_appUpdate, z);
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
    }

    private void showTosActivity(int i, TLRPC.TL_help_termsOfService tL_help_termsOfService) {
        if (this.termsOfServiceView == null) {
            TermsOfServiceView termsOfServiceView = new TermsOfServiceView(this);
            this.termsOfServiceView = termsOfServiceView;
            this.drawerLayoutContainer.addView(termsOfServiceView, LayoutHelper.createFrame(-1, -1.0f));
            this.termsOfServiceView.setDelegate(new TermsOfServiceView.TermsOfServiceViewDelegate() {
                @Override
                public void onAcceptTerms(int i2) {
                    UserConfig.getInstance(i2).unacceptedTermsOfService = null;
                    UserConfig.getInstance(i2).saveConfig(false);
                    LaunchActivity.this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    LaunchActivity.this.termsOfServiceView.setVisibility(8);
                }

                @Override
                public void onDeclineTerms(int i2) {
                    LaunchActivity.this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    LaunchActivity.this.termsOfServiceView.setVisibility(8);
                }
            });
        }
        TLRPC.TL_help_termsOfService tL_help_termsOfService2 = UserConfig.getInstance(i).unacceptedTermsOfService;
        if (tL_help_termsOfService2 != tL_help_termsOfService && (tL_help_termsOfService2 == null || !tL_help_termsOfService2.id.data.equals(tL_help_termsOfService.id.data))) {
            UserConfig.getInstance(i).unacceptedTermsOfService = tL_help_termsOfService;
            UserConfig.getInstance(i).saveConfig(false);
        }
        this.termsOfServiceView.show(i, tL_help_termsOfService);
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
    }

    public void showPasscodeActivity() {
        if (this.passcodeView == null) {
            return;
        }
        SharedConfig.appLocked = true;
        if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
            SecretMediaViewer.getInstance().closePhoto(false, false);
        } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().closePhoto(false, true);
        } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
            ArticleViewer.getInstance().close(false, true);
        }
        this.passcodeView.onShow();
        SharedConfig.isWaitingForPasscodeEnter = true;
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        this.passcodeView.setDelegate(new PasscodeView.PasscodeViewDelegate() {
            @Override
            public final void didAcceptedPassword() {
                LaunchActivity.this.lambda$showPasscodeActivity$3$LaunchActivity();
            }
        });
        this.actionBarLayout.setVisibility(4);
        if (AndroidUtilities.isTablet()) {
            if (this.layersActionBarLayout.getVisibility() == 0) {
                this.layersActionBarLayout.setVisibility(4);
            }
            this.rightActionBarLayout.setVisibility(4);
        }
    }

    public void lambda$showPasscodeActivity$3$LaunchActivity() {
        SharedConfig.isWaitingForPasscodeEnter = false;
        Intent intent = this.passcodeSaveIntent;
        if (intent != null) {
            handleIntent(intent, this.passcodeSaveIntentIsNew, this.passcodeSaveIntentIsRestore, true);
            this.passcodeSaveIntent = null;
        }
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        this.actionBarLayout.setVisibility(0);
        this.actionBarLayout.showLastFragment();
        if (AndroidUtilities.isTablet()) {
            this.layersActionBarLayout.showLastFragment();
            this.rightActionBarLayout.showLastFragment();
            if (this.layersActionBarLayout.getVisibility() == 4) {
                this.layersActionBarLayout.setVisibility(0);
            }
            this.rightActionBarLayout.setVisibility(0);
        }
    }

    private boolean handleIntent(Intent intent, boolean z, boolean z2, boolean z3) {
        long j;
        String str;
        long j2;
        final int[] iArr;
        Intent intent2;
        final LaunchActivity launchActivity;
        boolean z4;
        boolean z5;
        boolean z6;
        int i;
        boolean z7;
        boolean z8;
        boolean z9;
        int i2;
        int i3;
        int i4;
        int i5;
        String str2;
        boolean z10;
        boolean z11;
        boolean z12;
        boolean z13;
        boolean z14;
        boolean z15;
        boolean z16;
        boolean z17;
        ArrayList parcelableArrayListExtra;
        String type;
        boolean z18;
        int[] iArr2;
        int i6;
        int i7;
        String str3;
        String str4;
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        String str10;
        String str11;
        String str12;
        String str13;
        String str14;
        String str15;
        String str16;
        String str17;
        String str18;
        String str19;
        boolean z19;
        int i8;
        Cursor query;
        Throwable th;
        String path;
        String str20;
        String str21;
        boolean z20;
        boolean z21;
        String str22;
        String str23;
        String str24;
        String str25;
        String str26;
        String str27;
        String str28;
        String str29;
        String str30;
        int i9;
        String str31;
        String str32;
        String str33;
        String str34;
        String[] split;
        String str35;
        String[] split2;
        boolean z22;
        int i10;
        int i11;
        int parseInt;
        boolean z23;
        CharSequence charSequenceExtra;
        if (AndroidUtilities.handleProxyIntent(this, intent)) {
            this.actionBarLayout.showLastFragment();
            if (AndroidUtilities.isTablet()) {
                this.layersActionBarLayout.showLastFragment();
                this.rightActionBarLayout.showLastFragment();
            }
            return true;
        }
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible() && (intent == null || !"android.intent.action.MAIN".equals(intent.getAction()))) {
            PhotoViewer.getInstance().closePhoto(false, true);
        }
        int flags = intent.getFlags();
        int[] iArr3 = {intent.getIntExtra("currentAccount", UserConfig.selectedAccount)};
        switchToAccount(iArr3[0], true);
        if (!z3 && (AndroidUtilities.needShowPasscode(true) || SharedConfig.isWaitingForPasscodeEnter)) {
            showPasscodeActivity();
            this.passcodeSaveIntent = intent;
            this.passcodeSaveIntentIsNew = z;
            this.passcodeSaveIntentIsRestore = z2;
            UserConfig.getInstance(this.currentAccount).saveConfig(false);
            return false;
        }
        if (SharedConfig.directShare && intent != null && intent.getExtras() != null) {
            long j3 = intent.getExtras().getLong("dialogId", 0L);
            if (intent.getExtras().getLong("hash", 0L) == SharedConfig.directShareHash) {
                j = j3;
                String str36 = null;
                this.photoPathsArray = null;
                this.videoPath = null;
                this.sendingText = null;
                this.documentsPathsArray = null;
                this.documentsOriginalPathsArray = null;
                this.documentsMimeType = null;
                this.documentsUrisArray = null;
                this.contactsToSend = null;
                this.contactsToSendUri = null;
                if ((flags & 1048576) == 0 || intent == null || intent.getAction() == null || z2) {
                    str = "message_id";
                    j2 = 0;
                    iArr = iArr3;
                    intent2 = intent;
                    launchActivity = this;
                    z4 = false;
                } else {
                    if ("android.intent.action.SEND".equals(intent.getAction())) {
                        String type2 = intent.getType();
                        if (type2 != null && type2.equals("text/x-vcard")) {
                            try {
                                Uri uri = (Uri) intent.getExtras().get("android.intent.extra.STREAM");
                                if (uri != null) {
                                    this.contactsToSend = AndroidUtilities.loadVCardFromStream(uri, this.currentAccount, false, null, null);
                                    this.contactsToSendUri = uri;
                                }
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                            z23 = true;
                            if (z23) {
                            }
                        } else {
                            String stringExtra = intent.getStringExtra("android.intent.extra.TEXT");
                            if (stringExtra == null && (charSequenceExtra = intent.getCharSequenceExtra("android.intent.extra.TEXT")) != null) {
                                stringExtra = charSequenceExtra.toString();
                            }
                            String stringExtra2 = intent.getStringExtra("android.intent.extra.SUBJECT");
                            if (!TextUtils.isEmpty(stringExtra)) {
                                if ((stringExtra.startsWith("http://") || stringExtra.startsWith("https://")) && !TextUtils.isEmpty(stringExtra2)) {
                                    stringExtra = stringExtra2 + "\n" + stringExtra;
                                }
                                this.sendingText = stringExtra;
                            } else if (!TextUtils.isEmpty(stringExtra2)) {
                                this.sendingText = stringExtra2;
                            }
                            Parcelable parcelableExtra = intent.getParcelableExtra("android.intent.extra.STREAM");
                            if (parcelableExtra != null) {
                                boolean z24 = parcelableExtra instanceof Uri;
                                Parcelable parcelable = parcelableExtra;
                                if (!z24) {
                                    parcelable = Uri.parse(parcelableExtra.toString());
                                }
                                Uri uri2 = (Uri) parcelable;
                                boolean z25 = uri2 != null && AndroidUtilities.isInternalUri(uri2);
                                if (!z25) {
                                    if (uri2 != null && ((type2 != null && type2.startsWith("image/")) || uri2.toString().toLowerCase().endsWith(".jpg"))) {
                                        if (this.photoPathsArray == null) {
                                            this.photoPathsArray = new ArrayList<>();
                                        }
                                        SendMessagesHelper.SendingMediaInfo sendingMediaInfo = new SendMessagesHelper.SendingMediaInfo();
                                        sendingMediaInfo.uri = uri2;
                                        this.photoPathsArray.add(sendingMediaInfo);
                                    } else {
                                        String path2 = AndroidUtilities.getPath(uri2);
                                        if (path2 != null) {
                                            if (path2.startsWith("file:")) {
                                                path2 = path2.replace("file://", "");
                                            }
                                            if (type2 != null && type2.startsWith("video/")) {
                                                this.videoPath = path2;
                                            } else {
                                                if (this.documentsPathsArray == null) {
                                                    this.documentsPathsArray = new ArrayList<>();
                                                    this.documentsOriginalPathsArray = new ArrayList<>();
                                                }
                                                this.documentsPathsArray.add(path2);
                                                this.documentsOriginalPathsArray.add(uri2.toString());
                                            }
                                        } else {
                                            if (this.documentsUrisArray == null) {
                                                this.documentsUrisArray = new ArrayList<>();
                                            }
                                            this.documentsUrisArray.add(uri2);
                                            this.documentsMimeType = type2;
                                        }
                                    }
                                }
                                z23 = z25;
                                if (z23) {
                                    ToastUtils.show((CharSequence) "Unsupported content");
                                }
                            }
                        }
                        z23 = false;
                        if (z23) {
                        }
                    } else if ("android.intent.action.SEND_MULTIPLE".equals(intent.getAction())) {
                        try {
                            parcelableArrayListExtra = intent.getParcelableArrayListExtra("android.intent.extra.STREAM");
                            type = intent.getType();
                            if (parcelableArrayListExtra != null) {
                                int i12 = 0;
                                while (i12 < parcelableArrayListExtra.size()) {
                                    Parcelable parcelable2 = (Parcelable) parcelableArrayListExtra.get(i12);
                                    boolean z26 = parcelable2 instanceof Uri;
                                    Parcelable parcelable3 = parcelable2;
                                    if (!z26) {
                                        parcelable3 = Uri.parse(parcelable2.toString());
                                    }
                                    Uri uri3 = (Uri) parcelable3;
                                    if (uri3 != null && AndroidUtilities.isInternalUri(uri3)) {
                                        parcelableArrayListExtra.remove(i12);
                                        i12--;
                                    }
                                    i12++;
                                }
                                if (parcelableArrayListExtra.isEmpty()) {
                                    parcelableArrayListExtra = null;
                                }
                            }
                        } catch (Exception e2) {
                            FileLog.e(e2);
                        }
                        if (parcelableArrayListExtra != null) {
                            if (type != null && type.startsWith("image/")) {
                                for (int i13 = 0; i13 < parcelableArrayListExtra.size(); i13++) {
                                    Parcelable parcelable4 = (Parcelable) parcelableArrayListExtra.get(i13);
                                    boolean z27 = parcelable4 instanceof Uri;
                                    Parcelable parcelable5 = parcelable4;
                                    if (!z27) {
                                        parcelable5 = Uri.parse(parcelable4.toString());
                                    }
                                    Uri uri4 = (Uri) parcelable5;
                                    if (this.photoPathsArray == null) {
                                        this.photoPathsArray = new ArrayList<>();
                                    }
                                    SendMessagesHelper.SendingMediaInfo sendingMediaInfo2 = new SendMessagesHelper.SendingMediaInfo();
                                    sendingMediaInfo2.uri = uri4;
                                    this.photoPathsArray.add(sendingMediaInfo2);
                                }
                            } else {
                                for (int i14 = 0; i14 < parcelableArrayListExtra.size(); i14++) {
                                    Object obj = (Parcelable) parcelableArrayListExtra.get(i14);
                                    if (!(obj instanceof Uri)) {
                                        obj = Uri.parse(obj.toString());
                                    }
                                    Uri uri5 = (Uri) obj;
                                    String path3 = AndroidUtilities.getPath(uri5);
                                    String obj2 = obj.toString();
                                    if (obj2 == null) {
                                        obj2 = path3;
                                    }
                                    if (path3 != null) {
                                        if (path3.startsWith("file:")) {
                                            path3 = path3.replace("file://", "");
                                        }
                                        if (this.documentsPathsArray == null) {
                                            this.documentsPathsArray = new ArrayList<>();
                                            this.documentsOriginalPathsArray = new ArrayList<>();
                                        }
                                        this.documentsPathsArray.add(path3);
                                        this.documentsOriginalPathsArray.add(obj2);
                                    } else {
                                        if (this.documentsUrisArray == null) {
                                            this.documentsUrisArray = new ArrayList<>();
                                        }
                                        this.documentsUrisArray.add(uri5);
                                        this.documentsMimeType = type;
                                    }
                                }
                            }
                            z17 = false;
                            if (z17) {
                                ToastUtils.show((CharSequence) "Unsupported content");
                            }
                        }
                        z17 = true;
                        if (z17) {
                        }
                    } else {
                        if ("android.intent.action.VIEW".equals(intent.getAction())) {
                            Uri data = intent.getData();
                            if (data != null) {
                                String scheme = data.getScheme();
                                if (BuildVars.DEBUG_VERSION) {
                                    Log.i("OpenApp", "handleIntent() ===>  , uri = " + data.toString() + " , scheme = " + scheme);
                                }
                                if (scheme != null) {
                                    if (scheme.equals("http") || scheme.equals("https")) {
                                        String lowerCase = data.getHost().toLowerCase();
                                        if (lowerCase.equals("www.shareinstall.com.cn")) {
                                            String queryParameter = data.getQueryParameter("Key");
                                            if (!TextUtils.isEmpty(queryParameter)) {
                                                String str37 = new String(Base64.decode(queryParameter.replace("%3D", "="), 0));
                                                String[] split3 = str37.split("#");
                                                String str38 = split3[0].split("=")[1];
                                                String str39 = split3[1].split("=")[1];
                                                if (str37.contains("Uname")) {
                                                    MessagesController.getInstance(UserConfig.selectedAccount).openByUserName(split3[2].split("=")[1], getActionBarLayout().getCurrentFragment(), 1, true);
                                                } else {
                                                    TLRPC.TL_user tL_user = new TLRPC.TL_user();
                                                    try {
                                                        tL_user.id = Integer.valueOf(str38).intValue();
                                                        tL_user.access_hash = Long.valueOf(str39).longValue();
                                                        getUserInfo(tL_user);
                                                    } catch (NumberFormatException e3) {
                                                        FileLog.e("parse qr code err:" + e3);
                                                    }
                                                }
                                            }
                                        } else if (lowerCase.equals("m12345.cc") && (path = data.getPath()) != null && path.length() > 1) {
                                            String substring = path.substring(1);
                                            if (substring.startsWith("install.html")) {
                                                String queryParameter2 = data.getQueryParameter("Key");
                                                if (!TextUtils.isEmpty(queryParameter2)) {
                                                    String str40 = new String(Base64.decode(queryParameter2.replace("%3D", "="), 0));
                                                    String[] split4 = str40.split("#");
                                                    String str41 = split4[0].split("=")[1];
                                                    String str42 = split4[1].split("=")[1];
                                                    if (str40.contains("Uname")) {
                                                        MessagesController.getInstance(UserConfig.selectedAccount).openByUserName(split4[2].split("=")[1], getActionBarLayout().getCurrentFragment(), 1, true);
                                                    } else {
                                                        TLRPC.TL_user tL_user2 = new TLRPC.TL_user();
                                                        try {
                                                            tL_user2.id = Integer.valueOf(str41).intValue();
                                                            tL_user2.access_hash = Long.valueOf(str42).longValue();
                                                            getUserInfo(tL_user2);
                                                        } catch (NumberFormatException e4) {
                                                            FileLog.e("parse qr code err:" + e4);
                                                        }
                                                    }
                                                }
                                            } else if (substring.startsWith("bg/")) {
                                                TLRPC.TL_wallPaper tL_wallPaper = new TLRPC.TL_wallPaper();
                                                tL_wallPaper.settings = new TLRPC.TL_wallPaperSettings();
                                                tL_wallPaper.slug = substring.replace("bg/", "");
                                                if (tL_wallPaper.slug != null && tL_wallPaper.slug.length() == 6) {
                                                    try {
                                                        tL_wallPaper.settings.background_color = Integer.parseInt(tL_wallPaper.slug, 16) | (-16777216);
                                                    } catch (Exception unused) {
                                                    }
                                                    str20 = null;
                                                    tL_wallPaper.slug = null;
                                                } else {
                                                    str20 = null;
                                                    String queryParameter3 = data.getQueryParameter("mode");
                                                    if (queryParameter3 != null && (split = queryParameter3.toLowerCase().split(" ")) != null && split.length > 0) {
                                                        for (int i15 = 0; i15 < split.length; i15++) {
                                                            if ("blur".equals(split[i15])) {
                                                                tL_wallPaper.settings.blur = true;
                                                            } else if ("motion".equals(split[i15])) {
                                                                tL_wallPaper.settings.motion = true;
                                                            }
                                                        }
                                                    }
                                                    String queryParameter4 = data.getQueryParameter("intensity");
                                                    if (!TextUtils.isEmpty(queryParameter4)) {
                                                        tL_wallPaper.settings.intensity = Utilities.parseInt(queryParameter4).intValue();
                                                    } else {
                                                        tL_wallPaper.settings.intensity = 50;
                                                    }
                                                    try {
                                                        String queryParameter5 = data.getQueryParameter("bg_color");
                                                        if (!TextUtils.isEmpty(queryParameter5)) {
                                                            tL_wallPaper.settings.background_color = Integer.parseInt(queryParameter5, 16) | (-16777216);
                                                        } else {
                                                            tL_wallPaper.settings.background_color = -1;
                                                        }
                                                    } catch (Exception unused2) {
                                                    }
                                                }
                                                str28 = tL_wallPaper;
                                                str22 = str20;
                                                str23 = str22;
                                                str5 = str23;
                                                str6 = str5;
                                                str7 = str6;
                                                str8 = str7;
                                                str9 = str8;
                                                str10 = str9;
                                                str24 = str10;
                                                str25 = str24;
                                                str26 = str25;
                                                str27 = str26;
                                                str29 = str27;
                                                str30 = str29;
                                                z21 = false;
                                                str14 = str20;
                                                str16 = str14;
                                                str15 = str25;
                                                str19 = str26;
                                                str17 = str27;
                                                str18 = str28;
                                                str11 = str29;
                                                str12 = str30;
                                                i8 = 0;
                                                i6 = 0;
                                                str13 = str24;
                                                z19 = z21;
                                                i7 = 0;
                                                String str43 = str23;
                                                str4 = str22;
                                                str3 = str43;
                                            } else {
                                                str20 = null;
                                                if (substring.startsWith("login/")) {
                                                    str27 = substring.replace("login/", "");
                                                    str22 = null;
                                                    str23 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    str24 = null;
                                                    str25 = null;
                                                    str26 = null;
                                                    str28 = null;
                                                    str29 = str28;
                                                    str30 = str29;
                                                    z21 = false;
                                                    str14 = str20;
                                                    str16 = str14;
                                                    str15 = str25;
                                                    str19 = str26;
                                                    str17 = str27;
                                                    str18 = str28;
                                                    str11 = str29;
                                                    str12 = str30;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    str13 = str24;
                                                    z19 = z21;
                                                    i7 = 0;
                                                    String str432 = str23;
                                                    str4 = str22;
                                                    str3 = str432;
                                                } else if (substring.startsWith("joinchat/")) {
                                                    str7 = substring.replace("joinchat/", "");
                                                    str22 = null;
                                                    str23 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str8 = null;
                                                    str9 = str8;
                                                    str10 = str9;
                                                    str24 = str10;
                                                    str25 = str24;
                                                    str26 = str25;
                                                    str27 = str26;
                                                    str28 = str27;
                                                    str29 = str28;
                                                    str30 = str29;
                                                    z21 = false;
                                                    str14 = str20;
                                                    str16 = str14;
                                                    str15 = str25;
                                                    str19 = str26;
                                                    str17 = str27;
                                                    str18 = str28;
                                                    str11 = str29;
                                                    str12 = str30;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    str13 = str24;
                                                    z19 = z21;
                                                    i7 = 0;
                                                    String str4322 = str23;
                                                    str4 = str22;
                                                    str3 = str4322;
                                                } else if (substring.startsWith("addstickers/")) {
                                                    str8 = substring.replace("addstickers/", "");
                                                    str22 = null;
                                                    str23 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str9 = null;
                                                    str10 = str9;
                                                    str24 = str10;
                                                    str25 = str24;
                                                    str26 = str25;
                                                    str27 = str26;
                                                    str28 = str27;
                                                    str29 = str28;
                                                    str30 = str29;
                                                    z21 = false;
                                                    str14 = str20;
                                                    str16 = str14;
                                                    str15 = str25;
                                                    str19 = str26;
                                                    str17 = str27;
                                                    str18 = str28;
                                                    str11 = str29;
                                                    str12 = str30;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    str13 = str24;
                                                    z19 = z21;
                                                    i7 = 0;
                                                    String str43222 = str23;
                                                    str4 = str22;
                                                    str3 = str43222;
                                                } else {
                                                    if (substring.startsWith("msg/") || substring.startsWith("share/")) {
                                                        String queryParameter6 = data.getQueryParameter(ImagesContract.URL);
                                                        str21 = queryParameter6 != null ? queryParameter6 : "";
                                                        if (data.getQueryParameter("text") != null) {
                                                            if (str21.length() > 0) {
                                                                str21 = str21 + "\n";
                                                                z20 = true;
                                                            } else {
                                                                z20 = false;
                                                            }
                                                            str21 = str21 + data.getQueryParameter("text");
                                                        } else {
                                                            z20 = false;
                                                        }
                                                        if (str21.length() > 16384) {
                                                            str21 = str21.substring(0, 16384);
                                                        }
                                                        while (str21.endsWith("\n")) {
                                                            str21 = str21.substring(0, str21.length() - 1);
                                                        }
                                                        z21 = z20;
                                                        str22 = str21;
                                                        str23 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        str24 = null;
                                                        str25 = null;
                                                        str26 = null;
                                                        str27 = null;
                                                        str28 = null;
                                                        str29 = null;
                                                        str30 = null;
                                                    } else if (substring.startsWith("confirmphone")) {
                                                        str5 = data.getQueryParameter("phone");
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        str24 = null;
                                                        str25 = null;
                                                        str26 = null;
                                                        str27 = null;
                                                        str28 = null;
                                                        str29 = null;
                                                        str30 = null;
                                                        z21 = false;
                                                        str23 = data.getQueryParameter("hash");
                                                        str22 = null;
                                                    } else if (substring.startsWith("setlanguage/")) {
                                                        str25 = substring.substring(12);
                                                        str22 = null;
                                                        str23 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        str24 = null;
                                                        str26 = null;
                                                        str27 = str26;
                                                        str28 = str27;
                                                        str29 = str28;
                                                        str30 = str29;
                                                        z21 = false;
                                                    } else if (substring.startsWith("addtheme/")) {
                                                        str26 = substring.substring(9);
                                                        str22 = null;
                                                        str23 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        str24 = null;
                                                        str25 = null;
                                                        str27 = null;
                                                        str28 = str27;
                                                        str29 = str28;
                                                        str30 = str29;
                                                        z21 = false;
                                                    } else if (substring.startsWith("c/")) {
                                                        List<String> pathSegments = data.getPathSegments();
                                                        if (pathSegments.size() == 3) {
                                                            Integer parseInt2 = Utilities.parseInt(pathSegments.get(1));
                                                            Integer parseInt3 = Utilities.parseInt(pathSegments.get(2));
                                                            if (parseInt3.intValue() != 0 && parseInt2.intValue() != 0) {
                                                                str34 = parseInt3;
                                                                str33 = parseInt2;
                                                                str30 = str33;
                                                                str29 = str34;
                                                                str22 = null;
                                                                str23 = null;
                                                                str5 = null;
                                                                str6 = null;
                                                                str7 = null;
                                                                str8 = null;
                                                                str9 = null;
                                                                str10 = null;
                                                                str24 = null;
                                                                str25 = null;
                                                                str26 = null;
                                                                str27 = null;
                                                                str28 = null;
                                                                z21 = false;
                                                            }
                                                        }
                                                        str33 = null;
                                                        str34 = null;
                                                        str30 = str33;
                                                        str29 = str34;
                                                        str22 = null;
                                                        str23 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        str24 = null;
                                                        str25 = null;
                                                        str26 = null;
                                                        str27 = null;
                                                        str28 = null;
                                                        z21 = false;
                                                    } else {
                                                        if (substring.length() >= 1) {
                                                            ArrayList arrayList = new ArrayList(data.getPathSegments());
                                                            if (arrayList.size() > 0) {
                                                                i9 = 0;
                                                                if (((String) arrayList.get(0)).equals("s")) {
                                                                    arrayList.remove(0);
                                                                }
                                                            } else {
                                                                i9 = 0;
                                                            }
                                                            if (arrayList.size() > 0) {
                                                                str32 = (String) arrayList.get(i9);
                                                                if (arrayList.size() > 1) {
                                                                    Integer parseInt4 = Utilities.parseInt((CharSequence) arrayList.get(1));
                                                                    int intValue = parseInt4.intValue();
                                                                    str31 = parseInt4;
                                                                }
                                                                str31 = null;
                                                            } else {
                                                                str31 = null;
                                                                str32 = null;
                                                            }
                                                            String queryParameter7 = data.getQueryParameter(TtmlNode.START);
                                                            String queryParameter8 = data.getQueryParameter("startgroup");
                                                            str24 = data.getQueryParameter("game");
                                                            str29 = str31;
                                                            str9 = queryParameter7;
                                                            str10 = queryParameter8;
                                                            str22 = null;
                                                            str23 = null;
                                                            str7 = null;
                                                            str8 = null;
                                                            str25 = null;
                                                            str26 = null;
                                                            str27 = null;
                                                            str28 = null;
                                                            str30 = null;
                                                            z21 = false;
                                                            str6 = str32;
                                                            str5 = null;
                                                        }
                                                        str22 = str20;
                                                        str23 = str22;
                                                        str5 = str23;
                                                        str6 = str5;
                                                        str7 = str6;
                                                        str8 = str7;
                                                        str9 = str8;
                                                        str10 = str9;
                                                        str24 = str10;
                                                        str25 = str24;
                                                        str26 = str25;
                                                        str27 = str26;
                                                        str28 = str27;
                                                        str29 = str28;
                                                        str30 = str29;
                                                        z21 = false;
                                                    }
                                                    str14 = str20;
                                                    str16 = str14;
                                                    str15 = str25;
                                                    str19 = str26;
                                                    str17 = str27;
                                                    str18 = str28;
                                                    str11 = str29;
                                                    str12 = str30;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    str13 = str24;
                                                    z19 = z21;
                                                    i7 = 0;
                                                    String str432222 = str23;
                                                    str4 = str22;
                                                    str3 = str432222;
                                                }
                                            }
                                        }
                                        str20 = null;
                                        str22 = str20;
                                        str23 = str22;
                                        str5 = str23;
                                        str6 = str5;
                                        str7 = str6;
                                        str8 = str7;
                                        str9 = str8;
                                        str10 = str9;
                                        str24 = str10;
                                        str25 = str24;
                                        str26 = str25;
                                        str27 = str26;
                                        str28 = str27;
                                        str29 = str28;
                                        str30 = str29;
                                        z21 = false;
                                        str14 = str20;
                                        str16 = str14;
                                        str15 = str25;
                                        str19 = str26;
                                        str17 = str27;
                                        str18 = str28;
                                        str11 = str29;
                                        str12 = str30;
                                        i8 = 0;
                                        i6 = 0;
                                        str13 = str24;
                                        z19 = z21;
                                        i7 = 0;
                                        String str4322222 = str23;
                                        str4 = str22;
                                        str3 = str4322222;
                                    } else {
                                        if (scheme.equals("hchat")) {
                                            String uri6 = data.toString();
                                            if (uri6.startsWith("hchat:resolve") || uri6.startsWith("hchat://resolve")) {
                                                Uri parse = Uri.parse(uri6.replace("hchat:resolve", "hchat://m12345.cc").replace("hchat://resolve", "hchat://m12345.cc"));
                                                String queryParameter9 = parse.getQueryParameter("domain");
                                                if ("hchatpassport".equals(queryParameter9)) {
                                                    HashMap hashMap = new HashMap();
                                                    String queryParameter10 = parse.getQueryParameter("scope");
                                                    if (!TextUtils.isEmpty(queryParameter10) && queryParameter10.startsWith("{") && queryParameter10.endsWith("}")) {
                                                        hashMap.put("nonce", parse.getQueryParameter("nonce"));
                                                    } else {
                                                        hashMap.put("payload", parse.getQueryParameter("payload"));
                                                    }
                                                    hashMap.put("bot_id", parse.getQueryParameter("bot_id"));
                                                    hashMap.put("scope", queryParameter10);
                                                    hashMap.put("public_key", parse.getQueryParameter("public_key"));
                                                    hashMap.put("callback_url", parse.getQueryParameter("callback_url"));
                                                    str35 = hashMap;
                                                    str14 = str35;
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else {
                                                    String queryParameter11 = parse.getQueryParameter(TtmlNode.START);
                                                    String queryParameter12 = parse.getQueryParameter("startgroup");
                                                    String queryParameter13 = parse.getQueryParameter("game");
                                                    Integer parseInt5 = Utilities.parseInt(parse.getQueryParameter("post"));
                                                    if (parseInt5.intValue() == 0) {
                                                        str9 = queryParameter11;
                                                        str10 = queryParameter12;
                                                        str13 = queryParameter13;
                                                        str3 = null;
                                                        str5 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        z19 = false;
                                                        str11 = null;
                                                    } else {
                                                        str11 = parseInt5;
                                                        str9 = queryParameter11;
                                                        str10 = queryParameter12;
                                                        str13 = queryParameter13;
                                                        str3 = null;
                                                        str5 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        z19 = false;
                                                    }
                                                    str12 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                    str19 = null;
                                                    str6 = queryParameter9;
                                                    str4 = null;
                                                }
                                            } else {
                                                if (uri6.startsWith("hchat:privatepost") || uri6.startsWith("hchat://privatepost")) {
                                                    Uri parse2 = Uri.parse(uri6.replace("hchat:privatepost", "hchat://m12345.cc").replace("hchat://privatepost", "hchat://m12345.cc"));
                                                    Integer parseInt6 = Utilities.parseInt(parse2.getQueryParameter("post"));
                                                    Integer parseInt7 = Utilities.parseInt(parse2.getQueryParameter("channel"));
                                                    if (parseInt6.intValue() == 0 || parseInt7.intValue() == 0) {
                                                        str3 = null;
                                                        str4 = null;
                                                        str5 = null;
                                                    } else {
                                                        str12 = parseInt7;
                                                        str11 = parseInt6;
                                                        str3 = null;
                                                        str4 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        z19 = false;
                                                        str13 = null;
                                                        i8 = 0;
                                                        i6 = 0;
                                                        i7 = 0;
                                                        str14 = null;
                                                        str15 = null;
                                                        str16 = null;
                                                        str17 = null;
                                                        str18 = null;
                                                    }
                                                } else if (uri6.startsWith("hchat:bg") || uri6.startsWith("hchat://bg")) {
                                                    Uri parse3 = Uri.parse(uri6.replace("hchat:bg", "hchat://m12345.cc").replace("hchat://bg", "hchat://m12345.cc"));
                                                    TLRPC.TL_wallPaper tL_wallPaper2 = new TLRPC.TL_wallPaper();
                                                    tL_wallPaper2.settings = new TLRPC.TL_wallPaperSettings();
                                                    tL_wallPaper2.slug = parse3.getQueryParameter("slug");
                                                    if (tL_wallPaper2.slug == null) {
                                                        tL_wallPaper2.slug = parse3.getQueryParameter(TtmlNode.ATTR_TTS_COLOR);
                                                    }
                                                    if (tL_wallPaper2.slug != null && tL_wallPaper2.slug.length() == 6) {
                                                        try {
                                                            tL_wallPaper2.settings.background_color = Integer.parseInt(tL_wallPaper2.slug, 16) | (-16777216);
                                                        } catch (Exception unused3) {
                                                        }
                                                        tL_wallPaper2.slug = null;
                                                    } else {
                                                        String queryParameter14 = parse3.getQueryParameter("mode");
                                                        if (queryParameter14 != null && (split2 = queryParameter14.toLowerCase().split(" ")) != null && split2.length > 0) {
                                                            for (int i16 = 0; i16 < split2.length; i16++) {
                                                                if ("blur".equals(split2[i16])) {
                                                                    tL_wallPaper2.settings.blur = true;
                                                                } else if ("motion".equals(split2[i16])) {
                                                                    tL_wallPaper2.settings.motion = true;
                                                                }
                                                            }
                                                        }
                                                        tL_wallPaper2.settings.intensity = Utilities.parseInt(parse3.getQueryParameter("intensity")).intValue();
                                                        try {
                                                            String queryParameter15 = parse3.getQueryParameter("bg_color");
                                                            if (!TextUtils.isEmpty(queryParameter15)) {
                                                                tL_wallPaper2.settings.background_color = Integer.parseInt(queryParameter15, 16) | (-16777216);
                                                            }
                                                        } catch (Exception unused4) {
                                                        }
                                                    }
                                                    str18 = tL_wallPaper2;
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                } else if (uri6.startsWith("hchat:join") || uri6.startsWith("hchat://join")) {
                                                    str7 = Uri.parse(uri6.replace("hchat:join", "hchat://m12345.cc").replace("hchat://join", "hchat://m12345.cc")).getQueryParameter("invite");
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:addstickers") || uri6.startsWith("hchat://addstickers")) {
                                                    str8 = Uri.parse(uri6.replace("hchat:addstickers", "hchat://m12345.cc").replace("hchat://addstickers", "hchat://m12345.cc")).getQueryParameter("set");
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:msg") || uri6.startsWith("hchat://msg") || uri6.startsWith("hchat://share") || uri6.startsWith("hchat:share")) {
                                                    Uri parse4 = Uri.parse(uri6.replace("hchat:msg", "hchat://m12345.cc").replace("hchat://msg", "hchat://m12345.cc").replace("hchat://share", "hchat://m12345.cc").replace("hchat:share", "hchat://m12345.cc"));
                                                    String queryParameter16 = parse4.getQueryParameter(ImagesContract.URL);
                                                    str21 = queryParameter16 != null ? queryParameter16 : "";
                                                    if (parse4.getQueryParameter("text") != null) {
                                                        if (str21.length() > 0) {
                                                            str21 = str21 + "\n";
                                                            z22 = true;
                                                        } else {
                                                            z22 = false;
                                                        }
                                                        str21 = str21 + parse4.getQueryParameter("text");
                                                    } else {
                                                        z22 = false;
                                                    }
                                                    String substring2 = str21.length() > 16384 ? str21.substring(0, 16384) : str21;
                                                    while (substring2.endsWith("\n")) {
                                                        substring2 = substring2.substring(0, substring2.length() - 1);
                                                    }
                                                    z19 = z22;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                    str19 = null;
                                                    str4 = substring2;
                                                    str3 = null;
                                                } else if (uri6.startsWith("hchat:confirmphone") || uri6.startsWith("hchat://confirmphone")) {
                                                    Uri parse5 = Uri.parse(uri6.replace("hchat:confirmphone", "hchat://m12345.cc").replace("hchat://confirmphone", "hchat://m12345.cc"));
                                                    String queryParameter17 = parse5.getQueryParameter("phone");
                                                    str3 = parse5.getQueryParameter("hash");
                                                    str5 = queryParameter17;
                                                    str4 = null;
                                                } else if (uri6.startsWith("hchat:login") || uri6.startsWith("hchat://login")) {
                                                    str17 = Uri.parse(uri6.replace("hchat:login", "hchat://m12345.cc").replace("hchat://login", "hchat://m12345.cc")).getQueryParameter("code");
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:openmessage") || uri6.startsWith("hchat://openmessage")) {
                                                    Uri parse6 = Uri.parse(uri6.replace("hchat:openmessage", "hchat://m12345.cc").replace("hchat://openmessage", "hchat://m12345.cc"));
                                                    String queryParameter18 = parse6.getQueryParameter("user_id");
                                                    String queryParameter19 = parse6.getQueryParameter("chat_id");
                                                    String queryParameter20 = parse6.getQueryParameter("message_id");
                                                    if (queryParameter18 != null) {
                                                        i10 = Integer.parseInt(queryParameter18);
                                                        i11 = 0;
                                                        if (queryParameter20 != null) {
                                                            try {
                                                                parseInt = Integer.parseInt(queryParameter20);
                                                            } catch (NumberFormatException unused5) {
                                                            }
                                                            i7 = parseInt;
                                                            i8 = i10;
                                                            i6 = i11;
                                                            str3 = null;
                                                            str4 = null;
                                                            str5 = null;
                                                            str6 = null;
                                                            str7 = null;
                                                            str8 = null;
                                                            str9 = null;
                                                            str10 = null;
                                                            z19 = false;
                                                            str11 = null;
                                                            str12 = null;
                                                            str13 = null;
                                                            str14 = null;
                                                            str15 = null;
                                                            str16 = null;
                                                            str17 = null;
                                                            str18 = null;
                                                        }
                                                        parseInt = 0;
                                                        i7 = parseInt;
                                                        i8 = i10;
                                                        i6 = i11;
                                                        str3 = null;
                                                        str4 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        z19 = false;
                                                        str11 = null;
                                                        str12 = null;
                                                        str13 = null;
                                                        str14 = null;
                                                        str15 = null;
                                                        str16 = null;
                                                        str17 = null;
                                                        str18 = null;
                                                    } else {
                                                        if (queryParameter19 != null) {
                                                            i11 = Integer.parseInt(queryParameter19);
                                                            i10 = 0;
                                                            if (queryParameter20 != null) {
                                                            }
                                                            parseInt = 0;
                                                            i7 = parseInt;
                                                            i8 = i10;
                                                            i6 = i11;
                                                            str3 = null;
                                                            str4 = null;
                                                            str5 = null;
                                                            str6 = null;
                                                            str7 = null;
                                                            str8 = null;
                                                            str9 = null;
                                                            str10 = null;
                                                            z19 = false;
                                                            str11 = null;
                                                            str12 = null;
                                                            str13 = null;
                                                            str14 = null;
                                                            str15 = null;
                                                            str16 = null;
                                                            str17 = null;
                                                            str18 = null;
                                                        }
                                                        i10 = 0;
                                                        i11 = 0;
                                                        if (queryParameter20 != null) {
                                                        }
                                                        parseInt = 0;
                                                        i7 = parseInt;
                                                        i8 = i10;
                                                        i6 = i11;
                                                        str3 = null;
                                                        str4 = null;
                                                        str5 = null;
                                                        str6 = null;
                                                        str7 = null;
                                                        str8 = null;
                                                        str9 = null;
                                                        str10 = null;
                                                        z19 = false;
                                                        str11 = null;
                                                        str12 = null;
                                                        str13 = null;
                                                        str14 = null;
                                                        str15 = null;
                                                        str16 = null;
                                                        str17 = null;
                                                        str18 = null;
                                                    }
                                                } else if (uri6.startsWith("hchat:passport") || uri6.startsWith("hchat://passport") || uri6.startsWith("hchat:secureid")) {
                                                    Uri parse7 = Uri.parse(uri6.replace("hchat:passport", "hchat://m12345.cc").replace("hchat://passport", "hchat://m12345.cc").replace("hchat:secureid", "hchat://m12345.cc"));
                                                    HashMap hashMap2 = new HashMap();
                                                    String queryParameter21 = parse7.getQueryParameter("scope");
                                                    if (!TextUtils.isEmpty(queryParameter21) && queryParameter21.startsWith("{") && queryParameter21.endsWith("}")) {
                                                        hashMap2.put("nonce", parse7.getQueryParameter("nonce"));
                                                    } else {
                                                        hashMap2.put("payload", parse7.getQueryParameter("payload"));
                                                    }
                                                    hashMap2.put("bot_id", parse7.getQueryParameter("bot_id"));
                                                    hashMap2.put("scope", queryParameter21);
                                                    hashMap2.put("public_key", parse7.getQueryParameter("public_key"));
                                                    hashMap2.put("callback_url", parse7.getQueryParameter("callback_url"));
                                                    str35 = hashMap2;
                                                    str14 = str35;
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:setlanguage") || uri6.startsWith("hchat://setlanguage")) {
                                                    str15 = Uri.parse(uri6.replace("hchat:setlanguage", "hchat://m12345.cc").replace("hchat://setlanguage", "hchat://m12345.cc")).getQueryParameter("lang");
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:addtheme") || uri6.startsWith("hchat://addtheme")) {
                                                    str19 = Uri.parse(uri6.replace("hchat:addtheme", "hchat://m12345.cc").replace("hchat://addtheme", "hchat://m12345.cc")).getQueryParameter("slug");
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str16 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                } else if (uri6.startsWith("hchat:openKey") || uri6.startsWith("hchat://openKey")) {
                                                    parseSechmeOpenAccount(uri6);
                                                } else {
                                                    String replace = uri6.replace("hchat://", "").replace("hchat:", "");
                                                    int indexOf = replace.indexOf(63);
                                                    if (indexOf >= 0) {
                                                        replace = replace.substring(0, indexOf);
                                                    }
                                                    str16 = replace;
                                                    str3 = null;
                                                    str4 = null;
                                                    str5 = null;
                                                    str6 = null;
                                                    str7 = null;
                                                    str8 = null;
                                                    str9 = null;
                                                    str10 = null;
                                                    z19 = false;
                                                    str11 = null;
                                                    str12 = null;
                                                    str13 = null;
                                                    i8 = 0;
                                                    i6 = 0;
                                                    i7 = 0;
                                                    str14 = null;
                                                    str15 = null;
                                                    str17 = null;
                                                    str18 = null;
                                                }
                                                str6 = null;
                                                str7 = null;
                                                str8 = null;
                                                str9 = null;
                                                str10 = null;
                                                z19 = false;
                                                str11 = null;
                                                str12 = null;
                                                str13 = null;
                                                i8 = 0;
                                                i6 = 0;
                                                i7 = 0;
                                                str14 = null;
                                                str15 = null;
                                                str16 = null;
                                                str17 = null;
                                                str18 = null;
                                            }
                                            str19 = null;
                                        }
                                        str36 = null;
                                    }
                                    if (str17 != null && !UserConfig.getInstance(this.currentAccount).isClientActivated()) {
                                        str = "message_id";
                                        iArr2 = iArr3;
                                        launchActivity = this;
                                        j2 = 0;
                                    } else if (str5 == null || str3 != null) {
                                        str = "message_id";
                                        iArr2 = iArr3;
                                        j2 = 0;
                                        final Bundle bundle = new Bundle();
                                        bundle.putString("phone", str5);
                                        bundle.putString("hash", str3);
                                        launchActivity = this;
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public final void run() {
                                                LaunchActivity.this.lambda$handleIntent$4$LaunchActivity(bundle);
                                            }
                                        });
                                    } else if (str6 != null || str7 != null || str8 != null || str4 != null || str13 != null || str14 != null || str16 != null || str15 != null || str17 != null || str18 != null || str12 != null || str19 != null) {
                                        j2 = 0;
                                        str = "message_id";
                                        iArr2 = iArr3;
                                        runLinkRequest(iArr3[0], str6, str7, str8, str9, str10, (str4 == null || !str4.startsWith("@")) ? str4 : " " + str4, z19, str11, str12, str13, str14, str15, str16, str17, str18, str19, 0);
                                        launchActivity = this;
                                    } else {
                                        try {
                                            query = getContentResolver().query(intent.getData(), null, null, null, null);
                                        } catch (Exception e5) {
                                            e = e5;
                                        }
                                        try {
                                        } catch (Exception e6) {
                                            e = e6;
                                            FileLog.e(e);
                                            str = "message_id";
                                            iArr2 = iArr3;
                                            launchActivity = this;
                                            i = i8;
                                            j2 = 0;
                                            intent2 = intent;
                                            i5 = i6;
                                            i3 = i7;
                                            iArr = iArr2;
                                            z13 = false;
                                            i2 = 0;
                                            z9 = false;
                                            z8 = false;
                                            z7 = false;
                                            z6 = false;
                                            z12 = z13;
                                            z5 = false;
                                            i4 = z12;
                                            if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                            }
                                            str2 = null;
                                            z10 = z;
                                            z11 = false;
                                            if (!z11) {
                                            }
                                            intent2.setAction(str2);
                                            return z11;
                                        }
                                        if (query != null) {
                                            try {
                                                if (query.moveToFirst()) {
                                                    int intValue2 = Utilities.parseInt(query.getString(query.getColumnIndex("account_name"))).intValue();
                                                    int i17 = 0;
                                                    while (true) {
                                                        if (i17 >= 3) {
                                                            break;
                                                        }
                                                        try {
                                                            if (UserConfig.getInstance(i17).getClientUserId() == intValue2) {
                                                                break;
                                                            }
                                                            try {
                                                                i17++;
                                                            } catch (Throwable th2) {
                                                                th = th2;
                                                                th = th;
                                                                try {
                                                                    throw th;
                                                                } catch (Throwable th3) {
                                                                    if (query == null) {
                                                                        throw th3;
                                                                    }
                                                                    try {
                                                                        query.close();
                                                                        throw th3;
                                                                    } catch (Throwable th4) {
                                                                        th.addSuppressed(th4);
                                                                        throw th3;
                                                                    }
                                                                }
                                                            }
                                                        } catch (Throwable th5) {
                                                            th = th5;
                                                            th = th;
                                                            throw th;
                                                        }
                                                    }
                                                    int i18 = query.getInt(query.getColumnIndex("DATA4"));
                                                    NotificationCenter.getInstance(iArr3[0]).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                                                    i8 = i18;
                                                    if (query != null) {
                                                        query.close();
                                                    }
                                                    str = "message_id";
                                                    iArr2 = iArr3;
                                                    launchActivity = this;
                                                    i = i8;
                                                    j2 = 0;
                                                }
                                            } catch (Throwable th6) {
                                                th = th6;
                                            }
                                        }
                                        if (query != null) {
                                        }
                                        str = "message_id";
                                        iArr2 = iArr3;
                                        launchActivity = this;
                                        i = i8;
                                        j2 = 0;
                                    }
                                    i = i8;
                                }
                                str3 = str36;
                                str4 = str3;
                                str5 = str4;
                                str6 = str5;
                                str7 = str6;
                                str8 = str7;
                                str9 = str8;
                                str10 = str9;
                                str11 = str10;
                                str12 = str11;
                                str13 = str12;
                                str14 = str13;
                                str15 = str14;
                                str16 = str15;
                                str17 = str16;
                                str18 = str17;
                                str19 = str18;
                                z19 = false;
                                i8 = 0;
                                i6 = 0;
                                i7 = 0;
                                if (str17 != null) {
                                }
                                if (str5 == null) {
                                }
                                str = "message_id";
                                iArr2 = iArr3;
                                j2 = 0;
                                final Bundle bundle2 = new Bundle();
                                bundle2.putString("phone", str5);
                                bundle2.putString("hash", str3);
                                launchActivity = this;
                                AndroidUtilities.runOnUIThread(new Runnable() {
                                    @Override
                                    public final void run() {
                                        LaunchActivity.this.lambda$handleIntent$4$LaunchActivity(bundle2);
                                    }
                                });
                                i = i8;
                            } else {
                                str = "message_id";
                                iArr2 = iArr3;
                                launchActivity = this;
                                j2 = 0;
                                i = 0;
                                i6 = 0;
                                i7 = 0;
                            }
                            intent2 = intent;
                            i5 = i6;
                            i3 = i7;
                            iArr = iArr2;
                            z13 = false;
                            i2 = 0;
                            z9 = false;
                            z8 = false;
                            z7 = false;
                            z6 = false;
                            z12 = z13;
                            z5 = false;
                            i4 = z12;
                            if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                if (i != 0) {
                                    Bundle bundle3 = new Bundle();
                                    bundle3.putInt("user_id", i);
                                    if (i3 != 0) {
                                        bundle3.putInt(str, i3);
                                    }
                                    if (!mainFragmentsStack.isEmpty()) {
                                        MessagesController messagesController = MessagesController.getInstance(iArr[i4]);
                                        ArrayList<BaseFragment> arrayList2 = mainFragmentsStack;
                                    }
                                } else {
                                    String str44 = str;
                                    if (i5 != 0) {
                                        Bundle bundle4 = new Bundle();
                                        bundle4.putInt("chat_id", i5);
                                        if (i3 != 0) {
                                            bundle4.putInt(str44, i3);
                                        }
                                        if (!mainFragmentsStack.isEmpty()) {
                                            MessagesController messagesController2 = MessagesController.getInstance(iArr[i4]);
                                            ArrayList<BaseFragment> arrayList3 = mainFragmentsStack;
                                        }
                                    } else if (i2 != 0) {
                                        Bundle bundle5 = new Bundle();
                                        bundle5.putInt("enc_id", i2);
                                        z11 = launchActivity.actionBarLayout.presentFragment(new ChatActivity(bundle5), false, true, true, false);
                                    } else {
                                        if (z5) {
                                            if (!AndroidUtilities.isTablet()) {
                                                launchActivity.actionBarLayout.removeAllFragments();
                                            } else if (!launchActivity.layersActionBarLayout.fragmentsStack.isEmpty()) {
                                                while (launchActivity.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                                                    ActionBarLayout actionBarLayout = launchActivity.layersActionBarLayout;
                                                    actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(i4));
                                                }
                                                launchActivity.layersActionBarLayout.closeLastFragment(i4);
                                            }
                                            z10 = false;
                                        } else {
                                            if (z6) {
                                                if (!launchActivity.actionBarLayout.fragmentsStack.isEmpty()) {
                                                    launchActivity.actionBarLayout.fragmentsStack.get(i4).showDialog(new AudioPlayerAlert(launchActivity));
                                                }
                                            } else if (z9) {
                                                if (!launchActivity.actionBarLayout.fragmentsStack.isEmpty()) {
                                                    launchActivity.actionBarLayout.fragmentsStack.get(i4).showDialog(new SharingLocationsAlert(launchActivity, new SharingLocationsAlert.SharingLocationsAlertDelegate() {
                                                        @Override
                                                        public final void didSelectLocation(LocationController.SharingLocationInfo sharingLocationInfo) {
                                                            LaunchActivity.this.lambda$handleIntent$6$LaunchActivity(iArr, sharingLocationInfo);
                                                        }
                                                    }));
                                                }
                                            } else {
                                                if (launchActivity.videoPath != null || launchActivity.photoPathsArray != null || launchActivity.sendingText != null || launchActivity.documentsPathsArray != null || launchActivity.contactsToSend != null || launchActivity.documentsUrisArray != null) {
                                                    if (!AndroidUtilities.isTablet()) {
                                                        NotificationCenter.getInstance(iArr[i4]).postNotificationName(NotificationCenter.closeChats, new Object[i4]);
                                                    }
                                                    if (j == j2) {
                                                        Bundle bundle6 = new Bundle();
                                                        bundle6.putBoolean("onlySelect", true);
                                                        bundle6.putInt("dialogsType", 3);
                                                        bundle6.putBoolean("allowSwitchAccount", true);
                                                        ArrayList<TLRPC.User> arrayList4 = launchActivity.contactsToSend;
                                                        if (arrayList4 != null) {
                                                            if (arrayList4.size() != 1) {
                                                                bundle6.putString("selectAlertString", LocaleController.getString("SendContactTo", R.string.SendMessagesTo));
                                                                bundle6.putString("selectAlertStringGroup", LocaleController.getString("SendContactToGroup", R.string.SendContactToGroup));
                                                            }
                                                        } else {
                                                            bundle6.putString("selectAlertString", LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo));
                                                            bundle6.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroup", R.string.SendMessagesToGroup));
                                                        }
                                                        DialogsActivity dialogsActivity = new DialogsActivity(bundle6);
                                                        dialogsActivity.setDelegate(launchActivity);
                                                        launchActivity.actionBarLayout.presentFragment(dialogsActivity, false, true, true, false);
                                                        if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
                                                            SecretMediaViewer.getInstance().closePhoto(i4, i4);
                                                        } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
                                                            PhotoViewer.getInstance().closePhoto(i4, true);
                                                        } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                                                            ArticleViewer.getInstance().close(i4, true);
                                                        }
                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                        if (AndroidUtilities.isTablet()) {
                                                            launchActivity.actionBarLayout.showLastFragment();
                                                            launchActivity.rightActionBarLayout.showLastFragment();
                                                        } else {
                                                            launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                        }
                                                    } else {
                                                        ArrayList<Long> arrayList5 = new ArrayList<>();
                                                        arrayList5.add(Long.valueOf(j));
                                                        str2 = null;
                                                        launchActivity.didSelectDialogs(null, arrayList5, null, i4);
                                                        z10 = z;
                                                        z11 = false;
                                                        if (!z11 && !z10) {
                                                            if (!AndroidUtilities.isTablet()) {
                                                                if (!UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                                                    if (launchActivity.layersActionBarLayout.fragmentsStack.isEmpty()) {
                                                                        launchActivity.layersActionBarLayout.addFragmentToStack(new LoginContronllerActivity());
                                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                                    }
                                                                } else if (launchActivity.actionBarLayout.fragmentsStack.isEmpty()) {
                                                                    launchActivity.actionBarLayout.addFragmentToStack(new IndexActivity());
                                                                    launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                                }
                                                            } else if (launchActivity.actionBarLayout.fragmentsStack.isEmpty()) {
                                                                if (!UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                                                    launchActivity.actionBarLayout.addFragmentToStack(new LoginContronllerActivity());
                                                                    launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                                } else {
                                                                    launchActivity.actionBarLayout.addFragmentToStack(new IndexActivity());
                                                                    launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                                }
                                                            }
                                                            launchActivity.actionBarLayout.showLastFragment();
                                                            if (AndroidUtilities.isTablet()) {
                                                                launchActivity.layersActionBarLayout.showLastFragment();
                                                                launchActivity.rightActionBarLayout.showLastFragment();
                                                            }
                                                        }
                                                        intent2.setAction(str2);
                                                        return z11;
                                                    }
                                                } else if (z8) {
                                                    launchActivity.actionBarLayout.presentFragment(new SettingsActivity(), false, true, true, false);
                                                    if (AndroidUtilities.isTablet()) {
                                                        launchActivity.actionBarLayout.showLastFragment();
                                                        launchActivity.rightActionBarLayout.showLastFragment();
                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                    } else {
                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                    }
                                                } else if (z7) {
                                                    Bundle bundle7 = new Bundle();
                                                    bundle7.putBoolean("destroyAfterSelect", true);
                                                    launchActivity.actionBarLayout.presentFragment(new ContactsActivity(bundle7), false, true, true, false);
                                                    if (AndroidUtilities.isTablet()) {
                                                        launchActivity.actionBarLayout.showLastFragment();
                                                        launchActivity.rightActionBarLayout.showLastFragment();
                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                    } else {
                                                        launchActivity.drawerLayoutContainer.setAllowOpenDrawer(i4, i4);
                                                    }
                                                }
                                                z10 = z;
                                                str2 = null;
                                                z11 = true;
                                                if (!z11) {
                                                    if (!AndroidUtilities.isTablet()) {
                                                    }
                                                    launchActivity.actionBarLayout.showLastFragment();
                                                    if (AndroidUtilities.isTablet()) {
                                                    }
                                                }
                                                intent2.setAction(str2);
                                                return z11;
                                            }
                                            z10 = z;
                                        }
                                        str2 = null;
                                        z11 = false;
                                        if (!z11) {
                                        }
                                        intent2.setAction(str2);
                                        return z11;
                                    }
                                }
                                z10 = z;
                                str2 = null;
                                if (!z11) {
                                }
                                intent2.setAction(str2);
                                return z11;
                            }
                            str2 = null;
                            z10 = z;
                            z11 = false;
                            if (!z11) {
                            }
                            intent2.setAction(str2);
                            return z11;
                        }
                        str = "message_id";
                        launchActivity = this;
                        j2 = 0;
                        if (!intent.getAction().equals("im.grnuohmoqd.messenger.OPEN_ACCOUNT")) {
                            if (!intent.getAction().equals("new_dialog")) {
                                if (intent.getAction().startsWith("com.tmessages.openchat")) {
                                    intent2 = intent;
                                    i4 = 0;
                                    i5 = intent2.getIntExtra("chatId", 0);
                                    int intExtra = intent2.getIntExtra("userId", 0);
                                    i2 = intent2.getIntExtra("encId", 0);
                                    if (i5 != 0) {
                                        iArr = iArr3;
                                        NotificationCenter.getInstance(iArr[0]).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                                        i2 = 0;
                                    } else {
                                        iArr = iArr3;
                                        if (intExtra != 0) {
                                            NotificationCenter.getInstance(iArr[0]).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                                            i = intExtra;
                                            i5 = 0;
                                            i2 = 0;
                                            z18 = false;
                                            z5 = z18;
                                            i3 = 0;
                                            z9 = false;
                                            z8 = false;
                                            z7 = false;
                                            z6 = false;
                                            if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                            }
                                            str2 = null;
                                            z10 = z;
                                            z11 = false;
                                            if (!z11) {
                                            }
                                            intent2.setAction(str2);
                                            return z11;
                                        }
                                        if (i2 != 0) {
                                            NotificationCenter.getInstance(iArr[0]).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                                            i5 = 0;
                                        } else {
                                            i5 = 0;
                                            i2 = 0;
                                            i = 0;
                                            z18 = true;
                                            z5 = z18;
                                            i3 = 0;
                                            z9 = false;
                                            z8 = false;
                                            z7 = false;
                                            z6 = false;
                                            if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                            }
                                            str2 = null;
                                            z10 = z;
                                            z11 = false;
                                            if (!z11) {
                                            }
                                            intent2.setAction(str2);
                                            return z11;
                                        }
                                    }
                                    i = 0;
                                    z18 = false;
                                    z5 = z18;
                                    i3 = 0;
                                    z9 = false;
                                    z8 = false;
                                    z7 = false;
                                    z6 = false;
                                    if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                    }
                                    str2 = null;
                                    z10 = z;
                                    z11 = false;
                                    if (!z11) {
                                    }
                                    intent2.setAction(str2);
                                    return z11;
                                }
                                intent2 = intent;
                                iArr = iArr3;
                                z4 = false;
                                z12 = false;
                                z16 = false;
                                if (!intent.getAction().equals("com.tmessages.openplayer")) {
                                    if (!intent.getAction().equals("org.tmessages.openlocations")) {
                                        if (intent.getAction().equals("im.grnuohmoqd.contacts.add")) {
                                            launchActivity.lambda$runLinkRequest$28$LaunchActivity(new NewFriendsActivity());
                                            return false;
                                        }
                                    } else {
                                        i5 = 0;
                                        i3 = 0;
                                        i2 = 0;
                                        z9 = true;
                                        z8 = false;
                                        z15 = z16;
                                        z7 = false;
                                        z14 = z15;
                                        i = 0;
                                        z13 = z14;
                                        z6 = false;
                                        z12 = z13;
                                        z5 = false;
                                        i4 = z12;
                                        if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                        }
                                        str2 = null;
                                        z10 = z;
                                        z11 = false;
                                        if (!z11) {
                                        }
                                        intent2.setAction(str2);
                                        return z11;
                                    }
                                } else {
                                    i5 = 0;
                                    i3 = 0;
                                    i2 = 0;
                                    z9 = false;
                                    z8 = false;
                                    z7 = false;
                                    i = 0;
                                    z6 = true;
                                    z5 = false;
                                    i4 = z12;
                                    if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                    }
                                    str2 = null;
                                    z10 = z;
                                    z11 = false;
                                    if (!z11) {
                                    }
                                    intent2.setAction(str2);
                                    return z11;
                                }
                            } else {
                                intent2 = intent;
                                iArr = iArr3;
                                i5 = 0;
                                z14 = false;
                                i3 = 0;
                                i2 = 0;
                                z9 = false;
                                z8 = false;
                                z7 = true;
                                i = 0;
                                z13 = z14;
                                z6 = false;
                                z12 = z13;
                                z5 = false;
                                i4 = z12;
                                if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                                }
                                str2 = null;
                                z10 = z;
                                z11 = false;
                                if (!z11) {
                                }
                                intent2.setAction(str2);
                                return z11;
                            }
                        } else {
                            intent2 = intent;
                            iArr = iArr3;
                            i5 = 0;
                            z15 = false;
                            i3 = 0;
                            i2 = 0;
                            z9 = false;
                            z8 = true;
                            z7 = false;
                            z14 = z15;
                            i = 0;
                            z13 = z14;
                            z6 = false;
                            z12 = z13;
                            z5 = false;
                            i4 = z12;
                            if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                            }
                            str2 = null;
                            z10 = z;
                            z11 = false;
                            if (!z11) {
                            }
                            intent2.setAction(str2);
                            return z11;
                        }
                    }
                    str = "message_id";
                    iArr = iArr3;
                    intent2 = intent;
                    launchActivity = this;
                    z4 = false;
                    j2 = 0;
                }
                i5 = 0;
                i3 = 0;
                i2 = 0;
                z9 = false;
                z16 = z4;
                z8 = false;
                z15 = z16;
                z7 = false;
                z14 = z15;
                i = 0;
                z13 = z14;
                z6 = false;
                z12 = z13;
                z5 = false;
                i4 = z12;
                if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
                }
                str2 = null;
                z10 = z;
                z11 = false;
                if (!z11) {
                }
                intent2.setAction(str2);
                return z11;
            }
        }
        j = 0;
        String str362 = null;
        this.photoPathsArray = null;
        this.videoPath = null;
        this.sendingText = null;
        this.documentsPathsArray = null;
        this.documentsOriginalPathsArray = null;
        this.documentsMimeType = null;
        this.documentsUrisArray = null;
        this.contactsToSend = null;
        this.contactsToSendUri = null;
        if ((flags & 1048576) == 0) {
        }
        str = "message_id";
        j2 = 0;
        iArr = iArr3;
        intent2 = intent;
        launchActivity = this;
        z4 = false;
        i5 = 0;
        i3 = 0;
        i2 = 0;
        z9 = false;
        z16 = z4;
        z8 = false;
        z15 = z16;
        z7 = false;
        z14 = z15;
        i = 0;
        z13 = z14;
        z6 = false;
        z12 = z13;
        z5 = false;
        i4 = z12;
        if (UserConfig.getInstance(launchActivity.currentAccount).isClientActivated()) {
        }
        str2 = null;
        z10 = z;
        z11 = false;
        if (!z11) {
        }
        intent2.setAction(str2);
        return z11;
    }

    public void lambda$handleIntent$4$LaunchActivity(Bundle bundle) {
        lambda$runLinkRequest$28$LaunchActivity(new CancelAccountDeletionActivity(bundle));
    }

    public void lambda$handleIntent$6$LaunchActivity(int[] iArr, final LocationController.SharingLocationInfo sharingLocationInfo) {
        iArr[0] = sharingLocationInfo.messageObject.currentAccount;
        switchToAccount(iArr[0], true);
        NewLocationActivity newLocationActivity = new NewLocationActivity(3, sharingLocationInfo.messageObject);
        final long dialogId = sharingLocationInfo.messageObject.getDialogId();
        newLocationActivity.setDelegate(new NewLocationActivity.LocationActivityDelegate() {
            @Override
            public final void didSelectLocation(TLRPC.MessageMedia messageMedia, int i, boolean z, int i2) {
                SendMessagesHelper.getInstance(LocationController.SharingLocationInfo.this.messageObject.currentAccount).sendMessage(messageMedia, dialogId, (MessageObject) null, (TLRPC.ReplyMarkup) null, (HashMap<String, String>) null, z, i2);
            }
        });
        lambda$runLinkRequest$28$LaunchActivity(newLocationActivity);
    }

    private void getUserInfo(TLRPC.User user) {
        TLRPC.TL_users_getFullUser tL_users_getFullUser = new TLRPC.TL_users_getFullUser();
        tL_users_getFullUser.id = MessagesController.getInstance(UserConfig.selectedAccount).getInputUser(user);
        final XAlertDialog xAlertDialog = new XAlertDialog(this, 4);
        xAlertDialog.setLoadingText(LocaleController.getString(R.string.Loading));
        int sendRequest = ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(tL_users_getFullUser, new RequestDelegate() {
            @Override
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                LaunchActivity.this.lambda$getUserInfo$8$LaunchActivity(xAlertDialog, tLObject, tL_error);
            }
        });
        xAlertDialog.show();
        ConnectionsManager.getInstance(UserConfig.selectedAccount).bindRequestToGuid(sendRequest, getActionBarLayout().getCurrentFragment().getClassGuid());
    }

    public void lambda$getUserInfo$8$LaunchActivity(XAlertDialog xAlertDialog, final TLObject tLObject, TLRPC.TL_error tL_error) {
        xAlertDialog.dismiss();
        if (tL_error == null) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    LaunchActivity.this.lambda$null$7$LaunchActivity(tLObject);
                }
            });
        } else if ("USERNOTEXITST".equals(tL_error.text)) {
            AlertsCreator.showSimpleAlert(getActionBarLayout().getCurrentFragment(), LocaleController.getString("UserNotExist", R.string.UserNotExist));
        }
    }

    public void lambda$null$7$LaunchActivity(TLObject tLObject) {
        TLRPC.UserFull userFull = (TLRPC.UserFull) tLObject;
        MessagesController.getInstance(UserConfig.selectedAccount).putUser(userFull.user, false);
        if (userFull.user == null) {
            return;
        }
        if (userFull.user.self || userFull.user.contact) {
            Bundle bundle = new Bundle();
            bundle.putInt("user_id", userFull.user.id);
            lambda$runLinkRequest$28$LaunchActivity(new NewProfileActivity(bundle));
        } else {
            Bundle bundle2 = new Bundle();
            bundle2.putInt("from_type", 4);
            lambda$runLinkRequest$28$LaunchActivity(new AddContactsInfoActivity(bundle2, userFull.user));
        }
    }

    private void runLinkRequest(final int i, final String str, final String str2, final String str3, final String str4, final String str5, final String str6, final boolean z, final Integer num, final Integer num2, final String str7, final HashMap<String, String> hashMap, final String str8, final String str9, final String str10, final TLRPC.TL_wallPaper tL_wallPaper, final String str11, int i2) {
        final int[] iArr;
        final int i3;
        char c;
        Runnable runnable;
        BaseFragment baseFragment;
        final Runnable runnable2;
        if (i2 == 0 && UserConfig.getActivatedAccountsCount() >= 2 && hashMap != null) {
            AlertsCreator.createAccountSelectDialog(this, new AlertsCreator.AccountSelectDelegate() {
                @Override
                public final void didSelectAccount(int i4) {
                    LaunchActivity.this.lambda$runLinkRequest$9$LaunchActivity(i, str, str2, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11, i4);
                }
            }).show();
            return;
        }
        boolean z2 = true;
        if (str10 != null) {
            if (NotificationCenter.getGlobalInstance().hasObservers(NotificationCenter.didReceiveSmsCode)) {
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, str10);
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("OtherLoginCode", R.string.OtherLoginCode, str10)));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            showAlertDialog(builder);
            return;
        }
        final AlertDialog alertDialog = new AlertDialog(this, 3);
        int[] iArr2 = {0};
        if (str != null) {
            TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
            tL_contacts_resolveUsername.username = str;
            iArr2[0] = ConnectionsManager.getInstance(i).sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
                @Override
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    LaunchActivity.this.lambda$runLinkRequest$13$LaunchActivity(alertDialog, str7, i, str5, str4, num, tLObject, tL_error);
                }
            });
            iArr = iArr2;
            runnable = null;
            i3 = i;
            c = 0;
        } else if (str2 == null) {
            iArr = iArr2;
            i3 = i;
            c = 0;
            if (str3 != null) {
                if (mainFragmentsStack.isEmpty()) {
                    return;
                }
                TLRPC.TL_inputStickerSetShortName tL_inputStickerSetShortName = new TLRPC.TL_inputStickerSetShortName();
                tL_inputStickerSetShortName.short_name = str3;
                ArrayList<BaseFragment> arrayList = mainFragmentsStack;
                BaseFragment baseFragment2 = arrayList.get(arrayList.size() - 1);
                baseFragment2.showDialog(new StickersAlert(this, baseFragment2, tL_inputStickerSetShortName, null, null));
                return;
            }
            if (str6 != null) {
                Bundle bundle = new Bundle();
                bundle.putBoolean("onlySelect", true);
                DialogsActivity dialogsActivity = new DialogsActivity(bundle);
                dialogsActivity.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
                    @Override
                    public final void didSelectDialogs(DialogsActivity dialogsActivity2, ArrayList arrayList2, CharSequence charSequence, boolean z3) {
                        LaunchActivity.this.lambda$runLinkRequest$19$LaunchActivity(z, i3, str6, dialogsActivity2, arrayList2, charSequence, z3);
                    }
                });
                presentFragment(dialogsActivity, false, true);
            } else if (hashMap != null) {
                int intValue = Utilities.parseInt(hashMap.get("bot_id")).intValue();
                if (intValue == 0) {
                    return;
                }
                final String str12 = hashMap.get("payload");
                final String str13 = hashMap.get("nonce");
                final String str14 = hashMap.get("callback_url");
                final TLRPC.TL_account_getAuthorizationForm tL_account_getAuthorizationForm = new TLRPC.TL_account_getAuthorizationForm();
                tL_account_getAuthorizationForm.bot_id = intValue;
                tL_account_getAuthorizationForm.scope = hashMap.get("scope");
                tL_account_getAuthorizationForm.public_key = hashMap.get("public_key");
                iArr[0] = ConnectionsManager.getInstance(i).sendRequest(tL_account_getAuthorizationForm, new RequestDelegate() {
                    @Override
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        LaunchActivity.this.lambda$runLinkRequest$23$LaunchActivity(iArr, i, alertDialog, tL_account_getAuthorizationForm, str12, str13, str14, tLObject, tL_error);
                    }
                });
            } else if (str9 != null) {
                TLRPC.TL_help_getDeepLinkInfo tL_help_getDeepLinkInfo = new TLRPC.TL_help_getDeepLinkInfo();
                tL_help_getDeepLinkInfo.path = str9;
                iArr[0] = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_help_getDeepLinkInfo, new RequestDelegate() {
                    @Override
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        LaunchActivity.this.lambda$runLinkRequest$25$LaunchActivity(alertDialog, tLObject, tL_error);
                    }
                });
            } else if (str8 != null) {
                TLRPC.TL_langpack_getLanguage tL_langpack_getLanguage = new TLRPC.TL_langpack_getLanguage();
                tL_langpack_getLanguage.lang_code = str8;
                tL_langpack_getLanguage.lang_pack = "android";
                iArr[0] = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_langpack_getLanguage, new RequestDelegate() {
                    @Override
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        LaunchActivity.this.lambda$runLinkRequest$27$LaunchActivity(alertDialog, tLObject, tL_error);
                    }
                });
            } else if (tL_wallPaper != null) {
                if (TextUtils.isEmpty(tL_wallPaper.slug)) {
                    try {
                        runnable = null;
                        try {
                            final WallpaperActivity wallpaperActivity = new WallpaperActivity(new WallpapersListActivity.ColorWallpaper(-100L, tL_wallPaper.settings.background_color), null);
                            AndroidUtilities.runOnUIThread(new Runnable() {
                                @Override
                                public final void run() {
                                    LaunchActivity.this.lambda$runLinkRequest$28$LaunchActivity(wallpaperActivity);
                                }
                            });
                        } catch (Exception e) {
                            e = e;
                            FileLog.e(e);
                            z2 = false;
                            if (!z2) {
                            }
                            runnable2 = runnable;
                            if (iArr[c] != 0) {
                            }
                        }
                    } catch (Exception e2) {
                        e = e2;
                        runnable = null;
                    }
                    if (!z2) {
                        TLRPC.TL_account_getWallPaper tL_account_getWallPaper = new TLRPC.TL_account_getWallPaper();
                        TLRPC.TL_inputWallPaperSlug tL_inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
                        tL_inputWallPaperSlug.slug = tL_wallPaper.slug;
                        tL_account_getWallPaper.wallpaper = tL_inputWallPaperSlug;
                        iArr[0] = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_getWallPaper, new RequestDelegate() {
                            @Override
                            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                LaunchActivity.this.lambda$runLinkRequest$30$LaunchActivity(alertDialog, tL_wallPaper, tLObject, tL_error);
                            }
                        });
                    }
                } else {
                    runnable = null;
                }
                z2 = false;
                if (!z2) {
                }
            } else {
                runnable = null;
                if (str11 != null) {
                    runnable2 = new Runnable() {
                        @Override
                        public final void run() {
                            LaunchActivity.this.lambda$runLinkRequest$31$LaunchActivity();
                        }
                    };
                    TLRPC.TL_account_getTheme tL_account_getTheme = new TLRPC.TL_account_getTheme();
                    tL_account_getTheme.format = "android";
                    TLRPC.TL_inputThemeSlug tL_inputThemeSlug = new TLRPC.TL_inputThemeSlug();
                    tL_inputThemeSlug.slug = str11;
                    tL_account_getTheme.theme = tL_inputThemeSlug;
                    iArr[0] = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_account_getTheme, new RequestDelegate() {
                        @Override
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            LaunchActivity.this.lambda$runLinkRequest$33$LaunchActivity(alertDialog, tLObject, tL_error);
                        }
                    });
                    if (iArr[c] != 0) {
                        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public final void onCancel(DialogInterface dialogInterface) {
                                LaunchActivity.lambda$runLinkRequest$37(i3, iArr, runnable2, dialogInterface);
                            }
                        });
                        try {
                            alertDialog.show();
                            return;
                        } catch (Exception unused) {
                            return;
                        }
                    }
                    return;
                }
                if (num2 != null && num != null) {
                    final Bundle bundle2 = new Bundle();
                    bundle2.putInt("chat_id", num2.intValue());
                    bundle2.putInt("message_id", num.intValue());
                    if (mainFragmentsStack.isEmpty()) {
                        baseFragment = null;
                    } else {
                        ArrayList<BaseFragment> arrayList2 = mainFragmentsStack;
                        baseFragment = arrayList2.get(arrayList2.size() - 1);
                    }
                    if (baseFragment == null || MessagesController.getInstance(i).checkCanOpenChat(bundle2, baseFragment)) {
                        final BaseFragment baseFragment3 = baseFragment;
                        AndroidUtilities.runOnUIThread(new Runnable() {
                            @Override
                            public final void run() {
                                LaunchActivity.this.lambda$runLinkRequest$36$LaunchActivity(bundle2, num2, iArr, alertDialog, baseFragment3, i);
                            }
                        });
                    }
                }
            }
            runnable = null;
        } else if (i2 == 0) {
            TLRPC.TL_messages_checkChatInvite tL_messages_checkChatInvite = new TLRPC.TL_messages_checkChatInvite();
            tL_messages_checkChatInvite.hash = str2;
            iArr = iArr2;
            c = 0;
            iArr[0] = ConnectionsManager.getInstance(i).sendRequest(tL_messages_checkChatInvite, new RequestDelegate() {
                @Override
                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                    LaunchActivity.this.lambda$runLinkRequest$16$LaunchActivity(alertDialog, i, str2, str, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11, tLObject, tL_error);
                }
            }, 2);
            runnable = null;
            i3 = i;
            alertDialog = alertDialog;
        } else {
            iArr = iArr2;
            c = 0;
            if (i2 == 1) {
                TLRPC.TL_messages_importChatInvite tL_messages_importChatInvite = new TLRPC.TL_messages_importChatInvite();
                tL_messages_importChatInvite.hash = str2;
                i3 = i;
                alertDialog = alertDialog;
                ConnectionsManager.getInstance(i).sendRequest(tL_messages_importChatInvite, new RequestDelegate() {
                    @Override
                    public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                        LaunchActivity.this.lambda$runLinkRequest$18$LaunchActivity(i3, alertDialog, tLObject, tL_error);
                    }
                }, 2);
            } else {
                i3 = i;
                alertDialog = alertDialog;
            }
            runnable = null;
        }
        runnable2 = runnable;
        if (iArr[c] != 0) {
        }
    }

    public void lambda$runLinkRequest$9$LaunchActivity(int i, String str, String str2, String str3, String str4, String str5, String str6, boolean z, Integer num, Integer num2, String str7, HashMap hashMap, String str8, String str9, String str10, TLRPC.TL_wallPaper tL_wallPaper, String str11, int i2) {
        if (i2 != i) {
            switchToAccount(i2, true);
        }
        runLinkRequest(i2, str, str2, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11, 1);
    }

    public void lambda$runLinkRequest$13$LaunchActivity(final AlertDialog alertDialog, final String str, final int i, final String str2, final String str3, final Integer num, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$12$LaunchActivity(alertDialog, tLObject, tL_error, str, i, str2, str3, num);
            }
        });
    }

    public void lambda$null$12$LaunchActivity(AlertDialog alertDialog, TLObject tLObject, TLRPC.TL_error tL_error, final String str, final int i, final String str2, String str3, Integer num) {
        int i2;
        if (isFinishing()) {
            return;
        }
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        final TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
        if (tL_error == null && this.actionBarLayout != null && (str == null || (str != null && !tL_contacts_resolvedPeer.users.isEmpty()))) {
            boolean z = false;
            MessagesController.getInstance(i).putUsers(tL_contacts_resolvedPeer.users, false);
            MessagesController.getInstance(i).putChats(tL_contacts_resolvedPeer.chats, false);
            MessagesStorage.getInstance(i).putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, false, true);
            if (str != null) {
                Bundle bundle = new Bundle();
                bundle.putBoolean("onlySelect", true);
                bundle.putBoolean("cantSendToChannels", true);
                bundle.putInt("dialogsType", 1);
                bundle.putString("selectAlertString", LocaleController.getString("SendGameTo", R.string.SendGameTo));
                bundle.putString("selectAlertStringGroup", LocaleController.getString("SendGameToGroup", R.string.SendGameToGroup));
                DialogsActivity dialogsActivity = new DialogsActivity(bundle);
                dialogsActivity.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
                    @Override
                    public final void didSelectDialogs(DialogsActivity dialogsActivity2, ArrayList arrayList, CharSequence charSequence, boolean z2) {
                        LaunchActivity.this.lambda$null$10$LaunchActivity(str, i, tL_contacts_resolvedPeer, dialogsActivity2, arrayList, charSequence, z2);
                    }
                });
                this.actionBarLayout.presentFragment(dialogsActivity, !AndroidUtilities.isTablet() ? this.actionBarLayout.fragmentsStack.size() <= 1 || !(this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1) instanceof IndexActivity) : this.layersActionBarLayout.fragmentsStack.size() <= 0 || !(this.layersActionBarLayout.fragmentsStack.get(this.layersActionBarLayout.fragmentsStack.size() - 1) instanceof IndexActivity), true, true, false);
                if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
                    SecretMediaViewer.getInstance().closePhoto(false, false);
                } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
                    PhotoViewer.getInstance().closePhoto(false, true);
                } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                    ArticleViewer.getInstance().close(false, true);
                }
                this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                if (AndroidUtilities.isTablet()) {
                    this.actionBarLayout.showLastFragment();
                    this.rightActionBarLayout.showLastFragment();
                    return;
                } else {
                    this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    return;
                }
            }
            BaseFragment baseFragment = null;
            if (str2 != null) {
                final TLRPC.User user = tL_contacts_resolvedPeer.users.isEmpty() ? null : tL_contacts_resolvedPeer.users.get(0);
                if (user == null || (user.bot && user.bot_nochats)) {
                    try {
                        ToastUtils.show(R.string.BotCantJoinGroups);
                        return;
                    } catch (Exception e2) {
                        FileLog.e(e2);
                        return;
                    }
                }
                Bundle bundle2 = new Bundle();
                bundle2.putBoolean("onlySelect", true);
                bundle2.putInt("dialogsType", 2);
                bundle2.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getName(user), "%1$s"));
                DialogsActivity dialogsActivity2 = new DialogsActivity(bundle2);
                dialogsActivity2.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
                    @Override
                    public final void didSelectDialogs(DialogsActivity dialogsActivity3, ArrayList arrayList, CharSequence charSequence, boolean z2) {
                        LaunchActivity.this.lambda$null$11$LaunchActivity(i, user, str2, dialogsActivity3, arrayList, charSequence, z2);
                    }
                });
                lambda$runLinkRequest$28$LaunchActivity(dialogsActivity2);
                return;
            }
            Bundle bundle3 = new Bundle();
            if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
                bundle3.putInt("chat_id", tL_contacts_resolvedPeer.chats.get(0).id);
                i2 = -tL_contacts_resolvedPeer.chats.get(0).id;
            } else {
                bundle3.putInt("user_id", tL_contacts_resolvedPeer.users.get(0).id);
                i2 = tL_contacts_resolvedPeer.users.get(0).id;
            }
            long j = i2;
            if (str3 != null && tL_contacts_resolvedPeer.users.size() > 0 && tL_contacts_resolvedPeer.users.get(0).bot) {
                bundle3.putString("botUser", str3);
                z = true;
            }
            if (num != null) {
                bundle3.putInt("message_id", num.intValue());
            }
            if (!mainFragmentsStack.isEmpty()) {
                ArrayList<BaseFragment> arrayList = mainFragmentsStack;
                baseFragment = arrayList.get(arrayList.size() - 1);
            }
            if (baseFragment == null || MessagesController.getInstance(i).checkCanOpenChat(bundle3, baseFragment)) {
                if (z && (baseFragment instanceof ChatActivity)) {
                    ChatActivity chatActivity = (ChatActivity) baseFragment;
                    if (chatActivity.getDialogId() == j) {
                        chatActivity.setBotUser(str3);
                        return;
                    }
                }
                this.actionBarLayout.presentFragment(new ChatActivity(bundle3));
                return;
            }
            return;
        }
        try {
            AlertsCreator.createSimpleAlert(this, LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)).show();
        } catch (Exception e3) {
            FileLog.e(e3);
        }
    }

    public void lambda$null$10$LaunchActivity(String str, int i, TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer, DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z) {
        long longValue = ((Long) arrayList.get(0)).longValue();
        TLRPC.TL_inputMediaGame tL_inputMediaGame = new TLRPC.TL_inputMediaGame();
        tL_inputMediaGame.id = new TLRPC.TL_inputGameShortName();
        tL_inputMediaGame.id.short_name = str;
        tL_inputMediaGame.id.bot_id = MessagesController.getInstance(i).getInputUser(tL_contacts_resolvedPeer.users.get(0));
        int i2 = (int) longValue;
        SendMessagesHelper.getInstance(i).sendGame(MessagesController.getInstance(i).getInputPeer(i2), tL_inputMediaGame, 0L, 0L);
        Bundle bundle = new Bundle();
        bundle.putBoolean("scrollToTopOnResume", true);
        int i3 = (int) (longValue >> 32);
        if (i2 == 0) {
            bundle.putInt("enc_id", i3);
        } else if (i2 > 0) {
            bundle.putInt("user_id", i2);
        } else if (i2 < 0) {
            bundle.putInt("chat_id", -i2);
        }
        if (MessagesController.getInstance(i).checkCanOpenChat(bundle, dialogsActivity)) {
            NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.closeChats, new Object[0]);
            this.actionBarLayout.presentFragment(new ChatActivity(bundle), true, false, true, false);
        }
    }

    public void lambda$null$11$LaunchActivity(int i, TLRPC.User user, String str, DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z) {
        long longValue = ((Long) arrayList.get(0)).longValue();
        Bundle bundle = new Bundle();
        bundle.putBoolean("scrollToTopOnResume", true);
        int i2 = -((int) longValue);
        bundle.putInt("chat_id", i2);
        if (!mainFragmentsStack.isEmpty()) {
            MessagesController messagesController = MessagesController.getInstance(i);
            ArrayList<BaseFragment> arrayList2 = mainFragmentsStack;
            if (!messagesController.checkCanOpenChat(bundle, arrayList2.get(arrayList2.size() - 1))) {
                return;
            }
        }
        NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.closeChats, new Object[0]);
        MessagesController.getInstance(i).addUserToChat(i2, user, null, 0, str, null, null);
        this.actionBarLayout.presentFragment(new ChatActivity(bundle), true, false, true, false);
    }

    public void lambda$runLinkRequest$16$LaunchActivity(final AlertDialog alertDialog, final int i, final String str, final String str2, final String str3, final String str4, final String str5, final String str6, final boolean z, final Integer num, final Integer num2, final String str7, final HashMap hashMap, final String str8, final String str9, final String str10, final TLRPC.TL_wallPaper tL_wallPaper, final String str11, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$15$LaunchActivity(alertDialog, tL_error, tLObject, i, str, str2, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11);
            }
        });
    }

    public void lambda$null$15$LaunchActivity(AlertDialog alertDialog, TLRPC.TL_error tL_error, TLObject tLObject, final int i, final String str, final String str2, final String str3, final String str4, final String str5, final String str6, final boolean z, final Integer num, final Integer num2, final String str7, final HashMap hashMap, final String str8, final String str9, final String str10, final TLRPC.TL_wallPaper tL_wallPaper, final String str11) {
        if (!isFinishing()) {
            try {
                alertDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (tL_error == null && this.actionBarLayout != null) {
                TLRPC.ChatInvite chatInvite = (TLRPC.ChatInvite) tLObject;
                if (chatInvite.chat != null && (!ChatObject.isLeftFromChat(chatInvite.chat) || (!chatInvite.chat.kicked && !TextUtils.isEmpty(chatInvite.chat.username)))) {
                    MessagesController.getInstance(i).putChat(chatInvite.chat, false);
                    ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
                    arrayList.add(chatInvite.chat);
                    MessagesStorage.getInstance(i).putUsersAndChats(null, arrayList, false, true);
                    Bundle bundle = new Bundle();
                    bundle.putInt("chat_id", chatInvite.chat.id);
                    if (!mainFragmentsStack.isEmpty()) {
                        MessagesController messagesController = MessagesController.getInstance(i);
                        ArrayList<BaseFragment> arrayList2 = mainFragmentsStack;
                    }
                    ChatActivity chatActivity = new ChatActivity(bundle);
                    NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                    this.actionBarLayout.presentFragment(chatActivity, false, true, true, false);
                } else if (((chatInvite.chat == null && (!chatInvite.channel || chatInvite.megagroup)) || (chatInvite.chat != null && (!ChatObject.isChannel(chatInvite.chat) || chatInvite.chat.megagroup))) && !mainFragmentsStack.isEmpty()) {
                    ArrayList<BaseFragment> arrayList3 = mainFragmentsStack;
                    BaseFragment baseFragment = arrayList3.get(arrayList3.size() - 1);
                    baseFragment.showDialog(new JoinGroupAlert(this, chatInvite, str, baseFragment));
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    Object[] objArr = new Object[1];
                    objArr[0] = chatInvite.chat != null ? chatInvite.chat.title : chatInvite.title;
                    builder.setMessage(LocaleController.formatString("ChannelJoinTo", R.string.ChannelJoinTo, objArr));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i2) {
                            LaunchActivity.this.lambda$null$14$LaunchActivity(i, str2, str, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11, dialogInterface, i2);
                        }
                    });
                    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                    showAlertDialog(builder);
                }
            } else {
                AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
                builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
                if (tL_error.text.startsWith("FLOOD_WAIT")) {
                    builder2.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
                } else {
                    builder2.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
                }
                builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                showAlertDialog(builder2);
            }
        }
    }

    public void lambda$null$14$LaunchActivity(int i, String str, String str2, String str3, String str4, String str5, String str6, boolean z, Integer num, Integer num2, String str7, HashMap hashMap, String str8, String str9, String str10, TLRPC.TL_wallPaper tL_wallPaper, String str11, DialogInterface dialogInterface, int i2) {
        runLinkRequest(i, str, str2, str3, str4, str5, str6, z, num, num2, str7, hashMap, str8, str9, str10, tL_wallPaper, str11, 1);
    }

    public void lambda$runLinkRequest$18$LaunchActivity(final int i, final AlertDialog alertDialog, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        if (tL_error == null) {
            MessagesController.getInstance(i).processUpdates((TLRPC.Updates) tLObject, false);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$17$LaunchActivity(alertDialog, tL_error, tLObject, i);
            }
        });
    }

    public void lambda$null$17$LaunchActivity(AlertDialog alertDialog, TLRPC.TL_error tL_error, TLObject tLObject, int i) {
        if (isFinishing()) {
            return;
        }
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (tL_error == null) {
            if (this.actionBarLayout != null) {
                TLRPC.Updates updates = (TLRPC.Updates) tLObject;
                if (updates.chats.isEmpty()) {
                    return;
                }
                TLRPC.Chat chat = updates.chats.get(0);
                chat.left = false;
                chat.kicked = false;
                MessagesController.getInstance(i).putUsers(updates.users, false);
                MessagesController.getInstance(i).putChats(updates.chats, false);
                Bundle bundle = new Bundle();
                bundle.putInt("chat_id", chat.id);
                if (!mainFragmentsStack.isEmpty()) {
                    if (!MessagesController.getInstance(i).checkCanOpenChat(bundle, mainFragmentsStack.get(r0.size() - 1))) {
                        return;
                    }
                }
                ChatActivity chatActivity = new ChatActivity(bundle);
                NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.closeChats, new Object[0]);
                this.actionBarLayout.presentFragment(chatActivity, false, true, true, false);
                return;
            }
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        if (tL_error.text.startsWith("FLOOD_WAIT")) {
            builder.setMessage(LocaleController.getString("FloodWait", R.string.FloodWait));
        } else if (tL_error.text.equals("USERS_TOO_MUCH")) {
            builder.setMessage(LocaleController.getString("JoinToGroupErrorFull", R.string.JoinToGroupErrorFull));
        } else {
            builder.setMessage(LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist));
        }
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        showAlertDialog(builder);
    }

    public void lambda$runLinkRequest$19$LaunchActivity(boolean z, int i, String str, DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z2) {
        long longValue = ((Long) arrayList.get(0)).longValue();
        Bundle bundle = new Bundle();
        bundle.putBoolean("scrollToTopOnResume", true);
        bundle.putBoolean("hasUrl", z);
        int i2 = (int) longValue;
        int i3 = (int) (longValue >> 32);
        if (i2 == 0) {
            bundle.putInt("enc_id", i3);
        } else if (i2 > 0) {
            bundle.putInt("user_id", i2);
        } else if (i2 < 0) {
            bundle.putInt("chat_id", -i2);
        }
        if (MessagesController.getInstance(i).checkCanOpenChat(bundle, dialogsActivity)) {
            NotificationCenter.getInstance(i).postNotificationName(NotificationCenter.closeChats, new Object[0]);
            MediaDataController.getInstance(i).saveDraft(longValue, str, null, null, false);
            this.actionBarLayout.presentFragment(new ChatActivity(bundle), true, false, true, false);
        }
    }

    public void lambda$runLinkRequest$23$LaunchActivity(int[] iArr, final int i, final AlertDialog alertDialog, final TLRPC.TL_account_getAuthorizationForm tL_account_getAuthorizationForm, final String str, final String str2, final String str3, TLObject tLObject, final TLRPC.TL_error tL_error) {
        final TLRPC.TL_account_authorizationForm tL_account_authorizationForm = (TLRPC.TL_account_authorizationForm) tLObject;
        if (tL_account_authorizationForm != null) {
            iArr[0] = ConnectionsManager.getInstance(i).sendRequest(new TLRPC.TL_account_getPassword(), new RequestDelegate() {
                @Override
                public final void run(TLObject tLObject2, TLRPC.TL_error tL_error2) {
                    LaunchActivity.this.lambda$null$21$LaunchActivity(alertDialog, i, tL_account_authorizationForm, tL_account_getAuthorizationForm, str, str2, str3, tLObject2, tL_error2);
                }
            });
        } else {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    LaunchActivity.this.lambda$null$22$LaunchActivity(alertDialog, tL_error);
                }
            });
        }
    }

    public void lambda$null$21$LaunchActivity(final AlertDialog alertDialog, final int i, final TLRPC.TL_account_authorizationForm tL_account_authorizationForm, final TLRPC.TL_account_getAuthorizationForm tL_account_getAuthorizationForm, final String str, final String str2, final String str3, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$20$LaunchActivity(alertDialog, tLObject, i, tL_account_authorizationForm, tL_account_getAuthorizationForm, str, str2, str3);
            }
        });
    }

    public void lambda$null$20$LaunchActivity(AlertDialog alertDialog, TLObject tLObject, int i, TLRPC.TL_account_authorizationForm tL_account_authorizationForm, TLRPC.TL_account_getAuthorizationForm tL_account_getAuthorizationForm, String str, String str2, String str3) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (tLObject != null) {
            MessagesController.getInstance(i).putUsers(tL_account_authorizationForm.users, false);
            lambda$runLinkRequest$28$LaunchActivity(new PassportActivity(5, tL_account_getAuthorizationForm.bot_id, tL_account_getAuthorizationForm.scope, tL_account_getAuthorizationForm.public_key, str, str2, str3, tL_account_authorizationForm, (TLRPC.TL_account_password) tLObject));
        }
    }

    public void lambda$null$22$LaunchActivity(AlertDialog alertDialog, TLRPC.TL_error tL_error) {
        try {
            alertDialog.dismiss();
            if ("APP_VERSION_OUTDATED".equals(tL_error.text)) {
                AlertsCreator.showUpdateAppAlert(this, LocaleController.getString("UpdateAppAlert", R.string.UpdateAppAlert), true);
            } else {
                showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + tL_error.text));
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$runLinkRequest$25$LaunchActivity(final AlertDialog alertDialog, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$24$LaunchActivity(alertDialog, tLObject);
            }
        });
    }

    public void lambda$null$24$LaunchActivity(AlertDialog alertDialog, TLObject tLObject) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (tLObject instanceof TLRPC.TL_help_deepLinkInfo) {
            TLRPC.TL_help_deepLinkInfo tL_help_deepLinkInfo = (TLRPC.TL_help_deepLinkInfo) tLObject;
            AlertsCreator.showUpdateAppAlert(this, tL_help_deepLinkInfo.message, tL_help_deepLinkInfo.update_app);
        }
    }

    public void lambda$runLinkRequest$27$LaunchActivity(final AlertDialog alertDialog, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$26$LaunchActivity(alertDialog, tLObject, tL_error);
            }
        });
    }

    public void lambda$null$26$LaunchActivity(AlertDialog alertDialog, TLObject tLObject, TLRPC.TL_error tL_error) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (tLObject instanceof TLRPC.TL_langPackLanguage) {
            showAlertDialog(AlertsCreator.createLanguageAlert(this, (TLRPC.TL_langPackLanguage) tLObject));
            return;
        }
        if (tL_error != null) {
            if ("LANG_CODE_NOT_SUPPORTED".equals(tL_error.text)) {
                showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("LanguageUnsupportedError", R.string.LanguageUnsupportedError)));
                return;
            }
            showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + tL_error.text));
        }
    }

    public void lambda$runLinkRequest$30$LaunchActivity(final AlertDialog alertDialog, final TLRPC.TL_wallPaper tL_wallPaper, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$29$LaunchActivity(alertDialog, tLObject, tL_wallPaper, tL_error);
            }
        });
    }

    public void lambda$null$29$LaunchActivity(AlertDialog alertDialog, TLObject tLObject, TLRPC.TL_wallPaper tL_wallPaper, TLRPC.TL_error tL_error) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (tLObject instanceof TLRPC.TL_wallPaper) {
            TLRPC.TL_wallPaper tL_wallPaper2 = (TLRPC.TL_wallPaper) tLObject;
            if (tL_wallPaper2.pattern) {
                WallpapersListActivity.ColorWallpaper colorWallpaper = new WallpapersListActivity.ColorWallpaper(-1L, tL_wallPaper.settings.background_color, tL_wallPaper2.id, tL_wallPaper.settings.intensity / 100.0f, tL_wallPaper.settings.motion, null);
                colorWallpaper.pattern = tL_wallPaper2;
                tL_wallPaper2 = colorWallpaper;
            }
            WallpaperActivity wallpaperActivity = new WallpaperActivity(tL_wallPaper2, null);
            wallpaperActivity.setInitialModes(tL_wallPaper.settings.blur, tL_wallPaper.settings.motion);
            lambda$runLinkRequest$28$LaunchActivity(wallpaperActivity);
            return;
        }
        showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + tL_error.text));
    }

    public void lambda$runLinkRequest$31$LaunchActivity() {
        this.loadingThemeFileName = null;
        this.loadingThemeWallpaperName = null;
        this.loadingThemeInfo = null;
        this.loadingThemeProgressDialog = null;
        this.loadingTheme = null;
    }

    public void lambda$runLinkRequest$33$LaunchActivity(final AlertDialog alertDialog, final TLObject tLObject, final TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$32$LaunchActivity(tLObject, alertDialog, tL_error);
            }
        });
    }

    public void lambda$null$32$LaunchActivity(TLObject tLObject, AlertDialog alertDialog, TLRPC.TL_error tL_error) {
        char c;
        if (tLObject instanceof TLRPC.TL_theme) {
            TLRPC.TL_theme tL_theme = (TLRPC.TL_theme) tLObject;
            if (tL_theme.document != null) {
                this.loadingTheme = tL_theme;
                this.loadingThemeFileName = FileLoader.getAttachFileName(tL_theme.document);
                this.loadingThemeProgressDialog = alertDialog;
                FileLoader.getInstance(this.currentAccount).loadFile(this.loadingTheme.document, tL_theme, 1, 1);
                c = 0;
            }
            c = 1;
        } else {
            if (tL_error == null || !"THEME_FORMAT_INVALID".equals(tL_error.text)) {
                c = 2;
            }
            c = 1;
        }
        if (c != 0) {
            try {
                alertDialog.dismiss();
            } catch (Exception e) {
                FileLog.e(e);
            }
            if (c == 1) {
                showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("ThemeNotSupported", R.string.ThemeNotSupported)));
            } else {
                showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("Theme", R.string.Theme), LocaleController.getString("ThemeNotFound", R.string.ThemeNotFound)));
            }
        }
    }

    public void lambda$runLinkRequest$36$LaunchActivity(final Bundle bundle, Integer num, int[] iArr, final AlertDialog alertDialog, final BaseFragment baseFragment, final int i) {
        if (this.actionBarLayout.presentFragment(new ChatActivity(bundle))) {
            return;
        }
        TLRPC.TL_channels_getChannels tL_channels_getChannels = new TLRPC.TL_channels_getChannels();
        TLRPC.TL_inputChannel tL_inputChannel = new TLRPC.TL_inputChannel();
        tL_inputChannel.channel_id = num.intValue();
        tL_channels_getChannels.id.add(tL_inputChannel);
        iArr[0] = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_channels_getChannels, new RequestDelegate() {
            @Override
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                LaunchActivity.this.lambda$null$35$LaunchActivity(alertDialog, baseFragment, i, bundle, tLObject, tL_error);
            }
        });
    }

    public void lambda$null$35$LaunchActivity(final AlertDialog alertDialog, final BaseFragment baseFragment, final int i, final Bundle bundle, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$34$LaunchActivity(alertDialog, tLObject, baseFragment, i, bundle);
            }
        });
    }

    public void lambda$null$34$LaunchActivity(AlertDialog alertDialog, TLObject tLObject, BaseFragment baseFragment, int i, Bundle bundle) {
        try {
            alertDialog.dismiss();
        } catch (Exception e) {
            FileLog.e(e);
        }
        boolean z = true;
        if (tLObject instanceof TLRPC.TL_messages_chats) {
            TLRPC.TL_messages_chats tL_messages_chats = (TLRPC.TL_messages_chats) tLObject;
            if (!tL_messages_chats.chats.isEmpty()) {
                MessagesController.getInstance(this.currentAccount).putChats(tL_messages_chats.chats, false);
                tL_messages_chats.chats.get(0);
                if (baseFragment == null || MessagesController.getInstance(i).checkCanOpenChat(bundle, baseFragment)) {
                    this.actionBarLayout.presentFragment(new ChatActivity(bundle));
                }
                z = false;
            }
        }
        if (z) {
            showAlertDialog(AlertsCreator.createSimpleAlert(this, LocaleController.getString("LinkNotFound", R.string.LinkNotFound)));
        }
    }

    public static void lambda$runLinkRequest$37(int i, int[] iArr, Runnable runnable, DialogInterface dialogInterface) {
        ConnectionsManager.getInstance(i).cancelRequest(iArr[0], true);
        if (runnable != null) {
            runnable.run();
        }
    }

    public void checkAppUpdate(final boolean z) {
        if (z) {
            showCheckUpdateDialog();
        }
        AppUpdater.getInstance(this.currentAccount).checkAppUpdate(new AppUpdater.OnForceUpdateCallback() {
            @Override
            public void onForce(TLRPC.TL_help_appUpdate tL_help_appUpdate) {
                LaunchActivity.this.dismissCheckUpdateDialog();
                if (LaunchActivity.this.updateAppAlertDialog == null || !LaunchActivity.this.updateAppAlertDialog.isShowing()) {
                    LaunchActivity launchActivity = LaunchActivity.this;
                    LaunchActivity launchActivity2 = LaunchActivity.this;
                    launchActivity.updateAppAlertDialog = new UpdateAppAlertDialog(launchActivity2, tL_help_appUpdate, launchActivity2.currentAccount);
                    LaunchActivity.this.updateAppAlertDialog.show();
                }
            }

            @Override
            public void onNormal(TLRPC.TL_help_appUpdate tL_help_appUpdate) {
                LaunchActivity.this.dismissCheckUpdateDialog();
                if (LaunchActivity.this.updateAppAlertDialog == null || !LaunchActivity.this.updateAppAlertDialog.isShowing()) {
                    LaunchActivity launchActivity = LaunchActivity.this;
                    LaunchActivity launchActivity2 = LaunchActivity.this;
                    launchActivity.updateAppAlertDialog = new UpdateAppAlertDialog(launchActivity2, tL_help_appUpdate, launchActivity2.currentAccount);
                    LaunchActivity.this.updateAppAlertDialog.show();
                }
            }

            @Override
            public void onNoUpdate() {
                LaunchActivity.this.dismissCheckUpdateDialog();
                LaunchActivity.this.dismissUpdateAppAlertDialog();
                if (z) {
                    ToastUtils.show(R.string.NoUpdate);
                }
            }
        }, z);
    }

    private void showCheckUpdateDialog() {
        dismissCheckUpdateDialog();
        AlertDialog alertDialog = new AlertDialog(this, 3);
        this.checkUpdateDialog = alertDialog;
        alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public final void onDismiss(DialogInterface dialogInterface) {
                LaunchActivity.this.lambda$showCheckUpdateDialog$38$LaunchActivity(dialogInterface);
            }
        });
        this.checkUpdateDialog.show();
    }

    public void lambda$showCheckUpdateDialog$38$LaunchActivity(DialogInterface dialogInterface) {
        AppUpdater.getInstance(this.currentAccount).cancel();
    }

    public void dismissCheckUpdateDialog() {
        AlertDialog alertDialog = this.checkUpdateDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
            this.checkUpdateDialog = null;
        }
    }

    public void dismissUpdateAppAlertDialog() {
        UpdateAppAlertDialog updateAppAlertDialog = this.updateAppAlertDialog;
        if (updateAppAlertDialog != null) {
            updateAppAlertDialog.dismiss();
            this.updateAppAlertDialog = null;
        }
    }

    public AlertDialog showAlertDialog(AlertDialog.Builder builder) {
        return showAlertDialog(builder.show());
    }

    public AlertDialog showAlertDialog(AlertDialog alertDialog) {
        try {
            if (this.visibleDialog != null) {
                this.visibleDialog.dismiss();
                this.visibleDialog = null;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        try {
            this.visibleDialog = alertDialog;
            alertDialog.setCanceledOnTouchOutside(true);
            this.visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialogInterface) {
                    if (LaunchActivity.this.visibleDialog != null) {
                        if (LaunchActivity.this.visibleDialog != LaunchActivity.this.localeDialog) {
                            if (LaunchActivity.this.visibleDialog == LaunchActivity.this.proxyErrorDialog) {
                                MessagesController.getGlobalMainSettings();
                                SharedPreferences.Editor edit = MessagesController.getGlobalMainSettings().edit();
                                edit.putBoolean("proxy_enabled", false);
                                edit.putBoolean("proxy_enabled_calls", false);
                                edit.commit();
                                NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.proxySettingsChanged);
                                ConnectionsManager.setProxySettings(false, "", 1080, "", "", "");
                                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxySettingsChanged, new Object[0]);
                                LaunchActivity.this.proxyErrorDialog = null;
                            }
                        } else {
                            try {
                                ToastUtils.show((CharSequence) LaunchActivity.this.getStringForLanguageAlert(LocaleController.getInstance().getCurrentLocaleInfo().shortName.equals("en") ? LaunchActivity.this.englishLocaleStrings : LaunchActivity.this.systemLocaleStrings, "ChangeLanguageLater", R.string.ChangeLanguageLater));
                            } catch (Exception e2) {
                                FileLog.e(e2);
                            }
                            LaunchActivity.this.localeDialog = null;
                        }
                    }
                    LaunchActivity.this.visibleDialog = null;
                }
            });
            return this.visibleDialog;
        } catch (Exception e2) {
            FileLog.e(e2);
            return null;
        }
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        queryProxyAccount(intent);
        handleIntent(intent, true, false, false);
        OpenInstallUitl.getInstance().getInstallOrWakeUp(intent);
    }

    @Override
    public void didSelectDialogs(DialogsActivity dialogsActivity, ArrayList<Long> arrayList, CharSequence charSequence, boolean z) {
        ?? r7;
        int i;
        String str;
        final long longValue = arrayList.get(0).longValue();
        int i2 = (int) longValue;
        int i3 = (int) (longValue >> 32);
        ArrayList<TLRPC.User> arrayList2 = this.contactsToSend;
        int size = arrayList2 != null ? arrayList2.size() + 0 : 0;
        if (this.videoPath != null) {
            size++;
        }
        ArrayList<SendMessagesHelper.SendingMediaInfo> arrayList3 = this.photoPathsArray;
        if (arrayList3 != null) {
            size += arrayList3.size();
        }
        ArrayList<String> arrayList4 = this.documentsPathsArray;
        if (arrayList4 != null) {
            size += arrayList4.size();
        }
        ArrayList<Uri> arrayList5 = this.documentsUrisArray;
        if (arrayList5 != null) {
            size += arrayList5.size();
        }
        if (this.videoPath == null && this.photoPathsArray == null && this.documentsPathsArray == null && this.documentsUrisArray == null && this.sendingText != null) {
            size++;
        }
        if (AlertsCreator.checkSlowMode(this, this.currentAccount, longValue, size > 1)) {
            return;
        }
        Bundle bundle = new Bundle();
        final int currentAccount = dialogsActivity != null ? dialogsActivity.getCurrentAccount() : this.currentAccount;
        bundle.putBoolean("scrollToTopOnResume", true);
        if (!AndroidUtilities.isTablet()) {
            NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats, new Object[0]);
        }
        if (i2 == 0) {
            bundle.putInt("enc_id", i3);
        } else if (i2 > 0) {
            bundle.putInt("user_id", i2);
        } else if (i2 < 0) {
            bundle.putInt("chat_id", -i2);
        }
        if (MessagesController.getInstance(currentAccount).checkCanOpenChat(bundle, dialogsActivity)) {
            final ChatActivity chatActivity = new ChatActivity(bundle);
            ArrayList<TLRPC.User> arrayList6 = this.contactsToSend;
            if (arrayList6 != null && arrayList6.size() == 1) {
                if (this.contactsToSend.size() == 1) {
                    PhonebookShareActivity phonebookShareActivity = new PhonebookShareActivity(null, this.contactsToSendUri, null, null);
                    phonebookShareActivity.setDelegate(new PhoneBookSelectActivity.PhoneBookSelectActivityDelegate() {
                        @Override
                        public final void didSelectContact(TLRPC.User user, boolean z2, int i4) {
                            LaunchActivity.this.lambda$didSelectDialogs$39$LaunchActivity(chatActivity, currentAccount, longValue, user, z2, i4);
                        }
                    });
                    this.actionBarLayout.presentFragment(phonebookShareActivity, dialogsActivity != null, dialogsActivity == null, true, false);
                }
                r7 = 0;
            } else {
                AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
                r7 = 0;
                this.actionBarLayout.presentFragment(chatActivity, dialogsActivity != null, dialogsActivity == null, true, false);
                String str2 = this.videoPath;
                if (str2 != null) {
                    chatActivity.openVideoEditor(str2, this.sendingText);
                    this.sendingText = null;
                }
                if (this.photoPathsArray != null) {
                    String str3 = this.sendingText;
                    if (str3 != null && str3.length() <= 1024 && this.photoPathsArray.size() == 1) {
                        this.photoPathsArray.get(0).caption = this.sendingText;
                        this.sendingText = null;
                    }
                    i = 1;
                    SendMessagesHelper.prepareSendingMedia(accountInstance, this.photoPathsArray, longValue, null, null, false, false, null, true, 0, false);
                } else {
                    i = 1;
                }
                if (this.documentsPathsArray != null || this.documentsUrisArray != null) {
                    String str4 = this.sendingText;
                    if (str4 != null && str4.length() <= 1024) {
                        ArrayList<String> arrayList7 = this.documentsPathsArray;
                        int size2 = arrayList7 != null ? arrayList7.size() : 0;
                        ArrayList<Uri> arrayList8 = this.documentsUrisArray;
                        if (size2 + (arrayList8 != null ? arrayList8.size() : 0) == i) {
                            String str5 = this.sendingText;
                            this.sendingText = null;
                            str = str5;
                            SendMessagesHelper.prepareSendingDocuments(accountInstance, this.documentsPathsArray, this.documentsOriginalPathsArray, this.documentsUrisArray, str, this.documentsMimeType, longValue, null, null, null, true, 0);
                        }
                    }
                    str = null;
                    SendMessagesHelper.prepareSendingDocuments(accountInstance, this.documentsPathsArray, this.documentsOriginalPathsArray, this.documentsUrisArray, str, this.documentsMimeType, longValue, null, null, null, true, 0);
                }
                String str6 = this.sendingText;
                if (str6 != null) {
                    SendMessagesHelper.prepareSendingText(accountInstance, str6, longValue, true, 0);
                }
                ArrayList<TLRPC.User> arrayList9 = this.contactsToSend;
                if (arrayList9 != null && !arrayList9.isEmpty()) {
                    for (int i4 = 0; i4 < this.contactsToSend.size(); i4++) {
                        SendMessagesHelper.getInstance(currentAccount).sendMessage(this.contactsToSend.get(i4), longValue, (MessageObject) null, (TLRPC.ReplyMarkup) null, (HashMap<String, String>) null, true, 0);
                    }
                }
            }
            this.photoPathsArray = r7;
            this.videoPath = r7;
            this.sendingText = r7;
            this.documentsPathsArray = r7;
            this.documentsOriginalPathsArray = r7;
            this.contactsToSend = r7;
            this.contactsToSendUri = r7;
        }
    }

    public void lambda$didSelectDialogs$39$LaunchActivity(ChatActivity chatActivity, int i, long j, TLRPC.User user, boolean z, int i2) {
        this.actionBarLayout.presentFragment(chatActivity, true, false, true, false);
        SendMessagesHelper.getInstance(i).sendMessage(user, j, (MessageObject) null, (TLRPC.ReplyMarkup) null, (HashMap<String, String>) null, z, i2);
    }

    private void onFinish() {
        if (this.finished) {
            return;
        }
        this.finished = true;
        Runnable runnable = this.lockRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
            this.lockRunnable = null;
        }
        int i = this.currentAccount;
        if (i != -1) {
            NotificationCenter.getInstance(i).removeObserver(this, NotificationCenter.appDidLogout);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.mainUserInfoChanged);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.didUpdateConnectionState);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.needShowAlert);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.wasUnableToFindCurrentLocation);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.openArticle);
            NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.hasNewContactsToImport);
        }
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needShowAlert);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewWallpapper);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.suggestedLangpack);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.reloadInterface);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewTheme);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needSetDayNightTheme);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetPasscode);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.notificationsCountUpdated);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.receivedAVideoCallRequest);
    }

    public void lambda$runLinkRequest$28$LaunchActivity(BaseFragment baseFragment) {
        this.actionBarLayout.presentFragment(baseFragment);
    }

    public boolean presentFragment(BaseFragment baseFragment, boolean z, boolean z2) {
        return this.actionBarLayout.presentFragment(baseFragment, z, z2, true, false);
    }

    public ActionBarLayout getActionBarLayout() {
        return this.actionBarLayout;
    }

    public ActionBarLayout getLayersActionBarLayout() {
        return this.layersActionBarLayout;
    }

    public ActionBarLayout getRightActionBarLayout() {
        return this.rightActionBarLayout;
    }

    private void parseSechmeOpenAccount(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        String replace = str.replace("hchat:openKey=", "").replace("hchat://openKey=", "");
        if (TextUtils.isEmpty(replace)) {
            return;
        }
        String str2 = new String(Base64.decode(replace.replace("%3D", "="), 0));
        String[] split = str2.split("#");
        String str3 = split[0].split("=")[1];
        String str4 = split[1].split("=")[1];
        if (str2.contains("Uname")) {
            MessagesController.getInstance(UserConfig.selectedAccount).openByUserName(split[2].split("=")[1], getActionBarLayout().getCurrentFragment(), 1, getActionBarLayout().fragmentsStack == null || getActionBarLayout().fragmentsStack.size() <= 1);
            return;
        }
        TLRPC.TL_user tL_user = new TLRPC.TL_user();
        try {
            tL_user.id = Integer.valueOf(str3).intValue();
            tL_user.access_hash = Long.valueOf(str4).longValue();
            getUserInfo(tL_user);
        } catch (NumberFormatException e) {
            FileLog.e("parse qr code err:" + e);
        }
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        if (SharedConfig.passcodeHash.length() != 0 && SharedConfig.lastPauseTime != 0) {
            SharedConfig.lastPauseTime = 0;
            UserConfig.getInstance(this.currentAccount).saveConfig(false);
        }
        super.onActivityResult(i, i2, intent);
        if (i == PLAY_SERVICES_REQUEST_CHECK_SETTINGS) {
            LocationController.getInstance(this.currentAccount).startFusedLocationRequest(i2 == -1);
            return;
        }
        ThemeEditorView themeEditorView = ThemeEditorView.getInstance();
        if (themeEditorView != null) {
            themeEditorView.onActivityResult(i, i2, intent);
        }
        if (this.actionBarLayout.fragmentsStack.size() != 0) {
            this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1).onActivityResultFragment(i, i2, intent);
        }
        if (AndroidUtilities.isTablet()) {
            if (this.rightActionBarLayout.fragmentsStack.size() != 0) {
                this.rightActionBarLayout.fragmentsStack.get(this.rightActionBarLayout.fragmentsStack.size() - 1).onActivityResultFragment(i, i2, intent);
            }
            if (this.layersActionBarLayout.fragmentsStack.size() != 0) {
                this.layersActionBarLayout.fragmentsStack.get(this.layersActionBarLayout.fragmentsStack.size() - 1).onActivityResultFragment(i, i2, intent);
            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        boolean z = iArr.length > 0 && iArr[0] == 0;
        if (i == 4) {
            if (!z) {
                showPermissionErrorAlert(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
            } else {
                ImageLoader.getInstance().checkMediaPaths();
            }
        } else if (i == 5) {
            if (!z) {
                ContactsController.getInstance(this.currentAccount).forceImportContacts();
            } else {
                showPermissionErrorAlert(LocaleController.getString("PermissionContacts", R.string.PermissionContacts));
                return;
            }
        } else if (i == 3) {
            int length = strArr.length;
            boolean z2 = true;
            boolean z3 = true;
            for (int i2 = 0; i2 < length; i2++) {
                if ("android.permission.RECORD_AUDIO".equals(strArr[i2])) {
                    z2 = iArr[i2] == 0;
                } else if ("android.permission.CAMERA".equals(strArr[i2])) {
                    z3 = iArr[i2] == 0;
                }
            }
            if (!z2) {
                showPermissionErrorAlert(LocaleController.getString("PermissionNoAudio", R.string.PermissionNoAudio));
            } else if (!z3) {
                showPermissionErrorAlert(LocaleController.getString("PermissionNoCamera", R.string.PermissionNoCamera));
            } else {
                if (SharedConfig.inappCamera) {
                    CameraController.getInstance().initCamera(null);
                    return;
                }
                return;
            }
        } else if (i == 18 || i == 19 || i == 20 || i == 22) {
            if (!z) {
                showPermissionErrorAlert(LocaleController.getString("PermissionNoCamera", R.string.PermissionNoCamera));
            }
        } else if (i == 2 && z) {
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.locationPermissionGranted, new Object[0]);
        }
        if (this.actionBarLayout.fragmentsStack.size() != 0) {
            this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1).onRequestPermissionsResultFragment(i, strArr, iArr);
        }
        if (AndroidUtilities.isTablet()) {
            if (this.rightActionBarLayout.fragmentsStack.size() != 0) {
                this.rightActionBarLayout.fragmentsStack.get(this.rightActionBarLayout.fragmentsStack.size() - 1).onRequestPermissionsResultFragment(i, strArr, iArr);
            }
            if (this.layersActionBarLayout.fragmentsStack.size() != 0) {
                this.layersActionBarLayout.fragmentsStack.get(this.layersActionBarLayout.fragmentsStack.size() - 1).onRequestPermissionsResultFragment(i, strArr, iArr);
            }
        }
    }

    private void showPermissionErrorAlert(String str) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(str);
        builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                LaunchActivity.this.lambda$showPermissionErrorAlert$40$LaunchActivity(dialogInterface, i);
            }
        });
        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
        builder.show();
    }

    public void lambda$showPermissionErrorAlert$40$LaunchActivity(DialogInterface dialogInterface, int i) {
        try {
            Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("LaunchActivity ---> onPause");
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 4096);
        SharedConfig.lastAppPauseTime = System.currentTimeMillis();
        ApplicationLoader.mainInterfacePaused = true;
        Utilities.stageQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.lambda$onPause$41();
            }
        });
        onPasscodePause();
        this.actionBarLayout.onPause();
        if (AndroidUtilities.isTablet()) {
            this.rightActionBarLayout.onPause();
            this.layersActionBarLayout.onPause();
        }
        PasscodeView passcodeView = this.passcodeView;
        if (passcodeView != null) {
            passcodeView.onPause();
        }
        ConnectionsManager.getInstance(this.currentAccount).setAppPaused(true, false);
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().onPause();
        }
    }

    public static void lambda$onPause$41() {
        ApplicationLoader.mainInterfacePausedStageQueue = true;
        ApplicationLoader.mainInterfacePausedStageQueueTime = 0L;
    }

    @Override
    public void onStart() {
        super.onStart();
        Browser.bindCustomTabsService(this);
    }

    @Override
    public void onStop() {
        super.onStop();
        if (!AndroidUtilities.isAppOnForeground(this)) {
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.hideAVideoFloatWindow, 1);
            this.mBytJumpFromBack = (byte) 1;
            clearNotification();
        }
        Browser.unbindCustomTabsService(this);
    }

    @Override
    public void onDestroy() {
        if (PhotoViewer.getPipInstance() != null) {
            PhotoViewer.getPipInstance().destroyPhotoViewer();
        }
        if (PhotoViewer.hasInstance()) {
            PhotoViewer.getInstance().destroyPhotoViewer();
        }
        if (ImagePreviewActivity.getPipInstance() != null) {
            ImagePreviewActivity.getPipInstance().destroyPhotoViewer();
        }
        if (ImagePreviewActivity.hasInstance()) {
            ImagePreviewActivity.getInstance().destroyPhotoViewer();
        }
        if (PlayerUtils.getPlayer() != null) {
            PlayerUtils.getPlayer().pause();
            PlayerUtils.getPlayer().destroy();
        }
        if (SecretMediaViewer.hasInstance()) {
            SecretMediaViewer.getInstance().destroyPhotoViewer();
        }
        if (ArticleViewer.hasInstance()) {
            ArticleViewer.getInstance().destroyArticleViewer();
        }
        if (ContentPreviewViewer.hasInstance()) {
            ContentPreviewViewer.getInstance().destroy();
        }
        PipRoundVideoView pipRoundVideoView = PipRoundVideoView.getInstance();
        MediaController.getInstance().setBaseActivity(this, false);
        MediaController.getInstance().setFeedbackView(this.actionBarLayout, false);
        if (pipRoundVideoView != null) {
            pipRoundVideoView.close(false);
        }
        Theme.destroyResources();
        EmbedBottomSheet embedBottomSheet = EmbedBottomSheet.getInstance();
        if (embedBottomSheet != null) {
            embedBottomSheet.destroy();
        }
        ThemeEditorView themeEditorView = ThemeEditorView.getInstance();
        if (themeEditorView != null) {
            themeEditorView.destroy();
        }
        DiscoveryJumpPausedFloatingView.destroy();
        try {
            if (this.visibleDialog != null) {
                this.visibleDialog.dismiss();
                this.visibleDialog = null;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        try {
            if (this.onGlobalLayoutListener != null) {
                getWindow().getDecorView().getRootView().getViewTreeObserver().removeOnGlobalLayoutListener(this.onGlobalLayoutListener);
            }
        } catch (Exception e2) {
            FileLog.e(e2);
        }
        OpenInstallUitl.getInstance().onDestroy();
        super.onDestroy();
        onFinish();
    }

    private void clearNotification() {
        NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
        if (notificationManager != null) {
            notificationManager.cancelAll();
        }
    }

    @Override
    public void onResume() {
        MessageObject playingMessageObject;
        super.onResume();
        byte b = this.mBytJumpFromBack;
        if (b == 1 || b == 0) {
            clearNotification();
        }
        this.mBytJumpFromBack = (byte) 2;
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 4096);
        MediaController.getInstance().setFeedbackView(this.actionBarLayout, true);
        ApplicationLoader.mainInterfacePaused = false;
        showLanguageAlert(false);
        Utilities.stageQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.lambda$onResume$42();
            }
        });
        checkFreeDiscSpace();
        MediaController.checkGallery();
        onPasscodeResume();
        if (this.passcodeView.getVisibility() != 0) {
            this.actionBarLayout.onResume();
            if (AndroidUtilities.isTablet()) {
                this.rightActionBarLayout.onResume();
                this.layersActionBarLayout.onResume();
            }
        } else {
            this.actionBarLayout.dismissDialogs();
            if (AndroidUtilities.isTablet()) {
                this.rightActionBarLayout.dismissDialogs();
                this.layersActionBarLayout.dismissDialogs();
            }
            this.passcodeView.onResume();
        }
        ConnectionsManager.getInstance(this.currentAccount).setAppPaused(false, false);
        updateCurrentConnectionState(this.currentAccount);
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().onResume();
        }
        if (PipRoundVideoView.getInstance() != null && MediaController.getInstance().isMessagePaused() && (playingMessageObject = MediaController.getInstance().getPlayingMessageObject()) != null) {
            MediaController.getInstance().seekToProgress(playingMessageObject, playingMessageObject.audioProgress);
        }
        if (UserConfig.getInstance(UserConfig.selectedAccount).unacceptedTermsOfService != null) {
            showTosActivity(UserConfig.selectedAccount, UserConfig.getInstance(UserConfig.selectedAccount).unacceptedTermsOfService);
        } else if (AppUpdater.pendingAppUpdate != null) {
            dismissCheckUpdateDialog();
            UpdateAppAlertDialog updateAppAlertDialog = this.updateAppAlertDialog;
            if (updateAppAlertDialog != null && updateAppAlertDialog.isShowing()) {
                return;
            }
            UpdateAppAlertDialog updateAppAlertDialog2 = new UpdateAppAlertDialog(this, AppUpdater.pendingAppUpdate, this.currentAccount);
            this.updateAppAlertDialog = updateAppAlertDialog2;
            updateAppAlertDialog2.show();
        }
        checkAppUpdate(false);
        processVisualCallRequest();
        RingUtils.stopMediaPlayerRing();
        try {
            if (ApplicationLoader.mbytAVideoCallBusy == 1) {
                startActivity(new Intent(this, (Class<?>) VisualCallReceiveActivity.class));
            } else if (ApplicationLoader.mbytAVideoCallBusy == 2) {
                startActivity(new Intent(this, (Class<?>) VisualCallActivity.class));
            } else if (ApplicationLoader.mbytAVideoCallBusy == 3 || ApplicationLoader.mbytAVideoCallBusy == 4) {
                NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.hideAVideoFloatWindow, 0);
            }
        } catch (Exception unused) {
        }
    }

    public static void lambda$onResume$42() {
        ApplicationLoader.mainInterfacePausedStageQueue = false;
        ApplicationLoader.mainInterfacePausedStageQueueTime = System.currentTimeMillis();
    }

    private void processVisualCallRequest() {
        final ArrayList<VisualCallRequestParaBean> queryVisualCallRequest = DatabaseInstance.queryVisualCallRequest();
        if (queryVisualCallRequest.size() > 0) {
            this.actionBarLayout.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    LaunchActivity.this.lambda$processVisualCallRequest$43$LaunchActivity(queryVisualCallRequest);
                }
            }, 500L);
        }
    }

    public void lambda$processVisualCallRequest$43$LaunchActivity(ArrayList arrayList) {
        DatabaseInstance.deleteVisualCallRequest();
        VisualCallRequestParaBean visualCallRequestParaBean = (VisualCallRequestParaBean) arrayList.get(0);
        Intent intent = new Intent(this, (Class<?>) VisualCallReceiveActivity.class);
        intent.putExtra(MimeTypes.BASE_TYPE_VIDEO, visualCallRequestParaBean.isVideo());
        intent.putExtra(TtmlNode.ATTR_ID, visualCallRequestParaBean.getStrId());
        intent.putExtra("admin_id", visualCallRequestParaBean.getAdmin_id());
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("Launch call ===> processVisualCallRequest admin_id = " + visualCallRequestParaBean.getAdmin_id());
        }
        intent.putExtra("app_id", visualCallRequestParaBean.getApp_id());
        intent.putExtra("token", visualCallRequestParaBean.getToken());
        intent.putStringArrayListExtra("gslb", new ArrayList<>(Arrays.asList(visualCallRequestParaBean.getGslb().split(","))));
        intent.putExtra("json", visualCallRequestParaBean.getJson());
        intent.putExtra("from", 1);
        intent.addFlags(C.ENCODING_PCM_MU_LAW);
        startActivity(intent);
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        AndroidUtilities.checkDisplaySize(this, configuration);
        super.onConfigurationChanged(configuration);
        checkLayout();
        PipRoundVideoView pipRoundVideoView = PipRoundVideoView.getInstance();
        if (pipRoundVideoView != null) {
            pipRoundVideoView.onConfigurationChanged();
        }
        EmbedBottomSheet embedBottomSheet = EmbedBottomSheet.getInstance();
        if (embedBottomSheet != null) {
            embedBottomSheet.onConfigurationChanged(configuration);
        }
        PhotoViewer pipInstance = PhotoViewer.getPipInstance();
        if (pipInstance != null) {
            pipInstance.onConfigurationChanged(configuration);
        }
        ThemeEditorView themeEditorView = ThemeEditorView.getInstance();
        if (themeEditorView != null) {
            themeEditorView.onConfigurationChanged();
        }
    }

    @Override
    public void onMultiWindowModeChanged(boolean z) {
        AndroidUtilities.isInMultiwindow = z;
        checkLayout();
    }

    @Override
    public void didReceivedNotification(int i, final int i2, Object... objArr) {
        View childAt;
        if (i == NotificationCenter.appDidLogout) {
            switchToAvailableAccountOrLogout();
            return;
        }
        r1 = false;
        boolean z = false;
        if (i == NotificationCenter.closeOtherAppActivities) {
            if (objArr[0] != this) {
                onFinish();
                finish();
                return;
            }
            return;
        }
        if (i == NotificationCenter.didUpdateConnectionState) {
            int connectionState = ConnectionsManager.getInstance(i2).getConnectionState();
            if (this.currentConnectionState != connectionState) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("switch to state " + connectionState);
                }
                this.currentConnectionState = connectionState;
                updateCurrentConnectionState(i2);
                return;
            }
            return;
        }
        if (i == NotificationCenter.mainUserInfoChanged) {
            this.drawerLayoutAdapter.notifyDataSetChanged();
            return;
        }
        if (i == NotificationCenter.needShowAlert) {
            Integer num = (Integer) objArr[0];
            if (num.intValue() != 3 || this.proxyErrorDialog == null) {
                if (num.intValue() == 4) {
                    showTosActivity(i2, (TLRPC.TL_help_termsOfService) objArr[1]);
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                if (num.intValue() != 2 && num.intValue() != 3) {
                    builder.setNegativeButton(LocaleController.getString("MoreInfo", R.string.MoreInfo), new DialogInterface.OnClickListener() {
                        @Override
                        public final void onClick(DialogInterface dialogInterface, int i3) {
                            LaunchActivity.lambda$didReceivedNotification$44(i2, dialogInterface, i3);
                        }
                    });
                }
                if (num.intValue() == 5) {
                    builder.setMessage(LocaleController.getString("NobodyLikesSpam3", R.string.NobodyLikesSpam3));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                } else if (num.intValue() == 0) {
                    builder.setMessage(LocaleController.getString("NobodyLikesSpam1", R.string.NobodyLikesSpam1));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                } else if (num.intValue() == 1) {
                    builder.setMessage(LocaleController.getString("NobodyLikesSpam2", R.string.NobodyLikesSpam2));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                } else if (num.intValue() == 2) {
                    if ("ErrorSendMessageTooFreq".equals((String) objArr[1])) {
                        builder.setMessage(LocaleController.getString(R.string.ErrorSendMessageTooFreq));
                    } else {
                        builder.setMessage((String) objArr[1]);
                    }
                    if (((String) objArr[2]).startsWith("AUTH_KEY_DROP_")) {
                        builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                        builder.setNegativeButton(LocaleController.getString("LogOut", R.string.LogOut), new DialogInterface.OnClickListener() {
                            @Override
                            public final void onClick(DialogInterface dialogInterface, int i3) {
                                LaunchActivity.this.lambda$didReceivedNotification$45$LaunchActivity(dialogInterface, i3);
                            }
                        });
                    } else {
                        builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                    }
                } else if (num.intValue() == 3) {
                    builder.setMessage(LocaleController.getString("UseProxyErrorTips", R.string.UseProxyErrorTips));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                    this.proxyErrorDialog = showAlertDialog(builder);
                    return;
                }
                if (mainFragmentsStack.isEmpty()) {
                    return;
                }
                ArrayList<BaseFragment> arrayList = mainFragmentsStack;
                arrayList.get(arrayList.size() - 1).showDialog(builder.create());
                return;
            }
            return;
        }
        if (i == NotificationCenter.wasUnableToFindCurrentLocation) {
            final HashMap hashMap = (HashMap) objArr[0];
            AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
            builder2.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder2.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
            builder2.setNegativeButton(LocaleController.getString("ShareYouLocationUnableManually", R.string.ShareYouLocationUnableManually), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i3) {
                    LaunchActivity.this.lambda$didReceivedNotification$47$LaunchActivity(hashMap, i2, dialogInterface, i3);
                }
            });
            builder2.setMessage(LocaleController.getString("ShareYouLocationUnable", R.string.ShareYouLocationUnable));
            if (mainFragmentsStack.isEmpty()) {
                return;
            }
            ArrayList<BaseFragment> arrayList2 = mainFragmentsStack;
            arrayList2.get(arrayList2.size() - 1).showDialog(builder2.create());
            return;
        }
        if (i == NotificationCenter.didSetNewWallpapper) {
            RecyclerListView recyclerListView = this.sideMenu;
            if (recyclerListView == null || (childAt = recyclerListView.getChildAt(0)) == null) {
                return;
            }
            childAt.invalidate();
            return;
        }
        if (i == NotificationCenter.didSetPasscode) {
            if (SharedConfig.passcodeHash.length() > 0 && !SharedConfig.allowScreenCapture) {
                try {
                    getWindow().setFlags(8192, 8192);
                    return;
                } catch (Exception e) {
                    FileLog.e(e);
                    return;
                }
            }
            if (MediaController.getInstance().hasFlagSecureFragment()) {
                return;
            }
            try {
                getWindow().clearFlags(8192);
                return;
            } catch (Exception e2) {
                FileLog.e(e2);
                return;
            }
        }
        if (i == NotificationCenter.reloadInterface) {
            if (mainFragmentsStack.size() > 1) {
                ArrayList<BaseFragment> arrayList3 = mainFragmentsStack;
                if (arrayList3.get(arrayList3.size() - 1) instanceof SettingsActivity) {
                    z = true;
                }
            }
            rebuildAllFragments(z);
            return;
        }
        if (i == NotificationCenter.suggestedLangpack) {
            showLanguageAlert(false);
            return;
        }
        if (i == NotificationCenter.openArticle) {
            if (mainFragmentsStack.isEmpty()) {
                return;
            }
            ArticleViewer articleViewer = ArticleViewer.getInstance();
            ArrayList<BaseFragment> arrayList4 = mainFragmentsStack;
            articleViewer.setParentActivity(this, arrayList4.get(arrayList4.size() - 1));
            ArticleViewer.getInstance().open((TLRPC.TL_webPage) objArr[0], (String) objArr[1]);
            return;
        }
        if (i == NotificationCenter.hasNewContactsToImport) {
            ActionBarLayout actionBarLayout = this.actionBarLayout;
            if (actionBarLayout == null || actionBarLayout.fragmentsStack.isEmpty()) {
                return;
            }
            ((Integer) objArr[0]).intValue();
            final HashMap hashMap2 = (HashMap) objArr[1];
            final boolean booleanValue = ((Boolean) objArr[2]).booleanValue();
            final boolean booleanValue2 = ((Boolean) objArr[3]).booleanValue();
            BaseFragment baseFragment = this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1);
            AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
            builder3.setTitle(LocaleController.getString("UpdateContactsTitle", R.string.UpdateContactsTitle));
            builder3.setMessage(LocaleController.getString("UpdateContactsMessage", R.string.UpdateContactsMessage));
            builder3.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i3) {
                    ContactsController.getInstance(i2).syncPhoneBookByAlert(hashMap2, booleanValue, booleanValue2, false);
                }
            });
            builder3.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i3) {
                    ContactsController.getInstance(i2).syncPhoneBookByAlert(hashMap2, booleanValue, booleanValue2, true);
                }
            });
            builder3.setOnBackButtonListener(new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i3) {
                    ContactsController.getInstance(i2).syncPhoneBookByAlert(hashMap2, booleanValue, booleanValue2, true);
                }
            });
            AlertDialog create = builder3.create();
            baseFragment.showDialog(create);
            create.setCanceledOnTouchOutside(false);
            return;
        }
        if (i == NotificationCenter.didSetNewTheme) {
            if (!((Boolean) objArr[0]).booleanValue()) {
                RecyclerListView recyclerListView2 = this.sideMenu;
                if (recyclerListView2 != null) {
                    recyclerListView2.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
                    this.sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
                    this.sideMenu.setListSelectorColor(Theme.getColor(Theme.key_listSelector));
                    this.sideMenu.getAdapter().notifyDataSetChanged();
                }
                if (Build.VERSION.SDK_INT >= 21) {
                    try {
                        setTaskDescription(new ActivityManager.TaskDescription((String) null, (Bitmap) null, Theme.getColor(Theme.key_actionBarDefault) | (-16777216)));
                    } catch (Exception unused) {
                    }
                }
            }
            this.drawerLayoutContainer.setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
            return;
        }
        if (i == NotificationCenter.needSetDayNightTheme) {
            Theme.ThemeInfo themeInfo = (Theme.ThemeInfo) objArr[0];
            boolean booleanValue3 = ((Boolean) objArr[1]).booleanValue();
            this.actionBarLayout.animateThemedValues(themeInfo, booleanValue3);
            if (AndroidUtilities.isTablet()) {
                this.layersActionBarLayout.animateThemedValues(themeInfo, booleanValue3);
                this.rightActionBarLayout.animateThemedValues(themeInfo, booleanValue3);
                return;
            }
            return;
        }
        if (i == NotificationCenter.notificationsCountUpdated) {
            RecyclerListView recyclerListView3 = this.sideMenu;
            if (recyclerListView3 != null) {
                Integer num2 = (Integer) objArr[0];
                int childCount = recyclerListView3.getChildCount();
                for (int i3 = 0; i3 < childCount; i3++) {
                    View childAt2 = this.sideMenu.getChildAt(i3);
                    if ((childAt2 instanceof DrawerUserCell) && ((DrawerUserCell) childAt2).getAccountNumber() == num2.intValue()) {
                        childAt2.invalidate();
                        return;
                    }
                }
                return;
            }
            return;
        }
        if (i == NotificationCenter.needShowPlayServicesAlert) {
            try {
                ((Status) objArr[0]).startResolutionForResult(this, PLAY_SERVICES_REQUEST_CHECK_SETTINGS);
                return;
            } catch (Throwable unused2) {
                return;
            }
        }
        if (i == NotificationCenter.fileDidLoad) {
            String str = this.loadingThemeFileName;
            if (str != null) {
                if (str.equals((String) objArr[0])) {
                    this.loadingThemeFileName = null;
                    File file = new File(ApplicationLoader.getFilesDirFixed(), "remote" + this.loadingTheme.id + ".attheme");
                    final Theme.ThemeInfo fillThemeValues = Theme.fillThemeValues(file, this.loadingTheme.title, this.loadingTheme);
                    if (fillThemeValues != null) {
                        if (fillThemeValues.pathToWallpaper != null && !new File(fillThemeValues.pathToWallpaper).exists()) {
                            TLRPC.TL_account_getWallPaper tL_account_getWallPaper = new TLRPC.TL_account_getWallPaper();
                            TLRPC.TL_inputWallPaperSlug tL_inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
                            tL_inputWallPaperSlug.slug = fillThemeValues.slug;
                            tL_account_getWallPaper.wallpaper = tL_inputWallPaperSlug;
                            ConnectionsManager.getInstance(fillThemeValues.account).sendRequest(tL_account_getWallPaper, new RequestDelegate() {
                                @Override
                                public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                                    LaunchActivity.this.lambda$didReceivedNotification$52$LaunchActivity(fillThemeValues, tLObject, tL_error);
                                }
                            });
                            return;
                        }
                        Theme.ThemeInfo applyThemeFile = Theme.applyThemeFile(file, this.loadingTheme.title, this.loadingTheme, true);
                        if (applyThemeFile != null) {
                            lambda$runLinkRequest$28$LaunchActivity(new ThemePreviewActivity(applyThemeFile, true, 0, false));
                        }
                    }
                    onThemeLoadFinish();
                    return;
                }
                return;
            }
            String str2 = this.loadingThemeWallpaperName;
            if (str2 == null || !str2.equals((String) objArr[0])) {
                return;
            }
            this.loadingThemeWallpaperName = null;
            final File file2 = (File) objArr[1];
            Utilities.globalQueue.postRunnable(new Runnable() {
                @Override
                public final void run() {
                    LaunchActivity.this.lambda$didReceivedNotification$54$LaunchActivity(file2);
                }
            });
            return;
        }
        if (i == NotificationCenter.fileDidFailToLoad) {
            String str3 = (String) objArr[0];
            if (str3.equals(this.loadingThemeFileName) || str3.equals(this.loadingThemeWallpaperName)) {
                onThemeLoadFinish();
                return;
            }
            return;
        }
        if (i == NotificationCenter.receivedAVideoCallRequest) {
            TLRPCCall.TL_UpdateMeetCallRequested tL_UpdateMeetCallRequested = (TLRPCCall.TL_UpdateMeetCallRequested) objArr[0];
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("Launch call ===> receive video call , type = " + ((int) ApplicationLoader.mbytAVideoCallBusy));
            }
            if (tL_UpdateMeetCallRequested != null) {
                if (!isExistMainActivity(VisualCallReceiveActivity.class)) {
                    Intent intent = new Intent(this, (Class<?>) VisualCallReceiveActivity.class);
                    intent.putExtra(MimeTypes.BASE_TYPE_VIDEO, false);
                    intent.putExtra(TtmlNode.ATTR_ID, tL_UpdateMeetCallRequested.id);
                    intent.putExtra("admin_id", tL_UpdateMeetCallRequested.admin_id);
                    intent.putExtra("app_id", tL_UpdateMeetCallRequested.appid);
                    intent.putExtra("token", tL_UpdateMeetCallRequested.token);
                    intent.putStringArrayListExtra("gslb", tL_UpdateMeetCallRequested.gslb);
                    intent.putExtra("json", tL_UpdateMeetCallRequested.data.data);
                    startActivity(intent);
                    ApplicationLoader.mbytAVideoCallBusy = (byte) 1;
                    return;
                }
                AVideoCallInterface.IsBusyingNow(tL_UpdateMeetCallRequested.id);
                return;
            }
            return;
        }
        if (i == NotificationCenter.folderWebView) {
            createGamePlayingFloatingView();
        }
    }

    public static void lambda$didReceivedNotification$44(int i, DialogInterface dialogInterface, int i2) {
        if (mainFragmentsStack.isEmpty()) {
            return;
        }
        MessagesController messagesController = MessagesController.getInstance(i);
        ArrayList<BaseFragment> arrayList = mainFragmentsStack;
        messagesController.openByUserName("spambot", arrayList.get(arrayList.size() - 1), 1);
    }

    public void lambda$didReceivedNotification$45$LaunchActivity(DialogInterface dialogInterface, int i) {
        MessagesController.getInstance(this.currentAccount).performLogout(2);
    }

    public void lambda$didReceivedNotification$47$LaunchActivity(final HashMap hashMap, final int i, DialogInterface dialogInterface, int i2) {
        if (mainFragmentsStack.isEmpty()) {
            return;
        }
        if (Build.VERSION.SDK_INT >= 23 && checkSelfPermission(PermissionUtils.PERMISSION_ACCESS_COARSE_LOCATION) != 0) {
            requestPermissions(new String[]{PermissionUtils.PERMISSION_ACCESS_COARSE_LOCATION, "android.permission.ACCESS_FINE_LOCATION"}, 2);
            return;
        }
        NewLocationActivity newLocationActivity = new NewLocationActivity(0);
        newLocationActivity.setDelegate(new NewLocationActivity.LocationActivityDelegate() {
            @Override
            public final void didSelectLocation(TLRPC.MessageMedia messageMedia, int i3, boolean z, int i4) {
                LaunchActivity.lambda$null$46(hashMap, i, messageMedia, i3, z, i4);
            }
        });
        lambda$runLinkRequest$28$LaunchActivity(newLocationActivity);
    }

    public static void lambda$null$46(HashMap hashMap, int i, TLRPC.MessageMedia messageMedia, int i2, boolean z, int i3) {
        Iterator it = hashMap.entrySet().iterator();
        while (it.hasNext()) {
            MessageObject messageObject = (MessageObject) ((Map.Entry) it.next()).getValue();
            SendMessagesHelper.getInstance(i).sendMessage(messageMedia, messageObject.getDialogId(), messageObject, (TLRPC.ReplyMarkup) null, (HashMap<String, String>) null, z, i3);
        }
    }

    public void lambda$didReceivedNotification$52$LaunchActivity(final Theme.ThemeInfo themeInfo, final TLObject tLObject, TLRPC.TL_error tL_error) {
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$51$LaunchActivity(tLObject, themeInfo);
            }
        });
    }

    public void lambda$null$51$LaunchActivity(TLObject tLObject, Theme.ThemeInfo themeInfo) {
        if (tLObject instanceof TLRPC.TL_wallPaper) {
            TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) tLObject;
            this.loadingThemeInfo = themeInfo;
            this.loadingThemeWallpaperName = FileLoader.getAttachFileName(tL_wallPaper.document);
            FileLoader.getInstance(themeInfo.account).loadFile(tL_wallPaper.document, tL_wallPaper, 1, 1);
            return;
        }
        onThemeLoadFinish();
    }

    public void lambda$didReceivedNotification$54$LaunchActivity(File file) {
        try {
            Bitmap scaledBitmap = ThemesHorizontalListCell.getScaledBitmap(AndroidUtilities.dp(640.0f), AndroidUtilities.dp(360.0f), file.getAbsolutePath(), null, 0);
            if (this.loadingThemeInfo.isBlured) {
                scaledBitmap = Utilities.blurWallpaper(scaledBitmap);
            }
            FileOutputStream fileOutputStream = new FileOutputStream(this.loadingThemeInfo.pathToWallpaper);
            scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 87, fileOutputStream);
            fileOutputStream.close();
        } catch (Throwable th) {
            FileLog.e(th);
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$53$LaunchActivity();
            }
        });
    }

    public void lambda$null$53$LaunchActivity() {
        Theme.ThemeInfo applyThemeFile = Theme.applyThemeFile(new File(ApplicationLoader.getFilesDirFixed(), "remote" + this.loadingTheme.id + ".attheme"), this.loadingTheme.title, this.loadingTheme, true);
        if (applyThemeFile != null) {
            lambda$runLinkRequest$28$LaunchActivity(new ThemePreviewActivity(applyThemeFile, true, 0, false));
        }
        onThemeLoadFinish();
    }

    private boolean isExistMainActivity(Class<?> cls) {
        return ApplicationLoader.mbytAVideoCallBusy == 1;
    }

    public String getStringForLanguageAlert(HashMap<String, String> hashMap, String str, int i) {
        String str2 = hashMap.get(str);
        return str2 == null ? LocaleController.getString(str, i) : str2;
    }

    private void onThemeLoadFinish() {
        AlertDialog alertDialog = this.loadingThemeProgressDialog;
        if (alertDialog != null) {
            try {
                alertDialog.dismiss();
            } finally {
                this.loadingThemeProgressDialog = null;
            }
        }
        this.loadingThemeWallpaperName = null;
        this.loadingThemeInfo = null;
        this.loadingThemeFileName = null;
        this.loadingTheme = null;
    }

    private void checkFreeDiscSpace() {
        SharedConfig.checkKeepMedia();
        if (Build.VERSION.SDK_INT >= 26) {
            return;
        }
        Utilities.globalQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$checkFreeDiscSpace$56$LaunchActivity();
            }
        }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
    }

    public void lambda$checkFreeDiscSpace$56$LaunchActivity() {
        File directory;
        long blockSizeLong;
        if (UserConfig.getInstance(this.currentAccount).isClientActivated()) {
            try {
                SharedPreferences globalMainSettings = MessagesController.getGlobalMainSettings();
                if (Math.abs(globalMainSettings.getLong("last_space_check", 0L) - System.currentTimeMillis()) < 259200000 || (directory = FileLoader.getDirectory(4)) == null) {
                    return;
                }
                StatFs statFs = new StatFs(directory.getAbsolutePath());
                if (Build.VERSION.SDK_INT < 18) {
                    blockSizeLong = Math.abs(statFs.getAvailableBlocks() * statFs.getBlockSize());
                } else {
                    blockSizeLong = statFs.getBlockSizeLong() * statFs.getAvailableBlocksLong();
                }
                if (blockSizeLong < 104857600) {
                    globalMainSettings.edit().putLong("last_space_check", System.currentTimeMillis()).commit();
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            LaunchActivity.this.lambda$null$55$LaunchActivity();
                        }
                    });
                }
            } catch (Throwable unused) {
            }
        }
    }

    public void lambda$null$55$LaunchActivity() {
        try {
            AlertsCreator.createFreeSpaceDialog(this).show();
        } catch (Throwable unused) {
        }
    }

    private void showLanguageAlertInternal(LocaleController.LocaleInfo localeInfo, LocaleController.LocaleInfo localeInfo2, String str) {
        boolean z;
        int i;
        try {
            this.loadingLocaleDialog = false;
            LocaleController.LocaleInfo localeInfo3 = localeInfo;
            if (!localeInfo3.builtIn && !LocaleController.getInstance().isCurrentLocalLocale()) {
                z = false;
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(getStringForLanguageAlert(this.systemLocaleStrings, "ChooseYourLanguage", R.string.ChooseYourLanguage));
                builder.setSubtitle(getStringForLanguageAlert(this.englishLocaleStrings, "ChooseYourLanguage", R.string.ChooseYourLanguage));
                LinearLayout linearLayout = new LinearLayout(this);
                linearLayout.setOrientation(1);
                final LanguageCell[] languageCellArr = new LanguageCell[2];
                final LocaleController.LocaleInfo[] localeInfoArr = new LocaleController.LocaleInfo[1];
                LocaleController.LocaleInfo[] localeInfoArr2 = new LocaleController.LocaleInfo[2];
                String stringForLanguageAlert = getStringForLanguageAlert(this.systemLocaleStrings, "English", R.string.English);
                localeInfoArr2[0] = !z ? localeInfo3 : localeInfo2;
                localeInfoArr2[1] = !z ? localeInfo2 : localeInfo3;
                if (z) {
                    localeInfo3 = localeInfo2;
                }
                localeInfoArr[0] = localeInfo3;
                i = 0;
                while (i < 2) {
                    languageCellArr[i] = new LanguageCell(this, true);
                    languageCellArr[i].setLanguage(localeInfoArr2[i], localeInfoArr2[i] == localeInfo2 ? stringForLanguageAlert : null, true);
                    languageCellArr[i].setTag(Integer.valueOf(i));
                    languageCellArr[i].setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 2));
                    languageCellArr[i].setLanguageSelected(i == 0);
                    linearLayout.addView(languageCellArr[i], LayoutHelper.createLinear(-1, 50));
                    languageCellArr[i].setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view) {
                            LaunchActivity.lambda$showLanguageAlertInternal$57(localeInfoArr, languageCellArr, view);
                        }
                    });
                    i++;
                }
                LanguageCell languageCell = new LanguageCell(this, true);
                languageCell.setValue(getStringForLanguageAlert(this.systemLocaleStrings, "ChooseYourLanguageOther", R.string.ChooseYourLanguageOther), getStringForLanguageAlert(this.englishLocaleStrings, "ChooseYourLanguageOther", R.string.ChooseYourLanguageOther));
                languageCell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        LaunchActivity.this.lambda$showLanguageAlertInternal$58$LaunchActivity(view);
                    }
                });
                linearLayout.addView(languageCell, LayoutHelper.createLinear(-1, 50));
                builder.setView(linearLayout);
                builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i2) {
                        LaunchActivity.this.lambda$showLanguageAlertInternal$59$LaunchActivity(localeInfoArr, dialogInterface, i2);
                    }
                });
                this.localeDialog = showAlertDialog(builder);
                MessagesController.getGlobalMainSettings().edit().putString("language_showed2", str).commit();
            }
            z = true;
            AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
            builder2.setTitle(getStringForLanguageAlert(this.systemLocaleStrings, "ChooseYourLanguage", R.string.ChooseYourLanguage));
            builder2.setSubtitle(getStringForLanguageAlert(this.englishLocaleStrings, "ChooseYourLanguage", R.string.ChooseYourLanguage));
            LinearLayout linearLayout2 = new LinearLayout(this);
            linearLayout2.setOrientation(1);
            final LanguageCell[] languageCellArr2 = new LanguageCell[2];
            final LocaleController.LocaleInfo[] localeInfoArr3 = new LocaleController.LocaleInfo[1];
            LocaleController.LocaleInfo[] localeInfoArr22 = new LocaleController.LocaleInfo[2];
            String stringForLanguageAlert2 = getStringForLanguageAlert(this.systemLocaleStrings, "English", R.string.English);
            localeInfoArr22[0] = !z ? localeInfo3 : localeInfo2;
            localeInfoArr22[1] = !z ? localeInfo2 : localeInfo3;
            if (z) {
            }
            localeInfoArr3[0] = localeInfo3;
            i = 0;
            while (i < 2) {
            }
            LanguageCell languageCell2 = new LanguageCell(this, true);
            languageCell2.setValue(getStringForLanguageAlert(this.systemLocaleStrings, "ChooseYourLanguageOther", R.string.ChooseYourLanguageOther), getStringForLanguageAlert(this.englishLocaleStrings, "ChooseYourLanguageOther", R.string.ChooseYourLanguageOther));
            languageCell2.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    LaunchActivity.this.lambda$showLanguageAlertInternal$58$LaunchActivity(view);
                }
            });
            linearLayout2.addView(languageCell2, LayoutHelper.createLinear(-1, 50));
            builder2.setView(linearLayout2);
            builder2.setNegativeButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i2) {
                    LaunchActivity.this.lambda$showLanguageAlertInternal$59$LaunchActivity(localeInfoArr3, dialogInterface, i2);
                }
            });
            this.localeDialog = showAlertDialog(builder2);
            MessagesController.getGlobalMainSettings().edit().putString("language_showed2", str).commit();
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public static void lambda$showLanguageAlertInternal$57(LocaleController.LocaleInfo[] localeInfoArr, LanguageCell[] languageCellArr, View view) {
        Integer num = (Integer) view.getTag();
        localeInfoArr[0] = ((LanguageCell) view).getCurrentLocale();
        int i = 0;
        while (i < languageCellArr.length) {
            languageCellArr[i].setLanguageSelected(i == num.intValue());
            i++;
        }
    }

    public void lambda$showLanguageAlertInternal$58$LaunchActivity(View view) {
        this.localeDialog = null;
        this.drawerLayoutContainer.closeDrawer(true);
        lambda$runLinkRequest$28$LaunchActivity(new LanguageSelectActivity());
        AlertDialog alertDialog = this.visibleDialog;
        if (alertDialog != null) {
            alertDialog.dismiss();
            this.visibleDialog = null;
        }
    }

    public void lambda$showLanguageAlertInternal$59$LaunchActivity(LocaleController.LocaleInfo[] localeInfoArr, DialogInterface dialogInterface, int i) {
        LocaleController.getInstance().applyLanguage(localeInfoArr[0], true, false, this.currentAccount);
        rebuildAllFragments(true);
    }

    private void showLanguageAlert(boolean z) {
        String str;
        try {
            if (!this.loadingLocaleDialog && !ApplicationLoader.mainInterfacePaused) {
                String string = MessagesController.getGlobalMainSettings().getString("language_showed2", "");
                final String str2 = MessagesController.getInstance(this.currentAccount).suggestedLangCode;
                if (!z && string.equals(str2)) {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("alert already showed for " + string);
                        return;
                    }
                    return;
                }
                final LocaleController.LocaleInfo[] localeInfoArr = new LocaleController.LocaleInfo[2];
                String str3 = str2.contains("-") ? str2.split("-")[0] : str2;
                if ("in".equals(str3)) {
                    str = TtmlNode.ATTR_ID;
                } else if ("iw".equals(str3)) {
                    str = "he";
                } else {
                    str = "jw".equals(str3) ? "jv" : null;
                }
                for (int i = 0; i < LocaleController.getInstance().languages.size(); i++) {
                    LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().languages.get(i);
                    if (localeInfo.shortName.equals("en")) {
                        localeInfoArr[0] = localeInfo;
                    }
                    if (localeInfo.shortName.replace("_", "-").equals(str2) || localeInfo.shortName.equals(str3) || localeInfo.shortName.equals(str)) {
                        localeInfoArr[1] = localeInfo;
                    }
                    if (localeInfoArr[0] != null && localeInfoArr[1] != null) {
                        break;
                    }
                }
                if (localeInfoArr[0] != null && localeInfoArr[1] != null && localeInfoArr[0] != localeInfoArr[1]) {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.d("show lang alert for " + localeInfoArr[0].getKey() + " and " + localeInfoArr[1].getKey());
                    }
                    this.systemLocaleStrings = null;
                    this.englishLocaleStrings = null;
                    this.loadingLocaleDialog = true;
                    TLRPC.TL_langpack_getStrings tL_langpack_getStrings = new TLRPC.TL_langpack_getStrings();
                    tL_langpack_getStrings.lang_code = localeInfoArr[1].getLangCode();
                    tL_langpack_getStrings.keys.add("English");
                    tL_langpack_getStrings.keys.add("ChooseYourLanguage");
                    tL_langpack_getStrings.keys.add("ChooseYourLanguageOther");
                    tL_langpack_getStrings.keys.add("ChangeLanguageLater");
                    ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_langpack_getStrings, new RequestDelegate() {
                        @Override
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            LaunchActivity.this.lambda$showLanguageAlert$61$LaunchActivity(localeInfoArr, str2, tLObject, tL_error);
                        }
                    }, 8);
                    TLRPC.TL_langpack_getStrings tL_langpack_getStrings2 = new TLRPC.TL_langpack_getStrings();
                    tL_langpack_getStrings2.lang_code = localeInfoArr[0].getLangCode();
                    tL_langpack_getStrings2.keys.add("English");
                    tL_langpack_getStrings2.keys.add("ChooseYourLanguage");
                    tL_langpack_getStrings2.keys.add("ChooseYourLanguageOther");
                    tL_langpack_getStrings2.keys.add("ChangeLanguageLater");
                    ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_langpack_getStrings2, new RequestDelegate() {
                        @Override
                        public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                            LaunchActivity.this.lambda$showLanguageAlert$63$LaunchActivity(localeInfoArr, str2, tLObject, tL_error);
                        }
                    }, 8);
                }
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void lambda$showLanguageAlert$61$LaunchActivity(final LocaleController.LocaleInfo[] localeInfoArr, final String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        final HashMap hashMap = new HashMap();
        if (tLObject != null) {
            TLRPC.Vector vector = (TLRPC.Vector) tLObject;
            for (int i = 0; i < vector.objects.size(); i++) {
                TLRPC.LangPackString langPackString = (TLRPC.LangPackString) vector.objects.get(i);
                hashMap.put(langPackString.key, langPackString.value);
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$60$LaunchActivity(hashMap, localeInfoArr, str);
            }
        });
    }

    public void lambda$null$60$LaunchActivity(HashMap hashMap, LocaleController.LocaleInfo[] localeInfoArr, String str) {
        this.systemLocaleStrings = hashMap;
        if (this.englishLocaleStrings == null || hashMap == null) {
            return;
        }
        showLanguageAlertInternal(localeInfoArr[1], localeInfoArr[0], str);
    }

    public void lambda$showLanguageAlert$63$LaunchActivity(final LocaleController.LocaleInfo[] localeInfoArr, final String str, TLObject tLObject, TLRPC.TL_error tL_error) {
        final HashMap hashMap = new HashMap();
        if (tLObject != null) {
            TLRPC.Vector vector = (TLRPC.Vector) tLObject;
            for (int i = 0; i < vector.objects.size(); i++) {
                TLRPC.LangPackString langPackString = (TLRPC.LangPackString) vector.objects.get(i);
                hashMap.put(langPackString.key, langPackString.value);
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.lambda$null$62$LaunchActivity(hashMap, localeInfoArr, str);
            }
        });
    }

    public void lambda$null$62$LaunchActivity(HashMap hashMap, LocaleController.LocaleInfo[] localeInfoArr, String str) {
        this.englishLocaleStrings = hashMap;
        if (hashMap == null || this.systemLocaleStrings == null) {
            return;
        }
        showLanguageAlertInternal(localeInfoArr[1], localeInfoArr[0], str);
    }

    private void onPasscodePause() {
        Runnable runnable = this.lockRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
            this.lockRunnable = null;
        }
        if (SharedConfig.passcodeHash.length() != 0) {
            SharedConfig.lastPauseTime = ConnectionsManager.getInstance(this.currentAccount).getCurrentTime();
            this.lockRunnable = new Runnable() {
                @Override
                public void run() {
                    if (LaunchActivity.this.lockRunnable == this) {
                        if (AndroidUtilities.needShowPasscode(true)) {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.d("lock app");
                            }
                            LaunchActivity.this.showPasscodeActivity();
                        } else if (BuildVars.LOGS_ENABLED) {
                            FileLog.d("didn't pass lock check");
                        }
                        LaunchActivity.this.lockRunnable = null;
                    }
                }
            };
            if (SharedConfig.appLocked) {
                AndroidUtilities.runOnUIThread(this.lockRunnable, 1000L);
            } else if (SharedConfig.autoLockIn != 0) {
                AndroidUtilities.runOnUIThread(this.lockRunnable, (SharedConfig.autoLockIn * 1000) + 1000);
            }
        } else {
            SharedConfig.lastPauseTime = 0;
        }
        SharedConfig.saveConfig();
    }

    private void onPasscodeResume() {
        Runnable runnable = this.lockRunnable;
        if (runnable != null) {
            AndroidUtilities.cancelRunOnUIThread(runnable);
            this.lockRunnable = null;
        }
        if (AndroidUtilities.needShowPasscode(true)) {
            showPasscodeActivity();
        }
        if (SharedConfig.lastPauseTime != 0) {
            SharedConfig.lastPauseTime = 0;
            SharedConfig.saveConfig();
        }
    }

    private void updateCurrentConnectionState(int i) {
        String str;
        if (this.actionBarLayout == null) {
            return;
        }
        int i2 = 0;
        int connectionState = ConnectionsManager.getInstance(this.currentAccount).getConnectionState();
        this.currentConnectionState = connectionState;
        if (connectionState == 2) {
            i2 = R.string.WaitingForNetwork;
            str = "WaitingForNetwork";
        } else if (connectionState == 5) {
            i2 = R.string.Updating;
            str = "Updating";
        } else if (connectionState == 4) {
            i2 = R.string.ConnectingToProxy;
            str = "ConnectingToProxy";
        } else if (connectionState == 1) {
            i2 = R.string.Connecting;
            str = "Connecting";
        } else {
            str = null;
        }
        int i3 = this.currentConnectionState;
        this.actionBarLayout.setTitleOverlayText(str, i2, (i3 == 1 || i3 == 4) ? new Runnable() {
            @Override
            public void run() {
                BaseFragment baseFragment;
                if (AndroidUtilities.isTablet()) {
                    if (!LaunchActivity.layerFragmentsStack.isEmpty()) {
                        baseFragment = (BaseFragment) LaunchActivity.layerFragmentsStack.get(LaunchActivity.layerFragmentsStack.size() - 1);
                    }
                    baseFragment = null;
                } else {
                    if (!LaunchActivity.mainFragmentsStack.isEmpty()) {
                        baseFragment = (BaseFragment) LaunchActivity.mainFragmentsStack.get(LaunchActivity.mainFragmentsStack.size() - 1);
                    }
                    baseFragment = null;
                }
                if ((baseFragment instanceof ProxyListActivity) || (baseFragment instanceof ProxySettingsActivity)) {
                }
            }
        } : null);
    }

    public void hideVisibleActionMode() {
        ActionMode actionMode = this.visibleActionMode;
        if (actionMode == null) {
            return;
        }
        actionMode.finish();
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        try {
            super.onSaveInstanceState(bundle);
            BaseFragment baseFragment = null;
            if (AndroidUtilities.isTablet()) {
                if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                    baseFragment = this.layersActionBarLayout.fragmentsStack.get(this.layersActionBarLayout.fragmentsStack.size() - 1);
                } else if (!this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                    baseFragment = this.rightActionBarLayout.fragmentsStack.get(this.rightActionBarLayout.fragmentsStack.size() - 1);
                } else if (!this.actionBarLayout.fragmentsStack.isEmpty()) {
                    baseFragment = this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1);
                }
            } else if (!this.actionBarLayout.fragmentsStack.isEmpty()) {
                baseFragment = this.actionBarLayout.fragmentsStack.get(this.actionBarLayout.fragmentsStack.size() - 1);
            }
            if (baseFragment != null) {
                Bundle arguments = baseFragment.getArguments();
                if ((baseFragment instanceof ChatActivity) && arguments != null) {
                    bundle.putBundle("args", arguments);
                    bundle.putString("fragment", "chat");
                } else if (baseFragment instanceof SettingsActivity) {
                    bundle.putString("fragment", "settings");
                } else if ((baseFragment instanceof GroupCreateFinalActivity) && arguments != null) {
                    bundle.putBundle("args", arguments);
                    bundle.putString("fragment", "group");
                } else if (baseFragment instanceof WallpapersListActivity) {
                    bundle.putString("fragment", "wallpapers");
                } else if ((baseFragment instanceof ProfileActivity) && ((ProfileActivity) baseFragment).isChat() && arguments != null) {
                    bundle.putBundle("args", arguments);
                    bundle.putString("fragment", "chat_profile");
                } else if ((baseFragment instanceof ChannelCreateActivity) && arguments != null && arguments.getInt("step") == 0) {
                    bundle.putBundle("args", arguments);
                    bundle.putString("fragment", "channel");
                }
                baseFragment.saveSelfArgs(bundle);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    @Override
    public void onBackPressed() {
        if (this.passcodeView.getVisibility() == 0) {
            finish();
            return;
        }
        boolean z = false;
        if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
            SecretMediaViewer.getInstance().closePhoto(true, false);
            return;
        }
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().closePhoto(true, false);
            return;
        }
        if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
            ArticleViewer.getInstance().close(true, false);
            return;
        }
        if (this.drawerLayoutContainer.isDrawerOpened()) {
            this.drawerLayoutContainer.closeDrawer(false);
            return;
        }
        if (AndroidUtilities.isTablet()) {
            if (this.layersActionBarLayout.getVisibility() == 0) {
                this.layersActionBarLayout.onBackPressed();
                return;
            }
            if (this.rightActionBarLayout.getVisibility() == 0 && !this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                z = !this.rightActionBarLayout.fragmentsStack.get(this.rightActionBarLayout.fragmentsStack.size() - 1).onBackPressed();
            }
            if (z) {
                return;
            }
            this.actionBarLayout.onBackPressed();
            return;
        }
        this.actionBarLayout.onBackPressed();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        this.actionBarLayout.onLowMemory();
        if (AndroidUtilities.isTablet()) {
            this.rightActionBarLayout.onLowMemory();
            this.layersActionBarLayout.onLowMemory();
        }
    }

    @Override
    public void onActionModeStarted(ActionMode actionMode) {
        super.onActionModeStarted(actionMode);
        this.visibleActionMode = actionMode;
        try {
            Menu menu = actionMode.getMenu();
            if (menu != null && !this.actionBarLayout.extendActionMode(menu) && AndroidUtilities.isTablet() && !this.rightActionBarLayout.extendActionMode(menu)) {
                this.layersActionBarLayout.extendActionMode(menu);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        if (Build.VERSION.SDK_INT < 23 || actionMode.getType() != 1) {
            this.actionBarLayout.onActionModeStarted(actionMode);
            if (AndroidUtilities.isTablet()) {
                this.rightActionBarLayout.onActionModeStarted(actionMode);
                this.layersActionBarLayout.onActionModeStarted(actionMode);
            }
        }
    }

    @Override
    public void onActionModeFinished(ActionMode actionMode) {
        super.onActionModeFinished(actionMode);
        if (this.visibleActionMode == actionMode) {
            this.visibleActionMode = null;
        }
        if (Build.VERSION.SDK_INT < 23 || actionMode.getType() != 1) {
            this.actionBarLayout.onActionModeFinished(actionMode);
            if (AndroidUtilities.isTablet()) {
                this.rightActionBarLayout.onActionModeFinished(actionMode);
                this.layersActionBarLayout.onActionModeFinished(actionMode);
            }
        }
    }

    @Override
    public boolean onPreIme() {
        if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
            SecretMediaViewer.getInstance().closePhoto(true, false);
            return true;
        }
        if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
            PhotoViewer.getInstance().closePhoto(true, false);
            return true;
        }
        if (!ArticleViewer.hasInstance() || !ArticleViewer.getInstance().isVisible()) {
            return false;
        }
        ArticleViewer.getInstance().close(true, false);
        return true;
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        keyEvent.getKeyCode();
        if (!mainFragmentsStack.isEmpty() && ((!PhotoViewer.hasInstance() || !PhotoViewer.getInstance().isVisible()) && keyEvent.getRepeatCount() == 0 && keyEvent.getAction() == 0 && (keyEvent.getKeyCode() == 24 || keyEvent.getKeyCode() == 25))) {
            ArrayList<BaseFragment> arrayList = mainFragmentsStack;
            BaseFragment baseFragment = arrayList.get(arrayList.size() - 1);
            if ((baseFragment instanceof ChatActivity) && ((ChatActivity) baseFragment).maybePlayVisibleVideo()) {
                return true;
            }
            if (AndroidUtilities.isTablet() && !rightFragmentsStack.isEmpty()) {
                ArrayList<BaseFragment> arrayList2 = rightFragmentsStack;
                BaseFragment baseFragment2 = arrayList2.get(arrayList2.size() - 1);
                if ((baseFragment2 instanceof ChatActivity) && ((ChatActivity) baseFragment2).maybePlayVisibleVideo()) {
                    return true;
                }
            }
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    @Override
    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        if (i == 82 && !SharedConfig.isWaitingForPasscodeEnter) {
            if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
                return super.onKeyUp(i, keyEvent);
            }
            if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
                return super.onKeyUp(i, keyEvent);
            }
            if (AndroidUtilities.isTablet()) {
                if (this.layersActionBarLayout.getVisibility() == 0 && !this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                    this.layersActionBarLayout.onKeyUp(i, keyEvent);
                } else if (this.rightActionBarLayout.getVisibility() == 0 && !this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                    this.rightActionBarLayout.onKeyUp(i, keyEvent);
                } else {
                    this.actionBarLayout.onKeyUp(i, keyEvent);
                }
            } else if (this.actionBarLayout.fragmentsStack.size() == 1) {
                if (!this.drawerLayoutContainer.isDrawerOpened()) {
                    if (getCurrentFocus() != null) {
                        AndroidUtilities.hideKeyboard(getCurrentFocus());
                    }
                    this.drawerLayoutContainer.openDrawer(false);
                } else {
                    this.drawerLayoutContainer.closeDrawer(false);
                }
            } else {
                this.actionBarLayout.onKeyUp(i, keyEvent);
            }
        }
        if (i == 4 && keyEvent.getAction() == 1 && ApplicationLoader.mbytLiving == 1 && this.actionBarLayout.fragmentsStack.size() == 1 && (this.actionBarLayout.fragmentsStack.get(0) instanceof IndexActivity)) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage("您正在直播中,确定要退出吗?");
            builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i2) {
                    LaunchActivity.this.lambda$onKeyUp$64$LaunchActivity(dialogInterface, i2);
                }
            });
            builder.setPositiveButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showAlertDialog(builder);
            return true;
        }
        return super.onKeyUp(i, keyEvent);
    }

    public void lambda$onKeyUp$64$LaunchActivity(DialogInterface dialogInterface, int i) {
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.livefinishnotify, new Object[0]);
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                LaunchActivity.this.finish();
            }
        }, 1000L);
    }

    @Override
    public boolean needPresentFragment(BaseFragment baseFragment, boolean z, boolean z2, ActionBarLayout actionBarLayout) {
        ActionBarLayout actionBarLayout2;
        ActionBarLayout actionBarLayout3;
        ActionBarLayout actionBarLayout4;
        if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
            ArticleViewer.getInstance().close(false, true);
        }
        if (AndroidUtilities.isTablet()) {
            this.drawerLayoutContainer.setAllowOpenDrawer(false, true);
            if (baseFragment instanceof IndexActivity) {
                ActionBarLayout actionBarLayout5 = this.actionBarLayout;
                if (actionBarLayout != actionBarLayout5) {
                    actionBarLayout5.removeAllFragments();
                    this.actionBarLayout.presentFragment(baseFragment, z, z2, false, false);
                    this.layersActionBarLayout.removeAllFragments();
                    this.layersActionBarLayout.setVisibility(8);
                    this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    if (!this.tabletFullSize) {
                        this.shadowTabletSide.setVisibility(0);
                        if (this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                            this.backgroundTablet.setVisibility(0);
                        }
                    }
                    return false;
                }
            }
            if ((baseFragment instanceof ChatActivity) && !((ChatActivity) baseFragment).isInScheduleMode()) {
                if ((!this.tabletFullSize && actionBarLayout == this.rightActionBarLayout) || (this.tabletFullSize && actionBarLayout == this.actionBarLayout)) {
                    boolean z3 = (this.tabletFullSize && actionBarLayout == (actionBarLayout4 = this.actionBarLayout) && actionBarLayout4.fragmentsStack.size() == 1) ? false : true;
                    if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                        while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                            ActionBarLayout actionBarLayout6 = this.layersActionBarLayout;
                            actionBarLayout6.removeFragmentFromStack(actionBarLayout6.fragmentsStack.get(0));
                        }
                        this.layersActionBarLayout.closeLastFragment(!z2);
                    }
                    if (!z3) {
                        this.actionBarLayout.presentFragment(baseFragment, false, z2, false, false);
                    }
                    return z3;
                }
                if (!this.tabletFullSize && actionBarLayout != (actionBarLayout3 = this.rightActionBarLayout)) {
                    actionBarLayout3.setVisibility(0);
                    this.backgroundTablet.setVisibility(8);
                    this.rightActionBarLayout.removeAllFragments();
                    this.rightActionBarLayout.presentFragment(baseFragment, z, true, false, false);
                    if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                        while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                            ActionBarLayout actionBarLayout7 = this.layersActionBarLayout;
                            actionBarLayout7.removeFragmentFromStack(actionBarLayout7.fragmentsStack.get(0));
                        }
                        this.layersActionBarLayout.closeLastFragment(!z2);
                    }
                    return false;
                }
                if (this.tabletFullSize && actionBarLayout != (actionBarLayout2 = this.actionBarLayout)) {
                    actionBarLayout2.presentFragment(baseFragment, actionBarLayout2.fragmentsStack.size() > 1, z2, false, false);
                    if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                        while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                            ActionBarLayout actionBarLayout8 = this.layersActionBarLayout;
                            actionBarLayout8.removeFragmentFromStack(actionBarLayout8.fragmentsStack.get(0));
                        }
                        this.layersActionBarLayout.closeLastFragment(!z2);
                    }
                    return false;
                }
                if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                    while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                        ActionBarLayout actionBarLayout9 = this.layersActionBarLayout;
                        actionBarLayout9.removeFragmentFromStack(actionBarLayout9.fragmentsStack.get(0));
                    }
                    this.layersActionBarLayout.closeLastFragment(!z2);
                }
                ActionBarLayout actionBarLayout10 = this.actionBarLayout;
                actionBarLayout10.presentFragment(baseFragment, actionBarLayout10.fragmentsStack.size() > 1, z2, false, false);
                return false;
            }
            ActionBarLayout actionBarLayout11 = this.layersActionBarLayout;
            if (actionBarLayout == actionBarLayout11) {
                return true;
            }
            actionBarLayout11.setVisibility(0);
            this.drawerLayoutContainer.setAllowOpenDrawer(false, true);
            if (baseFragment instanceof LoginContronllerActivity) {
                this.backgroundTablet.setVisibility(0);
                this.shadowTabletSide.setVisibility(8);
                this.shadowTablet.setBackgroundColor(0);
            } else {
                this.shadowTablet.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
            }
            this.layersActionBarLayout.presentFragment(baseFragment, z, z2, false, false);
            return false;
        }
        if (baseFragment instanceof LoginContronllerActivity) {
            mainFragmentsStack.size();
        } else if (baseFragment instanceof CountrySelectActivity) {
            mainFragmentsStack.size();
        }
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        return true;
    }

    @Override
    public boolean needAddFragmentToStack(BaseFragment baseFragment, ActionBarLayout actionBarLayout) {
        ActionBarLayout actionBarLayout2;
        ActionBarLayout actionBarLayout3;
        if (AndroidUtilities.isTablet()) {
            this.drawerLayoutContainer.setAllowOpenDrawer(false, true);
            if (baseFragment instanceof IndexActivity) {
                ActionBarLayout actionBarLayout4 = this.actionBarLayout;
                if (actionBarLayout != actionBarLayout4) {
                    actionBarLayout4.removeAllFragments();
                    this.actionBarLayout.addFragmentToStack(baseFragment);
                    this.layersActionBarLayout.removeAllFragments();
                    this.layersActionBarLayout.setVisibility(8);
                    this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    if (!this.tabletFullSize) {
                        this.shadowTabletSide.setVisibility(0);
                        if (this.rightActionBarLayout.fragmentsStack.isEmpty()) {
                            this.backgroundTablet.setVisibility(0);
                        }
                    }
                    return false;
                }
            } else if ((baseFragment instanceof ChatActivity) && !((ChatActivity) baseFragment).isInScheduleMode()) {
                if (!this.tabletFullSize && actionBarLayout != (actionBarLayout3 = this.rightActionBarLayout)) {
                    actionBarLayout3.setVisibility(0);
                    this.backgroundTablet.setVisibility(8);
                    this.rightActionBarLayout.removeAllFragments();
                    this.rightActionBarLayout.addFragmentToStack(baseFragment);
                    if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                        while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                            ActionBarLayout actionBarLayout5 = this.layersActionBarLayout;
                            actionBarLayout5.removeFragmentFromStack(actionBarLayout5.fragmentsStack.get(0));
                        }
                        this.layersActionBarLayout.closeLastFragment(true);
                    }
                    return false;
                }
                if (this.tabletFullSize && actionBarLayout != (actionBarLayout2 = this.actionBarLayout)) {
                    actionBarLayout2.addFragmentToStack(baseFragment);
                    if (!this.layersActionBarLayout.fragmentsStack.isEmpty()) {
                        while (this.layersActionBarLayout.fragmentsStack.size() - 1 > 0) {
                            ActionBarLayout actionBarLayout6 = this.layersActionBarLayout;
                            actionBarLayout6.removeFragmentFromStack(actionBarLayout6.fragmentsStack.get(0));
                        }
                        this.layersActionBarLayout.closeLastFragment(true);
                    }
                    return false;
                }
            } else {
                ActionBarLayout actionBarLayout7 = this.layersActionBarLayout;
                if (actionBarLayout != actionBarLayout7) {
                    actionBarLayout7.setVisibility(0);
                    this.drawerLayoutContainer.setAllowOpenDrawer(false, true);
                    if (baseFragment instanceof LoginContronllerActivity) {
                        this.backgroundTablet.setVisibility(0);
                        this.shadowTabletSide.setVisibility(8);
                        this.shadowTablet.setBackgroundColor(0);
                    } else {
                        this.shadowTablet.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
                    }
                    this.layersActionBarLayout.addFragmentToStack(baseFragment);
                    return false;
                }
            }
            return true;
        }
        if (baseFragment instanceof LoginContronllerActivity) {
            mainFragmentsStack.size();
        } else if (baseFragment instanceof CountrySelectActivity) {
            mainFragmentsStack.size();
        }
        this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
        return true;
    }

    @Override
    public boolean needCloseLastFragment(ActionBarLayout actionBarLayout) {
        if (AndroidUtilities.isTablet()) {
            if (actionBarLayout == this.actionBarLayout && actionBarLayout.fragmentsStack.size() <= 1) {
                onFinish();
                finish();
                return false;
            }
            if (actionBarLayout == this.rightActionBarLayout) {
                if (!this.tabletFullSize) {
                    this.backgroundTablet.setVisibility(0);
                }
            } else if (actionBarLayout == this.layersActionBarLayout && this.actionBarLayout.fragmentsStack.isEmpty() && this.layersActionBarLayout.fragmentsStack.size() == 1) {
                onFinish();
                finish();
                return false;
            }
        } else {
            if (actionBarLayout.fragmentsStack.size() <= 1) {
                onFinish();
                finish();
                return false;
            }
            if (actionBarLayout.fragmentsStack.size() >= 2 && !(actionBarLayout.fragmentsStack.get(0) instanceof LoginContronllerActivity)) {
                this.drawerLayoutContainer.setAllowOpenDrawer(false, false);
            }
        }
        return true;
    }

    public void rebuildAllFragments(boolean z) {
        ActionBarLayout actionBarLayout = this.layersActionBarLayout;
        if (actionBarLayout != null) {
            actionBarLayout.rebuildAllFragmentViews(z, z);
        } else {
            this.actionBarLayout.rebuildAllFragmentViews(z, z);
        }
    }

    @Override
    public void onRebuildAllFragments(ActionBarLayout actionBarLayout, boolean z) {
        if (AndroidUtilities.isTablet() && actionBarLayout == this.layersActionBarLayout) {
            this.rightActionBarLayout.rebuildAllFragmentViews(z, z);
            this.actionBarLayout.rebuildAllFragmentViews(z, z);
        }
        this.drawerLayoutAdapter.notifyDataSetChanged();
    }

    private void createGamePlayingFloatingView() {
        if (this.drawerLayoutContainer == null) {
            return;
        }
        DiscoveryJumpPausedFloatingView.getInstance().setContext(this).setRootViewContainer(this.drawerLayoutContainer).setActionBarLayout(this.actionBarLayout).show(true);
    }
}