UI Tweaks to Zen Mode Voice Activity.
Small cleanup of the UI / strings. - Cleanup of string constant names. - Add a specific string for ZenModeVoiceActivity label. - Change look of list position indicators. - Add optional header to VoiceSettingsActivity. - Fix NPE in some cases when disabling Zen mode. Change-Id: Ic09ee2b1b5a50891b5447c2db0e3de3c475696bf
This commit is contained in:
@@ -1022,7 +1022,7 @@
|
|||||||
|
|
||||||
<activity android:name=".notification.ZenModeVoiceActivity"
|
<activity android:name=".notification.ZenModeVoiceActivity"
|
||||||
android:theme="@android:style/Theme.Material.Light"
|
android:theme="@android:style/Theme.Material.Light"
|
||||||
android:label="@string/zen_mode_settings_title">
|
android:label="@string/zen_mode_interruptions_voice_title">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE" />
|
<action android:name="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
@@ -16,6 +16,6 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="oval">
|
android:shape="rectangle">
|
||||||
<solid android:color="@color/blue" />
|
<solid android:color="@color/voice_interaction_highlight" />
|
||||||
</shape>
|
</shape>
|
@@ -14,10 +14,20 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/fragment_root"
|
android:padding="8dp"
|
||||||
android:paddingLeft="8dp"
|
android:orientation="vertical"
|
||||||
android:paddingRight="8dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
</FrameLayout>
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textColor="@color/voice_interaction_highlight"
|
||||||
|
android:id="@+id/voice_fragment_header" />
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/voice_fragment_root"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</LinearLayout>
|
||||||
|
@@ -23,8 +23,8 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="15dp"
|
||||||
android:layout_marginBottom="20dp">
|
android:layout_marginBottom="15dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
@@ -33,10 +33,10 @@
|
|||||||
android:id="@+id/voice_item_label" />
|
android:id="@+id/voice_item_label" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="100px"
|
android:layout_width="80px"
|
||||||
android:layout_height="100px"
|
android:layout_height="80px"
|
||||||
android:gravity="center_horizontal|center_vertical"
|
android:gravity="center_horizontal|center_vertical"
|
||||||
android:background="@drawable/bg_circle_blue"
|
android:background="@drawable/bg_voice_position"
|
||||||
android:textAppearance="?android:attr/textAppearanceMediumInverse"
|
android:textAppearance="?android:attr/textAppearanceMediumInverse"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:id="@+id/voice_item_position" />
|
android:id="@+id/voice_item_position" />
|
||||||
|
@@ -83,4 +83,5 @@
|
|||||||
<color name="confirm_device_credential_dark_background">#263238</color>
|
<color name="confirm_device_credential_dark_background">#263238</color>
|
||||||
<color name="fab_ripple">#1fffffff</color><!-- 12% white -->
|
<color name="fab_ripple">#1fffffff</color><!-- 12% white -->
|
||||||
<color name="fab_shape">#ff009688</color><!-- Teal 500 -->
|
<color name="fab_shape">#ff009688</color><!-- Teal 500 -->
|
||||||
|
<color name="voice_interaction_highlight">#33b5e5</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -6113,26 +6113,41 @@
|
|||||||
<!-- [CHAR LIMIT=60] Zen mode settings: End time option: Summary text value format when end time = next day -->
|
<!-- [CHAR LIMIT=60] Zen mode settings: End time option: Summary text value format when end time = next day -->
|
||||||
<string name="zen_mode_end_time_next_day_summary_format"><xliff:g id="formatted_time" example="7:00 AM">%s</xliff:g> next day</string>
|
<string name="zen_mode_end_time_next_day_summary_format"><xliff:g id="formatted_time" example="7:00 AM">%s</xliff:g> next day</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Activity title for interruption level -->
|
||||||
|
<string name="zen_mode_interruptions_voice_title">Interruptions</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Header for interruption level -->
|
||||||
|
<string name="zen_mode_interruptions_voice_header">When calls and notifications arrive</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Prompt read for interruption type -->
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Prompt read for interruption type -->
|
||||||
<string name="zen_mode_interruptions_voice_prompt">When would you like to be interrupted?</string>
|
<string name="zen_mode_interruptions_voice_prompt">When would you like to be interrupted?</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Prompt read for zen mode duration -->
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Prompt read for zen mode duration -->
|
||||||
<string name="zen_mode_duration_voice_prompt">For how long?</string>
|
<string name="zen_mode_duration_voice_prompt">For how long?</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=80] Zen mode voice: All interruptions -->
|
||||||
|
<string name="zen_mode_option_voice_all_interruptions">Always interrupt</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for all interriuptions -->
|
||||||
|
<string name="zen_mode_option_voice_all_interruptions_synonyms">off,all,everything</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=80] Zen mode voice: Important interruptions -->
|
||||||
|
<string name="zen_mode_option_voice_important_interruptions">Allow only priority interruptions</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for important interriuptions -->
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for important interriuptions -->
|
||||||
<string name="zen_mode_option_important_voice_synonyms">important,priority,priority notifications</string>
|
<string name="zen_mode_option_voice_important_synonyms">important,priority,priority notifications</string>
|
||||||
|
|
||||||
|
<!-- [CHAR LIMIT=80] Zen mode voice option: Alarms only -->
|
||||||
|
<string name="zen_mode_option_voice_alarms">Allow only alarms</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for alarm interriuptions -->
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for alarm interriuptions -->
|
||||||
<string name="zen_mode_option_alarms_voice_synonyms">alarms</string>
|
<string name="zen_mode_option_voice_alarms_synonyms">alarms</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=60] Zen mode voice: Off [CHAR LIMIT=60] -->
|
<!-- [CHAR LIMIT=80] Zen mode voice: No interruptions [CHAR LIMIT=60] -->
|
||||||
<string name="zen_mode_option_off">Off</string>
|
<string name="zen_mode_option_voice_no_interruptions">Don\'t interrupt</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for off interriuptions -->
|
|
||||||
<string name="zen_mode_option_off_voice_synonyms">off,all,everything</string>
|
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for no interriuptions -->
|
<!-- [CHAR LIMIT=NONE] Zen mode voice: Comma delimited synonyms for no interriuptions -->
|
||||||
<string name="zen_mode_option_no_interruptions_voice_synonyms">none,nothing,no interruptions</string>
|
<string name="zen_mode_option_voice_no_interruptions_synonyms">none,nothing,no interruptions</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=40] Zen mode voice: Label for indefinite mode duration -->
|
<!-- [CHAR LIMIT=40] Zen mode voice: Label for indefinite mode duration -->
|
||||||
<string name="zen_mode_duration_indefinte_voice_label">Indefinitely</string>
|
<string name="zen_mode_duration_indefinte_voice_label">Indefinitely</string>
|
||||||
|
@@ -65,22 +65,24 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
|
|||||||
boolean enabled = intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false);
|
boolean enabled = intent.getBooleanExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED, false);
|
||||||
boolean specified = intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED);
|
boolean specified = intent.hasExtra(EXTRA_DO_NOT_DISTURB_MODE_ENABLED);
|
||||||
|
|
||||||
|
setHeader(getString(R.string.zen_mode_interruptions_voice_header));
|
||||||
|
|
||||||
List<VoiceSelection> states = new ArrayList<VoiceSelection>();
|
List<VoiceSelection> states = new ArrayList<VoiceSelection>();
|
||||||
if (!specified || enabled) {
|
if (!specified || enabled) {
|
||||||
states.add(new ModeSelection(this, Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
|
states.add(new ModeSelection(this, Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
|
||||||
R.string.zen_mode_option_important_interruptions,
|
R.string.zen_mode_option_voice_important_interruptions,
|
||||||
R.string.zen_mode_option_important_voice_synonyms));
|
R.string.zen_mode_option_voice_important_synonyms));
|
||||||
states.add(new ModeSelection(this, Global.ZEN_MODE_ALARMS,
|
states.add(new ModeSelection(this, Global.ZEN_MODE_ALARMS,
|
||||||
R.string.zen_mode_option_alarms,
|
R.string.zen_mode_option_voice_alarms,
|
||||||
R.string.zen_mode_option_alarms_voice_synonyms));
|
R.string.zen_mode_option_voice_alarms_synonyms));
|
||||||
states.add(new ModeSelection(this, Global.ZEN_MODE_NO_INTERRUPTIONS,
|
states.add(new ModeSelection(this, Global.ZEN_MODE_NO_INTERRUPTIONS,
|
||||||
R.string.zen_mode_option_no_interruptions,
|
R.string.zen_mode_option_voice_no_interruptions,
|
||||||
R.string.zen_mode_option_no_interruptions_voice_synonyms));
|
R.string.zen_mode_option_voice_no_interruptions_synonyms));
|
||||||
}
|
}
|
||||||
if (!specified || !enabled) {
|
if (!specified || !enabled) {
|
||||||
states.add(new ModeSelection(this, Global.ZEN_MODE_OFF,
|
states.add(new ModeSelection(this, Global.ZEN_MODE_OFF,
|
||||||
R.string.zen_mode_option_off,
|
R.string.zen_mode_option_voice_all_interruptions,
|
||||||
R.string.zen_mode_option_off_voice_synonyms));
|
R.string.zen_mode_option_voice_all_interruptions_synonyms));
|
||||||
}
|
}
|
||||||
VoiceSelectionFragment fragment = new VoiceSelectionFragment();
|
VoiceSelectionFragment fragment = new VoiceSelectionFragment();
|
||||||
fragment.setArguments(VoiceSelectionFragment.createArguments(
|
fragment.setArguments(VoiceSelectionFragment.createArguments(
|
||||||
@@ -98,8 +100,10 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
|
|||||||
pickDuration(selection.getLabel(), mode);
|
pickDuration(selection.getLabel(), mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setZenModeConfig(mode, conditionSelection.mCondition);
|
||||||
|
} else {
|
||||||
|
setZenModeConfig(Global.ZEN_MODE_OFF, null);
|
||||||
}
|
}
|
||||||
setZenModeConfig(mode, conditionSelection.mCondition);
|
|
||||||
notifySuccess(getChangeSummary(mode, conditionSelection));
|
notifySuccess(getChangeSummary(mode, conditionSelection));
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -112,6 +116,8 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
|
|||||||
*/
|
*/
|
||||||
private void pickDuration(CharSequence label, final int mode) {
|
private void pickDuration(CharSequence label, final int mode) {
|
||||||
setTitle(label.toString());
|
setTitle(label.toString());
|
||||||
|
setHeader(null);
|
||||||
|
|
||||||
List<VoiceSelection> states = new ArrayList<VoiceSelection>();
|
List<VoiceSelection> states = new ArrayList<VoiceSelection>();
|
||||||
states.add(new ConditionSelection(null, -1,
|
states.add(new ConditionSelection(null, -1,
|
||||||
getString(R.string.zen_mode_duration_indefinte_voice_label),
|
getString(R.string.zen_mode_duration_indefinte_voice_label),
|
||||||
@@ -137,13 +143,6 @@ public class ZenModeVoiceActivity extends VoiceSettingsActivity {
|
|||||||
showFragment(fragment, "pick_duration_fragment");
|
showFragment(fragment, "pick_duration_fragment");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showFragment(Fragment fragment, String tag) {
|
|
||||||
getFragmentManager()
|
|
||||||
.beginTransaction()
|
|
||||||
.replace(R.id.fragment_root, fragment, tag)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setZenModeConfig(int mode, Condition condition) {
|
private void setZenModeConfig(int mode, Condition condition) {
|
||||||
if (condition != null) {
|
if (condition != null) {
|
||||||
NotificationManager.from(this).setZenMode(mode, condition.id, TAG);
|
NotificationManager.from(this).setZenMode(mode, condition.id, TAG);
|
||||||
|
@@ -111,7 +111,7 @@ public class VoiceSelectionFragment extends ListFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mOnItemSelectedListener != null) {
|
if (mOnItemSelectedListener != null) {
|
||||||
mOnItemSelectedListener.onItemSelected(position, getSelectionAt(position));
|
mOnItemSelectedListener.onItemSelected(position, getSelectionAt(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,11 +16,16 @@
|
|||||||
|
|
||||||
package com.android.settings.utils;
|
package com.android.settings.utils;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Fragment;
|
||||||
import android.app.VoiceInteractor;
|
import android.app.VoiceInteractor;
|
||||||
import android.app.VoiceInteractor.CompleteVoiceRequest;
|
import android.app.VoiceInteractor.CompleteVoiceRequest;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,10 +70,30 @@ abstract public class VoiceSettingsActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Indicates when the setting could not be changed.
|
||||||
*/
|
*/
|
||||||
protected void notifyFailure(String reason) {
|
protected void notifyFailure(String reason) {
|
||||||
getVoiceInteractor().submitRequest(new VoiceInteractor.AbortVoiceRequest(reason, null));
|
getVoiceInteractor().submitRequest(new VoiceInteractor.AbortVoiceRequest(reason, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void showFragment(Fragment fragment, String tag) {
|
||||||
|
getFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.replace(R.id.voice_fragment_root, fragment, tag)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user