正在查看: St.John's v1.0.9 应用的 FolioActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 FolioActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.folioreader.ui.activity;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.folioreader.Config;
import com.folioreader.Constants;
import com.folioreader.FolioReader;
import com.folioreader.R;
import com.folioreader.model.DisplayUnit;
import com.folioreader.model.HighlightImpl;
import com.folioreader.model.event.MediaOverlayPlayPauseEvent;
import com.folioreader.model.locators.ReadLocator;
import com.folioreader.model.locators.SearchLocator;
import com.folioreader.ui.activity.SearchActivity;
import com.folioreader.ui.adapter.FolioPageFragmentAdapter;
import com.folioreader.ui.adapter.SearchAdapter;
import com.folioreader.ui.fragment.FolioPageFragment;
import com.folioreader.ui.fragment.MediaControllerFragment;
import com.folioreader.ui.view.ConfigBottomSheetDialogFragment;
import com.folioreader.ui.view.DirectionalViewpager;
import com.folioreader.ui.view.FolioAppBarLayout;
import com.folioreader.ui.view.FolioWebView;
import com.folioreader.ui.view.MediaControllerCallback;
import com.folioreader.util.AppUtil;
import com.folioreader.util.FileUtil;
import com.folioreader.util.UiUtil;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.TypeCastException;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import kotlin.text.StringsKt;
import org.greenrobot.eventbus.EventBus;
import org.readium.r2.shared.Link;
import org.readium.r2.shared.Publication;
import org.readium.r2.streamer.container.Container;
import org.readium.r2.streamer.parser.CbzParser;
import org.readium.r2.streamer.parser.EpubParser;
import org.readium.r2.streamer.parser.PubBox;
import org.readium.r2.streamer.server.Server;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0082\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\b\u0003\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0007\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\r\n\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0015\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0016*\u0002\r;\u0018\u0000 \u0091\u00012\u00020\u00012\u00020\u00022\u00020\u00032\u00020\u0004:\u0006\u0091\u0001\u0092\u0001\u0093\u0001B\u0005¢\u0006\u0002\u0010\u0005J\b\u0010K\u001a\u00020LH\u0002J\b\u0010M\u001a\u00020NH\u0002J\b\u0010O\u001a\u00020LH\u0002J\u000e\u0010P\u001a\b\u0012\u0004\u0012\u00020\u00000QH\u0016J\u0010\u0010R\u001a\u00020\u00102\u0006\u0010S\u001a\u00020TH\u0016J\u0012\u0010U\u001a\u00020\u00102\b\u0010V\u001a\u0004\u0018\u00010\u001eH\u0002J\u0018\u0010U\u001a\u00020\u00102\u0006\u0010W\u001a\u00020\u000b2\u0006\u0010X\u001a\u00020\u000bH\u0002J\b\u0010Y\u001a\u00020\u0010H\u0016J\b\u0010Z\u001a\u00020\u0018H\u0016J\n\u0010[\u001a\u0004\u0018\u00010\u001eH\u0016J\b\u0010\\\u001a\u00020\u000bH\u0016J\u0010\u0010]\u001a\u00020\u00102\u0006\u0010S\u001a\u00020TH\u0016J\u0010\u0010^\u001a\u00020N2\u0006\u0010S\u001a\u00020TH\u0016J\u0010\u0010_\u001a\u00020\u001c2\u0006\u0010`\u001a\u00020\u000bH\u0016J\b\u0010a\u001a\u00020LH\u0002J\b\u0010b\u001a\u00020LH\u0002J\b\u0010c\u001a\u00020LH\u0002J\u0012\u0010d\u001a\u00020L2\b\u00104\u001a\u0004\u0018\u00010.H\u0002J\b\u0010e\u001a\u00020LH\u0002J\"\u0010f\u001a\u00020L2\u0006\u0010g\u001a\u00020\u00102\u0006\u0010h\u001a\u00020\u00102\b\u0010i\u001a\u0004\u0018\u00010jH\u0014J\b\u0010k\u001a\u00020LH\u0002J\b\u0010l\u001a\u00020LH\u0002J\u0012\u0010m\u001a\u00020L2\b\u00104\u001a\u0004\u0018\u00010.H\u0014J\u0010\u0010n\u001a\u00020\u001c2\u0006\u0010o\u001a\u00020pH\u0016J\b\u0010q\u001a\u00020LH\u0014J\u0010\u0010r\u001a\u00020L2\u0006\u0010s\u001a\u00020\u0018H\u0016J\u0010\u0010t\u001a\u00020L2\u0006\u0010u\u001a\u00020jH\u0014J\u0010\u0010v\u001a\u00020\u001c2\u0006\u0010w\u001a\u00020xH\u0016J\u0012\u0010y\u001a\u00020L2\b\u00104\u001a\u0004\u0018\u00010.H\u0014J+\u0010z\u001a\u00020L2\u0006\u0010g\u001a\u00020\u00102\f\u0010{\u001a\b\u0012\u0004\u0012\u00020\u000b0|2\u0006\u0010}\u001a\u00020~H\u0016¢\u0006\u0002\u0010\u007fJ\t\u0010\u0080\u0001\u001a\u00020LH\u0014J\u0011\u0010\u0081\u0001\u001a\u00020L2\u0006\u0010-\u001a\u00020.H\u0014J\t\u0010\u0082\u0001\u001a\u00020LH\u0014J\u0012\u0010\u0083\u0001\u001a\u00020L2\u0007\u0010\u0084\u0001\u001a\u00020\u0010H\u0016J\t\u0010\u0085\u0001\u001a\u00020LH\u0016J\t\u0010\u0086\u0001\u001a\u00020LH\u0016J\u0013\u0010\u0087\u0001\u001a\u00020L2\b\u00104\u001a\u0004\u0018\u00010.H\u0002J\t\u0010\u0088\u0001\u001a\u00020LH\u0016J\t\u0010\u0089\u0001\u001a\u00020LH\u0016J\t\u0010\u008a\u0001\u001a\u00020LH\u0002J\u0007\u0010\u008b\u0001\u001a\u00020LJ\u0007\u0010\u008c\u0001\u001a\u00020LJ\t\u0010\u008d\u0001\u001a\u00020LH\u0002J\u0007\u0010\u008e\u0001\u001a\u00020LJ\u0011\u0010\u008f\u0001\u001a\u00020L2\u0006\u0010!\u001a\u00020\u001eH\u0016J\t\u0010\u0090\u0001\u001a\u00020LH\u0016R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u00020\rX\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u000eR\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0016\u0010\u0011\u001a\u0004\u0018\u00010\u00128BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0013\u0010\u0014R\u000e\u0010\u0015\u001a\u00020\u0016X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0019\u001a\u0004\u0018\u00010\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\u001cX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001d\u001a\u0004\u0018\u00010\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u001f\u001a\u0004\u0018\u00010 X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010!\u001a\u0004\u0018\u00010\u001eX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\"\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010#\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010$\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010%\u001a\u0004\u0018\u00010&X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010'\u001a\u0004\u0018\u00010(X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010)\u001a\u0004\u0018\u00010*X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010+\u001a\u0004\u0018\u00010,X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010-\u001a\u0004\u0018\u00010.X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010/\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00100\u001a\u0004\u0018\u000101X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00102\u001a\u0004\u0018\u000103X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00104\u001a\u0004\u0018\u00010.X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00105\u001a\u0004\u0018\u00010.X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00106\u001a\u0004\u0018\u000107X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u00108\u001a\u0004\u0018\u000109X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010:\u001a\u00020;X\u0082\u0004¢\u0006\u0004\n\u0002\u0010<R\u0010\u0010=\u001a\u0004\u0018\u00010>X\u0082\u000e¢\u0006\u0002\n\u0000R\u0016\u0010?\u001a\n\u0012\u0004\u0012\u00020A\u0018\u00010@X\u0082\u000e¢\u0006\u0002\n\u0000R\u0011\u0010B\u001a\u00020\u00108F¢\u0006\u0006\u001a\u0004\bC\u0010DR\u0010\u0010E\u001a\u0004\u0018\u00010>X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010F\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010G\u001a\u0004\u0018\u00010HX\u0082\u000e¢\u0006\u0002\n\u0000R\u0012\u0010I\u001a\u0004\u0018\u00010\u001cX\u0082\u000e¢\u0006\u0004\n\u0002\u0010J¨\u0006\u0094\u0001"}, d2 = {"Lcom/folioreader/ui/activity/FolioActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "Lcom/folioreader/ui/activity/FolioActivityCallback;", "Lcom/folioreader/ui/view/MediaControllerCallback;", "Landroid/view/View$OnSystemUiVisibilityChangeListener;", "()V", "actionBar", "Landroidx/appcompat/app/ActionBar;", "appBarLayout", "Lcom/folioreader/ui/view/FolioAppBarLayout;", "bookFileName", "", "closeBroadcastReceiver", "com/folioreader/ui/activity/FolioActivity$closeBroadcastReceiver$1", "Lcom/folioreader/ui/activity/FolioActivity$closeBroadcastReceiver$1;", "currentChapterIndex", "", "currentFragment", "Lcom/folioreader/ui/fragment/FolioPageFragment;", "getCurrentFragment", "()Lcom/folioreader/ui/fragment/FolioPageFragment;", "density", "", Config.CONFIG_DIRECTION, "Lcom/folioreader/Config$Direction;", "displayMetrics", "Landroid/util/DisplayMetrics;", "distractionFreeMode", "", "entryReadLocator", "Lcom/folioreader/model/locators/ReadLocator;", "handler", "Landroid/os/Handler;", "lastReadLocator", "mBookId", "mEpubFilePath", "mEpubRawId", "mEpubSourceType", "Lcom/folioreader/ui/activity/FolioActivity$EpubSourceType;", "mFolioPageFragmentAdapter", "Lcom/folioreader/ui/adapter/FolioPageFragmentAdapter;", "mFolioPageViewPager", "Lcom/folioreader/ui/view/DirectionalViewpager;", "mediaControllerFragment", "Lcom/folioreader/ui/fragment/MediaControllerFragment;", "outState", "Landroid/os/Bundle;", "portNumber", "pubBox", "Lorg/readium/r2/streamer/parser/PubBox;", "r2StreamerServer", "Lorg/readium/r2/streamer/server/Server;", "savedInstanceState", "searchAdapterDataBundle", "searchLocator", "Lcom/folioreader/model/locators/SearchLocator;", "searchQuery", "", "searchReceiver", "com/folioreader/ui/activity/FolioActivity$searchReceiver$1", "Lcom/folioreader/ui/activity/FolioActivity$searchReceiver$1;", "searchUri", "Landroid/net/Uri;", "spine", "", "Lorg/readium/r2/shared/Link;", "statusBarHeight", "getStatusBarHeight", "()I", "streamerUri", "taskImportance", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "topActivity", "Ljava/lang/Boolean;", "clearSearchLocator", "", "computeViewportRect", "Landroid/graphics/Rect;", "configFolio", "getActivity", "Ljava/lang/ref/WeakReference;", "getBottomDistraction", "unit", "Lcom/folioreader/model/DisplayUnit;", "getChapterIndex", "readLocator", "caseString", "value", "getCurrentChapterIndex", "getDirection", "getEntryReadLocator", "getStreamerUrl", "getTopDistraction", "getViewportRect", "goToChapter", Constants.HREF, "hideSystemUI", "initActionBar", "initBook", "initDistractionFreeMode", "initMediaController", "onActivityResult", "requestCode", "resultCode", "data", "Landroid/content/Intent;", "onBookInitFailure", "onBookInitSuccess", "onCreate", "onCreateOptionsMenu", "menu", "Landroid/view/Menu;", "onDestroy", "onDirectionChange", "newDirection", "onNewIntent", "intent", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onPostCreate", "onRequestPermissionsResult", "permissions", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "onResume", "onSaveInstanceState", "onStop", "onSystemUiVisibilityChange", "visibility", "pause", "play", "setConfig", "setDayMode", "setNightMode", "setupBook", "showConfigBottomSheetDialogFragment", "showMediaController", "showSystemUI", "startContentHighlightActivity", "storeLastReadLocator", "toggleSystemUI", "Companion", "EpubSourceType", "RequestCode", "folioreader_release"}, k = 1, mv = {1, 1, 13})
public final class FolioActivity extends AppCompatActivity implements FolioActivityCallback, MediaControllerCallback, View.OnSystemUiVisibilityChangeListener {
public static final String ACTION_SEARCH_CLEAR = "ACTION_SEARCH_CLEAR";
private static final String BUNDLE_DISTRACTION_FREE_MODE = "BUNDLE_DISTRACTION_FREE_MODE";
private static final String BUNDLE_READ_LOCATOR_CONFIG_CHANGE = "BUNDLE_READ_LOCATOR_CONFIG_CHANGE";
public static final String EXTRA_READ_LOCATOR = "com.folioreader.extra.READ_LOCATOR";
public static final String EXTRA_SEARCH_ITEM = "EXTRA_SEARCH_ITEM";
private static final String HIGHLIGHT_ITEM = "highlight_item";
public static final String INTENT_EPUB_SOURCE_PATH = "com.folioreader.epub_asset_path";
public static final String INTENT_EPUB_SOURCE_TYPE = "epub_source_type";
public static final String LOG_TAG;
private HashMap _$_findViewCache;
private ActionBar actionBar;
private FolioAppBarLayout appBarLayout;
private String bookFileName;
private int currentChapterIndex;
private float density;
private DisplayMetrics displayMetrics;
private boolean distractionFreeMode;
private ReadLocator entryReadLocator;
private Handler handler;
private ReadLocator lastReadLocator;
private String mBookId;
private String mEpubFilePath;
private int mEpubRawId;
private EpubSourceType mEpubSourceType;
private FolioPageFragmentAdapter mFolioPageFragmentAdapter;
private DirectionalViewpager mFolioPageViewPager;
private MediaControllerFragment mediaControllerFragment;
private Bundle outState;
private PubBox pubBox;
private Server r2StreamerServer;
private Bundle savedInstanceState;
private Bundle searchAdapterDataBundle;
private SearchLocator searchLocator;
private CharSequence searchQuery;
private Uri searchUri;
private List<Link> spine;
private Uri streamerUri;
private int taskImportance;
private Toolbar toolbar;
private Boolean topActivity;
private Config.Direction direction = Config.Direction.VERTICAL;
private int portNumber = Constants.DEFAULT_PORT_NUMBER;
private final FolioActivity$closeBroadcastReceiver$1 closeBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Object systemService;
Intrinsics.checkParameterIsNotNull(context, "context");
Intrinsics.checkParameterIsNotNull(intent, "intent");
String str = FolioActivity.LOG_TAG;
StringBuilder sb = new StringBuilder("-> closeBroadcastReceiver -> onReceive -> ");
String action = intent.getAction();
if (action == null) {
Intrinsics.throwNpe();
}
sb.append(action);
Log.v(str, sb.toString());
String action2 = intent.getAction();
if (action2 == null || !Intrinsics.areEqual(action2, FolioReader.ACTION_CLOSE_FOLIOREADER)) {
return;
}
try {
systemService = context.getSystemService("activity");
} catch (Exception e) {
Log.e(FolioActivity.LOG_TAG, "-> ", e);
}
if (systemService == null) {
throw new TypeCastException("null cannot be cast to non-null type android.app.ActivityManager");
}
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = ((ActivityManager) systemService).getRunningAppProcesses();
FolioActivity.this.taskImportance = runningAppProcesses.get(0).importance;
Intent intent2 = new Intent(FolioActivity.this.getApplicationContext(), (Class<?>) FolioActivity.class);
intent2.setFlags(603979776);
intent2.setAction(FolioReader.ACTION_CLOSE_FOLIOREADER);
FolioActivity.this.startActivity(intent2);
}
};
private final FolioActivity$searchReceiver$1 searchReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Intrinsics.checkParameterIsNotNull(context, "context");
Intrinsics.checkParameterIsNotNull(intent, "intent");
String str = FolioActivity.LOG_TAG;
StringBuilder sb = new StringBuilder("-> searchReceiver -> onReceive -> ");
String action = intent.getAction();
if (action == null) {
Intrinsics.throwNpe();
}
sb.append(action);
Log.v(str, sb.toString());
String action2 = intent.getAction();
if (action2 != null && action2.hashCode() == 1595694143 && action2.equals(FolioActivity.ACTION_SEARCH_CLEAR)) {
FolioActivity.this.clearSearchLocator();
}
}
};
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0002\b\u0005\b\u0086\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002j\u0002\b\u0003j\u0002\b\u0004j\u0002\b\u0005¨\u0006\u0006"}, d2 = {"Lcom/folioreader/ui/activity/FolioActivity$EpubSourceType;", "", "(Ljava/lang/String;I)V", "RAW", "ASSETS", "SD_CARD", "folioreader_release"}, k = 1, mv = {1, 1, 13})
public enum EpubSourceType {
RAW,
ASSETS,
SD_CARD
}
@Metadata(bv = {1, 0, 3}, k = 3, mv = {1, 1, 13})
public final class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
public static final int[] $EnumSwitchMapping$1;
public static final int[] $EnumSwitchMapping$2;
public static final int[] $EnumSwitchMapping$3;
static {
int[] iArr = new int[Publication.EXTENSION.values().length];
$EnumSwitchMapping$0 = iArr;
iArr[Publication.EXTENSION.EPUB.ordinal()] = 1;
iArr[Publication.EXTENSION.CBZ.ordinal()] = 2;
int[] iArr2 = new int[DisplayUnit.values().length];
$EnumSwitchMapping$1 = iArr2;
iArr2[DisplayUnit.PX.ordinal()] = 1;
iArr2[DisplayUnit.DP.ordinal()] = 2;
int[] iArr3 = new int[DisplayUnit.values().length];
$EnumSwitchMapping$2 = iArr3;
iArr3[DisplayUnit.PX.ordinal()] = 1;
iArr3[DisplayUnit.DP.ordinal()] = 2;
int[] iArr4 = new int[DisplayUnit.values().length];
$EnumSwitchMapping$3 = iArr4;
iArr4[DisplayUnit.PX.ordinal()] = 1;
iArr4[DisplayUnit.DP.ordinal()] = 2;
iArr4[DisplayUnit.CSS_PX.ordinal()] = 3;
}
}
private final void onBookInitFailure() {
}
public void _$_clearFindViewByIdCache() {
HashMap hashMap = this._$_findViewCache;
if (hashMap != null) {
hashMap.clear();
}
}
public View _$_findCachedViewById(int i) {
if (this._$_findViewCache == null) {
this._$_findViewCache = new HashMap();
}
View view = (View) this._$_findViewCache.get(Integer.valueOf(i));
if (view != null) {
return view;
}
View findViewById = findViewById(i);
this._$_findViewCache.put(Integer.valueOf(i), findViewById);
return findViewById;
}
static {
Intrinsics.checkExpressionValueIsNotNull("FolioActivity", "FolioActivity::class.java.simpleName");
LOG_TAG = "FolioActivity";
}
public final int getStatusBarHeight() {
int identifier = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (identifier > 0) {
return getResources().getDimensionPixelSize(identifier);
}
return 0;
}
private final FolioPageFragment getCurrentFragment() {
FolioPageFragmentAdapter folioPageFragmentAdapter = this.mFolioPageFragmentAdapter;
if (folioPageFragmentAdapter == null || this.mFolioPageViewPager == null) {
return null;
}
if (folioPageFragmentAdapter == null) {
Intrinsics.throwNpe();
}
DirectionalViewpager directionalViewpager = this.mFolioPageViewPager;
if (directionalViewpager == null) {
Intrinsics.throwNpe();
}
Fragment item = folioPageFragmentAdapter.getItem(directionalViewpager.getCurrentItem());
if (item != null) {
return (FolioPageFragment) item;
}
throw new TypeCastException("null cannot be cast to non-null type com.folioreader.ui.fragment.FolioPageFragment");
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0010\n\u0000\n\u0002\u0010\b\n\u0002\b\u0006\b\u0082\u0001\u0018\u00002\b\u0012\u0004\u0012\u00020\u00000\u0001B\u000f\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0014\u0010\u0002\u001a\u00020\u0003X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006j\u0002\b\u0007j\u0002\b\b¨\u0006\t"}, d2 = {"Lcom/folioreader/ui/activity/FolioActivity$RequestCode;", "", "value", "", "(Ljava/lang/String;II)V", "getValue$folioreader_release", "()I", "CONTENT_HIGHLIGHT", "SEARCH", "folioreader_release"}, k = 1, mv = {1, 1, 13})
private enum RequestCode {
CONTENT_HIGHLIGHT(77),
SEARCH(101);
private final int value;
RequestCode(int i) {
this.value = i;
}
public final int getValue() {
return this.value;
}
}
@Override
protected void onNewIntent(Intent intent) {
Intrinsics.checkParameterIsNotNull(intent, "intent");
super.onNewIntent(intent);
setIntent(intent);
Log.v(LOG_TAG, "-> onNewIntent");
Intent intent2 = getIntent();
Intrinsics.checkExpressionValueIsNotNull(intent2, "getIntent()");
String action = intent2.getAction();
if (action == null || !Intrinsics.areEqual(action, FolioReader.ACTION_CLOSE_FOLIOREADER)) {
return;
}
Boolean bool = this.topActivity;
if (bool == null || Intrinsics.areEqual(bool, false)) {
finish();
if (Build.VERSION.SDK_INT < 26) {
if (400 != this.taskImportance) {
return;
}
} else if (400 != this.taskImportance) {
return;
}
moveTaskToBack(true);
}
}
@Override
protected void onResume() {
super.onResume();
Log.v(LOG_TAG, "-> onResume");
this.topActivity = true;
Intent intent = getIntent();
Intrinsics.checkExpressionValueIsNotNull(intent, "intent");
String action = intent.getAction();
if (action == null || !Intrinsics.areEqual(action, FolioReader.ACTION_CLOSE_FOLIOREADER)) {
return;
}
finish();
}
@Override
protected void onStop() {
super.onStop();
Log.v(LOG_TAG, "-> onStop");
this.topActivity = false;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
this.handler = new Handler();
WindowManager windowManager = getWindowManager();
Intrinsics.checkExpressionValueIsNotNull(windowManager, "windowManager");
Display defaultDisplay = windowManager.getDefaultDisplay();
Resources resources = getResources();
Intrinsics.checkExpressionValueIsNotNull(resources, "resources");
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
this.displayMetrics = displayMetrics;
defaultDisplay.getRealMetrics(displayMetrics);
DisplayMetrics displayMetrics2 = this.displayMetrics;
if (displayMetrics2 == null) {
Intrinsics.throwNpe();
}
this.density = displayMetrics2.density;
FolioActivity folioActivity = this;
LocalBroadcastManager.getInstance(folioActivity).registerReceiver(this.closeBroadcastReceiver, new IntentFilter(FolioReader.ACTION_CLOSE_FOLIOREADER));
setConfig(savedInstanceState);
initDistractionFreeMode(savedInstanceState);
setContentView(R.layout.folio_activity);
this.savedInstanceState = savedInstanceState;
if (savedInstanceState != null) {
this.searchAdapterDataBundle = savedInstanceState.getBundle(SearchAdapter.DATA_BUNDLE);
this.searchQuery = savedInstanceState.getCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY);
}
this.mBookId = getIntent().getStringExtra(FolioReader.EXTRA_BOOK_ID);
Intent intent = getIntent();
Intrinsics.checkExpressionValueIsNotNull(intent, "intent");
Bundle extras = intent.getExtras();
if (extras == null) {
Intrinsics.throwNpe();
}
Serializable serializable = extras.getSerializable(INTENT_EPUB_SOURCE_TYPE);
if (serializable == null) {
throw new TypeCastException("null cannot be cast to non-null type com.folioreader.ui.activity.FolioActivity.EpubSourceType");
}
EpubSourceType epubSourceType = (EpubSourceType) serializable;
this.mEpubSourceType = epubSourceType;
if (epubSourceType == EpubSourceType.RAW) {
Intent intent2 = getIntent();
Intrinsics.checkExpressionValueIsNotNull(intent2, "intent");
Bundle extras2 = intent2.getExtras();
if (extras2 == null) {
Intrinsics.throwNpe();
}
this.mEpubRawId = extras2.getInt(INTENT_EPUB_SOURCE_PATH);
} else {
Intent intent3 = getIntent();
Intrinsics.checkExpressionValueIsNotNull(intent3, "intent");
Bundle extras3 = intent3.getExtras();
if (extras3 == null) {
Intrinsics.throwNpe();
}
this.mEpubFilePath = extras3.getString(INTENT_EPUB_SOURCE_PATH);
}
initActionBar();
initMediaController();
if (ContextCompat.checkSelfPermission(folioActivity, "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
ActivityCompat.requestPermissions(this, Constants.getWriteExternalStoragePerms(), 102);
} else {
setupBook();
}
}
private final void initActionBar() {
int color;
this.appBarLayout = (FolioAppBarLayout) findViewById(R.id.appBarLayout);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
this.toolbar = toolbar;
setSupportActionBar(toolbar);
this.actionBar = getSupportActionBar();
Config savedConfig = AppUtil.INSTANCE.getSavedConfig(getApplicationContext());
if (savedConfig == null) {
Intrinsics.throwNpe();
}
FolioActivity folioActivity = this;
Drawable drawable = ContextCompat.getDrawable(folioActivity, R.drawable.ic_drawer);
int themeColor = savedConfig.getThemeColor();
if (drawable == null) {
Intrinsics.throwNpe();
}
UiUtil.setColorIntToDrawable(themeColor, drawable);
Toolbar toolbar2 = this.toolbar;
if (toolbar2 == null) {
Intrinsics.throwNpe();
}
toolbar2.setNavigationIcon(drawable);
if (savedConfig.isNightMode()) {
setNightMode();
} else {
setDayMode();
}
if (savedConfig.isNightMode()) {
color = ContextCompat.getColor(folioActivity, R.color.black);
} else {
color = getTheme().obtainStyledAttributes(new int[]{android.R.attr.navigationBarColor}).getColor(0, ContextCompat.getColor(folioActivity, R.color.white));
}
Window window = getWindow();
Intrinsics.checkExpressionValueIsNotNull(window, "window");
window.setNavigationBarColor(color);
}
@Override
public void setDayMode() {
Log.v(LOG_TAG, "-> setDayMode");
ActionBar actionBar = this.actionBar;
if (actionBar == null) {
Intrinsics.throwNpe();
}
FolioActivity folioActivity = this;
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(folioActivity, R.color.white)));
Toolbar toolbar = this.toolbar;
if (toolbar == null) {
Intrinsics.throwNpe();
}
toolbar.setTitleTextColor(ContextCompat.getColor(folioActivity, R.color.black));
}
@Override
public void setNightMode() {
Log.v(LOG_TAG, "-> setNightMode");
ActionBar actionBar = this.actionBar;
if (actionBar == null) {
Intrinsics.throwNpe();
}
FolioActivity folioActivity = this;
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(folioActivity, R.color.black)));
Toolbar toolbar = this.toolbar;
if (toolbar == null) {
Intrinsics.throwNpe();
}
toolbar.setTitleTextColor(ContextCompat.getColor(folioActivity, R.color.night_title_text_color));
}
private final void initMediaController() {
Log.v(LOG_TAG, "-> initMediaController");
MediaControllerFragment.Companion companion = MediaControllerFragment.INSTANCE;
FragmentManager supportFragmentManager = getSupportFragmentManager();
Intrinsics.checkExpressionValueIsNotNull(supportFragmentManager, "supportFragmentManager");
this.mediaControllerFragment = companion.getInstance(supportFragmentManager, this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Intrinsics.checkParameterIsNotNull(menu, "menu");
getMenuInflater().inflate(R.menu.menu_main, menu);
Config savedConfig = AppUtil.INSTANCE.getSavedConfig(getApplicationContext());
if (savedConfig == null) {
Intrinsics.throwNpe();
}
int themeColor = savedConfig.getThemeColor();
MenuItem findItem = menu.findItem(R.id.itemSearch);
Intrinsics.checkExpressionValueIsNotNull(findItem, "menu.findItem(R.id.itemSearch)");
UiUtil.setColorIntToDrawable(themeColor, findItem.getIcon());
int themeColor2 = savedConfig.getThemeColor();
MenuItem findItem2 = menu.findItem(R.id.itemConfig);
Intrinsics.checkExpressionValueIsNotNull(findItem2, "menu.findItem(R.id.itemConfig)");
UiUtil.setColorIntToDrawable(themeColor2, findItem2.getIcon());
int themeColor3 = savedConfig.getThemeColor();
MenuItem findItem3 = menu.findItem(R.id.itemTts);
Intrinsics.checkExpressionValueIsNotNull(findItem3, "menu.findItem(R.id.itemTts)");
UiUtil.setColorIntToDrawable(themeColor3, findItem3.getIcon());
if (savedConfig.isShowTts()) {
return true;
}
MenuItem findItem4 = menu.findItem(R.id.itemTts);
Intrinsics.checkExpressionValueIsNotNull(findItem4, "menu.findItem(R.id.itemTts)");
findItem4.setVisible(false);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Intrinsics.checkParameterIsNotNull(item, "item");
int itemId = item.getItemId();
if (itemId == 16908332) {
Log.v(LOG_TAG, "-> onOptionsItemSelected -> drawer");
startContentHighlightActivity();
return true;
}
if (itemId == R.id.itemSearch) {
Log.v(LOG_TAG, "-> onOptionsItemSelected -> " + item.getTitle());
if (this.searchUri == null) {
return true;
}
Intent intent = new Intent(this, (Class<?>) SearchActivity.class);
List<Link> list = this.spine;
intent.putExtra(SearchActivity.BUNDLE_SPINE_SIZE, list != null ? list.size() : 0);
intent.putExtra(SearchActivity.BUNDLE_SEARCH_URI, this.searchUri);
intent.putExtra(SearchAdapter.DATA_BUNDLE, this.searchAdapterDataBundle);
intent.putExtra(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY, this.searchQuery);
startActivityForResult(intent, RequestCode.SEARCH.getValue());
return true;
}
if (itemId == R.id.itemConfig) {
Log.v(LOG_TAG, "-> onOptionsItemSelected -> " + item.getTitle());
showConfigBottomSheetDialogFragment();
return true;
}
if (itemId == R.id.itemTts) {
Log.v(LOG_TAG, "-> onOptionsItemSelected -> " + item.getTitle());
showMediaController();
return true;
}
return super.onOptionsItemSelected(item);
}
public final void startContentHighlightActivity() {
Intent intent = new Intent(this, (Class<?>) ContentHighlightActivity.class);
PubBox pubBox = this.pubBox;
if (pubBox == null) {
Intrinsics.throwNpe();
}
intent.putExtra(Constants.PUBLICATION, (Serializable) pubBox.getPublication());
try {
List<Link> list = this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
intent.putExtra(Constants.CHAPTER_SELECTED, list.get(this.currentChapterIndex).getHref());
} catch (IndexOutOfBoundsException e) {
Log.w(LOG_TAG, "-> ", e);
intent.putExtra(Constants.CHAPTER_SELECTED, "");
} catch (NullPointerException e2) {
Log.w(LOG_TAG, "-> ", e2);
intent.putExtra(Constants.CHAPTER_SELECTED, "");
}
intent.putExtra(FolioReader.EXTRA_BOOK_ID, this.mBookId);
intent.putExtra(Constants.BOOK_TITLE, this.bookFileName);
startActivityForResult(intent, RequestCode.CONTENT_HIGHLIGHT.getValue());
overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
}
public final void showConfigBottomSheetDialogFragment() {
new ConfigBottomSheetDialogFragment().show(getSupportFragmentManager(), ConfigBottomSheetDialogFragment.LOG_TAG);
}
public final void showMediaController() {
MediaControllerFragment mediaControllerFragment = this.mediaControllerFragment;
if (mediaControllerFragment == null) {
Intrinsics.throwNpe();
}
FragmentManager supportFragmentManager = getSupportFragmentManager();
Intrinsics.checkExpressionValueIsNotNull(supportFragmentManager, "supportFragmentManager");
mediaControllerFragment.show(supportFragmentManager);
}
private final void setupBook() {
Log.v(LOG_TAG, "-> setupBook");
try {
initBook();
onBookInitSuccess();
} catch (Exception e) {
Log.e(LOG_TAG, "-> Failed to initialize book", e);
onBookInitFailure();
}
}
private final void initBook() throws Exception {
String extensionUppercase;
PubBox parse;
Log.v(LOG_TAG, "-> initBook");
FolioActivity folioActivity = this;
EpubSourceType epubSourceType = this.mEpubSourceType;
if (epubSourceType == null) {
Intrinsics.throwNpe();
}
String epubFilename = FileUtil.getEpubFilename(folioActivity, epubSourceType, this.mEpubFilePath, this.mEpubRawId);
this.bookFileName = epubFilename;
String saveEpubFileAndLoadLazyBook = FileUtil.saveEpubFileAndLoadLazyBook(folioActivity, this.mEpubSourceType, this.mEpubFilePath, this.mEpubRawId, epubFilename);
String str = null;
try {
extensionUppercase = FileUtil.getExtensionUppercase(saveEpubFileAndLoadLazyBook);
} catch (IllegalArgumentException e) {
e = e;
}
try {
Intrinsics.checkExpressionValueIsNotNull(extensionUppercase, "extensionString");
int i = WhenMappings.$EnumSwitchMapping$0[Publication.EXTENSION.valueOf(extensionUppercase).ordinal()];
if (i == 1) {
EpubParser epubParser = new EpubParser();
if (saveEpubFileAndLoadLazyBook == null) {
Intrinsics.throwNpe();
}
parse = epubParser.parse(saveEpubFileAndLoadLazyBook, "");
} else if (i != 2) {
parse = null;
} else {
CbzParser cbzParser = new CbzParser();
if (saveEpubFileAndLoadLazyBook == null) {
Intrinsics.throwNpe();
}
parse = cbzParser.parse(saveEpubFileAndLoadLazyBook, "");
}
this.pubBox = parse;
this.portNumber = getIntent().getIntExtra(FolioReader.EXTRA_PORT_NUMBER, Constants.DEFAULT_PORT_NUMBER);
this.portNumber = AppUtil.INSTANCE.getAvailablePortNumber(this.portNumber);
Server server = new Server(this.portNumber);
this.r2StreamerServer = server;
PubBox pubBox = this.pubBox;
if (pubBox == null) {
Intrinsics.throwNpe();
}
Publication publication = pubBox.getPublication();
PubBox pubBox2 = this.pubBox;
if (pubBox2 == null) {
Intrinsics.throwNpe();
}
Container container = pubBox2.getContainer();
StringBuilder sb = new StringBuilder("/");
String str2 = this.bookFileName;
if (str2 == null) {
Intrinsics.throwNpe();
}
sb.append(str2);
server.addEpub(publication, container, sb.toString(), (String) null);
Server server2 = this.r2StreamerServer;
if (server2 == null) {
Intrinsics.throwNpe();
}
server2.start();
FolioReader.initRetrofit(getStreamerUrl());
} catch (IllegalArgumentException e2) {
e = e2;
str = extensionUppercase;
throw new Exception("-> Unknown book file extension `" + str + '`', e);
}
}
private final void onBookInitSuccess() {
PubBox pubBox = this.pubBox;
if (pubBox == null) {
Intrinsics.throwNpe();
}
Publication publication = pubBox.getPublication();
this.spine = publication.getReadingOrder();
setTitle(publication.getMetadata().getTitle());
if (this.mBookId == null) {
if (publication.getMetadata().getIdentifier().length() != 0) {
this.mBookId = publication.getMetadata().getIdentifier();
} else if (publication.getMetadata().getTitle().length() != 0) {
this.mBookId = String.valueOf(publication.getMetadata().getTitle().hashCode());
} else {
String str = this.bookFileName;
if (str == null) {
Intrinsics.throwNpe();
}
this.mBookId = String.valueOf(str.hashCode());
}
}
Iterator it = publication.getLinks().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Link link = (Link) it.next();
if (link.getRel().contains("search")) {
StringBuilder sb = new StringBuilder("http://");
String href = link.getHref();
if (href == null) {
Intrinsics.throwNpe();
}
sb.append(href);
this.searchUri = Uri.parse(sb.toString());
}
}
if (this.searchUri == null) {
this.searchUri = Uri.parse(getStreamerUrl() + "search");
}
configFolio();
}
@Override
public String getStreamerUrl() {
if (this.streamerUri == null) {
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(Constants.STREAMER_URL_TEMPLATE, Arrays.copyOf(new Object[]{Constants.LOCALHOST, Integer.valueOf(this.portNumber), this.bookFileName}, 3));
Intrinsics.checkExpressionValueIsNotNull(format, "java.lang.String.format(format, *args)");
this.streamerUri = Uri.parse(format);
}
return String.valueOf(this.streamerUri);
}
@Override
public void onDirectionChange(Config.Direction newDirection) {
Intrinsics.checkParameterIsNotNull(newDirection, "newDirection");
Log.v(LOG_TAG, "-> onDirectionChange");
FolioPageFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
if (currentFragment == null) {
Intrinsics.throwNpe();
}
this.entryReadLocator = currentFragment.getLastReadLocator();
SearchLocator searchLocatorVisible = currentFragment.getSearchLocatorVisible();
this.direction = newDirection;
DirectionalViewpager directionalViewpager = this.mFolioPageViewPager;
if (directionalViewpager == null) {
Intrinsics.throwNpe();
}
directionalViewpager.setDirection(newDirection);
this.mFolioPageFragmentAdapter = new FolioPageFragmentAdapter(getSupportFragmentManager(), this.spine, this.bookFileName, this.mBookId);
DirectionalViewpager directionalViewpager2 = this.mFolioPageViewPager;
if (directionalViewpager2 == null) {
Intrinsics.throwNpe();
}
directionalViewpager2.setAdapter(this.mFolioPageFragmentAdapter);
DirectionalViewpager directionalViewpager3 = this.mFolioPageViewPager;
if (directionalViewpager3 == null) {
Intrinsics.throwNpe();
}
directionalViewpager3.setCurrentItem(this.currentChapterIndex);
FolioPageFragment currentFragment2 = getCurrentFragment();
if (currentFragment2 == null || searchLocatorVisible == null) {
return;
}
currentFragment2.highlightSearchLocator(searchLocatorVisible);
}
}
private final void initDistractionFreeMode(Bundle savedInstanceState) {
Log.v(LOG_TAG, "-> initDistractionFreeMode");
Window window = getWindow();
Intrinsics.checkExpressionValueIsNotNull(window, "window");
window.getDecorView().setOnSystemUiVisibilityChangeListener(this);
hideSystemUI();
showSystemUI();
this.distractionFreeMode = savedInstanceState != null && savedInstanceState.getBoolean(BUNDLE_DISTRACTION_FREE_MODE);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Log.v(LOG_TAG, "-> onPostCreate");
if (this.distractionFreeMode) {
Handler handler = this.handler;
if (handler == null) {
Intrinsics.throwNpe();
}
handler.post(new Runnable() {
@Override
public final void run() {
FolioActivity.this.hideSystemUI();
}
});
}
}
@Override
public int getTopDistraction(DisplayUnit unit) {
int i;
Intrinsics.checkParameterIsNotNull(unit, "unit");
if (this.distractionFreeMode) {
i = 0;
} else {
i = getStatusBarHeight();
ActionBar actionBar = this.actionBar;
if (actionBar != null) {
if (actionBar == null) {
Intrinsics.throwNpe();
}
i += actionBar.getHeight();
}
}
int i2 = WhenMappings.$EnumSwitchMapping$1[unit.ordinal()];
if (i2 == 1) {
return i;
}
if (i2 == 2) {
return i / ((int) this.density);
}
throw new IllegalArgumentException("-> Illegal argument -> unit = " + unit);
}
@Override
public int getBottomDistraction(DisplayUnit unit) {
int i;
Intrinsics.checkParameterIsNotNull(unit, "unit");
if (this.distractionFreeMode) {
i = 0;
} else {
FolioAppBarLayout folioAppBarLayout = this.appBarLayout;
if (folioAppBarLayout == null) {
Intrinsics.throwNpe();
}
i = folioAppBarLayout.getNavigationBarHeight();
}
int i2 = WhenMappings.$EnumSwitchMapping$2[unit.ordinal()];
if (i2 == 1) {
return i;
}
if (i2 == 2) {
return i / ((int) this.density);
}
throw new IllegalArgumentException("-> Illegal argument -> unit = " + unit);
}
private final Rect computeViewportRect() {
FolioAppBarLayout folioAppBarLayout = this.appBarLayout;
if (folioAppBarLayout == null) {
Intrinsics.throwNpe();
}
Rect rect = new Rect(folioAppBarLayout.getInsets());
if (this.distractionFreeMode) {
rect.left = 0;
}
rect.top = getTopDistraction(DisplayUnit.PX);
if (this.distractionFreeMode) {
DisplayMetrics displayMetrics = this.displayMetrics;
if (displayMetrics == null) {
Intrinsics.throwNpe();
}
rect.right = displayMetrics.widthPixels;
} else {
DisplayMetrics displayMetrics2 = this.displayMetrics;
if (displayMetrics2 == null) {
Intrinsics.throwNpe();
}
rect.right = displayMetrics2.widthPixels - rect.right;
}
DisplayMetrics displayMetrics3 = this.displayMetrics;
if (displayMetrics3 == null) {
Intrinsics.throwNpe();
}
rect.bottom = displayMetrics3.heightPixels - getBottomDistraction(DisplayUnit.PX);
return rect;
}
@Override
public Rect getViewportRect(DisplayUnit unit) {
Intrinsics.checkParameterIsNotNull(unit, "unit");
Rect computeViewportRect = computeViewportRect();
int i = WhenMappings.$EnumSwitchMapping$3[unit.ordinal()];
if (i != 1) {
if (i != 2) {
if (i == 3) {
computeViewportRect.left = (int) Math.ceil(computeViewportRect.left / this.density);
computeViewportRect.top = (int) Math.ceil(computeViewportRect.top / this.density);
computeViewportRect.right = (int) Math.ceil(computeViewportRect.right / this.density);
computeViewportRect.bottom = (int) Math.ceil(computeViewportRect.bottom / this.density);
return computeViewportRect;
}
throw new IllegalArgumentException("-> Illegal argument -> unit = " + unit);
}
computeViewportRect.left /= (int) this.density;
computeViewportRect.top /= (int) this.density;
computeViewportRect.right /= (int) this.density;
computeViewportRect.bottom /= (int) this.density;
}
return computeViewportRect;
}
@Override
public WeakReference<FolioActivity> getActivity() {
return new WeakReference<>(this);
}
@Override
public void onSystemUiVisibilityChange(int visibility) {
String str = LOG_TAG;
Log.v(str, "-> onSystemUiVisibilityChange -> visibility = " + visibility);
this.distractionFreeMode = visibility != 0;
Log.v(str, "-> distractionFreeMode = " + this.distractionFreeMode);
ActionBar actionBar = this.actionBar;
if (actionBar != null) {
if (this.distractionFreeMode) {
if (actionBar == null) {
Intrinsics.throwNpe();
}
actionBar.hide();
} else {
if (actionBar == null) {
Intrinsics.throwNpe();
}
actionBar.show();
}
}
}
@Override
public void toggleSystemUI() {
if (this.distractionFreeMode) {
showSystemUI();
} else {
hideSystemUI();
}
}
private final void showSystemUI() {
Log.v(LOG_TAG, "-> showSystemUI");
Window window = getWindow();
Intrinsics.checkExpressionValueIsNotNull(window, "window");
View decorView = window.getDecorView();
Intrinsics.checkExpressionValueIsNotNull(decorView, "decorView");
decorView.setSystemUiVisibility(1792);
}
public final void hideSystemUI() {
Log.v(LOG_TAG, "-> hideSystemUI");
Window window = getWindow();
Intrinsics.checkExpressionValueIsNotNull(window, "window");
View decorView = window.getDecorView();
Intrinsics.checkExpressionValueIsNotNull(decorView, "decorView");
decorView.setSystemUiVisibility(3846);
}
@Override
public ReadLocator getEntryReadLocator() {
ReadLocator readLocator = this.entryReadLocator;
if (readLocator == null) {
return null;
}
this.entryReadLocator = null;
return readLocator;
}
@Override
public boolean goToChapter(String href) {
Intrinsics.checkParameterIsNotNull(href, Constants.HREF);
List<Link> list = this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
for (Link link : list) {
String str = href;
String href2 = link.getHref();
if (href2 == null) {
Intrinsics.throwNpe();
}
if (StringsKt.contains$default(str, href2, false, 2, (Object) null)) {
List<Link> list2 = this.spine;
if (list2 == null) {
Intrinsics.throwNpe();
}
this.currentChapterIndex = list2.indexOf(link);
DirectionalViewpager directionalViewpager = this.mFolioPageViewPager;
if (directionalViewpager == null) {
Intrinsics.throwNpe();
}
directionalViewpager.setCurrentItem(this.currentChapterIndex);
FolioPageFragment currentFragment = getCurrentFragment();
if (currentFragment == null) {
Intrinsics.throwNpe();
}
currentFragment.scrollToFirst();
currentFragment.scrollToAnchorId(href);
return true;
}
}
return false;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RequestCode.SEARCH.getValue()) {
Log.v(LOG_TAG, "-> onActivityResult -> " + RequestCode.SEARCH);
if (resultCode == 0) {
return;
}
if (data == null) {
Intrinsics.throwNpe();
}
this.searchAdapterDataBundle = data.getBundleExtra(SearchAdapter.DATA_BUNDLE);
this.searchQuery = data.getCharSequenceExtra(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY);
if (resultCode == SearchActivity.ResultCode.ITEM_SELECTED.getValue()) {
SearchLocator searchLocator = (SearchLocator) data.getParcelableExtra(EXTRA_SEARCH_ITEM);
this.searchLocator = searchLocator;
if (this.mFolioPageViewPager == null) {
return;
}
if (searchLocator == null) {
Intrinsics.throwNpe();
}
this.currentChapterIndex = getChapterIndex(Constants.HREF, searchLocator.getHref());
DirectionalViewpager directionalViewpager = this.mFolioPageViewPager;
if (directionalViewpager == null) {
Intrinsics.throwNpe();
}
directionalViewpager.setCurrentItem(this.currentChapterIndex);
FolioPageFragment currentFragment = getCurrentFragment();
if (currentFragment != null) {
SearchLocator searchLocator2 = this.searchLocator;
if (searchLocator2 == null) {
Intrinsics.throwNpe();
}
currentFragment.highlightSearchLocator(searchLocator2);
this.searchLocator = null;
return;
}
return;
}
return;
}
if (requestCode == RequestCode.CONTENT_HIGHLIGHT.getValue() && resultCode == -1) {
if (data == null) {
Intrinsics.throwNpe();
}
if (data.hasExtra(Constants.TYPE)) {
String stringExtra = data.getStringExtra(Constants.TYPE);
if (Intrinsics.areEqual(stringExtra, Constants.CHAPTER_SELECTED)) {
String stringExtra2 = data.getStringExtra(Constants.SELECTED_CHAPTER_POSITION);
Intrinsics.checkExpressionValueIsNotNull(stringExtra2, "data.getStringExtra(SELECTED_CHAPTER_POSITION)");
goToChapter(stringExtra2);
return;
}
if (Intrinsics.areEqual(stringExtra, Constants.HIGHLIGHT_SELECTED)) {
HighlightImpl highlightImpl = (HighlightImpl) data.getParcelableExtra(HIGHLIGHT_ITEM);
Intrinsics.checkExpressionValueIsNotNull(highlightImpl, "highlightImpl");
this.currentChapterIndex = highlightImpl.getPageNumber();
DirectionalViewpager directionalViewpager2 = this.mFolioPageViewPager;
if (directionalViewpager2 == null) {
Intrinsics.throwNpe();
}
directionalViewpager2.setCurrentItem(this.currentChapterIndex);
FolioPageFragment currentFragment2 = getCurrentFragment();
if (currentFragment2 != null) {
String rangy = highlightImpl.getRangy();
Intrinsics.checkExpressionValueIsNotNull(rangy, "highlightImpl.rangy");
currentFragment2.scrollToHighlightId(rangy);
}
}
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
Bundle bundle = this.outState;
if (bundle != null) {
if (bundle == null) {
Intrinsics.throwNpe();
}
bundle.putSerializable(BUNDLE_READ_LOCATOR_CONFIG_CHANGE, (Serializable) this.lastReadLocator);
}
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
Intrinsics.checkExpressionValueIsNotNull(localBroadcastManager, "LocalBroadcastManager.getInstance(this)");
localBroadcastManager.unregisterReceiver(this.searchReceiver);
localBroadcastManager.unregisterReceiver(this.closeBroadcastReceiver);
Server server = this.r2StreamerServer;
if (server != null) {
if (server == null) {
Intrinsics.throwNpe();
}
server.stop();
}
if (isFinishing()) {
localBroadcastManager.sendBroadcast(new Intent(FolioReader.ACTION_FOLIOREADER_CLOSED));
FolioReader.get().retrofit = null;
FolioReader.get().r2StreamerApi = null;
}
}
@Override
public int getCurrentChapterIndex() {
return this.currentChapterIndex;
}
private final void configFolio() {
ReadLocator readLocator;
DirectionalViewpager directionalViewpager = (DirectionalViewpager) findViewById(R.id.folioPageViewPager);
this.mFolioPageViewPager = directionalViewpager;
if (directionalViewpager == null) {
Intrinsics.throwNpe();
}
directionalViewpager.setOnPageChangeListener(new DirectionalViewpager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
List list;
int i;
MediaControllerFragment mediaControllerFragment;
Log.v(FolioActivity.LOG_TAG, "-> onPageSelected -> DirectionalViewpager -> position = " + position);
EventBus eventBus = EventBus.getDefault();
list = FolioActivity.this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
i = FolioActivity.this.currentChapterIndex;
eventBus.post(new MediaOverlayPlayPauseEvent(((Link) list.get(i)).getHref(), false, true));
mediaControllerFragment = FolioActivity.this.mediaControllerFragment;
if (mediaControllerFragment == null) {
Intrinsics.throwNpe();
}
mediaControllerFragment.setPlayButtonDrawable();
FolioActivity.this.currentChapterIndex = position;
}
@Override
public void onPageScrollStateChanged(int state) {
DirectionalViewpager directionalViewpager2;
FolioPageFragmentAdapter folioPageFragmentAdapter;
FolioPageFragmentAdapter folioPageFragmentAdapter2;
if (state == 0) {
directionalViewpager2 = FolioActivity.this.mFolioPageViewPager;
if (directionalViewpager2 == null) {
Intrinsics.throwNpe();
}
int currentItem = directionalViewpager2.getCurrentItem();
Log.v(FolioActivity.LOG_TAG, "-> onPageScrollStateChanged -> DirectionalViewpager -> position = " + currentItem);
folioPageFragmentAdapter = FolioActivity.this.mFolioPageFragmentAdapter;
if (folioPageFragmentAdapter == null) {
Intrinsics.throwNpe();
}
FolioPageFragment folioPageFragment = (FolioPageFragment) folioPageFragmentAdapter.getItem(currentItem - 1);
if (folioPageFragment != null) {
folioPageFragment.scrollToLast();
if (folioPageFragment.getMWebview() != null) {
FolioWebView mWebview = folioPageFragment.getMWebview();
if (mWebview == null) {
Intrinsics.throwNpe();
}
mWebview.dismissPopupWindow();
}
}
folioPageFragmentAdapter2 = FolioActivity.this.mFolioPageFragmentAdapter;
if (folioPageFragmentAdapter2 == null) {
Intrinsics.throwNpe();
}
FolioPageFragment folioPageFragment2 = (FolioPageFragment) folioPageFragmentAdapter2.getItem(currentItem + 1);
if (folioPageFragment2 != null) {
folioPageFragment2.scrollToFirst();
if (folioPageFragment2.getMWebview() != null) {
FolioWebView mWebview2 = folioPageFragment2.getMWebview();
if (mWebview2 == null) {
Intrinsics.throwNpe();
}
mWebview2.dismissPopupWindow();
}
}
}
}
});
DirectionalViewpager directionalViewpager2 = this.mFolioPageViewPager;
if (directionalViewpager2 == null) {
Intrinsics.throwNpe();
}
directionalViewpager2.setDirection(this.direction);
this.mFolioPageFragmentAdapter = new FolioPageFragmentAdapter(getSupportFragmentManager(), this.spine, this.bookFileName, this.mBookId);
DirectionalViewpager directionalViewpager3 = this.mFolioPageViewPager;
if (directionalViewpager3 == null) {
Intrinsics.throwNpe();
}
directionalViewpager3.setAdapter(this.mFolioPageFragmentAdapter);
SearchLocator searchLocator = this.searchLocator;
if (searchLocator != null) {
if (searchLocator == null) {
Intrinsics.throwNpe();
}
this.currentChapterIndex = getChapterIndex(Constants.HREF, searchLocator.getHref());
DirectionalViewpager directionalViewpager4 = this.mFolioPageViewPager;
if (directionalViewpager4 == null) {
Intrinsics.throwNpe();
}
directionalViewpager4.setCurrentItem(this.currentChapterIndex);
FolioPageFragment currentFragment = getCurrentFragment();
if (currentFragment == null) {
return;
}
SearchLocator searchLocator2 = this.searchLocator;
if (searchLocator2 == null) {
Intrinsics.throwNpe();
}
currentFragment.highlightSearchLocator(searchLocator2);
this.searchLocator = null;
} else {
Bundle bundle = this.savedInstanceState;
if (bundle == null) {
readLocator = (ReadLocator) getIntent().getParcelableExtra("com.folioreader.extra.READ_LOCATOR");
this.entryReadLocator = readLocator;
} else {
if (bundle == null) {
Intrinsics.throwNpe();
}
readLocator = (ReadLocator) bundle.getParcelable(BUNDLE_READ_LOCATOR_CONFIG_CHANGE);
this.lastReadLocator = readLocator;
}
this.currentChapterIndex = getChapterIndex(readLocator);
DirectionalViewpager directionalViewpager5 = this.mFolioPageViewPager;
if (directionalViewpager5 == null) {
Intrinsics.throwNpe();
}
directionalViewpager5.setCurrentItem(this.currentChapterIndex);
}
LocalBroadcastManager.getInstance(this).registerReceiver(this.searchReceiver, new IntentFilter(ACTION_SEARCH_CLEAR));
}
private final int getChapterIndex(ReadLocator readLocator) {
if (readLocator == null || TextUtils.isEmpty(readLocator.getHref())) {
return 0;
}
return getChapterIndex(Constants.HREF, readLocator.getHref());
}
private final int getChapterIndex(String caseString, String value) {
List<Link> list = this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
int size = list.size();
for (int i = 0; i < size; i++) {
if (caseString.hashCode() == 3211051 && caseString.equals(Constants.HREF)) {
List<Link> list2 = this.spine;
if (list2 == null) {
Intrinsics.throwNpe();
}
if (Intrinsics.areEqual(list2.get(i).getHref(), value)) {
return i;
}
}
}
return 0;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
Intrinsics.checkParameterIsNotNull(outState, "outState");
super.onSaveInstanceState(outState);
Log.v(LOG_TAG, "-> onSaveInstanceState");
this.outState = outState;
outState.putBoolean(BUNDLE_DISTRACTION_FREE_MODE, this.distractionFreeMode);
outState.putBundle(SearchAdapter.DATA_BUNDLE, this.searchAdapterDataBundle);
outState.putCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY, this.searchQuery);
}
@Override
public void storeLastReadLocator(ReadLocator lastReadLocator) {
Intrinsics.checkParameterIsNotNull(lastReadLocator, "lastReadLocator");
Log.v(LOG_TAG, "-> storeLastReadLocator");
this.lastReadLocator = lastReadLocator;
}
private final void setConfig(android.os.Bundle r5) {
throw new UnsupportedOperationException("Method not decompiled: com.folioreader.ui.activity.FolioActivity.setConfig(android.os.Bundle):void");
}
@Override
public void play() {
EventBus eventBus = EventBus.getDefault();
List<Link> list = this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
eventBus.post(new MediaOverlayPlayPauseEvent(list.get(this.currentChapterIndex).getHref(), true, false));
}
@Override
public void pause() {
EventBus eventBus = EventBus.getDefault();
List<Link> list = this.spine;
if (list == null) {
Intrinsics.throwNpe();
}
eventBus.post(new MediaOverlayPlayPauseEvent(list.get(this.currentChapterIndex).getHref(), false, false));
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
Intrinsics.checkParameterIsNotNull(permissions, "permissions");
Intrinsics.checkParameterIsNotNull(grantResults, "grantResults");
if (requestCode != 102) {
return;
}
if (grantResults[0] == 0) {
setupBook();
} else {
Toast.makeText(this, getString(R.string.cannot_access_epub_message), 1).show();
finish();
}
}
@Override
public Config.Direction getDirection() {
return this.direction;
}
public final void clearSearchLocator() {
Log.v(LOG_TAG, "-> clearSearchLocator");
FolioPageFragmentAdapter folioPageFragmentAdapter = this.mFolioPageFragmentAdapter;
if (folioPageFragmentAdapter == null) {
Intrinsics.throwNpe();
}
ArrayList<Fragment> fragments = folioPageFragmentAdapter.getFragments();
Intrinsics.checkExpressionValueIsNotNull(fragments, "fragments");
int size = fragments.size();
for (int i = 0; i < size; i++) {
FolioPageFragment folioPageFragment = (FolioPageFragment) fragments.get(i);
if (folioPageFragment != null) {
folioPageFragment.clearSearchLocator();
}
}
FolioPageFragmentAdapter folioPageFragmentAdapter2 = this.mFolioPageFragmentAdapter;
if (folioPageFragmentAdapter2 == null) {
Intrinsics.throwNpe();
}
ArrayList<Fragment.SavedState> savedStateList = folioPageFragmentAdapter2.getSavedStateList();
if (savedStateList != null) {
int size2 = savedStateList.size();
for (int i2 = 0; i2 < size2; i2++) {
Bundle bundleFromSavedState = FolioPageFragmentAdapter.getBundleFromSavedState(savedStateList.get(i2));
if (bundleFromSavedState != null) {
bundleFromSavedState.putParcelable(FolioPageFragment.BUNDLE_SEARCH_LOCATOR, null);
}
}
}
}
}