-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
15 deletions.
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
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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/xtr/keymapper/floatingkeys/SwipeKeyOverlay.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,51 @@ | ||
package xtr.keymapper.floatingkeys; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.DashPathEffect; | ||
import android.graphics.Paint; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import androidx.annotation.UiContext; | ||
import androidx.annotation.UiThread; | ||
|
||
public class SwipeKeyOverlay extends View { | ||
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
private float lineStartX, lineStartY; | ||
private float lineStopX, lineStopY; | ||
|
||
public SwipeKeyOverlay(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public SwipeKeyOverlay(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public SwipeKeyOverlay(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
mPaint.setColor(Color.CYAN); | ||
mPaint.setStrokeWidth(5f); | ||
mPaint.setStyle(Paint.Style.STROKE); | ||
mPaint.setPathEffect(new DashPathEffect(new float[]{5, 10, 15, 20}, 0)); | ||
} | ||
|
||
@Override | ||
protected void onDraw(Canvas canvas) { | ||
super.onDraw(canvas); | ||
canvas.drawLine(lineStartX, lineStartY, lineStopX, lineStopY, mPaint); | ||
} | ||
|
||
@UiThread | ||
public void setLineXyFrom(View view1, View view2) { | ||
this.lineStartX = view1.getX() + view1.getPivotX(); | ||
this.lineStartY = view1.getY() + view1.getPivotY(); | ||
|
||
this.lineStopX = view2.getX() + view2.getPivotX(); | ||
this.lineStopY = view2.getY() + view2.getPivotY(); | ||
invalidate(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/xtr/keymapper/floatingkeys/SwipeKeyView.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,30 @@ | ||
package xtr.keymapper.floatingkeys; | ||
|
||
import android.content.Context; | ||
import android.view.ViewGroup; | ||
|
||
public class SwipeKeyView { | ||
|
||
public SwipeKeyView(ViewGroup rootView){ | ||
Context context = rootView.getContext(); | ||
MovableFloatingActionKey button1 = new MovableFloatingActionKey(context); | ||
MovableFloatingActionKey button2 = new MovableFloatingActionKey(context); | ||
|
||
SwipeKeyOverlay overlay = new SwipeKeyOverlay(context); | ||
rootView.addView(overlay); | ||
|
||
rootView.addView(button1); | ||
rootView.addView(button2); | ||
|
||
button1.setX(rootView.getPivotX() - 100); | ||
button1.setY(rootView.getPivotY() - 100); | ||
|
||
button2.setX(rootView.getPivotX() + 100); | ||
button2.setY(rootView.getPivotY() + 100); | ||
|
||
MovableFloatingActionKey.OnXyChangeListener xyChangeListener = (x, y) -> overlay.setLineXyFrom(button1, button2); | ||
|
||
button1.setXyChangeListener(xyChangeListener); | ||
button2.setXyChangeListener(xyChangeListener); | ||
} | ||
} |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M9,11.24V7.5C9,6.12 10.12,5 11.5,5S14,6.12 14,7.5v3.74c1.21,-0.81 2,-2.18 2,-3.74C16,5.01 13.99,3 11.5,3S7,5.01 7,7.5C7,9.06 7.79,10.43 9,11.24zM18.84,15.87l-4.54,-2.26c-0.17,-0.07 -0.35,-0.11 -0.54,-0.11H13v-6C13,6.67 12.33,6 11.5,6S10,6.67 10,7.5v10.74c-3.6,-0.76 -3.54,-0.75 -3.67,-0.75c-0.31,0 -0.59,0.13 -0.79,0.33l-0.79,0.8l4.94,4.94C9.96,23.83 10.34,24 10.75,24h6.79c0.75,0 1.33,-0.55 1.44,-1.28l0.75,-5.27c0.01,-0.07 0.02,-0.14 0.02,-0.2C19.75,16.63 19.37,16.09 18.84,15.87z"/> | ||
</vector> |
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,35 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xtr.keymapper.floatingkeys.MovableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="320dp" | ||
android:layout_height="240dp" | ||
android:translationZ="2dp" | ||
android:focusable="false" | ||
android:theme="@style/Theme.XtMapper" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
tools:ignore="HardcodedText,ContentDescription"> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:layout_width="60dp" | ||
android:layout_height="60dp" | ||
android:layout_gravity="top|left" | ||
android:id="@+id/key_1" | ||
style="@style/Widget.Material3.Button.IconButton.Filled" /> | ||
<com.google.android.material.button.MaterialButton | ||
android:layout_width="60dp" | ||
android:layout_height="60dp" | ||
android:layout_gravity="bottom|right" | ||
android:id="@+id/key_2" | ||
style="@style/Widget.Material3.Button.IconButton.Filled" /> | ||
|
||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/close_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
app:icon="@android:drawable/ic_delete" | ||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal" | ||
/> | ||
|
||
</xtr.keymapper.floatingkeys.MovableFrameLayout> |
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