From a8442468ad821e1121c3e59b1b3545ba424a06af Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Mon, 22 Nov 2021 19:57:47 +0800 Subject: [PATCH 1/7] Align the "Open activity" UI style with usual accessibility service "Use service" Root Cause: "Open activity" Preference is not part of the widget SettingsMainSwitchBarPreference, so its UI style did not be inherited. Solution: "Open activity" has different concept from switch bar, we need to manual set its bacground to comply with the SettingsLib style. Bug: 207067203 Test: manual test Change-Id: I66f63f6952e5c4770509febc0e53eca6dc6eedb9 --- ...cessibility_launch_activity_preference.xml | 37 +++++++++++++++++++ ...cessibilityActivityPreferenceFragment.java | 1 + 2 files changed, 38 insertions(+) create mode 100644 res/layout/accessibility_launch_activity_preference.xml diff --git a/res/layout/accessibility_launch_activity_preference.xml b/res/layout/accessibility_launch_activity_preference.xml new file mode 100644 index 00000000000..772bb846c56 --- /dev/null +++ b/res/layout/accessibility_launch_activity_preference.xml @@ -0,0 +1,37 @@ + + + + + + + diff --git a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java index 3b15830a153..9666fe9354d 100644 --- a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java +++ b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java @@ -150,6 +150,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature private void initLaunchPreference() { final Preference launchPreference = new Preference(getPrefContext()); + launchPreference.setLayoutResource(R.layout.accessibility_launch_activity_preference); launchPreference.setKey(KEY_LAUNCH_PREFERENCE); final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo(); From 8a892271dae9ca6b2a2df28b8bf564bb4d2e712d Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Mon, 29 Nov 2021 11:53:56 +0800 Subject: [PATCH 2/7] [Settings] Refactor Wifi Calling description text Refactor the display of description text when no wifi calling options available. Enhancement: 1. These text need to align the style with the summary part of the wifi calling options. 2. These text need to be scrollable in order to see full description. 3. The link within text need to be clickable. Bug: 204844012 Test: local Change-Id: I60f339bf4adf50236d80176669a557c77f0d97ca --- .../wifi_calling_settings_preferences.xml | 9 +-- res/xml/wifi_calling_settings.xml | 7 ++ .../calling/LinkifyDescriptionPreference.java | 70 +++++++++++++++++++ .../calling/WifiCallingSettingsForSub.java | 68 +++++++++--------- 4 files changed, 114 insertions(+), 40 deletions(-) create mode 100644 src/com/android/settings/wifi/calling/LinkifyDescriptionPreference.java diff --git a/res/layout/wifi_calling_settings_preferences.xml b/res/layout/wifi_calling_settings_preferences.xml index 98acd9525a3..9a6cbe6698b 100644 --- a/res/layout/wifi_calling_settings_preferences.xml +++ b/res/layout/wifi_calling_settings_preferences.xml @@ -29,16 +29,11 @@ - - diff --git a/res/xml/wifi_calling_settings.xml b/res/xml/wifi_calling_settings.xml index 0276bdb6b10..902ff1af2fa 100644 --- a/res/xml/wifi_calling_settings.xml +++ b/res/xml/wifi_calling_settings.xml @@ -21,6 +21,7 @@ + + diff --git a/src/com/android/settings/wifi/calling/LinkifyDescriptionPreference.java b/src/com/android/settings/wifi/calling/LinkifyDescriptionPreference.java new file mode 100644 index 00000000000..60400b0f354 --- /dev/null +++ b/src/com/android/settings/wifi/calling/LinkifyDescriptionPreference.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.wifi.calling; + +import android.content.Context; +import android.text.SpannableString; +import android.text.TextUtils; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; +import android.text.util.Linkify; +import android.util.AttributeSet; +import android.view.View; +import android.widget.TextView; + +import androidx.core.text.util.LinkifyCompat; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + +import com.android.settings.R; + +/** A preference which supports linkify text as a description in the summary **/ +public class LinkifyDescriptionPreference extends Preference { + + public LinkifyDescriptionPreference(Context context) { + this(context, null); + } + + public LinkifyDescriptionPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void onBindViewHolder(PreferenceViewHolder holder) { + super.onBindViewHolder(holder); + + final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary); + if (summaryView == null || summaryView.getVisibility() != View.VISIBLE) { + return; + } + + final CharSequence summary = getSummary(); + if (TextUtils.isEmpty(summary)) { + return; + } + + summaryView.setMaxLines(Integer.MAX_VALUE); + + final SpannableString spannableSummary = new SpannableString(summary); + if (spannableSummary.getSpans(0, spannableSummary.length(), ClickableSpan.class) + .length > 0) { + summaryView.setMovementMethod(LinkMovementMethod.getInstance()); + } + LinkifyCompat.addLinks(summaryView, + Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS); + } +} diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java index 53e1b4cafd7..19664be4094 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java @@ -35,9 +35,7 @@ import android.telephony.ims.ImsManager; import android.telephony.ims.ImsMmTelManager; import android.telephony.ims.ProvisioningManager; import android.text.TextUtils; -import android.text.util.Linkify; import android.util.Log; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -59,8 +57,11 @@ import com.android.settings.Utils; import com.android.settings.core.SubSettingLauncher; import com.android.settings.network.ims.WifiCallingQueryImsState; import com.android.settings.widget.SettingsMainSwitchBar; +import com.android.settings.wifi.calling.LinkifyDescriptionPreference; import com.android.settingslib.widget.OnMainSwitchChangeListener; +import java.util.List; + /** * This is the inner class of {@link WifiCallingSettings} fragment. * The preference screen lets you enable/disable Wi-Fi Calling and change Wi-Fi Calling mode. @@ -74,6 +75,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment private static final String BUTTON_WFC_MODE = "wifi_calling_mode"; private static final String BUTTON_WFC_ROAMING_MODE = "wifi_calling_roaming_mode"; private static final String PREFERENCE_EMERGENCY_ADDRESS = "emergency_address_key"; + private static final String PREFERENCE_NO_OPTIONS_DESC = "no_options_description"; @VisibleForTesting static final int REQUEST_CHECK_WFC_EMERGENCY_ADDRESS = 1; @@ -93,7 +95,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment private ListWithEntrySummaryPreference mButtonWfcMode; private ListWithEntrySummaryPreference mButtonWfcRoamingMode; private Preference mUpdateAddress; - private TextView mEmptyView; private boolean mValidListener = false; private boolean mEditableWfcMode = true; @@ -187,15 +188,6 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - mEmptyView = getView().findViewById(android.R.id.empty); - setEmptyView(mEmptyView); - mEmptyView.setAutoLinkMask(Linkify.WEB_URLS); - final Resources res = getResourcesForSubId(); - final String emptyViewText = res.getString(R.string.wifi_calling_off_explanation, - res.getString(R.string.wifi_calling_off_explanation_2)); - mEmptyView.setText(emptyViewText); - mEmptyView.setGravity(Gravity.TOP | Gravity.LEFT); - mSwitchBar = getView().findViewById(R.id.switch_bar); mSwitchBar.show(); } @@ -311,6 +303,9 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment mIntentFilter = new IntentFilter(); mIntentFilter.addAction(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR); + + updateDescriptionForOptions( + List.of(mButtonWfcMode, mButtonWfcRoamingMode, mUpdateAddress)); } @Override @@ -326,7 +321,7 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment final View view = inflater.inflate( R.layout.wifi_calling_settings_preferences, container, false); - final ViewGroup prefs_container = view.findViewById(R.id.prefs_container); + final ViewGroup prefs_container = view.findViewById(android.R.id.tabcontent); Utils.prepareCustomPreferencesList(container, view, prefs_container, false); final View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState); prefs_container.addView(prefs); @@ -575,28 +570,35 @@ public class WifiCallingSettingsForSub extends SettingsPreferenceFragment final PreferenceScreen preferenceScreen = getPreferenceScreen(); final boolean updateAddressEnabled = (getCarrierActivityIntent() != null); if (wfcEnabled) { - if (mEditableWfcMode) { - preferenceScreen.addPreference(mButtonWfcMode); - } else { - // Don't show WFC (home) preference if it's not editable. - preferenceScreen.removePreference(mButtonWfcMode); - } - if (mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming) { - preferenceScreen.addPreference(mButtonWfcRoamingMode); - } else { - // Don't show WFC roaming preference if it's not editable. - preferenceScreen.removePreference(mButtonWfcRoamingMode); - } - if (updateAddressEnabled) { - preferenceScreen.addPreference(mUpdateAddress); - } else { - preferenceScreen.removePreference(mUpdateAddress); - } + // Don't show WFC (home) preference if it's not editable. + mButtonWfcMode.setVisible(mEditableWfcMode); + // Don't show WFC roaming preference if it's not editable. + mButtonWfcRoamingMode.setVisible( + mEditableWfcRoamingMode && !mUseWfcHomeModeForRoaming); + mUpdateAddress.setVisible(updateAddressEnabled); } else { - preferenceScreen.removePreference(mButtonWfcMode); - preferenceScreen.removePreference(mButtonWfcRoamingMode); - preferenceScreen.removePreference(mUpdateAddress); + mButtonWfcMode.setVisible(false); + mButtonWfcRoamingMode.setVisible(false); + mUpdateAddress.setVisible(false); } + updateDescriptionForOptions( + List.of(mButtonWfcMode, mButtonWfcRoamingMode, mUpdateAddress)); + } + + private void updateDescriptionForOptions(List visibleOptions) { + LinkifyDescriptionPreference pref = findPreference(PREFERENCE_NO_OPTIONS_DESC); + if (pref == null) { + return; + } + + boolean optionsAvailable = visibleOptions.stream().anyMatch(Preference::isVisible); + if (!optionsAvailable) { + final Resources res = getResourcesForSubId(); + String emptyViewText = res.getString(R.string.wifi_calling_off_explanation, + res.getString(R.string.wifi_calling_off_explanation_2)); + pref.setSummary(emptyViewText); + } + pref.setVisible(!optionsAvailable); } @Override From 2f193c81576e2e86cf64470aeb312cab1e76d40d Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Mon, 29 Nov 2021 16:06:38 +0000 Subject: [PATCH 3/7] Add non system overlay flag to InstallCaCertificateWarning Bug: 196969991 Test: Manual testing with Settings Change-Id: Ia9dc251c853526b2ce66c9f8ff595d496b7f1bc4 --- .../settings/security/InstallCaCertificateWarning.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/android/settings/security/InstallCaCertificateWarning.java b/src/com/android/settings/security/InstallCaCertificateWarning.java index 38548756a31..139bc1c2700 100644 --- a/src/com/android/settings/security/InstallCaCertificateWarning.java +++ b/src/com/android/settings/security/InstallCaCertificateWarning.java @@ -16,6 +16,8 @@ package com.android.settings.security; +import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; + import android.annotation.Nullable; import android.app.Activity; import android.content.Intent; @@ -45,6 +47,8 @@ public class InstallCaCertificateWarning extends Activity { setTheme(SetupWizardUtils.getTheme(this, getIntent())); ThemeHelper.trySetDynamicColor(this); setContentView(R.layout.ca_certificate_warning_dialog); + getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS); + final GlifLayout layout = findViewById(R.id.setup_wizard_layout); layout.setHeaderText(R.string.ca_certificate_warning_title); @@ -57,6 +61,7 @@ public class InstallCaCertificateWarning extends Activity { .setTheme(R.style.SudGlifButton_Secondary) .build() ); + mixin.getSecondaryButtonView().setFilterTouchesWhenObscured(true); mixin.setPrimaryButton( new FooterButton.Builder(this) @@ -66,6 +71,7 @@ public class InstallCaCertificateWarning extends Activity { .setTheme(R.style.SudGlifButton_Primary) .build() ); + mixin.getPrimaryButtonView().setFilterTouchesWhenObscured(true); } private View.OnClickListener installCaCertificate() { From 756fa20e1ce86dc1fa0ef72b8782b8486d3882bb Mon Sep 17 00:00:00 2001 From: Joshua Mccloskey Date: Tue, 30 Nov 2021 09:29:13 -0800 Subject: [PATCH 4/7] Fixed face enroll intro button issue Fixed an issue where sometimes after completing face authentication the more & agree buttons would display instead of the done button. 1. Enter SUW 2. Complete face authentication flow 3. Go to next step (finishing the Biometric flow) 4. Press the back button 5. Observe that the text now says "Done" Fixes: 205203673 Test: Verified button text is changed as expected during SUW. Change-Id: I5cfad265f9b27669dcad64e5872750695b1b5bdc --- .../biometrics/BiometricEnrollIntroduction.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java index f80b01f39c3..7f3bc87aaec 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java +++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java @@ -203,11 +203,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase getMoreButtonTextRes(), this::onNextButtonClick); requireScrollMixin.setOnRequireScrollStateChangedListener( scrollNeeded -> { - // Update text of primary button from "More" to "Agree". - final int primaryButtonTextRes = scrollNeeded - ? getMoreButtonTextRes() - : getAgreeButtonTextRes(); - getPrimaryFooterButton().setText(this, primaryButtonTextRes); + + boolean enrollmentCompleted = checkMaxEnrolled() != 0; + if (!enrollmentCompleted) { + // Update text of primary button from "More" to "Agree". + final int primaryButtonTextRes = scrollNeeded + ? getMoreButtonTextRes() + : getAgreeButtonTextRes(); + getPrimaryFooterButton().setText(this, primaryButtonTextRes); + } // Show secondary button once scroll is completed. if (!scrollNeeded) { From 28bc1c04b98ad901462ae865e347f64c35d010d9 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Thu, 18 Nov 2021 15:45:44 +0800 Subject: [PATCH 5/7] Fix the background color of CollapsingToolbarLayout The wrong background color of CollapsingToolbarLayout appears in some pages like "All apps" page or "Password and accounts" page. This symptom can be observed in these pages when the work profile is enabled and the line count of title is 1. This issue is caused by updating the title of the page many times. In these pages that have the tab view, the structure of the page differs from a general setting page. The title of the page is coming from BaseActivity, ProfileSelectFragment, PersonalFragment and WorkFragment, in which the page that has the issue has an empty string from ProfileSelectFragment. That is causing the CollapsingTollbarLayout has the different line count during the process of setting the title. Since the pages that have the tab view are different from the general pages in Settings, the title should be set separately for those pages. Adding a method to get the title resource ID so the page extending from ProfileSelectFragment can set its title. Bug: 192914660 Test: visual test and manual test 1) Enable work profile 2) Navigate to All apps page 3) The page should have the correct background color in the CollapsingToolbarLayout Change-Id: I52ef9729f3cad56161ea3d87ba25429dfcdb26ef --- .../accounts_dashboard_settings_header.xml | 22 ++++++++ res/xml/location_recent_requests_header.xml | 22 ++++++++ res/xml/location_services_header.xml | 22 ++++++++ res/xml/location_settings_header.xml | 22 ++++++++ .../ManageApplications.java | 56 ++++++++++++++----- .../ProfileSelectAccountFragment.java | 6 ++ .../ProfileSelectFragment.java | 12 ++++ .../ProfileSelectLocationFragment.java | 5 ++ ...ProfileSelectLocationServicesFragment.java | 6 ++ .../ProfileSelectManageApplications.java | 10 ++++ ...leSelectRecentLocationRequestFragment.java | 6 ++ 11 files changed, 174 insertions(+), 15 deletions(-) create mode 100644 res/xml/accounts_dashboard_settings_header.xml create mode 100644 res/xml/location_recent_requests_header.xml create mode 100644 res/xml/location_services_header.xml create mode 100644 res/xml/location_settings_header.xml diff --git a/res/xml/accounts_dashboard_settings_header.xml b/res/xml/accounts_dashboard_settings_header.xml new file mode 100644 index 00000000000..99f07360f48 --- /dev/null +++ b/res/xml/accounts_dashboard_settings_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_recent_requests_header.xml b/res/xml/location_recent_requests_header.xml new file mode 100644 index 00000000000..0e252a5db85 --- /dev/null +++ b/res/xml/location_recent_requests_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_services_header.xml b/res/xml/location_services_header.xml new file mode 100644 index 00000000000..4eaf2c5bc00 --- /dev/null +++ b/res/xml/location_services_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_settings_header.xml b/res/xml/location_settings_header.xml new file mode 100644 index 00000000000..4749a2e3a6a --- /dev/null +++ b/res/xml/location_settings_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java index c1f45746599..7b5c2218f7d 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -272,8 +272,7 @@ public class ManageApplications extends InstrumentedFragment Intent intent = activity.getIntent(); Bundle args = getArguments(); - int screenTitle = intent.getIntExtra( - SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps); + final int screenTitle = getTitleResId(intent, args); String className = args != null ? args.getString(EXTRA_CLASSNAME) : null; if (className == null) { className = intent.getComponent().getClassName(); @@ -290,49 +289,36 @@ public class ManageApplications extends InstrumentedFragment mSortOrder = R.id.sort_order_size; } else if (className.equals(UsageAccessSettingsActivity.class.getName())) { mListType = LIST_TYPE_USAGE_ACCESS; - screenTitle = R.string.usage_access; } else if (className.equals(HighPowerApplicationsActivity.class.getName())) { mListType = LIST_TYPE_HIGH_POWER; // Default to showing system. mShowSystem = true; - screenTitle = R.string.high_power_apps; } else if (className.equals(OverlaySettingsActivity.class.getName())) { mListType = LIST_TYPE_OVERLAY; - screenTitle = R.string.system_alert_window_settings; reportIfRestrictedSawIntent(intent); } else if (className.equals(WriteSettingsActivity.class.getName())) { mListType = LIST_TYPE_WRITE_SETTINGS; - screenTitle = R.string.write_settings; } else if (className.equals(ManageExternalSourcesActivity.class.getName())) { mListType = LIST_TYPE_MANAGE_SOURCES; - screenTitle = R.string.install_other_apps; } else if (className.equals(GamesStorageActivity.class.getName())) { mListType = LIST_TYPE_GAMES; mSortOrder = R.id.sort_order_size; } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) { mListType = LIST_TYPE_WIFI_ACCESS; - screenTitle = R.string.change_wifi_state_title; } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) { mListType = LIST_MANAGE_EXTERNAL_STORAGE; - screenTitle = R.string.manage_external_storage_title; } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) { mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS; - screenTitle = R.string.media_management_apps_title; } else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) { mListType = LIST_TYPE_ALARMS_AND_REMINDERS; - screenTitle = R.string.alarms_and_reminders_title; } else if (className.equals(Settings.NotificationAppListActivity.class.getName())) { mListType = LIST_TYPE_NOTIFICATION; mUsageStatsManager = IUsageStatsManager.Stub.asInterface( ServiceManager.getService(Context.USAGE_STATS_SERVICE)); mNotificationBackend = new NotificationBackend(); mSortOrder = R.id.sort_order_recent_notification; - screenTitle = R.string.app_notifications_title; } else { - if (screenTitle == -1) { - screenTitle = R.string.all_apps; - } mListType = LIST_TYPE_MAIN; } final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance(); @@ -881,6 +867,46 @@ public class ManageApplications extends InstrumentedFragment params.setBehavior(behavior); } + /** + * Returns a resource ID of title based on what type of app list is + * @param intent the intent of the activity that might include a specified title + * @param args the args that includes a class name of app list + */ + public static int getTitleResId(@NonNull Intent intent, Bundle args) { + int screenTitle = intent.getIntExtra( + SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps); + String className = args != null ? args.getString(EXTRA_CLASSNAME) : null; + if (className == null) { + className = intent.getComponent().getClassName(); + } + if (className.equals(Settings.UsageAccessSettingsActivity.class.getName())) { + screenTitle = R.string.usage_access; + } else if (className.equals(Settings.HighPowerApplicationsActivity.class.getName())) { + screenTitle = R.string.high_power_apps; + } else if (className.equals(Settings.OverlaySettingsActivity.class.getName())) { + screenTitle = R.string.system_alert_window_settings; + } else if (className.equals(Settings.WriteSettingsActivity.class.getName())) { + screenTitle = R.string.write_settings; + } else if (className.equals(Settings.ManageExternalSourcesActivity.class.getName())) { + screenTitle = R.string.install_other_apps; + } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) { + screenTitle = R.string.change_wifi_state_title; + } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) { + screenTitle = R.string.manage_external_storage_title; + } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) { + screenTitle = R.string.media_management_apps_title; + } else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) { + screenTitle = R.string.alarms_and_reminders_title; + } else if (className.equals(Settings.NotificationAppListActivity.class.getName())) { + screenTitle = R.string.app_notifications_title; + } else { + if (screenTitle == -1) { + screenTitle = R.string.all_apps; + } + } + return screenTitle; + } + static class FilterSpinnerAdapter extends SettingsSpinnerAdapter { private final ManageApplications mManageApplications; diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java index ac67b586fa3..cf91031933a 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java @@ -17,6 +17,7 @@ package com.android.settings.dashboard.profileselector; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.accounts.AccountPersonalDashboardFragment; import com.android.settings.accounts.AccountWorkProfileDashboardFragment; @@ -32,4 +33,9 @@ public class ProfileSelectAccountFragment extends ProfileSelectFragment { new AccountWorkProfileDashboardFragment() }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.accounts_dashboard_settings_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java index 82d524d9f06..3b64d3d0c77 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java @@ -107,6 +107,10 @@ public abstract class ProfileSelectFragment extends DashboardFragment { Bundle savedInstanceState) { mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState); final Activity activity = getActivity(); + final int titleResId = getTitleResId(); + if (titleResId > 0) { + activity.setTitle(titleResId); + } final int selectedTab = convertPosition(getTabId(activity, getArguments())); final View tabContainer = mContentView.findViewById(R.id.tab_container); @@ -166,6 +170,14 @@ public abstract class ProfileSelectFragment extends DashboardFragment { */ public abstract Fragment[] getFragments(); + /** + * Returns a resource ID of the title + * Override this if the title needs to be updated dynamically. + */ + public int getTitleResId() { + return 0; + } + @Override protected int getPreferenceScreenResId() { return R.xml.placeholder_preference_screen; diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java index e4cde8e1590..28fb97bb42f 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java @@ -60,4 +60,9 @@ public class ProfileSelectLocationFragment extends ProfileSelectFragment { workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_settings_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java index b6f03d6b820..5f25f599988 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java @@ -20,6 +20,7 @@ import android.os.Bundle; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.location.LocationServices; import com.android.settings.location.LocationServicesForWork; @@ -44,4 +45,9 @@ public class ProfileSelectLocationServicesFragment extends ProfileSelectFragment workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_services_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java index 17fed11b44b..36aa9c53358 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java @@ -16,6 +16,8 @@ package com.android.settings.dashboard.profileselector; +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; @@ -43,4 +45,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment { workFragment }; } + + @Override + public int getTitleResId() { + final Activity activity = getActivity(); + final Intent intent = activity.getIntent(); + final Bundle args = getArguments(); + return ManageApplications.getTitleResId(intent, args); + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java index 058ffe4dfd2..16cb43cc432 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java @@ -20,6 +20,7 @@ import android.os.Bundle; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.location.RecentLocationRequestSeeAllFragment; /** @@ -43,4 +44,9 @@ public class ProfileSelectRecentLocationRequestFragment extends ProfileSelectFra workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_recent_requests_header; + } } From 65d46d6ee4851e6f093556bcd232b58b9e37fd3e Mon Sep 17 00:00:00 2001 From: Super Liu Date: Mon, 15 Nov 2021 12:45:50 +0800 Subject: [PATCH 6/7] Set property based on gesture option changed. System software could do the runtime configuration based on this added property. Bug: 193467627 Test: manual test. Signed-off-by: Super Liu Change-Id: I1897320e1c5d5d446727899328363e6a714983f8 --- .../gestures/TapScreenGesturePreferenceController.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java b/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java index 179ed262a20..86ac713194f 100644 --- a/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java +++ b/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java @@ -21,6 +21,7 @@ import static android.provider.Settings.Secure.DOZE_TAP_SCREEN_GESTURE; import android.annotation.UserIdInt; import android.content.Context; import android.hardware.display.AmbientDisplayConfiguration; +import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; @@ -74,8 +75,10 @@ public class TapScreenGesturePreferenceController extends GesturePreferenceContr @Override public boolean setChecked(boolean isChecked) { - return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_TAP_SCREEN_GESTURE, - isChecked ? 1 : 0); + boolean success = Settings.Secure.putInt(mContext.getContentResolver(), + DOZE_TAP_SCREEN_GESTURE, isChecked ? 1 : 0); + SystemProperties.set("persist.sys.tap_gesture", isChecked ? "1" : "0"); + return success; } private AmbientDisplayConfiguration getAmbientConfig() { From 3825bff0210f33ad2e4b154597f6a2095d581109 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Thu, 18 Nov 2021 15:45:44 +0800 Subject: [PATCH 7/7] Fix the background color of CollapsingToolbarLayout The wrong background color of CollapsingToolbarLayout appears in some pages like "All apps" page or "Password and accounts" page. This symptom can be observed in these pages when the work profile is enabled and the line count of title is 1. This issue is caused by updating the title of the page many times. In these pages that have the tab view, the structure of the page differs from a general setting page. The title of the page is coming from BaseActivity, ProfileSelectFragment, PersonalFragment and WorkFragment, in which the page that has the issue has an empty string from ProfileSelectFragment. That is causing the CollapsingTollbarLayout has the different line count during the process of setting the title. Since the pages that have the tab view are different from the general pages in Settings, the title should be set separately for those pages. Adding a method to get the title resource ID so the page extending from ProfileSelectFragment can set its title. Bug: 192914660 Test: visual test and manual test 1) Enable work profile 2) Navigate to All apps page 3) The page should have the correct background color in the CollapsingToolbarLayout Change-Id: I52ef9729f3cad56161ea3d87ba25429dfcdb26ef Merged-In: I52ef9729f3cad56161ea3d87ba25429dfcdb26ef --- .../accounts_dashboard_settings_header.xml | 22 +++++++ ...location_recent_location_access_header.xml | 22 +++++++ res/xml/location_recent_requests_header.xml | 22 +++++++ res/xml/location_services_header.xml | 22 +++++++ res/xml/location_settings_header.xml | 22 +++++++ .../ManageApplications.java | 57 ++++++++++++++----- .../ProfileSelectAccountFragment.java | 6 ++ .../ProfileSelectFragment.java | 12 ++++ .../ProfileSelectLocationFragment.java | 5 ++ ...ProfileSelectLocationServicesFragment.java | 6 ++ .../ProfileSelectManageApplications.java | 10 ++++ ...ileSelectRecentLocationAccessFragment.java | 6 ++ ...leSelectRecentLocationRequestFragment.java | 6 ++ 13 files changed, 203 insertions(+), 15 deletions(-) create mode 100644 res/xml/accounts_dashboard_settings_header.xml create mode 100644 res/xml/location_recent_location_access_header.xml create mode 100644 res/xml/location_recent_requests_header.xml create mode 100644 res/xml/location_services_header.xml create mode 100644 res/xml/location_settings_header.xml diff --git a/res/xml/accounts_dashboard_settings_header.xml b/res/xml/accounts_dashboard_settings_header.xml new file mode 100644 index 00000000000..99f07360f48 --- /dev/null +++ b/res/xml/accounts_dashboard_settings_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_recent_location_access_header.xml b/res/xml/location_recent_location_access_header.xml new file mode 100644 index 00000000000..219f13e9cdf --- /dev/null +++ b/res/xml/location_recent_location_access_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_recent_requests_header.xml b/res/xml/location_recent_requests_header.xml new file mode 100644 index 00000000000..0e252a5db85 --- /dev/null +++ b/res/xml/location_recent_requests_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_services_header.xml b/res/xml/location_services_header.xml new file mode 100644 index 00000000000..4eaf2c5bc00 --- /dev/null +++ b/res/xml/location_services_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/res/xml/location_settings_header.xml b/res/xml/location_settings_header.xml new file mode 100644 index 00000000000..4749a2e3a6a --- /dev/null +++ b/res/xml/location_settings_header.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java index edd4088a27f..d20e570acb5 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -272,8 +272,8 @@ public class ManageApplications extends InstrumentedFragment Intent intent = activity.getIntent(); Bundle args = getArguments(); - int screenTitle = intent.getIntExtra( - SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps); + final int screenTitle = getTitleResId(intent, args); + String className = args != null ? args.getString(EXTRA_CLASSNAME) : null; if (className == null) { className = intent.getComponent().getClassName(); @@ -290,49 +290,36 @@ public class ManageApplications extends InstrumentedFragment mSortOrder = R.id.sort_order_size; } else if (className.equals(UsageAccessSettingsActivity.class.getName())) { mListType = LIST_TYPE_USAGE_ACCESS; - screenTitle = R.string.usage_access; } else if (className.equals(HighPowerApplicationsActivity.class.getName())) { mListType = LIST_TYPE_HIGH_POWER; // Default to showing system. mShowSystem = true; - screenTitle = R.string.high_power_apps; } else if (className.equals(OverlaySettingsActivity.class.getName())) { mListType = LIST_TYPE_OVERLAY; - screenTitle = R.string.system_alert_window_settings; reportIfRestrictedSawIntent(intent); } else if (className.equals(WriteSettingsActivity.class.getName())) { mListType = LIST_TYPE_WRITE_SETTINGS; - screenTitle = R.string.write_settings; } else if (className.equals(ManageExternalSourcesActivity.class.getName())) { mListType = LIST_TYPE_MANAGE_SOURCES; - screenTitle = R.string.install_other_apps; } else if (className.equals(GamesStorageActivity.class.getName())) { mListType = LIST_TYPE_GAMES; mSortOrder = R.id.sort_order_size; } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) { mListType = LIST_TYPE_WIFI_ACCESS; - screenTitle = R.string.change_wifi_state_title; } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) { mListType = LIST_MANAGE_EXTERNAL_STORAGE; - screenTitle = R.string.manage_external_storage_title; } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) { mListType = LIST_TYPE_MEDIA_MANAGEMENT_APPS; - screenTitle = R.string.media_management_apps_title; } else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) { mListType = LIST_TYPE_ALARMS_AND_REMINDERS; - screenTitle = R.string.alarms_and_reminders_title; } else if (className.equals(Settings.NotificationAppListActivity.class.getName())) { mListType = LIST_TYPE_NOTIFICATION; mUsageStatsManager = IUsageStatsManager.Stub.asInterface( ServiceManager.getService(Context.USAGE_STATS_SERVICE)); mNotificationBackend = new NotificationBackend(); mSortOrder = R.id.sort_order_recent_notification; - screenTitle = R.string.app_notifications_title; } else { - if (screenTitle == -1) { - screenTitle = R.string.all_apps; - } mListType = LIST_TYPE_MAIN; } final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance(); @@ -881,6 +868,46 @@ public class ManageApplications extends InstrumentedFragment params.setBehavior(behavior); } + /** + * Returns a resource ID of title based on what type of app list is + * @param intent the intent of the activity that might include a specified title + * @param args the args that includes a class name of app list + */ + public static int getTitleResId(@NonNull Intent intent, Bundle args) { + int screenTitle = intent.getIntExtra( + SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.all_apps); + String className = args != null ? args.getString(EXTRA_CLASSNAME) : null; + if (className == null) { + className = intent.getComponent().getClassName(); + } + if (className.equals(Settings.UsageAccessSettingsActivity.class.getName())) { + screenTitle = R.string.usage_access; + } else if (className.equals(Settings.HighPowerApplicationsActivity.class.getName())) { + screenTitle = R.string.high_power_apps; + } else if (className.equals(Settings.OverlaySettingsActivity.class.getName())) { + screenTitle = R.string.system_alert_window_settings; + } else if (className.equals(Settings.WriteSettingsActivity.class.getName())) { + screenTitle = R.string.write_settings; + } else if (className.equals(Settings.ManageExternalSourcesActivity.class.getName())) { + screenTitle = R.string.install_other_apps; + } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) { + screenTitle = R.string.change_wifi_state_title; + } else if (className.equals(Settings.ManageExternalStorageActivity.class.getName())) { + screenTitle = R.string.manage_external_storage_title; + } else if (className.equals(Settings.MediaManagementAppsActivity.class.getName())) { + screenTitle = R.string.media_management_apps_title; + } else if (className.equals(Settings.AlarmsAndRemindersActivity.class.getName())) { + screenTitle = R.string.alarms_and_reminders_title; + } else if (className.equals(Settings.NotificationAppListActivity.class.getName())) { + screenTitle = R.string.app_notifications_title; + } else { + if (screenTitle == -1) { + screenTitle = R.string.all_apps; + } + } + return screenTitle; + } + static class FilterSpinnerAdapter extends SettingsSpinnerAdapter { private final ManageApplications mManageApplications; diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java index ac67b586fa3..cf91031933a 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectAccountFragment.java @@ -17,6 +17,7 @@ package com.android.settings.dashboard.profileselector; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.accounts.AccountPersonalDashboardFragment; import com.android.settings.accounts.AccountWorkProfileDashboardFragment; @@ -32,4 +33,9 @@ public class ProfileSelectAccountFragment extends ProfileSelectFragment { new AccountWorkProfileDashboardFragment() }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.accounts_dashboard_settings_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java index 82d524d9f06..79a4b87e991 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java @@ -107,6 +107,10 @@ public abstract class ProfileSelectFragment extends DashboardFragment { Bundle savedInstanceState) { mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState); final Activity activity = getActivity(); + final int titleResId = getTitleResId(); + if (titleResId > 0) { + activity.setTitle(titleResId); + } final int selectedTab = convertPosition(getTabId(activity, getArguments())); final View tabContainer = mContentView.findViewById(R.id.tab_container); @@ -166,6 +170,14 @@ public abstract class ProfileSelectFragment extends DashboardFragment { */ public abstract Fragment[] getFragments(); + /** + * Returns a resource ID of the title + * Override this if the title needs to be updated dynamically. + */ + int getTitleResId() { + return 0; + } + @Override protected int getPreferenceScreenResId() { return R.xml.placeholder_preference_screen; diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java index e4cde8e1590..28fb97bb42f 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationFragment.java @@ -60,4 +60,9 @@ public class ProfileSelectLocationFragment extends ProfileSelectFragment { workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_settings_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java index b6f03d6b820..5f25f599988 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectLocationServicesFragment.java @@ -20,6 +20,7 @@ import android.os.Bundle; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.location.LocationServices; import com.android.settings.location.LocationServicesForWork; @@ -44,4 +45,9 @@ public class ProfileSelectLocationServicesFragment extends ProfileSelectFragment workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_services_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java index 17fed11b44b..cbd1fe3d491 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectManageApplications.java @@ -16,6 +16,8 @@ package com.android.settings.dashboard.profileselector; +import android.app.Activity; +import android.content.Intent; import android.os.Bundle; import androidx.fragment.app.Fragment; @@ -43,4 +45,12 @@ public class ProfileSelectManageApplications extends ProfileSelectFragment { workFragment }; } + + @Override + int getTitleResId() { + final Activity activity = getActivity(); + final Intent intent = activity.getIntent(); + final Bundle args = getArguments(); + return ManageApplications.getTitleResId(intent, args); + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationAccessFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationAccessFragment.java index 3cb77c545a4..d9b9ba44fa9 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationAccessFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationAccessFragment.java @@ -20,6 +20,7 @@ import android.os.Bundle; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.location.RecentLocationAccessSeeAllFragment; /** @@ -43,4 +44,9 @@ public class ProfileSelectRecentLocationAccessFragment extends ProfileSelectFrag workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_recent_location_access_header; + } } diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java index 058ffe4dfd2..16cb43cc432 100644 --- a/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java +++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectRecentLocationRequestFragment.java @@ -20,6 +20,7 @@ import android.os.Bundle; import androidx.fragment.app.Fragment; +import com.android.settings.R; import com.android.settings.location.RecentLocationRequestSeeAllFragment; /** @@ -43,4 +44,9 @@ public class ProfileSelectRecentLocationRequestFragment extends ProfileSelectFra workFragment }; } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.location_recent_requests_header; + } }