Skip to content

Commit

Permalink
play-services-core: Theme improvements
Browse files Browse the repository at this point in the history
* Apply background color on status and navigation bar from API 23
* Drop ActionBar theme and switch to Toolbar which works better with theming

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
Change-Id: I82a0b00cf4d50e2ddf6739c730814f4ab3ab91c2
  • Loading branch information
theimpulson committed Dec 7, 2023
1 parent 891503f commit 81d31f7
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.ViewGroup;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

Expand All @@ -19,6 +20,8 @@ public abstract class AbstractSettingsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

if (showHomeAsUp) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />

<org.microg.tools.ui.SwitchBar
android:id="@+id/switch_bar"
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
android:label="@string/gms_app_name"
android:multiArch="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/Theme.AppCompat.DayNight">
android:theme="@style/Theme.App">

<library android:name="com.google.android.gms" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
Expand Down Expand Up @@ -32,6 +33,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}

setContentView(R.layout.settings_root_activity);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));

for (SettingsProvider settingsProvider : getAllSettingsProviders(this)) {
settingsProvider.extendNavigation(getNavController());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
android:layout_height="match_parent"
android:orientation="vertical">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/navhost"
android:name="androidx.navigation.fragment.NavHostFragment"
Expand Down
10 changes: 10 additions & 0 deletions play-services-core/src/main/res/values-night-v23/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.App" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:navigationBarColor">?android:colorBackground</item>
</style>

</resources>
11 changes: 11 additions & 0 deletions play-services-core/src/main/res/values-night-v27/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.App" parent="Theme.Base">
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar">false</item>
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:navigationBarColor">?android:colorBackground</item>
</style>

</resources>
10 changes: 10 additions & 0 deletions play-services-core/src/main/res/values-v23/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.App" parent="Theme.Base">
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:navigationBarColor">?android:colorBackground</item>
</style>

</resources>
11 changes: 11 additions & 0 deletions play-services-core/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.App" parent="Theme.Base">
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:statusBarColor">?android:colorBackground</item>
<item name="android:navigationBarColor">?android:colorBackground</item>
</style>

</resources>
6 changes: 6 additions & 0 deletions play-services-core/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

<resources>

<!-- Base application theme -->
<style name="Theme.Base" parent="Theme.AppCompat.DayNight.NoActionBar" />

<!-- Application theme (overrideable per API levels as required) -->
<style name="Theme.App" parent="Theme.Base" />

<style name="Theme.LoginBlue" parent="Theme.LoginBlue.Base" />

<style name="Theme.LoginBlue.Base" parent="Theme.AppCompat.Light.NoActionBar">
Expand Down

0 comments on commit 81d31f7

Please sign in to comment.