gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-android] 06/09: [wallet] Navbar and status bar are now set


From: gnunet
Subject: [taler-taler-android] 06/09: [wallet] Navbar and status bar are now set via XML
Date: Tue, 31 Jan 2023 14:39:54 +0100

This is an automated email from the git hooks/post-receive script.

torsten-grote pushed a commit to branch master
in repository taler-android.

commit f636027212d2a45d3b9696e8efd4348badf79661
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Wed Jan 11 23:48:55 2023 -0600

    [wallet] Navbar and status bar are now set via XML
---
 .../src/main/java/net/taler/wallet/MainActivity.kt | 17 --------
 wallet/src/main/res/values-night/styles.xml        | 37 ++++-------------
 wallet/src/main/res/values-v27/styles.xml          | 26 ++++++++++++
 wallet/src/main/res/values/styles.xml              | 46 ++++++++++++++++++++--
 4 files changed, 75 insertions(+), 51 deletions(-)

diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt 
b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index 52db73b..13fd394 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -22,7 +22,6 @@ import android.content.Context
 import android.content.Intent
 import android.content.Intent.ACTION_VIEW
 import android.content.IntentFilter
-import android.content.res.Configuration
 import android.net.Uri
 import android.os.Bundle
 import android.util.Log
@@ -35,7 +34,6 @@ import androidx.activity.viewModels
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.os.bundleOf
 import androidx.core.view.GravityCompat.START
-import androidx.core.view.WindowInsetsControllerCompat
 import androidx.lifecycle.MutableLiveData
 import androidx.lifecycle.Observer
 import androidx.lifecycle.viewModelScope
@@ -46,7 +44,6 @@ import androidx.navigation.ui.setupWithNavController
 import androidx.preference.Preference
 import androidx.preference.PreferenceFragmentCompat
 import 
androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback
-import com.google.android.material.elevation.SurfaceColors
 import 
com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener
 import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG
 import com.google.android.material.snackbar.Snackbar
@@ -87,22 +84,8 @@ class MainActivity : AppCompatActivity(), 
OnNavigationItemSelectedListener,
         handleTalerUri(result.contents, "QR code")
     }
 
-    private val insetsController: WindowInsetsControllerCompat? by lazy {
-        window?.let { window -> WindowInsetsControllerCompat(window, 
window.decorView) }
-    }
-
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
-
-        // Set status bar color
-        val color = SurfaceColors.SURFACE_0.getColor(this)
-        val isLightMode = resources.configuration.uiMode and 
Configuration.UI_MODE_NIGHT_MASK !=
-                Configuration.UI_MODE_NIGHT_YES
-        window.statusBarColor = color
-        window.navigationBarColor = color
-        insetsController?.isAppearanceLightStatusBars = isLightMode
-        insetsController?.isAppearanceLightNavigationBars = isLightMode
-
         ui = ActivityMainBinding.inflate(layoutInflater)
         setContentView(ui.root)
 
diff --git a/wallet/src/main/res/values-night/styles.xml 
b/wallet/src/main/res/values-night/styles.xml
index 9fba037..d61986e 100644
--- a/wallet/src/main/res/values-night/styles.xml
+++ b/wallet/src/main/res/values-night/styles.xml
@@ -15,37 +15,14 @@
   -->
 
 
-<resources>
+<resources xmlns:tools="http://schemas.android.com/tools";>
 
-    <style name="AppTheme" parent="Theme.Material3.Dark">
+    <style name="AppTheme" parent="AppTheme.Dark">
         <item name="windowActionModeOverlay">true</item>
-
-        <!-- Material 3 theme builder -->
-        <item name="colorPrimary">@color/md_theme_dark_primary</item>
-        <item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
-        <item 
name="colorPrimaryContainer">@color/md_theme_dark_primaryContainer</item>
-        <item 
name="colorOnPrimaryContainer">@color/md_theme_dark_onPrimaryContainer</item>
-        <item name="colorSecondary">@color/md_theme_dark_secondary</item>
-        <item name="colorOnSecondary">@color/md_theme_dark_onSecondary</item>
-        <item 
name="colorSecondaryContainer">@color/md_theme_dark_secondaryContainer</item>
-        <item 
name="colorOnSecondaryContainer">@color/md_theme_dark_onSecondaryContainer</item>
-        <item name="colorTertiary">@color/md_theme_dark_tertiary</item>
-        <item name="colorOnTertiary">@color/md_theme_dark_onTertiary</item>
-        <item 
name="colorTertiaryContainer">@color/md_theme_dark_tertiaryContainer</item>
-        <item 
name="colorOnTertiaryContainer">@color/md_theme_dark_onTertiaryContainer</item>
-        <item name="colorError">@color/md_theme_dark_error</item>
-        <item 
name="colorErrorContainer">@color/md_theme_dark_errorContainer</item>
-        <item name="colorOnError">@color/md_theme_dark_onError</item>
-        <item 
name="colorOnErrorContainer">@color/md_theme_dark_onErrorContainer</item>
-        <item 
name="android:colorBackground">@color/md_theme_dark_background</item>
-        <item name="colorOnBackground">@color/md_theme_dark_onBackground</item>
-        <item name="colorSurface">@color/md_theme_dark_surface</item>
-        <item name="colorOnSurface">@color/md_theme_dark_onSurface</item>
-        <item 
name="colorSurfaceVariant">@color/md_theme_dark_surfaceVariant</item>
-        <item 
name="colorOnSurfaceVariant">@color/md_theme_dark_onSurfaceVariant</item>
-        <item name="colorOutline">@color/md_theme_dark_outline</item>
-        <item 
name="colorOnSurfaceInverse">@color/md_theme_dark_inverseOnSurface</item>
-        <item 
name="colorSurfaceInverse">@color/md_theme_dark_inverseSurface</item>
-        <item 
name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item>
+        <item name="android:statusBarColor">?colorSurface</item>
+        <item name="android:windowLightStatusBar" 
tools:targetApi="m">false</item>
+        <item name="android:navigationBarColor">?colorSurface</item>
+        <item name="android:windowLightNavigationBar" 
tools:targetApi="o_mr1">false</item>
     </style>
