Skip to content

Commit ad2af80

Browse files
author
Mamba_out
committed
rollback:回滚状态栏代码
1 parent 78198db commit ad2af80

8 files changed

Lines changed: 41 additions & 87 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
<activity
180180
android:name=".ui.SettingsActivity"
181181
android:configChanges="screenSize|uiMode"
182-
android:theme="@style/AppTheme.Toolbar" />
182+
android:theme="@style/AppTheme.Settings" />
183183
<activity
184184
android:name=".ui.ExcludedLanguagesActivity"
185185
android:configChanges="screenSize|uiMode"

app/src/main/java/com/hippo/ehviewer/ui/EhActivity.java

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,12 @@
2121
import android.content.res.Resources;
2222
import android.os.Build;
2323
import android.os.Bundle;
24-
import android.view.View;
25-
import android.view.ViewGroup;
2624
import android.view.WindowManager;
2725

2826
import androidx.annotation.NonNull;
2927
import androidx.annotation.Nullable;
3028
import androidx.annotation.StyleRes;
3129
import androidx.appcompat.app.AppCompatActivity;
32-
import androidx.core.graphics.Insets;
33-
import androidx.core.view.ViewCompat;
34-
import androidx.core.view.WindowInsetsCompat;
35-
36-
import com.hippo.android.resource.AttrResources;
37-
import com.hippo.ehviewer.R;
3830
import com.google.firebase.analytics.FirebaseAnalytics;
3931
import com.hippo.content.ContextLocalWrapper;
4032
import com.hippo.ehviewer.Analytics;
@@ -54,13 +46,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5446
setTheme(getThemeResId(Settings.getTheme()));
5547
super.onCreate(savedInstanceState);
5648

57-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
58-
applyEdgeToEdgeSystemBars();
59-
}
60-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
61-
getWindow().setNavigationBarContrastEnforced(false);
62-
}
63-
6449
((EhApplication) getApplication()).registerActivity(this);
6550

6651
if (Analytics.isEnabled()) {
@@ -75,72 +60,9 @@ protected void onDestroy() {
7560
((EhApplication) getApplication()).unregisterActivity(this);
7661
}
7762

78-
@Override
79-
public void onContentChanged() {
80-
super.onContentChanged();
81-
applyNavigationBarPaddingIfNeeded();
82-
}
83-
84-
/**
85-
* MainActivity uses {@link com.hippo.ehviewer.widget.EhStageLayout} for window insets.
86-
* GalleryActivity is fullscreen and handles bottom controls separately.
87-
*/
88-
protected boolean shouldApplyNavigationBarPadding() {
89-
return !(this instanceof MainActivity) && !(this instanceof GalleryActivity);
90-
}
91-
92-
private void applyNavigationBarPaddingIfNeeded() {
93-
if (!shouldApplyNavigationBarPadding()) {
94-
return;
95-
}
96-
View target = findViewById(R.id.content_panel);
97-
if (target == null) {
98-
View content = findViewById(android.R.id.content);
99-
if (content instanceof ViewGroup) {
100-
ViewGroup group = (ViewGroup) content;
101-
if (group.getChildCount() > 0) {
102-
target = group.getChildAt(0);
103-
}
104-
}
105-
}
106-
if (target == null || target.getTag(R.id.navigation_bar_padding_applied) != null) {
107-
return;
108-
}
109-
target.setTag(R.id.navigation_bar_padding_applied, Boolean.TRUE);
110-
target.setTag(R.id.navigation_bar_padding_origin_bottom, target.getPaddingBottom());
111-
ViewCompat.setOnApplyWindowInsetsListener(target, (v, windowInsets) -> {
112-
Insets nav = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars());
113-
Object origin = v.getTag(R.id.navigation_bar_padding_origin_bottom);
114-
int originBottom = origin instanceof Integer ? (Integer) origin : 0;
115-
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
116-
originBottom + nav.bottom);
117-
return windowInsets;
118-
});
119-
ViewCompat.requestApplyInsets(target);
120-
}
121-
122-
private void applyEdgeToEdgeSystemBars() {
123-
int flags = android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
124-
| android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
125-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
126-
&& AttrResources.getAttrBoolean(this, android.R.attr.windowLightNavigationBar)) {
127-
flags |= android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
128-
}
129-
getWindow().getDecorView().setSystemUiVisibility(flags);
130-
syncNavigationBarWithTheme();
131-
}
132-
133-
private void syncNavigationBarWithTheme() {
134-
getWindow().setNavigationBarColor(
135-
AttrResources.getAttrColor(this, android.R.attr.windowBackground));
136-
}
137-
13863
@Override
13964
protected void onResume() {
14065
super.onResume();
141-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
142-
syncNavigationBarWithTheme();
143-
}
14466
if(Settings.getEnabledSecurity()){
14567
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
14668
WindowManager.LayoutParams.FLAG_SECURE);

