From e4651375aa25a23567812e8ead16177969068eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sun, 18 Nov 2018 03:23:22 +0100 Subject: [PATCH] fix qr url --- .../simplecloudnotifier/model/SCNSettings.java | 8 +++++--- .../simplecloudnotifier/model/ServerCommunication.java | 4 +++- .../simplecloudnotifier/view/AccountFragment.java | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java index c729bd6..aeceb4d 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/SCNSettings.java @@ -163,10 +163,12 @@ public class SCNSettings return user_id>=0 && user_key != null && !user_key.isEmpty(); } - public String createOnlineURL() + public String createOnlineURL(boolean longurl) { - if (!isConnected()) return ServerCommunication.BASE_URL + "index.php"; - return ServerCommunication.BASE_URL + "index.php?preset_user_id="+user_id+"&preset_user_key="+user_key; + String base = longurl ? ServerCommunication.PAGE_URL_LONG : ServerCommunication.PAGE_URL_SHORT; + + if (!isConnected()) return base; + return base + "index.php?preset_user_id="+user_id+"&preset_user_key="+user_key; } public void setServerToken(String token, View loader) diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java index 68087f9..6779fdb 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/model/ServerCommunication.java @@ -27,7 +27,9 @@ import okhttp3.ResponseBody; public class ServerCommunication { - public static final String BASE_URL = /*SCNApp.LOCAL_DEBUG ? "http://localhost:1010/" : */"https://scn.blackforestbytes.com/api/"; + public static final String PAGE_URL_LONG = "https://simplecloudnotifier.blackforestbytes.com/"; + public static final String PAGE_URL_SHORT = "https://scn.blackforestbytes.com/"; + public static final String BASE_URL = "https://scn.blackforestbytes.com/api/"; private static final OkHttpClient client = new OkHttpClient(); diff --git a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/AccountFragment.java b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/AccountFragment.java index e8aed56..d57b5b1 100644 --- a/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/AccountFragment.java +++ b/android/app/src/main/java/com/blackforestbytes/simplecloudnotifier/view/AccountFragment.java @@ -105,7 +105,7 @@ public class AccountFragment extends Fragment v.findViewById(R.id.btnQR).setOnClickListener(cv -> { - Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(SCNSettings.inst().createOnlineURL())); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(SCNSettings.inst().createOnlineURL(true))); startActivity(browserIntent); }); @@ -141,7 +141,7 @@ public class AccountFragment extends Fragment tvUserID.setText(String.valueOf(s.user_id)); tvUserKey.setText(s.user_key); tvQuota.setText(String.format("%d / %d", s.quota_curr, s.quota_max)); - btnQR.setImageBitmap(QRCode.from(s.createOnlineURL()).to(ImageType.PNG).withSize(512, 512).bitmap()); + btnQR.setImageBitmap(QRCode.from(s.createOnlineURL(false)).to(ImageType.PNG).withSize(512, 512).bitmap()); ivQuota.setColorFilter(s.quota_curr>=s.quota_max ? Color.rgb(200, 0, 0) : Color.rgb(128, 128, 128)); } else