aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDvTonder <david.vantonder@gmail.com>2013-03-06 17:34:52 -0500
committerDvTonder <david.vantonder@gmail.com>2013-03-06 17:34:52 -0500
commit69bb6736f1956318706db94359ff46c20cfe4b21 (patch)
tree4935f1e43394db7e6934be3931f87f143af0c3bf
parente8759b2ef8b3e5b788d364dc6dac1b617efa2aa9 (diff)
downloadandroid_packages_apps_LockClock-69bb6736f1956318706db94359ff46c20cfe4b21.tar.gz
android_packages_apps_LockClock-69bb6736f1956318706db94359ff46c20cfe4b21.tar.bz2
android_packages_apps_LockClock-69bb6736f1956318706db94359ff46c20cfe4b21.zip
cLock: Make the showing of weather when minimized a user option
Also includes some code cleanup Change-Id: Iad2c4dba4f6e1d77fae28d3f52fa1ef878815614
-rw-r--r--res/layout/appwidget.xml2
-rw-r--r--res/layout/appwidget_small.xml2
-rw-r--r--res/layout/clock_panel.xml1
-rw-r--r--res/layout/clock_panel_small.xml1
-rw-r--r--res/layout/preference_header_item.xml2
-rw-r--r--res/menu/options_menu.xml2
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/preferences_calendar.xml9
-rw-r--r--res/xml/preferences_weather.xml30
-rw-r--r--src/com/cyanogenmod/lockclock/ClockWidgetService.java9
-rw-r--r--src/com/cyanogenmod/lockclock/misc/Constants.java1
-rw-r--r--src/com/cyanogenmod/lockclock/misc/Preferences.java24
-rw-r--r--src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java1
13 files changed, 67 insertions, 19 deletions
diff --git a/res/layout/appwidget.xml b/res/layout/appwidget.xml
index a06e72c..0af81c2 100644
--- a/res/layout/appwidget.xml
+++ b/res/layout/appwidget.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/layout/appwidget_small.xml b/res/layout/appwidget_small.xml
index 53b8a53..f86c300 100644
--- a/res/layout/appwidget_small.xml
+++ b/res/layout/appwidget_small.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/layout/clock_panel.xml b/res/layout/clock_panel.xml
index 5c27d8c..ca35087 100644
--- a/res/layout/clock_panel.xml
+++ b/res/layout/clock_panel.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
+ Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/layout/clock_panel_small.xml b/res/layout/clock_panel_small.xml
index eae312a..3f757e2 100644
--- a/res/layout/clock_panel_small.xml
+++ b/res/layout/clock_panel_small.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
+ Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/layout/preference_header_item.xml b/res/layout/preference_header_item.xml
index 75536af..801c832 100644
--- a/res/layout/preference_header_item.xml
+++ b/res/layout/preference_header_item.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
+<!-- Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/menu/options_menu.xml b/res/menu/options_menu.xml
index 856bc5f..16758af 100644
--- a/res/menu/options_menu.xml
+++ b/res/menu/options_menu.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The CyanogenMod Project
+<!-- Copyright (C) 2013 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e80b715..48487be 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -144,6 +144,8 @@
<string name="weather_progress_title">Verifying location</string>
<string name="weather_alternate_icons_title">Use alternate icons</string>
<string name="weather_alternate_icons_summary">Select to toggle between the default (White) and the alternate (Color) icons</string>
+ <string name="weather_show_when_minimized_title">Show when minimized</string>
+ <string name="weather_show_when_minimized_summary">Display summary weather information when the widget is minimized</string>
<!-- Preferences - Calendar -->
<string name="calendar_title">Display next event</string>
diff --git a/res/xml/preferences_calendar.xml b/res/xml/preferences_calendar.xml
index 1f3cdb4..c28a076 100644
--- a/res/xml/preferences_calendar.xml
+++ b/res/xml/preferences_calendar.xml
@@ -23,7 +23,8 @@
<CheckBoxPreference
android:key="show_calendar"
- android:title="@string/calendar_title" />
+ android:title="@string/calendar_title"
+ android:defaultValue="false" />
<MultiSelectListPreference
android:key="calendar_list"
@@ -46,12 +47,14 @@
android:key="calendar_reminders_only"
android:dependency="show_calendar"
android:title="@string/calendar_reminders_only_title"
- android:summary="@string/calendar_reminders_only_summary" />
+ android:summary="@string/calendar_reminders_only_summary"
+ android:defaultValue="false" />
<CheckBoxPreference
android:key="calendar_hide_allday"
android:dependency="show_calendar"
- android:title="@string/calendar_hide_allday_title" />
+ android:title="@string/calendar_hide_allday_title"
+ android:defaultValue="false" />
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/preferences_weather.xml b/res/xml/preferences_weather.xml
index 7cfb516..8544cfc 100644
--- a/res/xml/preferences_weather.xml
+++ b/res/xml/preferences_weather.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
+<!-- Copyright (C) 2009 The CyanogenMod Project (DvTonder)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -24,7 +24,8 @@
<CheckBoxPreference
android:key="show_weather"
android:title="@string/weather_enable"
- android:summary="@string/weather_source" />
+ android:summary="@string/weather_source"
+ android:defaultValue="true" />
<ListPreference
android:key="weather_refresh_interval"
@@ -38,7 +39,8 @@
<CheckBoxPreference
android:key="weather_use_custom_location"
android:dependency="show_weather"
- android:title="@string/weather_use_custom_location" />
+ android:title="@string/weather_use_custom_location"
+ android:defaultValue="false" />
<EditTextPreference
android:key="weather_custom_location_string"
@@ -52,29 +54,41 @@
android:title="@string/display_category" >
<CheckBoxPreference
+ android:key="weather_show_when_minimized"
+ android:dependency="show_weather"
+ android:title="@string/weather_show_when_minimized_title"
+ android:summary="@string/weather_show_when_minimized_summary"
+ android:defaultValue="true" />
+
+ <CheckBoxPreference
android:key="weather_use_alternate_icons"
android:dependency="show_weather"
android:title="@string/weather_alternate_icons_title"
- android:summary="@string/weather_alternate_icons_summary" />
+ android:summary="@string/weather_alternate_icons_summary"
+ android:defaultValue="false" />
<CheckBoxPreference
android:key="weather_use_metric"
android:dependency="show_weather"
- android:title="@string/weather_use_metric" />
+ android:title="@string/weather_use_metric"
+ android:defaultValue="true" />
<CheckBoxPreference
android:key="weather_show_location"
android:dependency="show_weather"
- android:title="@string/weather_show_location_title" />
+ android:title="@string/weather_show_location_title"
+ android:defaultValue="true" />
<CheckBoxPreference
android:key="weather_show_timestamp"
android:dependency="show_weather"
- android:title="@string/weather_show_timestamp_title" />
+ android:title="@string/weather_show_timestamp_title"
+ android:defaultValue="true" />
<CheckBoxPreference
android:key="weather_invert_lowhigh"
android:dependency="show_weather"
- android:title="@string/weather_invert_lowhigh" />
+ android:title="@string/weather_invert_lowhigh"
+ android:defaultValue="false" />
</PreferenceCategory>
</PreferenceScreen> \ No newline at end of file
diff --git a/src/com/cyanogenmod/lockclock/ClockWidgetService.java b/src/com/cyanogenmod/lockclock/ClockWidgetService.java
index a34105d..c190dab 100644
--- a/src/com/cyanogenmod/lockclock/ClockWidgetService.java
+++ b/src/com/cyanogenmod/lockclock/ClockWidgetService.java
@@ -97,16 +97,19 @@ public class ClockWidgetService extends IntentService {
RemoteViews remoteViews;
boolean digitalClock = Preferences.showDigitalClock(this);
boolean showWeather = Preferences.showWeather(this);
+ boolean showWeatherWhenMinimized = Preferences.showWeatherWhenMinimized(this);
boolean showCalendar = false;
// Update the widgets
for (int id : mWidgetIds) {
// Determine which layout to use
- boolean smallWidget = showWeather && WidgetUtils.showSmallWidget(this, id, digitalClock);
+ boolean smallWidget = showWeather && showWeatherWhenMinimized
+ && WidgetUtils.showSmallWidget(this, id, digitalClock);
if (smallWidget) {
// The small widget is only shown if weather needs to be shown
- // and there is not enough space for the full weather widget
+ // and there is not enough space for the full weather widget and
+ // the user had selected to show the weather when minimized (default ON)
remoteViews = new RemoteViews(getPackageName(), R.layout.appwidget_small);
showCalendar = false;
} else {
@@ -138,7 +141,7 @@ public class ClockWidgetService extends IntentService {
}
// Resize the clock font if needed
- if (digitalClock && !smallWidget) {
+ if (digitalClock) {
float ratio = WidgetUtils.getScaleRatio(this, id);
setClockSize(remoteViews, ratio);
}
diff --git a/src/com/cyanogenmod/lockclock/misc/Constants.java b/src/com/cyanogenmod/lockclock/misc/Constants.java
index e7a2c0a..bc62401 100644
--- a/src/com/cyanogenmod/lockclock/misc/Constants.java
+++ b/src/com/cyanogenmod/lockclock/misc/Constants.java
@@ -38,6 +38,7 @@ public class Constants {
public static final String WEATHER_REFRESH_INTERVAL = "weather_refresh_interval";
public static final String WEATHER_USE_ALTERNATE_ICONS = "weather_use_alternate_icons";
public static final String WEATHER_WOEID = "weather_woeid";
+ public static final String WEATHER_SHOW_WHEN_MINIMIZED = "weather_show_when_minimized";
public static final String SHOW_CALENDAR = "show_calendar";
public static final String CALENDAR_LIST = "calendar_list";
diff --git a/src/com/cyanogenmod/lockclock/misc/Preferences.java b/src/com/cyanogenmod/lockclock/misc/Preferences.java
index 89a85c1..6f8d19f 100644
--- a/src/com/cyanogenmod/lockclock/misc/Preferences.java
+++ b/src/com/cyanogenmod/lockclock/misc/Preferences.java
@@ -30,12 +30,15 @@ public class Preferences {
public static boolean showDigitalClock(Context context) {
return getPrefs(context).getBoolean(Constants.CLOCK_DIGITAL, true);
}
+
public static boolean showAlarm(Context context) {
return getPrefs(context).getBoolean(Constants.CLOCK_SHOW_ALARM, true);
}
+
public static boolean showWeather(Context context) {
return getPrefs(context).getBoolean(Constants.SHOW_WEATHER, true);
}
+
public static boolean showCalendar(Context context) {
return getPrefs(context).getBoolean(Constants.SHOW_CALENDAR, false);
}
@@ -43,35 +46,48 @@ public class Preferences {
public static boolean useBoldFontForHours(Context context) {
return getPrefs(context).getBoolean(Constants.CLOCK_FONT, true);
}
+
public static boolean useBoldFontForMinutes(Context context) {
return getPrefs(context).getBoolean(Constants.CLOCK_FONT_MINUTES, false);
}
+
public static boolean useBoldFontForDateAndAlarms(Context context) {
return getPrefs(context).getBoolean(Constants.CLOCK_FONT_DATE, true);
}
+ public static boolean showWeatherWhenMinimized(Context context) {
+ return getPrefs(context).getBoolean(Constants.WEATHER_SHOW_WHEN_MINIMIZED, true);
+ }
+
public static boolean showWeatherLocation(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_SHOW_LOCATION, true);
}
+
public static boolean showWeatherTimestamp(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_SHOW_TIMESTAMP, true);
}
+
public static boolean invertLowHighTemperature(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_INVERT_LOWHIGH, false);
}
+
public static boolean useAlternateWeatherIcons(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_USE_ALTERNATE_ICONS, false);
}
+
public static boolean useMetricUnits(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_USE_METRIC, true);
}
+
public static long weatherRefreshIntervalInMs(Context context) {
String value = getPrefs(context).getString(Constants.WEATHER_REFRESH_INTERVAL, "60");
return Long.parseLong(value) * 60 * 1000;
}
+
public static boolean useCustomWeatherLocation(Context context) {
return getPrefs(context).getBoolean(Constants.WEATHER_USE_CUSTOM_LOCATION, false);
}
+
public static String customWeatherLocation(Context context) {
return getPrefs(context).getString(Constants.WEATHER_CUSTOM_LOCATION_STRING, null);
}
@@ -84,16 +100,20 @@ public class Preferences {
}
editor.apply();
}
+
public static long lastWeatherUpdateTimestamp(Context context) {
return getPrefs(context).getLong(Constants.WEATHER_LAST_UPDATE, 0);
}
+
public static WeatherInfo getCachedWeatherInfo(Context context) {
return WeatherInfo.fromSerializedString(context,
getPrefs(context).getString(Constants.WEATHER_DATA, null));
}
+
public static String getCachedWoeid(Context context) {
return getPrefs(context).getString(Constants.WEATHER_WOEID, null);
}
+
public static void setCachedWoeid(Context context, String woeid) {
getPrefs(context).edit().putString(Constants.WEATHER_WOEID, woeid).apply();
}
@@ -101,12 +121,15 @@ public class Preferences {
public static Set<String> calendarsToDisplay(Context context) {
return getPrefs(context).getStringSet(Constants.CALENDAR_LIST, null);
}
+
public static boolean showEventsWithRemindersOnly(Context context) {
return getPrefs(context).getBoolean(Constants.CALENDAR_REMINDERS_ONLY, false);
}
+
public static boolean showAllDayEvents(Context context) {
return !getPrefs(context).getBoolean(Constants.CALENDAR_HIDE_ALLDAY, false);
}
+
public static long lookAheadTimeInMs(Context context) {
return Long.parseLong(getPrefs(context).getString(Constants.CALENDAR_LOOKAHEAD, "10800000"));
}
@@ -118,6 +141,7 @@ public class Preferences {
public static int calendarLocationMode(Context context) {
return Integer.parseInt(getPrefs(context).getString(Constants.CALENDAR_SHOW_LOCATION, "0"));
}
+
public static int calendarDescriptionMode(Context context) {
return Integer.parseInt(getPrefs(context).getString(Constants.CALENDAR_SHOW_DESCRIPTION, "0"));
}
diff --git a/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java b/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java
index 6c2895e..48a572f 100644
--- a/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java
+++ b/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java
@@ -32,7 +32,6 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
-import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
import android.provider.Settings;