[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 BorderNestedScrollView rootView;
|
||||
|
||||
public FlashDialogBuilder(@NonNull Context context, @NonNull String zipPath) {
|
||||
public FlashDialogBuilder(@NonNull Context context, String zipPath, String notes) {
|
||||
super(context);
|
||||
this.zipPath = zipPath;
|
||||
setTitle(R.string.update_lsposed);
|
||||
|
||||
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());
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
|
|
@ -57,7 +58,15 @@ public class FlashDialogBuilder extends BlurBehindDialogBuilder {
|
|||
public AlertDialog show() {
|
||||
var dialog = super.show();
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,9 +102,11 @@ public class HomeFragment extends BaseFragment {
|
|||
}
|
||||
} else {
|
||||
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) {
|
||||
new FlashDialogBuilder(activity, zip).show();
|
||||
new FlashDialogBuilder(activity, zip, notes).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ public class UpdateUtil {
|
|||
var name = assets.get("name").getAsString();
|
||||
var code = Integer.parseInt(name.split("-", 4)[2]);
|
||||
var now = Instant.now().getEpochSecond();
|
||||
var releaseNotes = info.get("body").getAsString();
|
||||
pref.edit()
|
||||
.putInt("latest_version", code)
|
||||
.putLong("latest_check", now)
|
||||
.putString("release_notes", releaseNotes)
|
||||
.putBoolean("checked", true)
|
||||
.apply();
|
||||
var updatedAt = Instant.parse(assets.get("updated_at").getAsString());
|
||||
|
|
|
|||
Loading…
Reference in New Issue