LihonT Store 0.3

Sign-in through the Telegram bot with a nickname, follows and followers (the list of followers is for its owner alone), an inbox of new
works of the authors one follows, notifications through the bot. Publishing still needs the TikTok account to be proven.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
cheb0chik
2026-11-07 10:55:55 +03:00
parent 9a3b17e1bc
commit d66690613a
8 changed files with 589 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lihonstore.app"
android:versionCode="2"
android:versionName="0.2">
android:versionCode="3"
android:versionName="0.3">
<uses-sdk android:minSdkVersion="31" android:targetSdkVersion="34"/>

View File

@@ -0,0 +1,48 @@
package lihonstore.app;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.json.JSONObject;
/** The inbox: new works of the authors the member follows. A guest is asked to sign in with Telegram first. */
final class InboxPage {
private final LinearLayout page;
InboxPage(final MainActivity host) {
Theme theme = host.theme();
page = theme.column(host);
TextView title = theme.text(host, "Входящие", 26f, theme.onSurface, true);
title.setPadding(theme.dp(20), theme.dp(16), theme.dp(20), theme.dp(8));
page.addView(title);
if (!host.tg().registered) {
TextView say = theme.text(host, "Здесь появляются новые рамки и пузыри авторов, на которых вы подписаны. Чтобы подписываться, "
+ "войдите через Telegram.", 15f, theme.onSurface, false);
say.setPadding(theme.dp(20), theme.dp(8), theme.dp(20), theme.dp(16));
page.addView(say);
TextView login = theme.button(host, "Войти через Telegram", true);
login.setOnClickListener(v -> host.push(new TelegramPage(host, () -> host.showTab(1)).view()));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
params.setMargins(theme.dp(20), 0, theme.dp(20), 0);
page.addView(login, params);
return;
}
ItemGrid grid = new ItemGrid(host, cursor -> {
JSONObject request = host.tgBody();
try {
if (cursor != null) request.put("cursor", cursor);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
return ItemGrid.Page.of(Api.post("inbox", request));
}, "Пока пусто. Подпишитесь на авторов в их профилях: нажмите на ник под любой работой.");
page.addView(grid.view(), new LinearLayout.LayoutParams(-1, 0, 1f));
grid.reload();
host.markInboxSeen();
}
View view() {
return page;
}
}

View File

@@ -45,6 +45,8 @@ public final class MainActivity extends Activity {
private View root;
private int tab = -1;
private PublishPage publishing;
private final Tg tg = new Tg();
private boolean linkedTikTok;
@Override protected void onCreate(Bundle state) {
super.onCreate(state);
@@ -87,6 +89,101 @@ public final class MainActivity extends Activity {
return library;
}
Tg tg() {
return tg;
}
/** The body of a Telegram call: the installation alone stands for the person. */
JSONObject tgBody() {
try {
return new JSONObject().put("installation", account.installation);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
}
/** Asks the service who this installation is on Telegram, the unread count of the inbox, then runs `then` (if given). */
void refreshTg(final Runnable then) {
Work.run(() -> Api.post("tg_me", tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
tg.apply(reply);
if (!tg.registered) {
tg.unread = 0;
finishRefresh(then);
return;
}
linkTikTok();
Work.run(() -> {
JSONObject request = tgBody();
try {
request.put("limit", 1);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
return Api.post("inbox", request);
}, new Work.Done<JSONObject>() {
@Override public void ok(JSONObject box) {
tg.unread = box.optInt("unread", 0);
finishRefresh(then);
}
@Override public void failed(String message) {
finishRefresh(then);
}
});
}
@Override public void failed(String message) {
// only a plain "not signed in" answer clears what is known; a lost network keeps the last state
if (message != null && (message.startsWith("Сначала войдите") || message.startsWith("Сначала выберите"))) tg.clear();
finishRefresh(then);
}
});
}
private void finishRefresh(Runnable then) {
buildBar();
if (then != null) then.run();
else if (account != null && (tab == 1 || tab == 3) && stack.isEmpty()) showTab(tab);
}
/** A member who also proved the TikTok account becomes an author: the service ties the two (the call is repeated harmlessly). */
private void linkTikTok() {
if (linkedTikTok || account == null) return;
linkedTikTok = true;
Work.run(() -> Api.post("tg_link_tiktok", body()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
tg.level = "author";
}
@Override public void failed(String message) {
linkedTikTok = false; // the account is not proven yet: tried again after the next proof
}
});
}
void markInboxSeen() {
tg.unread = 0;
buildBar();
Work.run(() -> Api.post("inbox_seen", tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {}
@Override public void failed(String message) {}
});
}
void tgSignedOut() {
tg.clear();
linkedTikTok = false;
Work.run(() -> Api.post("tg_logout", tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {}
@Override public void failed(String message) {}
});
buildBar();
showTab(3);
}
void toast(String text) {
Toast.makeText(this, text, Toast.LENGTH_LONG).show();
}
@@ -147,6 +244,8 @@ public final class MainActivity extends Activity {
Account.forget(this);
account = null;
library.clear();
tg.clear();
linkedTikTok = false;
showLogin(null);
}
@@ -155,6 +254,7 @@ public final class MainActivity extends Activity {
bar.setVisibility(View.VISIBLE);
buildBar();
showTab(0);
refreshTg(null);
proven(() -> Work.run(() -> Api.post("library", body()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
library.clear();
@@ -183,6 +283,8 @@ public final class MainActivity extends Activity {
Work.run(() -> Api.post("prove", body()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
if (reply.optBoolean("published", false)) {
linkedTikTok = false;
if (tg.registered) linkTikTok();
then.run();
return;
}
@@ -224,13 +326,13 @@ public final class MainActivity extends Activity {
private void buildBar() {
bar.removeAllViews();
String[] names = {"Каталог", "+", "Профиль"};
String[] names = {"Каталог", tg.unread > 0 ? "Входящие •" : "Входящие", "+", "Профиль"};
for (int i = 0; i < names.length; i++) {
final int index = i;
TextView item = theme.text(this, names[i], i == 1 ? 24f : 14f, i == 1 ? theme.onAccent : (tab == i ? theme.accent : theme.muted), i == 1 || tab == i);
TextView item = theme.text(this, names[i], i == 2 ? 24f : 14f, i == 2 ? theme.onAccent : (tab == i ? theme.accent : theme.muted), i == 2 || tab == i);
item.setGravity(Gravity.CENTER);
item.setClickable(true);
if (i == 1) {
if (i == 2) {
item.setBackground(theme.round(theme.accent, 22));
item.setPadding(theme.dp(22), theme.dp(4), theme.dp(22), theme.dp(6));
LinearLayout.LayoutParams plus = new LinearLayout.LayoutParams(-2, -2);
@@ -251,7 +353,8 @@ public final class MainActivity extends Activity {
publishing = null;
View page;
if (index == 0) page = new CatalogPage(this).view();
else if (index == 1) {
else if (index == 1) page = new InboxPage(this).view();
else if (index == 2) {
PublishPage publish = new PublishPage(this);
publishing = publish;
page = publish.view();

View File

@@ -1,5 +1,6 @@
package lihonstore.app;
import android.app.AlertDialog;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;
@@ -23,6 +24,11 @@ final class ProfilePage {
private final TextView totals;
private final List<TextView> chips = new ArrayList<TextView>();
private final ItemGrid[] grids = new ItemGrid[3];
private int gridAt = 2;
private TextView followCount;
private TextView followButton;
private int followers;
private boolean following;
ProfilePage(final MainActivity host, String uid, String name, boolean own) {
this.host = host;
@@ -51,7 +57,9 @@ final class ProfilePage {
words.addView(totals);
head.addView(words, new LinearLayout.LayoutParams(0, -2, 1f));
page.addView(head);
if (!own) addFollowRow();
if (own) {
addSocial();
LinearLayout chipsRow = theme.row(host);
chipsRow.setPadding(theme.dp(16), theme.dp(4), theme.dp(16), theme.dp(8));
String[] titles = {"Опубликовано", "Проверка", "Библиотека"};
@@ -68,6 +76,7 @@ final class ProfilePage {
chips.add(chip);
}
page.addView(chipsRow);
gridAt = page.indexOfChild(chipsRow) + 1;
select(0);
TextView out = theme.button(host, "Сменить аккаунт", false);
out.setOnClickListener(v -> host.logout());
@@ -89,6 +98,190 @@ final class ProfilePage {
return page;
}
// ---- following: the button and the count of another author's profile -----------------------------------------
private JSONObject follow(boolean withInstallation) {
try {
JSONObject request = new JSONObject().put("uid", uid);
if (withInstallation) request.put("installation", host.account().installation);
return request;
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
}
private void addFollowRow() {
Theme theme = host.theme();
LinearLayout row = theme.row(host);
row.setPadding(theme.dp(20), 0, theme.dp(20), theme.dp(8));
followCount = theme.text(host, "", 14f, theme.muted, false);
row.addView(followCount, new LinearLayout.LayoutParams(0, -2, 1f));
followButton = theme.button(host, "Подписаться", true);
followButton.setPadding(theme.dp(18), theme.dp(8), theme.dp(18), theme.dp(8));
followButton.setOnClickListener(v -> toggleFollow());
row.addView(followButton);
page.addView(row);
renderFollow();
loadFollow();
}
private void loadFollow() {
final boolean signedIn = host.tg().registered;
Work.run(() -> Api.post("follow_info", follow(signedIn)), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
followers = reply.optInt("followers", 0);
following = reply.optBoolean("following", false);
renderFollow();
}
@Override public void failed(String message) {
// the count stays as it was
}
});
}
private void renderFollow() {
Theme theme = host.theme();
followCount.setText("Подписчики: " + followers);
followButton.setText(following ? "Вы подписаны" : "Подписаться");
followButton.setTextColor(following ? theme.onAccentSoft : theme.onAccent);
followButton.setBackground(theme.round(following ? theme.accentSoft : theme.accent, 24));
}
private void toggleFollow() {
if (!host.tg().registered) {
host.push(new TelegramPage(host, this::loadFollow).view());
return;
}
followButton.setEnabled(false);
final boolean add = !following;
Work.run(() -> Api.post(add ? "follow" : "unfollow", follow(true)), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
followButton.setEnabled(true);
following = add;
followers = reply.optInt("followers", followers);
renderFollow();
if (add) host.toast("Новые работы автора будут во «Входящих»");
}
@Override public void failed(String message) {
followButton.setEnabled(true);
host.toast(Texts.error(message));
}
});
}
// ---- the member's own side: Telegram, follows, followers, notifications -------------------------------------------
private void addSocial() {
Theme theme = host.theme();
LinearLayout box = theme.column(host);
box.setPadding(theme.dp(20), 0, theme.dp(20), theme.dp(8));
if (!host.tg().registered) {
TextView login = theme.button(host, "Войти через Telegram: подписки и входящие", false);
login.setOnClickListener(v -> host.push(new TelegramPage(host, () -> host.showTab(3)).view()));
box.addView(login, new LinearLayout.LayoutParams(-1, -2));
page.addView(box);
return;
}
Tg tg = host.tg();
box.addView(theme.text(host, "Telegram: @" + tg.handle + " · " + ("author".equals(tg.level) ? "автор" : "участник"), 14f, theme.muted, false));
LinearLayout row = theme.row(host);
row.setPadding(0, theme.dp(8), 0, 0);
TextView follows = theme.chip(host, "Подписки " + tg.following, false);
TextView fans = theme.chip(host, "Подписчики " + tg.followers, false);
final TextView notify = theme.chip(host, tg.notify ? "Уведомления: да" : "Уведомления: нет", false);
follows.setSingleLine(true);
fans.setSingleLine(true);
notify.setSingleLine(true);
for (TextView chip : new TextView[] {follows, fans, notify}) {
chip.setPadding(theme.dp(6), theme.dp(8), theme.dp(6), theme.dp(8));
LinearLayout.LayoutParams gap = new LinearLayout.LayoutParams(0, -2, 1f);
gap.rightMargin = chip == notify ? 0 : theme.dp(8);
row.addView(chip, gap);
}
follows.setOnClickListener(v -> showFollowing());
fans.setOnClickListener(v -> showFollowers());
notify.setOnClickListener(v -> toggleNotify(notify));
box.addView(row);
TextView out = theme.text(host, "Выйти из Telegram", 13f, theme.accent, true);
out.setPadding(0, theme.dp(10), 0, 0);
out.setClickable(true);
out.setOnClickListener(v -> host.tgSignedOut());
box.addView(out);
page.addView(box);
}
private void toggleNotify(final TextView chip) {
final boolean on = !host.tg().notify;
Work.run(() -> {
JSONObject request = host.tgBody();
try {
request.put("on", on);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
return Api.post("tg_notify", request);
}, new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
host.tg().notify = on;
chip.setText(on ? "Уведомления: да" : "Уведомления: нет");
host.toast(on ? "Бот будет сообщать о новых работах" : "Уведомления выключены");
}
@Override public void failed(String message) {
host.toast(Texts.error(message));
}
});
}
private void showFollowing() {
Work.run(() -> Api.post("following", host.tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
org.json.JSONArray array = reply.optJSONArray("items");
if (array == null || array.length() == 0) {
host.toast("Вы пока ни на кого не подписаны");
return;
}
final String[] uids = new String[array.length()];
final String[] names = new String[array.length()];
final String[] labels = new String[array.length()];
for (int i = 0; i < array.length(); i++) {
JSONObject one = array.optJSONObject(i);
uids[i] = one.optString("uid", "");
names[i] = one.isNull("name") ? "" : one.optString("name", "");
labels[i] = (names[i].length() == 0 ? "автор" : "@" + names[i]) + " · работ: " + one.optInt("works", 0);
}
new AlertDialog.Builder(host).setTitle("Вы подписаны").setItems(labels, (d, which) -> host.openProfile(uids[which], names[which]))
.setNegativeButton("Закрыть", null).show();
}
@Override public void failed(String message) {
host.toast(Texts.error(message));
}
});
}
private void showFollowers() {
Work.run(() -> Api.post("followers", host.tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
org.json.JSONArray array = reply.optJSONArray("items");
if (array == null || array.length() == 0) {
host.toast(reply.optInt("count", 0) == 0 ? "Подписчиков пока нет" : "Список пока недоступен");
return;
}
String[] labels = new String[array.length()];
for (int i = 0; i < array.length(); i++) labels[i] = "@" + array.optJSONObject(i).optString("handle", "");
new AlertDialog.Builder(host).setTitle("Подписчики: " + reply.optInt("count", labels.length)).setItems(labels, null)
.setNegativeButton("Закрыть", null).show();
}
@Override public void failed(String message) {
host.toast(Texts.error(message));
}
});
}
private static String initial(String name) {
return name.length() == 0 ? "?" : name.substring(0, 1).toUpperCase(java.util.Locale.ROOT);
}
@@ -131,7 +324,7 @@ final class ProfilePage {
chip.setBackground(theme.round(selected ? theme.accent : theme.surfaceHigh, 20));
}
// the grid sits after the head and the chips; it is replaced when another chip is chosen
if (page.getChildCount() > 2 && page.getChildAt(2) instanceof android.widget.ScrollView) page.removeViewAt(2);
if (page.getChildCount() > gridAt && page.getChildAt(gridAt) instanceof android.widget.ScrollView) page.removeViewAt(gridAt);
if (grids[index] == null) {
final String mode = index == 0 ? "published" : index == 1 ? "pending" : "library";
grids[index] = new ItemGrid(host, cursor -> {
@@ -148,6 +341,6 @@ final class ProfilePage {
}, index == 0 ? "Вы ещё ничего не опубликовали" : index == 1 ? "Ничего не ждёт проверки" : "Вы ещё ничего не добавили через «+»");
grids[index].reload();
}
page.addView(grids[index].view(), 2, new LinearLayout.LayoutParams(-1, 0, 1f));
page.addView(grids[index].view(), gridAt, new LinearLayout.LayoutParams(-1, 0, 1f));
}
}

View File

@@ -189,7 +189,7 @@ final class PublishPage {
String status = reply.optString("status", "new");
host.toast("approved".equals(status) ? "Уже принято: смотрите в каталоге"
: "Отправлено на проверку. Статус смотрите в профиле: «Проверка»");
host.showTab(2);
host.showTab(3);
}
@Override public void failed(String message) {

View File

@@ -0,0 +1,191 @@
package lihonstore.app;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.text.InputType;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import org.json.JSONObject;
import java.util.Locale;
/**
* Signing in through the Telegram bot: the app asks the service for a one-time link, opens it, and waits for the bot to tie the person to it;
* then the person chooses a nickname. The poll stops by itself when this screen is no longer shown.
*/
final class TelegramPage {
private static final long POLL_MS = 2500L;
private static final int MAX_POLLS = 360; // 15 minutes, the life of the link
private final MainActivity host;
private final Runnable done;
private final LinearLayout page;
private final TextView status;
private final TextView button;
private final Handler handler = new Handler(Looper.getMainLooper());
private String token = "";
private int polls;
/** `done` runs after the person is signed in and has a nickname (the screen has already closed itself). */
TelegramPage(MainActivity host, Runnable done) {
this.host = host;
this.done = done;
Theme theme = host.theme();
page = theme.column(host);
page.setPadding(theme.dp(20), theme.dp(8), theme.dp(20), theme.dp(24));
TextView back = theme.text(host, "← Назад", 15f, theme.accent, true);
back.setPadding(0, theme.dp(8), 0, theme.dp(12));
back.setClickable(true);
back.setOnClickListener(v -> host.back());
page.addView(back);
page.addView(theme.text(host, "Вход через Telegram", 26f, theme.onSurface, true));
TextView why = theme.text(host, "С входом через Telegram можно подписываться на авторов, читать входящие (новые рамки и пузыри тех, на кого "
+ "вы подписаны) и получать уведомления. Публиковать по-прежнему можно после подтверждения аккаунта TikTok.\n\n"
+ "Нажмите кнопку: откроется бот, в нём нажмите «Start» и вернитесь сюда.", 15f, theme.onSurface, false);
why.setPadding(0, theme.dp(12), 0, theme.dp(20));
page.addView(why);
button = theme.button(host, "Войти через Telegram", true);
button.setOnClickListener(v -> begin());
page.addView(button, new LinearLayout.LayoutParams(-1, -2));
status = theme.text(host, "", 14f, theme.muted, false);
status.setPadding(0, theme.dp(16), 0, 0);
page.addView(status);
}
View view() {
ScrollView scroll = new ScrollView(host);
scroll.addView(page);
return scroll;
}
private void begin() {
button.setEnabled(false);
status.setText("Готовим ссылку…");
Work.run(() -> Api.post("tg_start", host.tgBody()), new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
token = reply.optString("token", "");
String link = reply.optString("link", "");
if (token.length() == 0 || !link.startsWith("https://t.me/")) {
fail("Сервис не дал ссылку");
return;
}
try {
host.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link)));
} catch (ActivityNotFoundException none) {
fail("Не нашлось Telegram. Установите его и попробуйте снова");
return;
}
polls = 0;
status.setText("Откройте бота, нажмите «Start» и вернитесь сюда. Ждём…");
handler.postDelayed(TelegramPage.this::poll, POLL_MS);
}
@Override public void failed(String message) {
fail(Texts.error(message));
}
});
}
private void fail(String message) {
button.setEnabled(true);
button.setText("Попробовать ещё раз");
status.setText(message);
}
private void poll() {
if (!page.isAttachedToWindow()) return; // the screen was left: nothing more to do
Work.run(() -> {
JSONObject request = host.tgBody();
try {
request.put("token", token);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
return Api.post("tg_poll", request);
}, new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
String state = reply.optString("status", "");
if ("linked".equals(state)) {
if (reply.optBoolean("registered", false)) finish();
else askNickname();
} else if ("waiting".equals(state) && ++polls < MAX_POLLS) {
handler.postDelayed(TelegramPage.this::poll, POLL_MS);
} else {
fail("Ссылка устарела. Нажмите кнопку ещё раз");
}
}
@Override public void failed(String message) {
// the phone may lose the network for a moment while the person is in Telegram (a VPN switching, the screen off): keep trying
if (message != null && message.startsWith("Нет связи") && ++polls < MAX_POLLS) {
status.setText("Нет связи с сервером, пробуем ещё…");
handler.postDelayed(TelegramPage.this::poll, POLL_MS * 2);
} else {
fail(Texts.error(message));
}
}
});
}
private void askNickname() {
final Theme theme = host.theme();
page.removeAllViews();
page.addView(theme.text(host, "Выберите ник", 26f, theme.onSurface, true));
TextView hint = theme.text(host, "Его увидят другие: от 3 до 20 символов, латинские буквы, цифры и «_». Сменить можно раз в 30 дней.",
15f, theme.onSurface, false);
hint.setPadding(0, theme.dp(12), 0, theme.dp(16));
page.addView(hint);
final EditText input = new EditText(host);
input.setSingleLine(true);
input.setHint("ник");
input.setTextColor(theme.onSurface);
input.setHintTextColor(theme.muted);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
input.setBackground(theme.round(theme.surfaceHigh, 16));
input.setPadding(theme.dp(16), theme.dp(12), theme.dp(16), theme.dp(12));
page.addView(input, new LinearLayout.LayoutParams(-1, -2));
final TextView save = theme.button(host, "Готово", true);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
params.topMargin = theme.dp(16);
page.addView(save, params);
final TextView problem = theme.text(host, "", 14f, theme.danger, false);
problem.setPadding(0, theme.dp(12), 0, 0);
page.addView(problem);
save.setOnClickListener(v -> {
final String handle = input.getText().toString().trim().toLowerCase(Locale.ROOT);
save.setEnabled(false);
Work.run(() -> {
JSONObject request = host.tgBody();
try {
request.put("handle", handle);
} catch (org.json.JSONException impossible) {
throw new IllegalStateException(impossible);
}
return Api.post("tg_register", request);
}, new Work.Done<JSONObject>() {
@Override public void ok(JSONObject reply) {
finish();
}
@Override public void failed(String message) {
save.setEnabled(true);
problem.setText(Texts.error(message));
}
});
});
}
private void finish() {
host.refreshTg(() -> {
host.back();
if (done != null) done.run();
});
}
}

View File

@@ -17,6 +17,18 @@ final class Texts {
if (message.startsWith("Could not read the TikTok profile")) return "Не удалось прочитать профиль TikTok, попробуйте позже";
if (message.startsWith("Profile not found")) return "Профиль не найден";
if (message.startsWith("That profile belongs")) return "Это профиль другого аккаунта";
if (message.startsWith("Sign in with Telegram")) return "Сначала войдите через Telegram";
if (message.startsWith("Choose a nickname")) return "Сначала выберите ник";
if (message.startsWith("A nickname is 3")) return "Ник: от 3 до 20 символов, латиница, цифры или «_»";
if (message.startsWith("This nickname is reserved")) return "Этот ник занят системой";
if (message.startsWith("This nickname is taken")) return "Этот ник уже занят";
if (message.startsWith("A nickname can be changed")) return "Ник можно менять раз в 30 дней";
if (message.startsWith("Too many open sign-in links")) return "Слишком много попыток входа, подождите несколько минут";
if (message.startsWith("You cannot follow yourself")) return "Нельзя подписаться на себя";
if (message.startsWith("No such author")) return "Такого автора нет";
if (message.startsWith("You follow too many")) return "Вы подписаны на слишком многих авторов";
if (message.startsWith("Prove the TikTok account")) return "Сначала подтвердите аккаунт TikTok";
if (message.startsWith("Account banned")) return "Аккаунт заблокирован. Обжалование: t.me/cheb0chik";
return message;
}

View File

@@ -0,0 +1,33 @@
package lihonstore.app;
import org.json.JSONObject;
/** What the app knows about the Telegram side of the account (the service keeps the truth; this is its last answer). */
final class Tg {
boolean registered;
String handle = "";
String level = "member";
boolean notify = true;
int following;
int followers;
int unread;
void apply(JSONObject reply) {
registered = reply.optBoolean("registered", false);
handle = reply.isNull("handle") ? "" : reply.optString("handle", "");
level = reply.optString("level", "member");
notify = reply.optBoolean("notify", true);
following = reply.optInt("following", 0);
followers = reply.optInt("followers", 0);
}
void clear() {
registered = false;
handle = "";
level = "member";
notify = true;
following = 0;
followers = 0;
unread = 0;
}
}