Merge remote-tracking branch 'origin/develop' into release/3.4.1

This commit is contained in:
Sean Mac Gillicuddy 2020-10-14 10:18:45 +01:00
commit 4c529ecb6b
17 changed files with 101 additions and 19 deletions

View File

@ -38,11 +38,9 @@ class KiwixMockServer {
mockWebServer.shutdown() mockWebServer.shutdown()
} }
fun map( fun map(vararg pathsToResponses: Pair<String, Any>) {
vararg pathsToResponses: Pair<String, Any>
) {
val mapOfPathsToResponses = mapOf(*pathsToResponses) val mapOfPathsToResponses = mapOf(*pathsToResponses)
mockWebServer.setDispatcher(object : Dispatcher() { mockWebServer.dispatcher = object : Dispatcher() {
override fun dispatch(request: RecordedRequest) = override fun dispatch(request: RecordedRequest) =
mapOfPathsToResponses[request.path]?.let(::successfulResponse) mapOfPathsToResponses[request.path]?.let(::successfulResponse)
?: forcedResponse?.let { return@let it } ?: forcedResponse?.let { return@let it }
@ -50,7 +48,7 @@ class KiwixMockServer {
"No response mapped for ${request.path}" + "No response mapped for ${request.path}" +
"\nmapped $mapOfPathsToResponses\nqueued $forcedResponse" "\nmapped $mapOfPathsToResponses\nqueued $forcedResponse"
) )
}) }
} }
private fun successfulResponse(bodyObject: Any) = MockResponse().apply { private fun successfulResponse(bodyObject: Any) = MockResponse().apply {

View File

@ -18,11 +18,14 @@
package org.kiwix.kiwixmobile.webserver package org.kiwix.kiwixmobile.webserver
import android.Manifest
import android.app.ProgressDialog import android.app.ProgressDialog
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.provider.Settings import android.provider.Settings
@ -32,6 +35,8 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import kotlinx.android.synthetic.main.activity_zim_host.recyclerViewZimHost import kotlinx.android.synthetic.main.activity_zim_host.recyclerViewZimHost
import kotlinx.android.synthetic.main.activity_zim_host.serverTextView import kotlinx.android.synthetic.main.activity_zim_host.serverTextView
import kotlinx.android.synthetic.main.activity_zim_host.startServerButton import kotlinx.android.synthetic.main.activity_zim_host.startServerButton
@ -132,7 +137,54 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
} }
} }
startServerButton.setOnClickListener { startStopServer() } startServerButton.setOnClickListener {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P || checkCoarseLocationAccessPermission()) {
startStopServer()
}
}
}
private fun checkCoarseLocationAccessPermission(): Boolean =
if (ContextCompat.checkSelfPermission(
requireActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION
) == PackageManager.PERMISSION_DENIED
) {
if (ActivityCompat.shouldShowRequestPermissionRationale(
requireActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION
)
) {
alertDialogShower.show(
KiwixDialog.LocationPermissionRationaleOnHostZimFile,
::askCoarseLocationPermission
)
} else {
askCoarseLocationPermission()
}
false
} else {
true
}
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (requestCode == PERMISSION_REQUEST_CODE_COARSE_LOCATION) {
startStopServer()
}
}
}
private fun askCoarseLocationPermission() {
ActivityCompat.requestPermissions(
requireActivity(), arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION),
PERMISSION_REQUEST_CODE_COARSE_LOCATION
)
} }
private fun startStopServer() { private fun startStopServer() {
@ -316,5 +368,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
companion object { companion object {
const val SELECTED_ZIM_PATHS_KEY = "selected_zim_paths" const val SELECTED_ZIM_PATHS_KEY = "selected_zim_paths"
private const val PERMISSION_REQUEST_CODE_COARSE_LOCATION = 10
} }
} }

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Authors:
* Al Riaz Uddin Ripon
-->
<resources>
<string name="send_files_title">ফাইলসমূহ পাঠান</string>
<string name="receive_files_title">ফাইলসমূহ গ্রহণ করুন</string>
</resources>

View File

