diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java index 281b1bacdd4..fd15f4e4ab5 100644 --- a/src/com/android/settings/accounts/AccountDashboardFragment.java +++ b/src/com/android/settings/accounts/AccountDashboardFragment.java @@ -17,7 +17,6 @@ package com.android.settings.accounts; import static android.provider.Settings.EXTRA_AUTHORITIES; -import android.app.Activity; import android.content.Context; import android.icu.text.ListFormatter; import android.os.UserHandle; @@ -27,6 +26,7 @@ import android.text.TextUtils; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.search.BaseSearchIndexProvider; @@ -69,15 +69,23 @@ public class AccountDashboardFragment extends DashboardFragment { @Override protected List createPreferenceControllers(Context context) { - final List controllers = new ArrayList<>(); final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES); + return buildPreferenceControllers(context, this /* parent */, authorities); + } + + private static List buildPreferenceControllers(Context context, + SettingsPreferenceFragment parent, String[] authorities) { + final List controllers = new ArrayList<>(); + final AccountPreferenceController accountPrefController = - new AccountPreferenceController(context, this, authorities); - getLifecycle().addObserver(accountPrefController); + new AccountPreferenceController(context, parent, authorities); + if (parent != null) { + parent.getLifecycle().addObserver(accountPrefController); + } controllers.add(accountPrefController); - controllers.add(new AutoSyncDataPreferenceController(context, this /*parent */)); - controllers.add(new AutoSyncPersonalDataPreferenceController(context, this /*parent */)); - controllers.add(new AutoSyncWorkDataPreferenceController(context, this /* parent */)); + controllers.add(new AutoSyncDataPreferenceController(context, parent)); + controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent)); + controllers.add(new AutoSyncWorkDataPreferenceController(context, parent)); return controllers; } @@ -122,13 +130,7 @@ public class AccountDashboardFragment extends DashboardFragment { } public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY - = new SummaryLoader.SummaryProviderFactory() { - @Override - public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity, - SummaryLoader summaryLoader) { - return new SummaryProvider(activity, summaryLoader); - } - }; + = (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader); public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() { @@ -139,5 +141,12 @@ public class AccountDashboardFragment extends DashboardFragment { sir.xmlResId = R.xml.accounts_dashboard_settings; return Arrays.asList(sir); } + + @Override + public List createPreferenceControllers( + Context context) { + return buildPreferenceControllers( + context, null /* parent */, null /* authorities*/); + } }; } \ No newline at end of file diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java index 108fbcaa2e8..c11fbc81138 100644 --- a/src/com/android/settings/notification/WorkSoundPreferenceController.java +++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java @@ -32,11 +32,6 @@ import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; -import androidx.preference.Preference; -import androidx.preference.Preference.OnPreferenceChangeListener; -import androidx.preference.PreferenceGroup; -import androidx.preference.PreferenceScreen; -import androidx.preference.TwoStatePreference; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; @@ -51,6 +46,14 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnPause; import com.android.settingslib.core.lifecycle.events.OnResume; +import java.util.List; + +import androidx.preference.Preference; +import androidx.preference.Preference.OnPreferenceChangeListener; +import androidx.preference.PreferenceGroup; +import androidx.preference.PreferenceScreen; +import androidx.preference.TwoStatePreference; + public class WorkSoundPreferenceController extends AbstractPreferenceController implements PreferenceControllerMixin, OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause { @@ -96,10 +99,8 @@ public class WorkSoundPreferenceController extends AbstractPreferenceController @Override public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY); - if (mWorkPreferenceCategory != null) { - mWorkPreferenceCategory.setVisible(isAvailable()); - } } @Override @@ -157,6 +158,18 @@ public class WorkSoundPreferenceController extends AbstractPreferenceController return true; } + @Override + public void updateNonIndexableKeys(List keys) { + if (isAvailable()) { + return; + } + keys.add(KEY_WORK_CATEGORY); + keys.add(KEY_WORK_USE_PERSONAL_SOUNDS); + keys.add(KEY_WORK_NOTIFICATION_RINGTONE); + keys.add(KEY_WORK_PHONE_RINGTONE); + keys.add(KEY_WORK_ALARM_RINGTONE); + } + // === Phone & notification ringtone === private boolean shouldShowRingtoneSettings() { diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java index 32f4b9238dd..9669863a06c 100644 --- a/src/com/android/settings/security/LockscreenDashboardFragment.java +++ b/src/com/android/settings/security/LockscreenDashboardFragment.java @@ -159,6 +159,7 @@ public class LockscreenDashboardFragment extends DashboardFragment final List niks = super.getNonIndexableKeys(context); niks.add(KEY_ADD_USER_FROM_LOCK_SCREEN); niks.add(KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE); + niks.add(KEY_LOCK_SCREEN_NOTIFICATON_WORK_PROFILE_HEADER); return niks; } };