Search in sources :

Example 36 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.

the class ConversationListPreferenceController method getSubSettingLauncher.

SubSettingLauncher getSubSettingLauncher(ConversationChannelWrapper conversation, CharSequence title) {
    Bundle channelArgs = new Bundle();
    channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, conversation.getUid());
    channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, conversation.getPkg());
    channelArgs.putString(Settings.EXTRA_CHANNEL_ID, conversation.getNotificationChannel().getId());
    channelArgs.putString(Settings.EXTRA_CONVERSATION_ID, conversation.getNotificationChannel().getConversationId());
    return new SubSettingLauncher(mContext).setDestination(ChannelNotificationSettings.class.getName()).setArguments(channelArgs).setExtras(channelArgs).setUserHandle(UserHandle.getUserHandleForUid(conversation.getUid())).setTitleText(title).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS);
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle)

Example 37 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.

the class ZenModeAddBypassingAppsPreferenceController method updateAppList.

@VisibleForTesting
void updateAppList(List<ApplicationsState.AppEntry> apps) {
    if (apps == null) {
        return;
    }
    if (mPreferenceCategory == null) {
        mPreferenceCategory = new PreferenceCategory(mPrefContext);
        mPreferenceCategory.setTitle(R.string.zen_mode_bypassing_apps_add_header);
        mPreferenceScreen.addPreference(mPreferenceCategory);
    }
    List<Preference> appsWithNoBypassingDndNotificationChannels = new ArrayList<>();
    for (ApplicationsState.AppEntry entry : apps) {
        String pkg = entry.info.packageName;
        mApplicationsState.ensureIcon(entry);
        final int appChannels = mNotificationBackend.getChannelCount(pkg, entry.info.uid);
        final int appChannelsBypassingDnd = mNotificationBackend.getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList().size();
        if (appChannelsBypassingDnd == 0 && appChannels > 0) {
            final String key = ZenModeAllBypassingAppsPreferenceController.getKey(pkg);
            Preference pref = mPreferenceCategory.findPreference("");
            if (pref == null) {
                pref = new AppPreference(mPrefContext);
                pref.setKey(key);
                pref.setOnPreferenceClickListener(preference -> {
                    Bundle args = new Bundle();
                    args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
                    args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
                    new SubSettingLauncher(mContext).setDestination(AppChannelsBypassingDndSettings.class.getName()).setArguments(args).setResultListener(mHostFragment, 0).setUserHandle(new UserHandle(UserHandle.getUserId(entry.info.uid))).setSourceMetricsCategory(SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP).launch();
                    return true;
                });
            }
            pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
            pref.setIcon(entry.icon);
            appsWithNoBypassingDndNotificationChannels.add(pref);
        }
    }
    if (appsWithNoBypassingDndNotificationChannels.size() == 0) {
        Preference pref = mPreferenceCategory.findPreference(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
        if (pref == null) {
            pref = new Preference(mPrefContext);
            pref.setKey(ZenModeAllBypassingAppsPreferenceController.KEY_NO_APPS);
            pref.setTitle(R.string.zen_mode_bypassing_apps_subtext_none);
        }
        mPreferenceCategory.addPreference(pref);
    }
    if (ZenModeAllBypassingAppsPreferenceController.hasAppListChanged(appsWithNoBypassingDndNotificationChannels, mPreferenceCategory)) {
        mPreferenceCategory.removeAll();
        for (Preference prefToAdd : appsWithNoBypassingDndNotificationChannels) {
            mPreferenceCategory.addPreference(prefToAdd);
        }
    }
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) AppPreference(com.android.settingslib.widget.AppPreference) Preference(androidx.preference.Preference) AppPreference(com.android.settingslib.widget.AppPreference) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) ApplicationsState(com.android.settingslib.applications.ApplicationsState) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 38 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.

the class ChannelListPreferenceController method updateSingleChannelPrefs.

/**
 * Update the properties of the channel preference with the values from the channel object.
 */
private void updateSingleChannelPrefs(@NonNull final PrimarySwitchPreference channelPref, @NonNull final NotificationChannel channel, final boolean groupBlocked) {
    channelPref.setSwitchEnabled(mAdmin == null && isChannelBlockable(channel) && isChannelConfigurable(channel) && !groupBlocked);
    if (channel.getImportance() > IMPORTANCE_LOW) {
        channelPref.setIcon(getAlertingIcon());
    } else {
        channelPref.setIcon(R.drawable.empty_icon);
    }
    channelPref.setIconSize(PrimarySwitchPreference.ICON_SIZE_SMALL);
    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 ? Math.max(channel.getOriginalImportance(), IMPORTANCE_LOW) : IMPORTANCE_NONE;
        channel.setImportance(importance);
        channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
        PrimarySwitchPreference channelPref1 = (PrimarySwitchPreference) preference;
        channelPref1.setIcon(R.drawable.empty_icon);
        if (channel.getImportance() > IMPORTANCE_LOW) {
            channelPref1.setIcon(getAlertingIcon());
        }
        mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, channel);
        return true;
    });
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) PrimarySwitchPreference(com.android.settings.widget.PrimarySwitchPreference)

Example 39 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.

the class WifiSettings method launchNetworkDetailsFragment.

private void launchNetworkDetailsFragment(LongPressWifiEntryPreference pref) {
    final WifiEntry wifiEntry = pref.getWifiEntry();
    final Context context = getContext();
    final CharSequence title = FeatureFlagUtils.isEnabled(context, FeatureFlags.WIFI_DETAILS_DATAUSAGE_HEADER) ? wifiEntry.getTitle() : context.getText(R.string.pref_title_network_details);
    final Bundle bundle = new Bundle();
    bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY, wifiEntry.getKey());
    new SubSettingLauncher(context).setTitleText(title).setDestination(WifiNetworkDetailsFragment.class.getName()).setArguments(bundle).setSourceMetricsCategory(getMetricsCategory()).launch();
}
Also used : Context(android.content.Context) SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle) WifiEntry(com.android.wifitrackerlib.WifiEntry)

Example 40 with SubSettingLauncher

use of com.android.settings.core.SubSettingLauncher in project android_packages_apps_Settings by omnirom.

the class WifiSettings method launchConfigNewNetworkFragment.

private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
    final Bundle bundle = new Bundle();
    bundle.putString(WifiNetworkDetailsFragment.KEY_CHOSEN_WIFIENTRY_KEY, wifiEntry.getKey());
    new SubSettingLauncher(getContext()).setTitleText(wifiEntry.getTitle()).setDestination(ConfigureWifiEntryFragment.class.getName()).setArguments(bundle).setSourceMetricsCategory(getMetricsCategory()).setResultListener(WifiSettings.this, CONFIG_NETWORK_REQUEST).launch();
}
Also used : SubSettingLauncher(com.android.settings.core.SubSettingLauncher) Bundle(android.os.Bundle)

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