[app] Show release notes (#1277)
This commit is contained in:
parent
12b005c2d9
commit
fabe82b0b6
|
|
@ -33,13 +33,14 @@ public class FlashDialogBuilder extends BlurBehindDialogBuilder {
|
||||||
private final TextView textView;
|
private final TextView textView;
|
||||||
private final BorderNestedScrollView rootView;
|
private final BorderNestedScrollView rootView;
|
||||||
|
|
||||||
public FlashDialogBuilder(@NonNull Context context, @NonNull String zipPath) {
|
public FlashDialogBuilder(@NonNull Context context, String zipPath, String notes) {
|
||||||
super(context);
|
super(context);
|
||||||
this.zipPath = zipPath;
|
this.zipPath = zipPath;
|
||||||
setTitle(R.string.update_lsposed);
|
setTitle(R.string.update_lsposed);
|
||||||
|
|
||||||
textView = new MaterialTextView(context);
|
textView = new MaterialTextView(context);
|
||||||
textView.setText(R.string.update_lsposed_msg);
|
var text = notes + "\n\n\n" + context.getString(R.string.update_lsposed_msg) + "\n\n";
|
||||||
|
textView.setText(text);
|
||||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
|
@ -57,7 +58,15 @@ public class FlashDialogBuilder extends BlurBehindDialogBuilder {
|
||||||
public AlertDialog show() {
|
public AlertDialog show() {
|
||||||
var dialog = super.show();
|
var dialog = super.show();
|
||||||
var button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
var button = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
button.setOnClickListener((v) -> setFlashView(v, dialog));
|
button.setEnabled(false);
|
||||||
|
rootView.setOnScrollChangeListener((View.OnScrollChangeListener)
|
||||||
|
(v, scrollX, scrollY, oldScrollX, oldScrollY) -> button.setEnabled(
|
||||||
|
v.getScrollY() + v.getHeight() - v.getPaddingTop() - v.getPaddingBottom()
|
||||||
|
== rootView.getChildAt(0).getHeight()));
|
||||||
|
button.setOnClickListener((v) -> {
|
||||||
|
rootView.setOnScrollChangeListener((View.OnScrollChangeListener) null);
|
||||||
|
setFlashView(v, dialog);
|
||||||
|
});
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,11 @@ public class HomeFragment extends BaseFragment {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (UpdateUtil.canUpdate()) {
|
if (UpdateUtil.canUpdate()) {
|
||||||
var zip = App.getPreferences().getString("zip_file", null);
|
var pref = App.getPreferences();
|
||||||
|
var zip = pref.getString("zip_file", null);
|
||||||
|
var notes = pref.getString("release_notes", "");
|
||||||
if (zip != null) {
|
if (zip != null) {
|
||||||
new FlashDialogBuilder(activity, zip).show();
|
new FlashDialogBuilder(activity, zip, notes).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,11 @@ public class UpdateUtil {
|
||||||
var name = assets.get("name").getAsString();
|
var name = assets.get("name").getAsString();
|
||||||
var code = Integer.parseInt(name.split("-", 4)[2]);
|
var code = Integer.parseInt(name.split("-", 4)[2]);
|
||||||
var now = Instant.now().getEpochSecond();
|
var now = Instant.now().getEpochSecond();
|
||||||
|
var releaseNotes = info.get("body").getAsString();
|
||||||
pref.edit()
|
pref.edit()
|
||||||
.putInt("latest_version", code)
|
.putInt("latest_version", code)
|
||||||
.putLong("latest_check", now)
|
.putLong("latest_check", now)
|
||||||
|
.putString("release_notes", releaseNotes)
|
||||||
.putBoolean("checked", true)
|
.putBoolean("checked", true)
|
||||||
.apply();
|
.apply();
|
||||||
var updatedAt = Instant.parse(assets.get("updated_at").getAsString());
|
var updatedAt = Instant.parse(assets.get("updated_at").getAsString());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue