[app] Show release notes (#1277)

This commit is contained in:
南宫雪珊 2021-10-15 02:25:36 +08:00 committed by GitHub
parent 12b005c2d9
commit fabe82b0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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());