mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-02-04 13:17:42 +01:00
changelog popup initial working draft
This commit is contained in:
parent
17e9e43454
commit
e40eb5e6a1
@ -32,6 +32,7 @@ import org.mian.gitnex.fragments.SettingsFragment;
|
||||
import org.mian.gitnex.fragments.StarredRepositoriesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.ChangeLog;
|
||||
import org.mian.gitnex.helpers.Toasty;
|
||||
import org.mian.gitnex.models.GiteaVersion;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
@ -285,6 +286,10 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
|
||||
}
|
||||
|
||||
// Changelog popup
|
||||
ChangeLog changelogDialog = new ChangeLog(this);
|
||||
changelogDialog.showDialog();
|
||||
|
||||
}
|
||||
|
||||
public void setActionBarTitle (@NonNull String title) {
|
||||
|
102
app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java
Normal file
102
app/src/main/java/org/mian/gitnex/helpers/ChangeLog.java
Normal file
@ -0,0 +1,102 @@
|
||||
package org.mian.gitnex.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import org.mian.gitnex.R;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
|
||||
public class ChangeLog {
|
||||
|
||||
static final private String TAG = "ChangeLog";
|
||||
static final private String CHANGELOG_XML_NODE = "changelog";
|
||||
|
||||
private Activity changelogActivity;
|
||||
|
||||
public ChangeLog(Activity context) {
|
||||
changelogActivity = context;
|
||||
}
|
||||
|
||||
private String ParseReleaseTag(XmlResourceParser aXml) throws XmlPullParserException, IOException {
|
||||
|
||||
StringBuilder strBuilder = new StringBuilder(aXml.getAttributeValue(null, "version") + "<br>");
|
||||
int eventType = aXml.getEventType();
|
||||
|
||||
while ((eventType != XmlPullParser.END_TAG) || (aXml.getName().equals("change"))) {
|
||||
|
||||
if ((eventType == XmlPullParser.START_TAG) &&(aXml.getName().equals("change"))) {
|
||||
eventType = aXml.next();
|
||||
strBuilder.append(aXml.getText()).append("<br>");
|
||||
}
|
||||
eventType = aXml.next();
|
||||
|
||||
}
|
||||
strBuilder.append("<br>");
|
||||
|
||||
return strBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
private String getChangelog(int resId, Resources res) {
|
||||
|
||||
StringBuilder strBuilder = new StringBuilder();
|
||||
try (XmlResourceParser xml = res.getXml(resId)) {
|
||||
|
||||
int eventType = xml.getEventType();
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
|
||||
if ((eventType == XmlPullParser.START_TAG) && (xml.getName().equals("release"))) {
|
||||
strBuilder.append(ParseReleaseTag(xml));
|
||||
|
||||
}
|
||||
eventType = xml.next();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (XmlPullParserException | IOException e) {
|
||||
Log.e(TAG, Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
return strBuilder.toString();
|
||||
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
|
||||
String packageName = changelogActivity.getPackageName();
|
||||
Resources res = null;
|
||||
|
||||
try {
|
||||
res = changelogActivity.getPackageManager().getResourcesForApplication(packageName);
|
||||
}
|
||||
catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
|
||||
assert res != null;
|
||||
int resId = res.getIdentifier(CHANGELOG_XML_NODE, "xml", packageName);
|
||||
|
||||
String changelogMessage = getChangelog(resId, res);
|
||||
|
||||
androidx.appcompat.app.AlertDialog.Builder builder = new AlertDialog.Builder(changelogActivity);
|
||||
builder.setTitle(R.string.changelogTitle);
|
||||
builder.setMessage(Html.fromHtml("<small>" + changelogMessage + "</small>"));
|
||||
builder.setNegativeButton(R.string.okButton, (dialog, which) -> dialog.cancel());
|
||||
builder.create();
|
||||
builder.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -560,4 +560,7 @@
|
||||
<string name="shareIssue">Share Issue</string>
|
||||
<string name="shareRepository">Share Repository</string>
|
||||
<string name="createRepository">Create Repository</string>
|
||||
|
||||
<string name="changelogTitle" translatable="false">Changelog</string>
|
||||
|
||||
</resources>
|
||||
|
26
app/src/main/res/xml/changelog.xml
Normal file
26
app/src/main/res/xml/changelog.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<changelog>
|
||||
|
||||
<release version="2.4.0" versioncode="90">
|
||||
<change>New: Light theme (choose from settings)</change>
|
||||
<change>New: Icons</change>
|
||||
<change>New: Download files in Fileviewer (needs write permission)</change>
|
||||
<change>New: Custom fonts (choose from settings)</change>
|
||||
<change>New: PDF support in Fileviewer</change>
|
||||
<change>New: Night mode for PDF in Fileviewer (choose from settings)</change>
|
||||
<change>New: Default list of repositories in Explore screen</change>
|
||||
<change>New: Latvian language support</change>
|
||||
<change>Improvement: Support more files in file viewer syntax highlighter</change>
|
||||
<change>Improvement: Exclude BIN files rendering in diff viewer</change>
|
||||
<change>Improvement: Exclude specific files in Fileviewer like doc, xls etc</change>
|
||||
<change>Improvement: Single issue id and support copy title and description to clipboard</change>
|
||||
<change>Improvement: Translation updates</change>
|
||||
<change>Bugfix: Don’t refresh repositories without action</change>
|
||||
</release>
|
||||
|
||||
<release version="2.3.2" versioncode="82">
|
||||
<change>Bugfix: Slashes in URL(file viewer)</change>
|
||||
<change>Bugfix: No milestones when creating issue if user has other language selected</change>
|
||||
</release>
|
||||
|
||||
</changelog>
|
Loading…
x
Reference in New Issue
Block a user