use of com.android.settingslib.widget.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageSummary method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setAnimationAllowed(true);
initFeatureProvider();
mBatteryLayoutPref = (LayoutPreference) findPreference(KEY_BATTERY_HEADER);
mBatteryLevel = getContext().getResources().getInteger(com.android.internal.R.integer.config_criticalBatteryWarningLevel) + 1;
mScreenUsagePref = (PowerGaugePreference) findPreference(KEY_SCREEN_USAGE);
mBatteryTempPref = (PowerGaugePreference) findPreference(KEY_BATTERY_TEMP);
mCurrentBatteryCapacity = (PowerGaugePreference) findPreference(KEY_CURRENT_BATTERY_CAPACITY);
mDesignedBatteryCapacity = (PowerGaugePreference) findPreference(KEY_DESIGNED_BATTERY_CAPACITY);
mBatteryChargeCycles = (PowerGaugePreference) findPreference(KEY_BATTERY_CHARGE_CYCLES);
mLastFullChargePref = (PowerGaugePreference) findPreference(KEY_TIME_SINCE_LAST_FULL_CHARGE);
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.battery_footer_summary);
mBatteryUtils = BatteryUtils.getInstance(getContext());
restartBatteryInfoLoader();
mBatteryTipPreferenceController.restoreInstanceState(icicle);
updateBatteryTipFlag(icicle);
// Check availability of Battery Health
Preference mDesignedHealthPref = (Preference) findPreference(KEY_DESIGNED_BATTERY_CAPACITY);
if (!getResources().getBoolean(R.bool.config_supportBatteryHealth)) {
getPreferenceScreen().removePreference(mDesignedHealthPref);
}
Preference mCurrentHealthPref = (Preference) findPreference(KEY_CURRENT_BATTERY_CAPACITY);
if (!getResources().getBoolean(R.bool.config_supportBatteryHealth)) {
getPreferenceScreen().removePreference(mCurrentHealthPref);
}
Preference mCyclesHealthPref = (Preference) findPreference(KEY_BATTERY_CHARGE_CYCLES);
if (!getResources().getBoolean(R.bool.config_supportBatteryHealth)) {
getPreferenceScreen().removePreference(mCyclesHealthPref);
}
}
use of com.android.settingslib.widget.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class EntityHeaderController method done.
/**
* Done mutating entity header, rebinds everything and return a new {@link LayoutPreference}.
*/
public LayoutPreference done(Activity activity, Context uiContext) {
final LayoutPreference pref = new LayoutPreference(uiContext, done(activity));
// Makes sure it's the first preference onscreen.
pref.setOrder(-1000);
pref.setSelectable(false);
pref.setKey(PREF_KEY_APP_HEADER);
pref.setAllowDividerBelow(true);
return pref;
}
use of com.android.settingslib.widget.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDetailsHeaderControllerTest method setUp.
@Override
public void setUp() {
super.setUp();
FakeFeatureFactory.setupForTest();
ShadowEntityHeaderController.setUseMock(mHeaderController);
when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mCachedDeviceManager.getSubDeviceSummary(mCachedDevice)).thenReturn("abc");
mController = new BluetoothDetailsHeaderController(mContext, mFragment, mCachedDevice, mLifecycle, mBluetoothManager);
mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
mPreference.setKey(mController.getPreferenceKey());
mScreen.addPreference(mPreference);
setupDevice(mDeviceConfig);
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
}
use of com.android.settingslib.widget.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MyDeviceInfoFragment method initHeader.
private void initHeader() {
// TODO: Migrate into its own controller.
final LayoutPreference headerPreference = getPreferenceScreen().findPreference(KEY_MY_DEVICE_INFO_HEADER);
final boolean shouldDisplayHeader = getContext().getResources().getBoolean(R.bool.config_show_device_header_in_device_info);
headerPreference.setVisible(shouldDisplayHeader);
if (!shouldDisplayHeader) {
return;
}
final View headerView = headerPreference.findViewById(R.id.entity_header);
final Activity context = getActivity();
final Bundle bundle = getArguments();
final EntityHeaderController controller = EntityHeaderController.newInstance(context, this, headerView).setRecyclerView(getListView(), getSettingsLifecycle()).setButtonActions(EntityHeaderController.ActionType.ACTION_NONE, EntityHeaderController.ActionType.ACTION_NONE);
// TODO: There may be an avatar setting action we can use here.
final int iconId = bundle.getInt("icon_id", 0);
if (iconId == 0) {
final UserManager userManager = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
final UserInfo info = Utils.getExistingUser(userManager, android.os.Process.myUserHandle());
controller.setLabel(info.name);
controller.setIcon(com.android.settingslib.Utils.getUserIcon(getActivity(), userManager, info));
}
controller.done(context, true);
}
use of com.android.settingslib.widget.LayoutPreference in project android_packages_apps_Settings by omnirom.
the class EntityHeaderController method done.
/**
* Done mutating entity header, rebinds everything and return a new {@link LayoutPreference}.
*/
public LayoutPreference done(Activity activity, Context uiContext) {
final LayoutPreference pref = new LayoutPreference(uiContext, done(activity));
// Makes sure it's the first preference onscreen.
pref.setOrder(-1000);
pref.setSelectable(false);
pref.setKey(PREF_KEY_APP_HEADER);
pref.setAllowDividerBelow(true);
return pref;
}
Aggregations