@ -16,9 +16,9 @@ object Versions {
const val androidx_test_espresso: String = "3.2.0" // available: "3.3.0" const val androidx_test_espresso: String = "3.2.0" // available: "3.3.0"
const val com_squareup_retrofit2: String = "2.5.0" // available: "2.9.0" const val com_squareup_retrofit2: String = "2.9.0"
const val com_squareup_okhttp3: String = "3.6.0" // available: "4.9.0" const val com_squareup_okhttp3: String = "4.9.0"
const val org_jetbrains_kotlin: String = "1.3.72" // available: "1.4.10" const val org_jetbrains_kotlin: String = "1.3.72" // available: "1.4.10"
@ -36,11 +36,11 @@ object Versions {
const val org_jacoco: String = "0.7.9" const val org_jacoco: String = "0.7.9"
const val io_mockk: String = "1.10.0" const val io_mockk: String = "1.10.0" // available: "1.10.2"
const val android_arch_lifecycle_extensions: String = "1.1.1" const val android_arch_lifecycle_extensions: String = "1.1.1"
const val com_android_tools_build_gradle: String = "4.0.1" const val com_android_tools_build_gradle: String = "4.0.1" // available: "4.0.2"
const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0" const val de_fayard_buildsrcversions_gradle_plugin: String = "0.7.0"
@ -50,9 +50,9 @@ object Versions {
const val ink_page_indicator: String = "1.3.0" const val ink_page_indicator: String = "1.3.0"
const val leakcanary_android: String = "2.4" const val leakcanary_android: String = "2.4" // available: "2.5"
const val constraintlayout: String = "1.1.3" // available: "2.0.1" const val constraintlayout: String = "1.1.3" // available: "2.0.2"
const val collection_ktx: String = "1.1.0" const val collection_ktx: String = "1.1.0"
@ -60,7 +60,7 @@ object Versions {
const val junit_jupiter: String = "5.6.2" // available: "5.7.0" const val junit_jupiter: String = "5.6.2" // available: "5.7.0"
const val xfetch2okhttp: String = "3.1.4" // available: "3.1.5" const val xfetch2okhttp: String = "3.1.5"
const val assertj_core: String = "3.16.1" // available: "3.17.2" const val assertj_core: String = "3.16.1" // available: "3.17.2"
@ -68,7 +68,7 @@ object Versions {
const val fragment_ktx: String = "1.2.5" const val fragment_ktx: String = "1.2.5"
const val lint_gradle: String = "27.0.1" const val lint_gradle: String = "27.0.1" // available: "27.0.2"
const val testing_ktx: String = "1.1.2" const val testing_ktx: String = "1.1.2"
@ -84,7 +84,7 @@ object Versions {
const val rxandroid: String = "2.1.1" const val rxandroid: String = "2.1.1"
const val core_ktx: String = "1.3.1" const val core_ktx: String = "1.3.1" // available: "1.3.2"
const val kiwixlib: String = "9.4.0" const val kiwixlib: String = "9.4.0"
@ -92,19 +92,19 @@ object Versions {
const val multidex: String = "2.0.1" const val multidex: String = "2.0.1"
const val barista: String = "2.7.1" // available: "3.6.0" const val barista: String = "2.7.1" // available: "3.7.0"
const val xfetch2: String = "3.1.4" // available: "3.1.5" const val xfetch2: String = "3.1.5"
const val jsr305: String = "3.0.2" const val jsr305: String = "3.0.2"
const val ktlint: String = "0.36.0" // available: "0.39.0" const val ktlint: String = "0.36.0" // available: "0.39.0"
const val rxjava: String = "2.2.19" const val rxjava: String = "2.2.19" // available: "2.2.20"
const val webkit: String = "1.2.0" // available: "1.3.0" const val webkit: String = "1.2.0" // available: "1.3.0"
const val aapt2: String = "4.0.1-6197926" const val aapt2: String = "4.0.1-6197926" // available: "4.0.2-6197926"
const val junit: String = "1.1.1" // available: "1.1.2" const val junit: String = "1.1.1" // available: "1.1.2"

View File

@ -716,6 +716,7 @@ public abstract class CoreReaderFragment extends BaseFragment
actionBar = null; actionBar = null;
mainMenu = null; mainMenu = null;
tabRecyclerView.setAdapter(null); tabRecyclerView.setAdapter(null);
tableDrawerRight.setAdapter(null);
tableDrawerAdapter = null; tableDrawerAdapter = null;
unbinder.unbind(); unbinder.unbind();
webViewList.clear(); webViewList.clear();

View File

@ -47,6 +47,13 @@ sealed class KiwixDialog(
android.R.string.cancel android.R.string.cancel
) )
object LocationPermissionRationaleOnHostZimFile : KiwixDialog(
null,
R.string.permission_rationale_location_on_host_zim_file,
android.R.string.yes,
android.R.string.cancel
)
object StoragePermissionRationale : KiwixDialog( object StoragePermissionRationale : KiwixDialog(
null, null,
R.string.request_storage, R.string.request_storage,

View File

@ -25,6 +25,7 @@
<string name="search_label">অনুসন্ধান</string> <string name="search_label">অনুসন্ধান</string>
<string name="choose_file">একটি বিষয়বস্তুর ফাইল নির্বাচন করুন (*.zim)</string> <string name="choose_file">একটি বিষয়বস্তুর ফাইল নির্বাচন করুন (*.zim)</string>
<string name="open_in_new_tab">নতুন ট্যাবে লিঙ্ক খোলা হবে?</string> <string name="open_in_new_tab">নতুন ট্যাবে লিঙ্ক খোলা হবে?</string>
<string name="connection_refused">সংযোগ প্রত্যাখান করা হয়েছে।</string>
<string name="error_file_not_found">ত্রুটি: নির্বাচিত ZIM ফাইলটি খুঁজে পাওয়া যায় নি।</string> <string name="error_file_not_found">ত্রুটি: নির্বাচিত ZIM ফাইলটি খুঁজে পাওয়া যায় নি।</string>
<string name="error_file_invalid">ত্রুটি: নির্বাচিত ফাইলটি বৈধ ZIM ফাইল নয়।</string> <string name="error_file_invalid">ত্রুটি: নির্বাচিত ফাইলটি বৈধ ZIM ফাইল নয়।</string>
<string name="error_article_url_not_found">ত্রুটি: নিবন্ধ লোডে (Url: %1$s) ব্যর্থ।</string> <string name="error_article_url_not_found">ত্রুটি: নিবন্ধ লোডে (Url: %1$s) ব্যর্থ।</string>

View File

@ -40,6 +40,7 @@
<string name="hotspot_failed_title">Échec de démarrage du point daccès</string> <string name="hotspot_failed_title">Échec de démarrage du point daccès</string>
<string name="hotspot_failed_message">il semble que votre point daccès soit déjà activé. Veuillez dabord désactiver votre point daccès WiFi pour continuer.</string> <string name="hotspot_failed_message">il semble que votre point daccès soit déjà activé. Veuillez dabord désactiver votre point daccès WiFi pour continuer.</string>
<string name="go_to_wifi_settings_label">Aller aux paramètres WiFi</string> <string name="go_to_wifi_settings_label">Aller aux paramètres WiFi</string>
<string name="connection_refused">Connexion refusée.</string>
<string name="hotspot_running">Point daccès WiFi actif</string> <string name="hotspot_running">Point daccès WiFi actif</string>
<string name="no_books_selected_toast_message">Veuillez dabord choisir les livres</string> <string name="no_books_selected_toast_message">Veuillez dabord choisir les livres</string>
<string name="server_failed_message">Impossible de démarrer le serveur. Veuillez activer votre point daccès WiFi</string> <string name="server_failed_message">Impossible de démarrer le serveur. Veuillez activer votre point daccès WiFi</string>

View File

@ -6,6 +6,7 @@
* Csega * Csega
* Dj * Dj
* Fitoschido * Fitoschido
* Hanna Tardos
* Kelson * Kelson
* Macofe * Macofe
* Tacsipacsi * Tacsipacsi
@ -28,6 +29,7 @@
<string name="search_label">Keresés</string> <string name="search_label">Keresés</string>
<string name="choose_file">Tartalomfájl kiválasztása (*.zim)</string> <string name="choose_file">Tartalomfájl kiválasztása (*.zim)</string>
<string name="open_in_new_tab">Hivatkozás megnyitása új lapon?</string> <string name="open_in_new_tab">Hivatkozás megnyitása új lapon?</string>
<string name="connection_refused">Csatlakozás elutasítva.</string>
<string name="error_file_not_found">Hiba: A kijelölt ZIM-fájl nem található.</string> <string name="error_file_not_found">Hiba: A kijelölt ZIM-fájl nem található.</string>
<string name="error_file_invalid">Hiba: A kijelölt fájl nem érvényes ZIM-fájl.</string> <string name="error_file_invalid">Hiba: A kijelölt fájl nem érvényes ZIM-fájl.</string>
<string name="error_article_url_not_found">Hiba: A cikk (URL: %1$s) betöltése nem sikerült.</string> <string name="error_article_url_not_found">Hiba: A cikk (URL: %1$s) betöltése nem sikerült.</string>

View File

@ -6,6 +6,7 @@
* G.garatti * G.garatti
* Gianfranco * Gianfranco
* Matteocng * Matteocng
* Mpayansilva
* Nivit * Nivit
* Purodha * Purodha
--> -->
@ -26,6 +27,7 @@
<string name="search_label">Ricerca</string> <string name="search_label">Ricerca</string>
<string name="choose_file">Seleziona un file di contenuto (*.zim)</string> <string name="choose_file">Seleziona un file di contenuto (*.zim)</string>
<string name="open_in_new_tab">Apri il collegamento in una nuova scheda?</string> <string name="open_in_new_tab">Apri il collegamento in una nuova scheda?</string>
<string name="connection_refused">Collegamento negato.</string>
<string name="hotspot_dialog_title">Istruzioni per ospitare libri</string> <string name="hotspot_dialog_title">Istruzioni per ospitare libri</string>
<string name="hotspot_dialog_neutral_button">PROCEDI</string> <string name="hotspot_dialog_neutral_button">PROCEDI</string>
<string name="error_file_not_found">Errore: il file ZIM selezionato non è stato trovato.</string> <string name="error_file_not_found">Errore: il file ZIM selezionato non è stato trovato.</string>

View File

@ -33,6 +33,7 @@
<string name="hotspot_failed_title">הפעלת נקודת חיבור לא עבדה</string> <string name="hotspot_failed_title">הפעלת נקודת חיבור לא עבדה</string>
<string name="hotspot_failed_message">נראה שנקודת החיבור כבר מופעלת אצלך. נא לכבות את נקודת החיבור שלך כדי להמשיך.</string> <string name="hotspot_failed_message">נראה שנקודת החיבור כבר מופעלת אצלך. נא לכבות את נקודת החיבור שלך כדי להמשיך.</string>
<string name="go_to_wifi_settings_label">לעבור להגדרות וייפיי</string> <string name="go_to_wifi_settings_label">לעבור להגדרות וייפיי</string>
<string name="connection_refused">החיבור סורב.</string>
<string name="hotspot_running">נקודת החיבור פועלת</string> <string name="hotspot_running">נקודת החיבור פועלת</string>
<string name="no_books_selected_toast_message">נא לבחור ספרים קודם</string> <string name="no_books_selected_toast_message">נא לבחור ספרים קודם</string>
<string name="server_failed_message">לא היה אפשר להתחיל את השרת. נא להפעיל את נקודת החיבור שלך</string> <string name="server_failed_message">לא היה אפשר להתחיל את השרת. נא להפעיל את נקודת החיבור שלך</string>

View File

@ -26,6 +26,7 @@
<string name="hotspot_failed_title">Не успеав да ја покренам пристапната точка</string> <string name="hotspot_failed_title">Не успеав да ја покренам пристапната точка</string>
<string name="hotspot_failed_message">Се чини дека точката за безжичен пристап е веќе вклучена. Исклучете ја за да продолжите.</string> <string name="hotspot_failed_message">Се чини дека точката за безжичен пристап е веќе вклучена. Исклучете ја за да продолжите.</string>
<string name="go_to_wifi_settings_label">Оди во поставките за безжичен пристап</string> <string name="go_to_wifi_settings_label">Оди во поставките за безжичен пристап</string>
<string name="connection_refused">Поврзувањето е одбиено.</string>
<string name="hotspot_running">Активна пристапна точка</string> <string name="hotspot_running">Активна пристапна точка</string>
<string name="no_books_selected_toast_message">Најпрвин одберете книги</string> <string name="no_books_selected_toast_message">Најпрвин одберете книги</string>
<string name="server_failed_message">Не можев да го покренам опслужувачот. Вклучете ја пристапната точка</string> <string name="server_failed_message">Не можев да го покренам опслужувачот. Вклучете ја пристапната точка</string>

View File

@ -32,6 +32,7 @@
<string name="hotspot_failed_title">Falha ao iniciar o ponto de acesso</string> <string name="hotspot_failed_title">Falha ao iniciar o ponto de acesso</string>
<string name="hotspot_failed_message">Parece que seu ponto de acesso já está ativado. Desative seu ponto de acesso wi-fi para continuar.</string> <string name="hotspot_failed_message">Parece que seu ponto de acesso já está ativado. Desative seu ponto de acesso wi-fi para continuar.</string>
<string name="go_to_wifi_settings_label">Vá para configurações de wi-fi</string> <string name="go_to_wifi_settings_label">Vá para configurações de wi-fi</string>
<string name="connection_refused">Conexão recusada.</string>
<string name="hotspot_running">Rede wi-fi em execução</string> <string name="hotspot_running">Rede wi-fi em execução</string>
<string name="no_books_selected_toast_message">Selecione primeiro os livros</string> <string name="no_books_selected_toast_message">Selecione primeiro os livros</string>
<string name="server_failed_message">Não foi possível iniciar o servidor. Por favor, ligue seu ponto de acesso</string> <string name="server_failed_message">Não foi possível iniciar o servidor. Por favor, ligue seu ponto de acesso</string>
@ -280,4 +281,6 @@
<string name="tab_restored">Guia restaurada</string> <string name="tab_restored">Guia restaurada</string>
<string name="open_drawer">Abrir gaveta</string> <string name="open_drawer">Abrir gaveta</string>
<string name="close_drawer">Fechar gaveta</string> <string name="close_drawer">Fechar gaveta</string>
<string name="how_to_update_content">Como atualizar o conteúdo?</string>
<string name="update_content_description">Para atualizar o conteúdo (um arquivo zim), você precisa baixar a versão completa mais recente desse mesmo conteúdo. Você pode fazer isso através da seção de download.</string>
</resources> </resources>

View File

@ -61,4 +61,5 @@
<string name="no_open_book">Tell the user that they have not opened a book.</string> <string name="no_open_book">Tell the user that they have not opened a book.</string>
<string name="open_library">The action of opening the library destination, used on a button.</string> <string name="open_library">The action of opening the library destination, used on a button.</string>
<string name="tab_restored">Tell the user that a tab has been restored.</string> <string name="tab_restored">Tell the user that a tab has been restored.</string>
<string name="permission_rationale_location_on_host_zim_file">Tell the user Location permission required for hosting zim file.</string>
</resources> </resources>

View File

@ -31,6 +31,7 @@
<string name="hotspot_failed_title">開啟熱點失敗</string> <string name="hotspot_failed_title">開啟熱點失敗</string>
<string name="hotspot_failed_message">看起來似乎是您的熱點已開啟,請停用您的 WiFi 熱點來繼續。</string> <string name="hotspot_failed_message">看起來似乎是您的熱點已開啟,請停用您的 WiFi 熱點來繼續。</string>
<string name="go_to_wifi_settings_label">前往 WIFI 設定</string> <string name="go_to_wifi_settings_label">前往 WIFI 設定</string>
<string name="connection_refused">連線被拒絕。</string>
<string name="hotspot_running">運行熱點</string> <string name="hotspot_running">運行熱點</string>
<string name="no_books_selected_toast_message">請先選擇書籍</string> <string name="no_books_selected_toast_message">請先選擇書籍</string>
<string name="server_failed_message">無法開啟伺服器,請啟動您的熱點</string> <string name="server_failed_message">無法開啟伺服器,請啟動您的熱點</string>

View File

@ -38,6 +38,7 @@
<string name="hotspot_failed_title">未能启动热点</string> <string name="hotspot_failed_title">未能启动热点</string>
<string name="hotspot_failed_message">你的热点好像已经打开了。请先关闭 Wi-Fi 热点再继续。</string> <string name="hotspot_failed_message">你的热点好像已经打开了。请先关闭 Wi-Fi 热点再继续。</string>
<string name="go_to_wifi_settings_label">转到WIFI设置</string> <string name="go_to_wifi_settings_label">转到WIFI设置</string>
<string name="connection_refused">拒绝连接</string>
<string name="hotspot_running">运行热点</string> <string name="hotspot_running">运行热点</string>
<string name="no_books_selected_toast_message">请先选择书籍</string> <string name="no_books_selected_toast_message">请先选择书籍</string>
<string name="server_failed_message">未能启动服务器。请打开热点。</string> <string name="server_failed_message">未能启动服务器。请打开热点。</string>

View File

@ -230,6 +230,7 @@
<string name="severe_loss_error" tools:keep="@string/severe_loss_error">Severe error! Try Disable/Re-enable WiFi P2P</string> <string name="severe_loss_error" tools:keep="@string/severe_loss_error">Severe error! Try Disable/Re-enable WiFi P2P</string>
<string name="connection_failed" tools:keep="@string/connection_failed">Connection failed</string> <string name="connection_failed" tools:keep="@string/connection_failed">Connection failed</string>
<string name="permission_rationale_location">Location permission is required by Android to allow the app to detect peer devices</string> <string name="permission_rationale_location">Location permission is required by Android to allow the app to detect peer devices</string>
<string name="permission_rationale_location_on_host_zim_file">Location permission is required by Android to allow the app to Host Zim files</string>
<string name="permission_refused_location" tools:keep="@string/permission_refused_location">Cannot locate peer devices without location permissions</string> <string name="permission_refused_location" tools:keep="@string/permission_refused_location">Cannot locate peer devices without location permissions</string>
<string name="permission_refused_storage" tools:keep="@string/permission_refused_storage">Cannot access zim files without storage permission</string> <string name="permission_refused_storage" tools:keep="@string/permission_refused_storage">Cannot access zim files without storage permission</string>
<string name="request_enable_location">Enable location to allow detection of peers</string> <string name="request_enable_location">Enable location to allow detection of peers</string>