Desktop: - Search lists chats whose own name matches first, so a named group isn't pushed out of the top 8 by chats that merely include a member. Android (Rabbit R1) app, 0.2.0: - Pull the chat list past its top for a search box (name, person, number, then group members; archived chats too; Back clears it). - Swipe right to left marks a chat unread / read over a magenta band; left to right still archives (SwipeActions replaces SwipeArchive). - Google Voice chats don't offer voice notes in the paperclip bubble. - Chats open with their newest 60 messages, then the full history; marking read (and the Google Voice network call) waits until they're on screen. Cached pictures show at once, and one slow download no longer blocks the other images. Fixed a contacts reload race. - Sandbox data gains filler chats, a named group and a 4,000-message chat. Also: the Android app, Google Voice support, media, export, emoji and the other work since the first commit, and a CLAUDE.md carrying the privacy rule.
135 lines
4.7 KiB
Java
135 lines
4.7 KiB
Java
package me.teafry.voipmessages;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Matrix;
|
|
import android.graphics.RectF;
|
|
import android.os.Bundle;
|
|
import android.view.GestureDetector;
|
|
import android.view.MotionEvent;
|
|
import android.view.ScaleGestureDetector;
|
|
import android.widget.ImageView;
|
|
|
|
import java.io.File;
|
|
|
|
/** A photo, full screen. Pinch or double-tap to zoom, drag to pan, tap to close. */
|
|
public final class ImageActivity extends BaseActivity {
|
|
@Override
|
|
protected void onCreate(Bundle b) {
|
|
super.onCreate(b);
|
|
Zoom iv = new Zoom(this);
|
|
iv.setBackgroundColor(0xFF000000);
|
|
iv.setImageBitmap(Media.bitmap(new File(getIntent().getStringExtra("file")), 2048));
|
|
setContentView(iv);
|
|
}
|
|
|
|
@Override
|
|
public void changed() {}
|
|
|
|
private final class Zoom extends ImageView {
|
|
private static final float MAX = 6f, DOUBLE_TAP = 2.5f;
|
|
private final Matrix m = new Matrix();
|
|
private final float[] v = new float[9];
|
|
private float fit = 1f; // the scale that fits the whole photo on screen
|
|
private final ScaleGestureDetector pinch;
|
|
private final GestureDetector gestures;
|
|
|
|
Zoom(Context c) {
|
|
super(c);
|
|
setScaleType(ScaleType.MATRIX);
|
|
pinch = new ScaleGestureDetector(c, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
|
@Override
|
|
public boolean onScale(ScaleGestureDetector d) {
|
|
zoomBy(d.getScaleFactor(), d.getFocusX(), d.getFocusY());
|
|
return true;
|
|
}
|
|
});
|
|
gestures = new GestureDetector(c, new GestureDetector.SimpleOnGestureListener() {
|
|
@Override
|
|
public boolean onDown(MotionEvent e) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float dx, float dy) {
|
|
if (pinch.isInProgress()) return true;
|
|
m.postTranslate(-dx, -dy);
|
|
settle();
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
finish();
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onDoubleTap(MotionEvent e) {
|
|
// Zoomed in: back to fit; at fit: zoom in on the tapped spot.
|
|
float target = scale() > fit * 1.05f ? fit : fit * DOUBLE_TAP;
|
|
zoomBy(target / scale(), e.getX(), e.getY());
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
protected void onSizeChanged(int w, int h, int ow, int oh) {
|
|
super.onSizeChanged(w, h, ow, oh);
|
|
reset();
|
|
}
|
|
|
|
@Override
|
|
public void setImageBitmap(Bitmap bm) {
|
|
super.setImageBitmap(bm);
|
|
reset();
|
|
}
|
|
|
|
/** Whole photo, centred. */
|
|
private void reset() {
|
|
if (getDrawable() == null || getWidth() == 0) return;
|
|
float dw = getDrawable().getIntrinsicWidth(), dh = getDrawable().getIntrinsicHeight();
|
|
fit = Math.min(getWidth() / dw, getHeight() / dh);
|
|
m.setScale(fit, fit);
|
|
m.postTranslate((getWidth() - dw * fit) / 2, (getHeight() - dh * fit) / 2);
|
|
setImageMatrix(m);
|
|
}
|
|
|
|
private float scale() {
|
|
m.getValues(v);
|
|
return v[Matrix.MSCALE_X];
|
|
}
|
|
|
|
private void zoomBy(float f, float x, float y) {
|
|
float s = scale();
|
|
f = Math.max(fit / s, Math.min(fit * MAX / s, f));
|
|
m.postScale(f, f, x, y);
|
|
settle();
|
|
}
|
|
|
|
/** No black gaps at an edge: centre what's smaller than the screen, clamp what's bigger. */
|
|
private void settle() {
|
|
if (getDrawable() == null) return;
|
|
RectF r = new RectF(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
|
|
m.mapRect(r);
|
|
float dx = 0, dy = 0, w = getWidth(), h = getHeight();
|
|
if (r.width() <= w) dx = (w - r.width()) / 2 - r.left;
|
|
else if (r.left > 0) dx = -r.left;
|
|
else if (r.right < w) dx = w - r.right;
|
|
if (r.height() <= h) dy = (h - r.height()) / 2 - r.top;
|
|
else if (r.top > 0) dy = -r.top;
|
|
else if (r.bottom < h) dy = h - r.bottom;
|
|
m.postTranslate(dx, dy);
|
|
setImageMatrix(m);
|
|
}
|
|
|
|
@Override
|
|
public boolean onTouchEvent(MotionEvent e) {
|
|
pinch.onTouchEvent(e);
|
|
gestures.onTouchEvent(e);
|
|
return true;
|
|
}
|
|
}
|
|
}
|