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