Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher3: Allow to customize bottom corner swipe up action [1/4] #436

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from
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
1 change: 1 addition & 0 deletions AndroidManifest-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<uses-permission android:name="org.omnirom.omnijaws.READ_WEATHER" />
<uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.INJECT_EVENTS" />

<!-- AppLock -->
<uses-permission android:name="android.permission.MANAGE_APP_LOCK" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,23 @@
import android.content.Context;
import android.content.res.Resources;
import android.graphics.PointF;
import android.hardware.input.InputManager;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;

import com.android.app.animation.Interpolators;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.util.window.WindowManagerProxy;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
Expand Down Expand Up @@ -237,17 +243,16 @@ private void updateAssistantProgress() {
}

private void startAssistantInternal() {
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HOME, KeyEvent.FLAG_LONG_SWIPE);
sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HOME, KeyEvent.FLAG_LONG_SWIPE);

BaseDraggingActivity launcherActivity = mActivityInterface.getCreatedActivity();
if (launcherActivity != null) {
launcherActivity.getRootView().performHapticFeedback(
13, // HapticFeedbackConstants.GESTURE_END
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}

Bundle args = new Bundle();
args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
mLaunchedAssistant = true;
}

Expand All @@ -263,6 +268,19 @@ private boolean isValidAssistantGestureAngle(float deltaX, float deltaY) {
return (angle > mAngleThreshold && angle < 90);
}

private boolean sendEvent(int action, int code, int flags) {
long when = SystemClock.uptimeMillis();
final KeyEvent ev = new KeyEvent(when, when, action, code, 0 /* repeat */,
0 /* metaState */, KeyCharacterMap.VIRTUAL_KEYBOARD, 0 /* scancode */,
flags | KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY,
InputDevice.SOURCE_KEYBOARD);

int displayId = WindowManagerProxy.INSTANCE.get(mContext).getDisplayId(mContext);
ev.setDisplayId(displayId);
return InputManager.getInstance()
.injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}

private class AssistantGestureListener extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
Expand Down
8 changes: 8 additions & 0 deletions src/com/android/launcher3/util/window/WindowManagerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ public int getRotation(Context displayInfoContext) {
return getDisplay(displayInfoContext).getRotation();
}

/**
* Returns display ID of the display associated with the context, or display ID of DEFAULT_DISPLAY
* if the context isn't associated with a display.
*/
public int getDisplayId(Context displayInfoContext) {
return getDisplay(displayInfoContext).getDisplayId();
}

/**
* Returns the display associated with the context, or DEFAULT_DISPLAY if the context isn't
* associated with a display.
Expand Down