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.
56 lines
1.6 KiB
Java
56 lines
1.6 KiB
Java
package me.teafry.voipmessages;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.TreeSet;
|
|
|
|
/** Phone number helpers, matching the desktop's src/shared/phone.ts. */
|
|
final class Phone {
|
|
private Phone() {}
|
|
|
|
/** Bare 10-digit NANP numbers where possible, else plain digits. */
|
|
static String normalize(String raw) {
|
|
if (raw == null) return "";
|
|
String d = raw.replaceAll("\\D", "");
|
|
if (d.length() == 11 && d.startsWith("1")) d = d.substring(1);
|
|
return d;
|
|
}
|
|
|
|
static String format(String n) {
|
|
String d = normalize(n);
|
|
if (d.length() == 10) return "(" + d.substring(0, 3) + ") " + d.substring(3, 6) + "-" + d.substring(6);
|
|
return n;
|
|
}
|
|
|
|
static String e164(String n) {
|
|
String d = normalize(n);
|
|
return d.length() == 10 ? "+1" + d : "+" + d;
|
|
}
|
|
|
|
/** Group chats are keyed by their members' numbers, sorted and comma-joined. */
|
|
static String groupKey(List<String> numbers) {
|
|
TreeSet<String> set = new TreeSet<>();
|
|
for (String n : numbers) {
|
|
String d = normalize(n);
|
|
if (!d.isEmpty()) set.add(d);
|
|
}
|
|
return String.join(",", set);
|
|
}
|
|
|
|
static boolean isGroup(String contact) {
|
|
return contact.contains(",");
|
|
}
|
|
|
|
static List<String> members(String contact) {
|
|
return new ArrayList<>(Arrays.asList(contact.split(",")));
|
|
}
|
|
|
|
/** voip.ms sends at most 160 characters as one SMS; longer goes as one MMS. */
|
|
static final int SMS_TEXT_LIMIT = 160;
|
|
|
|
static int charCount(String s) {
|
|
return s.codePointCount(0, s.length());
|
|
}
|
|
}
|