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:
@@ -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");
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Mode id required to set mode config settings");
|
||||
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;
|
||||
}
|
||||
if (!reloadMode(id)) {
|
||||
Log.d(TAG, "Mode id " + id + " not found");
|
||||
toastAndFinish();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user