feat: Option to prevent sending greeting sticker

This commit is contained in:
luvletter2333 2021-06-02 18:05:07 +08:00
parent 47c813ba92
commit 28b9fc4fc2
No known key found for this signature in database
GPG Key ID: BFD68B892BECC1D8
4 changed files with 22 additions and 0 deletions

View File

@ -22,6 +22,8 @@ import org.telegram.ui.ActionBar.Theme;
import java.util.Locale;
import tw.nekomimi.nekogram.NekoConfig;
public class ChatGreetingsView extends LinearLayout {
private TLRPC.Document preloadedGreetingsSticker;
@ -84,6 +86,8 @@ public class ChatGreetingsView extends LinearLayout {
stickerToSendView.setImage(ImageLocation.getForDocument(sticker), createFilter(sticker), ImageLocation.getForDocument(thumb, sticker), null, 0, sticker);
}
stickerToSendView.setOnClickListener(v -> {
if (NekoConfig.dontSendGreetingSticker)
return;
if (listener != null) {
listener.onGreetings(sticker);
}

View File

@ -149,6 +149,8 @@ public class NekoConfig {
public static boolean disableAutoDownloadingWin32Executable;
public static boolean disableAutoDownloadingArchive;
public static boolean dontSendGreetingSticker;
public static String getOpenPGPAppName() {
if (StrUtil.isNotBlank(openPGPApp)) {
@ -311,6 +313,8 @@ public class NekoConfig {
disableAutoDownloadingWin32Executable = preferences.getBoolean("disableAutoDownloadingWin32Executable", true);
disableAutoDownloadingArchive = preferences.getBoolean("disableAutoDownloadingArchive", true);
dontSendGreetingSticker = preferences.getBoolean("dontSendGreetingSticker", false);
}
public static void toggleShowAddToSavedMessages() {
@ -791,6 +795,10 @@ public class NekoConfig {
preferences.edit().putBoolean("disableAutoDownloadingArchive", disableAutoDownloadingArchive = !disableAutoDownloadingArchive).apply();
}
public static void toggleDontSendGreetingSticker() {
preferences.edit().putBoolean("dontSendGreetingSticker", dontSendGreetingSticker = !dontSendGreetingSticker).apply();
}
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
public static Typeface getSystemEmojiTypeface() {

View File

@ -74,6 +74,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
private int sendCommentAfterForwardRow;
private int disableProximityEventsRow;
private int disableTrendingRow;
private int dontSendGreetingStickerRow;
private int mapPreviewRow;
private int messageMenuRow;
@ -269,6 +270,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.disableTrending);
}
} else if (position == dontSendGreetingStickerRow) {
NekoConfig.toggleDontSendGreetingSticker();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.dontSendGreetingSticker);
}
} else if (position == win32Row) {
NekoConfig.toggleDisableAutoDownloadingWin32Executable();
if (view instanceof TextCheckCell) {
@ -316,6 +322,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
sendCommentAfterForwardRow = rowCount++;
disableProximityEventsRow = rowCount++;
disableTrendingRow = rowCount++;
dontSendGreetingStickerRow = rowCount++;
mapPreviewRow = rowCount++;
messageMenuRow = rowCount++;
@ -675,6 +682,8 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
textCell.setTextAndCheck(LocaleController.getString("DisableProximityEvents", R.string.DisableProximityEvents), NekoConfig.disableProximityEvents, true);
} else if (position == disableTrendingRow) {
textCell.setTextAndCheck(LocaleController.getString("DisableTrending", R.string.DisableTrending), NekoConfig.disableTrending, true);
} else if (position == dontSendGreetingStickerRow) {
textCell.setTextAndCheck(LocaleController.getString("DontSendGreetingSticker", R.string.DontSendGreetingSticker), NekoConfig.dontSendGreetingSticker, true);
} else if (position == win32Row) {
textCell.setTextAndCheck(LocaleController.getString("Win32ExecutableFiles", R.string.Win32ExecutableFiles), !NekoConfig.disableAutoDownloadingWin32Executable, true);
} else if (position == archiveRow) {

View File

@ -110,5 +110,6 @@
<string name="ProviderMicrosoftTranslator">Microsoft Translator</string>
<string name="ProviderYouDao">YouDao Translate</string>
<string name="pressTitleToOpenAllChats">Press title to open \"All Chats\" tab</string>
<string name="DontSendGreetingSticker">Don\'t send greeting sticker</string>
</resources>