Search in sources :

Example 51 with PreferenceViewHolder

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);
}
Also used : GearPreference(com.android.settings.widget.GearPreference) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder)

Example 52 with PreferenceViewHolder

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));
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 53 with PreferenceViewHolder

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);
}
Also used : LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test)

Example 54 with PreferenceViewHolder

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);
}
Also used : PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) Test(org.junit.Test)

Example 55 with PreferenceViewHolder

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);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) TextView(android.widget.TextView) PreferenceViewHolder(androidx.preference.PreferenceViewHolder)

Aggregations

PreferenceViewHolder (androidx.preference.PreferenceViewHolder)79 Test (org.junit.Test)61 View (android.view.View)33 LayoutInflater (android.view.LayoutInflater)29 LinearLayout (android.widget.LinearLayout)17 Switch (android.widget.Switch)16 TextView (android.widget.TextView)16 CheckBox (android.widget.CheckBox)14 Preference (androidx.preference.Preference)12 PreferenceCategory (androidx.preference.PreferenceCategory)7 Drawable (android.graphics.drawable.Drawable)6 ProgressBar (android.widget.ProgressBar)5 OnPreferenceChangeListener (androidx.preference.Preference.OnPreferenceChangeListener)5 ImportancePreference (com.android.settings.notification.app.ImportancePreference)5 Before (org.junit.Before)5 ImageView (android.widget.ImageView)4 Context (android.content.Context)3 Button (android.widget.Button)3 ListPreference (androidx.preference.ListPreference)3 PreferenceGroupAdapter (androidx.preference.PreferenceGroupAdapter)3