Search in sources :

Example 71 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DataUsagePreference method getIntent.

@Override
public Intent getIntent() {
    final Bundle args = new Bundle();
    final SubSettingLauncher launcher;
    args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
    args.putInt(DataUsageList.EXTRA_SUB_ID, mSubId);
    args.putInt(DataUsageList.EXTRA_NETWORK_TYPE, mTemplate.isMatchRuleMobile() ? ConnectivityManager.TYPE_MOBILE : ConnectivityManager.TYPE_WIFI);
    launcher = new SubSettingLauncher(getContext()).setArguments(args).setDestination(DataUsageList.class.getName()).setSourceMetricsCategory(SettingsEnums.PAGE_UNKNOWN);
    if (mTemplate.isMatchRuleMobile()) {
        launcher.setTitleRes(R.string.app_cellular_data_usage);
    } else {
        launcher.setTitleRes(mTitleRes);
    }
    return launcher.toIntent();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle)

Example 72 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RecentNotifyingAppsPreferenceController method displayRecentApps.

private void displayRecentApps(Context prefContext, List<NotifyingApp> recentApps) {
    mCategory.setTitle(R.string.recent_notifications);
    mDivider.setVisible(true);
    mSeeAllPref.setSummary(null);
    mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);
    // Rebind prefs/avoid adding new prefs if possible. Adding/removing prefs causes jank.
    // Build a cached preference pool
    final Map<String, NotificationAppPreference> appPreferences = new ArrayMap<>();
    int prefCount = mCategory.getPreferenceCount();
    for (int i = 0; i < prefCount; i++) {
        final Preference pref = mCategory.getPreference(i);
        final String key = pref.getKey();
        if (!TextUtils.equals(key, KEY_SEE_ALL)) {
            appPreferences.put(key, (NotificationAppPreference) pref);
        }
    }
    final int recentAppsCount = recentApps.size();
    for (int i = 0; i < recentAppsCount; i++) {
        final NotifyingApp app = recentApps.get(i);
        // Bind recent apps to existing prefs if possible, or create a new pref.
        final String pkgName = app.getPackage();
        final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(app.getPackage(), app.getUserId());
        if (appEntry == null) {
            continue;
        }
        boolean rebindPref = true;
        NotificationAppPreference pref = appPreferences.remove(getKey(app.getUserId(), pkgName));
        if (pref == null) {
            pref = new NotificationAppPreference(prefContext);
            rebindPref = false;
        }
        pref.setKey(getKey(app.getUserId(), pkgName));
        pref.setTitle(appEntry.label);
        pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
        pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
        pref.setSummary(StringUtil.formatRelativeTime(mContext, System.currentTimeMillis() - app.getLastNotified(), true));
        pref.setOrder(i);
        Bundle args = new Bundle();
        args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
        args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
        pref.setOnPreferenceClickListener(preference -> {
            new SubSettingLauncher(mHost.getActivity()).setDestination(AppNotificationSettings.class.getName()).setTitleRes(R.string.notifications_title).setArguments(args).setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid))).setSourceMetricsCategory(SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS).launch();
            return true;
        });
        pref.setSwitchEnabled(mNotificationBackend.isBlockable(mContext, appEntry.info));
        pref.setOnPreferenceChangeListener((preference, newValue) -> {
            boolean blocked = !(Boolean) newValue;
            mNotificationBackend.setNotificationsEnabledForPackage(pkgName, appEntry.info.uid, !blocked);
            return true;
        });
        pref.setChecked(!mNotificationBackend.getNotificationsBanned(pkgName, appEntry.info.uid));
        if (!rebindPref) {
            mCategory.addPreference(pref);
        }
    }
    // Remove unused prefs from pref cache pool
    for (Preference unusedPrefs : appPreferences.values()) {
        mCategory.removePreference(unusedPrefs);
    }
}
Also used : ApplicationsState(com.android.settingslib.applications.ApplicationsState) Bundle(android.os.Bundle) ArrayMap(android.util.ArrayMap) Preference(androidx.preference.Preference) TwoTargetPreference(com.android.settingslib.TwoTargetPreference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) UserHandle(android.os.UserHandle) NotifyingApp(android.service.notification.NotifyingApp)

Example 73 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ChannelListPreferenceController method populateSingleChannelPrefs.

