v0.2.0: bubble for Android 0.2.0 — chat search, swipe for unread, faster chat opening
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.
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package me.teafry.voipmessages;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Pull down on a list that's already at the top to check for new messages.
|
||||
* (The framework has no SwipeRefreshLayout without androidx.)
|
||||
*/
|
||||
final class PullRefresh extends FrameLayout {
|
||||
interface OnRefresh {
|
||||
void refresh();
|
||||
}
|
||||
|
||||
private final AbsListView list;
|
||||
private final TextView hint;
|
||||
private final int threshold;
|
||||
private float startY = -1;
|
||||
private boolean pulling, refreshing;
|
||||
OnRefresh onRefresh;
|
||||
|
||||
PullRefresh(Context c, AbsListView list) {
|
||||
super(c);
|
||||
this.list = list;
|
||||
threshold = Ui.dp(c, 140);
|
||||
hint = Ui.text(c, "", Ui.T_SMALL, Ui.MUTED);
|
||||
hint.setGravity(Gravity.CENTER);
|
||||
hint.setPadding(0, Ui.dp(c, 16), 0, Ui.dp(c, 16));
|
||||
hint.setVisibility(GONE);
|
||||
addView(list, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
addView(hint, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.TOP));
|
||||
hint.setBackgroundColor(Ui.PANEL);
|
||||
}
|
||||
|
||||
private boolean atTop() {
|
||||
return list.getChildCount() == 0 || (list.getFirstVisiblePosition() == 0 && list.getChildAt(0).getTop() >= list.getPaddingTop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent e) {
|
||||
if (refreshing) return false;
|
||||
switch (e.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
startY = atTop() ? e.getY() : -1;
|
||||
pulling = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (startY >= 0 && e.getY() - startY > Ui.dp(getContext(), 24) && atTop()) {
|
||||
pulling = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
if (!pulling) return false;
|
||||
float d = e.getY() - startY;
|
||||
switch (e.getActionMasked()) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
hint.setVisibility(VISIBLE);
|
||||
hint.setText(d > threshold ? "Release to check for messages" : "Pull to check for messages");
|
||||
list.setTranslationY(Math.min(d, threshold * 1.4f) / 2);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
pulling = false;
|
||||
list.animate().translationY(0).setDuration(150).start();
|
||||
if (d > threshold && e.getActionMasked() == MotionEvent.ACTION_UP && onRefresh != null) {
|
||||
setRefreshing(true);
|
||||
onRefresh.refresh();
|
||||
} else {
|
||||
hint.setVisibility(GONE);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void setRefreshing(boolean on) {
|
||||
refreshing = on;
|
||||
hint.setText("Checking for messages…");
|
||||
hint.setVisibility(on ? VISIBLE : GONE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user