Skip to content

Commit

Permalink
Fixed: Use dp sizing for bubble size to support different display den…
Browse files Browse the repository at this point in the history
…sities
  • Loading branch information
dkramer95 authored and agnostic-apollo committed Sep 3, 2021
1 parent 90f908d commit c83cdda
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/src/main/java/com/termux/window/FloatingBubbleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import android.view.ViewGroup;
import android.view.WindowManager;

import com.termux.shared.view.ViewUtils;
import com.termux.view.TerminalView;

/**
* Handles displaying our TermuxFloatView as a collapsed bubble and restoring back
* to its original display.
*/
public class FloatingBubbleManager {
private static final int BUBBLE_SIZE = 200;
private static final int DEFAULT_BUBBLE_SIZE_DP = 80;

private TermuxFloatView mTermuxFloatView;
private final int BUBBLE_SIZE_PX;

private boolean mIsMinimized;

Expand All @@ -26,9 +28,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() {
Expand All @@ -50,8 +52,9 @@ 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);
Expand Down

0 comments on commit c83cdda

Please # to comment.