diff options
author | malockin <malockin@gmail.com> | 2020-05-03 22:56:31 +0300 |
---|---|---|
committer | malockin <malockin@gmail.com> | 2020-05-03 22:56:31 +0300 |
commit | 1cdfd80ca1561ca0f33313424488354ef6349749 (patch) | |
tree | 4d8f60e3768263bd1387823aa33b22b6d6ccd340 /core/src | |
parent | 10e8f7c614d60104ac381c6593116c5bbfb1595a (diff) | |
download | AntennaPod-1cdfd80ca1561ca0f33313424488354ef6349749.zip |
Updated PR according to comments
Removed unnecessary checks in while loop, and converted it to a
do...while loop.
Moved favorites export under HTML section.
Corrected indentation in resources files.
Moved to using a unified template for all HTML exports.
Removed unnecessary strings, corrected capitalization.
Diffstat (limited to 'core/src')
5 files changed, 12 insertions, 101 deletions
diff --git a/core/src/main/assets/favorites-export-template.html b/core/src/main/assets/favorites-export-template.html deleted file mode 100644 index ace80591b..000000000 --- a/core/src/main/assets/favorites-export-template.html +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
-<html>
- <head>
- <title>AntennaPod Favorites</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- * {
- font-family: 'Lato', sans-serif;
- font-weight: 300;
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- html {
- background: #3498db;
- text-align: center;
- padding: 10px;
- }
- h1 {
- color: #fff;
- font-weight: 300;
- display: inline-block;
- margin-top: 40px;
- margin-bottom: 20px;
- vertical-align: top;
- }
- li {
- width: 100%;
- max-width: 500px;
- display: block;
- display: inline-flex;
- padding: 10px;
- }
- li > div {
- background: #fefefe;
- padding: 10px;
- display: inline-block;
- width: 100%;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
- text-align: left;
- }
- li span {
- margin-top: 10px;
- display: block;
- }
- a {
- text-decoration: none;
- }
- a:hover {
- text-decoration: underline;
- }
- span a {
- color: #3498db;
- }
- img {
- width: 100px;
- height: 100px;
- margin-right: 10px;
- }
- li > div > img {
- float: left;
- }
- li > div > p {
- width: 100%;
- }
- body > a {
- color: #ffffff;
- display: inline-block;
- margin-top: 10px;
- clear:left;
- }
- </style>
- </head>
- <body>
- <img src="https://antennapod.org/assets/img/antennapod-logo.png" />
- <h1>AntennaPod Favorites</h1>
- <ul>
- {FAVORITES}
- </ul>
- <a href="https://play.google.com/store/apps/details?id=de.danoeh.antennapod" target="_blank">Get AntennaPod</a>
- </body>
-</html>
diff --git a/core/src/main/assets/html-export-template.html b/core/src/main/assets/html-export-template.html index ddab27a43..fd54a8dc6 100644 --- a/core/src/main/assets/html-export-template.html +++ b/core/src/main/assets/html-export-template.html @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8' standalone='no' ?>
<html>
<head>
- <title>AntennaPod Subscriptions</title>
+ <title>AntennaPod {TITLE}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
@@ -76,7 +76,7 @@ </head>
<body>
<img src="https://antennapod.org/assets/img/antennapod-logo.png" />
- <h1>AntennaPod Subscriptions</h1>
+ <h1>AntennaPod {TITLE}</h1>
<ul>
{FEEDS}
</ul>
diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java index 7b4b38265..4d4ad60bb 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java @@ -30,9 +30,10 @@ public class FavoritesWriter implements ExportWriter { throws IllegalArgumentException, IllegalStateException, IOException { Log.d(TAG, "Starting to write document"); - InputStream templateStream = context.getAssets().open("favorites-export-template.html"); + InputStream templateStream = context.getAssets().open("html-export-template.html"); String template = IOUtils.toString(templateStream, "UTF-8"); - String[] templateParts = template.split("\\{FAVORITES\\}"); + template = template.replaceAll("\\{TITLE\\}", "Favorites"); + String[] templateParts = template.split("\\{FEEDS\\}"); Map<Long, List<FeedItem>> favoriteByFeed = getFeedMap(getFavorites()); @@ -45,7 +46,7 @@ public class FavoritesWriter implements ExportWriter { writer.append("<li><div>"); writeFeed(writer, favorites.get(0).getFeed()); - writer.append("<ul>"); + writer.append("<ul style=\"text-align:left\">"); for (FeedItem item : favorites) { writeFavoriteItem(writer, item); } @@ -62,21 +63,13 @@ public class FavoritesWriter implements ExportWriter { private List<FeedItem> getFavorites() { int page = 0; - List<FeedItem> favoritesPage = DBReader.getFavoriteItemsList(page, PAGE_LIMIT); List<FeedItem> favoritesList = new ArrayList<>(); - - while (!favoritesPage.isEmpty()) { + List<FeedItem> favoritesPage; + do { + favoritesPage = DBReader.getFavoriteItemsList(page * PAGE_LIMIT, PAGE_LIMIT); favoritesList.addAll(favoritesPage); - - // save a DB call if there are no more items to fetch - if (favoritesPage.size() < PAGE_LIMIT) { - break; - } - ++page; - - favoritesPage = DBReader.getFavoriteItemsList(page * PAGE_LIMIT, PAGE_LIMIT); - } + } while (!favoritesPage.isEmpty() && favoritesPage.size() == PAGE_LIMIT); // sort in descending order Collections.sort(favoritesList, (lhs, rhs) -> rhs.getPubDate().compareTo(lhs.getPubDate())); diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java b/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java index 93b66daed..3f34343ee 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/html/HtmlWriter.java @@ -25,6 +25,7 @@ public class HtmlWriter implements ExportWriter { InputStream templateStream = context.getAssets().open("html-export-template.html"); String template = IOUtils.toString(templateStream, "UTF-8"); + template = template.replaceAll("\\{TITLE\\}", "Subscriptions"); String[] templateParts = template.split("\\{FEEDS\\}"); writer.append(templateParts[0]); diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d4bc20974..f4c7a86e1 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -576,8 +576,7 @@ <string name="import_select_file">Select file to import</string> <string name="import_ok">Import successful.\n\nPlease press OK to restart AntennaPod</string> <string name="import_no_downgrade">This database was exported with a newer version of AntennaPod. Your current installation does not yet know how to handle this file.</string> - <string name="favorites">Favorites</string> - <string name="favorites_export_label">Favorites Export</string> + <string name="favorites_export_label">Favorites export</string> <string name="favorites_export_summary">Export saved favorites to file</string> <!-- Sleep timer --> |