Split auto download settings
This commit is contained in:
parent
11de01f3ae
commit
b89be7f504
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
public class DownloadController extends BaseController implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
@ -576,8 +577,13 @@ public class DownloadController extends BaseController implements NotificationCe
|
||||
public boolean canDownloadMedia(MessageObject messageObject) {
|
||||
if (messageObject.getDocument() != null) {
|
||||
String documentName = messageObject.getDocument().file_name;
|
||||
if (StrUtil.endWithAny(documentName, ".cmd", ".bat", ".exe", ".lha", ".lzh", ".apk", ".zip", ".7z")) {
|
||||
return false;
|
||||
if (StrUtil.isNotBlank(documentName)) {
|
||||
if ((NekoConfig.disableAutoDownloadingWin32Executable &&
|
||||
documentName.toLowerCase().matches(".*\\.(cmd|bat|com|exe|lnk|msi|ps1|reg|vb|vbe|vbs|vbscript)")
|
||||
) || (NekoConfig.disableAutoDownloadingArchive &&
|
||||
documentName.toLowerCase().matches(".*\\.(apk|zip|7z|tar|gz|zst|iso|xz|lha|lzh)")
|
||||
)
|
||||
) return false;
|
||||
}
|
||||
}
|
||||
return canDownloadMedia(messageObject.messageOwner) == 1;
|
||||
|
@ -137,6 +137,9 @@ public class NekoConfig {
|
||||
public static boolean avatarBackgroundDarken;
|
||||
public static boolean disableTrending;
|
||||
|
||||
public static boolean disableAutoDownloadingWin32Executable;
|
||||
public static boolean disableAutoDownloadingArchive;
|
||||
|
||||
public static String getOpenPGPAppName() {
|
||||
|
||||
if (StrUtil.isNotBlank(openPGPApp)) {
|
||||
@ -222,8 +225,8 @@ public class NekoConfig {
|
||||
hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false);
|
||||
avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", true);
|
||||
avatarBackgroundBlur = preferences.getBoolean("avatarBackgroundBlur", false);
|
||||
avatarBackgroundDarken = preferences.getBoolean("avatarBackgroundDarken", false);
|
||||
useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
|
||||
avatarBackgroundDarken = preferences.getBoolean("avatarBackgroundDarken", false);
|
||||
useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
|
||||
showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
|
||||
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
|
||||
hideAllTab = preferences.getBoolean("hideAllTab", false);
|
||||
@ -291,6 +294,9 @@ public class NekoConfig {
|
||||
acceptSecretChat = preferences.getBoolean("acceptSecretChat", true);
|
||||
disableTrending = preferences.getBoolean("disableTrending", true);
|
||||
|
||||
disableAutoDownloadingWin32Executable = preferences.getBoolean("disableAutoDownloadingWin32Executable", true);
|
||||
disableAutoDownloadingArchive = preferences.getBoolean("disableAutoDownloadingArchive", true);
|
||||
|
||||
}
|
||||
|
||||
public static void toggleShowAddToSavedMessages() {
|
||||
@ -743,6 +749,14 @@ public class NekoConfig {
|
||||
preferences.edit().putBoolean("disableTrending", disableTrending = !disableTrending).apply();
|
||||
}
|
||||
|
||||
public static void toggleDisableAutoDownloadingWin32Executable() {
|
||||
preferences.edit().putBoolean("disableAutoDownloadingWin32Executable", disableAutoDownloadingWin32Executable = !disableAutoDownloadingWin32Executable).apply();
|
||||
}
|
||||
|
||||
public static void toggleDisableAutoDownloadingArchive() {
|
||||
preferences.edit().putBoolean("disableAutoDownloadingArchive", disableAutoDownloadingArchive = !disableAutoDownloadingArchive).apply();
|
||||
}
|
||||
|
||||
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
|
||||
|
||||
public static Typeface getSystemEmojiTypeface() {
|
||||
|
@ -79,6 +79,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
private int messageMenuRow;
|
||||
private int chat2Row;
|
||||
|
||||
private int downloadRow;
|
||||
private int win32Row;
|
||||
private int archiveRow;
|
||||
private int download2Row;
|
||||
|
||||
private int foldersRow;
|
||||
private int showTabsOnForwardRow;
|
||||
private int hideAllTabRow;
|
||||
@ -257,6 +262,16 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.disableTrending);
|
||||
}
|
||||
} else if (position == win32Row) {
|
||||
NekoConfig.toggleDisableAutoDownloadingWin32Executable();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(!NekoConfig.disableAutoDownloadingWin32Executable);
|
||||
}
|
||||
} else if (position == archiveRow) {
|
||||
NekoConfig.toggleDisableAutoDownloadingArchive();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(!NekoConfig.disableAutoDownloadingArchive);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -299,6 +314,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
messageMenuRow = rowCount++;
|
||||
chat2Row = rowCount++;
|
||||
|
||||
downloadRow = rowCount++;
|
||||
win32Row = rowCount++;
|
||||
archiveRow = rowCount++;
|
||||
download2Row = rowCount++;
|
||||
|
||||
foldersRow = rowCount++;
|
||||
showTabsOnForwardRow = rowCount++;
|
||||
hideAllTabRow = rowCount++;
|
||||
@ -636,6 +656,10 @@ 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 == win32Row) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("Win32ExecutableFiles", R.string.Win32ExecutableFiles), !NekoConfig.disableAutoDownloadingWin32Executable, true);
|
||||
} else if (position == archiveRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("ArchiveFiles", R.string.ArchiveFiles), !NekoConfig.disableAutoDownloadingArchive, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -645,6 +669,8 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
headerCell.setText(LocaleController.getString("Chat", R.string.Chat));
|
||||
} else if (position == foldersRow) {
|
||||
headerCell.setText(LocaleController.getString("Folder", R.string.Folder));
|
||||
} else if (position == downloadRow) {
|
||||
headerCell.setText(LocaleController.getString("AutoDownload", R.string.AutoDownload));
|
||||
} else if (position == stickerSizeHeaderRow) {
|
||||
headerCell.setText(LocaleController.getString("StickerSize", R.string.StickerSize));
|
||||
}
|
||||
@ -702,11 +728,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == chat2Row || position == folders2Row || position == stickerSize2Row) {
|
||||
if (position == chat2Row || position == folders2Row || position == download2Row || position == stickerSize2Row) {
|
||||
return 1;
|
||||
} else if (position == mapPreviewRow || position == messageMenuRow || position == tabsTitleTypeRow) {
|
||||
return 2;
|
||||
} else if (position == chatRow || position == foldersRow || position == stickerSizeHeaderRow) {
|
||||
} else if (position == chatRow || position == foldersRow || position == downloadRow || position == stickerSizeHeaderRow) {
|
||||
return 4;
|
||||
} else if (position == stickerSizeRow) {
|
||||
return 8;
|
||||
|
@ -274,9 +274,14 @@
|
||||
<string name="TextOrigin">Origin</string>
|
||||
<string name="TextReplace">Replace</string>
|
||||
<string name="ReplaceRegex">Use regex</string>
|
||||
|
||||
<string name="DisableTrending">Disable Trending</string>
|
||||
<string name="HideDeviceInfo">Hide device model</string>
|
||||
<string name="HideDeviceInfoOff">Device model will be uploaded the second time the app starts after logging in.</string>
|
||||
<string name="HideDeviceInfoOn">You can change this in the settings later.</string>
|
||||
|
||||
<string name="AutoDownload">AutoDownload</string>
|
||||
<string name="Win32ExecutableFiles">Win32 executable files</string>
|
||||
<string name="ArchiveFiles">Archive files</string>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user