Move bubble settings to their own page
To make room for graphics/longer descriptive text
Test: robotests
Bug: 129068779
Change-Id: Iac6ea43bd3a0cddc487ff3d1bbd8f35142294d01
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index bdb5889..e1c9aff 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -113,6 +113,7 @@
public static class ZenModeEventRuleSettingsActivity extends SettingsActivity { /* empty */ }
public static class SoundSettingsActivity extends SettingsActivity { /* empty */ }
public static class ConfigureNotificationSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class AppBubbleNotificationSettingsActivity extends SettingsActivity { /* empty */ }
public static class NotificationAssistantSettingsActivity extends SettingsActivity{ /* empty */ }
public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 31d54f9..30f6afc 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -101,7 +101,9 @@
import com.android.settings.network.NetworkDashboardFragment;
import com.android.settings.nfc.AndroidBeam;
import com.android.settings.nfc.PaymentSettings;
+import com.android.settings.notification.AppBubbleNotificationSettings;
import com.android.settings.notification.AppNotificationSettings;
+import com.android.settings.notification.BubbleNotificationSettings;
import com.android.settings.notification.ChannelGroupNotificationSettings;
import com.android.settings.notification.ChannelNotificationSettings;
import com.android.settings.notification.ConfigureNotificationSettings;
@@ -211,6 +213,8 @@
DreamSettings.class.getName(),
UserSettings.class.getName(),
NotificationAccessSettings.class.getName(),
+ BubbleNotificationSettings.class.getName(),
+ AppBubbleNotificationSettings.class.getName(),
ZenAccessSettings.class.getName(),
ZenAccessDetails.class.getName(),
ZenModeAutomationSettings.class.getName(),
diff --git a/src/com/android/settings/notification/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
new file mode 100644
index 0000000..17909c0
--- /dev/null
+++ b/src/com/android/settings/notification/AppBubbleNotificationSettings.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@SearchIndexable
+public class AppBubbleNotificationSettings extends NotificationSettingsBase {
+ private static final String TAG = "AppBubNotiSettings";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.APP_BUBBLE_SETTINGS;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.app_bubble_notification_settings;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ mControllers = getPreferenceControllers(context, this);
+ return new ArrayList<>(mControllers);
+ }
+
+ protected static List<NotificationPreferenceController> getPreferenceControllers(
+ Context context, AppBubbleNotificationSettings fragment) {
+ List<NotificationPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new HeaderPreferenceController(context, fragment));
+ controllers.add(new BubblePreferenceController(context, new NotificationBackend()));
+ return controllers;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) {
+ Log.w(TAG, "Missing package or uid or packageinfo");
+ finish();
+ return;
+ }
+
+ for (NotificationPreferenceController controller : mControllers) {
+ controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.displayPreference(getPreferenceScreen());
+ }
+ updatePreferenceStates();
+ }
+
+ /**
+ * For Search.
+ */
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.app_bubble_notification_settings;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<AbstractPreferenceController> createPreferenceControllers(Context
+ context) {
+ return new ArrayList<>(AppBubbleNotificationSettings.getPreferenceControllers(
+ context, null));
+ }
+ };
+}
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 3ccca00..24d85e2 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -152,7 +152,7 @@
mControllers.add(new DescriptionPreferenceController(context));
mControllers.add(new NotificationsOffPreferenceController(context));
mControllers.add(new DeletedChannelsPreferenceController(context, mBackend));
- mControllers.add(new BubblePreferenceController(context, mBackend));
+ mControllers.add(new BubbleSummaryPreferenceController(context, mBackend));
return new ArrayList<>(mControllers);
}
diff --git a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java b/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
index caba7d9..83e73e9 100644
--- a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
@@ -56,7 +56,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- Preference preference = screen.findPreference(NOTIFICATION_BUBBLES);
+ Preference preference = screen.findPreference(getPreferenceKey());
if (preference != null) {
mSettingObserver = new SettingObserver(preference);
}
diff --git a/src/com/android/settings/notification/BubbleNotificationSettings.java b/src/com/android/settings/notification/BubbleNotificationSettings.java
new file mode 100644
index 0000000..7044293
--- /dev/null
+++ b/src/com/android/settings/notification/BubbleNotificationSettings.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.settings.R;
+import com.android.settings.core.OnActivityResultListener;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.Arrays;
+import java.util.List;
+
+@SearchIndexable
+public class BubbleNotificationSettings extends DashboardFragment implements
+ OnActivityResultListener {
+ private static final String TAG = "BubbleNotiSettings";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.BUBBLE_SETTINGS;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.bubble_notification_settings;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.bubble_notification_settings;
+ return Arrays.asList(sir);
+ }
+ };
+}
diff --git a/src/com/android/settings/notification/BubblePreferenceController.java b/src/com/android/settings/notification/BubblePreferenceController.java
index 5b3be44..5dab374 100644
--- a/src/com/android/settings/notification/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/BubblePreferenceController.java
@@ -21,6 +21,7 @@
import android.content.Context;
import android.provider.Settings;
+import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -74,6 +75,8 @@
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
} else {
pref.setChecked(mAppRow.allowBubbles);
+ pref.setSummary(mContext.getString(
+ R.string.bubbles_app_toggle_summary, mAppRow.label));
}
}
}
diff --git a/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java b/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java
new file mode 100644
index 0000000..e26d9a8
--- /dev/null
+++ b/src/com/android/settings/notification/BubbleSummaryNotificationPreferenceController.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import androidx.annotation.VisibleForTesting;
+
+public class BubbleSummaryNotificationPreferenceController extends BasePreferenceController {
+
+ @VisibleForTesting
+ static final int ON = 1;
+
+ public BubbleSummaryNotificationPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return mContext.getString(
+ areBubblesEnabled() ? R.string.switch_on_text : R.string.switch_off_text);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ private boolean areBubblesEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, ON) == ON;
+ }
+}
diff --git a/src/com/android/settings/notification/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/BubbleSummaryPreferenceController.java
new file mode 100644
index 0000000..708bbcd
--- /dev/null
+++ b/src/com/android/settings/notification/BubbleSummaryPreferenceController.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.os.Bundle;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.core.SubSettingLauncher;
+
+import androidx.preference.Preference;
+
+public class BubbleSummaryPreferenceController extends NotificationPreferenceController {
+
+ private static final String KEY = "bubble_link_pref";
+ private static final int SYSTEM_WIDE_ON = 1;
+ private static final int SYSTEM_WIDE_OFF = 0;
+
+ public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null && mChannel == null) {
+ return false;
+ }
+ if (Settings.Secure.getInt(mContext.getContentResolver(),
+ NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
+ return false;
+ }
+ if (mChannel != null) {
+ if (isDefaultChannel()) {
+ return true;
+ } else {
+ return mAppRow == null ? false : mAppRow.allowBubbles;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+
+ if (mAppRow != null) {
+ Bundle args = new Bundle();
+ args.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
+ args.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
+
+ preference.setIntent(new SubSettingLauncher(mContext)
+ .setDestination(AppBubbleNotificationSettings.class.getName())
+ .setArguments(args)
+ .setSourceMetricsCategory(
+ SettingsEnums.NOTIFICATION_APP_NOTIFICATION)
+ .toIntent());
+ }
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ boolean canBubble = false;
+ if (mAppRow != null) {
+ if (mChannel != null) {
+ canBubble |= mChannel.canBubble();
+ } else {
+ canBubble |= mAppRow.allowBubbles;
+ }
+ }
+ return mContext.getString(canBubble ? R.string.switch_on_text : R.string.switch_off_text);
+ }
+}