v0.9.4: bubble for Android 0.7.7 — tap the paperclip, then tap a choice (holding and swiping up went home)
This commit is contained in:
@@ -13,23 +13,24 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* Hold the paperclip and the composer swells upward into a bubble while
|
||||
* Tap the paperclip and the composer swells upward into a bubble while
|
||||
* camera, photo and microphone (no microphone on a Google Voice chat, which
|
||||
* can't send voice notes) float out from under the clip, jostle each
|
||||
* other apart and settle above and to the right of it. The thumb stays down:
|
||||
* a soft spotlight follows it inside the bubble, leans toward whichever icon
|
||||
* it's near (so it needn't be exact), and that icon gets a glowing blue ring.
|
||||
* Let go on one to attach that; let go on none and they all slip back under
|
||||
* the clip as the bubble sinks.
|
||||
* other apart and settle above and to the right of it. The next touch picks:
|
||||
* a soft spotlight follows the thumb inside the bubble, leans toward whichever
|
||||
* icon it's near (so it needn't be exact), and that icon gets a glowing blue
|
||||
* ring. Let go on one to attach that; let go on none and they all slip back
|
||||
* under the clip as the bubble sinks.
|
||||
*
|
||||
* <p>Not hold-and-drag from the clip: on the R1 the clip is in the bottom
|
||||
* 48 dp, where a swipe up is the system's home gesture.
|
||||
*
|
||||
* <p>The way out is a little physics: each icon is sprung to a home spot and
|
||||
* the icons push each other away, launched a beat apart in nearly the same
|
||||
* direction so they bump and fan out. The bubble's height just chases the
|
||||
* icons. The way back is a plain ease-in, since they're only going away.
|
||||
*
|
||||
* <p>Lives on the window's decor while open; the paperclip's own touch
|
||||
* listener feeds it ({@link #move}, {@link #release}) since the touch began there.
|
||||
* After a quick tap ({@link #stay}) it takes the next touch itself instead.
|
||||
* <p>Lives on the window's decor while open and takes its touches itself.
|
||||
*/
|
||||
final class AttachBubble extends View {
|
||||
interface OnPick {
|
||||
@@ -69,7 +70,6 @@ final class AttachBubble extends View {
|
||||
private float width; // the bubble's right edge
|
||||
private float tx, ty; // the thumb
|
||||
private boolean touched; // the thumb has moved since the bubble opened
|
||||
private boolean sticky; // opened by a tap: the next touch picks or closes
|
||||
|
||||
// Icon state, in dp from the clip's centre with y up.
|
||||
private final float[] px = new float[3], py = new float[3], vx = new float[3], vy = new float[3];
|
||||
@@ -134,7 +134,7 @@ final class AttachBubble extends View {
|
||||
width = cx + (float) Math.cos(Math.toRadians(HOME_DEG[n - 1])) * HOME_DIST * dp + iconR + margin;
|
||||
tx = cx;
|
||||
ty = cy;
|
||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -230,18 +230,8 @@ final class AttachBubble extends View {
|
||||
if (pick >= 0) performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
|
||||
}
|
||||
|
||||
boolean dragged() {
|
||||
return touched;
|
||||
}
|
||||
|
||||
/** Opened by a quick tap: stay out until the next touch. */
|
||||
void stay() {
|
||||
sticky = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
if (!sticky) return true;
|
||||
switch (e.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
|
||||
@@ -39,8 +39,6 @@ public final class ChatActivity extends BaseActivity {
|
||||
private static final int PICK = 1;
|
||||
private static final int VOICE = 2;
|
||||
private static final int CAMERA = 3;
|
||||
/** A press on the paperclip shorter than this (ms), without dragging, is a tap: the bubble stays open. */
|
||||
private static final int TAP_MS = 250;
|
||||
private static final int MAX_PHOTOS = 3;
|
||||
|
||||
private String did, contact;
|
||||
@@ -64,8 +62,6 @@ public final class ChatActivity extends BaseActivity {
|
||||
// Audio playing in the list: one at a time, keyed "id/index".
|
||||
private android.media.MediaPlayer player;
|
||||
private String playing;
|
||||
// The bubble while a press on the paperclip is feeding it.
|
||||
private AttachBubble bubble;
|
||||
// Where the camera is writing the photo it's taking.
|
||||
private Uri shot;
|
||||
|
||||
@@ -183,7 +179,7 @@ public final class ChatActivity extends BaseActivity {
|
||||
// of the composer, cut off.
|
||||
row.setBaselineAligned(false);
|
||||
attach = Ui.headerButton(this, Glyph.Kind.ATTACH);
|
||||
attach.setOnTouchListener((v, e) -> attachTouch(e));
|
||||
attach.setOnClickListener(v -> openAttach());
|
||||
compactButton(attach);
|
||||
input = new EditText(this);
|
||||
input.setHint("Message");
|
||||
@@ -382,33 +378,13 @@ public final class ChatActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Press the paperclip and the bubble is out at once: drag to a choice and
|
||||
* let go. A quick tap leaves it open to tap a choice (or anywhere else to close).
|
||||
* Tap the paperclip and the bubble opens; tap a choice, or anywhere else
|
||||
* to close it. Not hold-and-drag: the clip sits in the R1's bottom 48 dp,
|
||||
* where a swipe up is the system's home gesture, and no app can opt out of that.
|
||||
*/
|
||||
private boolean attachTouch(android.view.MotionEvent e) {
|
||||
switch (e.getActionMasked()) {
|
||||
case android.view.MotionEvent.ACTION_DOWN:
|
||||
attach.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
// Google Voice only lets apps send photos: no voice-note choice there.
|
||||
bubble = new AttachBubble(this, attach, composerBox, !Config.get(this).isGv(did), this::attachKind);
|
||||
bubble.show(this);
|
||||
return true;
|
||||
case android.view.MotionEvent.ACTION_MOVE:
|
||||
if (bubble != null) bubble.move(e.getRawX(), e.getRawY());
|
||||
return true;
|
||||
case android.view.MotionEvent.ACTION_UP:
|
||||
if (bubble == null) return true;
|
||||
if (e.getEventTime() - e.getDownTime() < TAP_MS && !bubble.dragged()) bubble.stay();
|
||||
else bubble.release();
|
||||
bubble = null;
|
||||
return true;
|
||||
case android.view.MotionEvent.ACTION_CANCEL:
|
||||
if (bubble != null) bubble.dismiss();
|
||||
bubble = null;
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
private void openAttach() {
|
||||
// Google Voice only lets apps send photos: no voice-note choice there.
|
||||
new AttachBubble(this, attach, composerBox, !Config.get(this).isGv(did), this::attachKind).show(this);
|
||||
}
|
||||
|
||||
private void attachKind(int which) {
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
VERSION_NAME = "0.7.6"
|
||||
VERSION_CODE = 14
|
||||
VERSION_NAME = "0.7.7"
|
||||
VERSION_CODE = 15
|
||||
|
||||
PACKAGE = "me.teafry.voipmessages"
|
||||
DEV_PACKAGE = PACKAGE + ".dev"
|
||||
|
||||
Reference in New Issue
Block a user