protected Preference populateSingleChannelPrefs(PreferenceGroup parent, final NotificationChannel channel, final boolean groupBlocked) {
    MasterSwitchPreference channelPref = new MasterSwitchPreference(mContext);
    channelPref.setSwitchEnabled(mAdmin == null && isChannelBlockable(channel) && isChannelConfigurable(channel) && !groupBlocked);
    channelPref.setIcon(null);
    if (channel.getImportance() > IMPORTANCE_LOW) {
        channelPref.setIcon(getAlertingIcon());
    }
    channelPref.setIconSize(MasterSwitchPreference.ICON_SIZE_SMALL);
    channelPref.setKey(channel.getId());
    channelPref.setTitle(channel.getName());
    channelPref.setSummary(NotificationBackend.getSentSummary(mContext, mAppRow.sentByChannel.get(channel.getId()), false));
    channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
    Bundle channelArgs = new Bundle();
    channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
    channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
    channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
    channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
    channelPref.setIntent(new SubSettingLauncher(mContext).setDestination(ChannelNotificationSettings.class.getName()).setArguments(channelArgs).setTitleRes(R.string.notification_channel_title).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_APP_NOTIFICATION).toIntent());
    channelPref.setOnPreferenceChangeListener((preference, o) -> {
        boolean value = (Boolean) o;
        int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
        channel.setImportance(importance);
        channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
        MasterSwitchPreference channelPref1 = (MasterSwitchPreference) preference;
        channelPref1.setIcon(null);
        if (channel.getImportance() > IMPORTANCE_LOW) {
            channelPref1.setIcon(getAlertingIcon());
        }
        toggleBehaviorIconState(channelPref1.getIcon(), importance != IMPORTANCE_NONE);
        mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel);
        return true;
    });
    if (parent.findPreference(channelPref.getKey()) == null) {
        parent.addPreference(channelPref);
    }
    return channelPref;
}
Also used : MasterSwitchPreference(com.android.settings.widget.MasterSwitchPreference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle)

Example 74 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilitySettingsForSetupWizardActivity method tryLaunchFontSizeSettings.

@VisibleForTesting
void tryLaunchFontSizeSettings() {
    if (WizardManagerHelper.isAnySetupWizard(getIntent()) && new ComponentName(getPackageName(), CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(getIntent().getComponent())) {
        final Bundle args = new Bundle();
        args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
        args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
        final SubSettingLauncher subSettingLauncher = new SubSettingLauncher(this).setDestination(FontSizePreferenceFragmentForSetupWizard.class.getName()).setArguments(args).setSourceMetricsCategory(Instrumentable.METRICS_CATEGORY_UNKNOWN).setExtras(SetupWizardUtils.copyLifecycleExtra(getIntent().getExtras(), new Bundle()));
        Log.d(LOG_TAG, "Launch font size settings");
        subSettingLauncher.launch();
        finish();
    }
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) ComponentName(android.content.ComponentName) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 75 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class OpenBatterySaverAction method handlePositiveAction.

/**
 * Handle the action when user clicks positive button
 */
@Override
public void handlePositiveAction(int metricsKey) {
    mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_TIP_OPEN_BATTERY_SAVER_PAGE, metricsKey);
    new SubSettingLauncher(mContext).setDestination(BatterySaverSettings.class.getName()).setSourceMetricsCategory(metricsKey).launch();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) BatterySaverSettings(com.android.settings.fuelgauge.batterysaver.BatterySaverSettings)

Aggregations

SubSettingLauncher (com.android.settings.core.SubSettingLauncher)135 Bundle (android.os.Bundle)116 Intent (android.content.Intent)24 VisibleForTesting (androidx.annotation.VisibleForTesting)16 Preference (androidx.preference.Preference)14 UserHandle (android.os.UserHandle)10 ManageApplications (com.android.settings.applications.manageapplications.ManageApplications)10 Context (android.content.Context)9 PendingIntent (android.app.PendingIntent)6 PackageManager (android.content.pm.PackageManager)5 ComponentName (android.content.ComponentName)4 PersistableBundle (android.os.PersistableBundle)4 ApplicationsState (com.android.settingslib.applications.ApplicationsState)4 UserManager (android.os.UserManager)3 View (android.view.View)3 NetworkSelectSettings (com.android.settings.network.telephony.NetworkSelectSettings)3 Activity (android.app.Activity)2 NotificationChannel (android.app.NotificationChannel)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2