use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceAdminListPreferenceController method refreshUI.
private void refreshUI() {
if (mPreferenceGroup == null) {
return;
}
if (mFooterPreferenceMixin != null) {
final FooterPreference footer = mFooterPreferenceMixin.createFooterPreference();
footer.setTitle(R.string.no_device_admins);
footer.setVisible(mAdmins.isEmpty());
}
final Map<String, FilterTouchesSwitchPreference> preferenceCache = new ArrayMap<>();
final Context prefContext = mPreferenceGroup.getContext();
final int childrenCount = mPreferenceGroup.getPreferenceCount();
for (int i = 0; i < childrenCount; i++) {
final Preference pref = mPreferenceGroup.getPreference(i);
if (!(pref instanceof FilterTouchesSwitchPreference)) {
continue;
}
final FilterTouchesSwitchPreference appSwitch = (FilterTouchesSwitchPreference) pref;
preferenceCache.put(appSwitch.getKey(), appSwitch);
}
for (DeviceAdminListItem item : mAdmins) {
final String key = item.getKey();
FilterTouchesSwitchPreference pref = preferenceCache.remove(key);
if (pref == null) {
pref = new FilterTouchesSwitchPreference(prefContext);
mPreferenceGroup.addPreference(pref);
}
bindPreference(item, pref);
}
for (FilterTouchesSwitchPreference unusedCacheItem : preferenceCache.values()) {
mPreferenceGroup.removePreference(unusedCacheItem);
}
}
use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PremiumSmsAccess method updatePrefs.
private void updatePrefs(ArrayList<AppEntry> apps) {
if (apps == null)
return;
setEmptyText(R.string.premium_sms_none);
setLoading(false, true);
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
screen.setOrderingAsAdded(true);
for (int i = 0; i < apps.size(); i++) {
final PremiumSmsPreference smsPreference = new PremiumSmsPreference(apps.get(i), getPrefContext());
smsPreference.setOnPreferenceChangeListener(this);
screen.addPreference(smsPreference);
}
if (apps.size() != 0) {
FooterPreference footer = new FooterPreference(getPrefContext());
footer.setTitle(R.string.premium_sms_warning);
screen.addPreference(footer);
}
}
use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsMacAddressControllerTest method macAddress.
@Test
public void macAddress() {
showScreen(mController);
FooterPreference footer = (FooterPreference) mScreen.findPreference(mController.getPreferenceKey());
assertThat(footer.getTitle().toString()).endsWith(mDeviceConfig.getAddress());
}
use of com.android.settingslib.widget.FooterPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class EnterpriseDisclosurePreferenceController method addEnterpriseDisclosure.
private void addEnterpriseDisclosure() {
final CharSequence disclosure = getDisclosure();
if (disclosure == null) {
return;
}
final FooterPreference enterpriseDisclosurePreference = mFooterPreferenceMixin.createFooterPreference();
enterpriseDisclosurePreference.setSelectable(false);
enterpriseDisclosurePreference.setTitle(disclosure);
mScreen.addPreference(enterpriseDisclosurePreference);
}
use of com.android.settingslib.widget.FooterPreference in project android_packages_apps_Settings by omnirom.
the class AdvancedPowerUsageDetailTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getPackageName()).thenReturn("foo");
mFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
mFragment = spy(new AdvancedPowerUsageDetail());
doReturn(mContext).when(mFragment).getContext();
doReturn(mActivity).when(mFragment).getActivity();
doReturn(SUMMARY).when(mFragment).getString(anyInt());
doReturn(APP_LABEL).when(mBundle).getString(nullable(String.class));
when(mFragment.getArguments()).thenReturn(mBundle);
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
when(mFeatureFactory.powerUsageFeatureProvider.isChartGraphEnabled(mContext)).thenReturn(true);
ShadowEntityHeaderController.setUseMock(mEntityHeaderController);
doReturn(mEntityHeaderController).when(mEntityHeaderController).setRecyclerView(nullable(RecyclerView.class), nullable(Lifecycle.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setButtonActions(anyInt(), anyInt());
doReturn(mEntityHeaderController).when(mEntityHeaderController).setIcon(nullable(Drawable.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setIcon(nullable(ApplicationsState.AppEntry.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(String.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(String.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setLabel(nullable(ApplicationsState.AppEntry.class));
doReturn(mEntityHeaderController).when(mEntityHeaderController).setSummary(nullable(String.class));
when(mBatteryEntry.getUid()).thenReturn(UID);
when(mBatteryEntry.getLabel()).thenReturn(APP_LABEL);
when(mBatteryEntry.getTimeInBackgroundMs()).thenReturn(BACKGROUND_TIME_MS);
when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(FOREGROUND_TIME_MS);
mBatteryEntry.iconId = ICON_ID;
mFragment.mHeaderPreference = mHeaderPreference;
mFragment.mState = mState;
mFragment.enableTriState = true;
mFragment.mBatteryUtils = new BatteryUtils(RuntimeEnvironment.application);
mFragment.mBatteryOptimizeUtils = mBatteryOptimizeUtils;
mAppEntry.info = mock(ApplicationInfo.class);
mTestActivity = spy(new SettingsActivity());
doReturn(mPackageManager).when(mTestActivity).getPackageManager();
doReturn(mPackageManager).when(mActivity).getPackageManager();
doReturn(mAppOpsManager).when(mTestActivity).getSystemService(Context.APP_OPS_SERVICE);
mBatteryUtils = spy(new BatteryUtils(mContext));
doReturn(FOREGROUND_SERVICE_TIME_US).when(mBatteryUtils).getForegroundServiceTotalTimeUs(any(BatteryStats.Uid.class), anyLong());
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
Answer<Void> callable = invocation -> {
mBundle = captor.getValue().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
System.out.println("mBundle = " + mBundle);
return null;
};
doAnswer(callable).when(mActivity).startActivityAsUser(captor.capture(), nullable(UserHandle.class));
doAnswer(callable).when(mActivity).startActivity(captor.capture());
mForegroundPreference = new Preference(mContext);
mBackgroundPreference = new Preference(mContext);
mFooterPreference = new FooterPreference(mContext);
mRestrictedPreference = new RadioButtonPreference(mContext);
mOptimizePreference = new RadioButtonPreference(mContext);
mUnrestrictedPreference = new RadioButtonPreference(mContext);
mFragment.mForegroundPreference = mForegroundPreference;
mFragment.mBackgroundPreference = mBackgroundPreference;
mFragment.mFooterPreference = mFooterPreference;
mFragment.mRestrictedPreference = mRestrictedPreference;
mFragment.mOptimizePreference = mOptimizePreference;
mFragment.mUnrestrictedPreference = mUnrestrictedPreference;
}
Aggregations