Settings: Remove zenswitch from DND settings page.
- Remove the ability to view/modify zen mode/condition from the Settings app. Bug: 20064962 Change-Id: I8757780e5e9ef578e05203577871b9f513997798
This commit is contained in:
@@ -21,6 +21,7 @@ import static android.service.notification.ZenModeConfig.ALL_DAYS;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
@@ -181,7 +182,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
|
|||||||
|
|
||||||
private String computeRuleSummary(ZenRule rule) {
|
private String computeRuleSummary(ZenRule rule) {
|
||||||
if (rule == null || !rule.enabled) return getString(R.string.switch_off_text);
|
if (rule == null || !rule.enabled) return getString(R.string.switch_off_text);
|
||||||
final String mode = ZenModeSettings.computeZenModeCaption(getResources(), rule.zenMode);
|
final String mode = computeZenModeCaption(getResources(), rule.zenMode);
|
||||||
String summary = getString(R.string.switch_on_text);
|
String summary = getString(R.string.switch_on_text);
|
||||||
final ScheduleInfo schedule = ZenModeConfig.tryParseScheduleConditionId(rule.conditionId);
|
final ScheduleInfo schedule = ZenModeConfig.tryParseScheduleConditionId(rule.conditionId);
|
||||||
final EventInfo event = ZenModeConfig.tryParseEventConditionId(rule.conditionId);
|
final EventInfo event = ZenModeConfig.tryParseEventConditionId(rule.conditionId);
|
||||||
@@ -298,6 +299,19 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String computeZenModeCaption(Resources res, int zenMode) {
|
||||||
|
switch (zenMode) {
|
||||||
|
case Global.ZEN_MODE_ALARMS:
|
||||||
|
return res.getString(R.string.zen_mode_option_alarms);
|
||||||
|
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
||||||
|
return res.getString(R.string.zen_mode_option_important_interruptions);
|
||||||
|
case Global.ZEN_MODE_NO_INTERRUPTIONS:
|
||||||
|
return res.getString(R.string.zen_mode_option_no_interruptions);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final ServiceListing.Callback mServiceListingCallback = new ServiceListing.Callback() {
|
private final ServiceListing.Callback mServiceListingCallback = new ServiceListing.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onServicesReloaded(List<ServiceInfo> services) {
|
public void onServicesReloaded(List<ServiceInfo> services) {
|
||||||
|
@@ -27,6 +27,7 @@ import android.os.UserHandle;
|
|||||||
import android.service.notification.Condition;
|
import android.service.notification.Condition;
|
||||||
import android.service.notification.IConditionListener;
|
import android.service.notification.IConditionListener;
|
||||||
import android.service.notification.ZenModeConfig;
|
import android.service.notification.ZenModeConfig;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
@@ -119,7 +120,7 @@ public class ZenModeConditionSelection extends RadioGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (v != null) {
|
if (v != null) {
|
||||||
v.setText(ZenModeSettings.computeConditionText(c));
|
v.setText(computeConditionText(c));
|
||||||
v.setEnabled(c.state == Condition.STATE_TRUE);
|
v.setEnabled(c.state == Condition.STATE_TRUE);
|
||||||
}
|
}
|
||||||
mConditions.add(c);
|
mConditions.add(c);
|
||||||
@@ -139,6 +140,12 @@ public class ZenModeConditionSelection extends RadioGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String computeConditionText(Condition c) {
|
||||||
|
return !TextUtils.isEmpty(c.line1) ? c.line1
|
||||||
|
: !TextUtils.isEmpty(c.summary) ? c.summary
|
||||||
|
: "";
|
||||||
|
}
|
||||||
|
|
||||||
private final IConditionListener mListener = new IConditionListener.Stub() {
|
private final IConditionListener mListener = new IConditionListener.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onConditionsReceived(Condition[] conditions) {
|
public void onConditionsReceived(Condition[] conditions) {
|
||||||
|
@@ -16,44 +16,27 @@
|
|||||||
|
|
||||||
package com.android.settings.notification;
|
package com.android.settings.notification;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings.Global;
|
|
||||||
import android.service.notification.Condition;
|
|
||||||
import android.service.notification.ZenModeConfig;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.Switch;
|
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
import com.android.settings.search.SearchIndexableRaw;
|
import com.android.settings.search.SearchIndexableRaw;
|
||||||
import com.android.settings.widget.SwitchBar;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ZenModeSettings extends ZenModeSettingsBase
|
public class ZenModeSettings extends ZenModeSettingsBase implements Indexable {
|
||||||
implements Indexable, SwitchBar.OnSwitchChangeListener {
|
|
||||||
private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
|
private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
|
||||||
private static final String KEY_AUTOMATION_SETTINGS = "automation_settings";
|
private static final String KEY_AUTOMATION_SETTINGS = "automation_settings";
|
||||||
|
|
||||||
private Preference mPrioritySettings;
|
private Preference mPrioritySettings;
|
||||||
private AlertDialog mDialog;
|
|
||||||
private SwitchBar mSwitchBar;
|
|
||||||
private boolean mShowing;
|
|
||||||
private boolean mUpdatingControls;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -68,47 +51,10 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
|
||||||
mSwitchBar = activity.getSwitchBar();
|
|
||||||
mSwitchBar.addOnSwitchChangeListener(this);
|
|
||||||
mSwitchBar.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroyView() {
|
|
||||||
super.onDestroyView();
|
|
||||||
mSwitchBar.removeOnSwitchChangeListener(this);
|
|
||||||
mSwitchBar.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
updateControls();
|
updateControls();
|
||||||
mShowing = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
mShowing = false;
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
|
||||||
if (DEBUG) Log.d(TAG, "onSwitchChanged " + isChecked + " mShowing=" + mShowing
|
|
||||||
+ " mUpdatingControls=" + mUpdatingControls);
|
|
||||||
if (!mShowing || mUpdatingControls) return; // not from the user
|
|
||||||
if (isChecked) {
|
|
||||||
setZenMode(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, null);
|
|
||||||
showConditionSelection(Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS);
|
|
||||||
} else {
|
|
||||||
setZenMode(Global.ZEN_MODE_OFF, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -126,35 +72,7 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
|||||||
updateControls();
|
updateControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String computeZenModeCaption(Resources res, int zenMode) {
|
|
||||||
switch (zenMode) {
|
|
||||||
case Global.ZEN_MODE_ALARMS:
|
|
||||||
return res.getString(R.string.zen_mode_option_alarms);
|
|
||||||
case Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS:
|
|
||||||
return res.getString(R.string.zen_mode_option_important_interruptions);
|
|
||||||
case Global.ZEN_MODE_NO_INTERRUPTIONS:
|
|
||||||
return res.getString(R.string.zen_mode_option_no_interruptions);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String computeZenModeSummaryLine() {
|
|
||||||
final String caption = computeZenModeCaption(getResources(), mZenMode);
|
|
||||||
if (caption == null) return null; // zen mode off
|
|
||||||
final String conditionText = ZenModeConfig.getConditionLine1(mContext, mConfig,
|
|
||||||
UserHandle.myUserId());
|
|
||||||
return getString(R.string.zen_mode_summary_combination, caption, conditionText);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateControls() {
|
private void updateControls() {
|
||||||
if (mSwitchBar != null) {
|
|
||||||
final String summaryLine = computeZenModeSummaryLine();
|
|
||||||
mUpdatingControls = true;
|
|
||||||
mSwitchBar.setChecked(summaryLine != null);
|
|
||||||
mUpdatingControls = false;
|
|
||||||
mSwitchBar.setSummary(summaryLine);
|
|
||||||
}
|
|
||||||
updatePrioritySettingsSummary();
|
updatePrioritySettingsSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,52 +94,6 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showConditionSelection(final int zenMode) {
|
|
||||||
if (mDialog != null) return;
|
|
||||||
|
|
||||||
final ZenModeConditionSelection zenModeConditionSelection =
|
|
||||||
new ZenModeConditionSelection(mContext, zenMode);
|
|
||||||
DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
zenModeConditionSelection.confirmCondition();
|
|
||||||
mDialog = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ScrollView scrollView = new ScrollView(mContext);
|
|
||||||
scrollView.addView(zenModeConditionSelection);
|
|
||||||
mDialog = new AlertDialog.Builder(getActivity())
|
|
||||||
.setTitle(computeZenModeCaption(getResources(), zenMode))
|
|
||||||
.setView(scrollView)
|
|
||||||
.setPositiveButton(R.string.okay, positiveListener)
|
|
||||||
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
cancelDialog();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
cancelDialog();
|
|
||||||
}
|
|
||||||
}).create();
|
|
||||||
mDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cancelDialog() {
|
|
||||||
if (DEBUG) Log.d(TAG, "cancelDialog");
|
|
||||||
// If not making a decision, reset zen to off.
|
|
||||||
setZenMode(Global.ZEN_MODE_OFF, null);
|
|
||||||
mDialog = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String computeConditionText(Condition c) {
|
|
||||||
return !TextUtils.isEmpty(c.line1) ? c.line1
|
|
||||||
: !TextUtils.isEmpty(c.summary) ? c.summary
|
|
||||||
: "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static SparseArray<String> allKeyTitles(Context context) {
|
private static SparseArray<String> allKeyTitles(Context context) {
|
||||||
final SparseArray<String> rt = new SparseArray<String>();
|
final SparseArray<String> rt = new SparseArray<String>();
|
||||||
rt.put(R.string.zen_mode_priority_settings_title, KEY_PRIORITY_SETTINGS);
|
rt.put(R.string.zen_mode_priority_settings_title, KEY_PRIORITY_SETTINGS);
|
||||||
|
Reference in New Issue
Block a user