Skip to content

Commit

Permalink
Fixed: Fix bubble outline being cut off
Browse files Browse the repository at this point in the history
  • Loading branch information
dkramer95 authored and agnostic-apollo committed Sep 3, 2021
1 parent c83cdda commit 8863995
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
13 changes: 12 additions & 1 deletion app/src/main/java/com/termux/window/FloatingBubbleManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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;
Expand Down Expand Up @@ -57,7 +59,15 @@ public void displayAsFloatingBubble() {
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();
Expand All @@ -82,6 +92,7 @@ public void displayAsFloatingWindow() {

TerminalView terminalView = getTerminalView();
terminalView.setBackground(mOriginalTerminalViewBackground);
terminalView.setOutlineProvider(null);
terminalView.setClipToOutline(false);

TermuxFloatView termuxFloatView = getTermuxFloatView();
Expand Down
8 changes: 0 additions & 8 deletions app/src/main/res/drawable/round_button.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/drawable/round_button_with_outline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<shape android:shape="oval">
<solid android:color="@android:color/black" />
<stroke android:color="@android:color/white"
android:width="1dp" />
android:width="@dimen/bubble_outline_stroke_width" />
</shape>
</item>
</selector>
4 changes: 4 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="bubble_outline_stroke_width">1dp</dimen>
</resources>

0 comments on commit 8863995

Please # to comment.