From 7219d4a1525edb075b043b758e6fbc5abc72f6c2 Mon Sep 17 00:00:00 2001 From: CDrummond Date: Tue, 28 Feb 2023 07:30:18 +0000 Subject: [PATCH] Catch exceptions when launching PDF viewer. Closes #8 --- fastlane/metadata/android/en-US/changelogs/401.txt | 3 +++ lms-material/build.gradle | 4 ++-- .../java/com/craigd/lmsmaterial/app/MainActivity.java | 8 +++++++- lms-material/src/main/res/values/strings.xml | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/401.txt diff --git a/fastlane/metadata/android/en-US/changelogs/401.txt b/fastlane/metadata/android/en-US/changelogs/401.txt new file mode 100644 index 0000000..e90d922 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/401.txt @@ -0,0 +1,3 @@ +Fixed + +• Catch exceptions when launching PDF viewer. diff --git a/lms-material/build.gradle b/lms-material/build.gradle index e2c6d8c..ba2adf2 100644 --- a/lms-material/build.gradle +++ b/lms-material/build.gradle @@ -13,8 +13,8 @@ android { minSdkVersion 21 // Need to target 28, or lower, to allow WiFi to be enabled... targetSdkVersion 28 - versionCode 400 - versionName "0.4.0" + versionCode 401 + versionName "0.4.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java index 2e9dc82..4e159bb 100644 --- a/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java +++ b/lms-material/src/main/java/com/craigd/lmsmaterial/app/MainActivity.java @@ -642,7 +642,13 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) { if (null!=path && path.toLowerCase().endsWith(".pdf")) { intent.setDataAndType(uri, "application/pdf"); } - startActivity(intent); + try { + startActivity(intent); + } catch (Exception e) { + StyleableToast.makeText(getApplicationContext(), + getApplicationContext().getResources().getString(R.string.no_termux_run_perms), + Toast.LENGTH_SHORT, R.style.toast).show(); + } return true; } diff --git a/lms-material/src/main/res/values/strings.xml b/lms-material/src/main/res/values/strings.xml index 315fbc6..4025e46 100644 --- a/lms-material/src/main/res/values/strings.xml +++ b/lms-material/src/main/res/values/strings.xml @@ -64,4 +64,5 @@ Show an entry in the main menu to start chosen player app. Stopping local player Do not have permission to run Termux commands + Failed to start activity