diff --git a/app/src/main/java/com/termux/window/FloatingBubbleManager.java b/app/src/main/java/com/termux/window/FloatingBubbleManager.java
index 1c9985d..639e514 100644
--- a/app/src/main/java/com/termux/window/FloatingBubbleManager.java
+++ b/app/src/main/java/com/termux/window/FloatingBubbleManager.java
@@ -1,10 +1,13 @@
package com.termux.window;
+import android.graphics.Outline;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
import android.view.WindowManager;
+import com.termux.shared.view.ViewUtils;
import com.termux.view.TerminalView;
/**
@@ -12,9 +15,10 @@
* to its original display.
*/
public class FloatingBubbleManager {
- private static final int BUBBLE_SIZE = 200;
+ private static final int DEFAULT_BUBBLE_SIZE_DP = 56;
private TermuxFloatView mTermuxFloatView;
+ private final int BUBBLE_SIZE_PX;
private boolean mIsMinimized;
@@ -26,9 +30,9 @@ public class FloatingBubbleManager {
private Drawable mOriginalTerminalViewBackground;
private Drawable mOriginalFloatViewBackground;
-
public FloatingBubbleManager(TermuxFloatView termuxFloatView) {
mTermuxFloatView = termuxFloatView;
+ BUBBLE_SIZE_PX = ViewUtils.dpToPx(mTermuxFloatView.getContext(), DEFAULT_BUBBLE_SIZE_DP);
}
public void toggleBubble() {
@@ -50,11 +54,20 @@ public void displayAsFloatingBubble() {
captureOriginalLayoutValues();
WindowManager.LayoutParams layoutParams = getLayoutParams();
- layoutParams.width = BUBBLE_SIZE;
- layoutParams.height = BUBBLE_SIZE;
+
+ layoutParams.width = BUBBLE_SIZE_PX;
+ layoutParams.height = BUBBLE_SIZE_PX;
TerminalView terminalView = getTerminalView();
- terminalView.setBackgroundResource(R.drawable.round_button);
+ final int strokeWidth = (int) terminalView.getResources().getDimension(R.dimen.bubble_outline_stroke_width);
+ terminalView.setOutlineProvider(new ViewOutlineProvider() {
+ @SuppressWarnings("SuspiciousNameCombination")
+ @Override
+ public void getOutline(View view, Outline outline) {
+ // shrink TerminalView clipping a bit so it doesn't cut off our bubble outline
+ outline.setOval(strokeWidth, strokeWidth, view.getWidth() - strokeWidth, view.getHeight() - strokeWidth);
+ }
+ });
terminalView.setClipToOutline(true);
TermuxFloatView termuxFloatView = getTermuxFloatView();
@@ -79,6 +92,7 @@ public void displayAsFloatingWindow() {
TerminalView terminalView = getTerminalView();
terminalView.setBackground(mOriginalTerminalViewBackground);
+ terminalView.setOutlineProvider(null);
terminalView.setClipToOutline(false);
TermuxFloatView termuxFloatView = getTermuxFloatView();
diff --git a/app/src/main/res/drawable/round_button.xml b/app/src/main/res/drawable/round_button.xml
deleted file mode 100644
index c5f59c9..0000000
--- a/app/src/main/res/drawable/round_button.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/round_button_with_outline.xml b/app/src/main/res/drawable/round_button_with_outline.xml
index 0a14446..79b8df4 100644
--- a/app/src/main/res/drawable/round_button_with_outline.xml
+++ b/app/src/main/res/drawable/round_button_with_outline.xml
@@ -4,7 +4,7 @@
+ android:width="@dimen/bubble_outline_stroke_width" />
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..289703c
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,4 @@
+
+
+ 1dp
+
\ No newline at end of file