Skip to content

Commit

Permalink
Clean up doze
Browse files Browse the repository at this point in the history
* remove always enabled option
* use stock fade in delay

Change-Id: Ieebf13f88c02d5036a09b5ef83ca1b53bd6771ac
  • Loading branch information
Altaf-Mahdi authored and SubhrajyotiSen committed May 28, 2017
1 parent ac65772 commit 5b43886
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 65 deletions.
3 changes: 0 additions & 3 deletions doze/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<string name="ambient_display_title">Ambient display</string>
<string name="ambient_display_summary">Wake screen when you receive notifications</string>

<string name="always_enabled_title">Always enable</string>
<string name="always_enabled_summary">Listen for sensor events as soon as the screen turns off</string>

<!-- Tilt sensor -->
<string name="tilt_sensor_title">Tilt sensor</string>
<string name="pick_up_title">Pick up</string>
Expand Down
14 changes: 0 additions & 14 deletions doze/res/xml/doze_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
android:summary="@string/pick_up_summary"
android:dependency="ambient_display" />

<SwitchPreference
android:key="tilt_always"
android:defaultValue="false"
android:title="@string/always_enabled_title"
android:summary="@string/always_enabled_summary"
android:dependency="ambient_display" />

</PreferenceCategory>

<PreferenceCategory
Expand All @@ -60,13 +53,6 @@
android:summary="@string/pocket_gesture_summary"
android:dependency="ambient_display" />

<SwitchPreference
android:key="proximity_always"
android:defaultValue="false"
android:title="@string/always_enabled_title"
android:summary="@string/always_enabled_summary"
android:dependency="ambient_display" />

</PreferenceCategory>

</PreferenceScreen>
6 changes: 3 additions & 3 deletions doze/src/com/cyanogenmod/settings/doze/DozeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ private void onDisplayOn() {

private void onDisplayOff() {
if (DEBUG) Log.d(TAG, "Display off");
if (Utils.pickUpEnabled(this) && Utils.tiltAlwaysEnabled(this)) {
if (Utils.pickUpEnabled(this)) {
mTiltSensor.enable();
}
if (Utils.proximityAlwaysEnabled(this) && (Utils.handwaveGestureEnabled(this) ||
Utils.pocketGestureEnabled(this))) {
if (Utils.handwaveGestureEnabled(this) ||
Utils.pocketGestureEnabled(this)) {
mProximitySensor.enable();
}
}
Expand Down
30 changes: 0 additions & 30 deletions doze/src/com/cyanogenmod/settings/doze/DozeSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ public class DozeSettings extends PreferenceActivity implements OnPreferenceChan

private SwitchPreference mAmbientDisplayPreference;
private SwitchPreference mPickUpPreference;
private SwitchPreference mTiltAlwaysPreference;
private SwitchPreference mHandwavePreference;
private SwitchPreference mPocketPreference;
private SwitchPreference mProximityAlwaysPreference;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -65,10 +63,6 @@ public void onCreate(Bundle savedInstanceState) {
mAmbientDisplayPreference.setChecked(dozeEnabled);
mAmbientDisplayPreference.setOnPreferenceChangeListener(this);

mTiltAlwaysPreference =
(SwitchPreference) findPreference(Utils.TILT_ALWAYS_KEY);
mTiltAlwaysPreference.setOnPreferenceChangeListener(this);

mPickUpPreference =
(SwitchPreference) findPreference(Utils.PICK_UP_KEY);
mPickUpPreference.setOnPreferenceChangeListener(this);
Expand All @@ -81,20 +75,13 @@ public void onCreate(Bundle savedInstanceState) {
(SwitchPreference) findPreference(Utils.GESTURE_POCKET_KEY);
mPocketPreference.setOnPreferenceChangeListener(this);

mProximityAlwaysPreference =
(SwitchPreference) findPreference(Utils.PROXIMITY_ALWAYS_KEY);
mProximityAlwaysPreference.setOnPreferenceChangeListener(this);

final ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);

updateAlwaysEnabledPreference();
}

@Override
protected void onResume() {
super.onResume();
updateAlwaysEnabledPreference();
}

@Override
Expand All @@ -116,25 +103,16 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
} else if (Utils.PICK_UP_KEY.equals(key)) {
mPickUpPreference.setChecked(value);
updateAlwaysEnabledPreference();
Utils.startService(mContext);
return true;
} else if (Utils.TILT_ALWAYS_KEY.equals(key)) {
mTiltAlwaysPreference.setChecked(value);
return true;
} else if (Utils.GESTURE_HAND_WAVE_KEY.equals(key)) {
mHandwavePreference.setChecked(value);
updateAlwaysEnabledPreference();
Utils.startService(mContext);
return true;
} else if (Utils.GESTURE_POCKET_KEY.equals(key)) {
mPocketPreference.setChecked(value);
updateAlwaysEnabledPreference();
Utils.startService(mContext);
return true;
} else if (Utils.PROXIMITY_ALWAYS_KEY.equals(key)) {
mProximityAlwaysPreference.setChecked(value);
return true;
}
return false;
}
Expand Down Expand Up @@ -167,12 +145,4 @@ private void showHelp() {
HelpDialogFragment fragment = new HelpDialogFragment();
fragment.show(getFragmentManager(), "help_dialog");
}

private void updateAlwaysEnabledPreference() {
boolean tiltEnabled = Utils.pickUpEnabled(mContext);
boolean proximityEnabled = Utils.handwaveGestureEnabled(mContext)
|| Utils.pocketGestureEnabled(mContext);
mTiltAlwaysPreference.setEnabled(tiltEnabled);
mProximityAlwaysPreference.setEnabled(proximityEnabled);
}
}
12 changes: 0 additions & 12 deletions doze/src/com/cyanogenmod/settings/doze/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public final class Utils {

protected static final String AMBIENT_DISPLAY_KEY = "ambient_display";
protected static final String PICK_UP_KEY = "pick_up";
protected static final String TILT_ALWAYS_KEY = "tilt_always";
protected static final String GESTURE_HAND_WAVE_KEY = "gesture_hand_wave";
protected static final String GESTURE_POCKET_KEY = "gesture_pocket";
protected static final String PROXIMITY_ALWAYS_KEY = "proximity_always";

protected static void startService(Context context) {
if (DEBUG) Log.d(TAG, "Starting service");
Expand Down Expand Up @@ -77,11 +75,6 @@ protected static boolean pickUpEnabled(Context context) {
.getBoolean(PICK_UP_KEY, false);
}

protected static boolean tiltAlwaysEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(TILT_ALWAYS_KEY, false);
}

protected static boolean handwaveGestureEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(GESTURE_HAND_WAVE_KEY, false);
Expand All @@ -92,11 +85,6 @@ protected static boolean pocketGestureEnabled(Context context) {
.getBoolean(GESTURE_POCKET_KEY, false);
}

protected static boolean proximityAlwaysEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(PROXIMITY_ALWAYS_KEY, false);
}

protected static boolean sensorsEnabled(Context context) {
return pickUpEnabled(context) || handwaveGestureEnabled(context)
|| pocketGestureEnabled(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
<!-- Doze: check proximity sensor before pulsing from intent? -->
<bool name="doze_proximity_check_before_pulse_intent">true</bool>

<!-- Doze: pulse parameter - how long does it take to fade in after an intent? -->
<integer name="doze_pulse_duration_in_intent">0</integer>

<!-- Doze: pulse parameter - delay to wait for the screen to wake up after an intent -->
<integer name="doze_pulse_delay_in_intent">0</integer>

Expand Down

0 comments on commit 5b43886

Please sign in to comment.