From 45df6837cdb2a4614c64c772e5b9f84a9626a038 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 23 Mar 2021 09:52:35 -0700 Subject: Allow QS detail panels to change text of settings button User detail panel settings button will now say "User settings" instead of "More settings" Bug: 169783558 Test: atest SystemUITests Change-Id: I1a7a6963f15dbbf6ed8086113fa47f4662d8373c --- .../com/android/systemui/plugins/qs/DetailAdapter.java | 16 ++++++++++++++++ packages/SystemUI/res/values/strings.xml | 2 ++ .../SystemUI/src/com/android/systemui/qs/QSDetail.java | 7 ++++++- .../statusbar/policy/UserSwitcherController.java | 5 +++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/DetailAdapter.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/DetailAdapter.java index beee03b52579..caa9b4f4ec18 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/DetailAdapter.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/DetailAdapter.java @@ -16,6 +16,7 @@ package com.android.systemui.plugins.qs; import android.content.Context; import android.content.Intent; +import android.content.res.Resources; import android.view.View; import android.view.ViewGroup; @@ -34,7 +35,22 @@ public interface DetailAdapter { } View createDetailView(Context context, View convertView, ViewGroup parent); + + /** + * @return intent for opening more settings related to this detail panel. If null, the more + * settings button will not be shown + */ Intent getSettingsIntent(); + + /** + * @return resource id of the string to use for opening the settings intent. If + * {@code Resources.ID_NULL}, then use the default string: + * {@code com.android.systemui.R.string.quick_settings_more_settings} + */ + default int getSettingsText() { + return Resources.ID_NULL; + } + void setToggleState(boolean state); int getMetricsCategory(); diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 94bf86ab07da..935f0259fe86 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -889,6 +889,8 @@ Color correction mode More settings + + User settings Done diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java index 9967936ac1bd..05bc6e2a5e1e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSDetail.java @@ -23,6 +23,7 @@ import android.annotation.Nullable; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.drawable.Animatable; import android.util.AttributeSet; import android.util.SparseArray; @@ -140,7 +141,10 @@ public class QSDetail extends LinearLayout { private void updateDetailText() { mDetailDoneButton.setText(R.string.quick_settings_done); - mDetailSettingsButton.setText(R.string.quick_settings_more_settings); + final int resId = + mDetailAdapter != null ? mDetailAdapter.getSettingsText() : Resources.ID_NULL; + mDetailSettingsButton.setText( + (resId != Resources.ID_NULL) ? resId : R.string.quick_settings_more_settings); } public void updateResources() { @@ -218,6 +222,7 @@ public class QSDetail extends LinearLayout { mQsPanelController.setGridContentVisibility(true); mQsPanelCallback.onScanStateChanged(false); } + updateDetailText(); sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); if (mShouldAnimate) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index 0da441d1ad35..83558cbf089f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -821,6 +821,11 @@ public class UserSwitcherController implements Dumpable { return USER_SETTINGS_INTENT; } + @Override + public int getSettingsText() { + return R.string.quick_settings_more_user_settings; + } + @Override public Boolean getToggleState() { return null; -- cgit v1.2.3-59-g8ed1b