fix: fix nightly auto-updater
This commit is contained in:
@@ -59,7 +59,9 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
public GithubSelfUpdaterImpl(){
|
public GithubSelfUpdaterImpl(){
|
||||||
SharedPreferences prefs=getPrefs();
|
SharedPreferences prefs=getPrefs();
|
||||||
int checkedByBuild=prefs.getInt("checkedByBuild", 0);
|
int checkedByBuild=prefs.getInt("checkedByBuild", 0);
|
||||||
if(prefs.contains("version") && checkedByBuild==BuildConfig.VERSION_CODE){
|
String checkedByDate=prefs.getString("checkedByDate", "1970-01-00");
|
||||||
|
String currentVersionDate = BuildConfig.VERSION_NAME.substring(BuildConfig.VERSION_NAME.lastIndexOf("@") + 1);
|
||||||
|
if(prefs.contains("version") && checkedByBuild==BuildConfig.VERSION_CODE && checkedByDate.equals(currentVersionDate)){
|
||||||
info=new UpdateInfo();
|
info=new UpdateInfo();
|
||||||
info.version=prefs.getString("version", null);
|
info.version=prefs.getString("version", null);
|
||||||
info.size=prefs.getLong("apkSize", 0);
|
info.size=prefs.getLong("apkSize", 0);
|
||||||
@@ -74,7 +76,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
MastodonApp.context.registerReceiver(downloadCompletionReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(checkedByBuild!=BuildConfig.VERSION_CODE && checkedByBuild>0){
|
}else if((checkedByBuild!=BuildConfig.VERSION_CODE && checkedByBuild>0) || !checkedByDate.equals(currentVersionDate)){
|
||||||
// We are in a new version, running for the first time after update. Gotta clean things up.
|
// We are in a new version, running for the first time after update. Gotta clean things up.
|
||||||
long id=getPrefs().getLong("downloadID", 0);
|
long id=getPrefs().getLong("downloadID", 0);
|
||||||
if(id!=0){
|
if(id!=0){
|
||||||
@@ -140,6 +142,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
.putString("version", version)
|
.putString("version", version)
|
||||||
.putString("apkURL", url)
|
.putString("apkURL", url)
|
||||||
.putString("changelog", changelog)
|
.putString("changelog", changelog)
|
||||||
|
.putString("checkedByDate", BuildConfig.VERSION_NAME.substring(BuildConfig.VERSION_NAME.lastIndexOf("@") + 1))
|
||||||
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
||||||
.remove("downloadID")
|
.remove("downloadID")
|
||||||
.apply();
|
.apply();
|
||||||
@@ -158,7 +161,12 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
}catch(Exception x){
|
}catch(Exception x){
|
||||||
Log.w(TAG, "actuallyCheckForUpdates", x);
|
Log.w(TAG, "actuallyCheckForUpdates", x);
|
||||||
}finally{
|
}finally{
|
||||||
setState(info==null ? UpdateState.NO_UPDATE : UpdateState.UPDATE_AVAILABLE);
|
if(info != null && !info.version.substring(info.version.indexOf("-") + 1).equals(BuildConfig.VERSION_NAME.substring(BuildConfig.VERSION_NAME.lastIndexOf("@") + 1))) {
|
||||||
|
setState(UpdateState.UPDATE_AVAILABLE);
|
||||||
|
} else {
|
||||||
|
removeInfo();
|
||||||
|
setState(UpdateState.NO_UPDATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +176,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
.remove("version")
|
.remove("version")
|
||||||
.remove("apkURL")
|
.remove("apkURL")
|
||||||
.remove("checkedByBuild")
|
.remove("checkedByBuild")
|
||||||
|
.remove("checkedByDate")
|
||||||
.remove("downloadID")
|
.remove("downloadID")
|
||||||
.remove("changelog")
|
.remove("changelog")
|
||||||
.apply();
|
.apply();
|
||||||
|
|||||||
Reference in New Issue
Block a user