use of androidx.preference.PreferenceFragmentCompat in project AntennaPod by AntennaPod.
the class PreferenceActivity method openScreen.
public PreferenceFragmentCompat openScreen(int screen) {
PreferenceFragmentCompat fragment = getPreferenceScreen(screen);
if (screen == R.xml.preferences_notifications && Build.VERSION.SDK_INT >= 26) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
startActivity(intent);
} else {
getSupportFragmentManager().beginTransaction().replace(R.id.settingsContainer, fragment).addToBackStack(getString(getTitleOfPage(screen))).commit();
}
return fragment;
}
use of androidx.preference.PreferenceFragmentCompat in project Gadgetbridge by Freeyourgadget.
the class DeviceSettingsActivity method onPreferenceStartScreen.
@Override
public boolean onPreferenceStartScreen(PreferenceFragmentCompat caller, PreferenceScreen preferenceScreen) {
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
int[] supportedSettings = coordinator.getSupportedDeviceSpecificSettings(device);
String[] supportedLanguages = coordinator.getSupportedLanguageSettings(device);
if (supportedLanguages != null) {
supportedSettings = ArrayUtils.insert(0, supportedSettings, R.xml.devicesettings_language_generic);
}
if (coordinator.supportsActivityTracking()) {
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_chartstabs);
supportedSettings = ArrayUtils.addAll(supportedSettings, R.xml.devicesettings_device_card_activity_card_preferences);
}
final DeviceSpecificSettingsCustomizer deviceSpecificSettingsCustomizer = coordinator.getDeviceSpecificSettingsCustomizer(device);
PreferenceFragmentCompat fragment = DeviceSpecificSettingsFragment.newInstance(device.getAddress(), supportedSettings, supportedLanguages, deviceSpecificSettingsCustomizer);
Bundle args = fragment.getArguments();
args.putString(PreferenceFragmentCompat.ARG_PREFERENCE_ROOT, preferenceScreen.getKey());
fragment.setArguments(args);
getSupportFragmentManager().beginTransaction().replace(R.id.settings_container, fragment, preferenceScreen.getKey()).addToBackStack(preferenceScreen.getKey()).commit();
return true;
}
use of androidx.preference.PreferenceFragmentCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiDetailPreferenceController method setupEntityHeader.
private void setupEntityHeader(PreferenceScreen screen) {
LayoutPreference headerPref = screen.findPreference(KEY_HEADER);
if (usingDataUsageHeader(mContext)) {
headerPref.setVisible(false);
mDataUsageSummaryPref = screen.findPreference(KEY_DATA_USAGE_HEADER);
mDataUsageSummaryPref.setVisible(true);
mSummaryHeaderController = new WifiDataUsageSummaryPreferenceController(mFragment.getActivity(), mLifecycle, (PreferenceFragmentCompat) mFragment, mAccessPoint.getSsid());
return;
}
mEntityHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment, headerPref.findViewById(R.id.entity_header));
ImageView iconView = headerPref.findViewById(R.id.entity_header_icon);
iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mEntityHeaderController.setLabel(mAccessPoint.getTitle());
}
use of androidx.preference.PreferenceFragmentCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SeekBarPreferenceTest method isSelectable_selectableInXml_returnTrue.
@Test
@Config(qualifiers = "mcc999")
public void isSelectable_selectableInXml_returnTrue() {
final PreferenceFragmentCompat fragment = FragmentController.of(new TestFragment(), new Bundle()).create().start().resume().get();
final SeekBarPreference seekBarPreference = fragment.findPreference("seek_bar");
assertThat(seekBarPreference.isSelectable()).isTrue();
}
use of androidx.preference.PreferenceFragmentCompat in project collect by opendatakit.
the class ServerPreferencesAdderTest method whenAPreferenceHasAnIncorrectType_returnsFalse_andShowsToastError.
@Test
public void whenAPreferenceHasAnIncorrectType_returnsFalse_andShowsToastError() {
FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
PreferenceFragmentCompat fragment = mock(PreferenceFragmentCompat.class);
doThrow(ClassCastException.class).when(fragment).addPreferencesFromResource(R.xml.odk_server_preferences);
when(fragment.getActivity()).thenReturn(activity);
ServerPreferencesAdder loader = new ServerPreferencesAdder(fragment);
boolean result = loader.add();
assertFalse(result);
String toastText = ShadowToast.getTextOfLatestToast();
assertEquals(toastText, getString(R.string.corrupt_imported_preferences_error));
}
Aggregations