Remove unused codes
No files matched your search
@@ -50,7 +50,7 @@ android {
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
buildConfigField 'String', 'FILE_PROVIDER_AUTHORITY', '"com.hippo.ehviewer.fileprovider"'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@
|
||||
#}
|
||||
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
-keep class com.hippo.** { *; }
|
||||
-keep class com.hippo.** { *; }
|
||||
-repackageclasses ''
|
||||
@@ -26,7 +26,8 @@ import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
@@ -118,12 +119,11 @@ public class AddDeleteDrawable extends Drawable {
|
||||
mAutoUpdateMirror = autoUpdateMirror;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public float getProgress() {
|
||||
return mProgress;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Keep
|
||||
public void setProgress(float progress) {
|
||||
if (mAutoUpdateMirror) {
|
||||
if (progress == 1f) {
|
||||
@@ -152,9 +152,7 @@ public class AddDeleteDrawable extends Drawable {
|
||||
} else {
|
||||
ObjectAnimator oa = ObjectAnimator.ofFloat(this, "progress", endProgress);
|
||||
oa.setDuration(duration);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
oa.setAutoCancel(true);
|
||||
}
|
||||
oa.setAutoCancel(true);
|
||||
oa.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +145,6 @@ public final class Crash {
|
||||
fw.write("RADIO=");
|
||||
fw.write(Build.getRadioVersion());
|
||||
fw.write("\r\n");
|
||||
fw.write("SERIAL=");
|
||||
fw.write(Build.SERIAL);
|
||||
fw.write("\r\n");
|
||||
fw.write("TAGS=");
|
||||
fw.write(Build.TAGS);
|
||||
fw.write("\r\n");
|
||||
|
||||
@@ -971,7 +971,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static boolean getEnableFingerprint() {
|
||||
return getBoolean(KEY_ENABLE_FINGERPRINT, false);
|
||||
return getBoolean(KEY_ENABLE_FINGERPRINT, true);
|
||||
}
|
||||
|
||||
public static void putEnableFingerprint(boolean value) {
|
||||
|
||||
@@ -116,13 +116,7 @@ public class EhClient {
|
||||
|
||||
if (mCallback != null) {
|
||||
// TODO Avoid new runnable
|
||||
final Callback finalCallback = mCallback;
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalCallback.onCancel();
|
||||
}
|
||||
});
|
||||
SimpleHandler.getInstance().post(mCallback::onCancel);
|
||||
}
|
||||
|
||||
Status status = getStatus();
|
||||
@@ -144,7 +138,6 @@ public class EhClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Object doInBackground(Object... params) {
|
||||
try {
|
||||
switch (mMethod) {
|
||||
|
||||
@@ -67,8 +67,6 @@ public class EhDns implements Dns {
|
||||
|
||||
@Override
|
||||
public List<InetAddress> lookup(String hostname) throws UnknownHostException {
|
||||
if (hostname == null) throw new UnknownHostException("hostname == null");
|
||||
|
||||
InetAddress inetAddress = hosts.get(hostname);
|
||||
if (inetAddress != null) {
|
||||
return Collections.singletonList(inetAddress);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class EhUrl {
|
||||
HttpUrl url = HttpUrl.parse(originUrl);
|
||||
if (url == null) return originUrl;
|
||||
List<String> pathSegments = url.pathSegments();
|
||||
if (pathSegments == null || pathSegments.size() < 3) return originUrl;
|
||||
if (pathSegments.size() < 3) return originUrl;
|
||||
|
||||
ListIterator<String> iterator = pathSegments.listIterator(pathSegments.size());
|
||||
// The last segments, like
|
||||
|
||||
@@ -55,12 +55,7 @@ import java.util.Map;
|
||||
public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
|
||||
private static final String TAG = DownloadManager.class.getSimpleName();
|
||||
private static final Comparator<DownloadInfo> DATE_DESC_COMPARATOR = new Comparator<DownloadInfo>() {
|
||||
@Override
|
||||
public int compare(DownloadInfo lhs, DownloadInfo rhs) {
|
||||
return lhs.time - rhs.time > 0 ? -1 : 1;
|
||||
}
|
||||
};
|
||||
private static final Comparator<DownloadInfo> DATE_DESC_COMPARATOR = (lhs, rhs) -> lhs.time - rhs.time > 0 ? -1 : 1;
|
||||
private final Context mContext;
|
||||
// All download info list
|
||||
private final LinkedList<DownloadInfo> mAllInfoList;
|
||||
@@ -95,7 +90,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
HashMap<String, LinkedList<DownloadInfo>> map = new HashMap<>();
|
||||
mMap = map;
|
||||
for (DownloadLabel label : labels) {
|
||||
map.put(label.getLabel(), new LinkedList<DownloadInfo>());
|
||||
map.put(label.getLabel(), new LinkedList<>());
|
||||
}
|
||||
|
||||
// Create default for non tag
|
||||
@@ -340,15 +335,13 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
void startAllDownload() {
|
||||
boolean update = false;
|
||||
// Start all STATE_NONE and STATE_FAILED item
|
||||
LinkedList<DownloadInfo> allInfoList = mAllInfoList;
|
||||
LinkedList<DownloadInfo> waitList = mWaitList;
|
||||
for (DownloadInfo info : allInfoList) {
|
||||
for (DownloadInfo info : mAllInfoList) {
|
||||
if (info.state == DownloadInfo.STATE_NONE || info.state == DownloadInfo.STATE_FAILED) {
|
||||
update = true;
|
||||
// Set state DownloadInfo.STATE_WAIT
|
||||
info.state = DownloadInfo.STATE_WAIT;
|
||||
// Add to wait list
|
||||
waitList.add(info);
|
||||
mWaitList.add(info);
|
||||
// Update in DB
|
||||
EhDB.putDownloadInfo(info);
|
||||
}
|
||||
@@ -413,7 +406,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
for (DownloadLabel label : downloadLabelList) {
|
||||
String labelString = label.getLabel();
|
||||
if (!containLabel(labelString)) {
|
||||
mMap.put(labelString, new LinkedList<DownloadInfo>());
|
||||
mMap.put(labelString, new LinkedList<>());
|
||||
mLabelList.add(EhDB.addDownloadLabel(label));
|
||||
}
|
||||
}
|
||||
@@ -748,7 +741,7 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
}
|
||||
|
||||
mLabelList.add(EhDB.addDownloadLabel(label));
|
||||
mMap.put(label, new LinkedList<DownloadInfo>());
|
||||
mMap.put(label, new LinkedList<>());
|
||||
|
||||
for (DownloadInfoListener l : mDownloadInfoListeners) {
|
||||
l.onUpdateLabels();
|
||||
|
||||
@@ -104,7 +104,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
|
||||
CHANNEL_ID = getPackageName() + ".download";
|
||||
mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mNotifyManager != null) {
|
||||
mNotifyManager.createNotificationChannel(new NotificationChannel(CHANNEL_ID, getString(R.string.download_service),
|
||||
NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
@@ -203,7 +203,6 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
throw new IllegalStateException("No bindService");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void ensureDownloadingBuilder() {
|
||||
if (mDownloadingBuilder != null) {
|
||||
return;
|
||||
@@ -422,11 +421,10 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
style = new NotificationCompat.InboxStyle();
|
||||
style.setBigContentTitle(getString(R.string.stat_download_done_title));
|
||||
SparseJBArray stateArray = sItemStateArray;
|
||||
SparseJLArray<String> titleArray = sItemTitleArray;
|
||||
for (int i = 0, n = stateArray.size(); i < n; i++) {
|
||||
long id = stateArray.keyAt(i);
|
||||
boolean fin = stateArray.valueAt(i);
|
||||
String title = titleArray.get(id);
|
||||
String title = sItemTitleArray.get(id);
|
||||
if (title == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -161,12 +161,10 @@ public class ArchiveGalleryProvider extends GalleryProvider2 {
|
||||
@Override
|
||||
public void run() {
|
||||
UniRandomAccessFile uraf = null;
|
||||
if (file != null) {
|
||||
try {
|
||||
uraf = file.createRandomAccessFile("r");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
uraf = file.createRandomAccessFile("r");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (uraf == null) {
|
||||
size = STATE_ERROR;
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -26,6 +26,8 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
|
||||
@@ -51,13 +53,14 @@ public class CleanRedundancyPreference extends TaskPreference {
|
||||
|
||||
private static class ClearTask extends Task {
|
||||
|
||||
private final EhApplication mApplication;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private final SettingsActivity mActivity;
|
||||
private final DownloadManager mManager;
|
||||
|
||||
public ClearTask(@NonNull Context context) {
|
||||
super(context);
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
mManager = EhApplication.getDownloadManager(mApplication);
|
||||
mActivity = (SettingsActivity) context;
|
||||
mManager = EhApplication.getDownloadManager(context.getApplicationContext());
|
||||
}
|
||||
|
||||
// True for cleared
|
||||
@@ -111,9 +114,9 @@ public class CleanRedundancyPreference extends TaskPreference {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
Toast.makeText(mApplication, 0 == count ?
|
||||
mApplication.getString(R.string.settings_download_clean_redundancy_no_redundancy) :
|
||||
mApplication.getString(R.string.settings_download_clean_redundancy_done, count), Toast.LENGTH_SHORT).show();
|
||||
mActivity.showTip(0 == count ?
|
||||
mActivity.getString(R.string.settings_download_clean_redundancy_no_redundancy) :
|
||||
mActivity.getString(R.string.settings_download_clean_redundancy_done, count), BaseScene.LENGTH_SHORT);
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public class ClearDownloadPathCachePreference extends MessagePreference {
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setTitle(null);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,6 +104,9 @@ public class IdentityCookiePreference extends MessagePreference {
|
||||
|
||||
IdentityCookiePreference.this.onClick(dialog, which);
|
||||
});
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
} else {
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
@@ -35,6 +35,8 @@ import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.spider.SpiderInfo;
|
||||
import com.hippo.ehviewer.spider.SpiderQueen;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
@@ -69,15 +71,16 @@ public class RestoreDownloadPreference extends TaskPreference {
|
||||
|
||||
private static class RestoreTask extends Task {
|
||||
|
||||
private final EhApplication mApplication;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private final SettingsActivity mActivity;
|
||||
private final DownloadManager mManager;
|
||||
private final OkHttpClient mHttpClient;
|
||||
|
||||
public RestoreTask(@NonNull Context context) {
|
||||
super(context);
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
mManager = EhApplication.getDownloadManager(mApplication);
|
||||
mHttpClient = EhApplication.getOkHttpClient(mApplication);
|
||||
mActivity = (SettingsActivity) context;
|
||||
mManager = EhApplication.getDownloadManager(context.getApplicationContext());
|
||||
mHttpClient = EhApplication.getOkHttpClient(context.getApplicationContext());
|
||||
}
|
||||
|
||||
private RestoreItem getRestoreItem(UniFile file) {
|
||||
@@ -151,11 +154,11 @@ public class RestoreDownloadPreference extends TaskPreference {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onPostExecute(Object o) {
|
||||
if (!(o instanceof List)) {
|
||||
Toast.makeText(mApplication, R.string.settings_download_restore_failed, Toast.LENGTH_SHORT).show();
|
||||
mActivity.showTip(R.string.settings_download_restore_failed, BaseScene.LENGTH_SHORT);
|
||||
} else {
|
||||
List<RestoreItem> list = (List<RestoreItem>) o;
|
||||
if (list.isEmpty()) {
|
||||
Toast.makeText(mApplication, R.string.settings_download_restore_not_found, Toast.LENGTH_SHORT).show();
|
||||
mActivity.showTip(R.string.settings_download_restore_not_found, BaseScene.LENGTH_SHORT);
|
||||
} else {
|
||||
int count = 0;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
@@ -169,9 +172,9 @@ public class RestoreDownloadPreference extends TaskPreference {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Toast.makeText(mApplication,
|
||||
mApplication.getString(R.string.settings_download_restore_successfully, count),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
mActivity.showTip(
|
||||
mActivity.getString(R.string.settings_download_restore_successfully, count),
|
||||
BaseScene.LENGTH_SHORT);
|
||||
|
||||
Preference preference = getPreference();
|
||||
if (null != preference) {
|
||||
|
||||
@@ -16,42 +16,38 @@
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.preference.ActivityPreference;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class SignInRequiredActivityPreference extends ActivityPreference {
|
||||
|
||||
private View view;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private final SettingsActivity mActivity;
|
||||
|
||||
public SignInRequiredActivityPreference(Context context) {
|
||||
super(context);
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
public SignInRequiredActivityPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
public SignInRequiredActivityPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
view = holder.itemView;
|
||||
super.onBindViewHolder(holder);
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,11 +62,7 @@ public class SignInRequiredActivityPreference extends ActivityPreference {
|
||||
store.contains(ex, EhCookieStore.KEY_IPD_PASS_HASH)) {
|
||||
super.onClick();
|
||||
} else {
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.error_please_login_first, 3000).show();
|
||||
} else {
|
||||
Toast.makeText(getContext(), R.string.error_please_login_first, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
mActivity.showTip(R.string.error_please_login_first, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,31 +16,39 @@
|
||||
|
||||
package com.hippo.ehviewer.preference;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.preference.MessagePreference;
|
||||
|
||||
public class SignOutPreference extends MessagePreference {
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private final SettingsActivity mActivity;
|
||||
|
||||
public SignOutPreference(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
public SignOutPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
public SignOutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
mActivity = (SettingsActivity) context;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
@@ -51,6 +59,7 @@ public class SignOutPreference extends MessagePreference {
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
builder.setPositiveButton(R.string.settings_eh_sign_out_yes, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +67,7 @@ public class SignOutPreference extends MessagePreference {
|
||||
super.onDialogClosed(positiveResult);
|
||||
if (positiveResult) {
|
||||
EhUtils.signOut(getContext());
|
||||
Toast.makeText(getContext(), R.string.settings_eh_sign_out_tip, Toast.LENGTH_SHORT).show();
|
||||
mActivity.showTip(R.string.settings_eh_sign_out_tip, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class SpiderInfo {
|
||||
}
|
||||
}
|
||||
|
||||
return startPage >= 0 ? startPage : 0;
|
||||
return Math.max(startPage, 0);
|
||||
}
|
||||
|
||||
private static int getVersion(String str) {
|
||||
@@ -171,7 +171,7 @@ public class SpiderInfo {
|
||||
writer.write(VERSION_STR);
|
||||
writer.write(Integer.toString(VERSION));
|
||||
writer.write("\n");
|
||||
writer.write(String.format("%08x", startPage >= 0 ? startPage : 0)); // Avoid negative
|
||||
writer.write(String.format("%08x", Math.max(startPage, 0))); // Avoid negative
|
||||
writer.write("\n");
|
||||
writer.write(Long.toString(gid));
|
||||
writer.write("\n");
|
||||
|
||||
@@ -167,7 +167,7 @@ public final class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
mWorkerPoolExecutor = new ThreadPoolExecutor(mWorkerMaxCount, mWorkerMaxCount,
|
||||
0, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>(),
|
||||
0, TimeUnit.SECONDS, new LinkedBlockingDeque<>(),
|
||||
new PriorityThreadFactory(SpiderWorker.class.getSimpleName(), Process.THREAD_PRIORITY_BACKGROUND));
|
||||
}
|
||||
|
||||
@@ -1019,6 +1019,33 @@ public final class SpiderQueen implements Runnable {
|
||||
void onGetImageFailure(int index, String error);
|
||||
}
|
||||
|
||||
private static class AutoCloseInputStream extends InputStream {
|
||||
|
||||
private final InputStreamPipe mPipe;
|
||||
private final InputStream mIs;
|
||||
|
||||
public AutoCloseInputStream(InputStreamPipe pipe, InputStream is) {
|
||||
mPipe = pipe;
|
||||
mIs = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return mIs.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(@NonNull byte[] buffer, int byteOffset, int byteCount) throws IOException {
|
||||
return mIs.read(buffer, byteOffset, byteCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
mPipe.close();
|
||||
mPipe.release();
|
||||
}
|
||||
}
|
||||
|
||||
private class SpiderWorker implements Runnable {
|
||||
|
||||
private final long mGid;
|
||||
@@ -1606,31 +1633,4 @@ public final class SpiderQueen implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AutoCloseInputStream extends InputStream {
|
||||
|
||||
private final InputStreamPipe mPipe;
|
||||
private final InputStream mIs;
|
||||
|
||||
public AutoCloseInputStream(InputStreamPipe pipe, InputStream is) {
|
||||
mPipe = pipe;
|
||||
mIs = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return mIs.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(@NonNull byte[] buffer, int byteOffset, int byteCount) throws IOException {
|
||||
return mIs.read(buffer, byteOffset, byteCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
mPipe.close();
|
||||
mPipe.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,6 @@ import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.hippo.app.ListCheckBoxDialogBuilder;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
@@ -192,36 +190,33 @@ public final class CommonOperations {
|
||||
}
|
||||
|
||||
new ListCheckBoxDialogBuilder(activity, items,
|
||||
new ListCheckBoxDialogBuilder.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(ListCheckBoxDialogBuilder builder, AlertDialog dialog, int position) {
|
||||
String label;
|
||||
if (position == 0) {
|
||||
label = null;
|
||||
} else {
|
||||
label = items[position];
|
||||
if (!dm.containLabel(label)) {
|
||||
label = null;
|
||||
}
|
||||
(builder, dialog, position) -> {
|
||||
String label1;
|
||||
if (position == 0) {
|
||||
label1 = null;
|
||||
} else {
|
||||
label1 = items[position];
|
||||
if (!dm.containLabel(label1)) {
|
||||
label1 = null;
|
||||
}
|
||||
// Start download
|
||||
for (GalleryInfo gi : toAdd) {
|
||||
Intent intent = new Intent(activity, DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_START);
|
||||
intent.putExtra(DownloadService.KEY_LABEL, label);
|
||||
intent.putExtra(DownloadService.KEY_GALLERY_INFO, gi);
|
||||
activity.startService(intent);
|
||||
}
|
||||
// Save settings
|
||||
if (builder.isChecked()) {
|
||||
Settings.putHasDefaultDownloadLabel(true);
|
||||
Settings.putDefaultDownloadLabel(label);
|
||||
} else {
|
||||
Settings.putHasDefaultDownloadLabel(false);
|
||||
}
|
||||
// Notify
|
||||
activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
// Start download
|
||||
for (GalleryInfo gi : toAdd) {
|
||||
Intent intent = new Intent(activity, DownloadService.class);
|
||||
intent.setAction(DownloadService.ACTION_START);
|
||||
intent.putExtra(DownloadService.KEY_LABEL, label1);
|
||||
intent.putExtra(DownloadService.KEY_GALLERY_INFO, gi);
|
||||
activity.startService(intent);
|
||||
}
|
||||
// Save settings
|
||||
if (builder.isChecked()) {
|
||||
Settings.putHasDefaultDownloadLabel(true);
|
||||
Settings.putDefaultDownloadLabel(label1);
|
||||
} else {
|
||||
Settings.putHasDefaultDownloadLabel(false);
|
||||
}
|
||||
// Notify
|
||||
activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT);
|
||||
}, activity.getString(R.string.remember_download_label), false)
|
||||
.setTitle(R.string.download)
|
||||
.show();
|
||||
|
||||
@@ -55,7 +55,6 @@ import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryPageUrlParser;
|
||||
import com.hippo.ehviewer.ui.scene.AnalyticsScene;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.ehviewer.ui.scene.CookieSignInScene;
|
||||
import com.hippo.ehviewer.ui.scene.DownloadLabelsScene;
|
||||
@@ -106,7 +105,7 @@ public final class MainActivity extends StageActivity
|
||||
static {
|
||||
registerLaunchMode(SecurityScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
registerLaunchMode(WarningScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
registerLaunchMode(AnalyticsScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
//registerLaunchMode(AnalyticsScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
registerLaunchMode(SignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
registerLaunchMode(WebViewSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
registerLaunchMode(CookieSignInScene.class, SceneFragment.LAUNCH_MODE_SINGLE_TASK);
|
||||
@@ -597,7 +596,7 @@ public final class MainActivity extends StageActivity
|
||||
public void showTip(CharSequence message, int length) {
|
||||
if (null != mDrawerLayout) {
|
||||
Snackbar.make(mDrawerLayout, message,
|
||||
length == BaseScene.LENGTH_LONG ? 5000 : 3000).show();
|
||||
length == BaseScene.LENGTH_LONG ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(this, message,
|
||||
length == BaseScene.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -59,11 +59,9 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
|
||||
LockPatternUtils.stringToPattern(pattern));
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
if (BiometricManager.from(this).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
mFingerprint.setVisibility(View.VISIBLE);
|
||||
mFingerprint.setChecked(Settings.getEnableFingerprint());
|
||||
}
|
||||
if (BiometricManager.from(this).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
mFingerprint.setVisibility(View.VISIBLE);
|
||||
mFingerprint.setChecked(Settings.getEnableFingerprint());
|
||||
}
|
||||
|
||||
mCancel.setOnClickListener(this);
|
||||
|
||||
@@ -19,10 +19,13 @@ package com.hippo.ehviewer.ui;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.fragment.SettingsFragment;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
|
||||
public final class SettingsActivity extends EhActivity {
|
||||
|
||||
@@ -42,6 +45,18 @@ public final class SettingsActivity extends EhActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void showTip(@StringRes int id, int length) {
|
||||
showTip(getString(id), length);
|
||||
}
|
||||
|
||||
/**
|
||||
* If activity is running, show snack bar, otherwise show toast
|
||||
*/
|
||||
public void showTip(CharSequence message, int length) {
|
||||
Snackbar.make(findViewById(R.id.snackbar), message,
|
||||
length == BaseScene.LENGTH_LONG ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
@@ -16,30 +16,18 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Base64;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class AboutFragment extends PreferenceFragmentCompat
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
|
||||
@@ -47,11 +35,6 @@ public class AboutFragment extends PreferenceFragmentCompat
|
||||
private static final String KEY_DONATE = "donate";
|
||||
private static final String KEY_CHECK_FOR_UPDATES = "check_for_updates";
|
||||
|
||||
private static String base64Decode(String encoded) {
|
||||
byte[] bytes = Base64.decode(encoded, Base64.DEFAULT);
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.about_settings);
|
||||
@@ -74,43 +57,9 @@ public class AboutFragment extends PreferenceFragmentCompat
|
||||
if (KEY_AUTHOR.equals(key)) {
|
||||
AppHelper.sendEmail(requireActivity(), EhApplication.getDeveloperEmail(),
|
||||
"About EhViewer", null);
|
||||
} else if (KEY_DONATE.equals(key)) {
|
||||
showDonationDialog();
|
||||
} else if (KEY_CHECK_FOR_UPDATES.equals(key)) {
|
||||
CommonOperations.checkUpdate(getActivity(), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showDonationDialog() {
|
||||
AlertDialog dialog = new MaterialAlertDialogBuilder(requireActivity())
|
||||
.setView(R.layout.dialog_donate)
|
||||
.show();
|
||||
|
||||
String alipayStr = base64Decode("c2V2ZW4zMzJAMTYzLmNvbQ==");
|
||||
TextView alipayText = dialog.findViewById(R.id.alipay_text);
|
||||
alipayText.setText(alipayStr);
|
||||
dialog.findViewById(R.id.alipay_copy).setOnClickListener(v -> copyToClipboard(alipayStr));
|
||||
|
||||
String paypalStr = base64Decode("aHR0cHM6Ly9wYXlwYWwubWUvc2V2ZW4zMzI=");
|
||||
TextView paypalText = dialog.findViewById(R.id.paypal_text);
|
||||
paypalText.setText(paypalStr);
|
||||
dialog.findViewById(R.id.paypal_open).setOnClickListener(v -> openUrl(paypalStr));
|
||||
dialog.findViewById(R.id.paypal_copy).setOnClickListener(v -> copyToClipboard(paypalStr));
|
||||
}
|
||||
|
||||
private void copyToClipboard(String text) {
|
||||
ClipboardManager cmb = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (cmb != null) {
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, text));
|
||||
Toast.makeText(getActivity(), R.string.settings_about_donate_copied, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void openUrl(String url) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
Intent chooser = Intent.createChooser(intent, "");
|
||||
startActivity(chooser);
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,9 @@
|
||||
package com.hippo.ehviewer.ui.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -29,19 +27,17 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.BuildConfig;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.util.LogCat;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AdvancedFragment extends PreferenceFragmentCompat
|
||||
implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -55,28 +51,6 @@ public class AdvancedFragment extends PreferenceFragmentCompat
|
||||
private static final String KEY_IMPORT_DATA = "import_data";
|
||||
private static final String KEY_EXPORT_DATA = "export_data";
|
||||
|
||||
private static void importData(final Context context) {
|
||||
final File dir = AppConfig.getExternalDataDir();
|
||||
if (null == dir) {
|
||||
Toast.makeText(context, R.string.cant_get_data_dir, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final String[] files = dir.list();
|
||||
if (null == files || files.length <= 0) {
|
||||
Toast.makeText(context, R.string.cant_find_any_data, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Arrays.sort(files);
|
||||
new MaterialAlertDialogBuilder(context).setItems(files, (dialog, which) -> {
|
||||
File file = new File(dir, files[which]);
|
||||
//String error = EhDB.importDB(context, file);
|
||||
//if (null == error) {
|
||||
// error = context.getString(R.string.settings_advanced_import_data_successfully);
|
||||
//}
|
||||
//Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
|
||||
}).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
|
||||
addPreferencesFromResource(R.xml.advanced_settings);
|
||||
@@ -154,15 +128,15 @@ public class AdvancedFragment extends PreferenceFragmentCompat
|
||||
if (alertDialog.isShowing()) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
Toast.makeText(requireContext(),
|
||||
((SettingsActivity) requireActivity()).showTip(
|
||||
(success)
|
||||
? GetText.getString(R.string.settings_advanced_export_data_to, uri.toString())
|
||||
: GetText.getString(R.string.settings_advanced_export_data_failed),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
BaseScene.LENGTH_SHORT);
|
||||
});
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
GetText.getString(R.string.settings_advanced_export_data_failed);
|
||||
((SettingsActivity) requireActivity()).showTip(R.string.settings_advanced_export_data_failed, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,14 +157,14 @@ public class AdvancedFragment extends PreferenceFragmentCompat
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
if (null == error) {
|
||||
Toast.makeText(requireContext(), getString(R.string.settings_advanced_import_data_successfully), Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(getString(R.string.settings_advanced_import_data_successfully), BaseScene.LENGTH_SHORT);
|
||||
} else {
|
||||
Toast.makeText(requireContext(), error, Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(error, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(requireContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(e.getLocalizedMessage(), BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,11 +175,11 @@ public class AdvancedFragment extends PreferenceFragmentCompat
|
||||
requireActivity().grantUriPermission(BuildConfig.APPLICATION_ID, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
try {
|
||||
boolean ok = LogCat.save(requireActivity().getContentResolver().openOutputStream(uri));
|
||||
Toast.makeText(getActivity(),
|
||||
((SettingsActivity) requireActivity()).showTip(
|
||||
ok ? getString(R.string.settings_advanced_dump_logcat_to, uri.toString()) :
|
||||
getString(R.string.settings_advanced_dump_logcat_failed), Toast.LENGTH_SHORT).show();
|
||||
getString(R.string.settings_advanced_dump_logcat_failed), BaseScene.LENGTH_SHORT);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getActivity(), getString(R.string.settings_advanced_dump_logcat_failed), Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(getString(R.string.settings_advanced_dump_logcat_failed), BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.Preference;
|
||||
@@ -28,6 +27,8 @@ import androidx.preference.Preference;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.SettingsActivity;
|
||||
import com.hippo.ehviewer.ui.scene.BaseScene;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.takisoft.preferencex.PreferenceFragmentCompat;
|
||||
@@ -95,7 +96,7 @@ public class DownloadFragment extends PreferenceFragmentCompat implements
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE_DIR_L);
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
Toast.makeText(getActivity(), R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(R.string.error_cant_find_activity, BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +114,8 @@ public class DownloadFragment extends PreferenceFragmentCompat implements
|
||||
Settings.putDownloadLocation(uniFile);
|
||||
onUpdateDownloadLocation();
|
||||
} else {
|
||||
Toast.makeText(getActivity(), R.string.settings_download_cant_get_download_location,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
((SettingsActivity) requireActivity()).showTip(R.string.settings_download_cant_get_download_location,
|
||||
BaseScene.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
LongList gidList = new LongList();
|
||||
for (int i = list.size() - 1; i > -1; i--) {
|
||||
DownloadInfo info = list.get(i);
|
||||
if(info.state!=DownloadInfo.STATE_FINISH){
|
||||
if (info.state != DownloadInfo.STATE_FINISH) {
|
||||
gidList.add(info.gid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
@@ -66,7 +67,6 @@ import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
@@ -91,7 +92,6 @@ import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.ehviewer.widget.GalleryRatingBar;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
|
||||
@@ -77,8 +77,6 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
mQuickSearchList = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView3(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.hippo.ehviewer.ui.scene;
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -100,7 +99,11 @@ public class SecurityScene extends SolidScene implements
|
||||
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
|
||||
if (isFingerprintAuthAvailable()) {
|
||||
startBiometricPrompt();
|
||||
}
|
||||
|
||||
private void startBiometricPrompt() {
|
||||
if (Settings.getEnableFingerprint() && BiometricManager.from(requireContext()).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
BiometricPrompt biometricPrompt = new BiometricPrompt(this, Executors.newSingleThreadExecutor(), new BiometricPrompt.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) {
|
||||
@@ -147,6 +150,7 @@ public class SecurityScene extends SolidScene implements
|
||||
public View onCreateView2(LayoutInflater inflater,
|
||||
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.scene_security, container, false);
|
||||
view.setOnClickListener(v -> startBiometricPrompt());
|
||||
|
||||
mPatternView = (LockPatternView) ViewUtils.$$(view, R.id.pattern_view);
|
||||
mPatternView.setOnPatternListener(this);
|
||||
@@ -206,10 +210,4 @@ public class SecurityScene extends SolidScene implements
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFingerprintAuthAvailable() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& Settings.getEnableFingerprint()
|
||||
&& BiometricManager.from(requireContext()).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.io;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.hippo.streampipe.InputStreamPipe;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class FileInputStreamPipe implements InputStreamPipe {
|
||||
|
||||
private final File mFile;
|
||||
private InputStream mIs;
|
||||
|
||||
public FileInputStreamPipe(File file) {
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void obtain() {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public InputStream open() throws IOException {
|
||||
if (mIs != null) {
|
||||
throw new IllegalStateException("Please close it first");
|
||||
}
|
||||
|
||||
mIs = new FileInputStream(mFile);
|
||||
return mIs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
IOUtils.closeQuietly(mIs);
|
||||
mIs = null;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.io;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.hippo.streampipe.OutputStreamPipe;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class FileOutputStreamPipe implements OutputStreamPipe {
|
||||
|
||||
private final File mFile;
|
||||
private OutputStream mOs;
|
||||
|
||||
public FileOutputStreamPipe(File file) {
|
||||
mFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void obtain() {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
// Empty
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public OutputStream open() throws IOException {
|
||||
if (mOs != null) {
|
||||
throw new IllegalStateException("Please close it first");
|
||||
}
|
||||
|
||||
mOs = new FileOutputStream(mFile);
|
||||
return mOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
IOUtils.closeQuietly(mOs);
|
||||
mOs = null;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.reveal;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.view.View;
|
||||
|
||||
public final class ViewAnimationUtils {
|
||||
public static Animator createCircularReveal(View view,
|
||||
int centerX, int centerY, float startRadius, float endRadius) {
|
||||
return android.view.ViewAnimationUtils.createCircularReveal(
|
||||
view, centerX, centerY, startRadius, endRadius);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
public class PermissionRequester {
|
||||
|
||||
/**
|
||||
* @return true for there no need to request, do your work it now.
|
||||
* false for do in {@link androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int, String[], int[])}
|
||||
*/
|
||||
public static boolean request(final Activity activity, final String permission, String rationale, final int requestCode) {
|
||||
if (!(activity instanceof ActivityCompat.OnRequestPermissionsResultCallback)) {
|
||||
throw new IllegalStateException("The Activity must implement ActivityCompat.OnRequestPermissionsResultCallback");
|
||||
}
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(activity, permission)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
|
||||
new MaterialAlertDialogBuilder(activity)
|
||||
.setMessage(rationale)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> requestPermissions(activity, new String[]{permission}, requestCode)).setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
} else {
|
||||
return requestPermissions(activity, new String[]{permission}, requestCode);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean requestPermissions(
|
||||
final Activity activity,
|
||||
final String[] permissions,
|
||||
int requestCode
|
||||
) {
|
||||
try {
|
||||
ActivityCompat.requestPermissions(activity, permissions, requestCode);
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
ExceptionUtils.throwIfFatal(t);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 114 B |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 100 B |
|
Before Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 129 B |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 155 B |
|
Before Width: | Height: | Size: 156 B |
|
Before Width: | Height: | Size: 16 KiB |