-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle intent parameters, first implementation of launching immersive…
… mode by simulating clicks
- Loading branch information
1 parent
7319e31
commit 58ebb3a
Showing
4 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/src/common/shared/com/igalia/wolvic/launchmode/ImmersiveModeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.igalia.wolvic.launchmode; | ||
|
||
import android.net.Uri; | ||
import android.os.SystemClock; | ||
import android.view.MotionEvent; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import com.igalia.wolvic.ui.widgets.WindowWidget; | ||
|
||
public class ImmersiveModeController { | ||
@NonNull private final Uri mTargetUri; | ||
@Nullable private final Integer mTargetX; | ||
@Nullable private final Integer mTargetY; | ||
@Nullable private final String mTargetElement; | ||
@Nullable private final String mTargetEvent; | ||
|
||
private boolean mTriggered = false; | ||
|
||
public ImmersiveModeController(@NonNull Uri targetUri, | ||
@Nullable Integer targetX, @Nullable Integer targetY, | ||
@Nullable String targetElement, @Nullable String targetEvent) { | ||
mTargetUri = targetUri; | ||
mTargetX = targetX; | ||
mTargetY = targetY; | ||
mTargetElement = targetElement; | ||
mTargetEvent = targetEvent; | ||
} | ||
|
||
@NonNull public Uri getTargetUri() { | ||
return mTargetUri; | ||
} | ||
|
||
@Nullable public Integer getTargetX() { | ||
return mTargetX; | ||
} | ||
|
||
@Nullable public Integer getTargetY() { | ||
return mTargetY; | ||
} | ||
|
||
@Nullable public String getTargetElement() { | ||
return mTargetElement; | ||
} | ||
|
||
@Nullable public String getTargetEvent() { | ||
return mTargetEvent; | ||
} | ||
|
||
public void launchImmersiveMode(WindowWidget window) { | ||
if (mTriggered) { | ||
return; | ||
} | ||
|
||
if (mTargetX != null && mTargetY != null) { | ||
MotionEvent downEvent = MotionEvent.obtain( | ||
SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), | ||
MotionEvent.ACTION_DOWN, mTargetX, mTargetY, 0); | ||
window.handleTouchEvent(downEvent); | ||
|
||
MotionEvent upEvent = MotionEvent.obtain( | ||
SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), | ||
MotionEvent.ACTION_DOWN, mTargetX, mTargetY, 0); | ||
window.handleTouchEvent(upEvent); | ||
|
||
downEvent.recycle(); | ||
upEvent.recycle(); | ||
} | ||
mTriggered = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters