Skip to content

Commit

Permalink
Matching colour
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Jul 13, 2024
1 parent cebf97f commit 3a7f816
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/src/main/java/net/gsantner/opoc/util/GsContextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public Drawable rdrawable(final Context context, @DrawableRes final int resId) {
*/
@ColorInt
public int rcolor(final Context context, @ColorRes final int resId) {
if (resId == 0) {
if (context == null || resId == 0) {
Log.e(getClass().getName(), "GsContextUtils::rcolor: resId is 0!");
return Color.BLACK;
}
Expand Down Expand Up @@ -2681,10 +2681,12 @@ public <T extends GsContextUtils> T setActivityBackgroundColor(final Activity ac
}

public <T extends GsContextUtils> T setActivityNavigationBarBackgroundColor(final Activity context, @ColorInt Integer color) {
if (color != null) {
if (context != null && color != null) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
context.getWindow().setNavigationBarColor(color);
final Window window = context.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setNavigationBarColor(color);
}
} catch (Exception ignored) {
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<item name="android:windowAllowReturnTransitionOverlap" tools:targetApi="lollipop">true</item>
<item name="android:windowSharedElementEnterTransition" tools:targetApi="lollipop">@android:transition/move</item>
<item name="android:windowSharedElementExitTransition" tools:targetApi="lollipop">@android:transition/move</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@color/primary</item>
<item name="android:navigationBarColor" tools:targetApi="lollipop">@color/primary</item>

<!-- Android V28 options; ignore IDE warnings -->
<item name="android:dialogCornerRadius" tools:targetApi="p">@dimen/dialog_corner_radius</item>
Expand Down

0 comments on commit 3a7f816

Please sign in to comment.