Merge remote-tracking branch 'origin/develop' into feature/macgills/1447-open-zim-from-content-uri

# Conflicts:
#	core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt
This commit is contained in:
Sean Mac Gillicuddy 2020-12-14 10:05:20 +00:00
commit a4ef17d254
29 changed files with 127 additions and 30 deletions

View File

@ -32,7 +32,7 @@ class ServiceWorkerInitialiser @Inject constructor(zimReaderContainer: ZimReader
ServiceWorkerControllerCompat.getInstance()
.setServiceWorkerClient(object : ServiceWorkerClientCompat() {
override fun shouldInterceptRequest(request: WebResourceRequest): WebResourceResponse? =
zimReaderContainer.load(request.url.toString())
zimReaderContainer.load(request.url.toString(), request.requestHeaders)
})
}
}

View File

@ -142,7 +142,7 @@ public class CoreWebViewClient extends WebViewClient {
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
String url = convertLegacyUrl(request.getUrl().toString());
if (url.startsWith(CONTENT_PREFIX)) {
return zimReaderContainer.load(url);
return zimReaderContainer.load(url, request.getRequestHeaders());
} else {
return super.shouldInterceptRequest(view, request);
}

View File

@ -172,7 +172,7 @@ open class KiwixWebView @SuppressLint("SetJavaScriptEnabled") constructor(
}.first { !it.exists() }
val source = Uri.parse(src)
try {
zimReaderContainer.load("$source").data.use { inputStream ->
zimReaderContainer.load("$source", emptyMap()).data.use { inputStream ->
fileToSave.outputStream().use { inputStream.copyTo(it) }
}
instance.toast(instance.getString(R.string.save_media_saved, fileToSave.name))

View File

@ -19,6 +19,7 @@ package org.kiwix.kiwixmobile.core.reader
import android.webkit.WebResourceResponse
import org.kiwix.kiwixmobile.core.reader.ZimReader.Factory
import java.net.HttpURLConnection
import javax.inject.Inject
import javax.inject.Singleton
@ -43,12 +44,26 @@ class ZimReaderContainer @Inject constructor(private val zimFileReaderFactory: F
fun getRandomArticleUrl() = zimReader?.getRandomArticleUrl()
fun isRedirect(url: String): Boolean = zimReader?.isRedirect(url) == true
fun getRedirect(url: String): String = zimReader?.getRedirect(url) ?: ""
fun load(url: String) =
WebResourceResponse(
zimReader?.readMimeType(url),
Charsets.UTF_8.name(),
zimReader?.load(url)
)
fun load(url: String, requestHeaders: Map<String, String>): WebResourceResponse {
val data = zimReader?.load(url)
return WebResourceResponse(zimReader?.readMimeType(url), Charsets.UTF_8.name(), data)
.apply {
val headers = mutableMapOf("Accept-Ranges" to "bytes")
if ("Range" in requestHeaders.keys) {
setStatusCodeAndReasonPhrase(HttpURLConnection.HTTP_PARTIAL, "Partial Content")
val fullSize = data?.available()?.toLong() ?: 0L
val lastByte = fullSize - 1
val byteRanges = requestHeaders.getValue("Range").substringAfter("=").split("-")
headers["Content-Range"] = "bytes ${byteRanges[0]}-$lastByte/$fullSize"
if (byteRanges.size == 1) {
headers["Connection"] = "close"
}
} else {
setStatusCodeAndReasonPhrase(HttpURLConnection.HTTP_OK, "OK")
}
responseHeaders = headers
}
}
fun copyReader(): ZimReader? = zimSource?.let(zimFileReaderFactory::create)

View File

@ -77,6 +77,7 @@
<string name="delete_recent_search_item">حذف هذا العنصر؟</string>
<string name="pref_clear_all_history_title">إفراغ التاريخ</string>
<string name="pref_clear_all_history_summary">إفراغ عمليات البحث الحديثة وعلامات التبويب</string>
<string name="pref_notes">ملاحظات</string>
<string name="all_history_cleared">أُفرغ سجل التاريخ</string>
<string name="pref_clear_all_bookmarks_title">حذف الإشارات المرجعية</string>
<string name="clear_all_history_dialog_title">مسح كل التاريخ</string>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Authors:
* InsomniHat
* Kareyac
* ShockD
* StanProg
* Ted Masters
@ -48,6 +49,7 @@
<string name="delete_recent_search_item">Изтриване на този елемент?</string>
<string name="pref_clear_all_history_title">Изтрий история</string>
<string name="pref_clear_all_history_summary">Изтрийте последните търсения и история на табовете</string>
<string name="pref_notes">Бележки</string>
<string name="all_history_cleared">Историята е изтрита</string>
<string name="clear_all_history_dialog_title">Изтриване на цялата история?</string>
<string name="delete">Изтриване</string>

View File

@ -6,6 +6,7 @@
* FF11
* Killarnee
* Metalhead64
* Pittigrilli
* Stephane
* Susann Schweden
* Symposiarch
@ -74,6 +75,7 @@
<string name="delete_recent_search_item">Dieses Element löschen?</string>
<string name="pref_clear_all_history_title">Verlauf löschen</string>
<string name="pref_clear_all_history_summary">Letzte Suchanfragen und Registerkartenverlauf löschen</string>
<string name="pref_notes">Anmerkungen</string>
<string name="all_history_cleared">Gesamter Verlauf gelöscht</string>
<string name="pref_clear_all_bookmarks_title">Lesezeichen löschen</string>
<string name="clear_all_history_dialog_title">Gesamten Verlauf löschen?</string>

View File

@ -75,6 +75,7 @@
<string name="delete_recent_search_item">No item wa esterıyo?</string>
<string name="pref_clear_all_history_title">verore cı besterne</string>
<string name="pref_clear_all_history_summary">Cıgeyrayışê peyêni u Verocê tavaya bıesterne</string>
<string name="pref_notes">Noti</string>
<string name="all_history_cleared">Tarix pêro biyo pak</string>
<string name="pref_clear_all_bookmarks_title">Bookmarka pak kerê</string>
<string name="clear_all_history_dialog_title">Verori pêro wa pak kerê?</string>

View File

@ -4,6 +4,7 @@
* Geraki
* Giorgos456
* Glavkos
* NikosLikomitros
* Nikosgranturismogt
* Norhorn
-->
@ -68,6 +69,7 @@
<string name="delete_recent_search_item">Διαγραφή αυτού του αντικειμένου;</string>
<string name="pref_clear_all_history_title">Εκκαθάριση ιστορικού</string>
<string name="pref_clear_all_history_summary">Εκκαθάριση ιστορικού πρόσφατων αναζητήσεων και ετικετών</string>
<string name="pref_notes">Σημειώσεις</string>
<string name="all_history_cleared">Όλο το ιστορικό καθαρίστηκε</string>
<string name="clear_all_history_dialog_title" fuzzy="true">Εκκαθάριση όλου του ιστορικού</string>
<string name="delete">Διαγραφή</string>

View File

@ -3,6 +3,7 @@
* Abijeet Patro
* Blahma
* Fitoschido
* Javiero
* Kelson
* KuboF
* Mirin
@ -49,6 +50,7 @@
<string name="delete_recent_search_item">Forigi ĉi tiu eron?</string>
<string name="pref_clear_all_history_title">Forviŝi hisorion</string>
<string name="pref_clear_all_history_summary">Forviŝi ĵusajn serĉojn kaj historion de langetoj</string>
<string name="pref_notes">Notoj</string>
<string name="all_history_cleared">Forviŝis Ĉiun Historion</string>
<string name="clear_all_history_dialog_title" fuzzy="true">Forviŝi Ĉiun da Historio</string>
<string name="share">Diskonigi</string>

View File

@ -12,6 +12,7 @@
* MarcoAurelio
* Mpayansilva
* Ncr
* Rodney Araujo
* VegaDark
-->
<resources>
@ -76,6 +77,7 @@
<string name="delete_recent_search_item">¿Borrar este elemento?</string>
<string name="pref_clear_all_history_title">Limpiar el historial</string>
<string name="pref_clear_all_history_summary">Borrar las búsquedas recientes y el historial de pestañas</string>
<string name="pref_notes">Notas</string>
<string name="all_history_cleared">Borrado todo el historial</string>
<string name="pref_clear_all_bookmarks_title">Borrar marcadores</string>
<string name="clear_all_history_dialog_title">Borrar todo el historial?</string>

View File

@ -84,6 +84,7 @@
<string name="delete_recent_search_item">Supprimer cet élément?</string>
<string name="pref_clear_all_history_title">Effacer lhistorique</string>
<string name="pref_clear_all_history_summary">Effacer les recherches récentes et lhistorique des onglets</string>
<string name="pref_notes">Notes</string>
<string name="all_history_cleared">Tout lhistorique est effacé</string>
<string name="pref_clear_all_bookmarks_title">Supprimer les marque-pages</string>
<string name="clear_all_history_dialog_title">Effacer tout lhistorique ?</string>

View File

@ -50,6 +50,7 @@
<string name="clear_recent_and_tabs_history_dialog">Sei sicuro di voler cancellare la tua cronologia di ricerca e resettare tutte le tab attive?</string>
<string name="delete_recent_search_item">Elimina questo elemento?</string>
<string name="pref_clear_all_history_title">Cancella la cronologia</string>
<string name="pref_notes">Note</string>
<string name="all_history_cleared">Tutta la cronologia è stata cancellata</string>
<string name="clear_all_history_dialog_title">Cancellare tutta la cronologia?</string>
<string name="delete">Cancella</string>

View File

@ -9,6 +9,7 @@
* Tuvalevsku
* YaronSh
* יאיר מן
* ישראל קלר
-->
<resources>
<string name="menu_help">עזרה</string>
@ -77,6 +78,7 @@
<string name="delete_recent_search_item">למחוק את הפריט הזה?</string>
<string name="pref_clear_all_history_title">ניקוי ההיסטוריה</string>
<string name="pref_clear_all_history_summary">ניקוי מילות חיפוש קודמות והיסטוריית כרטיסיות</string>
<string name="pref_notes">הערות</string>
<string name="all_history_cleared">כל ההיסטוריה נמחקה</string>
<string name="pref_clear_all_bookmarks_title">ניקוי סימניות</string>
<string name="clear_all_history_dialog_title">לנקות את כל ההיסטוריה?</string>

View File

@ -52,7 +52,7 @@
<string name="server_started_message">Vê adresa IPyê di geroka xwe de binivîsîne ji bo ku xwe bigihînî servera %s</string>
<string name="error_file_not_found">Çewtîː Peldanka ZIM\'ê ya bijartî nehate dîtin.</string>
<string name="zim_not_opened">Nikare dosyeya zim-ê veke</string>
<string name="error_file_invalid">Çewtîː Peldanka bijartî ne peldankeke ZIM\'ê ya derbasdar e.</string>
<string name="error_file_invalid">Çewtîː Peldanka bijartî ne peldankeke ZIMê ya derbasdar e.</string>
<string name="error_article_url_not_found">Çewtîː Barkirina gotara (Url: %1$s) têk çû.</string>
<string name="pref_display_title">Nîşan bide</string>
<string name="pref_info_title">Agahî</string>
@ -73,6 +73,7 @@
<string name="delete_recent_search_item">Vê pelê jê bibe?</string>
<string name="pref_clear_all_history_title">Raboriyê paqij bike</string>
<string name="pref_clear_all_history_summary">Lêgerînên dawî û raboriya hilpekînan paqij bike</string>
<string name="pref_notes">Not</string>
<string name="all_history_cleared">Hemû Raborî Hat Paqijkirin</string>
<string name="pref_clear_all_bookmarks_title">Bijareyan paqij bike</string>
<string name="clear_all_history_dialog_title">Hemû Dîrokê Paqij Bike</string>

View File

@ -39,6 +39,7 @@
<string name="pref_language_chooser">Sicht eng Sprooch eraus</string>
<string name="pref_credits">Auteuren a Lizenzen</string>
<string name="delete_recent_search_item">Dëst Element läschen?</string>
<string name="pref_notes">Notizen</string>
<string name="pref_clear_all_bookmarks_title">Lieszeechen ewechhuelen</string>
<string name="delete">Läschen</string>
<string name="cancel">Ofbriechen</string>

View File

@ -70,6 +70,7 @@
<string name="delete_recent_search_item">Да ја избришам ставкава?</string>
<string name="pref_clear_all_history_title">Исчисти историја</string>
<string name="pref_clear_all_history_summary">Исчисти скорешни пребарувања и јазичиња</string>
<string name="pref_notes">Белешки</string>
<string name="all_history_cleared">Сета историја е исчистена</string>
<string name="pref_clear_all_bookmarks_title">Исчисти обележувачи</string>
<string name="clear_all_history_dialog_title">Да ја исчистам сета историја</string>

View File

@ -4,6 +4,7 @@
* Alan ffm
* DeRudySoulStorm
* InternerowyGołąb
* Kareyac
* Kelson
* Krzyz23
* Macofe
@ -79,6 +80,7 @@
<string name="delete_recent_search_item">Usunąć ten obiekt?</string>
<string name="pref_clear_all_history_title">Wyczyść historię</string>
<string name="pref_clear_all_history_summary">Wyczyść historię ostatnich wyszukiwań i kart</string>
<string name="pref_notes">Uwagi</string>
<string name="all_history_cleared">Usunięto całą historię</string>
<string name="pref_clear_all_bookmarks_title">Wyczyść zakładki</string>
<string name="clear_all_history_dialog_title">Wyczyść całą historię?</string>

View File

@ -76,6 +76,7 @@
<string name="delete_recent_search_item">Eliminar este item?</string>
<string name="pref_clear_all_history_title">Apagar histórico</string>
<string name="pref_clear_all_history_summary">Limpar pesquisas recentes e histórico de guias</string>
<string name="pref_notes">Notas</string>
<string name="all_history_cleared">Eliminando todo o histórico</string>
<string name="pref_clear_all_bookmarks_title">Limpar marcadores</string>
<string name="clear_all_history_dialog_title">Limpar todo o histórico?</string>

View File

@ -7,6 +7,7 @@
* Hamilton Abreu
* Imperadeiro90
* Imperadeiro98
* Kareyac
* Kelson
* Macofe
* Mansil alfalb
@ -53,6 +54,7 @@
<string name="delete_recent_search_item">Apagar este elemento?</string>
<string name="pref_clear_all_history_title">Limpar o histórico</string>
<string name="pref_clear_all_history_summary">Limpar as pesquisas recentes e o histórico de separadores</string>
<string name="pref_notes">Notas</string>
<string name="all_history_cleared">Todo o historial foi apagado</string>
<string name="clear_all_history_dialog_title" fuzzy="true">Apagar todo o historial</string>
<string name="delete">Apagar</string>

View File

@ -27,10 +27,9 @@
<string name="pref_info_title">{{Identical|Information}}</string>
<string name="pref_info_version">{{Identical|Version}}</string>
<string name="pref_back_to_top">{{Identical|Back to top}}</string>
<string name="history">{{Identical|History}}</string>
<string name="pref_notes">{{Identical|Notes}}</string>
<string name="pref_language_title">{{Identical|Language}}</string>
<string name="pref_language_chooser">{{Identical|Choose language}}</string>
<string name="pref_notes">{{Identical|Notes}}</string>
<string name="delete">{{Identical|Delete}}</string>
<string name="cancel">{{identical|Cancel}}</string>
<string name="undo">{{Identical|Undo}}</string>
@ -47,6 +46,7 @@
<string name="previous">{{Identical|Previous}}</string>
<string name="time_left">This is the past participle of the verb “to leave” (meaning “quitted” or “exited”). This is used in a context of “X minutes left” to finish a download.</string>
<string name="time_yesterday">{{Identical|Yesterday}}</string>
<string name="history">{{Identical|History}}</string>
<string name="search_history">TODO: Unclear, must be documented. See https://github.com/kiwix/overview/issues/31</string>
<string name="save">{{Identical|Save}}</string>
<string name="permission_rationale_location_on_host_zim_file">Tell the user Location permission required for hosting zim file.</string>

View File

@ -156,7 +156,7 @@
<string name="table_of_contents">Kazalo vsebine</string>
<string name="select_languages">Izberi jezike</string>
<string name="save_languages">Shrani jezike</string>
<string name="send_feedback">Sporoči svoje mnenje</string>
<string name="send_feedback">Sporočite svoje mnenje</string>
<string name="expand">Razširi</string>
<string name="history">Zgodovina</string>
<string name="history_from_current_book" fuzzy="true">Zgodovina iz trenutne knjige</string>

View File

@ -75,6 +75,7 @@
<string name="delete_recent_search_item">Radera detta objekt?</string>
<string name="pref_clear_all_history_title">Rensa historik</string>
<string name="pref_clear_all_history_summary">Rensa senaste sökningar och flikhistorik</string>
<string name="pref_notes">Anteckningar</string>
<string name="all_history_cleared">All historik rensades</string>
<string name="pref_clear_all_bookmarks_title">Rensa bokmärken</string>
<string name="clear_all_history_dialog_title">Rensa all historik?</string>

View File

@ -83,6 +83,7 @@
<string name="delete_recent_search_item">Bu öğe silinsin mi?</string>
<string name="pref_clear_all_history_title">Geçmişi temizle</string>
<string name="pref_clear_all_history_summary">Son aramalar ve sekmeler geçmişini temizle</string>
<string name="pref_notes">Notlar</string>
<string name="all_history_cleared">Tüm geçmiş temizlendi</string>
<string name="pref_clear_all_bookmarks_title">Yer imlerini temizle</string>
<string name="clear_all_history_dialog_title">Tüm Geçmişi Silinsin mi?</string>

View File

@ -75,6 +75,7 @@
<string name="delete_recent_search_item">刪除此項目?</string>
<string name="pref_clear_all_history_title">清除歷史記錄</string>
<string name="pref_clear_all_history_summary">清除近期搜尋和分頁歷史記錄</string>
<string name="pref_notes">備註</string>
<string name="all_history_cleared">所有歷史記錄已清除</string>
<string name="pref_clear_all_bookmarks_title">清除書籤</string>
<string name="clear_all_history_dialog_title">清除所有歷史記錄?</string>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
~
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/alabaster_white" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
</layer-list>

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -21,11 +20,9 @@
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/mine_shaft_gray900" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
~
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/alabaster_white" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
</layer-list>

View File

@ -21,11 +21,9 @@
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/alabaster_white" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>