Fix themes
This commit is contained in:
11 files changed
+104
-33
No files matched your search
@@ -19,7 +19,10 @@ 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.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -30,6 +33,7 @@ import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
|
||||
import rikka.core.res.ResourcesKt;
|
||||
import rikka.material.app.MaterialActivity;
|
||||
|
||||
public abstract class EhActivity extends MaterialActivity {
|
||||
@@ -98,4 +102,26 @@ public abstract class EhActivity extends MaterialActivity {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplyTranslucentSystemBars() {
|
||||
super.onApplyTranslucentSystemBars();
|
||||
Window window = getWindow();
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
|
||||
window.getDecorView().post(() -> {
|
||||
if (window.getDecorView().getRootWindowInsets().getSystemWindowInsetBottom() >= Resources.getSystem().getDisplayMetrics().density * 40) {
|
||||
window.setNavigationBarColor(ResourcesKt.resolveColor(getTheme(), android.R.attr.navigationBarColor) & 0x00ffffff | -0x20000000);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
window.setNavigationBarContrastEnforced(false);
|
||||
}
|
||||
} else {
|
||||
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
window.setNavigationBarContrastEnforced(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -325,10 +325,6 @@ public final class MainActivity extends StageActivity
|
||||
Settings.putTheme(theme);
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
findViewById(R.id.fragment_container).setFitsSystemWindows(true);
|
||||
}
|
||||
|
||||
updateProfile();
|
||||
|
||||
|
||||
@@ -16,16 +16,11 @@
|
||||
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -49,14 +44,6 @@ public final class SettingsActivity extends EhActivity {
|
||||
.replace(R.id.fragment, new SettingsFragment())
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.snackbar), (v, insets) -> {
|
||||
Insets insets1 = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime());
|
||||
v.setPadding(insets1.left, insets1.top, insets1.right, 0);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void showTip(@StringRes int id, int length) {
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
<com.hippo.widget.SafeCoordinatorLayout 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:consumeSystemWindowsInsets="start|end"
|
||||
app:edgeToEdge="true"
|
||||
app:fitSystemWindowsInsets="start|end">
|
||||
|
||||
<com.hippo.ehviewer.widget.EhDrawerLayout
|
||||
android:id="@+id/draw_view"
|
||||
|
||||
@@ -3,17 +3,22 @@
|
||||
android:id="@+id/snackbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false">
|
||||
android:clipChildren="false"
|
||||
app:consumeSystemWindowsInsets="start|end"
|
||||
app:edgeToEdge="true"
|
||||
app:fitSystemWindowsInsets="start|end">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/toolbarColor"
|
||||
android:elevation="4dp">
|
||||
android:elevation="4dp"
|
||||
android:fitsSystemWindows="true"
|
||||
app:statusBarForeground="?colorPrimaryDark">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||
app:popupTheme="?attr/toolbarPopupTheme" />
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="?attr/toolbarColor"
|
||||
android:elevation="4dp"
|
||||
app:statusBarForeground="@color/colorPrimaryDark">
|
||||
app:statusBarForeground="?colorPrimaryDark">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="AppTheme" parent="Base.AppTheme" />
|
||||
</resources>
|
||||
@@ -1,8 +1,4 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="BaseTheme">
|
||||
<item name="android:colorEdgeEffect">?attr/colorEdgeEffect</item>
|
||||
</style>
|
||||
|
||||
<style name="ToolbarPopupTheme" parent="ThemeOverlay.MaterialComponents.Dark" />
|
||||
</resources>
|
||||
@@ -15,6 +15,7 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="AppTheme" parent="Base.AppTheme.Light" />
|
||||
|
||||
<style name="ActionBarStyle" parent="@style/Widget.MaterialComponents.ActionBar.Solid">
|
||||
<item name="background">?attr/toolbarColor</item>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<!-- ========== -->
|
||||
<!-- Base Theme -->
|
||||
<!-- ========== -->
|
||||
<style name="BaseTheme.Light" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Base.AppTheme.Light" parent="Theme.Material.Light">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
@@ -57,9 +57,14 @@
|
||||
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">
|
||||
@bool/lightNavigationBar
|
||||
</item>
|
||||
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="BaseTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<style name="Base.AppTheme" parent="Theme.Material">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/grey_875</item>
|
||||
<item name="colorAccent">@color/colorPrimary</item>
|
||||
@@ -98,14 +103,15 @@
|
||||
<item name="toolbarPopupTheme">@style/ThemeOverlay.MaterialComponents.Dark</item>
|
||||
<item name="galleryDetailDivider">@drawable/divider_gallery_detail_dark</item>
|
||||
<item name="android:navigationBarColor">@color/colorNavigationBar</item>
|
||||
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="ToolbarPopupTheme" parent="ThemeOverlay.MaterialComponents.Light" />
|
||||
|
||||
<style name="AppTheme" parent="BaseTheme.Light">
|
||||
<item name="android:colorEdgeEffect">?attr/colorEdgeEffect</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Add android:colorControlNormal -->
|
||||
<style name="Base.ThemeOverlay.AppCompat.ActionBar" tools:override="true">
|
||||
<item name="android:colorControlNormal">?android:attr/textColorPrimary</item>
|
||||
<item name="colorControlNormal">?android:attr/textColorPrimary</item>
|
||||
<item name="searchViewStyle">@style/Widget.AppCompat.SearchView.ActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Base.ThemeOverlay.AppCompat.Dark.ActionBar" tools:override="true">
|
||||
<item name="android:colorControlNormal">?android:attr/textColorPrimary</item>
|
||||
<item name="colorControlNormal">?android:attr/textColorPrimary</item>
|
||||
<item name="searchViewStyle">@style/Widget.AppCompat.SearchView.ActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.MaterialComponents.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox" tools:override="true">
|
||||
<item name="enforceMaterialTheme">true</item>
|
||||
<item name="useMaterialThemeColors">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.MaterialComponents.CompoundButton.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton" tools:override="true">
|
||||
<item name="enforceMaterialTheme">true</item>
|
||||
<item name="useMaterialThemeColors">true</item>
|
||||
</style>
|
||||
|
||||
<style name="PreferenceSummaryTextStyle" tools:override="true">
|
||||
<item name="android:fontFamily">sans-serif</item>
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:letterSpacing">0.0178571429</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in new issue
Block a user