Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28bc1c04 authored by Mill Chen's avatar Mill Chen
Browse files

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
parent ecf408bb
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/account_dashboard_title"
    settings:searchable="false">
</PreferenceScreen>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/location_category_recent_location_requests"
    settings:searchable="false">
</PreferenceScreen>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/location_services_preference_title"
    settings:searchable="false">
</PreferenceScreen>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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.
-->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/location_settings_title"
    settings:searchable="false">
</PreferenceScreen>
+41 −15
Original line number Diff line number Diff line
@@ -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<CharSequence> {

        private final ManageApplications mManageApplications;
Loading