Merge pull request #176

Fix/nightly updater
This commit is contained in:
LucasGGamerM
2023-04-20 17:51:37 -03:00
committed by GitHub
3 changed files with 23 additions and 10 deletions

View File

@@ -109,7 +109,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
if(GithubSelfUpdater.needSelfUpdating()){
GithubSelfUpdater updater=GithubSelfUpdater.getInstance();
GithubSelfUpdater.UpdateState state=updater.getState();
if(state!=GithubSelfUpdater.UpdateState.NO_UPDATE && state!=GithubSelfUpdater.UpdateState.CHECKING){
if(state!=GithubSelfUpdater.UpdateState.NO_UPDATE && state!=GithubSelfUpdater.UpdateState.CHECKING && updater.getUpdateInfo() != null){
items.add(new UpdateItem());
}
}

View File

@@ -20,6 +20,7 @@ import org.joinmastodon.android.fragments.account_list.StatusFavoritesListFragme
import org.joinmastodon.android.fragments.account_list.StatusReblogsListFragment;
import org.joinmastodon.android.fragments.account_list.StatusRelatedAccountListFragment;
import org.joinmastodon.android.model.Status;
import org.joinmastodon.android.model.StatusPrivacy;
import org.joinmastodon.android.ui.utils.UiUtils;
import org.parceler.Parcels;
@@ -72,7 +73,11 @@ public class ExtendedFooterStatusDisplayItem extends StatusDisplayItem{
public void onBind(ExtendedFooterStatusDisplayItem item){
Status s=item.status;
favorites.setText(context.getResources().getQuantityString(R.plurals.x_favorites, (int)(s.favouritesCount%1000), s.favouritesCount));
reblogs.setText(context.getResources().getQuantityString(R.plurals.x_reblogs, (int)(s.reblogsCount%1000), s.reblogsCount));
reblogs.setText(context.getResources().getQuantityString(R.plurals.x_reblogs, (int) (s.reblogsCount % 1000), s.reblogsCount));
if (s.visibility==StatusPrivacy.DIRECT)
reblogs.setVisibility(View.GONE);
if(s.editedAt!=null){
editHistory.setVisibility(View.VISIBLE);
editHistory.setText(UiUtils.formatRelativeTimestampAsMinutesAgo(itemView.getContext(), s.editedAt));

View File

@@ -81,14 +81,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
MastodonApp.context.getSystemService(DownloadManager.class).remove(id);
}
getUpdateApkFile().delete();
getPrefs().edit()
.remove("apkSize")
.remove("version")
.remove("apkURL")
.remove("checkedByBuild")
.remove("downloadID")
.remove("changelog")
.apply();
removeInfo();
}
}
@@ -154,6 +147,10 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
break;
}
}
} else {
Log.d(TAG, "actuallyCheckForUpdates: no update available");
removeInfo();
setState(UpdateState.NO_UPDATE);
}
getPrefs().edit().putLong("lastCheck", System.currentTimeMillis()).apply();
break;
@@ -165,6 +162,17 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
}
}
private void removeInfo() {
getPrefs().edit()
.remove("apkSize")
.remove("version")
.remove("apkURL")
.remove("checkedByBuild")
.remove("downloadID")
.remove("changelog")
.apply();
}
private void setState(UpdateState state){
this.state=state;
E.post(new SelfUpdateStateChangedEvent(state));