Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions app/src/main/java/com/darkeyes/tricks/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public class Main implements IXposedHookZygoteInit, IXposedHookLoadPackage {
private PowerManager.WakeLock mWakeUpWakeLock;
private int MSG_WAKE_UP = 100;
private ArrayMap<String, Long> mLastTimestamps = new ArrayMap<>();
private long mDownTime = 0L;
private boolean mVolumeUp = false;
private boolean mVolumeDown = false;
private boolean mCameraGesture;
private GestureDetector mDoubleTapGesture;
private Object mNotificationPanelViewController;
Expand Down Expand Up @@ -1116,12 +1117,25 @@ protected void beforeHookedMethod(MethodHookParam param) {
}
}

if (keyCode == KeyEvent.KEYCODE_POWER && mPowerManager.isInteractive()) {
mDownTime = event.getEventTime();
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
if (event.getAction() == KeyEvent.ACTION_DOWN && mPowerManager.isInteractive()) {
mVolumeUp = true;
}
else {
mVolumeUp = false;
}
}

if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
if (event.getAction() == KeyEvent.ACTION_DOWN && mPowerManager.isInteractive()) {
mVolumeDown = true;
}
else {
mVolumeDown = false;
}
}

if (keyCode == KeyEvent.KEYCODE_POWER && ((!mPowerManager.isInteractive() &&
(event.getEventTime() - mDownTime > 300)) || mTorchEnabled) && event.getSource() != InputDevice.SOURCE_UNKNOWN) {
if (keyCode == KeyEvent.KEYCODE_POWER && mVolumeUp == false && mVolumeDown == false && event.getSource() != InputDevice.SOURCE_UNKNOWN) {
if (mSensorManager == null)
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
if (mProximitySensor == null)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="skipTrack_title">Volume keys skip track</string>
<string name="skipTrack_summary">Skip track by long pressing volume keys while screen is off</string>
<string name="powerTorch_title">Power key toggles torch</string>
<string name="powerTorch_summary">Toggle torch by long pressing power key while screen is off</string>
<string name="powerTorch_summary">Toggle torch by long pressing power key</string>
<string name="proximityWakeUp_title">Prevent accidental wake up</string>
<string name="proximityWakeUp_summary">Check the proximity sensor before waking up the phone</string>
<string name="lessNotifications_title">Less frequent notifications (sound and vibration)</string>
Expand Down