导航菜单

页面标题

页面副标题

Adobe Acrobat v15.3 - ARViewerActivity.java 源代码

正在查看: Adobe Acrobat v15.3 应用的 ARViewerActivity.java JAVA 源代码文件

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


package com.adobe.reader.viewer;

import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.MailTo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.content.FileProvider;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewCompat;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SearchView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.a.a.a.a;
import com.adobe.libs.buildingblocks.utils.BBFileUtils;
import com.adobe.libs.buildingblocks.utils.e;
import com.adobe.libs.buildingblocks.utils.f;
import com.adobe.libs.buildingblocks.utils.m;
import com.adobe.libs.pdfviewer.PVApp;
import com.adobe.libs.services.a.g;
import com.adobe.libs.services.a.j;
import com.adobe.libs.services.h.d;
import com.adobe.libs.services.h.n;
import com.adobe.libs.signature.a.c;
import com.adobe.reader.R;
import com.adobe.reader.analytics.ARDCMAnalytics;
import com.adobe.reader.attachments.ARAttachments;
import com.adobe.reader.attachments.ARPortfolio;
import com.adobe.reader.attachments.ARPortfolioStack;
import com.adobe.reader.attachments.ARPortfolioStackEntry;
import com.adobe.reader.attachments.ARPortfolioViewManager;
import com.adobe.reader.bookmarks.ARBookmarkManager;
import com.adobe.reader.comments.ARCommentAuthorDialog;
import com.adobe.reader.comments.ARCommentPopupHandler;
import com.adobe.reader.comments.ARCommentsManager;
import com.adobe.reader.comments.ARCommentsToolbar;
import com.adobe.reader.comments.ARFreetextCommentHandler;
import com.adobe.reader.comments.ARInkActionBar;
import com.adobe.reader.comments.ARInkCommentHandler;
import com.adobe.reader.comments.ARInkSignatureHandler;
import com.adobe.reader.config.ARConfig;
import com.adobe.reader.config.ARConstants;
import com.adobe.reader.config.PageID;
import com.adobe.reader.core.ARDocLoaderManager;
import com.adobe.reader.core.ARDocViewManager;
import com.adobe.reader.core.ARUIRunnable;
import com.adobe.reader.emm.AREMMManager;
import com.adobe.reader.filebrowser.ARFileBrowserUtils;
import com.adobe.reader.filebrowser.ARFileEntry;
import com.adobe.reader.filebrowser.Recents.ARRFEDelayedQueueManager;
import com.adobe.reader.filebrowser.Recents.ARRecentsFileDBManager;
import com.adobe.reader.filebrowser.Recents.ARRecentsFilesManager;
import com.adobe.reader.fillandsign.ARFillAndSignFragment;
import com.adobe.reader.fillandsign.ARFillAndSignToolbar;
import com.adobe.reader.fillandsign.ARFillAndSignUtils;
import com.adobe.reader.forms.ARWidgetToolbars;
import com.adobe.reader.framework.ui.FWBaseSwitcherActivity;
import com.adobe.reader.framework.ui.FWSwitcherEntry;
import com.adobe.reader.misc.ARAlert;
import com.adobe.reader.misc.ARApp;
import com.adobe.reader.misc.ARFileTransferActivity;
import com.adobe.reader.misc.ARGotoPageDialog;
import com.adobe.reader.misc.ARLastViewedPosition;
import com.adobe.reader.misc.ARSettingsActivity;
import com.adobe.reader.pagemanipulation.AROrganizePagesFragment;
import com.adobe.reader.search.ARTextFinder;
import com.adobe.reader.security.ARLCRMDialog;
import com.adobe.reader.security.ARPasswordDialog;
import com.adobe.reader.security.ARSecurityManager;
import com.adobe.reader.services.ARBlueHeronFileTransferActivity;
import com.adobe.reader.services.ARFileTransferService;
import com.adobe.reader.services.AROutboxFileEntry;
import com.adobe.reader.services.AROutboxTransferManager;
import com.adobe.reader.services.ARUserAccountsActivity;
import com.adobe.reader.services.blueheron.ARBlueHeronFileShareHandler;
import com.adobe.reader.services.blueheron.ARBlueHeronMD5CheckAsyncTask;
import com.adobe.reader.services.blueheron.ARBlueHeronMoveCacheAsyncTask;
import com.adobe.reader.services.blueheron.ARBlueHeronUpdateLastAccessAsyncTask;
import com.adobe.reader.services.blueheron.ARBlueHeronUpdateLastViewedPageIndexAsyncTask;
import com.adobe.reader.services.cpdf.ARCreatePDFFragment;
import com.adobe.reader.services.epdf.ARExportPDFFragment;
import com.adobe.reader.services.signature.ARSignatureServices;
import com.adobe.reader.ui.ARAppSwitcherEntryManager;
import com.adobe.reader.ui.ARBaseSwitcherActivity;
import com.adobe.reader.utils.ARUtils;
import java.io.File;
import java.lang.ref.WeakReference;
import java.net.URLDecoder;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;

