Skip to content

Commit

Permalink
fix parsing of changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Development committed Sep 20, 2023
1 parent f850ad2 commit e36385b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
0.9.9.82
---------------------

- Added - <a href="https://github.com/nextcloud/news-android/pull/1262">!1262 - Add shortcut to "Show only unread articles" in the toolbar (thanks to @mkanilsson)</a>
- Changed - <a href="https://github.com/nextcloud/news-android/pull/1186">!1186 - Material 3 Theme (thanks to @stefan-niedermann)</a>
- Changed - <a href="https://github.com/nextcloud/news-android/pull/1256">!1256 - Fix starred items not obeying sort order (thanks to @mkanilsson)</a>
Expand All @@ -10,12 +9,10 @@

0.9.9.81
---------------------

- Changed - Updated SSO lib

0.9.9.80
---------------------

- Changed - Internal dependency updates
- Changed - <a href="https://github.com/nextcloud/news-android/pull/1212">!1212 - Nextcloud Single-Sign-On updates</a>
- Changed - <a href="https://github.com/nextcloud/news-android/pull/1200">!1200 - Bail out early on generating unread rss items notifications (thanks to @Unpublished)</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.database.DataSetObserver;
import android.os.AsyncTask;
import android.util.Log;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
Expand All @@ -26,7 +27,7 @@ public class DownloadChangelogTask extends AsyncTask<Void, Void, String> {

private static final String TAG = "DownloadChangelogTask";

private static final String README_URL = "https://raw.githubusercontent.com/nextcloud/news-android/master/CHANGELOG.md";
private static final String CHANGELOG_URL = "https://raw.githubusercontent.com/nextcloud/news-android/master/CHANGELOG.md";
private static final String FILE_NAME = "changelog.xml";

private final Context mContext;
Expand Down Expand Up @@ -54,7 +55,7 @@ protected String doInBackground(Void... params) {
String path = null;

try {
ArrayList<String> changelogArr = downloadReadme();
ArrayList<String> changelogArr = downloadChangelog();
String xml = convertToXML(changelogArr);
path = saveToTempFile(xml, FILE_NAME);
} catch (IOException e) {
Expand All @@ -80,17 +81,23 @@ public void onChanged() {
});
}

private ArrayList<String> downloadReadme() throws IOException {
private ArrayList<String> downloadChangelog() throws IOException {
ArrayList<String> changelogArr = new ArrayList<>();

URL url = new URL(README_URL);
URL url = new URL(CHANGELOG_URL);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
InputStream isTemp = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(isTemp));
String inputLine;
String prevLine = "";
while ((inputLine = in.readLine()) != null) {
changelogArr.add(inputLine.replace("<", "[").replace(">", "]"));
if(inputLine.trim().isEmpty() && prevLine.startsWith("---")) {
Log.e(TAG, "skip empty line after version code in changelog (please fix changelog - remove all empty lines after the version code line)");
} else {
changelogArr.add(inputLine.replace("<", "[").replace(">", "]"));
}
prevLine = inputLine;
}
in.close();
} finally {
Expand Down

0 comments on commit e36385b

Please sign in to comment.