SystemUI: TunerActivity: Switch to material expressive design

Statusbar icons tuner looked never so good.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
Pranav Vashi
2025-11-14 17:58:34 +05:30
committed by Zabuka_zuzu
parent 5e08fe8913
commit 074783c0f4
6 changed files with 35 additions and 22 deletions

View File

@@ -631,7 +631,7 @@
<activity android:name=".tuner.TunerActivity"
android:enabled="false"
android:icon="@drawable/tuner"
android:theme="@style/Theme.SubSettingsBase"
android:theme="@style/Theme.SubSettingsBase.Expressive"
android:label="@string/system_ui_tuner"
android:process=":tuner"
android:enableOnBackInvokedCallback="true"
@@ -649,7 +649,7 @@
<activity-alias android:name=".DemoMode"
android:targetActivity=".tuner.TunerActivity"
android:icon="@drawable/tuner"
android:theme="@style/Theme.SubSettingsBase"
android:theme="@style/Theme.SubSettingsBase.Expressive"
android:label="@string/demo_mode"
android:process=":tuner"
android:exported="true">

View File

@@ -35,7 +35,7 @@
android:name=".tuner.StatusBarTuner"
android:targetActivity=".tuner.TunerActivity"
android:icon="@drawable/tuner"
android:theme="@style/Theme.SubSettingsBase"
android:theme="@style/Theme.SubSettingsBase.Expressive"
android:label="@string/status_bar_icons_title"
android:process=":tuner"
android:exported="true">

View File

@@ -22,7 +22,6 @@ import android.os.Bundle;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceFragment;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreferenceCompat;
@@ -34,7 +33,9 @@ import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.res.R;
import com.android.systemui.util.settings.GlobalSettings;
public class DemoModeFragment extends PreferenceFragment implements OnPreferenceChangeListener {
import com.android.settingslib.widget.SettingsBasePreferenceFragment;
public class DemoModeFragment extends SettingsBasePreferenceFragment implements OnPreferenceChangeListener {
private static final String[] STATUS_ICONS = {
"volume",

View File

@@ -18,13 +18,14 @@ package com.android.systemui.tuner;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceFragment;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.res.R;
public class StatusBarTuner extends PreferenceFragment {
import com.android.settingslib.widget.SettingsBasePreferenceFragment;
public class StatusBarTuner extends SettingsBasePreferenceFragment {
private MetricsLogger mMetricsLogger;

View File

@@ -67,10 +67,11 @@ public class TunerActivity extends CollapsingToolbarBaseActivity implements
setContentView(R.layout.tuner_activity);
DynamicColors.applyToActivityIfAvailable(this);
setTheme(com.android.settingslib.widget.theme.R.style.Theme_SubSettingsBase);
setTheme(com.android.settingslib.widget.theme.R.style.Theme_SubSettingsBase_Expressive);
// Handle window insets for padding adjustments
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.content_frame), (view, insets) -> {
ViewCompat.setOnApplyWindowInsetsListener(findViewById(
com.android.settingslib.collapsingtoolbar.R.id.content_frame), (view, insets) -> {
Insets systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars());
view.setPadding(
@@ -82,9 +83,9 @@ public class TunerActivity extends CollapsingToolbarBaseActivity implements
return insets;
});
if (getFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
if (getSupportFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
final String action = getIntent().getAction();
final Fragment fragment;
final androidx.fragment.app.Fragment fragment;
if ("com.android.settings.action.DEMO_MODE".equals(action)) {
fragment = new DemoModeFragment(mDemoModeController, mGlobalSettings);
} else if ("com.android.settings.action.STATUS_BAR_TUNER".equals(action)) {
@@ -92,9 +93,13 @@ public class TunerActivity extends CollapsingToolbarBaseActivity implements
} else {
fragment = new TunerFragment();
}
getFragmentManager().beginTransaction().replace(R.id.content_frame,
fragment, TAG_TUNER).commit();
getSupportFragmentManager()
.beginTransaction()
.replace(
com.android.settingslib.collapsingtoolbar.R.id.content_frame,
fragment
)
.commit();
}
}
@@ -106,18 +111,23 @@ public class TunerActivity extends CollapsingToolbarBaseActivity implements
@Override
public void onBackPressed() {
if (getFragmentManager().popBackStackImmediate()) {
if (getSupportFragmentManager().popBackStackImmediate()) {
String title = titleStack.poll();
if (title != null) {
setTitle(title);
}
try {
Fragment f = getFragmentManager().findFragmentById(R.id.content_frame);
Fragment fragment = (Fragment) f.getClass().newInstance();
androidx.fragment.app.Fragment f = getSupportFragmentManager().findFragmentById(
com.android.settingslib.collapsingtoolbar.R.id.content_frame);
androidx.fragment.app.Fragment fragment = (androidx.fragment.app.Fragment) f.getClass().newInstance();
fragment.setArguments(f.getArguments());
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.content_frame, fragment);
transaction.commit();
getSupportFragmentManager()
.beginTransaction()
.replace(
com.android.settingslib.collapsingtoolbar.R.id.content_frame,
fragment
)
.commit();
} catch (InstantiationException | IllegalAccessException e) {
Log.d("TunerActivity", "Problem launching fragment", e);
}

View File

@@ -21,7 +21,6 @@ import android.os.Build;
import android.os.Bundle;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragment;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -30,7 +29,9 @@ import com.android.systemui.shared.plugins.PluginPrefs;
import com.android.tools.r8.keepanno.annotations.KeepTarget;
import com.android.tools.r8.keepanno.annotations.UsesReflection;
public class TunerFragment extends PreferenceFragment {
import com.android.settingslib.widget.SettingsBasePreferenceFragment;
public class TunerFragment extends SettingsBasePreferenceFragment {
private static final String TAG = "TunerFragment";