+
 </resources>
diff --git a/wallet/src/main/res/values-v27/styles.xml 
b/wallet/src/main/res/values-v27/styles.xml
new file mode 100644
index 0000000..5a21b91
--- /dev/null
+++ b/wallet/src/main/res/values-v27/styles.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  ~ This file is part of GNU Taler
+  ~ (C) 2023 Taler Systems S.A.
+  ~
+  ~ GNU Taler is free software; you can redistribute it and/or modify it under 
the
+  ~ terms of the GNU General Public License as published by the Free Software
+  ~ Foundation; either version 3, or (at your option) any later version.
+  ~
+  ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT 
ANY
+  ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+  ~ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License along 
with
+  ~ GNU Taler; see the file COPYING.  If not, see 
<http://www.gnu.org/licenses/>
+  -->
+
+<resources>
+
+    <style name="AppTheme" parent="AppTheme.Light">
+        <item name="android:statusBarColor">?colorSurface</item>
+        <item name="android:windowLightStatusBar">true</item>
+        <item name="android:navigationBarColor">?colorSurface</item>
+        <item name="android:windowLightNavigationBar">true</item>
+    </style>
+
+</resources>
\ No newline at end of file
diff --git a/wallet/src/main/res/values/styles.xml 
b/wallet/src/main/res/values/styles.xml
index 3cd4cf4..d7d939f 100644
--- a/wallet/src/main/res/values/styles.xml
+++ b/wallet/src/main/res/values/styles.xml
@@ -14,11 +14,9 @@
   ~ GNU Taler; see the file COPYING.  If not, see 
<http://www.gnu.org/licenses/>
   -->
 
-<resources>
-
-    <style name="AppTheme" parent="Theme.Material3.Light">
-        <item name="windowActionModeOverlay">true</item>
+<resources xmlns:tools="http://schemas.android.com/tools";>
 
+    <style name="AppTheme.Light" parent="Theme.Material3.Light">
         <!-- Material 3 theme builder -->
         <item name="colorPrimary">@color/md_theme_light_primary</item>
         <item name="colorOnPrimary">@color/md_theme_light_onPrimary</item>
@@ -48,6 +46,46 @@
         <item 
name="colorPrimaryInverse">@color/md_theme_light_inversePrimary</item>
     </style>
 
+    <style name="AppTheme.Dark" parent="Theme.Material3.Dark">
+        <item name="windowActionModeOverlay">true</item>
+        <item name="android:statusBarColor" 
tools:targetApi="m">?colorSurface</item>
+        <item name="android:windowLightStatusBar" 
tools:targetApi="m">false</item>
+        <item name="android:navigationBarColor" 
tools:targetApi="o_mr1">?colorSurface</item>
+        <item name="android:windowLightNavigationBar" 
tools:targetApi="o_mr1">false</item>
+
+        <!-- Material 3 theme builder -->
+        <item name="colorPrimary">@color/md_theme_dark_primary</item>
+        <item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
+        <item 
name="colorPrimaryContainer">@color/md_theme_dark_primaryContainer</item>
+        <item 
name="colorOnPrimaryContainer">@color/md_theme_dark_onPrimaryContainer</item>
+        <item name="colorSecondary">@color/md_theme_dark_secondary</item>
+        <item name="colorOnSecondary">@color/md_theme_dark_onSecondary</item>
+        <item 
name="colorSecondaryContainer">@color/md_theme_dark_secondaryContainer</item>
+        <item 
name="colorOnSecondaryContainer">@color/md_theme_dark_onSecondaryContainer</item>
+        <item name="colorTertiary">@color/md_theme_dark_tertiary</item>
+        <item name="colorOnTertiary">@color/md_theme_dark_onTertiary</item>
+        <item 
name="colorTertiaryContainer">@color/md_theme_dark_tertiaryContainer</item>
+        <item 
name="colorOnTertiaryContainer">@color/md_theme_dark_onTertiaryContainer</item>
+        <item name="colorError">@color/md_theme_dark_error</item>
+        <item 
name="colorErrorContainer">@color/md_theme_dark_errorContainer</item>
+        <item name="colorOnError">@color/md_theme_dark_onError</item>
+        <item 
name="colorOnErrorContainer">@color/md_theme_dark_onErrorContainer</item>
+        <item 
name="android:colorBackground">@color/md_theme_dark_background</item>
+        <item name="colorOnBackground">@color/md_theme_dark_onBackground</item>
+        <item name="colorSurface">@color/md_theme_dark_surface</item>
+        <item name="colorOnSurface">@color/md_theme_dark_onSurface</item>
+        <item 
name="colorSurfaceVariant">@color/md_theme_dark_surfaceVariant</item>
+        <item 
name="colorOnSurfaceVariant">@color/md_theme_dark_onSurfaceVariant</item>
+        <item name="colorOutline">@color/md_theme_dark_outline</item>
+        <item 
name="colorOnSurfaceInverse">@color/md_theme_dark_inverseOnSurface</item>
+        <item 
name="colorSurfaceInverse">@color/md_theme_dark_inverseSurface</item>
+        <item 
name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item>
+    </style>
+
+    <style name="AppTheme" parent="AppTheme.Light">
+        <item name="windowActionModeOverlay">true</item>
+    </style>
+
     <style name="AppTheme.NoActionBar">
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]