use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class PaymentSettingsTest method isShowEmptyImage_hasNoVisiblePreference_returnTrue.
@Test
public void isShowEmptyImage_hasNoVisiblePreference_returnTrue() {
final PaymentSettings paymentSettings = new PaymentSettings();
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
final Preference preference1 = new Preference(mContext);
preference1.setVisible(false);
screen.addPreference(preference1);
final Preference preference2 = new Preference(mContext);
screen.addPreference(preference2);
preference2.setVisible(false);
assertThat(paymentSettings.isShowEmptyImage(screen)).isTrue();
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class StorageSelectionPreferenceControllerTest method setUp.
@Before
public void setUp() throws Exception {
if (Looper.myLooper() == null) {
Looper.prepare();
}
mContext = ApplicationProvider.getApplicationContext();
mStorageManager = mContext.getSystemService(StorageManager.class);
mController = new StorageSelectionPreferenceController(mContext, PREFERENCE_KEY);
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
final PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
final SettingsSpinnerPreference spinnerPreference = new SettingsSpinnerPreference(mContext);
spinnerPreference.setKey(PREFERENCE_KEY);
preferenceScreen.addPreference(spinnerPreference);
mController.displayPreference(preferenceScreen);
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class InteractAcrossProfilesSettings method onResume.
@Override
public void onResume() {
super.onResume();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps = collectConfigurableApps(mPackageManager, mUserManager, mCrossProfileApps);
final Context prefContext = getPrefContext();
for (final Pair<ApplicationInfo, UserHandle> appData : crossProfileApps) {
final ApplicationInfo appInfo = appData.first;
final UserHandle user = appData.second;
final String packageName = appInfo.packageName;
final CharSequence label = appInfo.loadLabel(mPackageManager);
final Preference pref = new AppPreference(prefContext);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, user.getIdentifier()));
pref.setTitle(mPackageManager.getUserBadgedLabel(label, user));
pref.setSummary(InteractAcrossProfilesDetails.getPreferenceSummary(prefContext, packageName));
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AppInfoBase.startAppInfoFragment(InteractAcrossProfilesDetails.class, R.string.interact_across_profiles_title, packageName, appInfo.uid, InteractAcrossProfilesSettings.this, /* source */
-1, /* request */
getMetricsCategory());
return true;
}
});
screen.addPreference(pref);
}
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class ToggleBackupSettingFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
setPreferenceScreen(preferenceScreen);
mSummaryPreference = new Preference(getPrefContext()) {
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
summaryView.setText(getSummary());
}
};
mSummaryPreference.setPersistent(false);
mSummaryPreference.setLayoutResource(R.layout.text_description_preference);
preferenceScreen.addPreference(mSummaryPreference);
}
use of androidx.preference.PreferenceScreen in project android_packages_apps_Settings by omnirom.
the class PictureInPictureSettings method onResume.
@Override
public void onResume() {
super.onResume();
// Clear the prefs
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
// Fetch the set of applications for each profile which have at least one activity that
// declare that they support picture-in-picture
final ArrayList<Pair<ApplicationInfo, Integer>> pipApps = collectPipApps(UserHandle.myUserId());
Collections.sort(pipApps, new AppComparator(mPackageManager));
// Rebuild the list of prefs
final Context prefContext = getPrefContext();
for (final Pair<ApplicationInfo, Integer> appData : pipApps) {
final ApplicationInfo appInfo = appData.first;
final int userId = appData.second;
final UserHandle user = UserHandle.of(userId);
final String packageName = appInfo.packageName;
final CharSequence label = appInfo.loadLabel(mPackageManager);
final Preference pref = new AppPreference(prefContext);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, userId));
pref.setTitle(mPackageManager.getUserBadgedLabel(label, user));
pref.setSummary(PictureInPictureDetails.getPreferenceSummary(prefContext, appInfo.uid, packageName));
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class, R.string.picture_in_picture_app_detail_title, packageName, appInfo.uid, PictureInPictureSettings.this, -1, getMetricsCategory());
return true;
}
});
screen.addPreference(pref);
}
}
Aggregations