Search in sources :

Example 46 with LayoutPreference

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);
    }
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Preference(androidx.preference.Preference)

Example 47 with LayoutPreference

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;
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 48 with LayoutPreference

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);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Example 49 with LayoutPreference

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);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) EntityHeaderController(com.android.settings.widget.EntityHeaderController) Bundle(android.os.Bundle) UserManager(android.os.UserManager) Activity(android.app.Activity) UserInfo(android.content.pm.UserInfo) View(android.view.View)

Example 50 with LayoutPreference

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;
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference)

Aggregations

LayoutPreference (com.android.settingslib.widget.LayoutPreference)61 Before (org.junit.Before)10 Preference (androidx.preference.Preference)8 Activity (android.app.Activity)5 View (android.view.View)5 Button (android.widget.Button)5 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)5 Test (org.junit.Test)5 ImageView (android.widget.ImageView)3 PreferenceManager (androidx.preference.PreferenceManager)3 PreferenceScreen (androidx.preference.PreferenceScreen)3 Intent (android.content.Intent)2 UserInfo (android.content.pm.UserInfo)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 RemoteException (android.os.RemoteException)2 UserManager (android.os.UserManager)2 TextView (android.widget.TextView)2 PreferenceFragmentCompat (androidx.preference.PreferenceFragmentCompat)2 WifiDataUsageSummaryPreferenceController (com.android.settings.datausage.WifiDataUsageSummaryPreferenceController)2