aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorCarey Metcalfe <carey@cmetcalfe.ca>2017-10-13 19:54:41 -0400
committerCarey Metcalfe <carey@cmetcalfe.ca>2017-10-13 23:02:15 -0400
commitd0223c6eab8f58799c8c3ff0e67f5974c237e01c (patch)
tree89c72eec95d66b94ad5ba5e061a6ca7a8b6e4ff1 /app
parent9f89e7e1524cd4a6e6646e8768aa76c26ee92e79 (diff)
downloaddsub-d0223c6eab8f58799c8c3ff0e67f5974c237e01c.tar.gz
dsub-d0223c6eab8f58799c8c3ff0e67f5974c237e01c.tar.bz2
dsub-d0223c6eab8f58799c8c3ff0e67f5974c237e01c.zip
Fix crash on startup when building without environment variables
- Adds a check for the `CAST_APPLICATION_ID` variable in `CastCompat`. If it's null, casting will be disabled. - Without a `PASTEBIN_DEV_KEY` sending logs would result in a generic "Failed to gather logs" message. This commit changes the message to something more accurate.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/EnvironmentVariables.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/CastCompat.java3
3 files changed, 9 insertions, 2 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
index 82e50b76..e7c7f1fb 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
@@ -270,6 +270,10 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
}
private void getLogs() {
+ if (EnvironmentVariables.PASTEBIN_DEV_KEY == null) {
+ Util.toast(context, "No PASTEBIN_DEV_KEY configured - can't upload logs");
+ return;
+ }
try {
final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
new LoadingTask<String>(context) {
diff --git a/app/src/main/java/github/daneren2005/dsub/util/EnvironmentVariables.java b/app/src/main/java/github/daneren2005/dsub/util/EnvironmentVariables.java
index 710d5232..8af74f07 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/EnvironmentVariables.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/EnvironmentVariables.java
@@ -16,6 +16,6 @@
package github.daneren2005.dsub.util;
public final class EnvironmentVariables {
- public static final String PASTEBIN_DEV_KEY = "";
- public static final String CAST_APPLICATION_ID = "";
+ public static final String PASTEBIN_DEV_KEY = null;
+ public static final String CAST_APPLICATION_ID = null;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/CastCompat.java b/app/src/main/java/github/daneren2005/dsub/util/compat/CastCompat.java
index 415106db..08bac263 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/CastCompat.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/CastCompat.java
@@ -27,6 +27,9 @@ import github.daneren2005.dsub.util.EnvironmentVariables;
public final class CastCompat {
static {
+ if (EnvironmentVariables.CAST_APPLICATION_ID == null) {
+ throw new RuntimeException("CAST_APPLICATION_ID not provided");
+ }
try {
Class.forName("com.google.android.gms.cast.CastDevice");
} catch (Exception ex) {