这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit c83cdda

Browse files
dkramer95agnostic-apollo
authored andcommitted
Fixed: Use dp sizing for bubble size to support different display densities
1 parent 90f908d commit c83cdda

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/src/main/java/com/termux/window/FloatingBubbleManager.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
import android.view.ViewGroup;
66
import android.view.WindowManager;
77

8+
import com.termux.shared.view.ViewUtils;
89
import com.termux.view.TerminalView;
910

1011
/**
1112
* Handles displaying our TermuxFloatView as a collapsed bubble and restoring back
1213
* to its original display.
1314
*/
1415
public class FloatingBubbleManager {
15-
private static final int BUBBLE_SIZE = 200;
16+
private static final int DEFAULT_BUBBLE_SIZE_DP = 80;
1617

1718
private TermuxFloatView mTermuxFloatView;
19+
private final int BUBBLE_SIZE_PX;
1820

1921
private boolean mIsMinimized;
2022

@@ -26,9 +28,9 @@ public class FloatingBubbleManager {
2628
private Drawable mOriginalTerminalViewBackground;
2729
private Drawable mOriginalFloatViewBackground;
2830

29-
3031
public FloatingBubbleManager(TermuxFloatView termuxFloatView) {
3132
mTermuxFloatView = termuxFloatView;
33+
BUBBLE_SIZE_PX = ViewUtils.dpToPx(mTermuxFloatView.getContext(), DEFAULT_BUBBLE_SIZE_DP);
3234
}
3335

3436
public void toggleBubble() {
@@ -50,8 +52,9 @@ public void displayAsFloatingBubble() {
5052
captureOriginalLayoutValues();
5153

5254
WindowManager.LayoutParams layoutParams = getLayoutParams();
53-
layoutParams.width = BUBBLE_SIZE;
54-
layoutParams.height = BUBBLE_SIZE;
55+
56+
layoutParams.width = BUBBLE_SIZE_PX;
57+
layoutParams.height = BUBBLE_SIZE_PX;
5558

5659
TerminalView terminalView = getTerminalView();
5760
terminalView.setBackgroundResource(R.drawable.round_button);

0 commit comments

Comments
 (0)