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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user