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

Commit 0adea055 authored by Keith Mok's avatar Keith Mok Committed by Arne Coucheron
Browse files

DeskClock: Move default action for flip and shake to overlay

The current default action for flip and shake when alarm comes
is hardcoded. Move it to overlay, so we can config it easily
and overrided by device settings.
Also change the default action for flip to dismiss alarm.

Change-Id: I18a1850b7bf5f9342b121f6a9c930b3a05d40ed1
parent 8ca73f73
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -23,6 +23,15 @@
    <bool name="config_requiresScreenSaver">true</bool>
    <bool name="config_dockAppEnabled">true</bool>
    <bool name="config_rotateAlarmAlert">false</bool>
    <!-- Default action for flip (turn face down) during alarm
         0 means no action, 1 means snooze
         2 means dismiss. -->
    <integer name="config_defaultActionFlip">2</integer>
    <!-- Default action for shake during alarm
         0 means no action, 1 means snooze
         2 means dismiss. -->
    <integer name="config_defaultActionShake">0</integer>

    <item type="integer" name="timer_column_count">1</item>
    <!-- Number of world clocks in a row, for the clock tab. -->
    <item type="integer" name="world_clocks_per_row">1</item>
+2 −2
Original line number Diff line number Diff line
@@ -84,14 +84,14 @@
            android:title="@string/default_alarm_tone_title" />

        <ListPreference
            android:defaultValue="0"
            android:defaultValue="@integer/config_defaultActionFlip"
            android:dialogTitle="@string/flip_action_title"
            android:entries="@array/volume_button_setting_entries"
            android:entryValues="@array/volume_button_setting_values"
            android:key="flip_action"
            android:title="@string/flip_action_title" />
        <ListPreference
            android:defaultValue="0"
            android:defaultValue="@integer/config_defaultActionShake"
            android:dialogTitle="@string/shake_action_title"
            android:entries="@array/volume_button_setting_entries"
            android:entryValues="@array/volume_button_setting_values"
+6 −6
Original line number Diff line number Diff line
@@ -87,8 +87,6 @@ public class AlarmService extends Service {
    private static final int ALARM_NO_ACTION = 0;
    private static final int ALARM_SNOOZE = 1;
    private static final int ALARM_DISMISS = 2;
    // default action for flip and shake
    private static final String DEFAULT_ACTION = "0";

    @Override
    public IBinder onBind(Intent intent) {
@@ -253,10 +251,12 @@ public class AlarmService extends Service {

        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        SharedPreferences prefs = Utils.getDefaultSharedPreferences(this);
        mFlipAction = Integer.parseInt(prefs.getString(
                SettingsActivity.KEY_FLIP_ACTION, DEFAULT_ACTION));
        mShakeAction = Integer.parseInt(prefs.getString(
                SettingsActivity.KEY_SHAKE_ACTION, DEFAULT_ACTION));
        String action = prefs.getString(SettingsActivity.KEY_FLIP_ACTION, null);
        mFlipAction = (action != null) ? Integer.parseInt(action) :
            getResources().getInteger(R.integer.config_defaultActionFlip);
        action  = prefs.getString(SettingsActivity.KEY_SHAKE_ACTION, null);
        mShakeAction = (action != null) ? Integer.parseInt(action) :
            getResources().getInteger(R.integer.config_defaultActionShake);
    }

    @Override