add changelog to updater
thanks, @LucasGGamerM!
This commit is contained in:
@@ -61,6 +61,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
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);
|
||||||
|
info.changelog=prefs.getString("changelog", null);
|
||||||
downloadID=prefs.getLong("downloadID", 0);
|
downloadID=prefs.getLong("downloadID", 0);
|
||||||
if(downloadID==0 || !getUpdateApkFile().exists()){
|
if(downloadID==0 || !getUpdateApkFile().exists()){
|
||||||
state=UpdateState.UPDATE_AVAILABLE;
|
state=UpdateState.UPDATE_AVAILABLE;
|
||||||
@@ -84,6 +85,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
.remove("apkURL")
|
.remove("apkURL")
|
||||||
.remove("checkedByBuild")
|
.remove("checkedByBuild")
|
||||||
.remove("downloadID")
|
.remove("downloadID")
|
||||||
|
.remove("changelog")
|
||||||
.apply();
|
.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,6 +119,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
try(Response resp=call.execute()){
|
try(Response resp=call.execute()){
|
||||||
JsonObject obj=JsonParser.parseReader(resp.body().charStream()).getAsJsonObject();
|
JsonObject obj=JsonParser.parseReader(resp.body().charStream()).getAsJsonObject();
|
||||||
String tag=obj.get("tag_name").getAsString();
|
String tag=obj.get("tag_name").getAsString();
|
||||||
|
String changelog=obj.get("body").getAsString();
|
||||||
Pattern pattern=Pattern.compile("v?(\\d+)\\.(\\d+)\\.(\\d+)\\+fork\\.(\\d+)");
|
Pattern pattern=Pattern.compile("v?(\\d+)\\.(\\d+)\\.(\\d+)\\+fork\\.(\\d+)");
|
||||||
Matcher matcher=pattern.matcher(tag);
|
Matcher matcher=pattern.matcher(tag);
|
||||||
if(!matcher.find()){
|
if(!matcher.find()){
|
||||||
@@ -151,12 +154,14 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
|
|||||||
UpdateInfo info=new UpdateInfo();
|
UpdateInfo info=new UpdateInfo();
|
||||||
info.size=size;
|
info.size=size;
|
||||||
info.version=version;
|
info.version=version;
|
||||||
|
info.changelog=changelog;
|
||||||
this.info=info;
|
this.info=info;
|
||||||
|
|
||||||
getPrefs().edit()
|
getPrefs().edit()
|
||||||
.putLong("apkSize", size)
|
.putLong("apkSize", size)
|
||||||
.putString("version", version)
|
.putString("version", version)
|
||||||
.putString("apkURL", url)
|
.putString("apkURL", url)
|
||||||
|
.putString("changelog", changelog)
|
||||||
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
.putInt("checkedByBuild", BuildConfig.VERSION_CODE)
|
||||||
.remove("downloadID")
|
.remove("downloadID")
|
||||||
.apply();
|
.apply();
|
||||||
|
|||||||
@@ -959,7 +959,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
|
|
||||||
private class UpdateViewHolder extends BindableViewHolder<UpdateItem>{
|
private class UpdateViewHolder extends BindableViewHolder<UpdateItem>{
|
||||||
|
|
||||||
private final TextView text;
|
private final TextView text, changelog;
|
||||||
private final Button button;
|
private final Button button;
|
||||||
private final ImageButton cancelBtn;
|
private final ImageButton cancelBtn;
|
||||||
private final ProgressBar progress;
|
private final ProgressBar progress;
|
||||||
@@ -970,6 +970,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
public UpdateViewHolder(){
|
public UpdateViewHolder(){
|
||||||
super(getActivity(), R.layout.item_settings_update, list);
|
super(getActivity(), R.layout.item_settings_update, list);
|
||||||
text=findViewById(R.id.text);
|
text=findViewById(R.id.text);
|
||||||
|
changelog=findViewById(R.id.changelog);
|
||||||
button=findViewById(R.id.button);
|
button=findViewById(R.id.button);
|
||||||
cancelBtn=findViewById(R.id.cancel_btn);
|
cancelBtn=findViewById(R.id.cancel_btn);
|
||||||
progress=findViewById(R.id.progress);
|
progress=findViewById(R.id.progress);
|
||||||
@@ -1013,6 +1014,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||||||
progress.setVisibility(View.GONE);
|
progress.setVisibility(View.GONE);
|
||||||
progress.removeCallbacks(progressUpdater);
|
progress.removeCallbacks(progressUpdater);
|
||||||
}
|
}
|
||||||
|
changelog.setText(info.changelog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress(){
|
private void updateProgress(){
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public abstract class GithubSelfUpdater{
|
|||||||
|
|
||||||
public static class UpdateInfo{
|
public static class UpdateInfo{
|
||||||
public String version;
|
public String version;
|
||||||
|
public String changelog;
|
||||||
public long size;
|
public long size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,67 +8,83 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="64dp"
|
android:orientation="vertical"
|
||||||
android:gravity="center_vertical"
|
android:background="@drawable/bg_settings_update">
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:background="@drawable/bg_settings_update"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/text"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:minHeight="64dp"
|
||||||
android:layout_marginEnd="4dp"
|
android:gravity="center_vertical"
|
||||||
android:layout_marginTop="16dp"
|
android:orientation="horizontal">
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:textAppearance="@style/m3_body_medium"
|
|
||||||
tools:text="@string/sk_update_available"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/text"
|
||||||
android:layout_height="wrap_content">
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginVertical="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:textAppearance="@style/m3_body_medium"
|
||||||
|
tools:text="@string/sk_update_available"/>
|
||||||
|
|
||||||
<Button
|
<FrameLayout
|
||||||
android:id="@+id/button"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:layout_marginEnd="16dp">
|
||||||
android:background="?android:selectableItemBackground"
|
|
||||||
android:textColor="?android:textColorPrimary"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:stateListAnimator="@null"
|
|
||||||
tools:text="@string/install_update"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<Button
|
||||||
android:id="@+id/cancel_btn"
|
android:id="@+id/button"
|
||||||
android:layout_width="40dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end|center_vertical"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_marginEnd="16dp"
|
android:stateListAnimator="@null"
|
||||||
android:background="@drawable/bg_update_download_progress"
|
tools:text="@string/install_update"/>
|
||||||
android:tint="?colorSearchHint"
|
|
||||||
android:contentDescription="@string/cancel"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:src="@drawable/ic_fluent_dismiss_16_filled"/>
|
|
||||||
|
|
||||||
<ProgressBar
|
<ImageButton
|
||||||
android:id="@+id/progress"
|
android:id="@+id/cancel_btn"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="end|center_vertical"
|
android:layout_gravity="end|center_vertical"
|
||||||
android:layout_marginEnd="16dp"
|
android:background="@drawable/bg_update_download_progress"
|
||||||
android:progressDrawable="@drawable/update_progress"
|
android:tint="?colorSearchHint"
|
||||||
android:max="1000"
|
android:contentDescription="@string/cancel"
|
||||||
android:padding="0dp"
|
android:visibility="gone"
|
||||||
android:visibility="gone"
|
android:src="@drawable/ic_fluent_dismiss_16_filled"/>
|
||||||
android:indeterminateOnly="false"
|
|
||||||
android:indeterminate="false"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
<ProgressBar
|
||||||
|
android:id="@+id/progress"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:progressDrawable="@drawable/update_progress"
|
||||||
|
android:max="1000"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:indeterminateOnly="false"
|
||||||
|
android:indeterminate="false"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/changelog_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/m3_title_medium"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:text="@string/sk_changelog" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/changelog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/m3_body_medium"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="16dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -148,4 +148,5 @@
|
|||||||
<string name="sk_remove_follower_confirm">Remove %s as a follower by blocking and immediately unblocking them?</string>
|
<string name="sk_remove_follower_confirm">Remove %s as a follower by blocking and immediately unblocking them?</string>
|
||||||
<string name="sk_do_remove_follower">Remove</string>
|
<string name="sk_do_remove_follower">Remove</string>
|
||||||
<string name="sk_remove_follower_success">Successfully removed follower</string>
|
<string name="sk_remove_follower_success">Successfully removed follower</string>
|
||||||
|
<string name="sk_changelog">Changelog</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user