fix: Export File On Low Android Version
This commit is contained in:
parent
83c5a1b4ff
commit
5a9dfe2d46
@ -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();
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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() {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user