From c4530c7d949a9f512d43940f908900a1dd8978af Mon Sep 17 00:00:00 2001 From: Jose Lima Date: Thu, 25 Sep 2014 12:31:43 -0700 Subject: Update network icon assets in Settings Bug: 17573229 Bug: 17574598 Change-Id: Ib4847dcbbb8eb87aaa6e43a8e252d28b0bf20f31 --- .../ic_settings_ethernet_active_launcher.png | Bin 1638 -> 2647 bytes .../ic_settings_wifi_active_1_launcher.png | Bin 0 -> 3706 bytes .../ic_settings_wifi_active_2_launcher.png | Bin 0 -> 4184 bytes .../ic_settings_wifi_active_3_launcher.png | Bin 0 -> 4524 bytes .../ic_settings_wifi_active_4_launcher.png | Bin 0 -> 4686 bytes .../ic_settings_wifi_not_connected_launcher.png | Bin 0 -> 3314 bytes .../ic_settings_ethernet_active_launcher.png | Bin 1340 -> 1963 bytes .../ic_settings_wifi_active_1_launcher.png | Bin 0 -> 2509 bytes .../ic_settings_wifi_active_2_launcher.png | Bin 0 -> 2815 bytes .../ic_settings_wifi_active_3_launcher.png | Bin 0 -> 3053 bytes .../ic_settings_wifi_active_4_launcher.png | Bin 0 -> 3122 bytes .../ic_settings_wifi_not_connected_launcher.png | Bin 0 -> 2175 bytes .../ic_settings_ethernet_active_launcher.png | Bin 1833 -> 4002 bytes .../ic_settings_wifi_active_1_launcher.png | Bin 0 -> 4882 bytes .../ic_settings_wifi_active_2_launcher.png | Bin 0 -> 5574 bytes .../ic_settings_wifi_active_3_launcher.png | Bin 0 -> 5967 bytes .../ic_settings_wifi_active_4_launcher.png | Bin 0 -> 6328 bytes .../ic_settings_wifi_not_connected_launcher.png | Bin 0 -> 4444 bytes .../ic_settings_ethernet_active_launcher.png | Bin 1960 -> 4424 bytes .../ic_settings_wifi_active_1_launcher.png | Bin 0 -> 4850 bytes .../ic_settings_wifi_active_2_launcher.png | Bin 0 -> 5355 bytes .../ic_settings_wifi_active_3_launcher.png | Bin 0 -> 5643 bytes .../ic_settings_wifi_active_4_launcher.png | Bin 0 -> 5313 bytes .../ic_settings_wifi_not_connected_launcher.png | Bin 0 -> 4879 bytes Settings/res/drawable/network_state_disconnected.xml | 2 +- Settings/res/drawable/network_state_wifi_1.xml | 2 +- Settings/res/drawable/network_state_wifi_2.xml | 2 +- Settings/res/drawable/network_state_wifi_3.xml | 2 +- Settings/res/drawable/network_state_wifi_4.xml | 2 +- 29 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 Settings/res/drawable-hdpi/ic_settings_wifi_active_1_launcher.png create mode 100644 Settings/res/drawable-hdpi/ic_settings_wifi_active_2_launcher.png create mode 100644 Settings/res/drawable-hdpi/ic_settings_wifi_active_3_launcher.png create mode 100644 Settings/res/drawable-hdpi/ic_settings_wifi_active_4_launcher.png create mode 100644 Settings/res/drawable-hdpi/ic_settings_wifi_not_connected_launcher.png create mode 100644 Settings/res/drawable-mdpi/ic_settings_wifi_active_1_launcher.png create mode 100644 Settings/res/drawable-mdpi/ic_settings_wifi_active_2_launcher.png create mode 100644 Settings/res/drawable-mdpi/ic_settings_wifi_active_3_launcher.png create mode 100644 Settings/res/drawable-mdpi/ic_settings_wifi_active_4_launcher.png create mode 100644 Settings/res/drawable-mdpi/ic_settings_wifi_not_connected_launcher.png create mode 100644 Settings/res/drawable-xhdpi/ic_settings_wifi_active_1_launcher.png create mode 100644 Settings/res/drawable-xhdpi/ic_settings_wifi_active_2_launcher.png create mode 100644 Settings/res/drawable-xhdpi/ic_settings_wifi_active_3_launcher.png create mode 100644 Settings/res/drawable-xhdpi/ic_settings_wifi_active_4_launcher.png create mode 100644 Settings/res/drawable-xhdpi/ic_settings_wifi_not_connected_launcher.png create mode 100755 Settings/res/drawable-xxhdpi/ic_settings_wifi_active_1_launcher.png create mode 100755 Settings/res/drawable-xxhdpi/ic_settings_wifi_active_2_launcher.png create mode 100755 Settings/res/drawable-xxhdpi/ic_settings_wifi_active_3_launcher.png create mode 100755 Settings/res/drawable-xxhdpi/ic_settings_wifi_active_4_launcher.png create mode 100644 Settings/res/drawable-xxhdpi/ic_settings_wifi_not_connected_launcher.png diff --git a/Settings/res/drawable-hdpi/ic_settings_ethernet_active_launcher.png b/Settings/res/drawable-hdpi/ic_settings_ethernet_active_launcher.png index 2ef8d6e1..ff6b93d5 100644 Binary files a/Settings/res/drawable-hdpi/ic_settings_ethernet_active_launcher.png and b/Settings/res/drawable-hdpi/ic_settings_ethernet_active_launcher.png differ diff --git a/Settings/res/drawable-hdpi/ic_settings_wifi_active_1_launcher.png b/Settings/res/drawable-hdpi/ic_settings_wifi_active_1_launcher.png new file mode 100644 index 00000000..f229ff79 Binary files /dev/null and b/Settings/res/drawable-hdpi/ic_settings_wifi_active_1_launcher.png differ diff --git a/Settings/res/drawable-hdpi/ic_settings_wifi_active_2_launcher.png b/Settings/res/drawable-hdpi/ic_settings_wifi_active_2_launcher.png new file mode 100644 index 00000000..3e881290 Binary files /dev/null and b/Settings/res/drawable-hdpi/ic_settings_wifi_active_2_launcher.png differ diff --git a/Settings/res/drawable-hdpi/ic_settings_wifi_active_3_launcher.png b/Settings/res/drawable-hdpi/ic_settings_wifi_active_3_launcher.png new file mode 100644 index 00000000..23da51b7 Binary files /dev/null and b/Settings/res/drawable-hdpi/ic_settings_wifi_active_3_launcher.png differ diff --git a/Settings/res/drawable-hdpi/ic_settings_wifi_active_4_launcher.png b/Settings/res/drawable-hdpi/ic_settings_wifi_active_4_launcher.png new file mode 100644 index 00000000..5492f4d1 Binary files /dev/null and b/Settings/res/drawable-hdpi/ic_settings_wifi_active_4_launcher.png differ diff --git a/Settings/res/drawable-hdpi/ic_settings_wifi_not_connected_launcher.png b/Settings/res/drawable-hdpi/ic_settings_wifi_not_connected_launcher.png new file mode 100644 index 00000000..50d20bf2 Binary files /dev/null and b/Settings/res/drawable-hdpi/ic_settings_wifi_not_connected_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_ethernet_active_launcher.png b/Settings/res/drawable-mdpi/ic_settings_ethernet_active_launcher.png index 8c4b0acb..a6ecd39d 100644 Binary files a/Settings/res/drawable-mdpi/ic_settings_ethernet_active_launcher.png and b/Settings/res/drawable-mdpi/ic_settings_ethernet_active_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_wifi_active_1_launcher.png b/Settings/res/drawable-mdpi/ic_settings_wifi_active_1_launcher.png new file mode 100644 index 00000000..f6fa2031 Binary files /dev/null and b/Settings/res/drawable-mdpi/ic_settings_wifi_active_1_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_wifi_active_2_launcher.png b/Settings/res/drawable-mdpi/ic_settings_wifi_active_2_launcher.png new file mode 100644 index 00000000..f41b3976 Binary files /dev/null and b/Settings/res/drawable-mdpi/ic_settings_wifi_active_2_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_wifi_active_3_launcher.png b/Settings/res/drawable-mdpi/ic_settings_wifi_active_3_launcher.png new file mode 100644 index 00000000..8cc25e14 Binary files /dev/null and b/Settings/res/drawable-mdpi/ic_settings_wifi_active_3_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_wifi_active_4_launcher.png b/Settings/res/drawable-mdpi/ic_settings_wifi_active_4_launcher.png new file mode 100644 index 00000000..65466b64 Binary files /dev/null and b/Settings/res/drawable-mdpi/ic_settings_wifi_active_4_launcher.png differ diff --git a/Settings/res/drawable-mdpi/ic_settings_wifi_not_connected_launcher.png b/Settings/res/drawable-mdpi/ic_settings_wifi_not_connected_launcher.png new file mode 100644 index 00000000..1f33e687 Binary files /dev/null and b/Settings/res/drawable-mdpi/ic_settings_wifi_not_connected_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_ethernet_active_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_ethernet_active_launcher.png index 6c5e0544..fb53f9b3 100644 Binary files a/Settings/res/drawable-xhdpi/ic_settings_ethernet_active_launcher.png and b/Settings/res/drawable-xhdpi/ic_settings_ethernet_active_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_wifi_active_1_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_1_launcher.png new file mode 100644 index 00000000..6f8c4437 Binary files /dev/null and b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_1_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_wifi_active_2_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_2_launcher.png new file mode 100644 index 00000000..06949fbc Binary files /dev/null and b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_2_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_wifi_active_3_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_3_launcher.png new file mode 100644 index 00000000..7eb33414 Binary files /dev/null and b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_3_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_wifi_active_4_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_4_launcher.png new file mode 100644 index 00000000..7ff93af4 Binary files /dev/null and b/Settings/res/drawable-xhdpi/ic_settings_wifi_active_4_launcher.png differ diff --git a/Settings/res/drawable-xhdpi/ic_settings_wifi_not_connected_launcher.png b/Settings/res/drawable-xhdpi/ic_settings_wifi_not_connected_launcher.png new file mode 100644 index 00000000..418e0ab2 Binary files /dev/null and b/Settings/res/drawable-xhdpi/ic_settings_wifi_not_connected_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_ethernet_active_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_ethernet_active_launcher.png index 231b91b4..06dc98b8 100644 Binary files a/Settings/res/drawable-xxhdpi/ic_settings_ethernet_active_launcher.png and b/Settings/res/drawable-xxhdpi/ic_settings_ethernet_active_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_1_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_1_launcher.png new file mode 100755 index 00000000..c8a42b78 Binary files /dev/null and b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_1_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_2_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_2_launcher.png new file mode 100755 index 00000000..133ca1d2 Binary files /dev/null and b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_2_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_3_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_3_launcher.png new file mode 100755 index 00000000..17521474 Binary files /dev/null and b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_3_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_4_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_4_launcher.png new file mode 100755 index 00000000..a9cf1dac Binary files /dev/null and b/Settings/res/drawable-xxhdpi/ic_settings_wifi_active_4_launcher.png differ diff --git a/Settings/res/drawable-xxhdpi/ic_settings_wifi_not_connected_launcher.png b/Settings/res/drawable-xxhdpi/ic_settings_wifi_not_connected_launcher.png new file mode 100644 index 00000000..781e512e Binary files /dev/null and b/Settings/res/drawable-xxhdpi/ic_settings_wifi_not_connected_launcher.png differ diff --git a/Settings/res/drawable/network_state_disconnected.xml b/Settings/res/drawable/network_state_disconnected.xml index f21aeebb..96408f72 100644 --- a/Settings/res/drawable/network_state_disconnected.xml +++ b/Settings/res/drawable/network_state_disconnected.xml @@ -15,4 +15,4 @@ --> + android:src="@drawable/ic_settings_wifi_not_connected_launcher" /> diff --git a/Settings/res/drawable/network_state_wifi_1.xml b/Settings/res/drawable/network_state_wifi_1.xml index 00e2edff..a5a3eae9 100644 --- a/Settings/res/drawable/network_state_wifi_1.xml +++ b/Settings/res/drawable/network_state_wifi_1.xml @@ -15,4 +15,4 @@ --> + android:src="@drawable/ic_settings_wifi_active_1_launcher" /> diff --git a/Settings/res/drawable/network_state_wifi_2.xml b/Settings/res/drawable/network_state_wifi_2.xml index 4519c18d..b6a1c2fe 100644 --- a/Settings/res/drawable/network_state_wifi_2.xml +++ b/Settings/res/drawable/network_state_wifi_2.xml @@ -15,4 +15,4 @@ --> + android:src="@drawable/ic_settings_wifi_active_2_launcher" /> diff --git a/Settings/res/drawable/network_state_wifi_3.xml b/Settings/res/drawable/network_state_wifi_3.xml index 25f30196..30b8aa36 100644 --- a/Settings/res/drawable/network_state_wifi_3.xml +++ b/Settings/res/drawable/network_state_wifi_3.xml @@ -15,4 +15,4 @@ --> + android:src="@drawable/ic_settings_wifi_active_3_launcher"/> diff --git a/Settings/res/drawable/network_state_wifi_4.xml b/Settings/res/drawable/network_state_wifi_4.xml index d091a489..fbbc246f 100644 --- a/Settings/res/drawable/network_state_wifi_4.xml +++ b/Settings/res/drawable/network_state_wifi_4.xml @@ -15,4 +15,4 @@ --> + android:src="@drawable/ic_settings_wifi_active_4_launcher" /> -- cgit v1.2.3 From 179c3b643f10cd75edf705344b1e2924d0a3dcb4 Mon Sep 17 00:00:00 2001 From: RoboErik Date: Tue, 30 Sep 2014 15:39:31 -0700 Subject: Write the system sleep value to system settings We were saving it to local shared prefs but had no way for another package to get it as we lost the provider for it. This moves the value to system settings where it should be. This also required one string change to match the behavior of the new setting. Also cleans up the naming so the code is easier to read. bug:17665809 Change-Id: Ib2d8860909c946daac16c4ccf40de808c274e9f9 --- Settings/AndroidManifest.xml | 1 + Settings/res/values-notouch/strings.xml | 2 +- .../device/display/daydream/DaydreamActivity.java | 84 ++++++++++------------ 3 files changed, 41 insertions(+), 46 deletions(-) diff --git a/Settings/AndroidManifest.xml b/Settings/AndroidManifest.xml index e4459d31..48b5aeaf 100644 --- a/Settings/AndroidManifest.xml +++ b/Settings/AndroidManifest.xml @@ -34,6 +34,7 @@ + When to sleep - Screen turns off this amount of time after daydream starts. + Screen turns off after this period of inactivity. %1$s after dreaming diff --git a/Settings/src/com/android/tv/settings/device/display/daydream/DaydreamActivity.java b/Settings/src/com/android/tv/settings/device/display/daydream/DaydreamActivity.java index c1ba12ff..6e75ff82 100644 --- a/Settings/src/com/android/tv/settings/device/display/daydream/DaydreamActivity.java +++ b/Settings/src/com/android/tv/settings/device/display/daydream/DaydreamActivity.java @@ -16,7 +16,10 @@ package com.android.tv.settings.device.display.daydream; +// This setting controls when we will start dreaming import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; +// This setting controls when we'll turn the output off and go to sleep +import static android.provider.Settings.Secure.SLEEP_TIMEOUT; import com.android.tv.settings.R; import com.android.tv.settings.dialog.old.Action; @@ -38,23 +41,21 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; - /** * Activity that allows the setting of daydreams. */ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Listener { enum ActionType { - SELECT, LIST_SLEEP, LIST_SCREEN_OFF, SET_SLEEP, SET_SCREEN_OFF, TEST; + SELECT, LIST_DREAM_TIMEOUT, LIST_SYSTEM_SLEEP_TIMEOUT, SET_DREAM_TIMEOUT, SET_SYSTEM_SLEEP_TIMEOUT, TEST; } /** If there is no setting in the provider, use this. */ private static final int DREAM_SETTINGS_REQUEST = 1; - private static final long FALLBACK_SCREEN_TIMEOUT_VALUE = 1800000; + private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 1800000; private static final String EXTRA_LIST_VALUE = "list_value"; private static final int CHECK_SET_ID = 1; - private static final String SLEEP_TIMEOUT_MS = "sleep_timeout_ms"; private static final int DEFAULT_SLEEP_TIMEOUT_MS = 3 * 60 * 60 * 1000; private DreamBackend mDreamBackend; @@ -103,17 +104,17 @@ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Li case SELECT: onSelect(); break; - case LIST_SLEEP: - onListSleep(); + case LIST_DREAM_TIMEOUT: + onListDreamTimeouts(); break; - case LIST_SCREEN_OFF: - onListScreenOff(); + case LIST_SYSTEM_SLEEP_TIMEOUT: + onListSystemSleepTimeouts(); break; - case SET_SLEEP: - onSetSleep(action); + case SET_DREAM_TIMEOUT: + onSetDreamTimeout(action); break; - case SET_SCREEN_OFF: - onSetScreenOff(action); + case SET_SYSTEM_SLEEP_TIMEOUT: + onSetSystemSleepTimeout(action); break; case TEST: onTest(); @@ -130,37 +131,33 @@ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Li ActionFragment.newInstance(mDreamBackend.getDreamInfoActions())); } - private void onListSleep() { + private void onListDreamTimeouts() { setContentAndActionFragments(createSubMenuContentFragment( getString(R.string.device_daydreams_sleep), getString(R.string.device_daydreams_sleep_description)), - ActionFragment.newInstance(getListActions(ActionType.SET_SLEEP.name(), + ActionFragment.newInstance(getListActions(ActionType.SET_DREAM_TIMEOUT.name(), R.array.sleep_timeout_values, R.array.sleep_timeout_entries, - getSleepValue()))); + getDreamTimeoutValue()))); } - private void onListScreenOff() { + private void onListSystemSleepTimeouts() { setContentAndActionFragments(createSubMenuContentFragment( getString(R.string.device_daydreams_screen_off), getString(R.string.device_daydreams_screen_off_description)), - ActionFragment.newInstance(getListActions(ActionType.SET_SCREEN_OFF.name(), + ActionFragment.newInstance(getListActions(ActionType.SET_SYSTEM_SLEEP_TIMEOUT.name(), R.array.screen_off_timeout_values, R.array.screen_off_timeout_entries, - getSleepTimeout(getApplicationContext())))); + getSystemSleepTimeout()))); } - private void onSetSleep(Action action) { + private void onSetDreamTimeout(Action action) { long sleepValue = action.getIntent().getLongExtra(EXTRA_LIST_VALUE, 0); - try { - Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, (int) sleepValue); - } catch (NumberFormatException e) { - Log.e("DaydreamActivity", "could not persist screen timeout setting", e); - } + Settings.System.putInt(getContentResolver(), SCREEN_OFF_TIMEOUT, (int) sleepValue); goToMainScreen(); } - private void onSetScreenOff(Action action) { - long screenOffValue = action.getIntent().getLongExtra(EXTRA_LIST_VALUE, 0); - setSleepTimeout(getApplicationContext(), (int) screenOffValue); + private void onSetSystemSleepTimeout(Action action) { + int screenOffValue = (int) action.getIntent().getLongExtra(EXTRA_LIST_VALUE, 0); + setSystemSleepTimeout(screenOffValue); goToMainScreen(); } @@ -179,23 +176,23 @@ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Li .title(getString(R.string.device_daydreams_select)) .description(mDreamBackend.getActiveDreamTitle()).build()); actions.add(new Action.Builder() - .key(ActionType.LIST_SLEEP.name()) + .key(ActionType.LIST_DREAM_TIMEOUT.name()) .title(getString(R.string.device_daydreams_sleep)) .description((getString(R.string.device_daydreams_sleep_summary, getEntry(R.array.sleep_timeout_values, R.array.sleep_timeout_entries, - getSleepValue())))) + getDreamTimeoutValue())))) .build()); String[] screenOffEntries = getResources().getStringArray( R.array.screen_off_timeout_entries); - int screenOffTimeout = getSleepTimeout(getApplicationContext()); + int systemSleepTimeout = getSystemSleepTimeout(); // Only add the summary text if the value is not "Never" - String screenOffDescription = screenOffTimeout > 0 ? getString( - R.string.device_daydreams_screen_off_summary, + String screenOffDescription = systemSleepTimeout > 0 ? getString( + R.string.device_daydreams_sleep_summary, getEntry(R.array.screen_off_timeout_values, R.array.screen_off_timeout_entries, - screenOffTimeout)) : screenOffEntries[screenOffEntries.length - 1]; + systemSleepTimeout)) : screenOffEntries[screenOffEntries.length - 1]; actions.add(new Action.Builder() - .key(ActionType.LIST_SCREEN_OFF.name()) + .key(ActionType.LIST_SYSTEM_SLEEP_TIMEOUT.name()) .title(getString(R.string.device_daydreams_screen_off)) .description(screenOffDescription) .build()); @@ -239,15 +236,15 @@ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Li return actions; } - private long getSleepValue() { - return Settings.System.getLong(getContentResolver(), SCREEN_OFF_TIMEOUT, + private int getDreamTimeoutValue() { + return Settings.System.getInt(getContentResolver(), SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE); } private String getEntry(int valuesResId, int entriesResId, long value) { String[] sleepOptionValues = getResources().getStringArray(valuesResId); String[] sleepOptionEntries = getResources().getStringArray(entriesResId); - long sleepValue = getSleepValue(); + long sleepValue = getDreamTimeoutValue(); for (int index = 0; index < sleepOptionValues.length; ++index) { long loopValue = Long.parseLong(sleepOptionValues[index]); if (loopValue == value) { @@ -257,15 +254,12 @@ public class DaydreamActivity extends DialogActivity implements ActionAdapter.Li return null; } - private static int getSleepTimeout(Context context) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - return preferences.getInt(SLEEP_TIMEOUT_MS, DEFAULT_SLEEP_TIMEOUT_MS); + private int getSystemSleepTimeout() { + return Settings.Secure.getInt(getContentResolver(), SLEEP_TIMEOUT, + DEFAULT_SLEEP_TIMEOUT_MS); } - public static void setSleepTimeout(Context context, int valueMs) { - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); - preferences.edit() - .putInt(SLEEP_TIMEOUT_MS, valueMs) - .apply(); + private void setSystemSleepTimeout(int valueMs) { + Settings.Secure.putInt(getContentResolver(), SLEEP_TIMEOUT, valueMs); } } -- cgit v1.2.3 From 901e8233a23d67140709d3b7e66cf5a894d9f732 Mon Sep 17 00:00:00 2001 From: bulic Date: Wed, 1 Oct 2014 19:05:02 -0700 Subject: Fixed line cutting bug b/17740676 b/16700980 b/17561191 Change-Id: Ie3609499b5eb0b45deaacf5868d96ba549580994 --- Settings/res/layout/browse_item.xml | 70 ++++++++++++++++++++++ Settings/res/layout/browse_item_blended_light.xml | 70 ---------------------- Settings/res/values/dimens.xml | 6 +- .../com/android/tv/settings/MenuItemPresenter.java | 17 ++++-- 4 files changed, 87 insertions(+), 76 deletions(-) create mode 100644 Settings/res/layout/browse_item.xml delete mode 100644 Settings/res/layout/browse_item_blended_light.xml diff --git a/Settings/res/layout/browse_item.xml b/Settings/res/layout/browse_item.xml new file mode 100644 index 00000000..f9e34f0d --- /dev/null +++ b/Settings/res/layout/browse_item.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + diff --git a/Settings/res/layout/browse_item_blended_light.xml b/Settings/res/layout/browse_item_blended_light.xml deleted file mode 100644 index cb27bfa2..00000000 --- a/Settings/res/layout/browse_item_blended_light.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - diff --git a/Settings/res/values/dimens.xml b/Settings/res/values/dimens.xml index ab34b11d..f54a39e4 100644 --- a/Settings/res/values/dimens.xml +++ b/Settings/res/values/dimens.xml @@ -22,8 +22,10 @@ 112dp 112dp 12dp - 32dp - 12dp + + 9dp + + 29dp 48sp 36sp diff --git a/Settings/src/com/android/tv/settings/MenuItemPresenter.java b/Settings/src/com/android/tv/settings/MenuItemPresenter.java index 9399ccb8..28ccbe5e 100644 --- a/Settings/src/com/android/tv/settings/MenuItemPresenter.java +++ b/Settings/src/com/android/tv/settings/MenuItemPresenter.java @@ -19,6 +19,7 @@ package com.android.tv.settings; import android.animation.ObjectAnimator; import android.app.Activity; import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Paint; import android.graphics.Paint.FontMetricsInt; @@ -58,7 +59,7 @@ public class MenuItemPresenter extends Presenter { public ViewHolder onCreateViewHolder(ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); - View v = inflater.inflate(R.layout.browse_item_blended_light, parent, false); + View v = inflater.inflate(R.layout.browse_item, parent, false); return new MenuItemViewHolder(v); } @@ -73,11 +74,19 @@ public class MenuItemPresenter extends Presenter { menuItem.getDescriptionGetter() == null ? null : menuItem.getDescriptionGetter().getText()); - if (!hasDescription) { - menuItemViewHolder.mTitleView.setMaxLines(2); + Resources res = menuItemViewHolder.mTitleView.getContext().getResources(); + ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) + menuItemViewHolder.mTitleView.getLayoutParams(); + if (hasDescription) { + lp.bottomMargin = (int) res.getDimension(R.dimen.browse_item_title_marginBottom); + menuItemViewHolder.mTitleView.setSingleLine(true); + menuItemViewHolder.mTitleView.setLines(1); } else { - menuItemViewHolder.mTitleView.setMaxLines(1); + lp.bottomMargin = (int) res.getDimension(R.dimen.browse_item_description_marginBottom); + menuItemViewHolder.mTitleView.setSingleLine(false); + menuItemViewHolder.mTitleView.setLines(2); } + menuItemViewHolder.mTitleView.setLayoutParams(lp); viewHolder.view.setOnClickListener(new View.OnClickListener() { @Override -- cgit v1.2.3