This commit is contained in:
LucasGGamerM 2022-12-25 11:58:23 -03:00
parent d66a4c0920
commit c5fcf49eda
2 changed files with 22 additions and 5 deletions

View File

@ -40,6 +40,7 @@ import okhttp3.Response;
public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
private static final long CHECK_PERIOD=6*3600*1000L;
private static final String TAG="GithubSelfUpdater";
private static String changelog;
private UpdateState state=UpdateState.NO_UPDATE;
private UpdateInfo info;
@ -109,6 +110,11 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
MastodonAPIController.runInBackground(this::actuallyCheckForUpdates);
}
@Override
public void getChangelog(){
MastodonAPIController.runInBackground(this::actuallyGetChangelog);
}
private void actuallyCheckForUpdates(){
Request req=new Request.Builder()
.url("https://api.github.com/repos/LucasGGamerM/moshidon/releases/latest")
@ -173,7 +179,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
}
}
public String getChangelog(){
public void actuallyGetChangelog(){
String changelog = null;
Request req=new Request.Builder()
.url("https://api.github.com/repos/LucasGGamerM/moshidon/releases/latest")
@ -184,15 +190,23 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
changelog=obj.get("body").getAsString();
if(changelog == null){
Log.w(TAG, "No changelog available");
return null;
return;
}
return changelog;
}catch(Exception x){
Log.w(TAG, "getChangelog: ", x);
}finally{
// setState(changelog==null ? UpdateState.NO_UPDATE : UpdateState.UPDATE_AVAILABLE);
setChangelog(changelog);
}
return changelog;
}
private void setChangelog(String changelog){
this.changelog = changelog;
}
public String getChangelogText(){
return changelog;
}
private void setState(UpdateState state){
this.state=state;

View File

@ -3,6 +3,7 @@ package org.joinmastodon.android.fragments;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@ -267,7 +268,9 @@ public class SettingsFragment extends MastodonToolbarFragment{
}
private void onGetChangelogClick(){
GithubSelfUpdater.getInstance().getChangelog();
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getContext());
alertDialogBuilder.setTitle("Something TODO remove this");
alertDialogBuilder.setMessage(GithubSelfUpdater.getInstance().getChangelog());
}
private void onThemePreferenceClick(GlobalUserPreferences.ThemePreference theme){