Revert "Drop rikkax"

This reverts commit 87d284ad97.
This commit is contained in:
tarsin committed 2022-05-27 00:26:48 +08:00
1 parent aa18e5f2f1
commit f305a59880
46 files changed
+281 -69

No files matched your search

+3
View File
@@ -126,6 +126,8 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
implementation 'com.takisoft.preferencex:preferencex:1.1.0'
implementation 'com.gitlab.NekoInverter:yorozuya:723dc867a9'
implementation 'dev.rikka.rikkax.appcompat:appcompat:1.4.1'
implementation 'dev.rikka.rikkax.material:material:2.4.0'
implementation 'dev.rikka.rikkax.preference:simplemenu-preference:1.0.3'
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
implementation 'org.greenrobot:greendao:3.3.0'
@@ -148,5 +150,6 @@ configurations.all {
exclude group: 'com.github.seven332', module: 'okhttp'
exclude group: 'com.github.seven332', module: 'image'
exclude group: 'com.github.seven332', module: 'yorozuya'
exclude group: 'androidx.appcompat', module: 'appcompat'
}
}
@@ -47,12 +47,13 @@ public class AddDeleteDrawable extends Drawable {
/**
* @param context used to get the configuration for the drawable from
*/
public AddDeleteDrawable(Context context) {
public AddDeleteDrawable(Context context, int color) {
Resources resources = context.getResources();
mSize = resources.getDimensionPixelSize(R.dimen.add_size);
float barThickness = Math.round(resources.getDimension(R.dimen.add_thickness));
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.MITER);
mPaint.setStrokeCap(Paint.Cap.BUTT);
@@ -67,10 +67,11 @@ public class DrawerArrowDrawable extends Drawable {
/**
* @param context used to get the configuration for the drawable from
*/
public DrawerArrowDrawable(Context context) {
public DrawerArrowDrawable(Context context, int color) {
Resources resources = context.getResources();
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mSize = resources.getDimensionPixelSize(R.dimen.dad_drawable_size);
// round this because having this floating may cause bad measurements
mBarSize = Math.round(resources.getDimension(R.dimen.dad_bar_size));
@@ -144,6 +145,11 @@ public class DrawerArrowDrawable extends Drawable {
canvas.restore();
}
public void setColor(@ColorInt int color) {
mPaint.setColor(color);
invalidateSelf();
}
@Override
public void setAlpha(int i) {
mPaint.setAlpha(i);
@@ -91,6 +91,8 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import rikka.material.app.DayNightDelegate;
import rikka.material.app.LocaleDelegate;
public class EhApplication extends SceneApplication {
@@ -334,6 +336,10 @@ public class EhApplication extends SceneApplication {
EhDB.mergeOldDB(this);
}
LocaleDelegate.setDefaultLocale(Settings.getLocale());
DayNightDelegate.setApplicationContext(this);
DayNightDelegate.setDefaultNightMode(Settings.getTheme());
// Do io tasks in new thread
//noinspection deprecation
new AsyncTask<Void, Void, Void>() {
@@ -18,18 +18,25 @@ package com.hippo.ehviewer.ui;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.StyleRes;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
public abstract class EhActivity extends AppCompatActivity {
import rikka.core.res.ResourcesKt;
import rikka.material.app.MaterialActivity;
public abstract class EhActivity extends MaterialActivity {
private static final String THEME_DEFAULT = "DEFAULT";
private static final String THEME_BLACK = "BLACK";
@@ -48,16 +55,27 @@ public abstract class EhActivity extends AppCompatActivity {
return (configuration.uiMode & Configuration.UI_MODE_NIGHT_YES) > 0;
}
@Override
public void onApplyUserThemeResource(@NonNull Resources.Theme theme, boolean isDecorView) {
theme.applyStyle(getThemeStyleRes(this), true);
}
@Override
public String computeUserThemeKey() {
return getTheme(this);
}
@StyleRes
public int getThemeStyleRes(Context context) {
if (THEME_BLACK.equals(getTheme(context))) {
return R.style.ThemeOverlay_Black;
}
return R.style.ThemeOverlay;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
window.setStatusBarColor(Color.TRANSPARENT);
window.getDecorView().post(() -> {
window.setNavigationBarColor(Color.TRANSPARENT);
window.setNavigationBarContrastEnforced(true);
});
((EhApplication) getApplication()).registerActivity(this);
}
@@ -77,4 +95,22 @@ public abstract class EhActivity extends AppCompatActivity {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
}
@Override
public void onApplyTranslucentSystemBars() {
super.onApplyTranslucentSystemBars();
Window window = getWindow();
window.setStatusBarColor(Color.TRANSPARENT);
window.getDecorView().post(() -> {
WindowInsets rootWindowInsets = window.getDecorView().getRootWindowInsets();
if (rootWindowInsets != null && rootWindowInsets.getSystemWindowInsetBottom() >= Resources.getSystem().getDisplayMetrics().density * 40) {
window.setNavigationBarColor(ResourcesKt.resolveColor(getTheme(), android.R.attr.navigationBarColor) & 0x00ffffff | -0x20000000);
window.setNavigationBarContrastEnforced(false);
} else {
window.setNavigationBarColor(Color.TRANSPARENT);
window.setNavigationBarContrastEnforced(true);
}
});
}
}
@@ -103,6 +103,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import rikka.core.res.ConfigurationKt;
import rikka.core.res.ResourcesKt;
import rikka.material.app.DayNightDelegate;
public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChangeListener,
GalleryView.Listener {
@@ -290,6 +294,24 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex);
}
@Override
protected void attachBaseContext(@NonNull Context newBase) {
switch (Settings.getReadTheme()) {
case 1:
getDayNightDelegate().setLocalNightMode(DayNightDelegate.MODE_NIGHT_YES, false);
break;
case 2:
getDayNightDelegate().setLocalNightMode(DayNightDelegate.MODE_NIGHT_NO, false);
break;
}
super.attachBaseContext(newBase);
}
@Override
public boolean respectDefaultNightMode() {
return Settings.getReadTheme() == 0;
}
@Override
@SuppressWarnings({"WrongConstant"})
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -330,13 +352,15 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
.setScaleMode(Settings.getPageScaling())
.setStartPosition(Settings.getStartPosition())
.setStartPage(startPage)
.setEdgeColor(0)
.setBackgroundColor(ResourcesKt.resolveColor(getTheme(), android.R.attr.colorBackground))
.setEdgeColor(ResourcesKt.resolveColor(getTheme(), R.attr.colorEdgeEffect) & 0xffffff | 0x33000000)
.setPagerInterval(Settings.getShowPageInterval() ? resources.getDimensionPixelOffset(R.dimen.gallery_pager_interval) : 0)
.setScrollInterval(Settings.getShowPageInterval() ? resources.getDimensionPixelOffset(R.dimen.gallery_scroll_interval) : 0)
.setPageMinHeight(resources.getDimensionPixelOffset(R.dimen.gallery_page_min_height))
.setPageInfoInterval(resources.getDimensionPixelOffset(R.dimen.gallery_page_info_interval))
.setProgressColor(ResourcesUtils.getAttrColor(this, androidx.appcompat.R.attr.colorPrimary))
.setProgressSize(resources.getDimensionPixelOffset(R.dimen.gallery_progress_size))
.setPageTextColor(ResourcesKt.resolveColor(getTheme(), android.R.attr.textColorSecondary))
.setPageTextSize(resources.getDimensionPixelOffset(R.dimen.gallery_page_text_size))
.setPageTextTypeface(Typeface.DEFAULT)
.setErrorTextColor(resources.getColor(R.color.red_500))
@@ -360,6 +384,9 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
insetsController.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH);
insetsController.show(WindowInsetsCompat.Type.systemBars());
}
boolean night = ConfigurationKt.isNight(getResources().getConfiguration());
insetsController.setAppearanceLightStatusBars(!night);
insetsController.setAppearanceLightNavigationBars(!night);
}
mMaskView = (ColorView) ViewUtils.$$(this, R.id.mask);
@@ -54,6 +54,8 @@ import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import rikka.material.app.LocaleDelegate;
public class AdvancedFragment extends BasePreferenceFragment {
private static final String KEY_DUMP_LOGCAT = "dump_logcat";
@@ -284,6 +286,21 @@ public class AdvancedFragment extends BasePreferenceFragment {
return false;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (KEY_APP_LANGUAGE.equals(key)) {
if ("system".equals(newValue)) {
LocaleDelegate.setDefaultLocale(LocaleDelegate.getSystemLocale());
} else {
LocaleDelegate.setDefaultLocale(Locale.forLanguageTag((String) newValue));
}
requireActivity().recreate();
return true;
}
return false;
}
@Override
public int getFragmentTitle() {
return R.string.settings_advanced;
@@ -27,12 +27,16 @@ import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.client.EhTagDatabase;
import rikka.material.app.DayNightDelegate;
public class EhFragment extends BasePreferenceFragment {
@Override
public void onCreatePreferencesFix(@Nullable Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.eh_settings);
Preference theme = findPreference(Settings.KEY_THEME);
Preference blackDarkTheme = findPreference(Settings.KEY_BLACK_DARK_THEME);
Preference gallerySite = findPreference(Settings.KEY_GALLERY_SITE);
Preference listMode = findPreference(Settings.KEY_LIST_MODE);
Preference detailSize = findPreference(Settings.KEY_DETAIL_SIZE);
@@ -40,11 +44,13 @@ public class EhFragment extends BasePreferenceFragment {
Preference showTagTranslations = findPreference(Settings.KEY_SHOW_TAG_TRANSLATIONS);
Preference tagTranslationsSource = findPreference("tag_translations_source");
theme.setOnPreferenceChangeListener(this);
gallerySite.setOnPreferenceChangeListener(this);
listMode.setOnPreferenceChangeListener(this);
detailSize.setOnPreferenceChangeListener(this);
thumbSize.setOnPreferenceChangeListener(this);
showTagTranslations.setOnPreferenceChangeListener(this);
blackDarkTheme.setOnPreferenceChangeListener(this);
if (!EhTagDatabase.isPossible(requireActivity())) {
getPreferenceScreen().removePreference(showTagTranslations);
@@ -56,6 +62,7 @@ public class EhFragment extends BasePreferenceFragment {
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
if (Settings.KEY_THEME.equals(key)) {
DayNightDelegate.setDefaultNightMode(Integer.parseInt((String) newValue));
requireActivity().recreate();
return true;
} else if (Settings.KEY_GALLERY_SITE.equals(key)) {
@@ -38,6 +38,8 @@ import com.hippo.yorozuya.ViewUtils;
import java.util.List;
import rikka.core.res.ResourcesKt;
public class FilterFragment extends BaseFragment {
@Nullable
@@ -76,7 +78,7 @@ public class FilterFragment extends BaseFragment {
recyclerView.setClipChildren(false);
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(requireActivity().getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(requireActivity(), 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
@@ -30,6 +30,8 @@ import com.hippo.yorozuya.ViewUtils;
import java.util.List;
import java.util.Locale;
import rikka.core.res.ResourcesKt;
public class HostsFragment extends BaseFragment
implements View.OnClickListener {
@@ -67,7 +69,7 @@ public class HostsFragment extends BaseFragment
recyclerView.setLayoutManager(new LinearLayoutManager(requireActivity(), RecyclerView.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(requireActivity().getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(requireActivity(), 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
@@ -22,6 +22,7 @@ import com.hippo.ehviewer.widget.DialogWebChromeClient;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
import rikka.core.res.ResourcesKt;
public class MyTagsFragment extends BaseFragment {
@@ -35,6 +36,7 @@ public class MyTagsFragment extends BaseFragment {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_webview, container, false);
webView = view.findViewById(R.id.webview);
webView.setBackgroundColor(ResourcesKt.resolveColor(requireActivity().getTheme(), android.R.attr.colorBackground));
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setJavaScriptEnabled(true);
@@ -26,6 +26,7 @@ import com.hippo.ehviewer.widget.DialogWebChromeClient;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
import rikka.core.res.ResourcesKt;
public class UConfigFragment extends BaseFragment {
@@ -40,6 +41,7 @@ public class UConfigFragment extends BaseFragment {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_webview, container, false);
webView = view.findViewById(R.id.webview);
webView.setBackgroundColor(ResourcesKt.resolveColor(requireActivity().getTheme(), android.R.attr.colorBackground));
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setJavaScriptEnabled(true);
@@ -113,6 +113,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import rikka.core.res.ResourcesKt;
@SuppressLint("RtlHardcoded")
public class DownloadsScene extends ToolbarScene
implements DownloadManager.DownloadInfoListener,
@@ -649,7 +651,7 @@ public class DownloadsScene extends ToolbarScene
recyclerView.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
@@ -90,6 +90,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import rikka.core.res.ResourcesKt;
// TODO Get favorite, modify favorite, add favorite, what a mess!
@SuppressLint("RtlHardcoded")
public class FavoritesScene extends BaseScene implements
@@ -281,7 +283,7 @@ public class FavoritesScene extends BaseScene implements
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());
mLeftDrawable = new DrawerArrowDrawable(context);
mLeftDrawable = new DrawerArrowDrawable(context, ResourcesKt.resolveColor(getTheme(), android.R.attr.colorControlNormal));
mSearchBar.setLeftDrawable(mLeftDrawable);
mSearchBar.setRightDrawable(ContextCompat.getDrawable(context, R.drawable.v_magnify_x24));
mSearchBar.setHelper(this);
@@ -289,7 +291,13 @@ public class FavoritesScene extends BaseScene implements
updateSearchBar();
mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView);
mActionFabDrawable = new AddDeleteDrawable(context);
int colorID;
if (EhActivity.isNightMode(context.getResources().getConfiguration())) {
colorID = resources.getColor(android.R.color.white, getTheme());
} else {
colorID = resources.getColor(android.R.color.black, getTheme());
}
mActionFabDrawable = new AddDeleteDrawable(context, colorID);
mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
mFabLayout.setExpanded(false, false);
mFabLayout.setAutoCancel(true);
@@ -446,7 +454,7 @@ public class FavoritesScene extends BaseScene implements
recyclerView.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
@@ -93,6 +93,8 @@ import com.hippo.yorozuya.collect.IntList;
import java.util.ArrayList;
import java.util.List;
import rikka.core.res.ResourcesKt;
public final class GalleryCommentsScene extends ToolbarScene
implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
@@ -209,7 +211,7 @@ public final class GalleryCommentsScene extends ToolbarScene
mRecyclerView.setLayoutManager(new LinearLayoutManager(context,
RecyclerView.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, 0,
LinearDividerItemDecoration.VERTICAL, ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
mRecyclerView.addItemDecoration(decoration);
@@ -327,7 +329,7 @@ public final class GalleryCommentsScene extends ToolbarScene
});
rv.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL, 0,
LinearDividerItemDecoration.VERTICAL, ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, androidx.appcompat.R.attr.dialogPreferredPadding));
rv.addItemDecoration(decoration);
@@ -877,7 +879,7 @@ public final class GalleryCommentsScene extends ToolbarScene
SpannableString ss = new SpannableString(scoreString);
ss.setSpan(new RelativeSizeSpan(0.8f), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new ForegroundColorSpan(0)
ss.setSpan(new ForegroundColorSpan(ResourcesKt.resolveColor(getTheme(), android.R.attr.textColorSecondary))
, 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append(" ").append(ss);
}
@@ -887,7 +889,7 @@ public final class GalleryCommentsScene extends ToolbarScene
SpannableString ss = new SpannableString(str);
ss.setSpan(new RelativeSizeSpan(0.8f), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new ForegroundColorSpan(0),
ss.setSpan(new ForegroundColorSpan(ResourcesKt.resolveColor(getTheme(), android.R.attr.textColorSecondary)),
0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append("\n\n").append(ss);
}
@@ -135,6 +135,7 @@ import java.util.ArrayList;
import java.util.List;
import okhttp3.HttpUrl;
import rikka.core.res.ResourcesKt;
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
@@ -831,7 +832,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
}
if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER)) {
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER) && ResourcesKt.resolveBoolean(getTheme(), androidx.appcompat.R.attr.isLightTheme, false)) {
if (!createCircularReveal()) {
SimpleHandler.getInstance().post(this::createCircularReveal);
}
@@ -951,8 +952,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
}
EhTagDatabase ehTags = Settings.getShowTagTranslations() ? EhTagDatabase.getInstance(context) : null;
int colorTag = 0;
int colorName = 0;
int colorTag = ResourcesKt.resolveColor(getTheme(), R.attr.tagBackgroundColor);
int colorName = ResourcesKt.resolveColor(getTheme(), R.attr.tagGroupBackgroundColor);
for (GalleryTagGroup tg : tagGroups) {
LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false);
ll.setOrientation(LinearLayout.HORIZONTAL);
@@ -43,6 +43,8 @@ import com.hippo.yorozuya.ViewUtils;
import java.util.ArrayList;
import rikka.core.res.ResourcesKt;
public final class GalleryInfoScene extends ToolbarScene {
public static final String KEY_GALLERY_DETAIL = "gallery_detail";
@@ -164,7 +166,7 @@ public final class GalleryInfoScene extends ToolbarScene {
mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
int keylineMargin = context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin);
decoration.setPadding(keylineMargin);
@@ -126,6 +126,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import rikka.core.res.ResourcesKt;
@SuppressLint("RtlHardcoded")
public final class GalleryListScene extends BaseScene
implements SearchBar.Helper, SearchBar.OnStateChangeListener, FastScroller.OnDragHandlerListener,
@@ -592,8 +594,8 @@ public final class GalleryListScene extends BaseScene
fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());
mLeftDrawable = new DrawerArrowDrawable(context);
mRightDrawable = new AddDeleteDrawable(context);
mLeftDrawable = new DrawerArrowDrawable(context, ResourcesKt.resolveColor(getTheme(), android.R.attr.colorControlNormal));
mRightDrawable = new AddDeleteDrawable(context, ResourcesKt.resolveColor(getTheme(), android.R.attr.colorControlNormal));
mSearchBar.setLeftDrawable(mLeftDrawable);
mSearchBar.setRightDrawable(mRightDrawable);
mSearchBar.setHelper(this);
@@ -612,7 +614,13 @@ public final class GalleryListScene extends BaseScene
mFabLayout.setOnExpandListener(this);
addAboveSnackView(mFabLayout);
mActionFabDrawable = new AddDeleteDrawable(context);
int colorID;
if (EhActivity.isNightMode(context.getResources().getConfiguration())) {
colorID = resources.getColor(android.R.color.white, getTheme());
} else {
colorID = resources.getColor(android.R.color.black, getTheme());
}
mActionFabDrawable = new AddDeleteDrawable(context, colorID);
mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
mSearchFab.setOnClickListener(this);
@@ -794,7 +802,7 @@ public final class GalleryListScene extends BaseScene
recyclerView.setLayoutManager(new LinearLayoutManager(context));
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(true);
recyclerView.addItemDecoration(decoration);
@@ -42,6 +42,7 @@ import java.util.List;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
import rikka.core.res.ResourcesKt;
public class WebViewSignInScene extends SolidScene {
@@ -73,6 +74,7 @@ public class WebViewSignInScene extends SolidScene {
cookieManager.removeSessionCookies(null);
mWebView = new WebView(context);
mWebView.setBackgroundColor(ResourcesKt.resolveColor(getTheme(), android.R.attr.colorBackground));
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setDisplayZoomControls(false);
mWebView.getSettings().setJavaScriptEnabled(true);
@@ -29,6 +29,8 @@ import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.yorozuya.ViewUtils;
import rikka.core.res.ResourcesKt;
public class GalleryGuideView extends ViewGroup implements View.OnClickListener {
private final float[] mPoints = new float[3 * 4];
@@ -58,7 +60,9 @@ public class GalleryGuideView extends ViewGroup implements View.OnClickListener
}
private void init(Context context) {
mBgColor = ResourcesKt.resolveColor(context.getTheme(), R.attr.guideBackgroundColor);
mPaint = new Paint();
mPaint.setColor(ResourcesKt.resolveColor(context.getTheme(), R.attr.guideTitleColor));
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(context.getResources().getDimension(R.dimen.gallery_guide_divider_width));
setOnClickListener(this);
@@ -60,6 +60,8 @@ import com.hippo.yorozuya.ViewUtils;
import java.util.ArrayList;
import java.util.List;
import rikka.core.res.ResourcesKt;
public class SearchBar extends MaterialCardView implements View.OnClickListener,
TextView.OnEditorActionListener, TextWatcher,
SearchEditText.SearchEditTextListener {
@@ -146,7 +148,7 @@ public class SearchBar extends MaterialCardView implements View.OnClickListener,
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
LinearDividerItemDecoration.VERTICAL,
0,
ResourcesKt.resolveColor(context.getTheme(), R.attr.dividerColor),
LayoutUtils.dp2pix(context, 1));
decoration.setShowLastDivider(false);
mListView.addItemDecoration(decoration);
@@ -34,6 +34,8 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
import rikka.core.res.ResourcesKt;
public class SceneFragment extends Fragment {
public static final int LAUNCH_MODE_STANDARD = 0;
@@ -112,6 +114,7 @@ public class SceneFragment extends Fragment {
super.onViewCreated(view, savedInstanceState);
view.setTag(R.id.fragment_tag, getTag());
view.setBackground(ResourcesKt.resolveDrawable(requireActivity().getTheme(), android.R.attr.windowBackground));
// Notify
FragmentActivity activity = getActivity();
+5 -2
View File
@@ -22,7 +22,8 @@
<com.hippo.easyrecyclerview.EasyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="bottom" />
<TextView
android:id="@+id/tip"
@@ -32,7 +33,8 @@
android:layout_gravity="center"
android:drawablePadding="16dp"
android:gravity="center_horizontal"
android:text="@string/no_filter" />
android:text="@string/no_filter"
app:fitsSystemWindowsInsets="bottom" />
<com.google.android.material.floatingactionbutton.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
@@ -41,6 +43,7 @@
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/corner_fab_margin"
android:layout_marginBottom="@dimen/corner_fab_margin"
app:layout_fitsSystemWindowsInsets="bottom"
app:srcCompat="@drawable/v_plus_dark_x24" />
</FrameLayout>
+5 -2
View File
@@ -24,7 +24,8 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" />
android:clipToPadding="false"
app:fitsSystemWindowsInsets="bottom" />
<TextView
android:id="@+id/tip"
@@ -33,7 +34,8 @@
android:layout_gravity="center"
android:gravity="center"
android:text="@string/hosts_tip"
android:textSize="@dimen/text_super_large" />
android:textSize="@dimen/text_super_large"
app:fitsSystemWindowsInsets="bottom" />
<com.google.android.material.floatingactionbutton.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
@@ -42,6 +44,7 @@
android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/corner_fab_margin"
android:layout_marginBottom="@dimen/corner_fab_margin"
app:layout_fitsSystemWindowsInsets="bottom"
app:srcCompat="@drawable/v_plus_dark_x24" />
</FrameLayout>
+4 -1
View File
@@ -18,7 +18,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
android:clipChildren="false"
app:consumeSystemWindowsInsets="start|end"
app:edgeToEdge="true"
app:fitsSystemWindowsInsets="start|end">
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/draw_view"
@@ -1,8 +1,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:orientation="vertical">
android:orientation="vertical"
app:consumeSystemWindowsInsets="start|end"
app:edgeToEdge="true"
app:fitsSystemWindowsInsets="start|end">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
+3 -1
View File
@@ -15,10 +15,12 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
android:orientation="vertical"
app:fitsSystemWindowsInsets="bottom">
<WebView
android:id="@+id/webview"
@@ -30,7 +30,8 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:elevation="4dp" />
android:elevation="4dp"
app:fitsSystemWindowsInsets="top" />
<Space
android:layout_width="match_parent"
@@ -46,13 +47,14 @@
<RelativeLayout
android:id="@+id/header_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:fitsSystemWindowsInsets="top">
<com.hippo.widget.LoadImageView
android:id="@+id/thumb"
android:layout_width="@dimen/gallery_detail_thumb_width"
android:layout_height="@dimen/gallery_detail_thumb_height"
android:layout_marginStart="@dimen/keyline_margin"
android:layout_marginLeft="@dimen/keyline_margin"
android:layout_marginTop="@dimen/keyline_margin"
android:layout_marginBottom="@dimen/keyline_margin" />
@@ -25,7 +25,8 @@
android:focusable="true"
android:orientation="vertical"
android:padding="@dimen/keyline_margin"
android:showDividers="middle">
android:showDividers="middle"
app:fitsSystemWindowsInsets="bottom">
<com.hippo.widget.SimpleGridAutoSpanLayout
android:id="@+id/grid_layout"
@@ -19,6 +19,7 @@
-->
<com.hippo.easyrecyclerview.EasyRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/list"
android:layout_width="match_parent"
@@ -27,5 +28,6 @@
android:fadeScrollbars="true"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:fitsSystemWindowsInsets="bottom"
tools:ignore="UnusedResources"
tools:viewBindingIgnore="true" />
@@ -20,7 +20,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/keyline_margin">
android:padding="@dimen/keyline_margin"
app:fitsSystemWindowsInsets="top|bottom">
<ImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
+6 -3
View File
@@ -27,7 +27,8 @@
<com.hippo.easyrecyclerview.EasyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="bottom" />
<com.hippo.easyrecyclerview.FastScroller
android:id="@+id/fast_scroller"
@@ -37,7 +38,8 @@
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="4dp"
android:paddingBottom="8dp" />
android:paddingBottom="8dp"
app:fitsSystemWindowsInsets="bottom" />
</FrameLayout>
@@ -56,7 +58,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
android:paddingBottom="@dimen/corner_fab_margin"
app:fitsSystemWindowsInsets="bottom">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
+6 -3
View File
@@ -23,7 +23,8 @@
<com.hippo.widget.ContentLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="top|bottom" />
<com.hippo.ehviewer.widget.SearchBar
android:id="@+id/search_bar"
@@ -31,14 +32,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/gallery_search_bar_margin_h"
android:layout_marginVertical="@dimen/gallery_search_bar_margin_v" />
android:layout_marginVertical="@dimen/gallery_search_bar_margin_v"
app:layout_fitsSystemWindowsInsets="top|bottom" />
<com.hippo.widget.FabLayout
android:id="@+id/fab_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
android:paddingBottom="@dimen/corner_fab_margin"
app:fitsSystemWindowsInsets="top|bottom">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
@@ -29,7 +29,8 @@
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" />
android:clipToPadding="false"
app:fitsSystemWindowsInsets="bottom" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@@ -41,7 +42,8 @@
android:layout_gravity="center"
android:drawablePadding="8dp"
android:gravity="center_horizontal"
android:text="@string/no_one_comments_gallery" />
android:text="@string/no_one_comments_gallery"
app:fitsSystemWindowsInsets="bottom" />
<LinearLayout
android:id="@+id/edit_panel"
@@ -51,7 +53,8 @@
android:background="@color/material_dynamic_primary50"
android:elevation="4dp"
android:orientation="horizontal"
android:visibility="invisible">
android:visibility="invisible"
app:fitsSystemWindowsInsets="bottom">
<EditText
android:id="@+id/edit_text"
@@ -84,7 +87,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
android:paddingBottom="@dimen/corner_fab_margin"
app:fitsSystemWindowsInsets="bottom">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
@@ -36,7 +36,8 @@
style="@style/ProgressView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
android:layout_gravity="center"
app:fitsSystemWindowsInsets="top|bottom" />
<TextView
android:id="@+id/tip"
@@ -45,6 +46,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="8dp"
android:gravity="center_horizontal" />
android:gravity="center_horizontal"
app:fitsSystemWindowsInsets="top|bottom" />
</FrameLayout>
@@ -15,6 +15,8 @@
-->
<com.hippo.easyrecyclerview.EasyRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="bottom" />
+10 -5
View File
@@ -24,12 +24,14 @@
<com.hippo.widget.ContentLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="top|bottom" />
<com.hippo.ehviewer.widget.SearchLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:layout_fitsSystemWindowsInsets="top|bottom" />
<com.hippo.ehviewer.widget.SearchBar
android:id="@+id/search_bar"
@@ -37,14 +39,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/gallery_search_bar_margin_h"
android:layout_marginVertical="@dimen/gallery_search_bar_margin_v" />
android:layout_marginVertical="@dimen/gallery_search_bar_margin_v"
app:layout_fitsSystemWindowsInsets="top|bottom" />
<com.hippo.widget.FabLayout
android:id="@+id/fab_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
android:paddingBottom="@dimen/corner_fab_margin"
app:fitsSystemWindowsInsets="top|bottom">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
@@ -74,7 +78,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="@dimen/corner_fab_margin"
android:paddingBottom="@dimen/corner_fab_margin">
android:paddingBottom="@dimen/corner_fab_margin"
app:fitsSystemWindowsInsets="top|bottom">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/search_fab"
@@ -15,8 +15,10 @@
-->
<com.hippo.widget.ContentLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false" />
android:clipToPadding="false"
app:fitsSystemWindowsInsets="bottom" />
+7 -3
View File
@@ -15,6 +15,7 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -26,7 +27,8 @@
<com.hippo.easyrecyclerview.EasyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="bottom" />
<com.hippo.easyrecyclerview.FastScroller
android:id="@+id/fast_scroller"
@@ -36,7 +38,8 @@
android:paddingLeft="20dp"
android:paddingTop="8dp"
android:paddingRight="4dp"
android:paddingBottom="8dp" />
android:paddingBottom="8dp"
app:fitsSystemWindowsInsets="bottom" />
</FrameLayout>
@@ -48,6 +51,7 @@
android:layout_gravity="center"
android:drawablePadding="16dp"
android:gravity="center_horizontal"
android:text="@string/no_history" />
android:text="@string/no_history"
app:fitsSystemWindowsInsets="bottom" />
</FrameLayout>
+2 -1
View File
@@ -18,7 +18,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
app:fitsSystemWindowsInsets="top|bottom">
<ScrollView
android:id="@+id/login_form"
+3 -1
View File
@@ -15,8 +15,10 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
app:fitsSystemWindowsInsets="top|bottom">
<com.google.android.material.progressindicator.CircularProgressIndicator
android:id="@+id/progress"
@@ -20,7 +20,8 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="@dimen/keyline_margin"
android:paddingTop="@dimen/keyline_margin">
android:paddingTop="@dimen/keyline_margin"
app:fitsSystemWindowsInsets="top|bottom">
<ScrollView
android:layout_width="wrap_content"
+2 -1
View File
@@ -20,7 +20,8 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="@dimen/keyline_margin"
android:paddingTop="@dimen/keyline_margin">
android:paddingTop="@dimen/keyline_margin"
app:fitsSystemWindowsInsets="top|bottom">
<ImageView
android:layout_width="wrap_content"
+6
View File
@@ -289,6 +289,12 @@
<item>SOCKS</item>
</string-array>
<string-array name="night_mode_entries" translatable="false">
<item>@string/dark_theme_follow_system</item>
<item>@string/dark_theme_off</item>
<item>@string/dark_theme_on</item>
</string-array>
<string-array name="night_mode_values">
<item>-1</item>
<item>1</item>
+1
View File
@@ -41,6 +41,7 @@
<style name="ThemeOverlay.Black">
<item name="colorPrimaryDark">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="toolbarColor">@android:color/black</item>
<item name="dividerColor">@color/divider_black</item>
<item name="drawableColorSecondary">@color/secondary_drawable_black</item>
<item name="drawableColorThemePrimary">@color/primary_drawable_black</item>
+9
View File
@@ -52,6 +52,15 @@
android:title="@string/settings_my_tags"
app:iconSpaceReserved="false" />
<rikka.preference.SimpleMenuPreference
android:defaultValue="-1"
android:entries="@array/night_mode_entries"
android:entryValues="@array/night_mode_values"
android:key="theme"
android:summary="%s"
android:title="@string/dark_theme"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:key="black_dark_theme"
android:title="@string/black_dark_theme"