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);
}
}
}
};
}
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);
}
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);
}
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;
}
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);
}
Aggregations