Search in sources :

Example 11 with OnPreferenceClickListener

use of android.support.v7.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InstalledAppDetails method addDynamicPrefs.

private void addDynamicPrefs() {
    if (Utils.isManagedProfile(UserManager.get(getContext()))) {
        return;
    }
    final PreferenceScreen screen = getPreferenceScreen();
    if (DefaultHomePreference.hasHomePreference(mPackageName, getContext())) {
        screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_home", R.string.home_app, R.string.configure_apps));
    }
    if (DefaultBrowserPreference.hasBrowserPreference(mPackageName, getContext())) {
        screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_browser", R.string.default_browser_title, R.string.configure_apps));
    }
    if (DefaultPhonePreference.hasPhonePreference(mPackageName, getContext())) {
        screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_phone_app", R.string.default_phone_title, R.string.configure_apps));
    }
    if (DefaultEmergencyPreference.hasEmergencyPreference(mPackageName, getContext())) {
        screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_emergency_app", R.string.default_emergency_app, R.string.configure_apps));
    }
    if (DefaultSmsPreference.hasSmsPreference(mPackageName, getContext())) {
        screen.addPreference(new ShortcutPreference(getPrefContext(), AdvancedAppSettings.class, "default_sms_app", R.string.sms_application_title, R.string.configure_apps));
    }
    boolean hasDrawOverOtherApps = hasPermission(permission.SYSTEM_ALERT_WINDOW);
    boolean hasWriteSettings = hasPermission(permission.WRITE_SETTINGS);
    if (hasDrawOverOtherApps || hasWriteSettings) {
        PreferenceCategory category = new PreferenceCategory(getPrefContext());
        category.setTitle(R.string.advanced_apps);
        screen.addPreference(category);
        if (hasDrawOverOtherApps) {
            Preference pref = new Preference(getPrefContext());
            pref.setTitle(R.string.draw_overlay);
            pref.setKey("system_alert_window");
            pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    startAppInfoFragment(DrawOverlayDetails.class, getString(R.string.draw_overlay));
                    return true;
                }
            });
            category.addPreference(pref);
        }
        if (hasWriteSettings) {
            Preference pref = new Preference(getPrefContext());
            pref.setTitle(R.string.write_settings);
            pref.setKey("write_settings_apps");
            pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                @Override
                public boolean onPreferenceClick(Preference preference) {
                    startAppInfoFragment(WriteSettingsDetails.class, getString(R.string.write_settings));
                    return true;
                }
            });
            category.addPreference(pref);
        }
    }
    addAppInstallerInfoPref(screen);
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) Preference(android.support.v7.preference.Preference)

Example 12 with OnPreferenceClickListener

use of android.support.v7.preference.Preference.OnPreferenceClickListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ZenModeAutomationSettings method updateControls.

private void updateControls() {
    final PreferenceScreen root = getPreferenceScreen();
    root.removeAll();
    final Map.Entry<String, AutomaticZenRule>[] sortedRules = sortedRules();
    for (Map.Entry<String, AutomaticZenRule> sortedRule : sortedRules) {
        ZenRulePreference pref = new ZenRulePreference(getPrefContext(), sortedRule);
        if (pref.appExists) {
            root.addPreference(pref);
        }
    }
    final Preference p = new Preference(getPrefContext());
    p.setIcon(R.drawable.ic_add);
    p.setTitle(R.string.zen_mode_add_rule);
    p.setPersistent(false);
    p.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            MetricsLogger.action(mContext, MetricsEvent.ACTION_ZEN_ADD_RULE);
            showAddRuleDialog();
            return true;
        }
    });
    root.addPreference(p);
}
Also used : OnPreferenceClickListener(android.support.v7.preference.Preference.OnPreferenceClickListener) AutomaticZenRule(android.app.AutomaticZenRule) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) Map(java.util.Map)

Example 13 with OnPreferenceClickListener

use of android.support.v7.preference.Preference.OnPreferenceClickListener 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)

Aggregations

Preference (android.support.v7.preference.Preference)12 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)10 Intent (android.content.Intent)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)5 Context (android.content.Context)3 SwitchPreference (android.support.v14.preference.SwitchPreference)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)2 Uri (android.net.Uri)2 Bundle (android.os.Bundle)2 ListPreference (android.support.v7.preference.ListPreference)2 View (android.view.View)2 LayoutPreference (com.android.settings.applications.LayoutPreference)2 Activity (android.app.Activity)1 AutomaticZenRule (android.app.AutomaticZenRule)1 Fragment (android.app.Fragment)1 FragmentManager (android.app.FragmentManager)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 ResolveInfo (android.content.pm.ResolveInfo)1 Fingerprint (android.hardware.fingerprint.Fingerprint)1