Settings: An update on Downtime.

- Migrate settings to the new zen mode state model.
 - Remove downtime settings.
 - Add automatic rule management page (add/remove)
 - Bind new automatic schedule rules to detail editor.
 - Clean up a few found miscapitalized string captions.
 - Migrate zen switch to report the shared summary string.

Bug: 20064962
Change-Id: Ia561e7f77c90c962729240b4d51ba1915297f64a
This commit is contained in:
John Spurlock
2015-04-09 12:50:04 -04:00
parent 342d08537f
commit 45fa140b8c
23 changed files with 907 additions and 763 deletions

View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2015 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.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.ArraySet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import com.android.settings.R;
public abstract class ZenRuleNameDialog {
private final AlertDialog mDialog;
private final EditText mEditText;
private final ArraySet<String> mExistingNames;
public ZenRuleNameDialog(Context context, String ruleName, ArraySet<String> existingNames) {
final View v = LayoutInflater.from(context).inflate(R.layout.zen_rule_name, null, false);
mEditText = (EditText) v.findViewById(R.id.rule_name);
mEditText.setText(ruleName);
mEditText.setSelectAllOnFocus(true);
mDialog = new AlertDialog.Builder(context)
.setTitle(R.string.zen_mode_rule_name)
.setView(v)
.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onOk(trimmedText());
}
})
.setNegativeButton(R.string.cancel, null)
.create();
mEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// noop
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// noop
}
@Override
public void afterTextChanged(Editable s) {
updatePositiveButton();
}
});
mExistingNames = new ArraySet<String>(existingNames.size());
for (String existingName : existingNames) {
mExistingNames.add(existingName.toLowerCase());
}
}
abstract public void onOk(String ruleName);
private String trimmedText() {
return mEditText.getText() == null ? null : mEditText.getText().toString().trim();
}
public void show() {
mDialog.show();
updatePositiveButton();
}
private void updatePositiveButton() {
final String name = trimmedText();
final boolean validName = !TextUtils.isEmpty(name)
&& !mExistingNames.contains(name.toLowerCase());
mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(validName);
}
}