summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Kover <dkover@cyngn.com>2015-05-07 17:31:19 -0700
committerClark Scheff <clark@cyngn.com>2015-05-08 22:16:00 +0000
commit8c482123e49f5c5543612efd95f597c013ce11c1 (patch)
treec93f6a0b7c2c89acb34c40197fb60545cb61f272
parent5ab226efd7a0e9bc5a2d9942e4f832c37192abc4 (diff)
downloadandroid_packages_apps_DeskClock-stable/cm-12.1-YOG3C.tar.gz
android_packages_apps_DeskClock-stable/cm-12.1-YOG3C.tar.bz2
android_packages_apps_DeskClock-stable/cm-12.1-YOG3C.zip
Expose background colors for theming.stable/cm-12.1-YOG3C
The background colors are currently defined as a hard coded array in Utils.java. This patch moves this array to cm_arrays.xml and exposes the colors of the array in cm_colors.xml for theming Change-Id: Id72867ee82edd28bc120223be96c34448d79f1ae (cherry picked from commit 03a553766991b37fd4a07248cacd3ba9339b8180)
-rw-r--r--res/values/cm_arrays.xml29
-rw-r--r--res/values/cm_colors.xml45
-rw-r--r--src/com/android/deskclock/AlarmClockFragment.java4
-rw-r--r--src/com/android/deskclock/DeskClock.java2
-rw-r--r--src/com/android/deskclock/SettingsActivity.java2
-rwxr-xr-xsrc/com/android/deskclock/Utils.java30
-rw-r--r--src/com/android/deskclock/alarms/AlarmActivity.java2
-rw-r--r--src/com/android/deskclock/timer/TimerAlertFullScreen.java2
-rwxr-xr-xsrc/com/android/deskclock/worldclock/CitiesActivity.java2
9 files changed, 100 insertions, 18 deletions
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml
index 320d8320d..4717f2677 100644
--- a/res/values/cm_arrays.xml
+++ b/res/values/cm_arrays.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2012-2014 The CyanogenMod Project
+ Copyright (C) 2012-2015 The CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -29,4 +29,31 @@
<item>@string/alarm_type_playlist</item>
<item>@string/alarm_type_random</item>
</string-array>
+
+ <array name="background_color_by_hour">
+ <item>@color/hour_00</item>
+ <item>@color/hour_01</item>
+ <item>@color/hour_02</item>
+ <item>@color/hour_03</item>
+ <item>@color/hour_04</item>
+ <item>@color/hour_05</item>
+ <item>@color/hour_06</item>
+ <item>@color/hour_07</item>
+ <item>@color/hour_08</item>
+ <item>@color/hour_09</item>
+ <item>@color/hour_10</item>
+ <item>@color/hour_11</item>
+ <item>@color/hour_12</item>
+ <item>@color/hour_13</item>
+ <item>@color/hour_14</item>
+ <item>@color/hour_15</item>
+ <item>@color/hour_16</item>
+ <item>@color/hour_17</item>
+ <item>@color/hour_18</item>
+ <item>@color/hour_19</item>
+ <item>@color/hour_20</item>
+ <item>@color/hour_21</item>
+ <item>@color/hour_22</item>
+ <item>@color/hour_23</item>
+ </array>
</resources>
diff --git a/res/values/cm_colors.xml b/res/values/cm_colors.xml
new file mode 100644
index 000000000..b318bdfe2
--- /dev/null
+++ b/res/values/cm_colors.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The CyanogenMod 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.
+-->
+<resources>
+
+ <!--- Colors modify the background of the clock and change hourly -->
+ <color name="hour_00">#212121</color><!-- Midnight -->
+ <color name="hour_01">#27232e</color>
+ <color name="hour_02">#2d253a</color>
+ <color name="hour_03">#332847</color>
+ <color name="hour_04">#382a53</color>
+ <color name="hour_05">#3e2c5f</color>
+ <color name="hour_06">#442e6c</color>
+ <color name="hour_07">#393a7a</color>
+ <color name="hour_08">#2e4687</color>
+ <color name="hour_09">#235395</color>
+ <color name="hour_10">#185fa2</color>
+ <color name="hour_11">#0d6baf</color>
+ <color name="hour_12">#0277bd</color><!-- Noon -->
+ <color name="hour_13">#0d6cb1</color>
+ <color name="hour_14">#1861a6</color>
+ <color name="hour_15">#23569b</color>
+ <color name="hour_16">#2d4a8f</color>
+ <color name="hour_17">#383f84</color>
+ <color name="hour_18">#433478</color>
+ <color name="hour_19">#3d3169</color>
+ <color name="hour_20">#382e5b</color>
+ <color name="hour_21">#322b4d</color>
+ <color name="hour_22">#2c273e</color>
+ <color name="hour_23">#272430</color>
+
+</resources>
diff --git a/src/com/android/deskclock/AlarmClockFragment.java b/src/com/android/deskclock/AlarmClockFragment.java
index 356e51496..4cc6aaa77 100644
--- a/src/com/android/deskclock/AlarmClockFragment.java
+++ b/src/com/android/deskclock/AlarmClockFragment.java
@@ -1178,7 +1178,7 @@ public class AlarmClockFragment extends DeskClockFragment implements
}
private int getTintedBackgroundColor() {
- final int c = Utils.getCurrentHourColor();
+ final int c = Utils.getCurrentHourColor(getActivity());
final int red = Color.red(c) + (int) (TINTED_LEVEL * (255 - Color.red(c)));
final int green = Color.green(c) + (int) (TINTED_LEVEL * (255 - Color.green(c)));
final int blue = Color.blue(c) + (int) (TINTED_LEVEL * (255 - Color.blue(c)));
@@ -1386,7 +1386,7 @@ public class AlarmClockFragment extends DeskClockFragment implements
private void turnOnDayOfWeek(ItemHolder holder, int dayIndex) {
final Button dayButton = holder.dayButtons[dayIndex];
dayButton.setActivated(true);
- dayButton.setTextColor(Utils.getCurrentHourColor());
+ dayButton.setTextColor(Utils.getCurrentHourColor(getActivity()));
}
diff --git a/src/com/android/deskclock/DeskClock.java b/src/com/android/deskclock/DeskClock.java
index 61306ed7a..032489748 100644
--- a/src/com/android/deskclock/DeskClock.java
+++ b/src/com/android/deskclock/DeskClock.java
@@ -433,7 +433,7 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
} else {
duration = getResources().getInteger(android.R.integer.config_longAnimTime);
}
- final int currHourColor = Utils.getCurrentHourColor();
+ final int currHourColor = Utils.getCurrentHourColor(this);
if (mLastHourColor != currHourColor) {
final ObjectAnimator animator = ObjectAnimator.ofInt(getWindow().getDecorView(),
"backgroundColor", mLastHourColor, currHourColor);
diff --git a/src/com/android/deskclock/SettingsActivity.java b/src/com/android/deskclock/SettingsActivity.java
index a232202c7..c25f078fb 100644
--- a/src/com/android/deskclock/SettingsActivity.java
+++ b/src/com/android/deskclock/SettingsActivity.java
@@ -116,7 +116,7 @@ public class SettingsActivity extends PreferenceActivity
@Override
protected void onResume() {
super.onResume();
- getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor());
+ getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor(this));
refresh();
}
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index 4fcf97c39..26a9fe021 100755
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -28,6 +28,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Paint;
@@ -70,8 +71,6 @@ import java.text.Collator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
@@ -108,10 +107,8 @@ public class Utils {
public static final String CLOCK_TYPE_ANALOG = "analog";
/** The background colors of the app, it changes thru out the day to mimic the sky. **/
- public static final String[] BACKGROUND_SPECTRUM = { "#212121", "#27232e", "#2d253a",
- "#332847", "#382a53", "#3e2c5f", "#442e6c", "#393a7a", "#2e4687", "#235395", "#185fa2",
- "#0d6baf", "#0277bd", "#0d6cb1", "#1861a6", "#23569b", "#2d4a8f", "#383f84", "#433478",
- "#3d3169", "#382e5b", "#322b4d", "#2c273e", "#272430" };
+ public static TypedArray sBackgroundSpectrum;
+ private static int sDefaultBackgroundSpectrumColor;
/**
* Returns whether the SDK is KitKat or later
@@ -641,14 +638,27 @@ public class Utils {
return (city.mCityId == null || dbCity == null) ? city.mCityName : dbCity.mCityName;
}
- public static int getCurrentHourColor() {
+ private static void loadBackgroundSpectrum(Context context) {
+ Resources res = context.getResources();
+ sBackgroundSpectrum = res.obtainTypedArray(R.array.background_color_by_hour);
+ sDefaultBackgroundSpectrumColor = res.getColor(R.color.hour_12);
+ }
+
+ public static int getCurrentHourColor(Context context) {
+ if (sBackgroundSpectrum == null) {
+ loadBackgroundSpectrum(context);
+ }
final int hourOfDay = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
- return Color.parseColor(BACKGROUND_SPECTRUM[hourOfDay]);
+ return sBackgroundSpectrum.getColor(hourOfDay, sDefaultBackgroundSpectrumColor);
}
- public static int getNextHourColor() {
+ public static int getNextHourColor(Context context) {
+ if (sBackgroundSpectrum == null) {
+ loadBackgroundSpectrum(context);
+ }
final int currHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
- return Color.parseColor(BACKGROUND_SPECTRUM[currHour < 24 ? currHour + 1 : 1]);
+ return sBackgroundSpectrum.getColor(currHour < 24 ? currHour + 1 : 1,
+ sDefaultBackgroundSpectrumColor);
}
/**
diff --git a/src/com/android/deskclock/alarms/AlarmActivity.java b/src/com/android/deskclock/alarms/AlarmActivity.java
index 4b1909980..56b3f8000 100644
--- a/src/com/android/deskclock/alarms/AlarmActivity.java
+++ b/src/com/android/deskclock/alarms/AlarmActivity.java
@@ -195,7 +195,7 @@ public class AlarmActivity extends Activity implements View.OnClickListener, Vie
Utils.setTimeFormat(digitalClock,
getResources().getDimensionPixelSize(R.dimen.main_ampm_font_size));
- mCurrentHourColor = Utils.getCurrentHourColor();
+ mCurrentHourColor = Utils.getCurrentHourColor(this);
mContainerView.setBackgroundColor(mCurrentHourColor);
mAlarmButton.setOnTouchListener(this);
diff --git a/src/com/android/deskclock/timer/TimerAlertFullScreen.java b/src/com/android/deskclock/timer/TimerAlertFullScreen.java
index 27e18a95e..913ff4d33 100644
--- a/src/com/android/deskclock/timer/TimerAlertFullScreen.java
+++ b/src/com/android/deskclock/timer/TimerAlertFullScreen.java
@@ -77,7 +77,7 @@ public class TimerAlertFullScreen extends Activity implements OnEmptyListListene
protected void onResume() {
super.onResume();
- getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor());
+ getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor(this));
// Only show notifications for times-up when this activity closed.
Utils.cancelTimesUpNotifications(this);
diff --git a/src/com/android/deskclock/worldclock/CitiesActivity.java b/src/com/android/deskclock/worldclock/CitiesActivity.java
index 45ab3469f..3912f9248 100755
--- a/src/com/android/deskclock/worldclock/CitiesActivity.java
+++ b/src/com/android/deskclock/worldclock/CitiesActivity.java
@@ -613,7 +613,7 @@ public class CitiesActivity extends Activity implements OnCheckedChangeListener,
mAdapter.set24HoursMode(this);
}
- getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor());
+ getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor(this));
}
@Override