summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-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
7 files changed, 27 insertions, 17 deletions
diff --git a/src/com/android/deskclock/AlarmClockFragment.java b/src/com/android/deskclock/AlarmClockFragment.java
index e4c549188..ac2eb16ae 100644
--- a/src/com/android/deskclock/AlarmClockFragment.java
+++ b/src/com/android/deskclock/AlarmClockFragment.java
@@ -1162,7 +1162,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)));
@@ -1393,7 +1393,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 dc3cb45a7..43aba4274 100644
--- a/src/com/android/deskclock/DeskClock.java
+++ b/src/com/android/deskclock/DeskClock.java
@@ -417,7 +417,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 a89c5db7d..f2be14a63 100644
--- a/src/com/android/deskclock/SettingsActivity.java
+++ b/src/com/android/deskclock/SettingsActivity.java
@@ -119,7 +119,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 8bffe21ac..1013a9ca8 100644
--- a/src/com/android/deskclock/alarms/AlarmActivity.java
+++ b/src/com/android/deskclock/alarms/AlarmActivity.java
@@ -190,7 +190,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 ea0ad29f2..607c0e996 100755
--- a/src/com/android/deskclock/worldclock/CitiesActivity.java
+++ b/src/com/android/deskclock/worldclock/CitiesActivity.java
@@ -610,7 +610,7 @@ public class CitiesActivity extends Activity implements OnCheckedChangeListener,
mAdapter.set24HoursMode(this);
}
- getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor());
+ getWindow().getDecorView().setBackgroundColor(Utils.getCurrentHourColor(this));
}
@Override