Only ignore a special version update
This commit is contained in:
1 parent
bfd85e9bc7
commit
ceeb84812b
15 files changed
+30
-31
No files matched your search
@@ -63,7 +63,6 @@ public class EhApplication extends RecordingApplication {
|
||||
private static final String TAG = EhApplication.class.getSimpleName();
|
||||
|
||||
public static final boolean BETA = false;
|
||||
public static final boolean AUTO_UPDATE = true;
|
||||
|
||||
private static final boolean DEBUG_CONACO = false;
|
||||
private static final boolean DEBUG_PRINT_NATIVE_MEMORY = false;
|
||||
|
||||
@@ -976,8 +976,8 @@ public class Settings {
|
||||
********************/
|
||||
private static final String KEY_BETA_UPDATE_CHANNEL = "beta_update_channel";
|
||||
private static final boolean DEFAULT_BETA_UPDATE_CHANNEL = EhApplication.BETA;
|
||||
private static final String KEY_AUTO_CHECK_FOR_UPDATES = "auto_check_for_updates";
|
||||
private static final boolean DEFAULT_AUTO_CHECK_FOR_UPDATES = EhApplication.AUTO_UPDATE;
|
||||
private static final String KEY_SKIP_UPDATE_VERSION = "skip_update_version";
|
||||
private static final int DEFAULT_SKIP_UPDATE_VERSION = 0;
|
||||
|
||||
public static boolean getBetaUpdateChannel() {
|
||||
return getBoolean(KEY_BETA_UPDATE_CHANNEL, DEFAULT_BETA_UPDATE_CHANNEL);
|
||||
@@ -987,8 +987,12 @@ public class Settings {
|
||||
putBoolean(KEY_BETA_UPDATE_CHANNEL, value);
|
||||
}
|
||||
|
||||
public static boolean getAutoCheckUpdateEnable() {
|
||||
return getBoolean(KEY_AUTO_CHECK_FOR_UPDATES, DEFAULT_AUTO_CHECK_FOR_UPDATES);
|
||||
public static int getSkipUpdateVersion() {
|
||||
return getInt(KEY_SKIP_UPDATE_VERSION, DEFAULT_SKIP_UPDATE_VERSION);
|
||||
}
|
||||
|
||||
public static void putSkipUpdateVersion(int value) {
|
||||
putInt(KEY_SKIP_UPDATE_VERSION, value);
|
||||
}
|
||||
|
||||
/********************
|
||||
|
||||
@@ -101,17 +101,13 @@ public final class CommonOperations {
|
||||
}
|
||||
|
||||
private void showUpToDateDialog() {
|
||||
if (!mFeedback) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(mActivity)
|
||||
.setMessage(R.string.update_to_date)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showUpdateDialog(String versionName, String size, CharSequence info, final String url) {
|
||||
private void showUpdateDialog(String versionName, int versionCode, String size, CharSequence info, final String url) {
|
||||
new AlertDialog.Builder(mActivity)
|
||||
.setTitle(R.string.update)
|
||||
.setMessage(mActivity.getString(R.string.update_plain, versionName, size, info))
|
||||
@@ -120,16 +116,22 @@ public final class CommonOperations {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
UrlOpener.openUrl(mActivity, url, false);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.update_ignore, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Settings.putSkipUpdateVersion(versionCode);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
|
||||
private void handleResult(JSONObject jo) {
|
||||
if (null == jo || mActivity.isFinishing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String versionName;
|
||||
int versionCode;
|
||||
String size;
|
||||
CharSequence info;
|
||||
String url;
|
||||
@@ -138,10 +140,12 @@ public final class CommonOperations {
|
||||
PackageManager pm = mActivity.getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
|
||||
int currentVersionCode = pi.versionCode;
|
||||
int newVersionCode = jo.getInt("version_code");
|
||||
if (currentVersionCode >= newVersionCode) {
|
||||
versionCode = jo.getInt("version_code");
|
||||
if (currentVersionCode >= versionCode) {
|
||||
// Update to date
|
||||
showUpToDateDialog();
|
||||
if (mFeedback) {
|
||||
showUpToDateDialog();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,7 +157,9 @@ public final class CommonOperations {
|
||||
return;
|
||||
}
|
||||
|
||||
showUpdateDialog(versionName, size, info, url);
|
||||
if (mFeedback || versionCode != Settings.getSkipUpdateVersion()) {
|
||||
showUpdateDialog(versionName, versionCode, size, info, url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -350,9 +350,7 @@ public final class MainActivity extends StageActivity
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
onInit();
|
||||
if (Settings.getAutoCheckUpdateEnable()) {
|
||||
CommonOperations.checkUpdate(this, false);
|
||||
}
|
||||
CommonOperations.checkUpdate(this, false);
|
||||
checkDownloadLocation();
|
||||
if (Settings.getCellularNetworkWarning()) {
|
||||
checkCellularNetwork();
|
||||
|
||||
Reference in new issue
Block a user