Skip to content

Commit b8fb511

Browse files
committed
float ball moves to the edge, becomes transparent.
1 parent f53af15 commit b8fb511

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

app/src/main/java/com/termux/app/terminal/FloatBallMenuClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public void onDetachedFromWindow() {
8484
private void init() {
8585
// 1 set position of float ball, set size, icon and drawable
8686
int ballSize = DensityUtil.dip2px(mTermuxActivity, 40);
87-
Drawable ballIcon = AppCompatResources.getDrawable(mTermuxActivity, R.drawable.icon_float_ball_shape);
87+
// Drawable ballIcon = AppCompatResources.getDrawable(mTermuxActivity, R.drawable.icon_float_ball_shape);
88+
Drawable ballIcon = AppCompatResources.getDrawable(mTermuxActivity, R.drawable.icon_float_ball);
8889
// different config below
8990
// FloatBallCfg ballCfg = new FloatBallCfg(ballSize, ballIcon);
9091
// FloatBallCfg ballCfg = new FloatBallCfg(ballSize, ballIcon, FloatBallCfg.Gravity.LEFT_CENTER,false);

float-ball/src/main/java/com/termux/floatball/widget/FloatBall.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ private void touchDown(int x, int y) {
224224
mLastY = mDownY;
225225
isClick = true;
226226
removeSleepRunnable();
227+
228+
if (imageView != null) {
229+
imageView.setAlpha(1.0f);
230+
}
227231
}
228232

229233
private void touchMove(int x, int y) {
@@ -236,6 +240,11 @@ private void touchMove(int x, int y) {
236240
}
237241
mLastX = x;
238242
mLastY = y;
243+
244+
if (imageView != null) {
245+
imageView.setAlpha(1.0f);
246+
}
247+
239248
if (!isClick) {
240249
onMove(deltaX, deltaY);
241250
}
@@ -287,6 +296,11 @@ private void wakeUp() {
287296
int destX;
288297
destX = mLayoutParams.x < centerX ? 0 : screenWidth - width;
289298
sleep = false;
299+
300+
if (imageView != null) {
301+
imageView.setAlpha(1.0f);
302+
}
303+
290304
moveToX(true, destX);
291305
}
292306

@@ -308,6 +322,10 @@ private void moveToEdge(boolean smooth, boolean forceSleep) {
308322
mSleepX = destX;
309323
}
310324
moveToX(smooth, destX);
325+
326+
if (imageView != null) {
327+
imageView.setAlpha(0.3f);
328+
}
311329
}
312330

313331
private int getScrollDuration(int distance) {

0 commit comments

Comments
 (0)