use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PhoneNumberPreferenceControllerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mClipboardManager = (ClipboardManager) spy(mContext.getSystemService(CLIPBOARD_SERVICE));
doReturn(mClipboardManager).when(mContext).getSystemService(CLIPBOARD_SERVICE);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
mController = spy(new PhoneNumberPreferenceController(mContext, "phone_number"));
if (Looper.myLooper() == null) {
Looper.prepare();
}
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
mScreen = preferenceManager.createPreferenceScreen(mContext);
mPreference = spy(new Preference(mContext));
mPreference.setKey(mController.getPreferenceKey());
mPreference.setVisible(true);
mScreen.addPreference(mPreference);
final String categoryKey = "basic_info_category";
mCategory = new PreferenceCategory(mContext);
mCategory.setKey(categoryKey);
mScreen.addPreference(mCategory);
doReturn(mSubscriptionInfo).when(mController).getSubscriptionInfo(anyInt());
doReturn(mSecondPreference).when(mController).createNewPreference(mContext);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboard method createChangeCategoryPreference.
PreferenceCategory createChangeCategoryPreference(List<CompatibilityChangeInfo> changes, CompatibilityChangeConfig configMappings, String title) {
final PreferenceCategory category = new PreferenceCategory(getPreferenceScreen().getContext());
category.setTitle(title);
getPreferenceScreen().addPreference(category);
addChangePreferencesToCategory(changes, category, configMappings);
return category;
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PriorityConversationsPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
PreferenceCategory pref = (PreferenceCategory) preference;
// Load conversations
mConversations = mBackend.getConversations(true).getList();
Collections.sort(mConversations, mConversationComparator);
populateList(mConversations, pref);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class RecentConversationsPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
PreferenceCategory pref = (PreferenceCategory) preference;
// Load conversations
try {
mConversations = mPs.getRecentConversations().getList();
} catch (RemoteException e) {
Slog.w(TAG, "Could get recents", e);
}
Collections.sort(mConversations, mConversationComparator);
populateList(mConversations, pref);
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class ZenModeAddBypassingAppsPreferenceController method updateAppList.
@VisibleForTesting
void updateAppList(List<ApplicationsState.AppEntry> apps) {
if (apps == null) {
return;
}
if (mPreferenceCategory == null) {
mPreferenceCategory = new PreferenceCategory(mPrefContext);
mPreferenceCategory.setTitle(R.string.zen_mode_bypassing_apps_add_header);
mPreferenceScreen.addPreference(mPreferenceCategory);
}
List<Preference> appsWithNoBypassingDndNotificationChannels = new ArrayList<>();
for (ApplicationsState.AppEntry entry : apps) {
String pkg = entry.info.packageName;
mApplicationsState.ensureIcon(entry);
final int appChannels = mNotificationBackend.getChannelCount(pkg, entry.info.uid);
final int appChannelsBypassingDnd = mNotificationBackend.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList().size();
if (appChannelsBypassingDnd == 0 && appChannels > 0) {
final String key = ZenModeAllBypassingAppsPreferenceController.getKey(pkg);
Preference pref = mPreferenceCategory.findPreference("");
if (pref == null) {
pref = new AppPreference(mPrefContext);
pref.setKey(key);
pref.setOnPreferenceClickListener(preference -> {
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
new SubSettingLauncher(mContext).setDestination(AppChannelsBypassingDndSettings.class.getName()).setArguments(args).setResultListener(mHostFragment, 0).setUserHandle(new UserHandle(UserHandle.getUserId(entry.info.uid))).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP).launch();
return true;
});
}
pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
pref.setIcon(entry.icon);
appsWithNoBypassingDndNotificationChannels.add(pref);
}
}
if (appsWithNoBypassingDndNotificationChannels.size() == 0) {
Preference pref = mPreferenceCategory.findPreference(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
if (pref == null) {
pref = new Preference(mPrefContext);
pref.setKey(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
pref.setTitle(R.string.zen_mode_bypassing_apps_subtext_none);
}
mPreferenceCategory.addPreference(pref);
}
if (ZenModeAllBypassingAppsPreferenceController.hasAppListChanged(appsWithNoBypassingDndNotificationChannels, mPreferenceCategory)) {
mPreferenceCategory.removeAll();
for (Preference prefToAdd : appsWithNoBypassingDndNotificationChannels) {
mPreferenceCategory.addPreference(prefToAdd);
}
}
}
Aggregations