From 8cc6285d470f5c6420c38134a282dbb708fb9afd Mon Sep 17 00:00:00 2001
From: NekoInverter <42698724+NekoInverter@users.noreply.github.com>
Date: Sat, 11 Jan 2020 11:50:05 +0800
Subject: [PATCH] view user history in chat
---
.../java/org/telegram/ui/ChatActivity.java | 19 ++++++++++++++++---
.../java/tw/nekomimi/nekogram/NekoConfig.java | 11 +++++++++++
.../nekogram/NekoSettingsActivity.java | 13 +++++++++++--
.../src/main/res/values-it/strings_neko.xml | 1 +
.../src/main/res/values-ja/strings_neko.xml | 1 +
.../main/res/values-zh-rCN/strings_neko.xml | 1 +
.../main/res/values-zh-rTW/strings_neko.xml | 1 +
.../src/main/res/values/strings_neko.xml | 1 +
8 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
index 3950e5050..b0efb4826 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
@@ -729,7 +729,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final static int chat_enc_timer = 13;
private final static int chat_menu_attach = 14;
private final static int clear_history = 15;
- private final static int delete_history = 92;
+ private final static int delete_history = 26;
private final static int delete_chat = 16;
private final static int share_contact = 17;
private final static int mute = 18;
@@ -13726,6 +13726,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean allowPrpr = currentUser != null
|| (currentChat != null && ChatObject.canSendMessages(currentChat) && !currentChat.broadcast &&
message.isFromUser());
+ boolean allowViewHistory = currentUser == null
+ && (currentChat != null && !currentChat.broadcast && message.isFromUser());
+
if (allowRepeat) {
items.add(LocaleController.getString("Repeat", R.string.Repeat));
options.add(94);
@@ -13733,9 +13736,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (allowPrpr && NekoConfig.showPrPr) {
items.add(LocaleController.getString("Prpr", R.string.Prpr));
- options.add(27);
+ options.add(92);
icons.add(R.drawable.msg_prpr);
}
+ if (allowViewHistory && NekoConfig.showViewHistory) {
+ items.add(LocaleController.getString("ViewUserHistory", R.string.ViewHistory));
+ options.add(90);
+ icons.add(R.drawable.menu_recent);
+ }
}
if (allowUnpin) {
items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
@@ -14685,7 +14693,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
break;
- } case 27: {
+ } case 90: {
+ TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(selectedObject.messageOwner.from_id);
+ getMediaDataController().searchMessagesInChat("", dialog_id, mergeDialogId, classGuid, 0, user);
+ showMessagesSearchListView(true);
+ break;
+ } case 92: {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(selectedObject.messageOwner.from_id);
if (user.username != null) {
SendMessagesHelper.getInstance(currentAccount).sendMessage("/prpr@" + user.username, dialog_id, selectedObject, null, false,
diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
index f3c046ef4..de5bdc49a 100644
--- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java
@@ -25,6 +25,7 @@ public class NekoConfig {
public static boolean showAddToSavedMessages = true;
public static boolean showReport = false;
public static boolean showPrPr = true;
+ public static boolean showViewHistory = true;
public static boolean showAdminActions = true;
public static boolean showChangePermissions = true;
public static boolean showDeleteDownloadedFile = true;
@@ -59,6 +60,7 @@ public class NekoConfig {
editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages);
editor.putBoolean("showReport", showReport);
editor.putBoolean("showPrPr", showPrPr);
+ editor.putBoolean("showViewHistory", showViewHistory);
editor.putBoolean("showAdminActions", showAdminActions);
editor.putBoolean("showChangePermissions", showChangePermissions);
editor.putBoolean("showDeleteDownloadedFile", showDeleteDownloadedFile);
@@ -94,6 +96,7 @@ public class NekoConfig {
showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", true);
showReport = preferences.getBoolean("showReport", false);
showPrPr = preferences.getBoolean("showPrPr", true);
+ showViewHistory = preferences.getBoolean("showViewHistory", true);
showAdminActions = preferences.getBoolean("showAdminActions", true);
showChangePermissions = preferences.getBoolean("showChangePermissions", true);
showDeleteDownloadedFile = preferences.getBoolean("showDeleteDownloadedFile", true);
@@ -122,6 +125,14 @@ public class NekoConfig {
}
+ public static void toggleShowViewHistory() {
+ showViewHistory = !showViewHistory;
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("showViewHistory", showViewHistory);
+ editor.commit();
+ }
+
public static void toggleShowPrPr() {
showPrPr = !showPrPr;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java
index bef536a49..1df0ed25b 100644
--- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java
@@ -63,6 +63,7 @@ public class NekoSettingsActivity extends BaseFragment {
private int showAddToSavedMessagesRow;
private int showReportRow;
private int showPrPrRow;
+ private int showViewHistoryRow;
private int showAdminActionsRow;
private int showChangePermissionsRow;
private int showDeleteDownloadedFileRow;
@@ -180,6 +181,11 @@ public class NekoSettingsActivity extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.showPrPr);
}
+ } else if (position == showViewHistoryRow) {
+ NekoConfig.toggleShowViewHistory();
+ if (view instanceof TextCheckCell) {
+ ((TextCheckCell) view).setChecked(NekoConfig.showViewHistory);
+ }
} else if (position == showReportRow) {
NekoConfig.toggleShowReport();
if (view instanceof TextCheckCell) {
@@ -335,6 +341,7 @@ public class NekoSettingsActivity extends BaseFragment {
messageMenuRow = rowCount++;
showAddToSavedMessagesRow = rowCount++;
showPrPrRow = rowCount++;
+ showViewHistoryRow = rowCount++;
showReportRow = rowCount++;
showAdminActionsRow = rowCount++;
showChangePermissionsRow = rowCount++;
@@ -454,6 +461,8 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages, true);
} else if (position == showPrPrRow) {
textCell.setTextAndCheck(LocaleController.getString("Prpr", R.string.Prpr), NekoConfig.showPrPr, true);
+ } else if (position == showViewHistoryRow) {
+ textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekoConfig.showViewHistory, true);
} else if (position == showReportRow) {
textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport, true);
} else if (position == showAdminActionsRow) {
@@ -518,7 +527,7 @@ public class NekoSettingsActivity extends BaseFragment {
return position == hidePhoneRow || position == inappCameraRow || position == ignoreBlockedRow ||
position == useSystemEmojiRow || position == ipv6Row || position == typefaceRow ||
position == showChangePermissionsRow || position == showDeleteDownloadedFileRow || position == showAdminActionsRow || position == showReportRow ||
- position == showPrPrRow || position == showAddToSavedMessagesRow ||
+ position == showPrPrRow || position == showViewHistoryRow || position == showAddToSavedMessagesRow ||
position == nameOrderRow || position == forceTabletRow || position == mapPreviewRow ||
position == xmasRow || position == newYearRow || position == newYearEveRow || position == fireworksRow ||
position == transparentStatusBarRow || position == hideProxySponsorChannelRow;
@@ -569,7 +578,7 @@ public class NekoSettingsActivity extends BaseFragment {
} else if (position == ipv6Row || position == hidePhoneRow || position == inappCameraRow ||
position == showAddToSavedMessagesRow || position == showPrPrRow || position == showReportRow ||
position == showAdminActionsRow || position == showChangePermissionsRow || position == showDeleteDownloadedFileRow ||
- position == transparentStatusBarRow || position == hideProxySponsorChannelRow ||
+ position == transparentStatusBarRow || position == hideProxySponsorChannelRow || position == showViewHistoryRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
position == forceTabletRow || position == xmasRow || position == newYearRow || position == newYearEveRow ||
position == fireworksRow) {
diff --git a/TMessagesProj/src/main/res/values-it/strings_neko.xml b/TMessagesProj/src/main/res/values-it/strings_neko.xml
index 310e48425..a47fbe57a 100644
--- a/TMessagesProj/src/main/res/values-it/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-it/strings_neko.xml
@@ -50,4 +50,5 @@
Questo account si connetterà al server di test.
Questo account si connetterà al server principale.
Nascondi canale sponsor proxy
+ Visualizza la cronologia
diff --git a/TMessagesProj/src/main/res/values-ja/strings_neko.xml b/TMessagesProj/src/main/res/values-ja/strings_neko.xml
index 1e21e51c7..b00ff1056 100644
--- a/TMessagesProj/src/main/res/values-ja/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-ja/strings_neko.xml
@@ -50,4 +50,5 @@
このアカウントは、テストバックエンドに接続します。
このアカウントは、本番バックエンドに接続します。
Proxy sponsor channel を非表示
+ 履歴を見る
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
index 2cc858389..05999d588 100644
--- a/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_neko.xml
@@ -50,4 +50,5 @@
此账户将连接至测试后端服务器。
此账户将连接至生产后端服务器。
隐藏代理赞助商频道
+ 显示历史消息
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
index 22ea4791f..4cd1af03f 100644
--- a/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values-zh-rTW/strings_neko.xml
@@ -50,4 +50,5 @@
此賬戶將連接至測試後端伺服器。
此賬戶將連接至生產後端伺服器。
隱藏代理贊助商頻道
+ 顯示歷史消息
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml
index 5b2aeb296..f276f4f87 100644
--- a/TMessagesProj/src/main/res/values/strings_neko.xml
+++ b/TMessagesProj/src/main/res/values/strings_neko.xml
@@ -55,4 +55,5 @@
This account will connect to the test backend.
This account will connect to the production backend.
Hide proxy sponsor channel
+ View history
\ No newline at end of file