diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 74aeea7bf..ecd403cd5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -8106,7 +8106,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private void sendLogs() { - File path = new File(EnvUtil.getTelegramPath(), "logs"); + File path = new File(EnvUtil.getShareCachePath(), "logs"); path.mkdirs(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java index f2dc4dbea..33211334a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java @@ -123,6 +123,7 @@ import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.ui.PinnedStickerHelper; import tw.nekomimi.nekogram.utils.AlertUtil; +import tw.nekomimi.nekogram.utils.EnvUtil; import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.ShareUtil; import tw.nekomimi.nekogram.utils.StickersUtil; @@ -695,7 +696,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter JsonObject exportObj = StickersUtil.exportStickers(currentAccount, exportSets, exportArchived); - File cacheFile = new File(ApplicationLoader.applicationContext.getCacheDir(), new Date().toLocaleString() + ".nekox-stickers.json"); + File cacheFile = new File(EnvUtil.getShareCachePath(), new Date().toLocaleString() + ".nekox-stickers.json"); StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); @@ -1200,7 +1201,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter JsonObject exportObj = StickersUtil.exportStickers(stickerSetList); - File cacheFile = new File(ApplicationLoader.applicationContext.getCacheDir(), new Date().toLocaleString() + ".nekox-stickers.json"); + File cacheFile = new File(EnvUtil.getShareCachePath(), new Date().toLocaleString() + ".nekox-stickers.json"); StringWriter stringWriter = new StringWriter(); JsonWriter jsonWriter = new JsonWriter(stringWriter); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoSettingsActivity.java index 8663866eb..f838393ec 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoSettingsActivity.java @@ -61,6 +61,7 @@ import kotlin.text.StringsKt; import tw.nekomimi.nekogram.DatacenterActivity; import tw.nekomimi.nekogram.utils.AlertUtil; +import tw.nekomimi.nekogram.utils.EnvUtil; import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.GsonUtil; import tw.nekomimi.nekogram.utils.ShareUtil; @@ -194,7 +195,7 @@ public class NekoSettingsActivity extends BaseFragment { private void backupSettings() { try { - File cacheFile = new File(ApplicationLoader.applicationContext.getCacheDir(), new Date().toLocaleString() + ".nekox-settings.json"); + File cacheFile = new File(EnvUtil.getShareCachePath(), new Date().toLocaleString() + ".nekox-settings.json"); FileUtil.writeUtf8String(backupSettingsJson(), cacheFile); ShareUtil.shareFile(getParentActivity(), cacheFile); } catch (JSONException e) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoXSettingActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoXSettingActivity.java index 27e726bd5..5bd73a23e 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoXSettingActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoXSettingActivity.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.utils.AlertUtil; +import tw.nekomimi.nekogram.utils.EnvUtil; import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.LocaleUtil; import tw.nekomimi.nekogram.utils.ShareUtil; @@ -165,7 +166,7 @@ public class NekoXSettingActivity extends BaseFragment { LocaleUtil.fetchAndExportLang(); - File zipFile = new File(ApplicationLoader.applicationContext.getCacheDir(), "languages.zip"); + File zipFile = new File(EnvUtil.getShareCachePath(), "languages.zip"); FileUtil.delete(zipFile); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt index 6992749a2..be33f4147 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt @@ -79,6 +79,15 @@ object EnvUtil { } + @JvmStatic + fun getShareCachePath(): File { + // fix SDK < A11 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + return getTelegramPath() + } + return File(availableDirectories[3]) + } + @JvmStatic fun doTest() {