Merge "Update button styles for fingerprint" into nyc-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 29a7495..3a3f567 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1746,11 +1746,9 @@
<activity android:name=".EncryptionInterstitial"
android:theme="@style/SetupWizardTheme.Light" />
- <!-- Runs in the phone process since it needs access to the Phone object -->
<activity android:name=".Settings$StatusActivity"
android:label="@string/device_status_activity_title"
- android:theme="@style/Theme.SubSettingsDialogWhenLarge"
- android:process="com.android.phone">
+ android:theme="@style/Theme.SubSettingsDialogWhenLarge">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -2923,7 +2921,7 @@
<activity android:name="Settings$GestureSettingsActivity"
android:label="@string/gesture_preference_title"
android:icon="@drawable/ic_settings_gestures"
- android:taskAffinity="">
+ android:enabled="@bool/config_gesture_settings_enabled">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.android.settings.SHORTCUT" />
@@ -2935,6 +2933,8 @@
android:value="com.android.settings.category.device" />
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.gestures.GestureSettings" />
+ <meta-data android:name="com.android.settings.summary"
+ android:resource="@string/gesture_preference_summary" />
</activity>
<activity android:name="BackupSettingsActivity"
diff --git a/proguard.flags b/proguard.flags
index f3c218a..040fa6c 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -20,6 +20,7 @@
-keep class com.android.settings.overlay.FeatureFactoryImpl
-keep class com.android.settings.accessibility.*FragmentForSetupWizard
-keep class com.android.settings.display.*FragmentForSetupWizard
+-keep class com.android.settings.display.NightDisplaySettings
# Keep click responders
-keepclassmembers class com.android.settings.inputmethod.UserDictionaryAddWordActivity {
diff --git a/res/layout/device_profiles_settings.xml b/res/layout/device_profiles_settings.xml
index bd78bea..260fa05 100644
--- a/res/layout/device_profiles_settings.xml
+++ b/res/layout/device_profiles_settings.xml
@@ -14,48 +14,56 @@
limitations under the License.
-->
-<LinearLayout
+<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="25dp"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/bluetooth_preference_paired_dialog_name_label"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary"
- android:textDirection="locale"
- android:paddingTop="16dp"
- style="@style/bt_item_label" />
-
- <EditText
- android:id="@+id/name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:inputType="textNoSuggestions"
- android:maxLength="@integer/bluetooth_name_length"
- android:singleLine="true"
- android:paddingBottom="@dimen/bluetooth_dialog_padding"
- android:textDirection="locale"
- style="@style/bt_item_edit_content" />
-
- <TextView
- android:id="@+id/profiles_label"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="16dp"
- android:paddingBottom="4dp"
- android:text="@string/bluetooth_device_advanced_profile_header_title"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
- android:textColor="?android:attr/textColorSecondary" />
+ android:paddingEnd="25dp">
<LinearLayout
- android:id="@+id/profiles_section"
- android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
-</LinearLayout>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/bluetooth_preference_paired_dialog_name_label"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textDirection="locale"
+ android:paddingTop="16dp"
+ style="@style/bt_item_label"/>
+
+ <EditText
+ android:id="@+id/name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"
+ android:maxLength="@integer/bluetooth_name_length"
+ android:singleLine="true"
+ android:paddingBottom="@dimen/bluetooth_dialog_padding"
+ android:textDirection="locale"
+ style="@style/bt_item_edit_content"/>
+
+ <TextView
+ android:id="@+id/profiles_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="4dp"
+ android:text="@string/bluetooth_device_advanced_profile_header_title"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textColor="?android:attr/textColorSecondary"/>
+
+
+ <LinearLayout
+ android:id="@+id/profiles_section"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ </LinearLayout>
+
+</ScrollView>
diff --git a/res/layout/gesture_preference.xml b/res/layout/gesture_preference.xml
index 71fe86f..2f593fe 100644
--- a/res/layout/gesture_preference.xml
+++ b/res/layout/gesture_preference.xml
@@ -57,11 +57,12 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:orientation="horizontal">
- <FrameLayout
+ <com.android.settings.widget.AspectRatioFrameLayout
android:id="@+id/gesture_animation_frame"
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="1">
+ android:layout_weight="1"
+ android:padding="@dimen/gesture_animation_padding">
<TextureView
android:id="@+id/gesture_video"
@@ -73,7 +74,7 @@
android:id="@+id/gesture_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="gone"/>
+ android:background="@color/gestures_setting_background_color"/>
<ImageView
android:id="@+id/gesture_play_button"
@@ -81,10 +82,9 @@
android:layout_height="@dimen/gestures_play_button_size"
android:src="@drawable/ic_gesture_play_button"
android:gravity="center"
- android:layout_gravity="center"
- android:visibility="gone"/>
+ android:layout_gravity="center"/>
- </FrameLayout>
+ </com.android.settings.widget.AspectRatioFrameLayout>
<TextView
android:id="@android:id/summary"
diff --git a/res/layout/support_tile.xml b/res/layout/support_tile.xml
index 5f7ced4..053f748 100644
--- a/res/layout/support_tile.xml
+++ b/res/layout/support_tile.xml
@@ -21,7 +21,7 @@
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
- android:minHeight="@dimen/dashboard_tile_minimum_height"
+ android:minHeight="@dimen/support_tile_min_height"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
diff --git a/res/layout/support_tile_spacer.xml b/res/layout/support_tile_spacer.xml
new file mode 100644
index 0000000..95aea0b
--- /dev/null
+++ b/res/layout/support_tile_spacer.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 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.
+-->
+
+<Space
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/support_spacer_height"
+ android:background="@color/card_background"/>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index f18b34b..749a4e9 100755
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -34,4 +34,8 @@
<!-- Display, Screen zoom -->
<dimen name="screen_zoom_preview_height">160dp</dimen>
+
+ <!-- Gestures -->
+ <dimen name="gesture_animation_padding">35dp</dimen>
+
</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 8fb61dd..218d7f2 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -141,4 +141,9 @@
<attr name="animation" format="reference" />
</declare-styleable>
+ <!-- For AspectRatioFrameLayout -->
+ <declare-styleable name="AspectRatioFrameLayout">
+ <attr name="aspectRatio" format="float" />
+ </declare-styleable>
+
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index c5cc341..c8ea171 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -46,5 +46,13 @@
<string name="config_wallpaper_picker_class" translatable="false">com.android.settings.Settings$WallpaperSettingsActivity</string>
<!-- Backup settings to launch -->
- <string name="config_backup_settings_intent"></string>
+ <string name="config_backup_settings_intent" translatable="false"></string>
+
+ <!-- Double twist sensor name and vendor used by gesture setting -->
+ <string name="gesture_double_twist_sensor_name" translatable="false"></string>
+ <string name="gesture_double_twist_sensor_vendor" translatable="false"></string>
+
+ <!-- When true enable gesture setting. -->
+ <bool name="config_gesture_settings_enabled">false</bool>
+
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 9a97d30..b2d0570 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -299,4 +299,10 @@
<!-- Padding for Gestures settings screen -->
<dimen name="gestures_settings_padding_top_bottom">20dp</dimen>
<dimen name="gestures_play_button_size">36dp</dimen>
+ <dimen name="gesture_animation_padding">0dp</dimen>
+
+ <!-- Support tile minimum height -->
+ <dimen name="support_tile_min_height">48dp</dimen>
+ <!-- support spacer layout height -->
+ <dimen name="support_spacer_height">8dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5073893..ab4a9ab 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2133,6 +2133,39 @@
<!-- Sound & display settings screen, setting option summary to enable adaptive brightness [CHAR LIMIT=100] -->
<string name="auto_brightness_summary">Optimize brightness level for available light</string>
+ <!-- Night display screen, setting option name to enable night display. [CHAR LIMIT=30] -->
+ <string name="night_display_title">Night display</string>
+ <!-- Night display screen, description of night display feature. [CHAR LIMIT=NONE] -->
+ <string name="night_display_text">Night display tints your screen red at night. This makes it easier to look at your screen in dim light and may help you fall asleep more easily.</string>
+ <!-- Night display screen, setting option name to configure whether night display turn on/off automatically. [CHAR LIMIT=30] -->
+ <string name="night_display_auto_mode_title">Turn on automatically</string>
+ <!-- Night display screen, setting option value for night display to *never* turn on/off automatically. [CHAR LIMIT=30] -->
+ <string name="night_display_auto_mode_never">Never</string>
+ <!-- Night display screen, setting option value for night display to turn on/off automatically according to a user defined schedule. [CHAR LIMIT=30] -->
+ <string name="night_display_auto_mode_custom">Custom schedule</string>
+ <!-- Night display screen, setting option value for night display to turn on/off automatically at sunset/sunrise. [CHAR LIMIT=30] -->
+ <string name="night_display_auto_mode_twilight">Sunset to sunrise</string>
+ <!-- Night display screen, setting option name to configure time to automatically turn on night display. [CHAR LIMIT=30] -->
+ <string name="night_display_start_time_title">Start time</string>
+ <!-- Night display screen, setting option name to configure time to automatically turn off night display. [CHAR LIMIT=30] -->
+ <string name="night_display_end_time_title">End time</string>
+ <!-- Display settings screen, summary format of night display when off. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_off">Off / <xliff:g name="auto_mode_summary" example="Never turn on automatically">%1$s</xliff:g></string>
+ <!-- Display settings screen, summary of night display when off and will *never* turn on automatically. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_off_auto_mode_never">Never turn on automatically</string>
+ <!-- Display settings screen, summary format of night display when off and will turn on automatically at a user defined time. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_off_auto_mode_custom">Turn on automatically at <xliff:g name="time" example="6 AM">%1$s</xliff:g></string>
+ <!-- Display settings screen, summary of night display when off and will turn on automatically at sunset. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_off_auto_mode_twilight">Turn on automatically at sunset</string>
+ <!-- Display settings screen, summary format of night display when on. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_on">On / <xliff:g name="auto_mode_summary" example="Never turn off automatically">%1$s</xliff:g></string>
+ <!-- Display settings screen, summary of night display when on and will *never* turn off automatically. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_on_auto_mode_never">Never turn off automatically</string>
+ <!-- Display settings screen, summary format of night display when on and will turn off automatically at a user defined time. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_on_auto_mode_custom">Turn off automatically at <xliff:g name="time" example="10 PM">%1$s</xliff:g></string>
+ <!-- Display settings screen, summary of night display when on and will turn off automatically at sunrise. [CHAR LIMIT=NONE] -->
+ <string name="night_display_summary_on_auto_mode_twilight">Turn off automatically at sunrise</string>
+
<!-- Sound & display settings screen, setting option name to change screen timeout -->
<string name="screen_timeout">Sleep</string>
<!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] -->
@@ -5825,6 +5858,7 @@
<string name="keywords_display">screen, touchscreen</string>
<string name="keywords_display_brightness_level">dim screen, touchscreen, battery</string>
<string name="keywords_display_auto_brightness">dim screen, touchscreen, battery</string>
+ <string name="keywords_display_night_display">dim screen, night, tint</string>
<string name="keywords_display_wallpaper">background, personalize, customize display</string>
<string name="keywords_display_font_size">text size</string>
<string name="keywords_display_cast_screen">project, cast</string>
@@ -7465,13 +7499,10 @@
<string name="button_confirm_convert_fbe">Wipe and convert</string>
<!-- Reset rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
- <string name="reset_shortcut_manager_throttling">Reset ShortcutManager rate-limiting counters</string>
+ <string name="reset_shortcut_manager_throttling">Reset ShortcutManager rate-limiting</string>
- <!-- Title of the dialog box to confirm resetting rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
- <string name="confirm_reset_shortcut_manager_throttling_title">Reset ShortcutManager rate-limiting?</string>
-
- <!-- Message of the dialog box to confirm resetting rate-limiting in the system service ShortcutManager. [CHAR_LIMIT=none] -->
- <string name="confirm_reset_shortcut_manager_throttling_message">Reset ShortcutManager rate-limiting counters?</string>
+ <!-- Toast message shown when "Reset ShortcutManager rate-limiting" has been performed. [CHAR_LIMIT=none] -->
+ <string name="reset_shortcut_manager_throttling_complete">ShortcutManager rate-limiting has been reset</string>
<!-- Title of notification suggestion during optional steps of setup. [CHAR_LIMIT=60] -->
<string name="notification_suggestion_title">Control lock screen notifications</string>
@@ -7516,7 +7547,10 @@
<string name="support_escalation_24_7_summary">Our support team is available all day, every day</string>
<!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
- <string name="support_escalation_closed_summary">Phone support hours (local time)<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
+ <string name="support_escalation_closed_summary">Search help or come back during support hours (local time):<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
+
+ <!-- Summary text to call customer support when there is no internet. [CHAR LIMIT=NONE]-->
+ <string name="support_escalation_no_internet_summary">Phone support hours (local time)<br><b><xliff:g id="operation_hours">%s</xliff:g></b></string>
<!-- Summary text when customer support is unavailable in the region. [CHAR LIMIT=NONE]-->
<string name="support_escalation_unavailable_summary">Search help or explore tips & tricks</string>
@@ -7538,7 +7572,7 @@
</string>
<!-- Title text for a list of international support phone numbers. [CHAR LIMIT=60]-->
- <string name="support_international_phone_title">Traveling aboard?</string>
+ <string name="support_international_phone_title">Traveling abroad?</string>
<!-- Description text warning international phone charge may apply when dialing support numbers. [CHAR LIMIT=NONE]-->
<string name="support_international_phone_summary">International charges may apply</string>
@@ -7649,29 +7683,32 @@
<!-- Preference title for gesture settings [CHAR LIMIT=25]-->
<string name="gesture_preference_title">Gestures</string>
+ <!-- Preference summary for gesture settings [CHAR LIMIT=NONE]-->
+ <string name="gesture_preference_summary">Quick gestures to control your phone</string>
+
<!-- Title text for double tap power for camera [CHAR LIMIT=60]-->
<string name="double_tap_power_for_camera_title">Jump to Camera</string>
<!-- Summary text for double tap power for camera [CHAR LIMIT=160]-->
- <string name="double_tap_power_for_camera_summary">To quickly open camera, just double-tap the power button. Works from any screen.</string>
+ <string name="double_tap_power_for_camera_summary">To quickly open camera, just double-tap the power button. Works from any screen</string>
<!-- Title text for double twist for camera mode [CHAR LIMIT=60]-->
<string name="double_twist_for_camera_mode_title">Flip camera</string>
<!-- Summary text for double twist for camera mode [CHAR LIMIT=160]-->
- <string name="double_twist_for_camera_mode_summary">To switch between front and back cameras, double-twist.</string>
+ <string name="double_twist_for_camera_mode_summary">To switch between front and back cameras, double-twist</string>
<!-- Title text for ambient display [CHAR LIMIT=60]-->
<string name="ambient_display_title">Quick screen check</string>
<!-- Summary text for ambient display [CHAR LIMIT=160]-->
- <string name="ambient_display_summary">To check your phone without waking it up fully, nudge or pick it up.</string>
+ <string name="ambient_display_summary">To check your phone without waking it up, double-tap the screen or raise the device</string>
<!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
<!-- Summary text for fingerprint swipe for notifications [CHAR LIMIT=160]-->
- <string name="fingerprint_swipe_for_notifications_summary">To check your notifications from any screen, swipe down on the fingerprint sensor.</string>
+ <string name="fingerprint_swipe_for_notifications_summary">To check your notifications from any screen, swipe down on the fingerprint sensor</string>
<!-- Switch text for each gesture setting state -->
<string name="gesture_setting_on">On</string>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 29363ad..2288520 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -372,6 +372,10 @@
android:key="force_resizable_activities"
android:title="@string/force_resizable_activities"
android:summary="@string/force_resizable_activities_summary"/>
+
+ <Preference
+ android:key="reset_shortcut_manager_throttling"
+ android:title="@string/reset_shortcut_manager_throttling" />
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml
index 74f873b..3d57fc1 100644
--- a/res/xml/device_info_settings.xml
+++ b/res/xml/device_info_settings.xml
@@ -35,10 +35,8 @@
<!-- Device status - launches activity -->
<PreferenceScreen android:key="status_info"
android:title="@string/device_status"
- android:summary="@string/device_status_summary">
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.Settings$StatusActivity" />
+ android:summary="@string/device_status_summary"
+ android:fragment="com.android.settings.deviceinfo.Status">
</PreferenceScreen>
<!-- Manual -->
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index cb1fac5..0630b55 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -32,6 +32,12 @@
settings:keywords="@string/keywords_display_auto_brightness"
android:summary="@string/auto_brightness_summary" />
+ <com.android.settings.display.NightDisplayPreference
+ android:key="night_display"
+ android:title="@string/night_display_title"
+ android:fragment="com.android.settings.display.NightDisplaySettings"
+ settings:keywords="@string/keywords_display_night_display" />
+
<!-- Hide night mode for now
<ListPreference
android:key="night_mode"
@@ -75,9 +81,9 @@
<PreferenceScreen
android:key="doze"
android:title="@string/doze_title"
- android:summary="@string/doze_summary"
+ android:summary="@string/ambient_display_summary"
android:fragment="com.android.settings.gestures.GestureSettings" >
- <extra android:name=":settings:fragment_args_key"
+ <extra android:name="gesture_scroll_to_preference"
android:value="gesture_pick_up_and_nudge" />
</PreferenceScreen>
diff --git a/res/xml/gesture_settings.xml b/res/xml/gesture_settings.xml
index 5adc311..78f65a6 100644
--- a/res/xml/gesture_settings.xml
+++ b/res/xml/gesture_settings.xml
@@ -41,6 +41,6 @@
android:key="gesture_pick_up_and_nudge"
android:title="@string/ambient_display_title"
android:summary="@string/ambient_display_summary"
- settings:animation="@raw/gesture_ambient_move_lift"/>
+ settings:animation="@raw/gesture_ambient_tap"/>
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/night_display_settings.xml b/res/xml/night_display_settings.xml
new file mode 100644
index 0000000..531f606
--- /dev/null
+++ b/res/xml/night_display_settings.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 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.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/night_display_title">
+
+ <DropDownPreference
+ android:key="night_display_auto_mode"
+ android:title="@string/night_display_auto_mode_title"
+ android:persistent="false"
+ android:summary="%s" />
+
+ <Preference
+ android:key="night_display_start_time"
+ android:title="@string/night_display_start_time_title" />
+
+ <Preference
+ android:key="night_display_end_time"
+ android:title="@string/night_display_end_time_title" />
+
+ <com.android.settings.fuelgauge.WallOfTextPreference
+ android:summary="@string/night_display_text"
+ android:selectable="false"
+ settings:allowDividerAbove="true" />
+
+</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
index 5a8960c..801f008 100644
--- a/src/com/android/settings/ChooseLockPassword.java
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -290,10 +290,7 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- GlifLayout layout = (GlifLayout) inflater.inflate(
- R.layout.choose_lock_password, container, false);
- layout.setHeaderText(getActivity().getTitle());
- return layout;
+ return inflater.inflate(R.layout.choose_lock_password, container, false);
}
@Override
@@ -365,6 +362,7 @@
: R.string.lockpassword_choose_your_pin_header;
CharSequence title = getText(id);
sa.setTitle(title);
+ ((GlifLayout) view).setHeaderText(title);
}
}
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 934e752..db6a373b 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -1911,7 +1911,7 @@
} else if (preference == mWebViewMultiprocess) {
writeWebViewMultiprocessOptions();
} else if (SHORTCUT_MANAGER_RESET_KEY.equals(preference.getKey())) {
- confirmResetShortcutManagerThrottling();
+ resetShortcutManagerThrottling();
} else {
return super.onPreferenceTreeClick(preference);
}
@@ -2153,30 +2153,18 @@
}
};
- private void confirmResetShortcutManagerThrottling() {
+ private void resetShortcutManagerThrottling() {
final IShortcutService service = IShortcutService.Stub.asInterface(
ServiceManager.getService(Context.SHORTCUT_SERVICE));
-
- DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (which == DialogInterface.BUTTON_POSITIVE) {
- try {
- service.resetThrottling();
- } catch (RemoteException e) {
- }
- }
+ if (service != null) {
+ try {
+ service.resetThrottling();
+ Toast.makeText(getActivity(), R.string.reset_shortcut_manager_throttling_complete,
+ Toast.LENGTH_SHORT).show();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to reset rate limiting", e);
}
- };
-
- new AlertDialog.Builder(getActivity())
- .setTitle(R.string.confirm_reset_shortcut_manager_throttling_title)
- .setMessage(R.string.confirm_reset_shortcut_manager_throttling_message)
- .setPositiveButton(R.string.okay, onClickListener)
- .setNegativeButton(android.R.string.cancel, null)
- .create()
- .show();
-
+ }
}
private void updateOemUnlockSettingDescription() {
diff --git a/src/com/android/settings/DeviceInfoSettings.java b/src/com/android/settings/DeviceInfoSettings.java
index dd8064f..7befbc2 100644
--- a/src/com/android/settings/DeviceInfoSettings.java
+++ b/src/com/android/settings/DeviceInfoSettings.java
@@ -32,6 +32,8 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
@@ -377,17 +379,39 @@
private final Context mContext;
private final SummaryLoader mSummaryLoader;
+ private final SubscriptionManager mSubscriptionManager;
+ private final SubscriptionChangeListener mSubscriptionChangeListener;
public SummaryProvider(Context context, SummaryLoader summaryLoader) {
mContext = context;
mSummaryLoader = summaryLoader;
+ mSubscriptionManager = SubscriptionManager.from(mContext);
+ mSubscriptionChangeListener = new SubscriptionChangeListener();
}
@Override
public void setListening(boolean listening) {
if (listening) {
- mSummaryLoader.setSummary(this, mContext.getString(R.string.about_summary,
- Build.VERSION.RELEASE));
+ updateSummary();
+ mSubscriptionManager.addOnSubscriptionsChangedListener(mSubscriptionChangeListener);
+ } else {
+ mSubscriptionManager.removeOnSubscriptionsChangedListener(
+ mSubscriptionChangeListener);
+ }
+ }
+
+ private void updateSummary() {
+ final String formattedPhoneNumbers = DeviceInfoUtils.getFormattedPhoneNumbers(
+ mContext, mSubscriptionManager.getActiveSubscriptionInfoList());
+ mSummaryLoader.setSummary(SummaryProvider.this, formattedPhoneNumbers);
+ }
+
+ private final class SubscriptionChangeListener
+ extends SubscriptionManager.OnSubscriptionsChangedListener {
+
+ @Override
+ public void onSubscriptionsChanged() {
+ updateSummary();
}
}
}
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index bb10570..2821eb2 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -44,6 +44,7 @@
import android.text.TextUtils;
import android.util.Log;
+import com.android.internal.app.NightDisplayController;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.view.RotationPolicy;
@@ -83,6 +84,7 @@
private static final String KEY_TAP_TO_WAKE = "tap_to_wake";
private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
private static final String KEY_AUTO_ROTATE = "auto_rotate";
+ private static final String KEY_NIGHT_DISPLAY = "night_display";
private static final String KEY_NIGHT_MODE = "night_mode";
private static final String KEY_CAMERA_GESTURE = "camera_gesture";
private static final String KEY_WALLPAPER = "wallpaper";
@@ -129,6 +131,10 @@
removePreference(KEY_AUTO_BRIGHTNESS);
}
+ if (!NightDisplayController.isAvailable(activity)) {
+ removePreference(KEY_NIGHT_DISPLAY);
+ }
+
if (isLiftToWakeAvailable(activity)) {
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
mLiftToWakePreference.setOnPreferenceChangeListener(this);
@@ -496,6 +502,9 @@
if (!isAutomaticBrightnessAvailable(context.getResources())) {
result.add(KEY_AUTO_BRIGHTNESS);
}
+ if (!NightDisplayController.isAvailable(context)) {
+ result.add(KEY_NIGHT_DISPLAY);
+ }
if (!isLiftToWakeAvailable(context)) {
result.add(KEY_LIFT_TO_WAKE);
}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 8cc9085..616cf8e 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -68,8 +68,8 @@
import com.android.settings.applications.ProcessStatsSummary;
import com.android.settings.applications.ProcessStatsUi;
import com.android.settings.applications.UsageAccessDetails;
-import com.android.settings.applications.WriteSettingsDetails;
import com.android.settings.applications.VrListenerSettings;
+import com.android.settings.applications.WriteSettingsDetails;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.dashboard.DashboardContainerFragment;
import com.android.settings.dashboard.SearchResultsSummary;
@@ -109,7 +109,6 @@
import com.android.settings.notification.ZenModeScheduleRuleSettings;
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment;
import com.android.settings.qstile.DevelopmentTiles;
@@ -695,6 +694,13 @@
+ " ms");
}
+ public void setDisplaySearchMenu(boolean displaySearch) {
+ if (displaySearch != mDisplaySearch) {
+ mDisplaySearch = displaySearch;
+ invalidateOptionsMenu();
+ }
+ }
+
private void setTitleFromIntent(Intent intent) {
final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
if (initialTitleResId > 0) {
diff --git a/src/com/android/settings/dashboard/DashboardContainerFragment.java b/src/com/android/settings/dashboard/DashboardContainerFragment.java
index b33063d..51c6694 100644
--- a/src/com/android/settings/dashboard/DashboardContainerFragment.java
+++ b/src/com/android/settings/dashboard/DashboardContainerFragment.java
@@ -31,6 +31,7 @@
import com.android.internal.logging.MetricsProto;
import com.android.settings.InstrumentedFragment;
import com.android.settings.R;
+import com.android.settings.SettingsActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SupportFeatureProvider;
import com.android.settings.widget.SlidingTabLayout;
@@ -62,11 +63,10 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
final View content = inflater.inflate(R.layout.dashboard_container, parent, false);
- final Context context = getContext();
mViewPager = (ViewPager) content.findViewById(R.id.pager);
- mPagerAdapter = new DashboardViewPagerAdapter(context, getChildFragmentManager());
+ mPagerAdapter = new DashboardViewPagerAdapter(getContext(), getChildFragmentManager());
mViewPager.setAdapter(mPagerAdapter);
- mViewPager.addOnPageChangeListener(new TabInstrumentationListener(context));
+ mViewPager.addOnPageChangeListener(new TabChangeListener((SettingsActivity) getActivity()));
mHeaderView = inflater.inflate(R.layout.dashboard_container_header, parent, false);
((SlidingTabLayout) mHeaderView).setViewPager(mViewPager);
return content;
@@ -127,13 +127,13 @@
}
}
- private static final class TabInstrumentationListener
+ private static final class TabChangeListener
implements ViewPager.OnPageChangeListener {
- private final Context mContext;
+ private final SettingsActivity mActivity;
- public TabInstrumentationListener(Context context) {
- mContext = context;
+ public TabChangeListener(SettingsActivity activity) {
+ mActivity = activity;
}
@Override
@@ -150,11 +150,14 @@
public void onPageSelected(int position) {
switch (position) {
case INDEX_SUMMARY_FRAGMENT:
- MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_SELECT_SUMMARY);
+ MetricsLogger.action(
+ mActivity, MetricsProto.MetricsEvent.ACTION_SELECT_SUMMARY);
+ mActivity.setDisplaySearchMenu(true);
break;
case INDEX_SUPPORT_FRAGMENT:
MetricsLogger.action(
- mContext, MetricsProto.MetricsEvent.ACTION_SELECT_SUPPORT_FRAGMENT);
+ mActivity, MetricsProto.MetricsEvent.ACTION_SELECT_SUPPORT_FRAGMENT);
+ mActivity.setDisplaySearchMenu(false);
break;
}
}
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 678226a..52440e9 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -60,6 +60,7 @@
private static final int TYPE_ESCALATION_OPTIONS_OFFLINE =
R.layout.support_offline_escalation_options;
private static final int TYPE_SUPPORT_TILE = R.layout.support_tile;
+ private static final int TYPE_SUPPORT_TILE_SPACER = R.layout.support_tile_spacer;
private static final int TYPE_SIGN_IN_BUTTON = R.layout.support_sign_in_button;
private final Activity mActivity;
@@ -111,6 +112,8 @@
case TYPE_ESCALATION_OPTIONS_OFFLINE:
bindOfflineEscalationOptions(holder, (OfflineEscalationData) data);
break;
+ case TYPE_SUPPORT_TILE_SPACER:
+ break;
default:
bindSupportTile(holder, data);
break;
@@ -198,10 +201,11 @@
builder.setTileTitle(R.string.support_escalation_title)
.setTileSummary(R.string.support_escalation_summary);
} else {
- // Support is not temporarily unavailable.
+ // Support is now temporarily unavailable.
builder.setTileTitle(R.string.support_escalation_title)
.setTileSummary(
- mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null));
+ mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null,
+ true /* hasInternet */));
}
if (hasPhoneOperation) {
builder.setText1(R.string.support_escalation_by_phone)
@@ -218,11 +222,13 @@
private void addOfflineEscalationCards() {
final CharSequence operatingHours;
- if (mSupportFeatureProvider.isAlwaysOperating(PHONE, mSelectedCountry)) {
+ final boolean isPhoneSupportAlwaysOperating =
+ mSupportFeatureProvider.isAlwaysOperating(PHONE, mSelectedCountry);
+ if (isPhoneSupportAlwaysOperating) {
operatingHours = mActivity.getString(R.string.support_escalation_24_7_summary);
} else {
operatingHours = mSupportFeatureProvider.getOperationHours(mActivity,
- PHONE, mSelectedCountry);
+ PHONE, mSelectedCountry, false /* hasInternet */);
}
mSupportData.add(new OfflineEscalationData.Builder(mActivity)
.setCountries(mSupportFeatureProvider.getPhoneSupportCountries())
@@ -230,7 +236,9 @@
mSelectedCountry, true /* isTollFree */))
.setTolledPhone(mSupportFeatureProvider.getSupportPhones(
mSelectedCountry, false /* isTollFree */))
- .setTileTitle(R.string.support_escalation_title)
+ .setTileTitle(isPhoneSupportAlwaysOperating
+ ? R.string.support_escalation_24_7_title
+ : R.string.support_escalation_title)
.setTileSummary(operatingHours)
.build());
}
@@ -245,6 +253,7 @@
}
private void addMoreHelpItems() {
+ mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE_SPACER).build());
mSupportData.add(new SupportData.Builder(mActivity, TYPE_SUPPORT_TILE)
.setIcon(R.drawable.ic_help_24dp)
.setTileTitle(R.string.support_help_feedback_title)
@@ -397,6 +406,8 @@
final SupportPhone phone = mSupportFeatureProvider
.getSupportPhones(mSelectedCountry, true /* isTollFree */);
if (phone != null) {
+ MetricsLogger.action(mActivity,
+ MetricsProto.MetricsEvent.ACTION_SUPPORT_DAIL_TOLLFREE);
mActivity.startActivity(phone.getDialIntent());
}
break;
@@ -406,6 +417,8 @@
.getSupportPhones(mSelectedCountry, false /* isTollFree */);
final SupportPhoneDialogFragment fragment =
SupportPhoneDialogFragment.newInstance(phone);
+ MetricsLogger.action(mActivity,
+ MetricsProto.MetricsEvent.ACTION_SUPPORT_VIEW_TRAVEL_ABROAD_DIALOG);
fragment.show(mActivity.getFragmentManager(),
SupportPhoneDialogFragment.TAG);
break;
diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java
index ba14e13..4569131 100644
--- a/src/com/android/settings/deviceinfo/SimStatus.java
+++ b/src/com/android/settings/deviceinfo/SimStatus.java
@@ -16,9 +16,6 @@
package com.android.settings.deviceinfo;
-import static android.content.Context.CARRIER_CONFIG_SERVICE;
-import static android.content.Context.TELEPHONY_SERVICE;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -32,7 +29,6 @@
import android.support.v7.preference.Preference;
import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastMessage;
-import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
@@ -58,9 +54,13 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
+import com.android.settingslib.DeviceInfoUtils;
import java.util.List;
+import static android.content.Context.CARRIER_CONFIG_SERVICE;
+import static android.content.Context.TELEPHONY_SERVICE;
+
/**
* Display the following information
@@ -393,13 +393,10 @@
mShowICCID = carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
- String rawNumber = mTelephonyManager.getLine1Number(mSir.getSubscriptionId());
- String formattedNumber = null;
- if (!TextUtils.isEmpty(rawNumber)) {
- formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
- }
+
// If formattedNumber is null or empty, it'll display as "Unknown".
- setSummaryText(KEY_PHONE_NUMBER, formattedNumber);
+ setSummaryText(KEY_PHONE_NUMBER,
+ DeviceInfoUtils.getFormattedPhoneNumber(getContext(), mSir));
setSummaryText(KEY_IMEI, mPhone.getImei());
setSummaryText(KEY_IMEI_SV, mPhone.getDeviceSvn());
diff --git a/src/com/android/settings/display/NightDisplayPreference.java b/src/com/android/settings/display/NightDisplayPreference.java
new file mode 100644
index 0000000..73ecf49
--- /dev/null
+++ b/src/com/android/settings/display/NightDisplayPreference.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2016 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.display;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+import android.util.AttributeSet;
+
+import com.android.internal.app.NightDisplayController;
+import com.android.settings.R;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+public class NightDisplayPreference extends Preference implements NightDisplayController.Callback {
+
+ private NightDisplayController mController;
+ private DateFormat mTimeFormatter;
+
+ public NightDisplayPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ mController = new NightDisplayController(context);
+ mTimeFormatter = android.text.format.DateFormat.getTimeFormat(context);
+ mTimeFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ @Override
+ public void onAttached() {
+ super.onAttached();
+
+ // Listen for changes only while attached.
+ mController.setListener(this);
+
+ // Update the summary since the state may have changed while not attached.
+ updateSummary();
+ }
+
+ @Override
+ public void onDetached() {
+ super.onDetached();
+
+ // Stop listening for state changes.
+ mController.setListener(null);
+ }
+
+ private String getFormattedTimeString(NightDisplayController.LocalTime localTime) {
+ final Calendar c = Calendar.getInstance();
+ c.setTimeZone(mTimeFormatter.getTimeZone());
+ c.set(Calendar.HOUR_OF_DAY, localTime.hourOfDay);
+ c.set(Calendar.MINUTE, localTime.minute);
+ c.set(Calendar.SECOND, 0);
+ c.set(Calendar.MILLISECOND, 0);
+ return mTimeFormatter.format(c.getTime());
+ }
+
+ private void updateSummary() {
+ final Context context = getContext();
+
+ final boolean isActivated = mController.isActivated();
+ final int autoMode = mController.getAutoMode();
+
+ final String autoModeSummary;
+ switch (autoMode) {
+ default:
+ case NightDisplayController.AUTO_MODE_DISABLED:
+ autoModeSummary = context.getString(isActivated
+ ? R.string.night_display_summary_on_auto_mode_never
+ : R.string.night_display_summary_off_auto_mode_never);
+ break;
+ case NightDisplayController.AUTO_MODE_CUSTOM:
+ if (isActivated) {
+ autoModeSummary = context.getString(
+ R.string.night_display_summary_on_auto_mode_custom,
+ getFormattedTimeString(mController.getCustomEndTime()));
+ } else {
+ autoModeSummary = context.getString(
+ R.string.night_display_summary_off_auto_mode_custom,
+ getFormattedTimeString(mController.getCustomStartTime()));
+ }
+ break;
+ case NightDisplayController.AUTO_MODE_TWILIGHT:
+ autoModeSummary = context.getString(isActivated
+ ? R.string.night_display_summary_on_auto_mode_twilight
+ : R.string.night_display_summary_off_auto_mode_twilight);
+ break;
+ }
+
+ final int summaryFormatResId = isActivated ? R.string.night_display_summary_on
+ : R.string.night_display_summary_off;
+ setSummary(context.getString(summaryFormatResId, autoModeSummary));
+ }
+
+ @Override
+ public void onActivated(boolean activated) {
+ updateSummary();
+ }
+
+ @Override
+ public void onAutoModeChanged(int autoMode) {
+ updateSummary();
+ }
+
+ @Override
+ public void onCustomStartTimeChanged(NightDisplayController.LocalTime startTime) {
+ updateSummary();
+ }
+
+ @Override
+ public void onCustomEndTimeChanged(NightDisplayController.LocalTime endTime) {
+ updateSummary();
+ }
+}
diff --git a/src/com/android/settings/display/NightDisplaySettings.java b/src/com/android/settings/display/NightDisplaySettings.java
new file mode 100644
index 0000000..ecba527
--- /dev/null
+++ b/src/com/android/settings/display/NightDisplaySettings.java
@@ -0,0 +1,226 @@
+/**
+ * Copyright (C) 2016 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.display;
+
+import android.app.Dialog;
+import android.app.TimePickerDialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.preference.DropDownPreference;
+import android.support.v7.preference.Preference;
+import android.widget.Switch;
+import android.widget.TimePicker;
+
+import com.android.internal.app.NightDisplayController;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.widget.SwitchBar;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+/**
+ * Settings screen for Night display.
+ */
+public class NightDisplaySettings extends SettingsPreferenceFragment implements
+ NightDisplayController.Callback,
+ Preference.OnPreferenceChangeListener,
+ SwitchBar.OnSwitchChangeListener {
+
+ private static final String KEY_NIGHT_DISPLAY_AUTO_MODE = "night_display_auto_mode";
+ private static final String KEY_NIGHT_DISPLAY_START_TIME = "night_display_start_time";
+ private static final String KEY_NIGHT_DISPLAY_END_TIME = "night_display_end_time";
+
+ private static final int DIALOG_START_TIME = 0;
+ private static final int DIALOG_END_TIME = 1;
+
+ private NightDisplayController mController;
+ private DateFormat mTimeFormatter;
+
+ private DropDownPreference mAutoModePreference;
+ private Preference mStartTimePreference;
+ private Preference mEndTimePreference;
+
+ private SwitchBar mSwitchBar;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Context context = getContext();
+ mController = new NightDisplayController(context);
+
+ mTimeFormatter = android.text.format.DateFormat.getTimeFormat(context);
+ mTimeFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ super.onCreatePreferences(savedInstanceState, rootKey);
+
+ // Load the preferences from xml.
+ addPreferencesFromResource(R.xml.night_display_settings);
+
+ mAutoModePreference = (DropDownPreference) findPreference(KEY_NIGHT_DISPLAY_AUTO_MODE);
+ mStartTimePreference = findPreference(KEY_NIGHT_DISPLAY_START_TIME);
+ mEndTimePreference = findPreference(KEY_NIGHT_DISPLAY_END_TIME);
+
+ mAutoModePreference.setEntries(new CharSequence[] {
+ getString(R.string.night_display_auto_mode_never),
+ getString(R.string.night_display_auto_mode_custom),
+ getString(R.string.night_display_auto_mode_twilight)
+ });
+ mAutoModePreference.setEntryValues(new CharSequence[] {
+ String.valueOf(NightDisplayController.AUTO_MODE_DISABLED),
+ String.valueOf(NightDisplayController.AUTO_MODE_CUSTOM),
+ String.valueOf(NightDisplayController.AUTO_MODE_TWILIGHT)
+ });
+ mAutoModePreference.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ mSwitchBar = ((SettingsActivity) getActivity()).getSwitchBar();
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+
+ // Listen for changes only while visible.
+ mController.setListener(this);
+
+ // Update the current state since it have changed while not visible.
+ onActivated(mController.isActivated());
+ onAutoModeChanged(mController.getAutoMode());
+ onCustomStartTimeChanged(mController.getCustomStartTime());
+ onCustomEndTimeChanged(mController.getCustomEndTime());
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+
+ // Stop listening for state changes.
+ mController.setListener(null);
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(Preference preference) {
+ if (preference == mStartTimePreference) {
+ showDialog(DIALOG_START_TIME);
+ return true;
+ } else if (preference == mEndTimePreference) {
+ showDialog(DIALOG_END_TIME);
+ return true;
+ }
+ return super.onPreferenceTreeClick(preference);
+ }
+
+ @Override
+ public Dialog onCreateDialog(final int dialogId) {
+ if (dialogId == DIALOG_START_TIME || dialogId == DIALOG_END_TIME) {
+ final NightDisplayController.LocalTime initialTime;
+ if (dialogId == DIALOG_START_TIME) {
+ initialTime = mController.getCustomStartTime();
+ } else {
+ initialTime = mController.getCustomEndTime();
+ }
+
+ final Context context = getContext();
+ final boolean use24HourFormat = android.text.format.DateFormat.is24HourFormat(context);
+ return new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
+ @Override
+ public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
+ final NightDisplayController.LocalTime time =
+ new NightDisplayController.LocalTime(hourOfDay, minute);
+ if (dialogId == DIALOG_START_TIME) {
+ mController.setCustomStartTime(time);
+ } else {
+ mController.setCustomEndTime(time);
+ }
+ }
+ }, initialTime.hourOfDay, initialTime.minute, use24HourFormat);
+ }
+ return super.onCreateDialog(dialogId);
+ }
+
+ @Override
+ public void onActivated(boolean activated) {
+ mSwitchBar.setChecked(activated);
+ }
+
+ @Override
+ public void onAutoModeChanged(int autoMode) {
+ mAutoModePreference.setValue(String.valueOf(autoMode));
+
+ final boolean showCustomSchedule = autoMode == NightDisplayController.AUTO_MODE_CUSTOM;
+ mStartTimePreference.setVisible(showCustomSchedule);
+ mEndTimePreference.setVisible(showCustomSchedule);
+ }
+
+ private String getFormattedTimeString(NightDisplayController.LocalTime localTime) {
+ final Calendar c = Calendar.getInstance();
+ c.setTimeZone(mTimeFormatter.getTimeZone());
+ c.set(Calendar.HOUR_OF_DAY, localTime.hourOfDay);
+ c.set(Calendar.MINUTE, localTime.minute);
+ c.set(Calendar.SECOND, 0);
+ c.set(Calendar.MILLISECOND, 0);
+ return mTimeFormatter.format(c.getTime());
+ }
+
+ @Override
+ public void onCustomStartTimeChanged(NightDisplayController.LocalTime startTime) {
+ mStartTimePreference.setSummary(getFormattedTimeString(startTime));
+ }
+
+ @Override
+ public void onCustomEndTimeChanged(NightDisplayController.LocalTime endTime) {
+ mEndTimePreference.setSummary(getFormattedTimeString(endTime));
+ }
+
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ // Attempt to update the NIGHT_DISPLAY_ACTIVATED setting if necessary.
+ final boolean isActivated = mController.isActivated();
+ if (isActivated != isChecked) {
+ if (mController.setActivated(isChecked)) {
+ switchView.setChecked(isActivated);
+ }
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mAutoModePreference) {
+ return mController.setAutoMode(Integer.parseInt((String) newValue));
+ }
+ return false;
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsEvent.NIGHT_DISPLAY_SETTINGS;
+ }
+}
diff --git a/src/com/android/settings/gestures/GesturePreference.java b/src/com/android/settings/gestures/GesturePreference.java
index 76ceba4..cad7297 100644
--- a/src/com/android/settings/gestures/GesturePreference.java
+++ b/src/com/android/settings/gestures/GesturePreference.java
@@ -50,7 +50,8 @@
private Uri mVideoPath;
private MediaPlayer mMediaPlayer;
private MediaMetadataRetriever mMediaMetadata;
- private boolean animationAvailable;
+ private boolean mAnimationAvailable;
+ private boolean mPreviewReady;
public GesturePreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -68,7 +69,7 @@
.build();
mMediaMetadata = new MediaMetadataRetriever();
mMediaMetadata.setDataSource(mContext, mVideoPath);
- animationAvailable = true;
+ mAnimationAvailable = true;
} catch (Exception e) {
Log.w(TAG, "Animation resource not found. Will not show animation.");
} finally {
@@ -86,20 +87,11 @@
final ImageView playButton = (ImageView) holder.findViewById(R.id.gesture_play_button);
final View animationFrame = holder.findViewById(R.id.gesture_animation_frame);
- if (!animationAvailable) {
+ if (!mAnimationAvailable) {
animationFrame.setVisibility(View.GONE);
return;
}
- Bitmap bitmap = mMediaMetadata.getFrameAtTime(0);
- if (bitmap != null) {
- imageView.setImageDrawable(new BitmapDrawable(bitmap));
- imageView.setColorFilter(mContext.getResources().getColor(
- R.color.gestures_setting_background_color), PorterDuff.Mode.DARKEN);
- }
- imageView.setVisibility(View.VISIBLE);
- playButton.setVisibility(View.VISIBLE);
-
video.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -119,13 +111,22 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
int height) {
- animationFrame.setLayoutParams(new LinearLayout.LayoutParams(width, width));
mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
if (mMediaPlayer != null) {
mMediaPlayer.setSurface(new Surface(surfaceTexture));
+ mMediaPlayer.setOnSeekCompleteListener(
+ new MediaPlayer.OnSeekCompleteListener() {
+ @Override
+ public void onSeekComplete(MediaPlayer mp) {
+ mPreviewReady = true;
+ mMediaPlayer.setOnSeekCompleteListener(null);
+ }
+ });
+
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
+ mediaPlayer.seekTo(0);
mediaPlayer.setLooping(true);
}
});
@@ -150,7 +151,7 @@
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
- if (mMediaPlayer.isPlaying() && imageView.getVisibility() == View.VISIBLE) {
+ if (mPreviewReady && imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index cafba68..2c065ac 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -18,15 +18,20 @@
import android.content.Context;
import android.content.res.Resources;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource;
-import android.provider.Settings.Global;
import android.provider.Settings.Secure;
import android.support.v7.preference.Preference;
+import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -51,6 +56,9 @@
private static final String PREF_KEY_PICK_UP_AND_NUDGE = "gesture_pick_up_and_nudge";
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
+ private static final String ARG_SCROLL_TO_PREFERENCE = "gesture_scroll_to_preference";
+
+ private int mScrollPosition = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -91,6 +99,39 @@
removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
}
+ // Double twist for camera mode
+ if (isDoubleTwistAvailable(context)) {
+ int doubleTwistEnabled = Secure.getInt(
+ getContentResolver(), Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
+ GesturePreference preference =
+ (GesturePreference) findPreference(PREF_KEY_DOUBLE_TWIST);
+ preference.setChecked(doubleTwistEnabled != 0);
+ preference.setOnPreferenceChangeListener(this);
+ } else {
+ removePreference(PREF_KEY_DOUBLE_TWIST);
+ }
+
+ if (savedInstanceState == null) {
+ final Bundle args = getArguments();
+ if (args != null && args.containsKey(ARG_SCROLL_TO_PREFERENCE)) {
+ String prefKey = args.getString(ARG_SCROLL_TO_PREFERENCE);
+ GesturePreference pref = (GesturePreference) findPreference(prefKey);
+ if (pref != null) {
+ mScrollPosition = pref.getOrder();
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = super.onCreateView(inflater, container, savedInstanceState);
+ if (mScrollPosition >= 0) {
+ getListView().scrollToPosition(mScrollPosition);
+ }
+ return view;
}
@Override
@@ -103,8 +144,11 @@
} else if (PREF_KEY_PICK_UP_AND_NUDGE.equals(key)) {
Secure.putInt(getContentResolver(), Secure.DOZE_ENABLED, enabled ? 1 : 0);
} else if (PREF_KEY_SWIPE_DOWN_FINGERPRINT.equals(key)) {
- Global.putInt(getContentResolver(),
- Global.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
+ Secure.putInt(getContentResolver(),
+ Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
+ } else if (PREF_KEY_DOUBLE_TWIST.equals(key)) {
+ Secure.putInt(getContentResolver(),
+ Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, enabled ? 1 : 0);
}
return true;
}
@@ -139,10 +183,26 @@
}
private static boolean isSystemUINavigationEnabled(Context context) {
- return Global.getInt(context.getContentResolver(), Global.SYSTEM_NAVIGATION_KEYS_ENABLED, 1)
+ return Secure.getInt(context.getContentResolver(), Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 1)
== 1;
}
+ private static boolean isDoubleTwistAvailable(Context context) {
+ Resources resources = context.getResources();
+ String name = resources.getString(R.string.gesture_double_twist_sensor_name);
+ String vendor = resources.getString(R.string.gesture_double_twist_sensor_vendor);
+ if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(vendor)) {
+ SensorManager sensorManager =
+ (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ for (Sensor s : sensorManager.getSensorList(Sensor.TYPE_ALL)) {
+ if (name.equals(s.getName()) && vendor.equals(s.getVendor())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index c535622..4d8e3d6 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -71,7 +71,8 @@
* Returns localized string for operation hours in specified country. If country is null, use
* current country to figure out operation hours.
*/
- CharSequence getOperationHours(Context context, @SupportType int type, String countryCode);
+ CharSequence getOperationHours(Context context, @SupportType int type, String countryCode,
+ boolean hasInternet);
/**
* Returns a localized string indicating estimated wait time for a support time.
diff --git a/src/com/android/settings/support/SupportPhoneDialogFragment.java b/src/com/android/settings/support/SupportPhoneDialogFragment.java
index bba6238..77eb225 100644
--- a/src/com/android/settings/support/SupportPhoneDialogFragment.java
+++ b/src/com/android/settings/support/SupportPhoneDialogFragment.java
@@ -23,6 +23,8 @@
import android.view.View;
import android.widget.TextView;
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.MetricsProto;
import com.android.settings.R;
import java.util.Locale;
@@ -66,6 +68,8 @@
@Override
public void onClick(View v) {
final SupportPhone phone = getArguments().getParcelable(EXTRA_PHONE);
+ MetricsLogger.action(getActivity(),
+ MetricsProto.MetricsEvent.ACTION_SUPPORT_DIAL_TOLLED);
getActivity().startActivity(phone.getDialIntent());
dismiss();
}
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 99d2f55..b306577 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -80,7 +80,7 @@
public void onForget() {
// Unset always-on-vpn when forgetting the VPN
if (isVpnAlwaysOn()) {
- setAlwaysOnVpnByUI(false);
+ setAlwaysOnVpn(false);
}
// Also dismiss and go back to VPN list
finish();
@@ -187,14 +187,18 @@
if (mUserId == UserHandle.USER_SYSTEM) {
VpnUtils.clearLockdownVpn(getContext());
}
- final boolean success = mConnectivityManager.setAlwaysOnVpnPackageForUser(mUserId,
- isEnabled ? mPackageName : null, /* lockdownEnabled */ false);
+ final boolean success = setAlwaysOnVpn(isEnabled);
if (isEnabled && (!success || !isVpnAlwaysOn())) {
CannotConnectFragment.show(this, mVpnLabel);
}
return success;
}
+ private boolean setAlwaysOnVpn(boolean isEnabled) {
+ return mConnectivityManager.setAlwaysOnVpnPackageForUser(mUserId,
+ isEnabled ? mPackageName : null, /* lockdownEnabled */ false);
+ }
+
private boolean checkTargetVersion() {
if (mPackageInfo == null || mPackageInfo.applicationInfo == null) {
return true;
diff --git a/src/com/android/settings/widget/AspectRatioFrameLayout.java b/src/com/android/settings/widget/AspectRatioFrameLayout.java
new file mode 100644
index 0000000..14d7921
--- /dev/null
+++ b/src/com/android/settings/widget/AspectRatioFrameLayout.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 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.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import com.android.settings.R;
+
+/**
+ * A {@link FrameLayout} with customizable aspect ration.
+ * This is used to avoid dynamically calculating the height for the frame. Default aspect
+ * ratio will be 1 if none is set in layout attribute.
+ */
+public final class AspectRatioFrameLayout extends FrameLayout {
+
+ private float mAspectRatio = 1.0f;
+
+ public AspectRatioFrameLayout(Context context) {
+ this(context, null);
+ }
+
+ public AspectRatioFrameLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AspectRatioFrameLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ if (attrs != null) {
+ TypedArray array =
+ context.obtainStyledAttributes(attrs, R.styleable.AspectRatioFrameLayout);
+ mAspectRatio = array.getFloat(
+ R.styleable.AspectRatioFrameLayout_aspectRatio, 1.0f);
+ array.recycle();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, (int) (widthMeasureSpec / mAspectRatio));
+ }
+
+}