diff --git a/mobile/com.sap.sailing.android.shared/res/values/stores.xml b/mobile/com.sap.sailing.android.shared/res/values/stores.xml
new file mode 100644
index 00000000000..58161f88be1
--- /dev/null
+++ b/mobile/com.sap.sailing.android.shared/res/values/stores.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ - com.android.vending
+ - com.amazon.venezia
+ - com.sec.android.app.samsungsapps
+
+
+ Sideload
+
+
+ - Google PlayStore
+ - Amazon App Store
+ - Galaxy Apps
+
+
+
\ No newline at end of file
diff --git a/mobile/com.sap.sailing.android.shared/src/com/sap/sailing/android/shared/util/AppUtils.java b/mobile/com.sap.sailing.android.shared/src/com/sap/sailing/android/shared/util/AppUtils.java
index 72ae436f4c7..64bff031398 100644
--- a/mobile/com.sap.sailing.android.shared/src/com/sap/sailing/android/shared/util/AppUtils.java
+++ b/mobile/com.sap.sailing.android.shared/src/com/sap/sailing/android/shared/util/AppUtils.java
@@ -10,9 +10,12 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
+import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
+import com.sap.sailing.android.shared.R;
+
public class AppUtils {
private final static String TAG = AppUtils.class.getName();
@@ -46,6 +49,30 @@ public class AppUtils {
}
}
+ public String getInstallerPackageName() {
+ return mContext.getPackageManager().getInstallerPackageName(mContext.getPackageName());
+ }
+
+ public String getStoreName() {
+ String installer = getInstallerPackageName();
+ if (!TextUtils.isEmpty(installer)) {
+ String[] storeNames = mContext.getResources().getStringArray(R.array.store_names);
+ String[] storePackages = mContext.getResources().getStringArray(R.array.store_packages);
+ int len = storePackages.length;
+ for (int i = 0; i < len; i++) {
+ if (installer.equals(storePackages[i])) {
+ return storeNames[i];
+ }
+ }
+ }
+
+ return mContext.getString(R.string.sideload);
+ }
+
+ public boolean isSideLoaded() {
+ return getStoreName().equals(mContext.getString(R.string.sideload));
+ }
+
/**
* Read the build.info from the asset folder, which is written at build time with git information
*
diff --git a/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml b/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml
index 37b89f9c1a6..cc309651bae 100644
--- a/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml
+++ b/mobile/com.sap.sailing.racecommittee.app/res/values-de/strings.xml
@@ -218,6 +218,7 @@
Link zur Versionsinformation ungültig.
Klicke \'Installieren\' um ein Update auf Version %1$d durchzuführen.
Es ist bereits die Server-Version installiert (Version %1$d).
+ Die aktuelle App wurde per %1$s installiert. Der Download vom Server kann nicht ohne vorherige Deinstallation der App installiert werden.
Alles aktuell!
Downloade APK vom Server…
Der Downloadlink ist ungültig.
diff --git a/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml b/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml
index 168518c0dd2..793583c214c 100644
--- a/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml
+++ b/mobile/com.sap.sailing.racecommittee.app/res/values/strings.xml
@@ -233,6 +233,7 @@
The version file link was not valid.
Click \'Install\' to perform the update to version %1$d.
You already have installed the version offered by the server (version %1$d).
+ Your current version is installed from %1$s. The download from the server can\'t be installed without uninstalling the current app.
You are already up to date!
Downloading APK from server…
The download link was not valid.
diff --git a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/autoupdate/AutoUpdaterChecker.java b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/autoupdate/AutoUpdaterChecker.java
index 7eb36b61aad..3cada99a486 100644
--- a/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/autoupdate/AutoUpdaterChecker.java
+++ b/mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/utils/autoupdate/AutoUpdaterChecker.java
@@ -48,11 +48,11 @@ public class AutoUpdaterChecker {
dialog.setCancelable(true);
dialog.setButton(DialogInterface.BUTTON_POSITIVE,
context.getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
- dialog.cancel();
- }
- });
+ @Override
+ public void onClick(DialogInterface arg0, int arg1) {
+ dialog.cancel();
+ }
+ });
}
public void check(URL serverUrl) {
@@ -63,7 +63,7 @@ public class AutoUpdaterChecker {
private final boolean forceUpdate;
private URL serverUrl;
-
+
public AutoUpdaterStateImpl(boolean forceUpdate) {
this.forceUpdate = forceUpdate;
}
@@ -75,7 +75,7 @@ public class AutoUpdaterChecker {
dialog.setIndeterminate(true);
dialog.setMessage(context.getString(R.string.auto_update_checking_version));
dialog.show();
-
+
try {
URL versionUrl = composeVersionUrl();
ExLog.i(context, TAG, context.getString(R.string.auto_update_downloading_version, versionUrl.toString()));
@@ -99,7 +99,7 @@ public class AutoUpdaterChecker {
int currentVersion = AppUtils.with(context).getPackageInfo().versionCode;
boolean needsUpdate = currentVersion != serverVersion;
ExLog.i(context, TAG, String.format("Server version is %d. Local version is %d.", serverVersion, currentVersion));
-
+
DialogInterface.OnClickListener dismissListener = new OnClickListener() {
@Override
public void onClick(DialogInterface prompt, int which) {
@@ -122,14 +122,17 @@ public class AutoUpdaterChecker {
};
String messageFormat = needsUpdate ? context.getString(R.string.auto_update_click_install) : context.getString(R.string.auto_update_force_install);
-
- AlertDialog.Builder updateDialog = new AlertDialog.Builder(context);
+ if (!AppUtils.with(context).isSideLoaded()) {
+ messageFormat += "\n\n" + context.getString(R.string.auto_update_with_store, AppUtils.with(context).getStoreName());
+ }
+
+ AlertDialog.Builder updateDialog = new AlertDialog.Builder(context, R.style.AppTheme_AlertDialog);
updateDialog
- .setTitle(R.string.auto_update)
- .setMessage(String.format(messageFormat, serverVersion))
- .setPositiveButton(context.getString(needsUpdate ? R.string.auto_update_install : android.R.string.ok), needsUpdate ? updateListener : dismissListener)
- .setNegativeButton(context.getString(needsUpdate ? android.R.string.cancel : R.string.auto_update_install_anyway), needsUpdate ? dismissListener : updateListener)
- .setOnCancelListener(cancelListener);
+ .setTitle(R.string.auto_update)
+ .setMessage(String.format(messageFormat, serverVersion))
+ .setPositiveButton(context.getString(needsUpdate ? R.string.auto_update_install : android.R.string.ok), needsUpdate ? updateListener : dismissListener)
+ .setNegativeButton(context.getString(needsUpdate ? android.R.string.cancel : R.string.auto_update_install_anyway), needsUpdate ? dismissListener : updateListener)
+ .setOnCancelListener(cancelListener);
if (needsUpdate || forceUpdate) {
updateDialog.show();
} else {
@@ -140,14 +143,14 @@ public class AutoUpdaterChecker {
private void downloadUpdate(String apkFileName) {
dialog.setMessage(context.getString(R.string.auto_update_downloading_apk));
-
+
try {
File target = updater.createApkTargetFile();
-
+
final AutoUpdaterApkDownloader downloader = new AutoUpdaterApkDownloader(this, target, context);
-
+
URL downloadUrl = composeDownloadUrl(apkFileName);
- ExLog.i(context, TAG, String.format("Download from %s to file %s.", downloadUrl.toString() , target.getAbsolutePath()));
+ ExLog.i(context, TAG, String.format("Download from %s to file %s.", downloadUrl.toString(), target.getAbsolutePath()));
downloader.execute(downloadUrl);
dialog.setOnCancelListener(new OnCancelListener() {
@Override
@@ -181,22 +184,14 @@ public class AutoUpdaterChecker {
@Override
public void onError() {
dialog.dismiss();
- Drawable drawable = ContextCompat.getDrawable(context, android.R.drawable.ic_dialog_alert);
AlertDialog.Builder errorDialog = new AlertDialog.Builder(context, R.style.AppTheme_AlertDialog);
errorDialog
- .setTitle(R.string.auto_update)
- .setMessage(R.string.auto_update_error)
- .setIcon(drawable)
- .setPositiveButton(context.getString(android.R.string.ok), new OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- }
- })
- .create()
- .show();
+ .setTitle(R.string.auto_update)
+ .setMessage(R.string.auto_update_error)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
}
-
+
protected URL composeVersionUrl() throws MalformedURLException {
String packageName = context.getPackageName();
return new URL(serverUrl.getProtocol(), serverUrl.getHost(), serverUrl.getPort(), serverUrl.getPath()