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:
@@ -16,44 +16,27 @@
|
||||
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.Preference;
|
||||
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.widget.ScrollView;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ZenModeSettings extends ZenModeSettingsBase
|
||||
implements Indexable, SwitchBar.OnSwitchChangeListener {
|
||||
public class ZenModeSettings extends ZenModeSettingsBase implements Indexable {
|
||||
private static final String KEY_PRIORITY_SETTINGS = "priority_settings";
|
||||
private static final String KEY_AUTOMATION_SETTINGS = "automation_settings";
|
||||
|
||||
private Preference mPrioritySettings;
|
||||
private AlertDialog mDialog;
|
||||
private SwitchBar mSwitchBar;
|
||||
private boolean mShowing;
|
||||
private boolean mUpdatingControls;
|
||||
|
||||
@Override
|
||||
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
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
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
|
||||
@@ -126,35 +72,7 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
||||
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() {
|
||||
if (mSwitchBar != null) {
|
||||
final String summaryLine = computeZenModeSummaryLine();
|
||||
mUpdatingControls = true;
|
||||
mSwitchBar.setChecked(summaryLine != null);
|
||||
mUpdatingControls = false;
|
||||
mSwitchBar.setSummary(summaryLine);
|
||||
}
|
||||
updatePrioritySettingsSummary();
|
||||
}
|
||||
|
||||
@@ -176,52 +94,6 @@ public class ZenModeSettings extends ZenModeSettingsBase
|
||||
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) {
|
||||
final SparseArray<String> rt = new SparseArray<String>();
|
||||
rt.put(R.string.zen_mode_priority_settings_title, KEY_PRIORITY_SETTINGS);
|
||||
|
Reference in New Issue
Block a user