Search in sources :

Example 1 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Signal-Android by WhisperSystems.

the class CorrectedPreferenceFragment method onCreateAdapter.

@Override
@SuppressLint("RestrictedApi")
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {

        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory) {
                setZeroPaddingToLayoutChildren(holder.itemView);
            } else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
Also used : ColorPickerPreference(org.thoughtcrime.securesms.preferences.widgets.ColorPickerPreference) Preference(androidx.preference.Preference) CustomDefaultPreference(org.thoughtcrime.securesms.components.CustomDefaultPreference) PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceGroupAdapter(androidx.preference.PreferenceGroupAdapter) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint)

Example 2 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DisabledSubscriptionControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    LifecycleOwner lifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(lifecycleOwner);
    doReturn(mSubscriptionManager).when(mContext).getSystemService(SubscriptionManager.class);
    mCategory = new PreferenceCategory(mContext);
    doReturn(mCategory).when(mScreen).findPreference(KEY);
    mController = new DisabledSubscriptionController(mContext, KEY);
    mController.init(mLifecycle, SUB_ID);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) LifecycleOwner(androidx.lifecycle.LifecycleOwner) Before(org.junit.Before)

Example 3 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsPreferenceFragmentTest method removePreference_nested_shouldRemove.

@Test
public void removePreference_nested_shouldRemove() {
    final String key = "test_key";
    final PreferenceScreen mScreen = spy(new PreferenceScreen(mContext, null));
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    final PreferenceCategory nestedCategory = new ProgressCategory(mContext);
    final Preference preference = new Preference(mContext);
    preference.setKey(key);
    preference.setPersistent(false);
    mScreen.addPreference(nestedCategory);
    nestedCategory.addPreference(preference);
    assertThat(mFragment.removePreference(mScreen, key)).isTrue();
    assertThat(nestedCategory.getPreferenceCount()).isEqualTo(0);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) PreferenceCategory(androidx.preference.PreferenceCategory) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test)

Example 4 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsbDetailsDataRoleControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycle = new Lifecycle(() -> mLifecycle);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    mDetailsDataRoleController = new UsbDetailsDataRoleController(mContext, mFragment, mUsbBackend);
    mPreference = new PreferenceCategory(mContext);
    mPreference.setKey(mDetailsDataRoleController.getPreferenceKey());
    mScreen.addPreference(mPreference);
    mDetailsDataRoleController.mHandler = mHandler;
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 5 with PreferenceCategory

use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsbDetailsFunctionsControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mLifecycle = new Lifecycle(() -> mLifecycle);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
    mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment, mUsbBackend);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(mDetailsFunctionsController.getPreferenceKey());
    mScreen.addPreference(mPreferenceCategory);
    mDetailsFunctionsController.displayPreference(mScreen);
    mRadioButtonPreference = new RadioButtonPreference(mContext);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) RadioButtonPreference(com.android.settings.widget.RadioButtonPreference) Before(org.junit.Before)

Aggregations

PreferenceCategory (androidx.preference.PreferenceCategory)38 PreferenceScreen (androidx.preference.PreferenceScreen)14 Preference (androidx.preference.Preference)12 Before (org.junit.Before)7 PreferenceManager (androidx.preference.PreferenceManager)6 SwitchPreference (androidx.preference.SwitchPreference)6 ContentResolver (android.content.ContentResolver)5 Context (android.content.Context)5 ListPreference (androidx.preference.ListPreference)4 Resources (android.content.res.Resources)3 Bundle (android.os.Bundle)3 RestrictedPreference (com.android.settingslib.RestrictedPreference)3 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)3 ComponentName (android.content.ComponentName)2 Intent (android.content.Intent)2 ResolveInfo (android.content.pm.ResolveInfo)2 View (android.view.View)2 EditTextPreference (androidx.preference.EditTextPreference)2 PreferenceGroup (androidx.preference.PreferenceGroup)2 Test (org.junit.Test)2