Better status bar color

This commit is contained in:
NekoInverter committed 2020-04-07 17:26:40 +08:00
1 parent 4b3488026d
commit e9aaba9e93
14 files changed
+52 -27

No files matched your search

@@ -31,6 +31,7 @@ import android.text.TextUtils;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -40,8 +41,10 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.view.ViewCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.snackbar.Snackbar;
@@ -131,7 +134,7 @@ public final class MainActivity extends StageActivity
@Nullable
private NavigationView mNavView;
@Nullable
private FrameLayout mRightDrawer;
private MaterialCardView mRightDrawer;
@Nullable
private LoadImageView mAvatar;
@Nullable
@@ -311,7 +314,7 @@ public final class MainActivity extends StageActivity
mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(this, R.id.draw_view);
mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
mRightDrawer = (MaterialCardView) ViewUtils.$$(this, R.id.right_drawer);
View headerLayout = mNavView.getHeaderView(0);
mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
@@ -321,6 +324,7 @@ public final class MainActivity extends StageActivity
((EhApplication) getApplication()).recreate();
Settings.putTheme(theme);
});
updateProfile();
if (mNavView != null) {
@@ -17,7 +17,10 @@
package com.hippo.ehviewer.ui.scene;
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.os.Parcelable;
import android.util.SparseArray;
@@ -35,6 +38,8 @@ import androidx.annotation.StyleRes;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.FragmentActivity;
import com.hippo.android.resource.AttrResources;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.ui.MainActivity;
import com.hippo.scene.SceneFragment;
import com.hippo.util.AppHelper;
@@ -186,6 +191,22 @@ public abstract class BaseScene extends SceneFragment {
drawerView = null;
}
public void setWhiteStatusBar(boolean set) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
View decorView = requireActivity().getWindow().getDecorView();
int flags = decorView.getSystemUiVisibility();
if (set && (requireActivity().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_YES) <= 0) {
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
} else {
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
decorView.setSystemUiVisibility(flags);
((DrawerLayout) requireActivity().findViewById(R.id.draw_view)).setStatusBarBackgroundColor(set ? Color.WHITE : AttrResources.getAttrColor(requireContext(), R.attr.colorPrimaryDark));
} else {
((DrawerLayout) requireActivity().findViewById(R.id.draw_view)).setStatusBarBackgroundColor(AttrResources.getAttrColor(requireContext(), R.attr.colorPrimaryDark));
}
}
public void onDestroyDrawerView() {
}
@@ -218,6 +239,7 @@ public abstract class BaseScene extends SceneFragment {
// Hide soft ime
AppHelper.hideSoftInput(getActivity());
setWhiteStatusBar(true);
}
public void createThemeContext(@StyleRes int style) {
@@ -424,7 +424,7 @@ public class DownloadsScene extends ToolbarScene
.withMaterialShowcase()
.setStyle(R.style.Guide)
.setTarget(new ViewTarget(((DownloadHolder) holder).thumb))
.blockAllTouches()
.hideOnTouchOutside()
.setContentTitle(R.string.guide_download_thumb_title)
.setContentText(R.string.guide_download_thumb_text)
.replaceEndButton(R.layout.button_guide)
@@ -453,7 +453,7 @@ public class DownloadsScene extends ToolbarScene
.withMaterialShowcase()
.setStyle(R.style.Guide)
.setTarget(new PointTarget(point.x, point.y / 3))
.blockAllTouches()
.hideOnTouchOutside()
.setContentTitle(R.string.guide_download_labels_title)
.setContentText(R.string.guide_download_labels_text)
.replaceEndButton(R.layout.button_guide)
@@ -334,7 +334,7 @@ public class FavoritesScene extends BaseScene implements
.withMaterialShowcase()
.setStyle(R.style.Guide)
.setTarget(new PointTarget(point.x, point.y / 3))
.blockAllTouches()
.hideOnTouchOutside()
.setContentTitle(R.string.guide_collections_title)
.setContentText(R.string.guide_collections_text)
.replaceEndButton(R.layout.button_guide)
@@ -603,6 +603,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setWhiteStatusBar(false);
}
@Override
@@ -610,7 +610,7 @@ public final class GalleryListScene extends BaseScene
.withMaterialShowcase()
.setStyle(R.style.Guide)
.setTarget(new PointTarget(point.x, point.y / 3))
.blockAllTouches()
.hideOnTouchOutside()
.setContentTitle(R.string.guide_quick_search_title)
.setContentText(R.string.guide_quick_search_text)
.replaceEndButton(R.layout.button_guide)
@@ -81,21 +81,12 @@ public abstract class ToolbarScene extends BaseScene {
int menuResId = getMenuResId();
if (menuResId != 0) {
mToolbar.inflateMenu(menuResId);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return ToolbarScene.this.onMenuItemClick(item);
}
});
mToolbar.setOnMenuItemClickListener(ToolbarScene.this::onMenuItemClick);
onMenuCreated(mToolbar.getMenu());
}
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNavigationClick();
}
});
mToolbar.setNavigationOnClickListener(v -> onNavigationClick());
}
setWhiteStatusBar(false);
}
public int getMenuResId() {
@@ -19,11 +19,11 @@ package com.hippo.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import com.google.android.material.card.MaterialCardView;
import com.hippo.yorozuya.LayoutUtils;
public class DrawerView extends FrameLayout {
public class DrawerView extends MaterialCardView {
private static final int DEFAULT_MAX_WIDTH = 280;
+3 -3
View File
@@ -35,7 +35,9 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:insetForeground="@null"
app:menu="@menu/nav_drawer_main" />
@@ -44,9 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="?android:attr/windowBackground"
android:clickable="true"
android:focusable="true"
android:background="@android:color/transparent"
android:maxWidth="@dimen/drawer_max_width" />
</com.hippo.ehviewer.widget.EhDrawerLayout>
+1
View File
@@ -19,6 +19,7 @@
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/get_it"
android:visibility="gone"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="@dimen/text_little_small"
+4 -1
View File
@@ -17,6 +17,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -26,7 +29,7 @@
android:background="?attr/toolbarColor"
android:elevation="8dp"
android:saveEnabled="false"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app:popupTheme="?attr/toolbarPopupTheme" />
<FrameLayout
+4 -1
View File
@@ -17,6 +17,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
@@ -26,7 +29,7 @@
android:background="?attr/toolbarColor"
android:elevation="8dp"
android:saveEnabled="false"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app:popupTheme="?attr/toolbarPopupTheme" />
<FrameLayout
@@ -79,7 +79,7 @@
android:layout_marginRight="@dimen/keyline_margin"
android:ellipsize="end"
android:singleLine="true"
android:textColor="?attr/galleryDetailHeaderTitleColor"
android:textColor="@android:color/white"
android:textSize="@dimen/text_little_small" />
<TextView
+1 -1
View File
@@ -1,3 +1,3 @@
<resources>
<color name="colorNavigationBar">@color/colorBackground</color>
<color name="colorNavigationBar">@android:color/white</color>
</resources>