Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da6c5b10 authored by James Lemieux's avatar James Lemieux
Browse files

Give up the dream of supporting pre-Kitkat

All SDK version checks are now routed through readable
cover methods on Utils. All code paths handling SDK
versions that predate Kitkat have been removed.

Change-Id: I876620ad34ab3d701789cb35904ccfe03c2d1e45
parent 0750923e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
     limitations under the License.
-->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<resources>
    <!-- String matching the lock screen format for displaying the date. -->
    <string name="abbrev_wday_month_day_no_year">EEEMMMMd</string>
    <!-- Format for describing the date, for accessibility. -->
+0 −36
Original line number Diff line number Diff line
@@ -921,42 +921,6 @@
    <!-- String for no enabled alarms in timeline view [CHAR LIMIT=30] -->
    <string name="no_upcoming_alarms">NO UPCOMING ALARMS</string>

    <!--
        String that represents time format for 12-hour time.
        h represents hour in range (1-12) with the minimum number of digits
        mm represents minute with leading 0 in case of values < 10
        a represents am/pm
        Ex: h:mm a = 12:54 am, 8:05 pm
    -->
    <string name="time_format_12_mode">h&#58;mm a</string>

    <!--
        String that represents time format for 24-hour time.
        k represents hour in range (0-23) with the minimum number of digits
        mm represents minute with leading 0 in case of values < 10
        Ex: k:mm = 13:51, 5:05
    -->
    <string name="time_format_24_mode">k&#58;mm</string>

    <!--
        String that represents weekday, time format for 12-hour time.
        EEE represents weekday name in short form (ex. Mon, Tue, Wed)
        h represents hour in range (1-12) with the minimum number of digits
        mm represents minute with leading 0 in case of values < 10
        a represents am/pm
        Ex: EEE, h:mm a = Mon, 2:55 pm
    -->
    <string name="weekday_time_format_12_mode">EEE, h&#58;mm a</string>

    <!--
        String that represents weekday, time format for 24-hour time.
        EEE represents weekday name in short form (ex. Mon, Tue, Wed)
        k represents hour in range (0-23) with the minimum number of digits
        mm represents minute with leading 0 in case of values < 10
        Ex: EEE, k:mm = Mon, 2:55
    -->
    <string name="weekday_time_format_24_mode">EEE, k&#58;mm</string>

    <!-- String that represents that invalid time for an alarm was specified, e.g. 23:00am
     or 27:68pm.
    First %d represents hour, second %d represents minutes, %s represents am/pm,
+11 −18
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
@@ -39,7 +40,6 @@ import com.android.deskclock.alarms.AlarmStateManager;
import com.android.deskclock.worldclock.Cities;
import com.android.deskclock.worldclock.CitiesActivity;

import java.text.SimpleDateFormat;
import java.util.Locale;

