Search in sources :

Example 1 with PreferenceFragmentCompat

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;
}
Also used : PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) Intent(android.content.Intent)

Example 2 with PreferenceFragmentCompat

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;
}
Also used : Bundle(android.os.Bundle) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) DeviceCoordinator(nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator)

Example 3 with PreferenceFragmentCompat

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());
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) WifiDataUsageSummaryPreferenceController(com.android.settings.datausage.WifiDataUsageSummaryPreferenceController) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) ImageView(android.widget.ImageView)

Example 4 with PreferenceFragmentCompat

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();
}
Also used : Bundle(android.os.Bundle) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 5 with PreferenceFragmentCompat

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));
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) Test(org.junit.Test)

Aggregations

PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)7 Test (org.junit.Test)4 Bundle (android.os.Bundle)3 Config (org.robolectric.annotation.Config)2 Intent (android.content.Intent)1 ImageView (android.widget.ImageView)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 WifiDataUsageSummaryPreferenceController (com.android.settings.datausage.WifiDataUsageSummaryPreferenceController)1 LayoutPreference (com.android.settingslib.widget.LayoutPreference)1 DeviceCoordinator (nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator)1