Search in sources :

Example 21 with PreferenceViewHolder

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

the class DataUsageSummaryPreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
    if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
        bar.setVisibility(View.VISIBLE);
        holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
        bar.setProgress((int) (mProgress * 100));
        ((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel);
        ((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel);
    } else {
        bar.setVisibility(View.GONE);
        holder.findViewById(R.id.label_bar).setVisibility(View.GONE);
    }
    updateDataUsageLabels(holder);
    TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
    TextView carrierInfo = (TextView) holder.findViewById(R.id.carrier_and_update);
    Button launchButton = (Button) holder.findViewById(R.id.launch_mdp_app_button);
    TextView limitInfo = (TextView) holder.findViewById(R.id.data_limits);
    if (mWifiMode && mSingleWifi) {
        updateCycleTimeText(holder);
        usageTitle.setVisibility(View.GONE);
        launchButton.setVisibility(View.GONE);
        carrierInfo.setVisibility(View.GONE);
        limitInfo.setVisibility(TextUtils.isEmpty(mLimitInfoText) ? View.GONE : View.VISIBLE);
        limitInfo.setText(mLimitInfoText);
    } else if (mWifiMode) {
        usageTitle.setText(R.string.data_usage_wifi_title);
        usageTitle.setVisibility(View.VISIBLE);
        TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
        cycleTime.setText(mUsagePeriod);
        carrierInfo.setVisibility(View.GONE);
        limitInfo.setVisibility(View.GONE);
        final long usageLevel = getHistoricalUsageLevel();
        if (usageLevel > 0L) {
            launchButton.setOnClickListener((view) -> {
                launchWifiDataUsage(getContext());
            });
        } else {
            launchButton.setEnabled(false);
        }
        launchButton.setText(R.string.launch_wifi_text);
        launchButton.setVisibility(View.VISIBLE);
    } else {
        usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
        updateCycleTimeText(holder);
        updateCarrierInfo(carrierInfo);
        if (mLaunchIntent != null) {
            launchButton.setOnClickListener((view) -> {
                getContext().startActivity(mLaunchIntent);
            });
            launchButton.setVisibility(View.VISIBLE);
        } else {
            launchButton.setVisibility(View.GONE);
        }
        limitInfo.setVisibility(TextUtils.isEmpty(mLimitInfoText) ? View.GONE : View.VISIBLE);
        limitInfo.setText(mLimitInfoText);
    }
}
Also used : Typeface(android.graphics.Typeface) Context(android.content.Context) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) Spannable(android.text.Spannable) Intent(android.content.Intent) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan) AttributeSet(android.util.AttributeSet) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) StringUtil(com.android.settingslib.utils.StringUtil) View(android.view.View) Button(android.widget.Button) Formatter(android.text.format.Formatter) R(com.android.settings.R) ConnectivityManager(android.net.ConnectivityManager) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) SpannableString(android.text.SpannableString) Utils(com.android.settingslib.Utils) SettingsEnums(android.app.settings.SettingsEnums) TextUtils(android.text.TextUtils) DataUsageController(com.android.settingslib.net.DataUsageController) Preference(androidx.preference.Preference) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) TextView(android.widget.TextView) AttrRes(android.annotation.AttrRes) VisibleForTesting(androidx.annotation.VisibleForTesting) NetworkTemplate(android.net.NetworkTemplate) Button(android.widget.Button) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar)

Example 22 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project Signal-Android by signalapp.

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 23 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project MTweaks-KernelAdiutorMOD by morogoku.

the class SettingsFragment method onCreateAdapter.

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

        @SuppressLint("RestrictedApi")
        @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 : Preference(androidx.preference.Preference) PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceGroupAdapter(androidx.preference.PreferenceGroupAdapter) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) BorderCircleView(com.moro.mtweaks.views.BorderCircleView)

Example 24 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class ConversationPriorityPreferenceTest method onClick_changesUICallsListener.

@Test
public void onClick_changesUICallsListener() {
    final ConversationPriorityPreference preference = spy(new ConversationPriorityPreference(mContext));
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(preference.getLayoutResource(), null));
    preference.setConfigurable(true);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.setPriorityConversation(true);
    preference.setOriginalImportance(IMPORTANCE_DEFAULT);
    preference.onBindViewHolder(holder);
    View silenceButton = holder.itemView.findViewById(R.id.silence);
    silenceButton.callOnClick();
    verify(preference, times(1)).callChangeListener(new Pair(IMPORTANCE_LOW, false));
}
Also used : LayoutInflater(android.view.LayoutInflater) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) TextView(android.widget.TextView) View(android.view.View) Pair(android.util.Pair) Test(org.junit.Test)

Example 25 with PreferenceViewHolder

use of androidx.preference.PreferenceViewHolder in project android_packages_apps_Settings by omnirom.

the class RecentConversationsPreferenceControllerTest method testRemoveConversation.

@Test
public void testRemoveConversation() throws Exception {
    ShortcutInfo si = mock(ShortcutInfo.class);
    when(si.getId()).thenReturn("person");
    when(si.getPackage()).thenReturn("pkg");
    ConversationChannel ccw = new ConversationChannel(si, 6, new NotificationChannel("hi", "channel", 4), new NotificationChannelGroup("hi", "group"), 7, false);
    RecentConversationPreference pref = (RecentConversationPreference) mController.createConversationPref(new PreferenceCategory(mContext), ccw, 100);
    final View view = View.inflate(mContext, pref.getLayoutResource(), null);
    PreferenceViewHolder holder = spy(PreferenceViewHolder.createInstanceForTests(view));
    View delete = View.inflate(mContext, pref.getSecondTargetResId(), null);
    when(holder.findViewById(pref.getClearId())).thenReturn(delete);
    pref.onBindViewHolder(holder);
    pref.getClearView().performClick();
    verify(mPs).removeRecentConversation(si.getPackage(), UserHandle.getUserId(ccw.getUid()), si.getId());
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationChannelGroup(android.app.NotificationChannelGroup) ShortcutInfo(android.content.pm.ShortcutInfo) ConversationChannel(android.app.people.ConversationChannel) PreferenceCategory(androidx.preference.PreferenceCategory) View(android.view.View) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

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