diff options
author | Barnaby James <bjames@google.com> | 2015-05-10 16:24:05 -0700 |
---|---|---|
committer | Barnaby James <bjames@google.com> | 2015-05-11 09:20:54 -0700 |
commit | 0474b723e1118fe99a26cd1d1452f181a4d74ba7 (patch) | |
tree | c46bbde9f8ba2c34e84fa1f2e1f9047f40586b72 /src/com/android/settings/utils | |
parent | 69a03f75171c9f21ee4517f8e6d02cfa955c6a84 (diff) | |
download | packages_apps_Settings-0474b723e1118fe99a26cd1d1452f181a4d74ba7.zip packages_apps_Settings-0474b723e1118fe99a26cd1d1452f181a4d74ba7.tar.gz packages_apps_Settings-0474b723e1118fe99a26cd1d1452f181a4d74ba7.tar.bz2 |
Simplify Zen mode voice activity.
Zen mode voice activity now only sets the notification mode to alarms mode
or off. A duration may be specified if it was in the original intent.
Change-Id: Ica472ca9c6dcbce473832f4f922baf225df4951b
Bug: 21024455
Diffstat (limited to 'src/com/android/settings/utils')
4 files changed, 0 insertions, 301 deletions
diff --git a/src/com/android/settings/utils/VoiceSelection.java b/src/com/android/settings/utils/VoiceSelection.java deleted file mode 100644 index 997d2cc..0000000 --- a/src/com/android/settings/utils/VoiceSelection.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.utils; - -import android.app.VoiceInteractor.PickOptionRequest.Option; -import android.os.Bundle; -import android.text.TextUtils; - -/** - * Model for a single item that can be selected by a {@link VoiceSelectionFragment}. - * Each item consists of a visual label and several alternative synonyms for the item - * that can be used to identify the item by voice. - */ -public class VoiceSelection { - final CharSequence mLabel; - final CharSequence[] mSynonyms; - - /** - * Created a new selectable item with a visual label and a set of synonyms. - */ - public VoiceSelection(CharSequence label, CharSequence synonyms) { - mLabel = label; - mSynonyms = TextUtils.split(synonyms.toString(), ","); - } - - /** - * Created a new selectable item with a visual label and no synonyms. - */ - public VoiceSelection(CharSequence label) { - mLabel = label; - mSynonyms = null; - } - - public CharSequence getLabel() { - return mLabel; - } - - public CharSequence[] getSynonyms() { - return mSynonyms; - } - - Option toOption(int index) { - Option result = new Option(mLabel); - Bundle extras = new Bundle(); - extras.putInt("index", index); - result.setExtras(extras); - - for (CharSequence synonym : mSynonyms) { - result.addSynonym(synonym); - } - return result; - } - - /** - * Listener interface for when an item is selected. - */ - public interface OnItemSelectedListener { - abstract void onItemSelected(int position, VoiceSelection selection); - }; -} diff --git a/src/com/android/settings/utils/VoiceSelectionAdapter.java b/src/com/android/settings/utils/VoiceSelectionAdapter.java deleted file mode 100644 index 2c060c2..0000000 --- a/src/com/android/settings/utils/VoiceSelectionAdapter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.utils; - -import android.content.Context; -import android.widget.ArrayAdapter; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import android.app.Activity; -import com.android.settings.R; - -import java.util.List; -import android.util.Log; - -/** - * Array adapter for selecting an item by voice interaction. Each row includes a visual - * indication of the 1-indexed position of the item so that a user can easily say - * "number 4" to select it. - */ -public class VoiceSelectionAdapter extends ArrayAdapter<VoiceSelection> { - public VoiceSelectionAdapter(Context context, int resource, List<VoiceSelection> objects) { - super(context, resource, objects); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - VoiceSelection item = getItem(position); - View row = convertView; - if (row == null) { - LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater(); - row = inflater.inflate(R.layout.voice_item_row, parent, false); - } - - TextView label = (TextView) row.findViewById(R.id.voice_item_label); - if (label != null) { - label.setText(item.getLabel()); - } - - TextView positionLabel = (TextView) row.findViewById(R.id.voice_item_position); - if (positionLabel != null) { - positionLabel.setText(Integer.toString(position + 1)); - } - - return row; - } -}; diff --git a/src/com/android/settings/utils/VoiceSelectionFragment.java b/src/com/android/settings/utils/VoiceSelectionFragment.java deleted file mode 100644 index 1e4e7e4..0000000 --- a/src/com/android/settings/utils/VoiceSelectionFragment.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.utils; - -import android.app.ListFragment; -import android.app.VoiceInteractor; -import android.app.VoiceInteractor.PickOptionRequest; -import android.app.VoiceInteractor.PickOptionRequest.Option; -import android.os.Bundle; -import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.ListAdapter; -import android.widget.ListView; - -import java.util.List; - -/** - * An Activity fragment that presents a set of options as a visual list and also allows - * items to be selected by the users voice. - */ -public class VoiceSelectionFragment extends ListFragment { - private static final String EXTRA_SELECTION_PROMPT = "selection_prompt"; - - private CharSequence mPrompt = null; - private VoiceInteractor.Request mRequest = null; - private VoiceInteractor mVoiceInteractor = null; - private VoiceSelection.OnItemSelectedListener mOnItemSelectedListener = null; - - /** - * No-args ctor required for fragment. - */ - public VoiceSelectionFragment() {} - - @Override - public void onCreate(Bundle args) { - super.onCreate(args); - mPrompt = getArguments().getCharSequence(EXTRA_SELECTION_PROMPT); - } - - /** - * Set the prompt spoken when the fragment is presented. - */ - static public Bundle createArguments(CharSequence prompt) { - Bundle args = new Bundle(); - args.putCharSequence(EXTRA_SELECTION_PROMPT, prompt); - return args; - } - - private VoiceSelection getSelectionAt(int position) { - return ((ArrayAdapter<VoiceSelection>) getListAdapter()).getItem(position); - } - - @Override - public void onStart() { - super.onStart(); - - final int numItems = getListAdapter().getCount(); - if (numItems <= 0) { - return; - } - - Option[] options = new Option[numItems]; - for (int idx = 0; idx < numItems; idx++) { - options[idx] = getSelectionAt(idx).toOption(idx); - } - mRequest = new PickOptionRequest(mPrompt, options, null) { - @Override - public void onPickOptionResult(boolean isComplete, Option[] options, Bundle args) { - if (!isComplete || options == null) { - return; - } - if (options.length == 1 && mOnItemSelectedListener != null) { - int idx = options[0].getExtras().getInt("index", -1); - mOnItemSelectedListener.onItemSelected(idx, getSelectionAt(idx)); - } else { - onCancel(); - } - } - }; - mVoiceInteractor = getActivity().getVoiceInteractor(); - if (mVoiceInteractor != null) { - mVoiceInteractor.submitRequest(mRequest); - } - } - - @Override - public void onDetach() { - super.onDetach(); - mVoiceInteractor = null; - } - - @Override - public void onListItemClick(ListView l, View v, int position, long id) { - if (mRequest != null) { - mRequest.cancel(); - mRequest = null; - } - - if (mOnItemSelectedListener != null) { - mOnItemSelectedListener.onItemSelected(position, getSelectionAt(position)); - } - } - - - /** - * Sets the selection handler for an item either by voice or by touch. - */ - public void setOnItemSelectedHandler(VoiceSelection.OnItemSelectedListener listener) { - mOnItemSelectedListener = listener; - } - - /** - * Called when the user cancels the interaction. The default implementation is to - * finish the activity. - */ - public void onCancel() { - getActivity().finish(); - } -}; diff --git a/src/com/android/settings/utils/VoiceSettingsActivity.java b/src/com/android/settings/utils/VoiceSettingsActivity.java index 2553a54..e81c7e8 100644 --- a/src/com/android/settings/utils/VoiceSettingsActivity.java +++ b/src/com/android/settings/utils/VoiceSettingsActivity.java @@ -16,8 +16,6 @@ package com.android.settings.utils; -import com.android.settings.R; - import android.app.Activity; import android.app.Fragment; import android.app.VoiceInteractor; @@ -27,7 +25,6 @@ import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TextView; -import android.widget.Toast; import android.util.Log; /** @@ -67,45 +64,17 @@ abstract public class VoiceSettingsActivity extends Activity { * not null, then it will be read to the user. */ protected void notifySuccess(CharSequence prompt) { - if (prompt != null) { - Toast.makeText(this, prompt, Toast.LENGTH_LONG).show(); - } - if (getVoiceInteractor() != null) { getVoiceInteractor().submitRequest(new CompleteVoiceRequest(prompt, null)); } } - protected void setHeader(String label) { - TextView header = (TextView) findViewById(R.id.voice_fragment_header); - if (header != null) { - if (label != null) { - header.setText(label); - header.setVisibility(View.VISIBLE); - } else { - header.setVisibility(View.GONE); - } - } - } - /** * Indicates when the setting could not be changed. */ protected void notifyFailure(CharSequence prompt) { - if (prompt != null) { - Toast.makeText(this, prompt, Toast.LENGTH_LONG).show(); - } - if (getVoiceInteractor() != null) { getVoiceInteractor().submitRequest(new AbortVoiceRequest(prompt, null)); } } - - protected void showFragment(Fragment fragment, String tag) { - getFragmentManager() - .beginTransaction() - .replace(R.id.voice_fragment_root, fragment, tag) - .commit(); - } - } |