From 2c69b6773124a92faf2e8f36726158a94d910092 Mon Sep 17 00:00:00 2001 From: seven332 Date: Mon, 21 Mar 2016 21:49:40 +0800 Subject: [PATCH] Add check download location --- .../java/com/hippo/ehviewer/ui/MainActivity.java | 15 +++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 2 ++ app/src/main/res/values-zh-rHK/strings.xml | 2 ++ app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 23 insertions(+) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java index f61cc67f2..40aef282a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.java @@ -29,6 +29,7 @@ import android.support.design.widget.NavigationView; import android.support.design.widget.Snackbar; import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.util.Log; import android.view.Gravity; @@ -66,6 +67,7 @@ import com.hippo.scene.Announcer; import com.hippo.scene.SceneFragment; import com.hippo.scene.StageActivity; +import com.hippo.unifile.UniFile; import com.hippo.util.PermissionRequester; import com.hippo.widget.LoadImageView; import com.hippo.yorozuya.ViewUtils; @@ -308,11 +310,24 @@ protected void onCreate2(@Nullable Bundle savedInstanceState) { if (savedInstanceState == null) { onInit(); CommonOperations.checkUpdate(this, false); + checkDownloadLocation(); } else { onRestore(savedInstanceState); } } + private void checkDownloadLocation() { + UniFile uniFile = Settings.getDownloadLocation(); + if (null != uniFile && uniFile.ensureDir()) { + return; + } + new AlertDialog.Builder(this) + .setTitle(R.string.waring) + .setMessage(R.string.invalid_download_location) + .setPositiveButton(R.string.get_it, null) + .show(); + } + private void onInit() { // Check permission PermissionRequester.request(this, Manifest.permission.WRITE_EXTERNAL_STORAGE, diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 8c53793ea..34aece1ff 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -46,6 +46,8 @@ 好的 我没输错 + 似乎下载路径不可用。请到重新设置下载路径。 + 错误的状态码:%d 超时 未知主机 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 273a37d41..69708cc11 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -46,6 +46,8 @@ 好的 我沒輸錯 + 似乎下載路徑不可用。請到重新設置下載路徑。 + 錯誤的狀態碼:%d 超時 未知主機 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 2a0e0f1a6..a64c90cf7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -46,6 +46,8 @@ 好的 我沒輸錯 + 似乎下載路徑不可用。請到重新設定下載路徑。 + 錯誤的狀態碼:%d 超時 未知主機 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 04450eb37..6df4514d2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,6 +62,8 @@ I will check it I don\'t think so + It seems download location is not available. Please set it in Settings. + Bad Request Unauthorized Payment Required