public class ARViewerActivity extends ARBaseSwitcherActivity implements DialogInterface.OnDismissListener, SeekBar.OnSeekBarChangeListener, ARBaseSwitcherActivity.OptionsMenuHandler, ARBaseSwitcherActivity.OrganizePagesHandler {
    public static final int ARSEARCH_SNIPPET_REQUEST_CODE = 3;
    public static final int ARSETTINGS_ACTIVITY_REQUEST_CODE = 2;
    private static final int BOOKMARK_BUTTON_WIDTH = 45;
    public static final String BROADCAST_NEW_PDF_OPENED = "com.adobe.reader.viewer.ARViewerActivity.newPDFOpened";
    public static final String BROADCAST_SWITCH_TO_OUTBOX = "com.adobe.reader.ARViewer.switchToOutboxTab";
    public static final String CLOUD_CACHE_DEST_DIR = "com.adobe.reader.CloudCacheDestDir";
    public static final String CLOUD_CACHE_SRC_DIR = "com.adobe.reader.CloudCacheSrcDir";
    public static final int CROP_RESULT = 5;
    private static final int DISPLAY_PROGRESS_BAR = 1;
    private static final boolean DUMP_TRACE_INFO = false;
    public static final String EXTERNAL_CONTENT_DATA = "com.adobe.reader.ExternalContentData";
    private static final int FATAL_ERROR = 0;
    public static final String FILE_BROWSER_CLOUD_FILE_ID = "com.adobe.reader.CloudFileID";
    public static final String FILE_BROWSER_CLOUD_FILE_SOURCE = "com.adobe.reader.CloudFileSource";
    public static final String FILE_BROWSER_FILE_PATH = "com.adobe.reader.FileBrowserReturnData";
    public static final int FILE_SHARE_LINK_REQUEST_CODE = 4;
    public static final int FILE_TRANSFER_ACTIVITY_REQUEST_CODE = 1;
    private static final int FLIP_ANIMATION_DURATION = 200;
    private static final String HEADER_BCC = "bcc";
    private static final int HIDE_UI_ELEMS = 1;
    private static final int MIN_PAGES_FOR_SCRUBBER = 3;
    private static final int NON_FATAL_ERROR = 1;
    private static final int SCRUBBER_FLIP_ANIMATION_DURATION = 50;
    private static final String SCRUBBER_FTE_DISPLAYED = "scrubberFteDisplayed";
    private static final int SCRUBBER_MINIMUM_WIDTH = 300;
    private static final int SCRUBBER_WIDTH_MULTIPLIER_DIP = 30;
    private static final String TILE_CACHE_FOLDER_NAME = "tile_cache";
    private static final long UI_ELEMS_DURATION = 2000;
    public static final String VIEWER_LAUNCHED_FROM_OTHERS = "com.adobe.reader.ARViewer.viewerLaunchedFromOthers";
    public static boolean mIsPageFlipAutomation = false;
    private static final int mPosTimeOut = 1800000;
    private static final int mTimeOut = 1800000;
    private static ARViewerActivity sCurrentActivity;
    public static boolean sViewerLaunchedFromOthers;
    private ActionBar mActionBar;
    private Menu mActionBarMenu;
    private boolean mActivityStartedForResult;
    private boolean mAddDocPathToRecentlyViewed;
    private ARCommentAuthorDialog mAuthorDlg;
    private LinearLayout mBottomBarLayout;
    private ARBottomBar mBottomToolbar;
    private long mCloudLastSavedDocSize;
    private String mCloudSource;
    private ARCreatePDFFragment mCreatePDFFragment;
    private String mCurrentDocPath;
    private int mCurrentViewMode;
    private float mDPI;
    private ARDocLoaderManager mDocLoaderManager;
    public boolean mDocOpenedFromFileList;
    private ARDocumentManager mDocumentManager;
    private boolean mDontHideUIElements;
    private String mErrMsg;
    private String mErrString;
    private Fragment mExportPDFFragment;
    private ARBlueHeronFileShareHandler mFileLinkShareHandler;
    private ARFillAndSignFragment mFillAndSignFragment;
    private ARGotoPageDialog mGotoPageDlg;
    private boolean mHasAttachment;
    private boolean mHasPendingErr;
    private boolean mInInkDrawingMode;
    private boolean mInSignatureMode;
    private boolean mIsBackgroundThreadWaiting;
    private boolean mIsDisplayOn;
    private boolean mIsDocViewDrawnOnce;
    private boolean mIsFatalErr;
    private boolean mIsInDocumentViewMode;
    private boolean mIsInFormsMode;
    private boolean mIsSearchViewExpanded;
    private ARLCRMDialog mLCRMDlg;
    private ARBlueHeronMoveCacheAsyncTask mMoveTask;
    private boolean mNewDocumentOpened;
    private Toast mNonFatalErrorToast;
    private AROrganizePagesFragment mOrganizePagesFragment;
    private ARPasswordDialog mPasswdAlert;
    private a mPopoverView;
    private ARPortfolio mPortfolio;
    private String mPortfolioBrowserDirectory;
    private ARPortfolioStack mPortfolioStack;
    ClearPreviousPositionTask mPositionTask;
    Timer mPositionTimer;
    private Dialog mProgressDialog;
    private Handler mProgressDialogHandler;
    private ARAlert mReadOnlyDlg;
    Timer mScreenWakeTimer;
    private ImageButton mScrollButton;
    private SeekBar mScrubber;
    private boolean mScrubberChangedDirectly;
    private SearchView mSearchView;
    private String mSharedFilePath;
    private boolean mShowingUIElems;
    private String mTileCachePath;
    ReleaseScreenDimTimerTask mTimerTask;
    private Object mTouchExplorationStateChangeListener;
    private Thread mUIThread;
    private ARViewPager mViewPager;
    private BroadcastReceiver mBroadcastReceiverMD5MatchFound = new BroadcastReceiver() {
        static final boolean $assertionsDisabled;

        static {
            $assertionsDisabled = !ARViewerActivity.class.desiredAssertionStatus();
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle extras = intent.getExtras();
            String string = extras.getString(ARBlueHeronMD5CheckAsyncTask.FILE_PATH_USED_FOR_MATCH, ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
            String string2 = extras.getString(ARBlueHeronMD5CheckAsyncTask.MD5_MATCHED_ASSET, null);
            if (string2 == null) {
                if (!$assertionsDisabled) {
                    throw new AssertionError();
                }
            } else if (BBFileUtils.b(string, ARViewerActivity.this.mCurrentDocPath)) {
                String a2 = n.a(string2, BBFileUtils.a(string));
                if (!BBFileUtils.e(a2)) {
                    BBFileUtils.b(new File(ARViewerActivity.this.mCurrentDocPath), new File(a2));
                }
                ARViewerActivity.this.mMappedClass1File = ARViewerActivity.this.mCurrentDocPath;
                ARViewerActivity.this.onDocMovedToCloudInternal(a2, string2);
            }
        }
    };
    private BroadcastReceiver broadcastReceiver_updateUndoRedoState = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            ARViewerActivity.this.updateUndoRedoMenuItems();
        }
    };
    private BroadcastReceiver broadcastReceiver_userSignedOutFromMyAccounts = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            ARViewerActivity.this.closeCloudDocument();
        }
    };
    private BroadcastReceiver mBroadcastReceiverOnEMMRestrictionsChanged = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            ARViewerActivity.this.closeCloudDocument();
        }
    };
    private final UIElementsHandler mUIElemsHandler = new UIElementsHandler(this);
    private final HashSet<OnActivityResumeListener> mOnActivityResumeClients = new HashSet<>();
    private final Object mRunnableSyncObject = new Object();
    private Handler mUIHandler = new Handler();
    private double mMaxTileHeapLimit = 0.0d;
    private String mCloudFileID = null;
    private String mMappedClass1File = null;
    private int mSelectedTabLocationId = 1;
    PROGRESS_DIALOG_CONTEXT mProgressDialogContext = PROGRESS_DIALOG_CONTEXT.NO_CONTEXT;
    private boolean mIsTrackingSeekbar = false;
    private String mSearchText = ARFileEntry.DEFAULT_ENTRY_ICON_STRING;

    class AnonymousClass29 {
        static final int[] $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT;

        static {
            try {
                $SwitchMap$com$adobe$reader$filebrowser$Recents$ARRFEDelayedQueueManager$DELAYED_QUEUE_OPERATION_STATUS[ARRFEDelayedQueueManager.DELAYED_QUEUE_OPERATION_STATUS.COMPLETED.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                $SwitchMap$com$adobe$reader$filebrowser$Recents$ARRFEDelayedQueueManager$DELAYED_QUEUE_OPERATION_STATUS[ARRFEDelayedQueueManager.DELAYED_QUEUE_OPERATION_STATUS.IN_PROGRESS.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                $SwitchMap$com$adobe$reader$filebrowser$Recents$ARRFEDelayedQueueManager$DELAYED_QUEUE_OPERATION_STATUS[ARRFEDelayedQueueManager.DELAYED_QUEUE_OPERATION_STATUS.PENDING.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                $SwitchMap$com$adobe$reader$filebrowser$Recents$ARRFEDelayedQueueManager$DELAYED_QUEUE_OPERATION_STATUS[ARRFEDelayedQueueManager.DELAYED_QUEUE_OPERATION_STATUS.FAILED.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT = new int[PROGRESS_DIALOG_CONTEXT.values().length];
            try {
                $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT[PROGRESS_DIALOG_CONTEXT.AR_FIND.ordinal()] = 1;
            } catch (NoSuchFieldError e5) {
            }
            try {
                $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT[PROGRESS_DIALOG_CONTEXT.AR_PORTFOLIO.ordinal()] = 2;
            } catch (NoSuchFieldError e6) {
            }
            try {
                $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT[PROGRESS_DIALOG_CONTEXT.AR_DOC_LOADER.ordinal()] = 3;
            } catch (NoSuchFieldError e7) {
            }
            try {
                $SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT[PROGRESS_DIALOG_CONTEXT.NO_CONTEXT.ordinal()] = 4;
            } catch (NoSuchFieldError e8) {
            }
            $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE = new int[ARConstants.SECURITY_HANDLER_TYPE.values().length];
            try {
                $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE[ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_NONE.ordinal()] = 1;
            } catch (NoSuchFieldError e9) {
            }
            try {
                $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE[ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_STANDARD.ordinal()] = 2;
            } catch (NoSuchFieldError e10) {
            }
            try {
                $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE[ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_EDC.ordinal()] = 3;
            } catch (NoSuchFieldError e11) {
            }
            try {
                $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE[ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_EBX.ordinal()] = 4;
            } catch (NoSuchFieldError e12) {
            }
            try {
                $SwitchMap$com$adobe$reader$config$ARConstants$SECURITY_HANDLER_TYPE[ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_UNKNOWN.ordinal()] = 5;
            } catch (NoSuchFieldError e13) {
            }
        }
    }

    public interface ARReadOnlyFileAlertSaveHandler {
        void onSave();
    }

    class ClearPreviousPositionTask extends TimerTask {
        ClearPreviousPositionTask() {
        }

        @Override
        public void run() {
            ARViewerActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (ARViewerActivity.this.mPositionTimer != null) {
                        ARViewerActivity.this.mPositionTimer.cancel();
                        ARViewerActivity.this.mPositionTimer.purge();
                        ARViewerActivity.this.mPositionTimer = null;
                        ARViewerActivity.this.hidePreviousPositionLink();
                    }
                }
            });
        }
    }

    public interface OnActivityResumeListener {
        void onActivityResume();
    }

    public enum PROGRESS_DIALOG_CONTEXT {
        AR_FIND,
        AR_PORTFOLIO,
        AR_DOC_LOADER,
        NO_CONTEXT
    }

    class ReleaseScreenDimTimerTask extends TimerTask {
        ReleaseScreenDimTimerTask() {
        }

        @Override
        public void run() {
            if (ARViewerActivity.this.mIsDisplayOn) {
                ARViewerActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (ARViewerActivity.this.mScreenWakeTimer != null) {
                            ARViewerActivity.this.mScreenWakeTimer.cancel();
                            ARViewerActivity.this.mScreenWakeTimer.purge();
                            ARViewerActivity.this.mScreenWakeTimer = null;
                            ARViewerActivity.this.clearScreenOnFlag();
                        }
                    }
                });
            }
        }
    }

    class UIElementsHandler extends Handler {
        private final WeakReference<ARViewerActivity> mActivity;

        public UIElementsHandler(ARViewerActivity aRViewerActivity) {
            this.mActivity = new WeakReference<>(aRViewerActivity);
        }

        @Override
        public void handleMessage(Message message) {
            ARViewerActivity aRViewerActivity = this.mActivity.get();
            if (aRViewerActivity != null) {
                switch (message.what) {
                    case 1:
                        aRViewerActivity.fadePageIndexOverlay(false);
                        break;
                }
            }
            super.handleMessage(message);
        }
    }

    public void ShowErrorDlg(int i, int i2, String str) {
        this.mErrString = getString(i);
        showErrorDlgCommon(i2, str);
    }

    private void acquireScreenOnFlag() {
        getWindow().addFlags(128);
    }

    private void actOnIntent(Intent intent, boolean z) {
        resetSearchView();
        sViewerLaunchedFromOthers = false;
        this.mDocOpenedFromFileList = false;
        String stringExtra = intent.getStringExtra(EXTERNAL_CONTENT_DATA);
        if (stringExtra != null) {
            File file = new File(stringExtra);
            if (BBFileUtils.c(getCacheDir(), file) && !file.exists()) {
                finish();
                return;
            }
            sViewerLaunchedFromOthers = true;
            resetToolSwitcher();
            if (!BBFileUtils.b(stringExtra, this.mCurrentDocPath)) {
                enterDocumentViewing(stringExtra, null, null);
            }
            this.mPortfolioStack.clearStack();
            return;
        }
        if (intent.getStringExtra(FILE_BROWSER_FILE_PATH) == null) {
            if (intent.getData() == null && z) {
                finish();
                return;
            }
            return;
        }
        String stringExtra2 = intent.getStringExtra(FILE_BROWSER_FILE_PATH);
        this.mDocOpenedFromFileList = true;
        String stringExtra3 = intent.getStringExtra(FILE_BROWSER_CLOUD_FILE_ID);
        String stringExtra4 = intent.getStringExtra(FILE_BROWSER_CLOUD_FILE_SOURCE);
        this.mSelectedTabLocationId = intent.getIntExtra(ARSplitPaneActivity.CURRENT_TAB_SELECTED, 0);
        if (BBFileUtils.c(stringExtra2)) {
            resetToolSwitcher();
            enterDocumentViewing(stringExtra2, stringExtra3, stringExtra4);
        } else {
            openNonPDFFile(stringExtra2);
            finish();
        }
    }

    private boolean canHideUIElements() {
        return (this.mDontHideUIElements || this.mIsTrackingSeekbar || isBookmarkPanelVisible() || isPortfolioListViewVisible()) ? false : true;
    }

    private void cancelTimerAndTasks() {
        if (this.mPositionTimer != null) {
            this.mPositionTimer.cancel();
            this.mPositionTimer.purge();
            this.mPositionTimer = null;
        }
        if (this.mPositionTask != null) {
            this.mPositionTask.cancel();
            this.mPositionTask = null;
        }
    }

    private void cleanup() {
        dismissDialogs();
        closeDocument();
        if (!this.mPortfolioStack.isStackEmpty()) {
            this.mPortfolioStack.clearStack();
        }
        ARUtils.deleteCacheFiles(getCacheDir().getAbsolutePath());
        cancelTimerAndTasks();
    }

    private void clearAnimationsForUIElems() {
        if (!this.mIsInDocumentViewMode) {
            findViewById(R.id.topBarLayout).clearAnimation();
        }
        findViewById(R.id.pageIndexOverlay).clearAnimation();
        this.mBottomBarLayout.clearAnimation();
    }

    public void clearScreenOnFlag() {
        getWindow().clearFlags(128);
    }

    public void closeCloudDocument() {
        if (this.mCloudFileID != null) {
            finish();
        }
    }

    private void closeDocument() {
        ARThumbnailManager platformThumbnailManager;
        BitmapDrawable bitmapDrawable;
        Bitmap bitmap;
        sendHideProgressDialogMessage();
        if (this.mDocumentManager != null) {
            ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
            if (docViewManager != null && (platformThumbnailManager = docViewManager.getPlatformThumbnailManager()) != null) {
                ImageView imageView = new ImageView(this);
                if (platformThumbnailManager.drawThumbnail(docViewManager.getPageIDForIndex(0), imageView) && !ARApp.getNightModePreference() && (bitmapDrawable = (BitmapDrawable) imageView.getDrawable()) != null && (bitmap = bitmapDrawable.getBitmap()) != null) {
                    ARRecentsFilesManager.setThumbnailForFile(this.mCurrentDocPath, bitmap, docViewManager.getSecurityHandlerType() != ARConstants.SECURITY_HANDLER_TYPE.SECURITY_HANDLER_NONE);
                }
            }
            this.mBottomToolbar.onDocClose();
            this.mDocumentManager.docWillClose();
        }
        ARLastViewedPosition aRLastViewedPosition = new ARLastViewedPosition();
        if (this.mDocLoaderManager != null) {
            aRLastViewedPosition = this.mDocLoaderManager.getInitialPosition();
            this.mDocLoaderManager.markAsClosed();
            updateDocToCloud();
        }
        if (this.mFileLinkShareHandler != null) {
            this.mFileLinkShareHandler.cancelShareLink();
        }
        this.mFileLinkShareHandler = null;
        if (this.mDocumentManager != null) {
            this.mDocumentManager.closeDocument();
        }
        this.mDocumentManager = null;
        clearCacheFiles();
        if (this.mPortfolio != null) {
            if (this.mCurrentDocPath != null && this.mCloudFileID == null) {
                ARRFEDelayedQueueManager.getInstance().onLocalDocClosed(this.mCurrentDocPath, aRLastViewedPosition);
            }
            this.mPortfolio.closeDocument();
        }
        this.mPortfolio = null;
        if (this.mDocLoaderManager != null) {
            this.mDocLoaderManager.release();
        }
        this.mDocLoaderManager = null;
        fadeOutUIElems(true);
        hidePopOverView();
        showSearch(false);
        this.mCurrentDocPath = null;
        if (this.mSharedFilePath != null) {
            File file = new File(this.mSharedFilePath);
            if (file.exists()) {
                file.delete();
            }
        }
        this.mCloudFileID = null;
        this.mCloudSource = null;
        this.mIsDocViewDrawnOnce = false;
        ARSignatureServices.getInstance().resetSyncSignatureSession();
    }

    public void continueExecution(String str, String str2, String str3) {
        int f;
        this.mMoveTask = null;
        if (str == null || BBFileUtils.b(str, this.mCurrentDocPath)) {
            return;
        }
        this.mNewDocumentOpened = true;
        this.mPasswdAlert.resetDialog();
        String e = (str2 == null && n.h(str)) ? n.e(str) : str2;
        ARLastViewedPosition positionForFile = ARRecentsFilesManager.getPositionForFile(e, str);
        if (e != null && (f = n.f(e)) != -1 && f != positionForFile.getPageIndex()) {
            positionForFile = new ARLastViewedPosition();
            positionForFile.setPageIndex(f);
        }
        openDocument(str, e, positionForFile, false, false, str3);
        this.mAddDocPathToRecentlyViewed = true;
    }

    private native void didResume();

    private void dismissDialogs() {
        this.mPasswdAlert.dismiss();
        this.mLCRMDlg.cancel();
        this.mAuthorDlg.dismiss();
        if (this.mGotoPageDlg != null) {
            this.mGotoPageDlg.dismiss();
        }
        if (this.mReadOnlyDlg != null) {
            this.mReadOnlyDlg.dismiss();
        }
    }

    private String docFileListSourceType() {
        String str = null;
        if (sViewerLaunchedFromOthers) {
            return ARDCMAnalytics.EXTERNAL;
        }
        if (!this.mDocOpenedFromFileList) {
            return null;
        }
        switch (this.mSelectedTabLocationId) {
            case 1:
                str = ARDCMAnalytics.RECENT;
                break;
            case 2:
                str = "Local";
                break;
            case 3:
                str = "Document Cloud";
                break;
            case 4:
                str = ARDCMAnalytics.OUTBOX;
                break;
        }
        return (this.mSelectedTabLocationId == 0 || this.mSelectedTabLocationId < 5) ? str : this.mCloudSource;
    }

    private String docSourceType() {
        String docFileListSourceType = docFileListSourceType();
        if (this.mCloudFileID == null) {
            return docFileListSourceType;
        }
        g.a();
        return !g.h(this.mCloudFileID) ? ARDCMAnalytics.MOBILE_RECENTS : docFileListSourceType;
    }

    private void enableHomeButton(boolean z) {
        this.mActionBar.setDisplayHomeAsUpEnabled(z);
        this.mActionBar.setDisplayShowHomeEnabled(z);
        this.mActionBar.setHomeButtonEnabled(z);
    }

    private void enterDocumentViewing(final String str, final String str2, final String str3) {
        boolean z = false;
        if (!ARApp.getAppContext().getSharedPreferences(ARApp.ADOBE_READER_PREFERENCES, 0).contains("cacheLocationKey")) {
            long a2 = m.a();
            long a3 = com.adobe.libs.services.b.a.a(true);
            if (a2 >= 52428800 + a3) {
                g.a();
                if (g.c() <= a3) {
                    File a4 = n.a();
                    if (a4 != null && new File(a4, ".Skybox.Cache").exists()) {
                        this.mMoveTask = new ARBlueHeronMoveCacheAsyncTask(this, true, a3, new ARBlueHeronMoveCacheAsyncTask.MoveCacheTaskHandler() {
                            private String mMovedDocPath;

                            {
                                this.mMovedDocPath = str;
                            }

                            @Override
                            public void onMoveCacheTaskCompletion() {
                                ARViewerActivity.this.continueExecution(this.mMovedDocPath, str2, str3);
                            }

                            @Override
                            public void onMoveCacheTaskStart() {
                            }

                            @Override
                            public void onMoveCacheTaskSuccess(String str4, String str5) {
                                if (BBFileUtils.c(this.mMovedDocPath, str4)) {
                                    this.mMovedDocPath = this.mMovedDocPath.replaceFirst(str4, str5);
                                }
                            }
                        });
                        this.mMoveTask.taskExecute(new Void[0]);
                        z = true;
                    }
                    if (!z) {
                        com.adobe.libs.services.b.a.a(d.CACHE_LOCATION_INTERNAL_VALUE, true, a3);
                    }
                }
            }
            com.adobe.libs.services.b.a.a(d.CACHE_LOCATION_SDCARD_VALUE, true, com.adobe.libs.services.b.a.a(false));
        }
        if (this.mMoveTask == null) {
            continueExecution(str, str2, str3);
        }
    }

    public void exitViewer() {
        if (this.mIsSearchViewExpanded) {
            hidePanels();
            showSearch(false);
        }
        if (ARWidgetToolbars.isToolbarShown(this)) {
            ARWidgetToolbars.onHomeUpButtonPressed();
        }
        hidePanels();
        exitActiveHandler();
    }

    public void fadePageIndexOverlay(boolean z) {
        Animation loadAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out);
        View findViewById = findViewById(R.id.pageIndexOverlay);
        if (findViewById.isShown()) {
            if (!z) {
                findViewById.startAnimation(loadAnimation);
            }
            hidePageIndexOverlay();
        }
    }

    public static ARViewerActivity getCurrentActivity() {
        return sCurrentActivity;
    }

    private String getDocumentTypeName(ARDocViewManager aRDocViewManager) {
        return aRDocViewManager.isXFAForm() ? aRDocViewManager.isXFAFormDynamic() ? ARDCMAnalytics.DOCUMENT_TYPE_DYNAMIC_XFA : ARDCMAnalytics.DOCUMENT_TYPE_STATIC_XFA : aRDocViewManager.isAcroForm() ? ARDCMAnalytics.DOCUMENT_TYPE_ACROFORM : ARDCMAnalytics.DOCUMENT_TYPE_STANDARD;
    }

    private String getFilePathForCopy() {
        String defaultFileCopyPath = ARFileBrowserUtils.getDefaultFileCopyPath();
        String str = null;
        if (defaultFileCopyPath != null) {
            String str2 = defaultFileCopyPath + File.separator + BBFileUtils.a(this.mCurrentDocPath);
            File file = new File(str2);
            int i = 1;
            str = str2;
            while (file.exists()) {
                str = BBFileUtils.a(str2, i);
                file = new File(str);
                i++;
            }
        }
        return str;
    }

    private ARInkSignatureHandler getInkSignatureHandler() {
        ARDocViewManager docViewManager;
        ARCommentsManager commentManager;
        ARInkCommentHandler inkCommentHandler;
        if (this.mDocumentManager == null || (docViewManager = this.mDocumentManager.getDocViewManager()) == null || (commentManager = docViewManager.getCommentManager()) == null || (inkCommentHandler = commentManager.getInkCommentHandler()) == null) {
            return null;
        }
        return inkCommentHandler.getInkSignatureHandler();
    }

    public int getPopOverHeight(int i, boolean z) {
        Rect rect = new Rect();
        Paint paint = new Paint();
        paint.setTextSize(getResources().getDimension(R.dimen.scrubber_fte_text_size));
        paint.getTextBounds(getString(R.string.IDS_SCRUBBER_FTE_MESSAGE), 0, getString(R.string.IDS_SCRUBBER_FTE_MESSAGE).length(), rect);
        int ceil = (int) Math.ceil(rect.width());
        double dimension = z ? getResources().getDimension(R.dimen.scrubber_fte_arrow_size) : 0.0d;
        double dimension2 = getResources().getDimension(R.dimen.scrubber_fte_textview_margin_left_right);
        double dimension3 = getResources().getDimension(R.dimen.scrubber_fte_textview_margin_top_bottom);
        double dimension4 = getResources().getDimension(R.dimen.scrubber_fte_line_spacing);
        return (int) ((((2.0d * dimension3) + (r4 * r5)) - dimension) + (((int) Math.ceil(ceil / ((i - (dimension2 * 2.0d)) - dimension))) * dimension4));
    }

    private Bitmap getRotatedBitmap(Bitmap bitmap, float f) {
        Matrix matrix = new Matrix();
        matrix.postRotate(f);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    }

    private int getScrubberThumbDrawable() {
        int currentPageNumber = getCurrentPageNumber();
        return (this.mCurrentViewMode == 1 || this.mCurrentViewMode == 3) ? ARApp.getNightModePreference() ? currentPageNumber >= 100 ? R.drawable.v_n_verticalscrubberbig : R.drawable.v_n_verticalscrubbersmall : currentPageNumber >= 100 ? R.drawable.v_verticalscrubberbig : R.drawable.v_verticalscrubbersmall : ARApp.getNightModePreference() ? currentPageNumber >= 100 ? R.drawable.v_n_horizontalscrubberbig : R.drawable.v_n_horizontalscrubbersmall : currentPageNumber >= 100 ? R.drawable.v_horizontalscrubberbig : R.drawable.v_horizontalscrubbersmall;
    }

    public String getSearchString() {
        String charSequence;
        if (this.mSearchView == null || (charSequence = this.mSearchView.getQuery().toString()) == null) {
            return null;
        }
        return charSequence.trim();
    }

    private String getSecurityHandlerName(ARConstants.SECURITY_HANDLER_TYPE security_handler_type) {
        switch (security_handler_type) {
            case SECURITY_HANDLER_NONE:
                return ARDCMAnalytics.DOCUMENT_SECURITY_TYPE_NONE;
            case SECURITY_HANDLER_STANDARD:
                return this.mDocLoaderManager.wasDocumentPasswordRequested() ? ARDCMAnalytics.DOCUMENT_SECURITY_TYPE_STANDARD_PASSWORD : ARDCMAnalytics.DOCUMENT_SECURITY_TYPE_STANDARD_NO_PASSWORD;
            case SECURITY_HANDLER_EDC:
                return ARDCMAnalytics.DOCUMENT_SECURITY_TYPE_LCRM;
            default:
                return ARDCMAnalytics.DOCUMENT_SECURITY_TYPE_UNKNOWN;
        }
    }

    private void hidePageIndexOverlay() {
        View findViewById = findViewById(R.id.pageIndexOverlay);
        if (findViewById != null) {
            findViewById.setVisibility(8);
        }
    }

    private void hidePopOverView() {
        if (this.mPopoverView == null || !this.mPopoverView.isShown()) {
            return;
        }
        this.mPopoverView.a(false);
    }

    private void hideProgressDialog() {
        if (this.mProgressDialog != null) {
            this.mProgressDialog.dismiss();
            this.mProgressDialog = null;
        }
    }

    private void hideSearchPanel() {
        if (this.mDocumentManager != null) {
            ARTextFinder textFinder = this.mDocumentManager.getDocViewManager().getTextFinder();
            if (textFinder.isPanelVisible()) {
                textFinder.hidePanel();
                showSearch(false);
            }
        }
    }

    private void hideTextSelection() {
        ARTextSelectionHandler aRTextSelector;
        if (this.mDocumentManager == null || (aRTextSelector = this.mDocumentManager.getDocViewManager().getARTextSelector()) == null || !aRTextSelector.isTextSelectionActive()) {
            return;
        }
        aRTextSelector.removeHandlesAndClearSelection();
    }

    private void initiateSaveToAcrobatDotCom(int i, boolean z) {
        String str = this.mCloudFileID;
        if (this.mCloudFileID == null) {
            switch (ARRFEDelayedQueueManager.getInstance().getAutoUploadStatusForFile(this.mCurrentDocPath)) {
                case COMPLETED:
                    str = ARRecentsFilesManager.getCloudIDForFilePath(this.mCurrentDocPath);
                    break;
                case IN_PROGRESS:
                    ARRFEDelayedQueueManager.getInstance().cancelAutoUploadRequestForFilePath(this.mCurrentDocPath);
                    ARBlueHeronFileTransferActivity.performUpload(this, this.mCurrentDocPath, i, com.adobe.libs.services.auth.d.ACROBAT_DOT_COM_DEFAULT_SOURCE_NAME);
                    break;
                case PENDING:
                    ARRFEDelayedQueueManager.getInstance().cancelAutoUploadRequestForFilePath(this.mCurrentDocPath);
                    ARBlueHeronFileTransferActivity.performUpload(this, this.mCurrentDocPath, i, com.adobe.libs.services.auth.d.ACROBAT_DOT_COM_DEFAULT_SOURCE_NAME);
                    break;
                case FAILED:
                    ARBlueHeronFileTransferActivity.performUpload(this, this.mCurrentDocPath, i, com.adobe.libs.services.auth.d.ACROBAT_DOT_COM_DEFAULT_SOURCE_NAME);
                    break;
            }
        }
        if (str != null) {
            g.a();
            if (g.h(str)) {
                return;
            }
            g.a();
            String f = g.f(str);
            File file = new File(f);
            BBFileUtils.b(new File(this.mCurrentDocPath), file);
            Intent intent = new Intent(this, (Class<?>) ARBlueHeronFileTransferActivity.class);
            ARFileTransferService.TRANSFER_TYPE transfer_type = ARFileTransferService.TRANSFER_TYPE.CLASS3_UPLOAD;
            if (z) {
                transfer_type = ARFileTransferService.TRANSFER_TYPE.UPDATE;
                intent.putExtra(ARFileTransferActivity.IS_MODAL_KEY, true);
            }
            String a2 = BBFileUtils.a(f);
            g.a();
            intent.putExtra(ARFileTransferActivity.FILE_ENTRY_KEY, AROutboxFileEntry.getJSONStrFromOutboxFileEntry(new AROutboxFileEntry(a2, f, str, g.d(str), file.length(), AROutboxTransferManager.TRANSFER_STATUS.NOT_STARTED, transfer_type, com.adobe.libs.services.auth.d.ACROBAT_DOT_COM_DEFAULT_SOURCE_NAME)));
            startActivityForResult(intent, i);
        }
    }

    public boolean isExportPDFAllowed() {
        throw new UnsupportedOperationException("Method not decompiled: com.adobe.reader.viewer.ARViewerActivity.isExportPDFAllowed():boolean");
    }

    private boolean isLCRMDialogShown() {
        return this.mLCRMDlg != null && this.mLCRMDlg.isShowing();
    }

    private native void lockAndTrimCache(long j, boolean z);

    public void onDocMovedToCloudInternal(String str, String str2) {
        long length = new File(str).length();
        if (this.mDocLoaderManager != null && !BBFileUtils.b(this.mCurrentDocPath, str)) {
            this.mDocLoaderManager.swapFilePath(str, true);
        }
        this.mCloudLastSavedDocSize = length;
        this.mCurrentDocPath = str;
        this.mCloudFileID = str2;
        this.mCloudSource = com.adobe.libs.services.auth.d.ACROBAT_DOT_COM_DEFAULT_SOURCE_NAME;
    }

    private void onDocMovedToCloudSuccess(String str, String str2) {
        ARRecentsFilesManager.removeEntryFromRecentFilesList(this.mCurrentDocPath);
        if (!new File(this.mCurrentDocPath).getName().equals(new File(str).getName())) {
            setDocTitle();
        }
        onDocMovedToCloudInternal(str, str2);
        this.mSelectedTabLocationId = 4;
        fadeOutUIElems(true);
        showUIElems();
        ARLastViewedPosition aRLastViewedPosition = this.mDocLoaderManager == null ? new ARLastViewedPosition() : this.mDocLoaderManager.getInitialPosition();
        this.mAddDocPathToRecentlyViewed = true;
        addDocPathToRecentlyViewed(aRLastViewedPosition);
        updateActionBar();
        if (this.mDocumentManager != null) {
            new ARBlueHeronUpdateLastViewedPageIndexAsyncTask(this.mCloudFileID, this.mDocumentManager.getPageIDForDisplay().getPageIndex()).taskExecute(new Void[0]);
            this.mDocumentManager.getDocViewManager().getBookmarkManager().onDocUploadSuccessful();
        }
    }

    public void onEnterAccessibilityMode() {
        if (this.mDocumentManager != null) {
            hidePopOverView();
            this.mDocumentManager.setViewMode(2);
            ARPageView activePageView = this.mDocumentManager.getActivePageView();
            if (activePageView != null) {
                activePageView.fetchAccessibilityNodes();
            }
        }
    }

    private void openDocument(java.lang.String r7, java.lang.String r8, com.adobe.reader.misc.ARLastViewedPosition r9, boolean r10, boolean r11, java.lang.String r12) {
        throw new UnsupportedOperationException("Method not decompiled: com.adobe.reader.viewer.ARViewerActivity.openDocument(java.lang.String, java.lang.String, com.adobe.reader.misc.ARLastViewedPosition, boolean, boolean, java.lang.String):void");
    }

    private void openPortfolioDoc(String str, boolean z, String str2, ARLastViewedPosition aRLastViewedPosition, String str3, String str4) {
        this.mLCRMDlg.cancel();
        this.mPasswdAlert.dismiss();
        this.mCurrentDocPath = str;
        this.mHasPendingErr = false;
        this.mNewDocumentOpened = false;
        if (!z) {
            openDocument(this.mCurrentDocPath, str3, aRLastViewedPosition, false, true, str4);
        } else {
            openDocument(this.mCurrentDocPath, str3, aRLastViewedPosition, true, true, str4);
            this.mPortfolioBrowserDirectory = str2;
        }
    }

    private native void registerApp();

    @TargetApi(19)
    private void registerTouchExplorationStateChangedListener() {
        if (Build.VERSION.SDK_INT >= 19) {
            if (this.mTouchExplorationStateChangeListener == null) {
                this.mTouchExplorationStateChangeListener = new AccessibilityManager.TouchExplorationStateChangeListener() {
                    @Override
                    public void onTouchExplorationStateChanged(boolean z) {
                        if (z) {
                            ARViewerActivity.this.onEnterAccessibilityMode();
                        }
                        ARViewerActivity.this.mBottomToolbar.refresh();
                    }
                };
            }
            ((AccessibilityManager) getSystemService("accessibility")).addTouchExplorationStateChangeListener((AccessibilityManager.TouchExplorationStateChangeListener) this.mTouchExplorationStateChangeListener);
        }
    }

    private void removeDocPathFromRecentlyViewed(String str) {
        ARRecentsFilesManager.removeEntryFromRecentFilesList(str);
    }

    private void resetSearchView() {
        if (this.mSearchView != null) {
            this.mSearchView.setQuery(ARFileEntry.DEFAULT_ENTRY_ICON_STRING, false);
        }
    }

    private void resetTimer() {
        cancelTimerAndTasks();
        this.mPositionTimer = new Timer();
        this.mPositionTask = new ClearPreviousPositionTask();
        this.mPositionTimer.schedule(this.mPositionTask, 1800000L);
    }

    private void setActionBarIconFilter() {
        if (this.mActionBar == null || this.mActionBarMenu == null) {
            return;
        }
        setMenuItemColorFilterForId(R.id.document_view_search_icon);
        setMenuItemColorFilterForId(R.id.document_view_addBookmark);
    }

    private void setActionBarTitleColor() {
        if (this.mActionBar != null) {
            int color = ARApp.getNightModePreference() ? getResources().getColor(R.color.action_bar_text_color_dark) : getResources().getColor(R.color.action_bar_text_color);
            SpannableString spannableString = new SpannableString(this.mActionBar.getTitle());
            spannableString.setSpan(new ForegroundColorSpan(color), 0, spannableString.length(), 18);
            this.mActionBar.setTitle(spannableString);
        }
    }

    private static void setCurrentActivity(ARViewerActivity aRViewerActivity) {
        sCurrentActivity = aRViewerActivity;
    }

    private void setMenuItemColorFilterForId(int i) {
        MenuItem findItem = this.mActionBarMenu.findItem(i);
        if (findItem != null) {
            if (ARApp.getNightModePreference()) {
                findItem.getIcon().setColorFilter(getResources().getColor(R.color.night_mode_icon_filter_color), PorterDuff.Mode.SRC_ATOP);
            } else {
                findItem.getIcon().clearColorFilter();
            }
        }
    }

    private void setPageIndexText(View view, int i, int i2) {
        TextView textView = (TextView) view.findViewById(R.id.currentPageTextView);
        textView.setText(new StringBuilder().append(i).toString());
        TextView textView2 = (TextView) view.findViewById(R.id.totalPagesTextView);
        if (Locale.getDefault().getLanguage().equalsIgnoreCase("en")) {
            textView2.setText("of " + i2);
        } else {
            textView2.setText(Integer.toString(i2));
        }
        textView.setContentDescription(ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
        textView2.setContentDescription(ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
        findViewById(R.id.pageIndexOverlay).setContentDescription(ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
        String replace = ARApp.getAppContext().getString(R.string.IDS_PAGE_TEXT_ACCESSIBILITY_TEMPLATE).replace("$PAGENUM$", String.valueOf(i)).replace("$PAGECOUNT$", String.valueOf(i2)).replace("$PAGECONTENT$", ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
        view.setContentDescription(replace);
        this.mScrubber.setContentDescription(replace);
        view.post(new Runnable() {
            @Override
            public void run() {
                ARViewerActivity.this.findViewById(R.id.pageIndexOverlay).requestLayout();
            }
        });
    }

    public void setScrubberFTEDisplayed() {
        SharedPreferences.Editor edit = getSharedPreferences(ARApp.ADOBE_READER_PREFERENCES, 0).edit();
        edit.putBoolean(SCRUBBER_FTE_DISPLAYED, true);
        edit.apply();
    }

    private void setSearchViewTheme() {
        try {
            EditText editText = (EditText) this.mSearchView.findViewById(this.mSearchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));
            if (editText != null) {
                editText.setTextColor(ARApp.getNightModePreference() ? -1 : ViewCompat.MEASURED_STATE_MASK);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void setTileCacheDirectory() {
        String absolutePath = getCacheDir().getAbsolutePath();
        if (absolutePath != null) {
            this.mTileCachePath = absolutePath + File.separator + TILE_CACHE_FOLDER_NAME;
        }
        File file = new File(this.mTileCachePath);
        if (!(file.exists() ? true : file.mkdir())) {
            this.mTileCachePath = null;
        }
        BBFileUtils.a(file, false);
    }

    private void setUIControls() {
        setupActionBar();
        this.mScrubber = new SeekBar(this);
        this.mBottomBarLayout = (LinearLayout) findViewById(R.id.bottomBarLayout);
        this.mBottomToolbar = (ARBottomBar) findViewById(R.id.bottomToolbar);
        this.mViewPager = (ARViewPager) findViewById(R.id.viewPager);
        this.mDPI = ARUtils.getScreenDPI();
        this.mPasswdAlert = new ARPasswordDialog(this);
        this.mLCRMDlg = new ARLCRMDialog(this);
        this.mAuthorDlg = new ARCommentAuthorDialog(this, getCurrentTheme(), new ARCommentAuthorDialog.OnAuthorPreferenceSet() {
            @Override
            public void onAuthorPreferenceSet() {
                if (ARViewerActivity.this.mDocumentManager != null) {
                    ARViewerActivity.this.mDocumentManager.getDocViewManager().getCommentManager().continueCommentCreation();
                }
            }
        });
        this.mGotoPageDlg = new ARGotoPageDialog(this, getCurrentTheme());
        this.mPortfolioStack = new ARPortfolioStack();
    }

    private void setupActionBar() {
        this.mActionBar = getActionBar();
        this.mActionBar.setDisplayHomeAsUpEnabled(true);
        this.mIsInDocumentViewMode = true;
    }

    @TargetApi(16)
    private void setupScrubberAutomation() {
        if (Build.VERSION.SDK_INT >= 16) {
            final TextView textView = (TextView) findViewById(R.id.scrubberAutomationTextView);
            textView.setVisibility(0);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    textView.setText(ARViewerActivity.this.mDocumentManager.getDocViewManager().getNumPages() + " " + ARViewerActivity.this.getCurrentPageNumber() + " " + ARViewerActivity.this.mScrubber.getThumb().getBounds().toString());
                }
            });
        }
    }

    private void setupSearchView(MenuItem menuItem) {
        this.mSearchView = (SearchView) menuItem.getActionView();
        this.mSearchView.setQueryHint(getResources().getString(R.string.IDS_FIND_EDIT_BOX_HINT_TEXT_STR));
        this.mSearchView.setIconified(false);
        if (!this.mSearchText.equals(ARFileEntry.DEFAULT_ENTRY_ICON_STRING)) {
            this.mSearchView.setQuery(this.mSearchText, false);
            ARTextFinder textFinder = this.mDocumentManager.getDocViewManager().getTextFinder();
            if (!textFinder.getSearchString().equals(ARFileEntry.DEFAULT_ENTRY_ICON_STRING)) {
                textFinder.showPanel();
            }
        }
        this.mSearchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean z) {
                if (z) {
                    ARViewerActivity.this.exitActiveHandler();
                }
            }
        });
        this.mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextChange(String str) {
                if (str == null) {
                    return false;
                }
                String trim = str.trim();
                if (ARViewerActivity.this.mSearchText.equals(trim)) {
                    return false;
                }
                if (trim.length() == 0) {
                    ARTextFinder textFinder2 = ARViewerActivity.this.mDocumentManager.getDocViewManager().getTextFinder();
                    textFinder2.hidePanel();
                    textFinder2.getSnippetManager().resetState();
                }
                ARViewerActivity.this.mSearchText = trim;
                return false;
            }

            @Override
            public boolean onQueryTextSubmit(String str) {
                ARViewerActivity.this.mSearchView.clearFocus();
                ARUtils.hideKeyboard(ARViewerActivity.this.mSearchView);
                ARTextFinder textFinder2 = ARViewerActivity.this.mDocumentManager.getDocViewManager().getTextFinder();
                textFinder2.showPanel();
                textFinder2.getSnippetManager().startSearch(ARViewerActivity.this.getSearchString());
                return false;
            }
        });
        this.mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
            @Override
            public boolean onClose() {
                ARViewerActivity.this.hidePanels();
                ARViewerActivity.this.showSearch(false);
                return false;
            }
        });
        setSearchViewTheme();
    }

    public void shareDocumentInternal(String str, String str2) {
        String[] split;
        String[] split2;
        String[] split3;
        File file = new File(str);
        if (!file.exists()) {
            ShowErrorDlg(R.string.IDS_ERR_SHARE_ERROR, 1, ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
            return;
        }
        if (this.mCloudFileID != null) {
            ARDCMAnalytics.getInstance().trackAction(ARDCMAnalytics.DC, ARDCMAnalytics.SHARE, ARDCMAnalytics.DOCUMENT_BUTTON_TAPPED);
        } else {
            ARDCMAnalytics.getInstance().trackAction("Local", ARDCMAnalytics.SHARE, ARDCMAnalytics.DOCUMENT_BUTTON_TAPPED);
        }
        Intent intent = new Intent("android.intent.action.SEND");
        intent.setType("application/pdf");
        Uri fromFile = Uri.fromFile(file);
        if (com.adobe.libs.buildingblocks.utils.n.a()) {
            fromFile = FileProvider.getUriForFile(this, ARApp.getContentProviderAuthority(), file);
            intent.addFlags(1);
        }
        intent.putExtra("android.intent.extra.STREAM", fromFile);
        if (str2 == null || !MailTo.isMailTo(str2)) {
            intent.putExtra("android.intent.extra.SUBJECT", String.format(getResources().getString(R.string.IDS_EMAILING_STR), file.getName()));
        } else {
            try {
                URLDecoder.decode(str2, "UTF-8");
                MailTo parse = MailTo.parse(str2);
                String subject = parse.getSubject();
                if (subject != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", subject);
                }
                String body = parse.getBody();
                if (body != null) {
                    intent.putExtra("android.intent.extra.TEXT", body);
                }
                String to = parse.getTo();
                if (to != null && (split3 = to.replaceFirst("^,", ARFileEntry.DEFAULT_ENTRY_ICON_STRING).split("\\s*,\\s*")) != null) {
                    intent.putExtra("android.intent.extra.EMAIL", split3);
                }
                String cc = parse.getCc();
                if (cc != null && (split2 = cc.replaceFirst("^,", ARFileEntry.DEFAULT_ENTRY_ICON_STRING).split("\\s*,\\s*")) != null) {
                    intent.putExtra("android.intent.extra.CC", split2);
                }
                String str3 = parse.getHeaders().get(HEADER_BCC);
                if (str3 != null && (split = str3.replaceFirst("^,", ARFileEntry.DEFAULT_ENTRY_ICON_STRING).split("\\s*,\\s*")) != null) {
                    intent.putExtra("android.intent.extra.BCC", split);
                }
            } catch (Exception e) {
            }
        }
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(Intent.createChooser(intent, getResources().getString(R.string.IDS_SHARE_APP_CHOOSER_TITLE)));
        } else {
            Toast.makeText(this, getString(2131230746), 0).show();
        }
    }

    private void showErrorDlg() {
        final String format = TextUtils.isEmpty(this.mErrMsg) ? this.mErrString : String.format(this.mErrString, this.mErrMsg);
        this.mErrMsg = null;
        if (this.mIsFatalErr) {
            new ARAlert(this, new ARAlert.DialogProvider() {
                @Override
                public Dialog getDialog() {
                    ARAlertDialog aRAlertDialog = new ARAlertDialog(ARViewerActivity.this) {
                        @Override
                        public void dismiss() {
                            if (isShowing()) {
                                ARViewerActivity.this.mHasPendingErr = false;
                                ARViewerActivity.this.sendHideProgressDialogMessage();
                            }
                            super.dismiss();
                        }
                    };
                    aRAlertDialog.setTitle(2131230738);
                    aRAlertDialog.setMessage(format);
                    aRAlertDialog.setButton(-1, ARViewerActivity.this.getResources().getString(2131230739), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            ARViewerActivity.this.handleFatalError();
                        }
                    });
                    return aRAlertDialog;
                }
            }, new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    ARViewerActivity.this.finish();
                }
            }).show();
            sendHideProgressDialogMessage();
        } else {
            this.mNonFatalErrorToast = Toast.makeText(ARApp.getAppContext(), format, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS);
            this.mNonFatalErrorToast.show();
            this.mHasPendingErr = false;
        }
        if (this.mPortfolioStack.isStackEmpty() || !isPortfolioListViewVisible()) {
            return;
        }
        this.mPortfolio.showListView();
    }

    private void showErrorDlgCommon(int i, String str) {
        if (this.mHasPendingErr) {
            return;
        }
        if (str != null && str.length() > 0) {
            this.mErrMsg = str;
        }
        this.mHasPendingErr = true;
        switch (i) {
            case 0:
                this.mIsFatalErr = true;
                break;
            case 1:
                this.mIsFatalErr = false;
                break;
            default:
                this.mIsFatalErr = false;
                break;
        }
        showErrorDlg();
    }

    private void showPageIndexOverlay() {
        View findViewById = findViewById(R.id.pageIndexOverlay);
        if (findViewById.isShown()) {
            return;
        }
        findViewById.setVisibility(0);
    }

    public void showProgressDialog() {
        if (isPasswordDialogShown() || isLCRMDialogShown()) {
            this.mProgressDialog = null;
            this.mProgressDialogContext = PROGRESS_DIALOG_CONTEXT.NO_CONTEXT;
            return;
        }
        this.mProgressDialog = new Dialog(this) {
            @Override
            public void onBackPressed() {
                switch (AnonymousClass29.$SwitchMap$com$adobe$reader$viewer$ARViewerActivity$PROGRESS_DIALOG_CONTEXT[ARViewerActivity.this.mProgressDialogContext.ordinal()]) {
                    case 1:
                        if (ARViewerActivity.this.mDocumentManager != null) {
                            ARViewerActivity.this.mDocumentManager.getDocViewManager().getTextFinder().cancelSearch();
                            break;
                        }
                        break;
                    case 2:
                        ARViewerActivity.this.mPortfolio.cancelFileDownload();
                        break;
                }
            }

            @Override
            public boolean onSearchRequested() {
                return true;
            }
        };
        this.mProgressDialog.getWindow().setBackgroundDrawableResource(2131296256);
        this.mProgressDialog.setOnDismissListener(this);
        this.mProgressDialog.requestWindowFeature(1);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
        layoutParams.gravity = 17;
        this.mProgressDialog.addContentView(new ProgressBar(this), layoutParams);
        this.mProgressDialog.show();
    }

    private void showScrubberFTE() {
        this.mScrubber.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                if (ARViewerActivity.this.mDocumentManager == null || ARViewerActivity.this.wasScrubberFTEDisplayed() || ARViewerActivity.this.isAccessibilityEnabled()) {
                    return;
                }
                ARViewerActivity.this.mPopoverView = new a(ARViewerActivity.this);
                RelativeLayout relativeLayout = (RelativeLayout) ARViewerActivity.this.findViewById(R.id.main_content);
                int dimension = (int) ARViewerActivity.this.getResources().getDimension(R.dimen.toolbar_height);
                int dimension2 = (int) ARViewerActivity.this.getResources().getDimension(R.dimen.scrubber_fte_popover_width);
                int galleyHeight = ARViewerActivity.this.mDocumentManager.getDocViewManager().getGalleyHeight(new PageID(), ARViewerActivity.this.mDocumentManager.getDocViewManager().getZoomLevel());
                if (ARViewerActivity.this.mCurrentViewMode != 1 && ARViewerActivity.this.mCurrentViewMode != 3) {
                    ARViewerActivity.this.mPopoverView.setContentSizeForViewInPopover(new Point(dimension2, ARViewerActivity.this.getPopOverHeight(dimension2, false)));
                    long thumbPosition = ((ARHorizontalScrubber) ARViewerActivity.this.mScrubber).getThumbPosition();
                    Rect rect = new Rect((int) thumbPosition, (ARViewerActivity.this.getScreenHeight() - ARViewerActivity.this.mScrubber.getHeight()) - dimension, (int) thumbPosition, (int) (ARViewerActivity.this.getScreenHeight() - ARViewerActivity.this.getResources().getDimension(R.dimen.toolbar_height)));
                    ARViewerActivity.this.mPopoverView.setPopoverBackgroundDrawable(2130837970);
                    ARViewerActivity.this.mPopoverView.setPopoverArrowDownDrawable(2130837978);
                    ARViewerActivity.this.mPopoverView.a(relativeLayout, rect, 0, 0, 2);
                } else {
                    if (ARViewerActivity.this.mCurrentViewMode == 1 && ARViewerActivity.this.mScrubber.getMax() != galleyHeight - ARViewerActivity.this.getScreenHeight()) {
                        return;
                    }
                    ARViewerActivity.this.mPopoverView.setContentSizeForViewInPopover(new Point(dimension2, ARViewerActivity.this.getPopOverHeight(dimension2, true)));
                    long thumbPosition2 = ((ARVerticalScrubber) ARViewerActivity.this.mScrubber).getThumbPosition();
                    Rect rect2 = new Rect(ARViewerActivity.this.getScreenWidth() - ARViewerActivity.this.mScrubber.getHeight(), (int) thumbPosition2, ARViewerActivity.this.getScreenWidth(), (int) thumbPosition2);
                    ARViewerActivity.this.mPopoverView.setPopoverBackgroundDrawable(2130837983);
                    ARViewerActivity.this.mPopoverView.setPopoverArrowRightDrawable(2130837979);
                    ARViewerActivity.this.mPopoverView.a(relativeLayout, rect2, dimension, dimension, 8);
                }
                ARViewerActivity.this.setScrubberFTEDisplayed();
            }
        });
    }

    private void swapCurrentDocFilePath(String str) {
        if (this.mDocLoaderManager != null) {
            this.mDocLoaderManager.doSave(false);
            BBFileUtils.b(new File(this.mCurrentDocPath), new File(str));
            this.mDocLoaderManager.swapFilePath(str, true);
            this.mCurrentDocPath = str;
        }
    }

    private native void unregisterApp();

    @TargetApi(19)
    private void unregisterTouchExplorationStateChangedListener() {
        if (Build.VERSION.SDK_INT < 19 || this.mTouchExplorationStateChangeListener == null) {
            return;
        }
        ((AccessibilityManager) getSystemService("accessibility")).removeTouchExplorationStateChangeListener((AccessibilityManager.TouchExplorationStateChangeListener) this.mTouchExplorationStateChangeListener);
    }

    private static void unsetCurrentActivity(ARViewerActivity aRViewerActivity) {
        if (sCurrentActivity == aRViewerActivity) {
            sCurrentActivity = null;
        }
    }

    public void updateDocToCloud() {
        if (this.mCloudFileID == null || this.mCurrentDocPath == null || isAttachmentDoc(this.mCurrentDocPath)) {
            return;
        }
        File file = new File(this.mCurrentDocPath);
        if (file.exists()) {
            long length = file.length();
            if (length != this.mCloudLastSavedDocSize) {
                AROutboxTransferManager.getInstance().addNewTransferAsync(new AROutboxFileEntry(file.getName(), this.mCurrentDocPath, this.mCloudFileID, -1L, length, AROutboxTransferManager.TRANSFER_STATUS.NOT_STARTED, ARFileTransferService.TRANSFER_TYPE.UPDATE, this.mCloudSource));
                this.mCloudLastSavedDocSize = length;
                Toast.makeText(ARApp.getAppContext(), com.adobe.libs.services.h.a.a(ARApp.getAppContext().getString(R.string.IDS_CLOUD_FILE_UPDATING), this.mCloudSource), 1).show();
                if (BBFileUtils.e(this.mMappedClass1File)) {
                    BBFileUtils.b(new File(this.mCurrentDocPath), new File(this.mMappedClass1File));
                }
            }
        }
    }

    private void updateDocumentToCloud(boolean z) {
        File file = new File(this.mCurrentDocPath);
        long length = file.length();
        if (length == this.mCloudLastSavedDocSize) {
            shareLink();
            return;
        }
        String jSONStrFromOutboxFileEntry = AROutboxFileEntry.getJSONStrFromOutboxFileEntry(new AROutboxFileEntry(file.getName(), this.mCurrentDocPath, this.mCloudFileID, -1L, length, AROutboxTransferManager.TRANSFER_STATUS.NOT_STARTED, ARFileTransferService.TRANSFER_TYPE.UPDATE, this.mCloudSource));
        Intent intent = new Intent(this, (Class<?>) ARBlueHeronFileTransferActivity.class);
        intent.putExtra(ARFileTransferActivity.FILE_ENTRY_KEY, jSONStrFromOutboxFileEntry);
        intent.putExtra(ARFileTransferActivity.IS_MODAL_KEY, z);
        startActivityForResult(intent, 4);
    }

    private void waitCallingThread() {
        synchronized (this.mRunnableSyncObject) {
            while (this.mIsBackgroundThreadWaiting) {
                try {
                    this.mRunnableSyncObject.wait();
                } catch (InterruptedException e) {
                }
            }
        }
    }

    public boolean wasScrubberFTEDisplayed() {
        return getSharedPreferences(ARApp.ADOBE_READER_PREFERENCES, 0).getBoolean(SCRUBBER_FTE_DISPLAYED, false);
    }

    private native void willPause();

    private BitmapDrawable writeOnDrawable(int i, String str) {
        Bitmap copy = BitmapFactory.decodeResource(getResources(), i).copy(Bitmap.Config.ARGB_8888, true);
        Paint paint = new Paint(1);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(ARApp.getNightModePreference() ? -1 : ViewCompat.MEASURED_STATE_MASK);
        paint.setTextSize(getResources().getDimension(R.dimen.scrubber_page_number_text_size));
        float measureText = paint.measureText(str);
        new Canvas(copy).drawText(str, (r3.getWidth() - measureText) / 2.0f, (r3.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2.0f), paint);
        return new BitmapDrawable(getResources(), getRotatedBitmap(copy, -90.0f));
    }

    public String GetLocalizedString(String str) {
        Resources resources = getResources();
        return resources.getString(resources.getIdentifier(str, "string", getPackageName()));
    }

    public boolean HasPendingError() {
        return this.mHasPendingErr;
    }

    public void ShowErrorDlgUsingKey(String str, int i, String str2) {
        this.mErrString = str;
        showErrorDlgCommon(i, str2);
    }

    public void addDocPathToRecentlyViewed(ARLastViewedPosition aRLastViewedPosition) {
        if (!this.mAddDocPathToRecentlyViewed || this.mCurrentDocPath == null) {
            return;
        }
        if (this.mCloudFileID != null) {
            String str = this.mCloudFileID;
            String a2 = BBFileUtils.a(this.mCurrentDocPath);
            g.a();
            ARRecentsFilesManager.updateCloudEntryInRecentFilesList(str, a2, e.a(g.d(this.mCloudFileID)), new File(this.mCurrentDocPath).length(), aRLastViewedPosition, e.a(), this.mCloudSource);
            new ARBlueHeronUpdateLastAccessAsyncTask(this.mCloudFileID, null).taskExecute(new Void[0]);
        } else {
            ARRecentsFilesManager.updateLocalEntryInRecentFilesList(this.mCurrentDocPath, aRLastViewedPosition, e.a());
            ARRFEDelayedQueueManager.getInstance().addLocalDocToDelayedQueue(this.mCurrentDocPath);
            ARRecentsFileDBManager.getInstance().logMaxDelayedQueueSize(this);
        }
        this.mAddDocPathToRecentlyViewed = false;
    }

    public void clearCacheFiles() {
        if (this.mCurrentDocPath != null && BBFileUtils.a(this.mCurrentDocPath, getCacheDir()) && this.mPortfolioStack.isStackEmpty()) {
            ARUtils.deleteCacheFiles(getCacheDir().getAbsolutePath());
        }
    }

    public void clearSearchFocus() {
        if (this.mSearchView == null || !this.mSearchView.hasFocus()) {
            return;
        }
        this.mSearchView.clearFocus();
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        if (this.mDocLoaderManager == null || (this.mDocumentManager == null && !this.mDocLoaderManager.isPortfolio())) {
            return true;
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    public void displayAlertForReadOnlyFiles(final ARReadOnlyFileAlertSaveHandler aRReadOnlyFileAlertSaveHandler) {
        final String filePathForCopy = getFilePathForCopy();
        if (filePathForCopy == null) {
            Toast.makeText(ARApp.getAppContext(), R.string.IDS_READONLY_MODIFICATION_STR, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
            return;
        }
        if (this.mReadOnlyDlg == null || aRReadOnlyFileAlertSaveHandler != null) {
            this.mReadOnlyDlg = new ARAlert(this, new ARAlert.DialogProvider() {
                @Override
                public Dialog getDialog() {
                    String string = ARViewerActivity.this.getString(R.string.IDS_READONLY_COPY_STR);
                    ARAlertDialog aRAlertDialog = new ARAlertDialog(ARViewerActivity.this);
                    aRAlertDialog.setTitle(R.string.IDS_READONLY_TITLE_STR);
                    aRAlertDialog.setMessage(string);
                    aRAlertDialog.setButton(-1, ARViewerActivity.this.getString(R.string.IDS_READONLY_OK_STR), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (ARViewerActivity.this.mDocLoaderManager != null) {
                                String str = ARViewerActivity.this.mCurrentDocPath;
                                File file = new File(str);
                                File file2 = new File(filePathForCopy);
                                BBFileUtils.b(file, file2);
                                ARViewerActivity.this.mDocLoaderManager.swapFilePath(filePathForCopy, ARViewerActivity.this.mCloudFileID != null);
                                String name = file.getName();
                                String name2 = file2.getName();
                                ARViewerActivity.this.mCurrentDocPath = filePathForCopy;
                                if (!name.equals(name2)) {
                                    ARViewerActivity.this.setDocTitle();
                                }
                                ARViewerActivity.this.updateActionBar();
                                ARLastViewedPosition initialPosition = ARViewerActivity.this.mDocLoaderManager.getInitialPosition();
                                ARViewerActivity.this.mAddDocPathToRecentlyViewed = true;
                                ARRecentsFilesManager.replacePathString(str, ARViewerActivity.this.mCurrentDocPath, true);
                                ARViewerActivity.this.addDocPathToRecentlyViewed(initialPosition);
                                ARViewerActivity.this.fadeOutUIElems(true);
                                ARViewerActivity.this.showUIElems();
                                if (aRReadOnlyFileAlertSaveHandler != null) {
                                    aRReadOnlyFileAlertSaveHandler.onSave();
                                }
                            }
                            dialogInterface.dismiss();
                        }
                    });
                    aRAlertDialog.setButton(-2, ARViewerActivity.this.getString(R.string.IDS_READONLY_CANCEL_STR), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    });
                    return aRAlertDialog;
                }
            });
        }
        this.mReadOnlyDlg.show();
    }

    public void docDidSave() {
        if (this.mCurrentDocPath == null || this.mCloudFileID != null) {
            return;
        }
        ARUtils.refreshSystemMediaScanDataBase(this, this.mCurrentDocPath);
    }

    public void emailFile(String str, String str2) {
        shareDocument(str2);
    }

    void exitActiveHandler() {
        ARDocViewManager docViewManager;
        if (this.mDocumentManager == null || (docViewManager = this.mDocumentManager.getDocViewManager()) == null) {
            return;
        }
        docViewManager.exitActiveHandlers();
    }

    public void fadeOutUIElems(boolean r4) {
        throw new UnsupportedOperationException("Method not decompiled: com.adobe.reader.viewer.ARViewerActivity.fadeOutUIElems(boolean):void");
    }

    @Override
    public void finish() {
        closeDocument();
        super.finish();
    }

    @Override
    protected int getActivityLayoutID() {
        return R.layout.adobereader;
    }

    @Override
    public int getActivityTheme() {
        return ARApp.getNightModePreference() ? R.style.Theme_OverlayActionBarDarkTheme : R.style.Theme_OverlayActionBarLightTheme;
    }

    public String getAttachmentsDir() {
        return new File(PVApp.getPVApp().getCacheDir(), ARConfig.ATTACHMENTS_DOWNLOAD_SUB_DIR).getAbsolutePath() + File.separator;
    }

    @Override
    public int getBackgroundImage() {
        return getCurrentSwitcherItemID() == 1 ? R.drawable.tool_viewer_bg : super.getBackgroundImage();
    }

    public ARBottomBar getBottomBar() {
        return this.mBottomToolbar;
    }

    @Override
    public File getCacheDir() {
        return PVApp.getPVApp().getCacheDir();
    }

    public String getCloudFileID() {
        return this.mCloudFileID;
    }

    public String getCloudSource() {
        return this.mCloudSource;
    }

    @Override
    public int getColor() {
        return getCurrentSwitcherItemID() == 1 ? R.color.switcher_viewer_color : super.getColor();
    }

    public ARCommentsToolbar getCommentingToolbar() {
        return (ARCommentsToolbar) this.mBottomBarLayout.findViewById(R.id.toolbar_commenting);
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getCommentsToolSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            private ARCommentsToolbar mCommentsToolbar;
            private String mErrorString;
            private String mErrorTitleString;
            private boolean mShowReadOnlyAlert;

            private boolean checkAndShowCommentingAllowedStatus() {
                boolean z;
                int i;
                int i2;
                boolean z2 = false;
                if (ARViewerActivity.this.mDocumentManager != null) {
                    ARDocViewManager docViewManager = ARViewerActivity.this.mDocumentManager.getDocViewManager();
                    z = docViewManager != null && docViewManager.isOperationPermitted(1, 0, false);
                } else {
                    z = false;
                }
                if (ARViewerActivity.this.isPortfolioListViewVisible()) {
                    i = R.string.IDS_TOOL_PORTFOLIO_ERROR_DESC;
                    i2 = R.string.IDS_TOOL_PORTFOLIO_ERROR_TITLE;
                } else if (ARViewerActivity.this.mDocumentManager != null && ARViewerActivity.this.mDocumentManager.getDocViewManager().getViewMode() == 3) {
                    i = R.string.IDS_COMMENTING_REFLOW_ERROR_DESC;
                    i2 = R.string.IDS_TOOL_REFLOW_ERROR_TITLE;
                } else if (ARViewerActivity.this.mDocLoaderManager.wasDocumentPasswordRequested()) {
                    i = R.string.IDS_ERROR_UNSUPPORTED_PASSWORD_PROTECTED;
                    i2 = R.string.IDS_TOOL_SECURED_DOC_ERROR_TITLE;
                } else if (z && !ARViewerActivity.this.isFileReadOnly()) {
                    z2 = true;
                    i2 = 2131230738;
                    i = 2131231478;
                } else if (ARViewerActivity.this.isAttachmentDoc(ARViewerActivity.this.mCurrentDocPath)) {
                    i = R.string.IDS_TOOL_ATTACHMENT_ERROR_DESC;
                    i2 = R.string.IDS_TOOL_ATTACHMENT_ERROR_TITLE;
                } else if (ARFileBrowserUtils.isCachedFile(ARViewerActivity.this.mCurrentDocPath)) {
                    i = 2131231704;
                    i2 = 2131230738;
                } else if (ARViewerActivity.this.isFileReadOnly() && z) {
                    this.mShowReadOnlyAlert = true;
                    i2 = 2131230738;
                    i = 2131231478;
                } else {
                    i = R.string.IDS_DOC_PERMISSIONS_COMMENTS_DIALOG_STR;
                    i2 = R.string.IDS_DOC_PERMISSIONS_DIALOG_TITLE;
                }
                this.mErrorString = ARViewerActivity.this.getResources().getString(i);
                this.mErrorTitleString = ARViewerActivity.this.getResources().getString(i2);
                return z2;
            }

            @Override
            public boolean canEnterTool(int i) {
                return checkAndShowCommentingAllowedStatus();
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, final FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
                if (!this.mShowReadOnlyAlert && !this.mErrorString.isEmpty() && !this.mErrorTitleString.isEmpty()) {
                    ARAlert.displayErrorDlg(ARViewerActivity.this, this.mErrorTitleString, this.mErrorString, null);
                } else if (this.mShowReadOnlyAlert) {
                    ARViewerActivity.this.displayAlertForReadOnlyFiles(new ARReadOnlyFileAlertSaveHandler() {
                        @Override
                        public void onSave() {
                            if (fWEnterToolSuccessHandler != null) {
                                fWEnterToolSuccessHandler.onEnterSuccess();
                            }
                        }
                    });
                    this.mShowReadOnlyAlert = false;
                }
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                this.mCommentsToolbar = (ARCommentsToolbar) ((LayoutInflater) ARViewerActivity.this.getSystemService("layout_inflater")).inflate(R.layout.toolbar_commenting, (ViewGroup) null);
                this.mCommentsToolbar.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
                ARViewerActivity.this.mBottomToolbar.push(this.mCommentsToolbar);
                ARSignatureServices.getInstance().syncProfileSignature(false);
            }

            @Override
            public void exitTool(int i) {
                this.mCommentsToolbar.closeToolbar();
                ARViewerActivity.this.mBottomToolbar.pop();
            }
        };
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getCreatePDFToolSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            @Override
            public boolean canEnterTool(int i) {
                return true;
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(8);
                ARViewerActivity.this.mCreatePDFFragment = new ARCreatePDFFragment(ARViewerActivity.this, true, true);
                ARViewerActivity.this.enterToolFragment(ARViewerActivity.this.mCreatePDFFragment);
            }

            @Override
            public void exitTool(int i) {
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(0);
                ARViewerActivity.this.exitToolFragment(ARViewerActivity.this.mCreatePDFFragment);
                ARViewerActivity.this.mCreatePDFFragment = null;
            }
        };
    }

    public String getCurrentDocPath() {
        return this.mCurrentDocPath;
    }

    public int getCurrentPageNumber() {
        return this.mDocumentManager.getPageIDForDisplay().getPageIndex() + 1;
    }

    public int getCurrentTheme() {
        return ARApp.getNightModePreference() ? R.style.readerDialogDark : R.style.readerDialogLight;
    }

    public double getDPI() {
        return this.mDPI;
    }

    @Override
    protected int getDefaultToolID() {
        return 2;
    }

    public ARDocLoaderManager getDocLoaderManager() {
        return this.mDocLoaderManager;
    }

    @Override
    public ARDocumentManager getDocumentManager() {
        return this.mDocumentManager;
    }

    public void getDocumentPassword(long j) {
        this.mPasswdAlert.getPassword(j, BBFileUtils.a(this.mCurrentDocPath));
    }

    @Override
    protected List<FWSwitcherEntry> getEntries() {
        List<FWSwitcherEntry> allEntries = ARAppSwitcherEntryManager.getAllEntries();
        if (!ARFillAndSignUtils.shouldShowFillAndSignEntryInToolSwitcher(this)) {
            for (FWSwitcherEntry fWSwitcherEntry : allEntries) {
                if (fWSwitcherEntry.getID() == 7) {
                    allEntries.remove(fWSwitcherEntry);
                }
            }
        }
        return allEntries;
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getExportPDFSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            @Override
            public boolean canEnterTool(int i) {
                return ARViewerActivity.this.isExportPDFAllowed();
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(8);
                if (ARViewerActivity.this.mDocLoaderManager.doSave(false)) {
                    ARViewerActivity.this.updateDocToCloud();
                }
                ARViewerActivity.this.mExportPDFFragment = new ARExportPDFFragment(ARViewerActivity.this, ARViewerActivity.this.isAttachmentDoc(ARViewerActivity.this.mCurrentDocPath) ? null : ARViewerActivity.this.mCloudFileID, ARViewerActivity.this.mCurrentDocPath, ARViewerActivity.this.mCloudLastSavedDocSize, ARViewerActivity.this.mCloudSource);
                ARViewerActivity.this.enterToolFragment(ARViewerActivity.this.mExportPDFFragment);
            }

            @Override
            public void exitTool(int i) {
                ARViewerActivity.this.exitToolFragment(ARViewerActivity.this.mExportPDFFragment);
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(0);
                ARViewerActivity.this.mExportPDFFragment = null;
            }
        };
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getFillAndSignSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            private ARFillAndSignToolbar mFillAndSignToolbar;

            @Override
            public boolean canEnterTool(int i) {
                return ARViewerActivity.this.mDocumentManager != null ? ARFillAndSignUtils.canEnterFillAndSignTool(ARViewerActivity.this, ARViewerActivity.this.mDocLoaderManager, ARViewerActivity.this.mDocumentManager.getDocViewManager(), ARViewerActivity.this.mCurrentDocPath, ARViewerActivity.this.isAttachmentDoc(ARViewerActivity.this.mCurrentDocPath)) : ARFillAndSignUtils.canEnterFillAndSignTool(ARViewerActivity.this, ARViewerActivity.this.mDocLoaderManager, null, null, false);
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                if (ARViewerActivity.this.mDocumentManager == null || !ARViewerActivity.this.mDocumentManager.getDocViewManager().isAcroForm()) {
                    if (ARViewerActivity.this.mDocLoaderManager != null && ARViewerActivity.this.mDocLoaderManager.doSave(false)) {
                        ARViewerActivity.this.updateDocToCloud();
                    }
                    ARViewerActivity.this.mFillAndSignFragment = new ARFillAndSignFragment(ARViewerActivity.this);
                    ARViewerActivity.this.enterToolFragment(ARViewerActivity.this.mFillAndSignFragment);
                } else {
                    this.mFillAndSignToolbar = (ARFillAndSignToolbar) ((LayoutInflater) ARViewerActivity.this.getSystemService("layout_inflater")).inflate(R.layout.toolbar_fill_and_sign, (ViewGroup) null);
                    this.mFillAndSignToolbar.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
                    ARViewerActivity.this.mBottomToolbar.push(this.mFillAndSignToolbar);
                }
                ARSignatureServices.getInstance().syncProfileSignature(false);
            }

            @Override
            public void exitTool(int i) {
                if (ARViewerActivity.this.mFillAndSignFragment != null) {
                    ARViewerActivity.this.exitToolFragment(ARViewerActivity.this.mFillAndSignFragment);
                    ARViewerActivity.this.mFillAndSignFragment = null;
                } else {
                    this.mFillAndSignToolbar.closeToolbar();
                    ARViewerActivity.this.mBottomToolbar.pop(this.mFillAndSignToolbar);
                }
            }
        };
    }

    public ARFillAndSignToolbar getFillAndSignToolbar() {
        return (ARFillAndSignToolbar) this.mBottomBarLayout.findViewById(R.id.toolbar_fill_and_sign);
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getHomeToolSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            @Override
            public boolean canEnterTool(int i) {
                return true;
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                if (ARViewerActivity.sViewerLaunchedFromOthers) {
                    Intent intent = new Intent(ARViewerActivity.this, (Class<?>) ARSplitPaneActivity.class);
                    intent.putExtra(ARViewerActivity.VIEWER_LAUNCHED_FROM_OTHERS, ARViewerActivity.sViewerLaunchedFromOthers);
                    int initialTabSelectedLocationId = ARViewerActivity.this.getInitialTabSelectedLocationId();
                    if (initialTabSelectedLocationId != 0) {
                        intent.putExtra(ARSplitPaneActivity.INITIAL_TAB_SELECTED, initialTabSelectedLocationId);
                    }
                    ARViewerActivity.sViewerLaunchedFromOthers = false;
                    ARViewerActivity.this.startActivity(intent);
                }
                ARViewerActivity.this.finish();
            }

            @Override
            public void exitTool(int i) {
            }
        };
    }

    @Override
    public int getIcon() {
        return getCurrentSwitcherItemID() == 1 ? R.drawable.tool_viewer_active : super.getIcon();
    }

    public int getInitialTabSelectedLocationId() {
        return this.mSelectedTabLocationId;
    }

    public ARInkActionBar getInkToolbar() {
        return (ARInkActionBar) findViewById(R.id.ink_actionbar);
    }

    public double getMaxTileHeapLimit() {
        if (this.mMaxTileHeapLimit == 0.0d && this.mDocumentManager != null) {
            this.mMaxTileHeapLimit = ARApp.getMaxHeapLimit() - this.mDocumentManager.getDocViewManager().getPlatformThumbnailManager().getMaxMemoryUsage();
            this.mMaxTileHeapLimit -= ((getScreenWidth() * getScreenHeight()) * 4) / 1024;
        }
        return this.mMaxTileHeapLimit;
    }

    @Override
    public int getOptionsMenuGroupID() {
        return R.id.viewer_menu_group;
    }

    @Override
    public AROrganizePagesFragment getOrganizePagesFragment() {
        return this.mOrganizePagesFragment;
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getOrganizePagesToolSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            private String mErrorString;
            private String mErrorTitleString;
            private boolean mShowReadOnlyAlert;

            private boolean checkAndShowPageReorganizationAllowedStatus() {
                int i;
                int i2;
                boolean z = false;
                ARDocViewManager docViewManager = ARViewerActivity.this.mDocumentManager != null ? ARViewerActivity.this.mDocumentManager.getDocViewManager() : null;
                boolean isOperationPermitted = docViewManager != null ? docViewManager.isOperationPermitted(0, 2, false) : false;
                boolean isFileReadOnly = ARViewerActivity.this.isFileReadOnly();
                if (ARViewerActivity.this.isPortfolioListViewVisible()) {
                    i = R.string.IDS_TOOL_PORTFOLIO_ERROR_DESC;
                    i2 = R.string.IDS_TOOL_PORTFOLIO_ERROR_TITLE;
                } else if (ARViewerActivity.this.mDocLoaderManager.wasDocumentPasswordRequested()) {
                    i = R.string.IDS_ERROR_UNSUPPORTED_PASSWORD_PROTECTED;
                    i2 = R.string.IDS_TOOL_SECURED_DOC_ERROR_TITLE;
                } else if (isOperationPermitted && !isFileReadOnly) {
                    z = true;
                    i2 = 2131230738;
                    i = 2131230991;
                } else if (ARViewerActivity.this.isAttachmentDoc(ARViewerActivity.this.mCurrentDocPath)) {
                    i = R.string.IDS_TOOL_ATTACHMENT_ERROR_DESC;
                    i2 = R.string.IDS_TOOL_ATTACHMENT_ERROR_TITLE;
                } else if (ARFileBrowserUtils.isCachedFile(ARViewerActivity.this.mCurrentDocPath)) {
                    i = 2131231704;
                    i2 = 2131230738;
                } else if (isFileReadOnly && isOperationPermitted) {
                    this.mShowReadOnlyAlert = true;
                    i2 = 2131230738;
                    i = 2131230991;
                } else {
                    i = R.string.IDS_DOC_PERMISSIONS_COMMENTS_DIALOG_STR;
                    i2 = R.string.IDS_DOC_PERMISSIONS_DIALOG_TITLE;
                }
                if (!z) {
                    this.mErrorString = ARViewerActivity.this.getResources().getString(i);
                    this.mErrorTitleString = ARViewerActivity.this.getResources().getString(i2);
                }
                return z;
            }

            @Override
            public boolean canEnterTool(int i) {
                return checkAndShowPageReorganizationAllowedStatus();
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, final FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
                if (!this.mShowReadOnlyAlert && this.mErrorString != null && !this.mErrorString.isEmpty() && this.mErrorTitleString != null && !this.mErrorTitleString.isEmpty()) {
                    ARAlert.displayErrorDlg(ARViewerActivity.this, this.mErrorTitleString, this.mErrorString, null);
                } else if (this.mShowReadOnlyAlert) {
                    ARViewerActivity.this.displayAlertForReadOnlyFiles(new ARReadOnlyFileAlertSaveHandler() {
                        @Override
                        public void onSave() {
                            if (fWEnterToolSuccessHandler != null) {
                                fWEnterToolSuccessHandler.onEnterSuccess();
                            }
                        }
                    });
                    this.mShowReadOnlyAlert = false;
                }
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                ARDocViewManager docViewManager;
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(8);
                if (ARViewerActivity.this.mDocumentManager != null && (docViewManager = ARViewerActivity.this.mDocumentManager.getDocViewManager()) != null) {
                    docViewManager.setOrganizePagesMode(true);
                }
                ARViewerActivity.this.mOrganizePagesFragment = new AROrganizePagesFragment(ARViewerActivity.this, ARViewerActivity.this);
                ARViewerActivity.this.enterToolFragment(ARViewerActivity.this.mOrganizePagesFragment);
            }

            @Override
            public void exitTool(int i) {
                int pageIndexOnExit;
                ARViewerActivity.this.findViewById(R.id.main_container).setVisibility(0);
                ARViewerActivity.this.exitToolFragment(ARViewerActivity.this.mOrganizePagesFragment);
                if (ARViewerActivity.this.mDocumentManager != null) {
                    ARDocViewManager docViewManager = ARViewerActivity.this.mDocumentManager.getDocViewManager();
                    if (docViewManager != null) {
                        docViewManager.setOrganizePagesMode(false);
                        if (ARViewerActivity.this.mOrganizePagesFragment != null && (pageIndexOnExit = ARViewerActivity.this.mOrganizePagesFragment.getPageIndexOnExit()) != -1) {
                            docViewManager.gotoPage(docViewManager.getPageIDForIndex(pageIndexOnExit), false);
                        }
                    }
                    ARViewerActivity.this.mDocumentManager.refreshViewer();
                }
                ARViewerActivity.this.mOrganizePagesFragment = null;
            }
        };
    }

    public int getScreenHeight() {
        return this.mViewPager.getScreenHeight();
    }

    public int getScreenWidth() {
        return this.mViewPager.getScreenWidth();
    }

    public String getTempDirForFlattenedCopies() {
        return new File(PVApp.getPVApp().getCacheDir(), ARConfig.TEMP_DIR_FOR_FLATTENING).getAbsolutePath() + File.separator;
    }

    public String getTileCacheDirectory() {
        return this.mTileCachePath;
    }

    @Override
    public int getToolTitle() {
        return getCurrentSwitcherItemID() == 1 ? R.string.IDS_SWITCHER_ENTRY_VIEWER_TITLE : super.getToolTitle();
    }

    public ARDocToolbar getToolbar() {
        return (ARDocToolbar) findViewById(R.id.documentToolbar);
    }

    public int getTopBarHeight() {
        View findViewById = findViewById(R.id.topBarLayout);
        if (findViewById != null) {
            return findViewById.getHeight();
        }
        return 0;
    }

    public Thread getUIThread() {
        return this.mUIThread;
    }

    public long getUIThreadId() {
        if (this.mUIThread == null) {
            return -1L;
        }
        return this.mUIThread.getId();
    }

    public ARViewPager getViewPager() {
        return this.mViewPager;
    }

    @Override
    protected FWBaseSwitcherActivity.FWToolSwitchHandler getViewerToolSwitchHandler() {
        return new FWBaseSwitcherActivity.FWToolSwitchHandler() {
            @Override
            public boolean canEnterTool(int i) {
                return true;
            }

            @Override
            public boolean canExitTool(int i) {
                return true;
            }

            @Override
            public void confirmToolEnter(int i, FWBaseSwitcherActivity.FWEnterToolSuccessHandler fWEnterToolSuccessHandler) {
            }

            @Override
            public void confirmToolExit(int i, FWBaseSwitcherActivity.FWExitToolSucccessHandler fWExitToolSucccessHandler) {
            }

            @Override
            public void enterTool(int i) {
                ARViewerActivity.this.setInDocViewMode(true);
                ARViewerActivity.this.showUIElems();
            }

            @Override
            public void exitTool(int i) {
                ARViewerActivity.this.fadeOutUIElems(false);
                ARViewerActivity.this.setInDocViewMode(false);
                ARViewerActivity.this.exitViewer();
            }
        };
    }

    @Override
    public boolean handleBackPressed() {
        sendHideProgressDialogMessage();
        if (isBookmarkPanelVisible() || this.mIsSearchViewExpanded) {
            hidePanels();
            showSearch(false);
        } else {
            if (this.mDocumentManager != null) {
                if ((!this.mBottomBarLayout.isShown() || !this.mBottomToolbar.onBackPressed()) && !this.mDocumentManager.notifyBackButtonPressed()) {
                    ARDocContextMenuHandler docContextMenuHandler = this.mDocumentManager.getDocViewManager().getDocContextMenuHandler();
                    if (docContextMenuHandler.isActive()) {
                        docContextMenuHandler.exitDocContextMenuMode();
                    } else {
                        ARTextSelectionHandler aRTextSelector = this.mDocumentManager.getDocViewManager().getARTextSelector();
                        if (aRTextSelector != null && aRTextSelector.isTextSelectionActive()) {
                            aRTextSelector.removeHandlesAndClearSelection();
                        }
                    }
                }
            }
            if (this.mIsInDocumentViewMode) {
                handleDocViewBackPress();
                if (this.mNonFatalErrorToast != null) {
                    this.mNonFatalErrorToast.cancel();
                }
            } else {
                unlockToolbar();
                this.mIsInDocumentViewMode = true;
                updateActionBar();
            }
        }
        return true;
    }

    public void handleBookmarkButton() {
        if (this.mDocumentManager == null || this.mDocumentManager.getDocViewManager() == null) {
            return;
        }
        ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
        docViewManager.exitActiveHandlers();
        hideSearchPanel();
        hideTextSelection();
        ARBookmarkManager bookmarkManager = docViewManager.getBookmarkManager();
        if (bookmarkManager.isPanelVisible()) {
            bookmarkManager.hidePanel();
        } else {
            bookmarkManager.showPanel();
        }
    }

    public void handleDocViewBackPress() {
        ARPageView activePageView;
        if (this.mDocumentManager != null && (activePageView = this.mDocumentManager.getActivePageView()) != null) {
            activePageView.removeAllChildViews();
        }
        hidePanels();
        if (!this.mPortfolioStack.isStackEmpty()) {
            restartPreviousPortfolioFromStack();
        } else if (isAttachmentsViewVisible()) {
            this.mPortfolio.hideListView();
        } else {
            closeDocument();
            finish();
        }
    }

    public void handleFatalError() {
        if (isPortfolioStackEmpty()) {
            finish();
        } else {
            restartPreviousPortfolioFromStack();
        }
    }

    public void handleSharePublicLink() {
        boolean doSave = this.mDocLoaderManager.doSave(false);
        if (this.mCloudFileID == null) {
            ARDCMAnalytics.getInstance().trackAction("Local", ARDCMAnalytics.SHARE, ARDCMAnalytics.LINK_BUTTON_TAPPED);
            initiateSaveToAcrobatDotCom(4, doSave);
            return;
        }
        ARDCMAnalytics.getInstance().trackAction(ARDCMAnalytics.DC, ARDCMAnalytics.SHARE, ARDCMAnalytics.LINK_BUTTON_TAPPED);
        long d = BBFileUtils.d(this.mCurrentDocPath);
        if (doSave || d != this.mCloudLastSavedDocSize) {
            updateDocumentToCloud(true);
            return;
        }
        g.a();
        if (g.h(this.mCloudFileID)) {
            shareLink();
        } else {
            initiateSaveToAcrobatDotCom(4, false);
        }
    }

    public void handleSignatureTool(ARCommentsToolbar.SignatureToolSelectionHandler signatureToolSelectionHandler) {
        ARDocToolbar.setupMenu(this, this.mViewPager, new ARInkSignatureHandler.ARSignaturePopupMenu(this, signatureToolSelectionHandler));
    }

    void handleViewModes() {
        ARDocToolbar.setupMenu(this, this.mViewPager, new ARDocViewModeMenu(this));
    }

    public boolean hasAttachments() {
        return this.mPortfolio != null && this.mPortfolio.hasAttachments();
    }

    public void hideBottomBar() {
        this.mBottomBarLayout.animate().translationY(this.mBottomBarLayout.getHeight());
        this.mBottomBarLayout.setVisibility(8);
        if (this.mCurrentViewMode != 1 && this.mCurrentViewMode != 3) {
            this.mScrubber.animate().translationY(this.mScrubber.getHeight());
        }
        this.mScrubber.setVisibility(8);
    }

    public void hideListView() {
        if (isPortfolioListViewVisible()) {
            updateAppSwitcher(true);
            findViewById(R.id.viewPager).setVisibility(0);
            if (this.mDocumentManager != null && this.mDocumentManager.getDocViewManager().getViewMode() == 3) {
                findViewById(R.id.reflowViewPager).setVisibility(0);
            }
            findViewById(R.id.portfolioLayout).setVisibility(8);
            setDocTitle();
            updateActionBar();
            this.mBottomToolbar.pop();
        }
    }

    public void hidePanels() {
        if (this.mDocumentManager != null) {
            ARBookmarkManager bookmarkManager = this.mDocumentManager.getDocViewManager().getBookmarkManager();
            if (bookmarkManager.isPanelVisible()) {
                bookmarkManager.hidePanel();
            }
            hideSearchPanel();
        }
        if ((this.mSearchView == null || this.mSearchView.isIconified()) && canHideUIElements()) {
            unlockToolbar();
        }
    }

    @Override
    public void hidePreviousPositionLink() {
        this.mGotoPageDlg.setPreviousPageNumberLinkVisibility(false);
    }

    public void hideTopAndBottomBar() {
        if (!isAccessibilityEnabled() && canHideUIElements()) {
            hideTopBar();
            hideBottomBar();
            this.mShowingUIElems = false;
        }
    }

    public void hideTopBar() {
        this.mActionBar.hide();
        findViewById(R.id.topBarLayout).setVisibility(8);
    }

    public void initialDocViewPainted() {
        if (this.mDocLoaderManager != null) {
            addDocPathToRecentlyViewed(this.mDocLoaderManager.getInitialPosition());
        }
        showUIElems();
        this.mIsDocViewDrawnOnce = true;
    }

    public boolean isAccessibilityEnabled() {
        AccessibilityManager accessibilityManager = (AccessibilityManager) getSystemService("accessibility");
        return accessibilityManager.isEnabled() && accessibilityManager.isTouchExplorationEnabled();
    }

    public native boolean isAttachmentDoc(String str);

    public boolean isAttachmentsViewVisible() {
        return this.mPortfolio != null && isPortfolioListViewVisible() && this.mPortfolio.isAttachmentsView();
    }

    boolean isBookmarkPanelVisible() {
        try {
            return this.mDocumentManager.getDocViewManager().getBookmarkManager().isPanelVisible();
        } catch (Exception e) {
            return false;
        }
    }

    public boolean isCommentingModeOn() {
        return getCurrentSwitcherItemID() == 3;
    }

    public boolean isCommentingToolbarVisible() {
        ARCommentsToolbar commentingToolbar = getCommentingToolbar();
        return commentingToolbar != null && commentingToolbar.isShown();
    }

    public boolean isDocViewDrawnOnce() {
        return this.mIsDocViewDrawnOnce;
    }

    public boolean isDrawingModeActive() {
        return this.mInInkDrawingMode;
    }

    public boolean isFileReadOnly() {
        return !BBFileUtils.isFileWritable(this.mCurrentDocPath);
    }

    public boolean isFillAndSignModeOn() {
        return getCurrentSwitcherItemID() == 7;
    }

    public boolean isInDocViewMode() {
        return this.mIsInDocumentViewMode;
    }

    public boolean isInFormsMode() {
        return this.mIsInFormsMode;
    }

    @Override
    public boolean isOrganizePagesFragmentVisible() {
        return this.mOrganizePagesFragment != null;
    }

    public boolean isPasswordDialogShown() {
        return this.mPasswdAlert != null && this.mPasswdAlert.isShowing();
    }

    public boolean isPortfolioListViewVisible() {
        return findViewById(R.id.portfolioLayout).getVisibility() == 0;
    }

    public boolean isPortfolioStackEmpty() {
        return this.mPortfolioStack.isStackEmpty();
    }

    public boolean isScrubberChangedDirectly() {
        return this.mScrubberChangedDirectly;
    }

    boolean isSearchPanelVisible() {
        if (this.mDocumentManager != null) {
            return this.mDocumentManager.getDocViewManager().getTextFinder().isPanelVisible();
        }
        return false;
    }

    public boolean isSharePublicLinkSupported() {
        j a2 = com.adobe.libs.services.a.n.a().a(this.mCloudSource);
        if (a2 != null) {
            return a2.c;
        }
        return true;
    }

    public boolean isToolbarInStack(Object obj) {
        ARDocToolbar toolbar = getToolbar();
        for (int i = 0; i < toolbar.getChildCount(); i++) {
            View childAt = toolbar.getChildAt(i);
            if (obj != null && obj.getClass().isInstance(childAt)) {
                return true;
            }
        }
        return false;
    }

    public boolean isToolbarTopView(Object obj) {
        ARDocToolbar toolbar = getToolbar();
        return obj != null && obj.getClass().isInstance(toolbar.getChildAt(toolbar.getChildCount() + (-1)));
    }

    public boolean isUIThread() {
        return this.mUIThread != null && this.mUIThread.getId() == Thread.currentThread().getId();
    }

    public void lockToolbar() {
        this.mUIElemsHandler.removeMessages(1);
        this.mDontHideUIElements = true;
    }

    @Override
    public void onActivityResultRAW(int i, int i2, Intent intent) {
        super.onActivityResultRAW(i, i2, intent);
        if (i != -1) {
            this.mActivityStartedForResult = false;
        }
        switch (i) {
            case 1:
            case 4:
                if (i2 == -1) {
                    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(new Intent(BROADCAST_SWITCH_TO_OUTBOX));
                    Bundle extras = intent.getExtras();
                    onDocMovedToCloudSuccess(extras.getString(ARBlueHeronFileTransferActivity.BLUE_HERON_TRANSFER_ACTIVITY_RETURN_FILE_PATH), extras.getString(ARBlueHeronFileTransferActivity.BLUE_HERON_TRANSFER_ACTIVITY_RETURN_CLOUD_ID));
                    if (i == 4) {
                        shareLink();
                        break;
                    }
                }
                break;
            case 2:
                if (i2 == -1) {
                    Bundle extras2 = intent.getExtras();
                    swapCloudDocFilePath(extras2.getString(CLOUD_CACHE_SRC_DIR), extras2.getString(CLOUD_CACHE_DEST_DIR));
                    break;
                }
                break;
            case 5:
                if (this.mDocumentManager != null) {
                    ARInkSignatureHandler inkSignatureHandler = this.mDocumentManager.getDocViewManager().getCommentManager().getInkCommentHandler().getInkSignatureHandler();
                    if (i2 != -1) {
                        inkSignatureHandler.onImageSignatureWorkflowCancelled();
                        break;
                    } else {
                        inkSignatureHandler.onCropCompleted();
                        break;
                    }
                }
                break;
            case 50:
                if (this.mDocumentManager != null) {
                    ARInkSignatureHandler inkSignatureHandler2 = this.mDocumentManager.getDocViewManager().getCommentManager().getInkCommentHandler().getInkSignatureHandler();
                    if (i2 != -1) {
                        inkSignatureHandler2.onImageSignatureWorkflowCancelled();
                        break;
                    } else {
                        Uri data = intent.getData();
                        String a2 = c.a(intent);
                        String b = c.b(intent);
                        String i3 = b != null ? BBFileUtils.i(b) : null;
                        if ((a2 != null && a2.equalsIgnoreCase("image/gif")) || (i3 != null && i3.equalsIgnoreCase("gif"))) {
                            c.a(this, getResources().getString(2131230740));
                            inkSignatureHandler2.onImageSignatureWorkflowCancelled();
                            break;
                        } else {
                            inkSignatureHandler2.onImageSelectedFromGallery(data);
                            break;
                        }
                    }
                }
                break;
            case com.adobe.libs.signature.ui.c.CHOOSE_CAMERA_RESULT:
                if (this.mDocumentManager != null) {
                    ARInkSignatureHandler inkSignatureHandler3 = this.mDocumentManager.getDocViewManager().getCommentManager().getInkCommentHandler().getInkSignatureHandler();
                    if (!(i2 == -1 ? inkSignatureHandler3.onImageTakenFromCamera() : false)) {
                        inkSignatureHandler3.onImageSignatureWorkflowCancelled();
                        break;
                    }
                }
                break;
            case 10101:
                com.adobe.libs.services.f.a.a().a(i, i2, intent);
                break;
        }
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.mDocumentManager != null) {
            ARCommentsManager commentManager = this.mDocumentManager.getDocViewManager().getCommentManager();
            ARCommentPopupHandler popupNoteHandler = commentManager.getPopupNoteHandler();
            if (popupNoteHandler != null) {
                popupNoteHandler.setPopupNoteWidgetPosition(configuration.orientation);
            }
            ARFreetextCommentHandler freeTextCommentHandler = commentManager.getFreeTextCommentHandler();
            if (freeTextCommentHandler != null) {
                freeTextCommentHandler.setPopupNoteWidgetPosition(configuration.orientation);
            }
            commentManager.getCommentEditHandler().onConfigurationChanged();
        }
        if (this.mInInkDrawingMode) {
            getInkToolbar().dismissCoachMark();
            return;
        }
        if (this.mActionBar != null && this.mIsInDocumentViewMode && !this.mIsSearchViewExpanded) {
            updateActionBar();
            setActionBarTitleColor();
        }
        hidePopOverView();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (this.mIsInFormsMode) {
            return false;
        }
        getMenuInflater().inflate(R.menu.document_view_menu, menu);
        super.onCreateOptionsMenu(menu);
        this.mActionBarMenu = menu;
        setActionBarIconFilter();
        return true;
    }

    @Override
    public void onCreateRAW(Bundle bundle) {
        super.onCreateRAW(null);
        setRequestedOrientation(2);
        registerApp();
        sCurrentActivity = this;
        setUIControls();
        registerForContextMenu(this.mViewPager);
        Intent intent = getIntent();
        this.mUIThread = Thread.currentThread();
        setTileCacheDirectory();
        this.mProgressDialogHandler = new Handler() {
            @Override
            public void handleMessage(Message message) {
                switch (message.what) {
                    case 1:
                        ARViewerActivity.this.showProgressDialog();
                        break;
                }
                super.handleMessage(message);
            }
        };
        actOnIntent(intent, true);
        LocalBroadcastManager.getInstance(this).registerReceiver(this.mBroadcastReceiverMD5MatchFound, new IntentFilter(ARBlueHeronMD5CheckAsyncTask.BROADCAST_MD5_MATCH_FOUND));
        LocalBroadcastManager.getInstance(this).registerReceiver(this.broadcastReceiver_updateUndoRedoState, new IntentFilter(ARDocumentManager.BROADCAST_UPDATE_UNDO_REDO_STATE));
        LocalBroadcastManager.getInstance(this).registerReceiver(this.broadcastReceiver_userSignedOutFromMyAccounts, new IntentFilter(ARUserAccountsActivity.USER_SIGNED_OUT_FROM_USER_ACCOUNTS));
    }

    @Override
    public void onDestroyRAW() {
        LocalBroadcastManager.getInstance(this).unregisterReceiver(this.broadcastReceiver_updateUndoRedoState);
        LocalBroadcastManager.getInstance(this).unregisterReceiver(this.mBroadcastReceiverMD5MatchFound);
        LocalBroadcastManager.getInstance(this).unregisterReceiver(this.broadcastReceiver_userSignedOutFromMyAccounts);
        if (this.mPortfolio != null && this.mProgressDialogContext == PROGRESS_DIALOG_CONTEXT.AR_PORTFOLIO && this.mProgressDialog != null && this.mProgressDialog.isShowing()) {
            this.mPortfolio.cancelFileDownload();
        }
        cleanup();
        sendHideProgressDialogMessage();
        hidePanels();
        this.mHasPendingErr = false;
        super.onDestroyRAW();
        System.gc();
        unsetCurrentActivity(this);
        unregisterApp();
        Thread.setDefaultUncaughtExceptionHandler(null);
        sViewerLaunchedFromOthers = false;
    }

    @Override
    public void onDismiss(DialogInterface dialogInterface) {
        this.mProgressDialogContext = PROGRESS_DIALOG_CONTEXT.NO_CONTEXT;
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        switch (i) {
            case 82:
                if (this.mInSignatureMode) {
                    updateActionBar();
                    return true;
                }
                break;
        }
        return super.onKeyDown(i, keyEvent);
    }

    @Override
    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        ARDocViewManager docViewManager;
        ARCommentsManager commentManager;
        if (i != 82) {
            return super.onKeyUp(i, keyEvent);
        }
        exitActiveHandler();
        ARDocumentManager documentManager = getDocumentManager();
        return (documentManager == null || (docViewManager = documentManager.getDocViewManager()) == null || (commentManager = docViewManager.getCommentManager()) == null) ? isBookmarkPanelVisible() : commentManager.getPopupNoteHandler().isPopupVisible() || commentManager.getFreeTextCommentHandler().isPopupVisible();
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        if (this.mDocumentManager != null) {
            ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
            docViewManager.releaseOffscreenTiles(true);
            lockAndTrimCache(docViewManager.getNativeDocViewManager(), true);
        }
    }

    @Override
    public boolean onMenuOpened(int i, Menu menu) {
        if (i == 8 && menu != null) {
            exitActiveHandler();
        }
        return super.onMenuOpened(i, menu);
    }

    @Override
    public void onNewIntentRAW(Intent intent) {
        super.onNewIntentRAW(intent);
        if (ARApp.getIsModal()) {
            return;
        }
        actOnIntent(intent, false);
    }

    @Override
    public boolean onOptionsItemSelected(android.view.MenuItem r11) {
        throw new UnsupportedOperationException("Method not decompiled: com.adobe.reader.viewer.ARViewerActivity.onOptionsItemSelected(android.view.MenuItem):boolean");
    }

    @Override
    public void onPauseRAW() {
        super.onPauseRAW();
        ARDCMAnalytics.getInstance().pauseCollectingLifecycleData();
        unregisterTouchExplorationStateChangedListener();
        AREMMManager.getInstance().unregisterRestrictionChangedReceivers(getApplicationContext(), this.mBroadcastReceiverOnEMMRestrictionsChanged);
        clearSearchFocus();
        if (this.mScreenWakeTimer != null) {
            this.mScreenWakeTimer.cancel();
            this.mScreenWakeTimer.purge();
            this.mScreenWakeTimer = null;
        }
        if (this.mIsDisplayOn) {
            clearScreenOnFlag();
        }
        if (this.mPortfolio != null) {
            this.mPortfolio.cancelFileDownload();
        }
        hidePreviousPositionLink();
        hidePopOverView();
        AREMMManager.getInstance().dismissEMMDialog();
    }

    @Override
    public boolean onPrepareOptionsMenu(android.view.Menu r13) {
        throw new UnsupportedOperationException("Method not decompiled: com.adobe.reader.viewer.ARViewerActivity.onPrepareOptionsMenu(android.view.Menu):boolean");
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
        if (this.mDocumentManager == null || !z) {
            return;
        }
        showPageIndexOverlay();
    }

    @Override
    public void onResumeRAW() {
        super.onResumeRAW();
        registerTouchExplorationStateChangedListener();
        if (AREMMManager.getInstance().checkAppRestrictions(getApplicationContext(), false)) {
            closeCloudDocument();
        }
        ARDCMAnalytics.getInstance().collectLifecycleData();
        AREMMManager.getInstance().registerRestrictionChangedReceivers(getApplicationContext(), this.mBroadcastReceiverOnEMMRestrictionsChanged);
        Iterator<OnActivityResumeListener> it = this.mOnActivityResumeClients.iterator();
        while (it.hasNext()) {
            it.next().onActivityResume();
        }
        this.mIsDisplayOn = ARApp.getAppContext().getSharedPreferences(ARApp.ADOBE_READER_PREFERENCES, 0).getBoolean(ARSettingsActivity.DISPLAY_ON_KEY, false);
        if (this.mIsDisplayOn) {
            resetScreenLockTimer();
        }
        if (this.mDocumentManager != null) {
            this.mDocumentManager.getDocViewManager().appResume();
            if (isAccessibilityEnabled()) {
                onEnterAccessibilityMode();
            }
            this.mBottomToolbar.refresh();
        }
        didResume();
        AREMMManager.getInstance().showEMMDialog(this);
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        if (this.mDocumentManager != null) {
            ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
            if (docViewManager != null) {
                docViewManager.setAnalyticsFlagStatus(6, true);
                docViewManager.exitActiveHandlers();
            }
            this.mDocumentManager.setPreviousPosition();
        }
        showPageIndexOverlay();
        hidePanels();
        this.mIsTrackingSeekbar = true;
        this.mScrubberChangedDirectly = true;
    }

    @Override
    public void onStop() {
        super.onStop();
        if (this.mDocumentManager != null) {
            ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
            docViewManager.appPause(false);
            lockAndTrimCache(docViewManager.getNativeDocViewManager(), false);
        }
        willPause();
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        this.mIsTrackingSeekbar = false;
        this.mScrubberChangedDirectly = false;
        fadePageIndexOverlay(false);
        showPreviousPositionLink();
        resetTimerHandlerForUIElems();
    }

    @Override
    public void onToolSwitcherStateChanged(boolean z, boolean z2) {
        super.onToolSwitcherStateChanged(z, z2);
        if (z2 || !z) {
            return;
        }
        exitActiveHandler();
    }

    public void openExtractedAttachment(String str, String str2) {
        this.mLCRMDlg.cancel();
        this.mPasswdAlert.dismiss();
        this.mCurrentDocPath = str;
        this.mHasPendingErr = false;
        this.mNewDocumentOpened = true;
        openDocument(this.mCurrentDocPath, null, null, false, true, str2);
    }

    public void openNonPDFFile(String str) {
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.setFlags(268435456);
        intent.addFlags(1);
        try {
            intent.setDataAndType(FileProvider.getUriForFile(this, ARApp.getContentProviderAuthority(), new File(str)), BBFileUtils.j(str));
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(ARApp.getAppContext(), getString(R.string.IDS_NO_SUPPORTED_APP), ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
        } catch (IllegalArgumentException e2) {
            Toast.makeText(ARApp.getAppContext(), getString(R.string.IDS_UNABLE_TO_SAVE_STREAM_AS_TEMPORARY_FILE), ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
        }
    }

    public void popFormsMenu() {
        if (this.mIsInFormsMode) {
            this.mIsInFormsMode = false;
            invalidateOptionsMenu();
            this.mActionBar.setDisplayOptions(14);
            unlockSwitcher();
            showScrubberAndBottomBar();
            updateActionBar();
            showTopBar();
        }
    }

    public void portfolioDocLoaded(ARDocLoaderManager aRDocLoaderManager, ARPortfolioViewManager aRPortfolioViewManager) {
        if (!HasPendingError() && !isPasswordDialogShown()) {
            setDocTitle();
            this.mPortfolio = new ARPortfolio(this);
            setPortfolioViewManager(aRPortfolioViewManager, true);
            showUIElems();
        }
        sendHideProgressDialogMessage();
        File file = new File(this.mCurrentDocPath);
        ARDCMAnalytics.getInstance().trackOpenDocumentActionWithTotalPages(null, ARDCMAnalytics.DOCUMENT_TYPE_PORTFOLIO, getSecurityHandlerName(aRPortfolioViewManager.getSecurityHandlerType()), ARUtils.getFileRangeString(file.exists() ? file.length() : 0L), docSourceType(), docFileListSourceType());
    }

    public void postToUIThread(long j, boolean z) {
        ARUIRunnable aRUIRunnable = new ARUIRunnable(j, Thread.currentThread(), z, this);
        if (z) {
            this.mIsBackgroundThreadWaiting = true;
        }
        runOnUiThread(aRUIRunnable);
        if (z) {
            waitCallingThread();
        }
    }

    public void postToUIThreadDelayed(long j, int i) {
        this.mUIHandler.postDelayed(new ARUIRunnable(j, Thread.currentThread(), false, this), i);
    }

    public void pushFormsMenu(int i) {
        this.mIsInFormsMode = true;
        this.mActionBarMenu.clear();
        this.mActionBar.setDisplayShowHomeEnabled(false);
        hideBottomBar();
        this.mActionBar.setCustomView((ViewGroup) getLayoutInflater().inflate(i, (ViewGroup) null));
        this.mActionBar.setDisplayOptions(16);
        lockSwitcher();
        this.mActionBar.setDisplayShowCustomEnabled(true);
        showTopBar();
    }

    public void pushInkMenu() {
        getToolbar().setVisibility(8);
        setInInkDrawingMode(true);
        this.mActionBarMenu.clear();
        this.mActionBar.setDisplayShowHomeEnabled(false);
        ViewGroup viewGroup = (ViewGroup) getLayoutInflater().inflate(R.layout.ink_actionbar, (ViewGroup) null);
        lockSwitcher();
        this.mActionBar.setCustomView(viewGroup);
        this.mActionBar.setDisplayOptions(16);
        this.mActionBar.setDisplayShowCustomEnabled(true);
        updateActionBar();
        showTopBar();
    }

    public void pushToPortfolioStack(ARPortfolioStackEntry aRPortfolioStackEntry) {
        this.mPortfolioStack.pushToStack(aRPortfolioStackEntry);
    }

    public void registerOnActivityResumeClient(OnActivityResumeListener onActivityResumeListener) {
        this.mOnActivityResumeClients.add(onActivityResumeListener);
    }

    public void resetActionBarForInkHandler() {
        getInkToolbar().cleanUp();
        this.mActionBar.setDisplayOptions(14);
        unlockSwitcher();
        this.mActionBarMenu.clear();
        onCreateOptionsMenu(this.mActionBarMenu);
        updateActionBar();
    }

    public void resetScreenLockTimer() {
        if (this.mScreenWakeTimer != null) {
            this.mScreenWakeTimer.cancel();
            this.mScreenWakeTimer.purge();
            this.mScreenWakeTimer = null;
        }
        if (this.mTimerTask != null) {
            this.mTimerTask.cancel();
            this.mTimerTask = null;
        }
        if (this.mIsDisplayOn) {
            acquireScreenOnFlag();
            this.mScreenWakeTimer = new Timer();
            this.mTimerTask = new ReleaseScreenDimTimerTask();
            this.mScreenWakeTimer.schedule(this.mTimerTask, 1800000L);
        }
    }

    public void resetTimerHandlerForUIElems() {
        updatePageIndexOverlayAndScrubber();
        this.mUIElemsHandler.removeMessages(1);
        Message message = new Message();
        message.what = 1;
        this.mUIElemsHandler.sendMessageDelayed(message, UI_ELEMS_DURATION);
    }

    public void restartPreviousPortfolioFromStack() {
        File file = new File(this.mCurrentDocPath);
        if (file.exists() && BBFileUtils.c(file, getCacheDir())) {
            file.delete();
        }
        closeDocument();
        ARPortfolioStackEntry popFromStack = this.mPortfolioStack.popFromStack();
        openPortfolioDoc(popFromStack.getFilePathOnDisk(), true, popFromStack.getParentDir(), popFromStack.getLastViewedPosition(), popFromStack.getCloudFileID(), popFromStack.getCloudSource());
    }

    public void sendHideProgressDialogMessage() {
        this.mProgressDialogHandler.removeMessages(1);
        hideProgressDialog();
    }

    public void sendShowProgressDialogMessage(int i, PROGRESS_DIALOG_CONTEXT progress_dialog_context) {
        this.mProgressDialogContext = progress_dialog_context;
        Message obtain = Message.obtain();
        obtain.what = 1;
        this.mProgressDialogHandler.sendMessageDelayed(obtain, i);
    }

    public void setActivityTheme() {
        try {
            if (this.mActionBar != null) {
                resetToolSwitcher();
                if (ARApp.getNightModePreference()) {
                    setTheme(R.style.Theme_OverlayActionBarDarkTheme);
                    this.mActionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.action_bar_dark)));
                    setActionBarTitleColor();
                } else {
                    setTheme(R.style.Theme_OverlayActionBarLightTheme);
                    this.mActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.top_action_bar_background));
                    setActionBarTitleColor();
                }
                ARViewerBottomToolbar aRViewerBottomToolbar = (ARViewerBottomToolbar) getBottomBar().findViewById(R.id.viewer_bottom_bar);
                if (aRViewerBottomToolbar != null) {
                    aRViewerBottomToolbar.setTheme();
                }
                this.mAuthorDlg = new ARCommentAuthorDialog(this, getCurrentTheme(), new ARCommentAuthorDialog.OnAuthorPreferenceSet() {
                    @Override
                    public void onAuthorPreferenceSet() {
                        if (ARViewerActivity.this.mDocumentManager != null) {
                            ARViewerActivity.this.mDocumentManager.getDocViewManager().getCommentManager().continueCommentCreation();
                        }
                    }
                });
                this.mGotoPageDlg = new ARGotoPageDialog(this, getCurrentTheme());
                setActionBarIconFilter();
                updatePageIndexOverlayAndScrubber();
                if (this.mSearchView != null) {
                    this.mSearchView.setQuery(ARFileEntry.DEFAULT_ENTRY_ICON_STRING, false);
                }
                if (this.mViewPager != null) {
                    this.mViewPager.setMarginDrawable();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setDocTitle() {
        ViewGroup viewGroup;
        if (isAttachmentsViewVisible()) {
            this.mActionBar.setTitle(getString(R.string.IDS_ATTACHMENTS_STR));
            View findViewById = findViewById(android.R.id.home);
            if (findViewById == null || (viewGroup = (ViewGroup) findViewById.getParent()) == null) {
                return;
            }
            View childAt = viewGroup.getChildAt(0);
            if (childAt instanceof ImageView) {
                ((ImageView) childAt).setImageResource(R.drawable.h_back);
                this.mActionBar.setHomeButtonEnabled(true);
            }
        }
    }

    public void setInDocViewMode(boolean z) {
        this.mIsInDocumentViewMode = z;
        if (z) {
            hideTopBar();
            updateActionBar();
            showTopBar();
        }
    }

    public void setInInkDrawingMode(boolean z) {
        if (this.mDocumentManager != null && !z) {
            this.mDocumentManager.getDocViewManager().getCommentManager().notifyToolDeselected();
            this.mDocumentManager.getDocViewManager().getCommentManager().getInkCommentHandler().setInkToolMode(0);
        }
        this.mInInkDrawingMode = z;
    }

    public void setInSignatureMode(boolean z) {
        this.mInSignatureMode = z;
    }

    public void setPortfolioViewManager(ARPortfolioViewManager aRPortfolioViewManager, boolean z) {
        if (aRPortfolioViewManager == null) {
            ShowErrorDlg(R.string.IDS_ERR_CANT_OPEN, 0, ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
            return;
        }
        this.mHasAttachment = aRPortfolioViewManager.hasAttachments();
        this.mPortfolio.setPortfolioViewManager(aRPortfolioViewManager);
        if (z) {
            if (!HasPendingError() && !isPasswordDialogShown()) {
                this.mPortfolio.launchUI(this.mPortfolioBrowserDirectory);
                this.mPortfolioBrowserDirectory = null;
            }
        } else if (isAttachmentDoc(this.mCurrentDocPath)) {
            Toast.makeText(ARApp.getAppContext(), R.string.IDS_TOOL_ATTACHMENT_ERROR_DESC, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
        } else if (ARFileBrowserUtils.isCachedFile(this.mCurrentDocPath)) {
            Toast.makeText(ARApp.getAppContext(), R.string.IDS_NO_SDCARD_MODIFICATION_STR, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
        }
        if (this.mHasAttachment && this.mNewDocumentOpened) {
            this.mPortfolio.openDefaultAttachmentIfAny();
        }
        this.mNewDocumentOpened = false;
    }

    public void setScrubberVisibilty() {
        if (this.mDocumentManager == null) {
            this.mScrubber.setVisibility(8);
            return;
        }
        if (this.mDocumentManager.getDocViewManager().getNumPages() < 3 || !this.mBottomToolbar.showPageIndexOverlay()) {
            this.mScrubber.setVisibility(8);
            return;
        }
        if (this.mCurrentViewMode == 1 || this.mCurrentViewMode == 3) {
            this.mScrubber = (ARVerticalScrubber) findViewById(R.id.verticalScrubber);
            findViewById(R.id.scrubber).setVisibility(8);
        } else {
            this.mScrubber = (ARHorizontalScrubber) findViewById(R.id.scrubber);
            findViewById(R.id.verticalScrubber).setVisibility(8);
            this.mScrubber.animate().translationY(0.0f).setDuration(50L);
        }
        this.mScrubber.setVisibility(0);
        updatePageIndexOverlayAndScrubber();
        showScrubberFTE();
    }

    public void shareDocument(final String str) {
        boolean z = true;
        if (this.mCurrentDocPath == null) {
            return;
        }
        hidePanels();
        this.mDocLoaderManager.doSave(false);
        this.mSharedFilePath = ARFileBrowserUtils.getFilePathForDirectory(ARFileBrowserUtils.getTempFileCopyPath(), BBFileUtils.a(this.mCurrentDocPath), true);
        final ARDocViewManager docViewManager = this.mDocumentManager != null ? this.mDocumentManager.getDocViewManager() : null;
        File file = new File(ARFileBrowserUtils.getTempFileCopyPath());
        if (!file.exists()) {
            file.mkdirs();
        }
        boolean z2 = !com.adobe.libs.buildingblocks.utils.n.a();
        boolean z3 = this.mCloudFileID != null && com.adobe.libs.services.b.a.a() == d.CACHE_LOCATION_INTERNAL_VALUE;
        boolean c = BBFileUtils.c(this.mCurrentDocPath, ARFileBrowserUtils.getDirectoryPathForSAF());
        if (!z2 || (!z3 && !c)) {
            z = false;
        }
        if (z) {
            new ARAlert(this, new ARAlert.DialogProvider() {
                @Override
                public Dialog getDialog() {
                    ARAlertDialog aRAlertDialog = new ARAlertDialog(ARViewerActivity.this);
                    aRAlertDialog.setTitle(ARApp.getAppContext().getString(R.string.IDS_SHARE_APP_CHOOSER_TITLE));
                    aRAlertDialog.setMessage(ARApp.getAppContext().getString(R.string.IDS_ADC_SHARE_CONFIRMATION_STR));
                    aRAlertDialog.setButton(-1, ARApp.getAppContext().getString(2131230739), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                            f fVar = f.COPY_FILE_FAILURE;
                            if (!(docViewManager != null ? docViewManager.createFlattenedCopy(ARViewerActivity.this.mSharedFilePath, ARCommentsManager.ANNOTS_TO_FLATTEN.INK_SIGNATURE) : false)) {
                                fVar = BBFileUtils.a(new File(ARViewerActivity.this.mCurrentDocPath), new File(ARViewerActivity.this.mSharedFilePath));
                            }
                            if (fVar == f.COPY_FILE_NO_SPACE_EXCEPTION) {
                                ARViewerActivity.this.ShowErrorDlg(R.string.IDS_ERR_SHARE_NOSPACE, 1, ARFileEntry.DEFAULT_ENTRY_ICON_STRING);
                            } else {
                                ARViewerActivity.this.shareDocumentInternal(ARViewerActivity.this.mSharedFilePath, str);
                            }
                        }
                    });
                    aRAlertDialog.setButton(-2, ARApp.getAppContext().getString(2131230745), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    });
                    return aRAlertDialog;
                }
            }).show();
        } else if (docViewManager == null || !docViewManager.createFlattenedCopy(this.mSharedFilePath, ARCommentsManager.ANNOTS_TO_FLATTEN.INK_SIGNATURE)) {
            shareDocumentInternal(this.mCurrentDocPath, str);
        } else {
            shareDocumentInternal(this.mSharedFilePath, str);
        }
    }

    public void shareLink() {
        if (this.mCloudFileID != null) {
            this.mFileLinkShareHandler = ARBlueHeronFileShareHandler.share(sCurrentActivity, this.mCloudFileID, this.mCloudSource, this.mCurrentDocPath, new ARBlueHeronFileShareHandler.ARBlueHeronOnFileShareCompletionListener() {
                @Override
                public void onFinish() {
                    ARViewerActivity.this.mFileLinkShareHandler = null;
                }
            });
        }
    }

    public void showAuthorDialog() {
        this.mAuthorDlg.show();
    }

    public void showGotoPageDialog() {
        ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
        docViewManager.exitActiveHandlers();
        if (docViewManager.getNumPages() > 1) {
            hidePanels();
            this.mGotoPageDlg.show();
        }
    }

    public void showLCRMDialog(long j, boolean z, String str, String str2, String str3, String str4, String str5, boolean z2, boolean z3) {
        this.mLCRMDlg = new ARLCRMDialog(this);
        this.mLCRMDlg.show(j, z, str, str2, str3, str4, str5, z2, z3);
    }

    public void showListView() {
        if (isPortfolioListViewVisible()) {
            return;
        }
        findViewById(R.id.viewPager).setVisibility(8);
        findViewById(R.id.reflowViewPager).setVisibility(8);
        findViewById(R.id.portfolioLayout).setVisibility(0);
        showTopBar();
        setDocTitle();
        this.mBottomToolbar.push(new ARNoToolbar(this));
    }

    protected void showOrHideUIElemsForTap() {
        ARPageView activePageView;
        String str = null;
        if (this.mShowingUIElems) {
            fadeOutUIElems(false);
            if (!this.mShowingUIElems) {
                str = getString(R.string.IDS_TOOLBAR_HIDDEN_ACCESSIBILITY_STR);
            }
        } else {
            showUIElems();
            str = getString(R.string.IDS_TOOLBAR_SHOWN_ACCESSIBILITY_STR);
        }
        if (Build.VERSION.SDK_INT < 16 || str == null || (activePageView = this.mDocumentManager.getActivePageView()) == null) {
            return;
        }
        activePageView.announceForAccessibility(str);
    }

    public void showPreviousPositionLink() {
        if (this.mDocumentManager == null || this.mDocumentManager.getDocViewManager().getViewMode() == 3) {
            return;
        }
        resetTimer();
        this.mGotoPageDlg.setPreviousPageNumberLinkVisibility(true);
    }

    public void showScrubberAndBottomBar() {
        this.mBottomBarLayout.animate().translationY(0.0f).setDuration(200L);
        this.mBottomBarLayout.setVisibility(0);
        setScrubberVisibilty();
    }

    public void showSearch(boolean z) {
        this.mIsSearchViewExpanded = z;
        if (this.mIsSearchViewExpanded) {
            hideBottomBar();
        } else {
            showScrubberAndBottomBar();
        }
        updateAppSwitcher(!this.mIsSearchViewExpanded);
        if (this.mSearchView != null) {
            ARUtils.hideKeyboard(this.mSearchView);
        }
        updateActionBar();
    }

    public void showTopBar() {
        View findViewById = findViewById(R.id.topBarLayout);
        this.mActionBar.show();
        findViewById.setVisibility(8);
    }

    public void showUIElems() {
        this.mShowingUIElems = true;
        clearAnimationsForUIElems();
        showTopBar();
        if (isPortfolioListViewVisible()) {
            return;
        }
        showScrubberAndBottomBar();
        resetTimerHandlerForUIElems();
    }

    public void standardDocLoaded(ARDocumentManager aRDocumentManager, ARPortfolioViewManager aRPortfolioViewManager, boolean z) {
        setDocTitle();
        this.mPortfolio = new ARAttachments(this);
        this.mDocumentManager = aRDocumentManager;
        ARViewerBottomToolbar aRViewerBottomToolbar = (ARViewerBottomToolbar) ((LayoutInflater) getSystemService("layout_inflater")).inflate(R.layout.viewer_bottom_toolbar, (ViewGroup) null);
        aRViewerBottomToolbar.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
        this.mBottomToolbar.push(aRViewerBottomToolbar);
        setPortfolioViewManager(aRPortfolioViewManager, z);
        ARDocViewManager docViewManager = this.mDocumentManager.getDocViewManager();
        if (isFileReadOnly() && (docViewManager.isAcroForm() || docViewManager.isXFAForm())) {
            displayAlertForReadOnlyFiles(null);
        }
        sendHideProgressDialogMessage();
        File file = new File(this.mCurrentDocPath);
        ARDCMAnalytics.getInstance().trackOpenDocumentActionWithTotalPages(String.valueOf(docViewManager.getNumPages()), getDocumentTypeName(docViewManager), getSecurityHandlerName(docViewManager.getSecurityHandlerType()), ARUtils.getFileRangeString(file.exists() ? file.length() : 0L), docSourceType(), docFileListSourceType());
        this.mCurrentViewMode = this.mDocumentManager.getDocViewManager().getViewMode();
    }

    @Override
    public void startActivityForResult(Intent intent, int i) {
        super.startActivityForResult(intent, i);
        if (i != -1) {
            this.mActivityStartedForResult = true;
        }
    }

    public void swapCloudDocFilePath(String str, String str2) {
        if (this.mCloudFileID == null || !BBFileUtils.c(this.mCurrentDocPath, str)) {
            return;
        }
        swapCurrentDocFilePath(this.mCurrentDocPath.replaceFirst(str, str2));
    }

    public void switchToViewerTool() {
        switchToDefaultTool(true);
    }

    public void unlockToolbar() {
        this.mDontHideUIElements = false;
        resetTimerHandlerForUIElems();
    }

    public void unregisterOnActivityResumeClient(OnActivityResumeListener onActivityResumeListener) {
        this.mOnActivityResumeClients.remove(onActivityResumeListener);
    }

    public void updateActionBar() {
        if (this.mActionBarMenu == null || this.mActionBarMenu.size() == 0) {
            return;
        }
        onPrepareOptionsMenu(this.mActionBarMenu);
    }

    @Override
    public void updateAppSwitcher(boolean z) {
        if (z) {
            unlockSwitcher();
        } else {
            lockSwitcher();
        }
    }

    public void updatePageIndexOverlayAndScrubber() {
        ARPageView activePageView;
        View findViewById = findViewById(R.id.pageIndexOverlay);
        int numPages = this.mDocumentManager != null ? this.mDocumentManager.getDocViewManager().getNumPages() : 0;
        if (numPages == 0 || isPortfolioListViewVisible() || !this.mBottomToolbar.showPageIndexOverlay()) {
            hidePageIndexOverlay();
            return;
        }
        PageID pageIDForDisplay = this.mDocumentManager.getPageIDForDisplay();
        setPageIndexText(findViewById, pageIDForDisplay.getPageIndex() + 1, numPages);
        if (this.mScrubber != null) {
            if (this.mCurrentViewMode != 1) {
                this.mScrubber.setMax(numPages - 1);
                this.mScrubber.setProgress(pageIDForDisplay.getPageIndex());
            } else if (this.mDocumentManager != null && !this.mScrubberChangedDirectly && (activePageView = this.mDocumentManager.getActivePageView()) != null) {
                int scrollY = activePageView.getScrollY();
                this.mScrubber.setMax(this.mDocumentManager.getDocViewManager().getGalleyHeight(new PageID(), this.mDocumentManager.getDocViewManager().getZoomLevel()) - getScreenHeight());
                this.mScrubber.setProgress(scrollY);
            }
            this.mScrubber.setThumb(writeOnDrawable(getScrubberThumbDrawable(), Integer.toString(pageIDForDisplay.getPageIndex() + 1)));
        }
        updateUserAddedBookmark(pageIDForDisplay);
    }

    public void updatePositionInRecentlyViewed(String str, ARLastViewedPosition aRLastViewedPosition) {
        if (aRLastViewedPosition.mViewMode != 4) {
            String str2 = this.mCloudFileID;
            if (str2 == null) {
                str2 = ARRecentsFilesManager.getCloudIDForFilePath(this.mCurrentDocPath);
            }
            if (str2 != null) {
                int pageIndex = aRLastViewedPosition.getPageIndex();
                n.a(str2, pageIndex);
                new ARBlueHeronUpdateLastViewedPageIndexAsyncTask(str2, pageIndex).taskExecute(new Void[0]);
            }
            ARRecentsFilesManager.updateRecentPosition(aRLastViewedPosition, str, this.mCloudFileID, e.a());
        }
    }

    @Override
    public void updateUndoRedoMenu(Menu menu, int i, int i2) {
        MenuItem findItem;
        boolean z = false;
        if (menu == null || (findItem = menu.findItem(i)) == null) {
            return;
        }
        boolean canUndo = this.mDocumentManager != null ? this.mDocumentManager.canUndo() : false;
        boolean canRedo = this.mDocumentManager != null ? this.mDocumentManager.canRedo() : false;
        if ((canUndo || canRedo) && !this.mIsSearchViewExpanded) {
            z = true;
        }
        findItem.setVisible(z);
        findItem.setEnabled(canUndo);
        if (canUndo) {
            findItem.setTitle(this.mDocumentManager.getUndoString());
        } else {
            findItem.setTitle(R.string.IDS_ACTION_BAR_UNDO_STR);
        }
        MenuItem findItem2 = menu.findItem(i2);
        findItem2.setVisible(z);
        findItem2.setEnabled(canRedo);
        if (canRedo) {
            findItem2.setTitle(this.mDocumentManager.getRedoString());
        } else {
            findItem2.setTitle(R.string.IDS_ACTION_BAR_REDO_STR);
        }
    }

    @Override
    public void updateUndoRedoMenuItems() {
        updateUndoRedoMenu(this.mActionBarMenu, R.id.document_view_undo, R.id.document_view_redo);
    }

    public void updateUserAddedBookmark(PageID pageID) {
        if (this.mActionBarMenu == null || !this.mIsInDocumentViewMode || this.mDocumentManager == null) {
            return;
        }
        ARBookmarkManager bookmarkManager = this.mDocumentManager.getDocViewManager().getBookmarkManager();
        MenuItem findItem = this.mActionBarMenu.findItem(R.id.document_view_addBookmark);
        if (bookmarkManager == null || findItem == null) {
            return;
        }
        if (bookmarkManager.pageHasUserBookmark(pageID.getPageIndex())) {
            findItem.setIcon(R.drawable.v_bookmarkadded);
            findItem.setTitle(R.string.IDS_ACTION_BAR_REMOVE_BOOKMARK_STR);
        } else {
            findItem.setIcon(R.drawable.v_bookmarks);
            findItem.setTitle(R.string.IDS_ACTION_BAR_ADD_BOOKMARK_STR);
        }
        setActionBarIconFilter();
    }

    public void updateViewMode(int i) {
        this.mCurrentViewMode = i;
        setScrubberVisibilty();
    }

    @Override
    public boolean usesNatives() {
        return true;
    }

    public void wakeupCallingThread(Thread thread) {
        this.mIsBackgroundThreadWaiting = false;
        synchronized (this.mRunnableSyncObject) {
            this.mRunnableSyncObject.notify();
        }
    }

    public void wrapperSecurityViewDialog() {
        ARDocViewManager docViewManager;
        ARSecurityManager securityManager;
        if (this.mDocumentManager == null || (docViewManager = this.mDocumentManager.getDocViewManager()) == null || (securityManager = docViewManager.getSecurityManager()) == null) {
            return;
        }
        securityManager.handleDocSecurity();
    }

    void wrapperSwitchToCommentTool() {
        switchToTool(3, false);
    }
}