Search in sources :

Example 6 with Preference

use of androidx.preference.Preference 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 7 with Preference

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

the class WifiNetworkListFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.wifi_dpp_network_list);
    mAccessPointsPreferenceCategory = (PreferenceCategory) findPreference(PREF_KEY_ACCESS_POINTS);
    mFakeNetworkPreference = new Preference(getPrefContext());
    mFakeNetworkPreference.setIcon(R.drawable.ic_wifi_signal_0);
    mFakeNetworkPreference.setKey("fake_key");
    mFakeNetworkPreference.setTitle("fake network");
    mAddPreference = new Preference(getPrefContext());
    mAddPreference.setIcon(R.drawable.ic_add_24dp);
    mAddPreference.setTitle(R.string.wifi_add_network);
    mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(androidx.preference.Preference) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference)

Example 8 with Preference

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

the class AppStorageSizesControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mAppPreference = new Preference(mContext);
    mCachePreference = new Preference(mContext);
    mDataPreference = new Preference(mContext);
    mTotalPreference = new Preference(mContext);
    mController = new AppStorageSizesController.Builder().setAppSizePreference(mAppPreference).setCacheSizePreference(mCachePreference).setDataSizePreference(mDataPreference).setTotalSizePreference(mTotalPreference).setErrorString(R.string.invalid_size_value).setComputingString(R.string.computing_size).build();
}
Also used : Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 9 with Preference

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

the class AccountSyncPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mActivity = Robolectric.setupActivity(Activity.class);
    ShadowApplication.getInstance().setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
    when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(new AuthenticatorDescription[0]);
    when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
    mPreference = new Preference(mActivity);
    mPreference.setKey("account_sync");
    mController = new AccountSyncPreferenceController(mActivity);
    mController.init(new Account("acct1", "type1"), new UserHandle(3));
}
Also used : Account(android.accounts.Account) Preference(androidx.preference.Preference) UserHandle(android.os.UserHandle) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) Before(org.junit.Before)

Example 10 with Preference

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

the class AppDataUsagePreferenceControllerTest method updateState_shouldUpdatePreferenceSummary.

@Test
public void updateState_shouldUpdatePreferenceSummary() {
    final Preference preference = mock(Preference.class);
    mController.updateState(preference);
    verify(preference).setSummary(any());
}
Also used : Preference(androidx.preference.Preference) Test(org.junit.Test)

Aggregations

Preference (androidx.preference.Preference)860 Test (org.junit.Test)343 Before (org.junit.Before)164 Intent (android.content.Intent)81 PreferenceScreen (androidx.preference.PreferenceScreen)81 NotificationChannel (android.app.NotificationChannel)77 SwitchPreference (androidx.preference.SwitchPreference)75 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)69 Context (android.content.Context)60 ArrayList (java.util.ArrayList)50 NotificationBackend (com.android.settings.notification.NotificationBackend)45 ListPreference (androidx.preference.ListPreference)41 Tile (com.android.settingslib.drawer.Tile)40 PreferenceCategory (androidx.preference.PreferenceCategory)39 PreferenceManager (androidx.preference.PreferenceManager)39 Activity (android.app.Activity)27 UserHandle (android.os.UserHandle)27 FooterPreference (com.android.settingslib.widget.FooterPreference)27 PackageManager (android.content.pm.PackageManager)26 Bundle (android.os.Bundle)24