diff options
Diffstat (limited to 'src/com/cyanogenmod')
-rw-r--r--[-rwxr-xr-x] | src/com/cyanogenmod/lockclock/ClockWidgetService.java | 26 | ||||
-rw-r--r-- | src/com/cyanogenmod/lockclock/preference/CalendarPreferences.java | 4 | ||||
-rw-r--r-- | src/com/cyanogenmod/lockclock/preference/ClockPreferences.java | 6 | ||||
-rw-r--r-- | src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java | 14 | ||||
-rw-r--r--[-rwxr-xr-x] | src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java | 1 |
5 files changed, 28 insertions, 23 deletions
diff --git a/src/com/cyanogenmod/lockclock/ClockWidgetService.java b/src/com/cyanogenmod/lockclock/ClockWidgetService.java index 31a7837..2c3c57a 100755..100644 --- a/src/com/cyanogenmod/lockclock/ClockWidgetService.java +++ b/src/com/cyanogenmod/lockclock/ClockWidgetService.java @@ -338,21 +338,18 @@ public class ClockWidgetService extends IntentService { if (!smallWidget) { if (Preferences.useBoldFontForDateAndAlarms(this)) { - alarmViews.setTextViewText(R.id.nextAlarm_bold, - nextAlarm.toString().toUpperCase(Locale.getDefault())); + alarmViews.setTextViewText(R.id.nextAlarm_bold, nextAlarm); alarmViews.setViewVisibility(R.id.nextAlarm_bold, View.VISIBLE); alarmViews.setViewVisibility(R.id.nextAlarm_regular, View.GONE); alarmViews.setTextColor(R.id.nextAlarm_bold, color); } else { - alarmViews.setTextViewText(R.id.nextAlarm_regular, - nextAlarm.toString().toUpperCase(Locale.getDefault())); + alarmViews.setTextViewText(R.id.nextAlarm_regular, nextAlarm); alarmViews.setViewVisibility(R.id.nextAlarm_regular, View.VISIBLE); alarmViews.setViewVisibility(R.id.nextAlarm_bold, View.GONE); alarmViews.setTextColor(R.id.nextAlarm_regular, color); } } else { - alarmViews.setTextViewText(R.id.nextAlarm, - nextAlarm.toString().toUpperCase(Locale.getDefault())); + alarmViews.setTextViewText(R.id.nextAlarm, nextAlarm); alarmViews.setViewVisibility(R.id.nextAlarm, View.VISIBLE); alarmViews.setTextColor(R.id.nextAlarm, color); } @@ -374,14 +371,23 @@ public class ClockWidgetService extends IntentService { * @return A formatted string of the next alarm or null if there is no next alarm. */ private String getNextAlarm() { - String nextAlarm = Settings.System.getString( - getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED); - if (nextAlarm == null || TextUtils.isEmpty(nextAlarm)) { - return null; + String nextAlarm = null; + + AlarmManager am =(AlarmManager) getSystemService(Context.ALARM_SERVICE); + AlarmManager.AlarmClockInfo alarmClock = am.getNextAlarmClock(); + if (alarmClock != null) { + nextAlarm = getNextAlarmFormattedTime(this, alarmClock.getTriggerTime()); } + return nextAlarm; } + private static String getNextAlarmFormattedTime(Context context, long time) { + String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma"; + String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton); + return (String) DateFormat.format(pattern, time); + } + //=============================================================================================== // Weather related functionality //=============================================================================================== diff --git a/src/com/cyanogenmod/lockclock/preference/CalendarPreferences.java b/src/com/cyanogenmod/lockclock/preference/CalendarPreferences.java index a192efd..e125929 100644 --- a/src/com/cyanogenmod/lockclock/preference/CalendarPreferences.java +++ b/src/com/cyanogenmod/lockclock/preference/CalendarPreferences.java @@ -112,8 +112,8 @@ public class CalendarPreferences extends PreferenceFragment implements private static final int DISPLAY_NAME_INDEX = 1; static CalendarEntries findCalendars(Context context) { - List<CharSequence> entries = new ArrayList<CharSequence>(); - List<CharSequence> entryValues = new ArrayList<CharSequence>(); + List<CharSequence> entries = new ArrayList<>(); + List<CharSequence> entryValues = new ArrayList<>(); ContentResolver cr = context.getContentResolver(); Cursor calendarCursor = cr.query(uri, projection, null, null, null); diff --git a/src/com/cyanogenmod/lockclock/preference/ClockPreferences.java b/src/com/cyanogenmod/lockclock/preference/ClockPreferences.java index 7a85a8c..88a6acc 100644 --- a/src/com/cyanogenmod/lockclock/preference/ClockPreferences.java +++ b/src/com/cyanogenmod/lockclock/preference/ClockPreferences.java @@ -21,10 +21,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; -import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.preference.SwitchPreference; import android.text.format.DateFormat; import com.cyanogenmod.lockclock.ClockWidgetProvider; @@ -37,7 +37,7 @@ public class ClockPreferences extends PreferenceFragment implements private Context mContext; private ListPreference mClockFontColor; private ListPreference mAlarmFontColor; - private CheckBoxPreference mAmPmToggle; + private SwitchPreference mAmPmToggle; @Override public void onCreate(Bundle savedInstanceState) { @@ -48,7 +48,7 @@ public class ClockPreferences extends PreferenceFragment implements mContext = getActivity(); mClockFontColor = (ListPreference) findPreference(Constants.CLOCK_FONT_COLOR); mAlarmFontColor = (ListPreference) findPreference(Constants.CLOCK_ALARM_FONT_COLOR); - mAmPmToggle = (CheckBoxPreference) findPreference(Constants.CLOCK_AM_PM_INDICATOR); + mAmPmToggle = (SwitchPreference) findPreference(Constants.CLOCK_AM_PM_INDICATOR); updateFontColorsSummary(); updateAmPmToggle(); diff --git a/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java b/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java index 94537c0..97dcef6 100644 --- a/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java +++ b/src/com/cyanogenmod/lockclock/preference/WeatherPreferences.java @@ -25,11 +25,11 @@ import android.content.Intent; import android.content.SharedPreferences; import android.location.LocationManager; import android.os.Bundle; -import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; +import android.preference.SwitchPreference; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -53,13 +53,13 @@ public class WeatherPreferences extends PreferenceFragment implements Constants.WEATHER_REFRESH_INTERVAL }; - private CheckBoxPreference mUseCustomLoc; + private SwitchPreference mUseCustomLoc; private EditTextPreference mCustomWeatherLoc; private ListPreference mFontColor; private ListPreference mTimestampFontColor; - private CheckBoxPreference mUseMetric; + private SwitchPreference mUseMetric; private IconSelectionPreference mIconSet; - private CheckBoxPreference mUseCustomlocation; + private SwitchPreference mUseCustomlocation; private Context mContext; private ContentResolver mResolver; @@ -73,13 +73,13 @@ public class WeatherPreferences extends PreferenceFragment implements mResolver = mContext.getContentResolver(); // Load items that need custom summaries etc. - mUseCustomLoc = (CheckBoxPreference) findPreference(Constants.WEATHER_USE_CUSTOM_LOCATION); + mUseCustomLoc = (SwitchPreference) findPreference(Constants.WEATHER_USE_CUSTOM_LOCATION); mCustomWeatherLoc = (EditTextPreference) findPreference(Constants.WEATHER_CUSTOM_LOCATION_CITY); mFontColor = (ListPreference) findPreference(Constants.WEATHER_FONT_COLOR); mTimestampFontColor = (ListPreference) findPreference(Constants.WEATHER_TIMESTAMP_FONT_COLOR); mIconSet = (IconSelectionPreference) findPreference(Constants.WEATHER_ICONS); - mUseMetric = (CheckBoxPreference) findPreference(Constants.WEATHER_USE_METRIC); - mUseCustomlocation = (CheckBoxPreference) findPreference(Constants.WEATHER_USE_CUSTOM_LOCATION); + mUseMetric = (SwitchPreference) findPreference(Constants.WEATHER_USE_METRIC); + mUseCustomlocation = (SwitchPreference) findPreference(Constants.WEATHER_USE_CUSTOM_LOCATION); // At first placement/start default the use of Metric units based on locale // If we had a previously set value already, this will just reset the same value diff --git a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java index 64fd5c6..662bab4 100755..100644 --- a/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java +++ b/src/com/cyanogenmod/lockclock/weather/WeatherUpdateService.java @@ -26,7 +26,6 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.LocationProvider; -import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.IBinder; |