Migrate Settings intents
to our new modes ui Fixes: 333909883 Test: manual - created test app that launches each intent, launched each with flag on and flag off Test: atest com.android.settings.notification.modes Flag: android.app.modes_ui Change-Id: I8259b554fe34b453880890c667165547033ccd06
This commit is contained in:
@@ -125,6 +125,9 @@ android_library {
|
||||
"telephony-common",
|
||||
"ims-common",
|
||||
],
|
||||
flags_packages: [
|
||||
"android.app.flags-aconfig",
|
||||
],
|
||||
}
|
||||
|
||||
platform_compat_config {
|
||||
@@ -155,6 +158,9 @@ android_app {
|
||||
optimize: {
|
||||
proguard_flags_files: ["proguard.flags"],
|
||||
},
|
||||
flags_packages: [
|
||||
"android.app.flags-aconfig",
|
||||
],
|
||||
}
|
||||
|
||||
android_library_import {
|
||||
|
@@ -1287,20 +1287,63 @@
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$ZenModeSettingsActivity"
|
||||
android:name="Settings$ModesSettingsActivity"
|
||||
android:label="@string/zen_mode_settings_title"
|
||||
android:icon="@drawable/ic_homepage_notification"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1">
|
||||
<intent-filter android:priority="1"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="1">
|
||||
<intent-filter android:priority="1"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="41">
|
||||
<intent-filter android:priority="41"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.SHORTCUT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="10"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="10"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.notification.modes.ZenModesListFragment"/>
|
||||
<meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
|
||||
android:value="@string/menu_key_notifications"/>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$ZenModeSettingsActivity"
|
||||
android:label="@string/zen_mode_settings_title"
|
||||
android:icon="@drawable/ic_homepage_notification"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1"
|
||||
android:featureFlag="!android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="1"
|
||||
android:featureFlag="!android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="41"
|
||||
android:featureFlag="!android.app.modes_ui">
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.SHORTCUT" />
|
||||
</intent-filter>
|
||||
@@ -1312,6 +1355,20 @@
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$ModeSettingsActivity"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1"
|
||||
android:featureFlag="android.app.modes_ui">
|
||||
<action android:name="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.notification.modes.ZenModeFragment"/>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".notification.zen.ZenSuggestionActivity"
|
||||
android:label="@string/zen_mode_settings_title"
|
||||
@@ -1351,11 +1408,13 @@
|
||||
android:label="@string/zen_mode_automation_settings_title"
|
||||
android:icon="@drawable/ic_notifications"
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1">
|
||||
<intent-filter android:priority="10"
|
||||
android:featureFlag="!android.app.modes_ui">
|
||||
<action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter android:priority="1">
|
||||
<intent-filter android:priority="10"
|
||||
android:featureFlag="!android.app.modes_ui">
|
||||
<action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
@@ -18,6 +18,8 @@ package com.android.settings;
|
||||
|
||||
import static android.provider.Settings.ACTION_PRIVACY_SETTINGS;
|
||||
|
||||
import android.annotation.FlaggedApi;
|
||||
import android.app.Flags;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -317,11 +319,13 @@ public class Settings extends SettingsActivity {
|
||||
public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeBehaviorSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeBlockedEffectsSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeScheduleRuleSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ZenModeEventRuleSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
@FlaggedApi(Flags.FLAG_MODES_UI)
|
||||
public static class ModeSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
@FlaggedApi(Flags.FLAG_MODES_UI)
|
||||
public static class ModesSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class SoundSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ConfigureNotificationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class ConversationListSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -162,6 +162,8 @@ import com.android.settings.notification.app.AppNotificationSettings;
|
||||
import com.android.settings.notification.app.ChannelNotificationSettings;
|
||||
import com.android.settings.notification.app.ConversationListSettings;
|
||||
import com.android.settings.notification.history.NotificationStation;
|
||||
import com.android.settings.notification.modes.ZenModeFragment;
|
||||
import com.android.settings.notification.modes.ZenModesListFragment;
|
||||
import com.android.settings.notification.zen.ZenAccessSettings;
|
||||
import com.android.settings.notification.zen.ZenModeAutomationSettings;
|
||||
import com.android.settings.notification.zen.ZenModeBlockedEffectsSettings;
|
||||
@@ -396,6 +398,8 @@ public class SettingsGateway {
|
||||
CellularSecuritySettingsFragment.class.getName(),
|
||||
AccessibilityHearingAidsFragment.class.getName(),
|
||||
HearingDevicePairingFragment.class.getName(),
|
||||
ZenModesListFragment.class.getName(),
|
||||
ZenModeFragment.class.getName()
|
||||
};
|
||||
|
||||
public static final String[] SETTINGS_FOR_RESTRICTED = {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -50,7 +50,7 @@ class ZenModeActionsPreferenceController extends AbstractZenModePreferenceContro
|
||||
buttonsPreference.setButton2Enabled(zenMode.canEditIcon());
|
||||
buttonsPreference.setButton2OnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeIconPickerFragment.class.getName())
|
||||
// TODO: b/332937635 - Update metrics category
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -72,7 +71,7 @@ class ZenModeAppsLinkPreferenceController extends AbstractZenModePreferenceContr
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeAppsFragment.class.getName())
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
@@ -103,7 +103,7 @@ public class ZenModeAppsPreferenceController extends
|
||||
private void launchPrioritySettings() {
|
||||
Bundle bundle = new Bundle();
|
||||
if (mModeId != null) {
|
||||
bundle.putString(MODE_ID, mModeId);
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, mModeId);
|
||||
}
|
||||
// TODO(b/332937635): Update metrics category
|
||||
new SubSettingLauncher(mContext)
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -39,7 +39,7 @@ class ZenModeCallsLinkPreferenceController extends AbstractZenModePreferenceCont
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeCallsFragment.class.getName())
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -39,7 +39,7 @@ class ZenModeDisplayLinkPreferenceController extends AbstractZenModePreferenceCo
|
||||
@Override
|
||||
void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeDisplayFragment.class.getName())
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.app.AutomaticZenRule;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -37,7 +39,6 @@ import java.util.List;
|
||||
*/
|
||||
abstract class ZenModeFragmentBase extends ZenModesFragmentBase {
|
||||
static final String TAG = "ZenModeSettings";
|
||||
static final String MODE_ID = "MODE_ID";
|
||||
|
||||
@Nullable // only until reloadMode() is called
|
||||
private ZenMode mZenMode;
|
||||
@@ -46,17 +47,21 @@ abstract class ZenModeFragmentBase extends ZenModesFragmentBase {
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
// TODO: b/322373473 - Update if modes page ends up using a different method of passing id
|
||||
String id = null;
|
||||
if (getActivity() != null && getActivity().getIntent() != null) {
|
||||
id = getActivity().getIntent().getStringExtra(EXTRA_AUTOMATIC_ZEN_RULE_ID);
|
||||
}
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null && bundle.containsKey(MODE_ID)) {
|
||||
String id = bundle.getString(MODE_ID);
|
||||
if (!reloadMode(id)) {
|
||||
Log.e(TAG, "Mode id " + id + " not found");
|
||||
if (id == null && bundle != null && bundle.containsKey(EXTRA_AUTOMATIC_ZEN_RULE_ID)) {
|
||||
id = bundle.getString(EXTRA_AUTOMATIC_ZEN_RULE_ID);
|
||||
}
|
||||
if (id == null) {
|
||||
Log.d(TAG, "No id provided");
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Mode id required to set mode config settings");
|
||||
if (!reloadMode(id)) {
|
||||
Log.d(TAG, "Mode id " + id + " not found");
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -38,7 +38,7 @@ class ZenModeMessagesLinkPreferenceController extends AbstractZenModePreferenceC
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeMessagesFragment.class.getName())
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -46,7 +45,7 @@ class ZenModeNotifVisLinkPreferenceController extends AbstractZenModePreferenceC
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeNotifVisFragment.class.getName())
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -49,7 +48,7 @@ class ZenModeOtherLinkPreferenceController extends AbstractZenModePreferenceCont
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModeOtherFragment.class.getName())
|
||||
.setSourceMetricsCategory(0)
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -49,7 +48,7 @@ class ZenModePeopleLinkPreferenceController extends AbstractZenModePreferenceCon
|
||||
@Override
|
||||
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MODE_ID, zenMode.getId());
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
|
||||
// TODO(b/332937635): Update metrics category
|
||||
preference.setIntent(new SubSettingLauncher(mContext)
|
||||
.setDestination(ZenModePeopleFragment.class.getName())
|
||||
|
@@ -63,7 +63,6 @@ class ZenModeSetTriggerLinkPreferenceController extends AbstractZenModePreferenc
|
||||
}
|
||||
switchPref.setChecked(zenMode.getRule().isEnabled());
|
||||
switchPref.setOnPreferenceChangeListener(mSwitchChangeListener);
|
||||
|
||||
switchPref.setSummary(zenMode.getRule().getTriggerDescription());
|
||||
switchPref.setIcon(null);
|
||||
switchPref.setOnPreferenceClickListener(null);
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -33,7 +35,7 @@ class ZenSubSettingLauncher {
|
||||
Class<? extends ZenModeFragmentBase> fragmentClass, String modeId,
|
||||
int sourceMetricsCategory) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ZenModeFragmentBase.MODE_ID, modeId);
|
||||
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, modeId);
|
||||
|
||||
return new SubSettingLauncher(context)
|
||||
.setDestination(fragmentClass.getName())
|
||||
|
@@ -17,8 +17,7 @@
|
||||
package com.android.settings.notification.modes;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY;
|
||||
|
||||
import static com.android.settings.notification.modes.ZenModeFragmentBase.MODE_ID;
|
||||
import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -138,7 +137,7 @@ public final class ZenModeAppsLinkPreferenceControllerTest {
|
||||
Bundle bundle = launcherIntent.getBundleExtra(
|
||||
SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||
assertThat(bundle).isNotNull();
|
||||
assertThat(bundle.getString(MODE_ID)).isEqualTo("id");
|
||||
assertThat(bundle.getString(EXTRA_AUTOMATIC_ZEN_RULE_ID)).isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user