use of com.android.settings.applications.LayoutPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageDetail method createDetails.
private void createDetails() {
final Bundle args = getArguments();
Context context = getActivity();
mUsageSince = args.getInt(EXTRA_USAGE_SINCE, USAGE_SINCE_UNPLUGGED);
mUid = args.getInt(EXTRA_UID, 0);
mPackages = context.getPackageManager().getPackagesForUid(mUid);
mDrainType = (BatterySipper.DrainType) args.getSerializable(EXTRA_DRAIN_TYPE);
mNoCoverage = args.getDouble(EXTRA_NO_COVERAGE, 0);
mShowLocationButton = args.getBoolean(EXTRA_SHOW_LOCATION_BUTTON);
mTypes = args.getIntArray(EXTRA_DETAIL_TYPES);
mValues = args.getDoubleArray(EXTRA_DETAIL_VALUES);
LayoutPreference twoButtons = (LayoutPreference) findPreference(KEY_TWO_BUTTONS);
mForceStopButton = (Button) twoButtons.findViewById(R.id.left_button);
mReportButton = (Button) twoButtons.findViewById(R.id.right_button);
mForceStopButton.setEnabled(false);
if (mUid >= Process.FIRST_APPLICATION_UID) {
mForceStopButton.setText(R.string.force_stop);
mForceStopButton.setTag(ACTION_FORCE_STOP);
mForceStopButton.setOnClickListener(this);
mReportButton.setText(com.android.internal.R.string.report);
mReportButton.setTag(ACTION_REPORT);
mReportButton.setOnClickListener(this);
if (mPackages != null && mPackages.length > 0) {
try {
mApp = context.getPackageManager().getApplicationInfo(mPackages[0], 0);
} catch (NameNotFoundException e) {
}
} else {
Log.d(TAG, "No packages!!");
}
// check if error reporting is enabled in secure settings
int enabled = android.provider.Settings.Global.getInt(context.getContentResolver(), android.provider.Settings.Global.SEND_ACTION_APP_ERROR, 0);
if (enabled != 0) {
if (mApp != null) {
mInstaller = ApplicationErrorReport.getErrorReportReceiver(context, mPackages[0], mApp.flags);
}
mReportButton.setEnabled(mInstaller != null);
} else {
removePreference(KEY_TWO_BUTTONS);
}
if (mApp != null && PowerWhitelistBackend.getInstance().isWhitelisted(mApp.packageName)) {
mHighPower = findPreference(KEY_HIGH_POWER);
mHighPower.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
HighPowerDetail.show(PowerUsageDetail.this, mApp.packageName, 0, false);
return true;
}
});
} else {
mControlsParent.removePreference(findPreference(KEY_HIGH_POWER));
}
} else {
removePreference(KEY_TWO_BUTTONS);
mControlsParent.removePreference(findPreference(KEY_HIGH_POWER));
}
refreshStats();
fillDetailsSection();
fillPackagesSection(mUid);
fillControlsSection(mUid);
fillMessagesSection(mUid);
}
use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by LineageOS.
the class SettingsPreferenceFragment method setHeaderView.
protected void setHeaderView(int resource) {
mHeader = new LayoutPreference(getPrefContext(), resource);
addPreferenceToTop(mHeader);
}
use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by LineageOS.
the class AppNotificationSettings method setupBlock.
protected void setupBlock() {
View switchBarContainer = LayoutInflater.from(getPrefContext()).inflate(R.layout.styled_switch_bar, null);
mSwitchBar = switchBarContainer.findViewById(R.id.switch_bar);
mSwitchBar.show();
mSwitchBar.setDisabledByAdmin(mSuspendedAppsAdmin);
mSwitchBar.setChecked(!mAppRow.banned);
mSwitchBar.addOnSwitchChangeListener(new SwitchBar.OnSwitchChangeListener() {
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
if (mShowLegacyChannelConfig && mChannel != null) {
final int importance = isChecked ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_NONE;
mImportanceToggle.setChecked(importance == IMPORTANCE_UNSPECIFIED);
mChannel.setImportance(importance);
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
mBackend.updateChannel(mPkg, mUid, mChannel);
}
mBackend.setNotificationsEnabledForPackage(mPkgInfo.packageName, mUid, isChecked);
mAppRow.banned = true;
updateDependents(!isChecked);
}
});
mBlockBar = new LayoutPreference(getPrefContext(), switchBarContainer);
mBlockBar.setOrder(ORDER_FIRST);
mBlockBar.setKey(KEY_BLOCK);
getPreferenceScreen().addPreference(mBlockBar);
if (mAppRow.systemApp && !mAppRow.banned) {
setVisible(mBlockBar, false);
}
setupBlockDesc(R.string.app_notifications_off_desc);
}
use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by LineageOS.
the class BluetoothDetailsButtonsControllerTest method setUp.
@Override
public void setUp() {
super.setUp();
mController = new BluetoothDetailsButtonsController(mContext, mFragment, mCachedDevice, mLifecycle);
mLeftButton = new Button(mContext);
mRightButton = new Button(mContext);
mLayoutPreference = new LayoutPreference(mContext, R.layout.app_action_buttons);
mLayoutPreference.setKey(mController.getPreferenceKey());
mScreen.addPreference(mLayoutPreference);
mLeftButton = (Button) mLayoutPreference.findViewById(R.id.left_button);
mRightButton = (Button) mLayoutPreference.findViewById(R.id.right_button);
setupDevice(mDeviceConfig);
when(mCachedDevice.isBusy()).thenReturn(false);
}
use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by LineageOS.
the class BluetoothDetailsHeaderControllerTest method setUp.
@Override
public void setUp() {
super.setUp();
FakeFeatureFactory.setupForTest(spy(mContext));
ShadowEntityHeaderController.setUseMock(mHeaderController);
mController = new BluetoothDetailsHeaderController(mContext, mFragment, mCachedDevice, mLifecycle);
mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
mPreference.setKey(mController.getPreferenceKey());
mScreen.addPreference(mPreference);
setupDevice(mDeviceConfig);
}
Aggregations