From 83eccf9704d189396904714a85741f01a11783c3 Mon Sep 17 00:00:00 2001 From: Julian Harty Date: Fri, 15 Dec 2017 20:51:49 +0000 Subject: [PATCH 1/3] Removed unused imports. --- .../java/org/kiwix/kiwixmobile/utils/StorageUtils.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java index a2fd44afe..23998c0ec 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/StorageUtils.java @@ -1,15 +1,5 @@ package org.kiwix.kiwixmobile.utils; -import android.os.Build; -import android.os.Environment; -import android.os.StatFs; -import android.util.Log; - -import java.io.File; -import java.io.IOException; -import java.text.DecimalFormat; -import java.util.UUID; - public class StorageUtils { public static String getFileNameFromUrl(String url) { From eeba917fe2b8b05e490b2b8dcab5371c852add09 Mon Sep 17 00:00:00 2001 From: Julian Harty Date: Sat, 16 Dec 2017 07:08:04 +0000 Subject: [PATCH 2/3] Improved the UI: users can now understand the purpose of the WiFi option. Duplicated the text that appears on the preferences in the summary so that the user can actually read what it says. This particularly affects smaller screened device. It might be worth revising the title, however that'd then need any changes to be retranslated. This change isn't ideal (duplicating content on the screen) however it seems practical and helpful. You're welcome to help improve it. --- app/src/main/res/xml/preferences.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 45d4f7ea2..6f179795f 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -62,7 +62,8 @@ + android:title="@string/pref_wifi_only" + android:summary="@string/pref_wifi_only"/> Date: Sat, 16 Dec 2017 09:41:16 +0000 Subject: [PATCH 3/3] A partial improvement to deal with problematic data in the library file. Does not seem to catch JNI exceptions/crashes. To be continued... --- .../kiwixmobile/utils/files/FileSearch.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileSearch.java b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileSearch.java index f37cdb817..7cae6930d 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileSearch.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/utils/files/FileSearch.java @@ -181,17 +181,24 @@ public class FileSearch { // This is not a great solution as we shouldn't need to fully open our ZIM files to get their metadata if (ZimContentProvider.canIterate) { if (ZimContentProvider.setZimFile(filePath) != null) { - book = new LibraryNetworkEntity.Book(); - book.title = ZimContentProvider.getZimFileTitle(); - book.id = ZimContentProvider.getId(); - book.file = new File(filePath); - book.size = String.valueOf(ZimContentProvider.getFileSize()); - book.favicon = ZimContentProvider.getFavicon(); - book.creator = ZimContentProvider.getCreator(); - book.publisher = ZimContentProvider.getPublisher(); - book.date = ZimContentProvider.getDate(); - book.description = ZimContentProvider.getDescription(); - book.language = ZimContentProvider.getLanguage(); + try { + book = new LibraryNetworkEntity.Book(); + book.title = ZimContentProvider.getZimFileTitle(); + book.id = ZimContentProvider.getId(); + book.file = new File(filePath); + book.size = String.valueOf(ZimContentProvider.getFileSize()); + book.favicon = ZimContentProvider.getFavicon(); + book.creator = ZimContentProvider.getCreator(); + book.publisher = ZimContentProvider.getPublisher(); + book.date = ZimContentProvider.getDate(); + book.description = ZimContentProvider.getDescription(); + book.language = ZimContentProvider.getLanguage(); + } catch (Exception e) { + // TODO 20171215 Consider more elegant approaches. + // This is to see if we can catch the exception at all! + Log.e("kiwix-filesearch", "Problem parsing a book entry from the library file. ", e); + return null; + } } } // Return content provider to its previous state