diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.java b/app/src/main/java/com/hippo/ehviewer/Settings.java index 167c9e857..7f5b414e5 100755 --- a/app/src/main/java/com/hippo/ehviewer/Settings.java +++ b/app/src/main/java/com/hippo/ehviewer/Settings.java @@ -175,6 +175,8 @@ public class Settings { private static final int DEFAULT_PRELOAD_IMAGE = 5; private static final String KEY_DOWNLOAD_ORIGIN_IMAGE = "download_origin_image"; private static final boolean DEFAULT_DOWNLOAD_ORIGIN_IMAGE = false; + private static final String KEY_READ_THEME = "read_theme"; + private static final int DEFAULT_READ_THEME = 1; /******************** ****** Favorites ********************/ @@ -669,6 +671,14 @@ public class Settings { putInt(KEY_SCREEN_LIGHTNESS, value); } + public static int getReadTheme() { + return getIntFromStr(KEY_READ_THEME, DEFAULT_READ_THEME); + } + + public static void putReadTheme(int value) { + putIntToStr(KEY_READ_THEME, value); + } + public static boolean getEnabledSecurity() { return getBoolean(KEY_SEC_SECURITY, VALUE_SEC_SECURITY); } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java index 7c96f1a7e..3f57fb9fd 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryActivity.java @@ -256,7 +256,16 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan @Override @SuppressWarnings({"WrongConstant"}) protected void onCreate(@Nullable Bundle savedInstanceState) { - getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); + switch (Settings.getReadTheme()) { + case 0: + break; + case 1: + getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); + break; + case 2: + getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); + break; + } if (Settings.getReadingFullscreen()) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, @@ -321,11 +330,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan // System UI helper if (Settings.getReadingFullscreen()) { int systemUiLevel; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - systemUiLevel = SystemUiHelper.LEVEL_IMMERSIVE; - } else { - systemUiLevel = SystemUiHelper.LEVEL_HIDE_STATUS_BAR; - } + systemUiLevel = SystemUiHelper.LEVEL_IMMERSIVE; mSystemUiHelper = new SystemUiHelper(this, systemUiLevel, SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES | SystemUiHelper.FLAG_IMMERSIVE_STICKY); mSystemUiHelper.hide(); @@ -954,6 +959,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan private final Spinner mReadingDirection; private final Spinner mScaleMode; private final Spinner mStartPosition; + private final Spinner mReadTheme; private final SwitchCompat mKeepScreenOn; private final SwitchCompat mShowClock; private final SwitchCompat mShowProgress; @@ -971,6 +977,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan mReadingDirection = mView.findViewById(R.id.reading_direction); mScaleMode = mView.findViewById(R.id.page_scaling); mStartPosition = mView.findViewById(R.id.start_position); + mReadTheme = mView.findViewById(R.id.read_theme); mKeepScreenOn = mView.findViewById(R.id.keep_screen_on); mShowClock = mView.findViewById(R.id.show_clock); mShowProgress = mView.findViewById(R.id.show_progress); @@ -985,6 +992,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan mReadingDirection.setSelection(Settings.getReadingDirection()); mScaleMode.setSelection(Settings.getPageScaling()); mStartPosition.setSelection(Settings.getStartPosition()); + mReadTheme.setSelection(Settings.getReadTheme()); mKeepScreenOn.setChecked(Settings.getKeepScreenOn()); mShowClock.setChecked(Settings.getShowClock()); mShowProgress.setChecked(Settings.getShowProgress()); @@ -1013,6 +1021,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition()); int scaleMode = GalleryView.sanitizeScaleMode(mScaleMode.getSelectedItemPosition()); int startPosition = GalleryView.sanitizeStartPosition(mStartPosition.getSelectedItemPosition()); + int readTheme = mReadTheme.getSelectedItemPosition(); boolean keepScreenOn = mKeepScreenOn.isChecked(); boolean showClock = mShowClock.isChecked(); boolean showProgress = mShowProgress.isChecked(); @@ -1023,12 +1032,14 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan boolean customScreenLightness = mCustomScreenLightness.isChecked(); int screenLightness = mScreenLightness.getProgress(); + int oldReadTheme = Settings.getReadTheme(); boolean oldReadingFullscreen = Settings.getReadingFullscreen(); Settings.putScreenRotation(screenRotation); Settings.putReadingDirection(layoutMode); Settings.putPageScaling(scaleMode); Settings.putStartPosition(startPosition); + Settings.putReadTheme(readTheme); Settings.putKeepScreenOn(keepScreenOn); Settings.putShowClock(showClock); Settings.putShowProgress(showProgress); @@ -1056,6 +1067,17 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan break; } setRequestedOrientation(orientation); + switch (Settings.getReadTheme()) { + case 0: + getDelegate().setLocalNightMode(AppCompatDelegate.getDefaultNightMode()); + break; + case 1: + getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); + break; + case 2: + getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); + break; + } mGalleryView.setLayoutMode(layoutMode); mGalleryView.setScaleMode(scaleMode); mGalleryView.setStartPosition(startPosition); @@ -1081,7 +1103,7 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan mLayoutMode = layoutMode; updateSlider(); - if (oldReadingFullscreen != readingFullscreen) { + if (oldReadingFullscreen != readingFullscreen || oldReadTheme != readTheme) { recreate(); } } diff --git a/app/src/main/res/layout/dialog_gallery_menu.xml b/app/src/main/res/layout/dialog_gallery_menu.xml index 33eb60a4d..6885c61a6 100644 --- a/app/src/main/res/layout/dialog_gallery_menu.xml +++ b/app/src/main/res/layout/dialog_gallery_menu.xml @@ -123,6 +123,29 @@ android:entries="@array/start_position_entries" /> + + + + + + + + 从搜索记录中删除“%s”? 安全 DNS(DoH) 解决某些地区的 DNS 污染问题 + 色彩主题 + 跟随应用 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index a2949abbc..1d05372b8 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -325,4 +325,16 @@ @string/download_state_finish @string/download_state_failed + + + @string/follow_app + @string/theme_dark + @string/theme_light + + + + 0 + 1 + 2 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb868df2b..64983952e 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -800,4 +800,6 @@ From clipboard No cookies found in clipboard. Delete \"%s\" from search history? + Color theme + Follow app diff --git a/app/src/main/res/xml/read_settings.xml b/app/src/main/res/xml/read_settings.xml index ef7feb909..b8f1eca25 100644 --- a/app/src/main/res/xml/read_settings.xml +++ b/app/src/main/res/xml/read_settings.xml @@ -53,6 +53,15 @@ app:entryValues="@array/start_position_values" app:iconSpaceReserved="false" /> + +