Search in sources :

Example 46 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by omnirom.

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

Example 47 with LayoutPreference

use of com.android.settings.applications.LayoutPreference in project android_packages_apps_Settings by omnirom.

the class EntityHeaderControllerTest method testBuildView_withContext_shouldBuildPreference.

@Test
public void testBuildView_withContext_shouldBuildPreference() {
    mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
    Preference preference = mController.done(mActivity, mShadowContext);
    assertThat(preference instanceof LayoutPreference).isTrue();
}
Also used : LayoutPreference(com.android.settings.applications.LayoutPreference) LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference) Test(org.junit.Test)

Example 48 with LayoutPreference

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);
}
Also used : Context(android.content.Context) LayoutPreference(com.android.settings.applications.LayoutPreference) OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) BatterySipper(com.android.internal.os.BatterySipper) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) LayoutPreference(com.android.settings.applications.LayoutPreference) Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle)

Example 49 with LayoutPreference

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

Example 50 with LayoutPreference

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);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) LayoutPreference(com.android.settings.applications.LayoutPreference) Switch(android.widget.Switch) View(android.view.View)

Aggregations

LayoutPreference (com.android.settings.applications.LayoutPreference)85 Button (android.widget.Button)18 View (android.view.View)12 Switch (android.widget.Switch)12 SwitchBar (com.android.settings.widget.SwitchBar)12 Before (org.junit.Before)12 Preference (android.support.v7.preference.Preference)7 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)6 Test (org.junit.Test)6 Context (android.content.Context)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Bundle (android.os.Bundle)1 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)1 BatterySipper (com.android.internal.os.BatterySipper)1