forked from upstream-mirrors/quik
Display changes in dialog
This commit is contained in:
@@ -17,6 +17,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -77,15 +78,20 @@ public class DialogHelper {
|
|||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Change[] changes = gson.fromJson(response, Change[].class);
|
Change[] changes = gson.fromJson(response, Change[].class);
|
||||||
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat dateParser = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
SimpleDateFormat formatWithRevision = new SimpleDateFormat("yyyy-MM-dd-'r'H"); // For multiple updates in a day
|
SimpleDateFormat dateRevisionParser = new SimpleDateFormat("yyyy-MM-dd-'r'H"); // For multiple updates in a day
|
||||||
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("MMMM d, yyyy");
|
||||||
for (Change change : changes) {
|
for (Change change : changes) {
|
||||||
try {
|
try {
|
||||||
|
Date date;
|
||||||
if (change.date.length() > 11) {
|
if (change.date.length() > 11) {
|
||||||
change.dateLong = formatWithRevision.parse(change.date).getTime();
|
date = dateRevisionParser.parse(change.date);
|
||||||
} else {
|
} else {
|
||||||
change.dateLong = format.parse(change.date).getTime();
|
date = dateParser.parse(change.date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
change.date = dateFormatter.format(date);
|
||||||
|
change.dateLong = date.getTime();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -93,7 +99,32 @@ public class DialogHelper {
|
|||||||
|
|
||||||
Arrays.sort(changes, (lhs, rhs) -> Long.valueOf(rhs.dateLong).compareTo(lhs.dateLong));
|
Arrays.sort(changes, (lhs, rhs) -> Long.valueOf(rhs.dateLong).compareTo(lhs.dateLong));
|
||||||
|
|
||||||
|
String[] versions = new String[changes.length];
|
||||||
|
String[] dates = new String[changes.length];
|
||||||
|
String[] changelists = new String[changes.length];
|
||||||
|
for (int i = 0; i < changes.length; i++) {
|
||||||
|
Change change = changes[i];
|
||||||
|
versions[i] = change.version;
|
||||||
|
dates[i] = change.date;
|
||||||
|
|
||||||
|
changelists[i] = "";
|
||||||
|
for (int j = 0; j < change.changes.size(); j++) {
|
||||||
|
String changeItem = change.changes.get(j);
|
||||||
|
changelists[i] += " • ";
|
||||||
|
changelists[i] += changeItem;
|
||||||
|
if (j < change.changes.size() - 1) {
|
||||||
|
changelists[i] += "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.hideProgressDialog();
|
context.hideProgressDialog();
|
||||||
|
|
||||||
|
new QKDialog()
|
||||||
|
.setContext(context)
|
||||||
|
.setTitle(R.string.title_changelog)
|
||||||
|
.setTripleLineItems(versions, dates, changelists, null)
|
||||||
|
.show();
|
||||||
}, error -> {
|
}, error -> {
|
||||||
context.hideProgressDialog();
|
context.hideProgressDialog();
|
||||||
context.makeToast(R.string.toast_changelog_error);
|
context.makeToast(R.string.toast_changelog_error);
|
||||||
@@ -103,9 +134,9 @@ public class DialogHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Change implements Comparator<Long> {
|
private class Change implements Comparator<Long> {
|
||||||
@SerializedName("changes") ArrayList<String> changes;
|
|
||||||
@SerializedName("release_date") String date;
|
|
||||||
@SerializedName("version_name") String version;
|
@SerializedName("version_name") String version;
|
||||||
|
@SerializedName("release_date") String date;
|
||||||
|
@SerializedName("changes") ArrayList<String> changes;
|
||||||
|
|
||||||
long dateLong = 0;
|
long dateLong = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user