use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChangeScreenLockPreferenceControllerTest method mockGearPreferenceAndViewHolder.
private void mockGearPreferenceAndViewHolder() {
mGearPreference = new GearPreference(mContext, null);
mGearView = new View(mContext);
PreferenceViewHolder viewHolder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(mGearPreference.getLayoutResource(), null, false));
mPreferenceViewHolder = spy(viewHolder);
doReturn(mGearView).when(mPreferenceViewHolder).findViewById(R.id.settings_button);
when(mPreferenceScreen.findPreference(anyString())).thenReturn(mGearPreference);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ImportancePreferenceTest method setImportanceSummary.
@Test
public void setImportanceSummary() {
final ImportancePreference preference = spy(new ImportancePreference(mContext));
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
TextView tv = holder.itemView.findViewById(R.id.silence_summary);
preference.setDisplayInStatusBar(true);
preference.setDisplayOnLockscreen(true);
preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
assertThat(tv.getText()).isEqualTo(mContext.getString(R.string.notification_channel_summary_low));
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ImportancePreferenceTest method onClick_changesUICallsListener.
@Test
public void onClick_changesUICallsListener() {
final ImportancePreference preference = spy(new ImportancePreference(mContext));
final LayoutInflater inflater = LayoutInflater.from(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
Drawable unselected = mock(Drawable.class);
Drawable selected = mock(Drawable.class);
preference.selectedBackground = selected;
preference.unselectedBackground = unselected;
preference.setConfigurable(true);
preference.setImportance(IMPORTANCE_DEFAULT);
preference.onBindViewHolder(holder);
View silenceButton = holder.itemView.findViewById(R.id.silence);
silenceButton.callOnClick();
assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenCustomRadioButtonPreferenceTest method clickRadioButton_shouldNotifyRadioButtonClicked.
@Test
public void clickRadioButton_shouldNotifyRadioButtonClicked() {
final ZenCustomRadioButtonPreference preference = new ZenCustomRadioButtonPreference(mContext);
final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(LayoutInflater.from(mContext).inflate(R.layout.preference_two_target_radio, null));
final View toggle = holder.findViewById(R.id.checkbox_frame);
ZenCustomRadioButtonPreference.OnRadioButtonClickListener l = mock(ZenCustomRadioButtonPreference.OnRadioButtonClickListener.class);
preference.setOnRadioButtonClickListener(l);
preference.onBindViewHolder(holder);
toggle.performClick();
verify(l).onRadioButtonClick(preference);
}
use of androidx.preference.PreferenceViewHolder in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ToggleBackupSettingFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
setPreferenceScreen(preferenceScreen);
mSummaryPreference = new Preference(getPrefContext()) {
@Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
summaryView.setText(getSummary());
}
};
mSummaryPreference.setPersistent(false);
mSummaryPreference.setLayoutResource(R.layout.text_description_preference);
preferenceScreen.addPreference(mSummaryPreference);
}
Aggregations