public class DigitalAppWidgetProvider extends AppWidgetProvider {
@@ -72,7 +72,7 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
    public void onReceive(@NonNull Context context, @NonNull Intent intent) {
        String action = intent.getAction();
        if (DigitalAppWidgetService.LOGGING) {
            Log.i(TAG, "onReceive: " + action);
@@ -185,13 +185,11 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider {
        WidgetUtils.setClockSize(context, widget, ratio);

        // Set today's date format
        final CharSequence dateFormat = Utils.isJBMR2OrLater()
                ? DateFormat.getBestDateTimePattern(Locale.getDefault(),
                        context.getString(R.string.abbrev_wday_month_day_no_year))
                : ((SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT))
                        .toPattern();
        widget.setCharSequence(R.id.date, "setFormat12Hour", dateFormat);
        widget.setCharSequence(R.id.date, "setFormat24Hour", dateFormat);
        final Locale locale = Locale.getDefault();
        final String skeleton = context.getString(R.string.abbrev_wday_month_day_no_year);
        final CharSequence timeFormat = DateFormat.getBestDateTimePattern(locale, skeleton);
        widget.setCharSequence(R.id.date, "setFormat12Hour", timeFormat);
        widget.setCharSequence(R.id.date, "setFormat24Hour", timeFormat);

        // Set up R.id.digital_appwidget_listview to use a remote views adapter
        // That remote views adapter connects to a RemoteViewsService through intent.
@@ -237,15 +235,10 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider {
     */
    private void startAlarmOnQuarterHour(Context context) {
        if (context != null) {
            long onQuarterHour = Utils.getAlarmOnQuarterHour();
            PendingIntent quarterlyIntent = getOnQuarterHourPendingIntent(context);
            AlarmManager alarmManager = ((AlarmManager) context
                    .getSystemService(Context.ALARM_SERVICE));
            if (Utils.isKitKatOrLater()) {
                alarmManager.setExact(AlarmManager.RTC, onQuarterHour, quarterlyIntent);
            } else {
                alarmManager.set(AlarmManager.RTC, onQuarterHour, quarterlyIntent);
            }
            final long onQuarterHour = Utils.getAlarmOnQuarterHour();
            final PendingIntent quarterlyIntent = getOnQuarterHourPendingIntent(context);
            final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
            am.setExact(AlarmManager.RTC, onQuarterHour, quarterlyIntent);
            if (DigitalAppWidgetService.LOGGING) {
                Log.v(TAG, "startAlarmOnQuarterHour " + context.toString());
            }
+2 −10
Original line number Diff line number Diff line
@@ -41,16 +41,8 @@ public class AlarmUtils {
    public static final String FRAG_TAG_TIME_PICKER = "time_dialog";

    public static String getFormattedTime(Context context, Calendar time) {
        String pattern;
        if (Utils.isJBMR2OrLater()) {
        final String skeleton = DateFormat.is24HourFormat(context) ? "EHm" : "Ehma";
            pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
            return (String) DateFormat.format(pattern, time);
        } else {
            pattern = DateFormat.is24HourFormat(context)
                    ? context.getString(R.string.weekday_time_format_24_mode)
                    : context.getString(R.string.weekday_time_format_12_mode);
        }
        final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
        return (String) DateFormat.format(pattern, time);
    }

+6 −19
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
@@ -48,8 +47,6 @@ import com.android.deskclock.worldclock.WorldClockAdapter;
public class ClockFragment extends DeskClockFragment implements OnSharedPreferenceChangeListener {

    private static final String BUTTONS_HIDDEN_KEY = "buttons_hidden";
    private static final boolean PRE_L_DEVICE =
            Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
    private final static String TAG = "ClockFragment";

    private boolean mButtonsHidden = false;
@@ -59,8 +56,6 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
    private SharedPreferences mPrefs;
    private String mDateFormat;
    private String mDateFormatForAccessibility;
    private String mDefaultClockStyle;
    private String mClockStyle;

    private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        @Override
@@ -102,7 +97,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
    private final Handler mHandler = new Handler();

    /* Register ContentObserver to see alarm changes for pre-L */
    private final ContentObserver mAlarmObserver = PRE_L_DEVICE
    private final ContentObserver mAlarmObserver = Utils.isPreL()
            ? new ContentObserver(mHandler) {
                @Override
                public void onChange(boolean selfChange) {
@@ -128,8 +123,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle icicle) {
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.clock_fragment, container, false);
        if (icicle != null) {
@@ -141,9 +135,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
        OnTouchListener longPressNightMode = new OnTouchListener() {
            private float mMaxMovementAllowed = -1;
            private int mLongPressTimeout = -1;
            private float mLastTouchX
                    ,
                    mLastTouchY;
            private float mLastTouchX, mLastTouchY;

            @Override
            public boolean onTouch(View v, MotionEvent event) {
@@ -154,7 +146,6 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen

                switch (event.getAction()) {
                    case (MotionEvent.ACTION_DOWN):
                        long time = Utils.getTimeNow();
                        mHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
@@ -215,7 +206,6 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
        mList.setAdapter(mAdapter);

        mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        mDefaultClockStyle = getActivity().getResources().getString(R.string.default_clock_style);
        return v;
    }

@@ -249,10 +239,8 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
            mAdapter.reloadData(activity);
        }
        // Resume can invoked after changing the clock style.
        View clockView = Utils.setClockStyle(activity, mDigitalClock, mAnalogClock,
        Utils.setClockStyle(activity, mDigitalClock, mAnalogClock,
                SettingsActivity.KEY_CLOCK_STYLE);
        mClockStyle = (clockView == mDigitalClock ?
                Utils.CLOCK_TYPE_DIGITAL : Utils.CLOCK_TYPE_ANALOG);

        // Center the main clock frame if cities are empty.
        if (getView().findViewById(R.id.main_clock_left_pane) != null && mAdapter.getCount() == 0) {
@@ -264,7 +252,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen

        Utils.updateDate(mDateFormat, mDateFormatForAccessibility, mClockFrame);
        Utils.refreshAlarm(activity, mClockFrame);
        if (PRE_L_DEVICE) {
        if (Utils.isPreL()) {
            activity.getContentResolver().registerContentObserver(
                Settings.System.getUriFor(Settings.System.NEXT_ALARM_FORMATTED),
                false,
@@ -279,7 +267,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
        Utils.cancelQuarterHourUpdater(mHandler, mQuarterHourUpdater);
        Activity activity = getActivity();
        activity.unregisterReceiver(mIntentReceiver);
        if (PRE_L_DEVICE) {
        if (Utils.isPreL()) {
            activity.getContentResolver().unregisterContentObserver(mAlarmObserver);
        }
    }
@@ -293,7 +281,6 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
    @Override
    public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
        if (key == SettingsActivity.KEY_CLOCK_STYLE) {
            mClockStyle = prefs.getString(SettingsActivity.KEY_CLOCK_STYLE, mDefaultClockStyle);
            mAdapter.notifyDataSetChanged();
        }
    }
Loading