app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,42 @@
3434
import com.hippo.ehviewer.ui.fragment.SettingsHeaders;
3535
import com.hippo.util.DrawableManager;
3636

37-
public final class SettingsActivity extends ToolbarActivity {
37+
public final class SettingsActivity extends EhActivity {
3838

3939
private static final int REQUEST_CODE_FRAGMENT = 0;
4040

41+
@Override
42+
protected int getThemeResId(int theme) {
43+
switch (theme) {
44+
case Settings.THEME_LIGHT:
45+
default:
46+
return R.style.AppTheme_Settings;
47+
case Settings.THEME_DARK:
48+
return R.style.AppTheme_Settings_Dark;
49+
case Settings.THEME_BLACK:
50+
return R.style.AppTheme_Settings_Black;
51+
}
52+
}
4153

54+
private void setActionBarUpIndicator(Drawable drawable) {
55+
ActionBarDrawerToggle.Delegate delegate = getDrawerToggleDelegate();
56+
if (delegate != null) {
57+
delegate.setActionBarUpIndicator(drawable, 0);
58+
}
59+
ActionBar actionBar = getSupportActionBar();
60+
if (actionBar != null) {
61+
actionBar.setDisplayHomeAsUpEnabled(true);
62+
actionBar.setHomeButtonEnabled(true);
63+
actionBar.setTitle(R.string.settings);
64+
}
65+
}
4266

4367
@SuppressWarnings("deprecation")
4468
@Override
4569
protected void onCreate(Bundle savedInstanceState) {
4670
super.onCreate(savedInstanceState);
4771
setContentView(R.layout.activity_settings);
48-
setNavigationIcon(DrawableManager.getVectorDrawable(this, R.drawable.v_arrow_left_dark_x24));
72+
setActionBarUpIndicator(DrawableManager.getVectorDrawable(this, R.drawable.v_arrow_left_dark_x24));
4973
if (savedInstanceState==null){
5074
getSupportFragmentManager()
5175
.beginTransaction()

app/src/main/java/com/hippo/ehviewer/widget/EhDrawerView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public int getAdditionalTopMargin() {
5050
return mWindowPaddingTop;
5151
}
5252

53-
@Override
5453
public int getAdditionalBottomMargin() {
5554
return mWindowPaddingBottom;
5655
}

app/src/main/res/layout-v21/scene_toolbar.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:fitsSystemWindows="true"
2322
android:orientation="vertical">
2423

2524
<androidx.appcompat.widget.Toolbar

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
android:layout_width="wrap_content"
5353
android:layout_height="match_parent"
5454
android:layout_weight="1"
55-
android:background="?android:attr/windowBackground"
55+
android:background="?android:navigationBarColor"
5656
android:paddingBottom="48dip"
5757
android:scrollbars="vertical"
5858
app:headerLayout="@layout/nav_header_main"
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/settings"
43
android:layout_width="match_parent"
5-
android:layout_height="match_parent" />
4+
android:layout_height="match_parent"
5+
xmlns:app="http://schemas.android.com/apk/res-auto">
6+
7+
<FrameLayout
8+
android:id="@+id/settings"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
app:layout_constraintBottom_toBottomOf="parent"
12+
app:layout_constraintEnd_toEndOf="parent"
13+
app:layout_constraintStart_toStartOf="parent"
14+
app:layout_constraintTop_toTopOf="parent"/>
15+
16+
</FrameLayout>

app/src/main/res/layout/scene_toolbar.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
22-
android:fitsSystemWindows="true"
2322
android:orientation="vertical">
2423

2524
<androidx.appcompat.widget.Toolbar

0 commit comments

Comments
 (0)