From ff425d6d2bc52217e7ab168db76e21e5c29e9557 Mon Sep 17 00:00:00 2001
From: Damian Czupryn <60961958+Daxxxis@users.noreply.github.com>
Date: Thu, 18 Feb 2021 00:05:27 +0100
Subject: [PATCH] Change background color of navigation and notification bars
(#1120)
---
app/src/main/AndroidManifest.xml | 4 +--
.../github/wulkanowy/ui/base/ThemeManager.kt | 22 ++++++++++---
.../wulkanowy/ui/modules/main/MainActivity.kt | 18 +++++++---
app/src/main/res/values-night/styles.xml | 33 +++++++++++++++++--
app/src/main/res/values-v23/styles.xml | 14 ++++++++
app/src/main/res/values-v26/styles.xml | 15 +++++++++
.../res/{values-v27 => values-v28}/styles.xml | 6 ++--
app/src/main/res/values-v29/styles.xml | 17 ++++++++++
app/src/main/res/values/colors.xml | 5 +++
app/src/main/res/values/styles.xml | 4 +++
10 files changed, 123 insertions(+), 15 deletions(-)
create mode 100644 app/src/main/res/values-v23/styles.xml
create mode 100644 app/src/main/res/values-v26/styles.xml
rename app/src/main/res/{values-v27 => values-v28}/styles.xml (75%)
create mode 100644 app/src/main/res/values-v29/styles.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ac8d3be4..7b714fb2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -56,7 +56,7 @@
android:name=".ui.modules.login.LoginActivity"
android:configChanges="orientation|screenSize"
android:label="@string/login_title"
- android:theme="@style/WulkanowyTheme.NoActionBar"
+ android:theme="@style/WulkanowyTheme.Login"
android:windowSoftInputMode="adjustResize" />
activity.setTheme(R.style.WulkanowyTheme_Black)
+ is LoginActivity -> activity.setTheme(R.style.WulkanowyTheme_Login_Black)
+ is SendMessageActivity -> activity.setTheme(R.style.WulkanowyTheme_MessageSend_Black)
+ }
+ }
}
}
@@ -33,8 +42,13 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
}
private fun isThemeApplicable(activity: AppCompatActivity): Boolean {
- return activity.packageManager.getPackageInfo(activity.packageName, GET_ACTIVITIES)
- .activities.singleOrNull { it.name == activity::class.java.canonicalName }?.theme
- .let { it == R.style.WulkanowyTheme_Black || it == R.style.WulkanowyTheme_NoActionBar }
+ return activity.packageManager
+ .getPackageInfo(activity.packageName, GET_ACTIVITIES)
+ .activities.singleOrNull { it.name == activity::class.java.canonicalName }
+ ?.theme.let {
+ it == R.style.WulkanowyTheme_Black || it == R.style.WulkanowyTheme_NoActionBar
+ || it == R.style.WulkanowyTheme_Login || it == R.style.WulkanowyTheme_Login_Black
+ || it == R.style.WulkanowyTheme_MessageSend || it == R.style.WulkanowyTheme_MessageSend_Black
+ }
}
}
diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt
index 5d93c594..da3863f4 100644
--- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt
+++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt
@@ -11,6 +11,7 @@ import android.graphics.drawable.Icon
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION_CODES.LOLLIPOP
+import android.os.Build.VERSION_CODES.P
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@@ -194,6 +195,7 @@ class MainActivity : BaseActivity(), MainVie
return true
}
+ @SuppressLint("NewApi")
override fun initView() {
with(binding.mainToolbar) {
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
@@ -233,12 +235,18 @@ class MainActivity : BaseActivity(), MainVie
with(navController) {
setOnViewChangeListener { section, name ->
- binding.mainBottomNav.visibility =
- if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
- View.GONE
- } else {
- View.VISIBLE
+ if (section == MainView.Section.ACCOUNT || section == MainView.Section.STUDENT_INFO) {
+ binding.mainBottomNav.visibility = View.GONE
+ if (appInfo.systemVersion >= P) {
+ window.navigationBarColor = getThemeAttrColor(R.attr.colorSurface)
}
+ } else {
+ binding.mainBottomNav.visibility = View.VISIBLE
+ if (appInfo.systemVersion >= P) {
+ window.navigationBarColor =
+ getThemeAttrColor(android.R.attr.navigationBarColor)
+ }
+ }
analytics.setCurrentScreen(this@MainActivity, name)
presenter.onViewChange(section)
diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml
index bf5cd769..2641e713 100644
--- a/app/src/main/res/values-night/styles.xml
+++ b/app/src/main/res/values-night/styles.xml
@@ -10,14 +10,43 @@
- @color/colorSwipeRefreshDark
- ?colorSurface
- ?android:textColorPrimary
- - @android:color/black
+
-
+ @color/colorNavigationBarLight
+
+ -
+ @color/colorStatusBarLight
- - @android:color/black
- false
- true
+ - false
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v23/styles.xml b/app/src/main/res/values-v23/styles.xml
new file mode 100644
index 00000000..574e8488
--- /dev/null
+++ b/app/src/main/res/values-v23/styles.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v26/styles.xml b/app/src/main/res/values-v26/styles.xml
new file mode 100644
index 00000000..55413c05
--- /dev/null
+++ b/app/src/main/res/values-v26/styles.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v28/styles.xml
similarity index 75%
rename from app/src/main/res/values-v27/styles.xml
rename to app/src/main/res/values-v28/styles.xml
index d33f6422..ee77091d 100644
--- a/app/src/main/res/values-v27/styles.xml
+++ b/app/src/main/res/values-v28/styles.xml
@@ -1,9 +1,10 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/values-v29/styles.xml b/app/src/main/res/values-v29/styles.xml
new file mode 100644
index 00000000..ee77091d
--- /dev/null
+++ b/app/src/main/res/values-v29/styles.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 99456744..b8a0b098 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,6 +6,11 @@
#ff5722
#e84853
+ #2E2E2E
+ #1E1E1E
+
+ #1C1C1C
+
#ffd54f
#ff8f00
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index cf587cbf..17550ae7 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -34,4 +34,8 @@
+
+
+
+