diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 29c6c0054..177486466 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,8 +1,16 @@ +-keepclassmembers class * implements android.os.Parcelable { + public static final ** CREATOR; +} + -assumenosideeffects class kotlin.jvm.internal.Intrinsics { public static void check*(...); public static void throw*(...); } +-repackageclasses +-allowaccessmodification +-overloadaggressively + -keepattributes SourceFile,LineNumberTable -keep class com.hippo.a7zip.* { *; } diff --git a/app/src/main/java/com/hippo/content/RecordingApplication.java b/app/src/main/java/com/hippo/content/RecordingApplication.java deleted file mode 100644 index 68ee7f49a..000000000 --- a/app/src/main/java/com/hippo/content/RecordingApplication.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2018 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.content; - -/* - * Created by Hippo on 2018/3/27. - */ - -import android.app.Activity; -import android.os.Bundle; - -import com.hippo.scene.SceneApplication; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -public abstract class RecordingApplication extends SceneApplication { - - private final List> list = new LinkedList<>(); - - @Override - public void onCreate() { - super.onCreate(); - - registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - list.add(new java.lang.ref.WeakReference<>(activity)); - } - - @Override - public void onActivityDestroyed(Activity activity) { - Iterator> iterator = list.iterator(); - while (iterator.hasNext()) { - WeakReference reference = iterator.next(); - Activity a = reference.get(); - // Remove current activity and null - if (a == null || a == activity) { - iterator.remove(); - } - } - } - - @Override - public void onActivityStarted(Activity activity) { - } - - @Override - public void onActivityResumed(Activity activity) { - } - - @Override - public void onActivityPaused(Activity activity) { - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - }); - } - - public void recreate() { - // Copy list - ArrayList listCopy = new ArrayList<>(list.size()); - for (WeakReference reference : list) { - Activity activity = reference.get(); - if (activity == null) continue; - listCopy.add(activity); - } - - // Finish all activities - for (int i = listCopy.size() - 1; i >= 0; --i) { - listCopy.get(i).recreate(); - } - } -} diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java index b109c3d60..94d609d04 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java @@ -36,7 +36,6 @@ import androidx.collection.LruCache; import com.hippo.a7zip.A7Zip; import com.hippo.beerbelly.SimpleDiskCache; import com.hippo.conaco.Conaco; -import com.hippo.content.RecordingApplication; import com.hippo.ehviewer.client.EhClient; import com.hippo.ehviewer.client.EhCookieStore; import com.hippo.ehviewer.client.EhDns; @@ -52,6 +51,7 @@ import com.hippo.ehviewer.ui.CommonOperations; import com.hippo.image.Image; import com.hippo.image.ImageBitmap; import com.hippo.network.StatusCodeException; +import com.hippo.scene.SceneApplication; import com.hippo.text.Html; import com.hippo.unifile.UniFile; import com.hippo.util.BitmapUtils; @@ -86,7 +86,7 @@ import okhttp3.Request; import rikka.material.app.DayNightDelegate; import rikka.material.app.LocaleDelegate; -public class EhApplication extends RecordingApplication { +public class EhApplication extends SceneApplication { public static final boolean BETA = false; private static final String TAG = EhApplication.class.getSimpleName(); diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java index 03e9dd9aa..49ed782bd 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java +++ b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.java @@ -151,7 +151,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable { } public String getKeyword() { - return MODE_UPLOADER == mMode ? "uploader:" + mKeyword :mKeyword; + return MODE_UPLOADER == mMode ? "uploader:" + mKeyword : mKeyword; } public void setKeyword(String keyword) { diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java index d07e71d94..c56006ea4 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.java @@ -43,6 +43,6 @@ public class ArchiveParser { Pair item = new Pair<>(res, name); archiveList.add(item); } - return new Pair[]>(paramOr, archiveList.toArray(new Pair[archiveList.size()])); + return new Pair<>(paramOr, archiveList.toArray(new Pair[0])); } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java index 3af3e39b4..c0127db6c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java @@ -16,8 +16,6 @@ package com.hippo.ehviewer.client.parser; -import android.util.Log; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java index 9af3f30bd..4568247a6 100644 --- a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java +++ b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.java @@ -217,7 +217,7 @@ public class DownloadService extends Service implements DownloadManager.Download Intent stopAllIntent = new Intent(this, DownloadService.class); stopAllIntent.setAction(ACTION_STOP_ALL); - PendingIntent piStopAll = PendingIntent.getService(this, 0, stopAllIntent, 0); + PendingIntent piStopAll = PendingIntent.getService(this, 0, stopAllIntent, PendingIntent.FLAG_IMMUTABLE); mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) .setSmallIcon(android.R.drawable.stat_sys_download) @@ -240,7 +240,7 @@ public class DownloadService extends Service implements DownloadManager.Download Intent clearIntent = new Intent(this, DownloadService.class); clearIntent.setAction(ACTION_CLEAR); - PendingIntent piClear = PendingIntent.getService(this, 0, clearIntent, 0); + PendingIntent piClear = PendingIntent.getService(this, 0, clearIntent, PendingIntent.FLAG_IMMUTABLE); Bundle bundle = new Bundle(); bundle.putString(DownloadsScene.KEY_ACTION, DownloadsScene.ACTION_CLEAR_DOWNLOAD_SERVICE); @@ -249,7 +249,7 @@ public class DownloadService extends Service implements DownloadManager.Download activityIntent.putExtra(StageActivity.KEY_SCENE_NAME, DownloadsScene.class.getName()); activityIntent.putExtra(StageActivity.KEY_SCENE_ARGS, bundle); PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0, - activityIntent, PendingIntent.FLAG_UPDATE_CURRENT); + activityIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); mDownloadedBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID) .setSmallIcon(android.R.drawable.stat_sys_download_done) @@ -310,7 +310,7 @@ public class DownloadService extends Service implements DownloadManager.Download activityIntent.putExtra(StageActivity.KEY_SCENE_NAME, DownloadsScene.class.getName()); activityIntent.putExtra(StageActivity.KEY_SCENE_ARGS, bundle); PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0, - activityIntent, PendingIntent.FLAG_UPDATE_CURRENT); + activityIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); mDownloadingBuilder.setContentTitle(EhUtils.getSuitableTitle(info)) .setContentText(null) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/MyTagsFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/MyTagsFragment.java index 2361913c1..1a1559854 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/MyTagsFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/MyTagsFragment.java @@ -19,7 +19,6 @@ 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.widget.DialogWebChromeClient; import okhttp3.Cookie; @@ -36,7 +35,6 @@ public class MyTagsFragment extends BaseFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_webview, container, false); - ((SettingsActivity) requireActivity()).getDelegate().applyDayNight(); webView = view.findViewById(R.id.webview); webView.setBackgroundColor(AttrResources.getAttrColor(requireActivity(), android.R.attr.colorBackground)); webView.getSettings().setBuiltInZoomControls(true); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.java b/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.java index 6a9b89a2a..17583111b 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.java @@ -22,7 +22,6 @@ 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.ehviewer.widget.DialogWebChromeClient; @@ -41,7 +40,6 @@ public class UConfigFragment extends BaseFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_webview, container, false); - ((SettingsActivity) requireActivity()).getDelegate().applyDayNight(); webView = view.findViewById(R.id.webview); webView.setBackgroundColor(AttrResources.getAttrColor(requireActivity(), android.R.attr.colorBackground)); webView.getSettings().setBuiltInZoomControls(true); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java index 243fba995..fcf6f9dae 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/WebViewSignInScene.java @@ -34,7 +34,6 @@ import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.client.EhCookieStore; import com.hippo.ehviewer.client.EhUrl; import com.hippo.ehviewer.client.EhUtils; -import com.hippo.ehviewer.ui.MainActivity; import com.hippo.ehviewer.widget.DialogWebChromeClient; import com.hippo.yorozuya.AssertUtils; @@ -75,7 +74,6 @@ public class WebViewSignInScene extends SolidScene { cookieManager.removeSessionCookies(null); mWebView = new WebView(context); - ((MainActivity) context).getDelegate().applyDayNight(); mWebView.setBackgroundColor(AttrResources.getAttrColor(requireActivity(), android.R.attr.colorBackground)); mWebView.getSettings().setBuiltInZoomControls(true); mWebView.getSettings().setDisplayZoomControls(false); diff --git a/app/src/main/java/com/hippo/ehviewer/widget/DividerView.java b/app/src/main/java/com/hippo/ehviewer/widget/DividerView.java deleted file mode 100644 index 5fe819bc2..000000000 --- a/app/src/main/java/com/hippo/ehviewer/widget/DividerView.java +++ /dev/null @@ -1,84 +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.ehviewer.widget; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.view.View; - -import com.hippo.ehviewer.R; - -public class DividerView extends View { - - private Paint mPaint; - private Rect mRect; - private int mDividerWidth; - private int mDividerHeight; - - public DividerView(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public DividerView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DividerView); - int color = a.getColor(R.styleable.DividerView_dividerColor, Color.BLACK); - mDividerWidth = a.getDimensionPixelOffset(R.styleable.DividerView_dividerWidth, 0); - mDividerHeight = a.getDimensionPixelOffset(R.styleable.DividerView_dividerHeight, 0); - a.recycle(); - - mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); - mPaint.setColor(color); - mRect = new Rect(); - } - - @Override - protected int getSuggestedMinimumWidth() { - return Math.max((getPaddingLeft() + getPaddingRight() + mDividerWidth), super.getSuggestedMinimumWidth()); - } - - @Override - protected int getSuggestedMinimumHeight() { - return Math.max((getPaddingTop() + getPaddingBottom() + mDividerHeight), super.getSuggestedMinimumHeight()); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - Rect rect = mRect; - rect.set(getPaddingLeft(), getPaddingTop(), - getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); - if (!rect.isEmpty()) { - canvas.drawRect(rect, mPaint); - } - } -}