From 996a630d63be29ea2cdfe60ef3a3dd786b75e2a6 Mon Sep 17 00:00:00 2001
From: Rutvik Rajendra Panchal
<39809059+rutvik-panchal@users.noreply.github.com>
Date: Wed, 25 Nov 2020 17:55:55 +0530
Subject: [PATCH 01/34] redesign: Fixed UI for no content messages displayed
---
.../layout/fragment_destination_download.xml | 13 ++++++------
.../layout/fragment_destination_library.xml | 20 ++++++++++---------
app/src/main/res/values/dimens.xml | 1 +
app/src/main/res/values/styles.xml | 10 ----------
core/src/main/res/layout/fragment_reader.xml | 17 ++++++++--------
core/src/main/res/layout/fragment_search.xml | 17 +++++++---------
core/src/main/res/values/dimens.xml | 2 ++
core/src/main/res/values/styles.xml | 8 +++++++-
8 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/app/src/main/res/layout/fragment_destination_download.xml b/app/src/main/res/layout/fragment_destination_download.xml
index fbe9dd6f7..5e5958598 100644
--- a/app/src/main/res/layout/fragment_destination_download.xml
+++ b/app/src/main/res/layout/fragment_destination_download.xml
@@ -18,9 +18,9 @@
+ android:layout_height="match_parent">
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ tools:listitem="@layout/item_download" />
@@ -56,11 +56,12 @@
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.45" />
diff --git a/app/src/main/res/layout/fragment_destination_library.xml b/app/src/main/res/layout/fragment_destination_library.xml
index b140a7e99..4cb7694fc 100644
--- a/app/src/main/res/layout/fragment_destination_library.xml
+++ b/app/src/main/res/layout/fragment_destination_library.xml
@@ -19,9 +19,10 @@
+ android:fitsSystemWindows="true">
+ android:layout_height="match_parent"
+ tools:listitem="@layout/item_book" />
-
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.45" />
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 8cf95327d..6ceecc158 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -25,5 +25,6 @@
8dp
8dp
8dp
+ 48dp
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 3860dc96a..ff4e1576d 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -18,14 +18,4 @@
-
diff --git a/core/src/main/res/layout/fragment_reader.xml b/core/src/main/res/layout/fragment_reader.xml
index 2729270f9..703248209 100644
--- a/core/src/main/res/layout/fragment_reader.xml
+++ b/core/src/main/res/layout/fragment_reader.xml
@@ -31,26 +31,25 @@
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintVertical_bias="0.45" />
+ app:layout_constraintEnd_toEndOf="@+id/no_open_book_text"
+ app:layout_constraintStart_toStartOf="@+id/no_open_book_text"
+ app:layout_constraintTop_toBottomOf="@id/no_open_book_text"/>
@@ -14,28 +14,25 @@
+ android:layout_height="match_parent"
+ tools:listitem="@layout/list_item_search" />
+ android:layout_gravity="center"
+ android:visibility="gone"
+ tools:visibility="visible" />
diff --git a/core/src/main/res/values/dimens.xml b/core/src/main/res/values/dimens.xml
index d136e4c81..b81eed089 100644
--- a/core/src/main/res/values/dimens.xml
+++ b/core/src/main/res/values/dimens.xml
@@ -18,4 +18,6 @@
56dp
5dp
25dp
+
+ 48dp
diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml
index 60df19b1f..1508f90b2 100644
--- a/core/src/main/res/values/styles.xml
+++ b/core/src/main/res/values/styles.xml
@@ -62,7 +62,6 @@
- end
-
+
+
From 1202e4403d676155183c85f77abfe81acb2c89af Mon Sep 17 00:00:00 2001
From: "translatewiki.net"
Date: Mon, 30 Nov 2020 17:05:58 +0100
Subject: [PATCH 02/34] Localisation updates from https://translatewiki.net.
---
core/src/main/res/values-ar/strings.xml | 2 ++
core/src/main/res/values-ku/strings.xml | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ar/strings.xml b/core/src/main/res/values-ar/strings.xml
index 9ae8c7488..bcd755c75 100644
--- a/core/src/main/res/values-ar/strings.xml
+++ b/core/src/main/res/values-ar/strings.xml
@@ -33,6 +33,7 @@
فشل بدء الهوت-سبوت
يبدو أن الهوت-سبوت مفعلٌ بالفعل. يرجى تعطيل هوت-سبوت الواي فاي للمتابعة.
انتقل إلى إعدادات الواي فاي
+ الاتصال مرفوض.
تشغيل الهوت-سبوت
يُرجى اختيار الكتب أولًا
لا يمكن بدء الخادم. يُرجى تشغيل الهوت-سبوت الخاص بك
@@ -227,6 +228,7 @@
خطأ شديد! حاول تعطيل/إعادة تمكين الواي فاي P2P
فشل الاتصال
مطلوب إذن للموقع بواسطة أندرويد للسماح للتطبيق باكتشاف الأجهزة المقترنة
+ مطلوب إذن للموقع بواسطة أندرويد للسماح للتطبيق باكتشاف ملفات زيم (Zim) المستضافة
لا يمكن تحديد موقع الأجهزة المقترنة دون أذونات الموقع
لا يمكن الوصول إلى ملفات زيم (ZIM) دون إذن وحدة تخزين
تمكين الموقع للسماح باكتشاف الأجهزة المقترنة
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index d48301e3e..68d1950cf 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -247,7 +247,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From 3d1a3237584a82c9220ef09b8a742c815c1826ff Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 1 Dec 2020 10:12:56 +0000
Subject: [PATCH 03/34] lint fix
---
core/src/main/res/values-ku/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index 68d1950cf..d48301e3e 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -247,7 +247,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From 6d008e45ee6c520ab50485a5c84ca1dfda190a48 Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 1 Dec 2020 10:54:12 +0000
Subject: [PATCH 04/34] #2530 Remove activity finishing from IntroFragment and
rely on default behaviour - use pops to make intro the only destination on
the stack
---
.../org/kiwix/kiwixmobile/intro/IntroFragment.kt | 10 ++--------
.../org/kiwix/kiwixmobile/main/KiwixMainActivity.kt | 3 ++-
app/src/main/res/navigation/kiwix_nav_graph.xml | 13 ++++++++++++-
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/intro/IntroFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/intro/IntroFragment.kt
index 861c17fc3..bce427ab1 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/intro/IntroFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/intro/IntroFragment.kt
@@ -23,8 +23,8 @@ import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
+import androidx.navigation.fragment.findNavController
import androidx.viewpager.widget.ViewPager
import kotlinx.android.synthetic.main.fragment_intro.get_started
import kotlinx.android.synthetic.main.fragment_intro.tab_indicator
@@ -35,7 +35,6 @@ import org.kiwix.kiwixmobile.cachedComponent
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.BaseFragment
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
-import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.zim_manager.SimplePageChangeListener
import java.util.Timer
import java.util.TimerTask
@@ -103,15 +102,10 @@ class IntroFragment : BaseFragment(), IntroContract.View, FragmentActivityExtens
views = emptyArray()
}
- override fun onBackPressed(activity: AppCompatActivity): FragmentActivityExtensions.Super {
- activity.finish()
- return super.onBackPressed(activity)
- }
-
private fun navigateToLibrary() {
dismissAutoRotate()
presenter.setIntroShown()
- (requireActivity() as KiwixMainActivity).navController.popBackStack()
+ findNavController().navigate(IntroFragmentDirections.actionIntrofragmentToLibraryFragment())
}
private fun updateView(position: Int) {
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
index 974851185..58e78da20 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt
@@ -38,6 +38,7 @@ import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
import org.kiwix.kiwixmobile.core.di.components.CoreComponent
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
+import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragmentDirections
const val NAVIGATE_TO_ZIM_HOST_FRAGMENT = "navigate_to_zim_host_fragment"
@@ -94,7 +95,7 @@ class KiwixMainActivity : CoreMainActivity() {
}
}
if (sharedPreferenceUtil.showIntro()) {
- navigate(R.id.introFragment)
+ navigate(LocalLibraryFragmentDirections.actionLibraryFragmentToIntrofragment())
}
}
diff --git a/app/src/main/res/navigation/kiwix_nav_graph.xml b/app/src/main/res/navigation/kiwix_nav_graph.xml
index 18bf190b1..e51ca0ef7 100644
--- a/app/src/main/res/navigation/kiwix_nav_graph.xml
+++ b/app/src/main/res/navigation/kiwix_nav_graph.xml
@@ -69,6 +69,11 @@
+
+ tools:layout="@layout/fragment_intro">
+
+
Date: Wed, 2 Dec 2020 14:49:12 +0530
Subject: [PATCH 05/34] Handled navigate up from toolbar in bookmarks and
history screens
---
.../main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt
index 66bf9c984..0b5a8aaee 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/page/PageFragment.kt
@@ -121,6 +121,7 @@ abstract class PageFragment : OnItemClickListener, BaseFragment(), FragmentActiv
recycler_view.layoutManager = LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
recycler_view.adapter = pageAdapter
activity.setSupportActionBar(toolbar)
+ toolbar.setNavigationOnClickListener { requireActivity().onBackPressed() }
activity.supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
title = screenTitle
From 829fb235828361e3dfbf0469060655656add14d1 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Thu, 3 Dec 2020 03:46:02 +0530
Subject: [PATCH 06/34] Close #2447 Only selected books are appearing in
browser
---
.../java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
index 1cc344973..a21714763 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
@@ -139,6 +139,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
startServerButton.setOnClickListener {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P || checkCoarseLocationAccessPermission()) {
+ bindService()
startStopServer()
}
}
@@ -211,6 +212,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
}
private fun stopServer() {
+ unbindService()
requireActivity().startService(createHotspotIntent(ACTION_STOP_SERVER))
}
From 1191cf0750053f642596b8481ae045acd8bc9d1d Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Thu, 3 Dec 2020 16:51:18 +0530
Subject: [PATCH 07/34] '#2535 Removed hardcoded strings from prefs screen
---
core/src/main/res/values-qq/strings.xml | 2 ++
core/src/main/res/values/strings.xml | 1 +
core/src/main/res/xml/preferences.xml | 4 ++--
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/core/src/main/res/values-qq/strings.xml b/core/src/main/res/values-qq/strings.xml
index 5d377f92d..22b31846d 100644
--- a/core/src/main/res/values-qq/strings.xml
+++ b/core/src/main/res/values-qq/strings.xml
@@ -27,6 +27,8 @@
{{Identical|Information}}
{{Identical|Version}}
{{Identical|Back to top}}
+ {{Identical|History}}
+ {{Identical|Notes}}
{{Identical|Language}}
{{Identical|Choose language}}
{{Identical|Delete}}
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 4895cfda0..fe2ef8176 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -66,6 +66,7 @@
Delete this item?
Clear history
Clear recent searches and tabs history
+ Notes
All History Cleared
Clear bookmarks
Clear All History?
diff --git a/core/src/main/res/xml/preferences.xml b/core/src/main/res/xml/preferences.xml
index 4cd555c32..e8e0c52cb 100644
--- a/core/src/main/res/xml/preferences.xml
+++ b/core/src/main/res/xml/preferences.xml
@@ -74,7 +74,7 @@
Date: Fri, 4 Dec 2020 13:47:54 +0530
Subject: [PATCH 08/34] Used factory for creating library
---
.../kiwixmobile/di/modules/ServiceModule.kt | 5 ++--
.../nav/destination/library/LibraryFactory.kt | 27 +++++++++++++++++++
.../webserver/WebServerHelper.java | 11 +++++---
.../kiwixmobile/webserver/ZimHostFragment.kt | 4 +--
4 files changed, 39 insertions(+), 8 deletions(-)
create mode 100644 app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index a61810662..e0320eaa3 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -26,6 +26,7 @@ import dagger.Provides
import org.kiwix.kiwixlib.JNIKiwixServer
import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.di.ServiceScope
+import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
import org.kiwix.kiwixmobile.webserver.WebServerHelper
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver
@@ -38,10 +39,10 @@ class ServiceModule {
@Provides
@ServiceScope
fun providesWebServerHelper(
- jniKiwixLibrary: Library,
+ jniKiwixLibraryFactory: LibraryFactory,
kiwixServer: JNIKiwixServer,
ipAddressCallbacks: IpAddressCallbacks
- ): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks)
+ ): WebServerHelper = WebServerHelper(jniKiwixLibraryFactory, kiwixServer, ipAddressCallbacks)
@Provides
@ServiceScope
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
new file mode 100644
index 000000000..38bb3b817
--- /dev/null
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -0,0 +1,27 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2020 Kiwix
+ * 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 .
+ *
+ */
+
+package org.kiwix.kiwixmobile.nav.destination.library
+
+import org.kiwix.kiwixlib.Library
+import javax.inject.Inject
+
+class LibraryFactory @Inject constructor(private val kiwixLibrary: Library) {
+
+ fun createKiwixLibrary(): Library = kiwixLibrary
+}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index e7a5e2463..89a93e54d 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -29,6 +29,7 @@ import org.kiwix.kiwixlib.JNIKiwixException;
import org.kiwix.kiwixlib.JNIKiwixServer;
import org.kiwix.kiwixlib.Library;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
+import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory;
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
@@ -41,14 +42,15 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
public class WebServerHelper {
private static final String TAG = "WebServerHelper";
- private Library kiwixLibrary;
+ //private Library kiwixLibrary;
+ private LibraryFactory kiwixLibraryFactory;
private JNIKiwixServer kiwixServer;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
- @Inject public WebServerHelper(@NonNull Library kiwixLibrary,
+ @Inject public WebServerHelper(@NonNull LibraryFactory kiwixLibraryFactory,
@NonNull JNIKiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) {
- this.kiwixLibrary = kiwixLibrary;
+ this.kiwixLibraryFactory = kiwixLibraryFactory;
this.kiwixServer = kiwixServer;
this.ipAddressCallbacks = ipAddressCallbacks;
}
@@ -76,7 +78,8 @@ public class WebServerHelper {
ServerUtils.port = DEFAULT_PORT;
for (String path : selectedBooksPath) {
try {
- boolean isBookAdded = kiwixLibrary.addBook(path);
+ boolean isBookAdded = kiwixLibraryFactory.createKiwixLibrary().addBook(path);
+ Log.d(TAG, "startAndroidWebServer: LibName: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
Log.v(TAG, "isBookAdded: " + isBookAdded + path);
} catch (JNIKiwixException e) {
Log.v(TAG, "Couldn't add book " + path);
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
index a21714763..164431e3d 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
@@ -139,7 +139,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
startServerButton.setOnClickListener {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P || checkCoarseLocationAccessPermission()) {
- bindService()
+ // bindService()
startStopServer()
}
}
@@ -212,7 +212,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
}
private fun stopServer() {
- unbindService()
+ // unbindService()
requireActivity().startService(createHotspotIntent(ACTION_STOP_SERVER))
}
From b8603473649dd1afa66530b7ca21b87966bb6e22 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 4 Dec 2020 15:27:02 +0530
Subject: [PATCH 09/34] wip
---
.../kiwixmobile/nav/destination/library/LibraryFactory.kt | 2 +-
.../java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
index 38bb3b817..3fd212d2d 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -22,6 +22,6 @@ import org.kiwix.kiwixlib.Library
import javax.inject.Inject
class LibraryFactory @Inject constructor(private val kiwixLibrary: Library) {
-
+ // private val libFactory = LibraryFactory(kiwixLibrary)
fun createKiwixLibrary(): Library = kiwixLibrary
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 89a93e54d..9328f10d9 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -75,11 +75,12 @@ public class WebServerHelper {
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
+ Log.d(TAG, "startAndroidWebServer: LibName101: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
ServerUtils.port = DEFAULT_PORT;
for (String path : selectedBooksPath) {
try {
boolean isBookAdded = kiwixLibraryFactory.createKiwixLibrary().addBook(path);
- Log.d(TAG, "startAndroidWebServer: LibName: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
+ Log.d(TAG, "startAndroidWebServer: LibName102: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
Log.v(TAG, "isBookAdded: " + isBookAdded + path);
} catch (JNIKiwixException e) {
Log.v(TAG, "Couldn't add book " + path);
From b9028dd6303ed9e84e911e910b4cec4b0275fb0b Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Mon, 7 Dec 2020 04:02:39 +0530
Subject: [PATCH 10/34] checked with multiple instances, doesn't work
---
.../kiwix/kiwixmobile/di/modules/ServiceModule.kt | 9 +++++++--
.../nav/destination/library/LibraryFactory.kt | 14 +++++++++++---
.../kiwixmobile/webserver/WebServerHelper.java | 13 +++++++++----
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index e0320eaa3..24e778374 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -39,10 +39,10 @@ class ServiceModule {
@Provides
@ServiceScope
fun providesWebServerHelper(
- jniKiwixLibraryFactory: LibraryFactory,
+ jniKiwixLibrary: LibraryFactory,
kiwixServer: JNIKiwixServer,
ipAddressCallbacks: IpAddressCallbacks
- ): WebServerHelper = WebServerHelper(jniKiwixLibraryFactory, kiwixServer, ipAddressCallbacks)
+ ): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks)
@Provides
@ServiceScope
@@ -58,6 +58,11 @@ class ServiceModule {
fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
JNIKiwixServer(jniKiwixLibrary)
+ @Provides
+ @ServiceScope
+ fun providesKiwixLibraryFactory(kiwixLibrary: Library): Library =
+ LibraryFactory(kiwixLibrary)
+
@Provides
@ServiceScope
fun providesHotspotNotificationManager(
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
index 3fd212d2d..661c2ccad 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -18,10 +18,18 @@
package org.kiwix.kiwixmobile.nav.destination.library
+import android.util.Log
import org.kiwix.kiwixlib.Library
import javax.inject.Inject
-class LibraryFactory @Inject constructor(private val kiwixLibrary: Library) {
- // private val libFactory = LibraryFactory(kiwixLibrary)
- fun createKiwixLibrary(): Library = kiwixLibrary
+private const val TAG = "LibraryFactory"
+
+class LibraryFactory @Inject constructor(libr: Library) : Library() {
+ private val lib = libr
+
+ fun createKiwixLibrary(): Library {
+ Log.d(TAG, "createKiwixLibrary: instance check of lib: $lib")
+ return lib
+ }
+ // works as previous one, nothing special also, ammend in this commit
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 9328f10d9..08812ff1e 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -29,6 +29,7 @@ import org.kiwix.kiwixlib.JNIKiwixException;
import org.kiwix.kiwixlib.JNIKiwixServer;
import org.kiwix.kiwixlib.Library;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
+import org.kiwix.kiwixmobile.di.components.ServiceComponent;
import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory;
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
@@ -47,7 +48,7 @@ public class WebServerHelper {
private JNIKiwixServer kiwixServer;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
-
+private ServiceComponent serviceComponent;
@Inject public WebServerHelper(@NonNull LibraryFactory kiwixLibraryFactory,
@NonNull JNIKiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) {
this.kiwixLibraryFactory = kiwixLibraryFactory;
@@ -75,12 +76,16 @@ public class WebServerHelper {
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
- Log.d(TAG, "startAndroidWebServer: LibName101: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
+ Log.d(TAG, "startAndroidWebServer: KiwixLibFactory check: { " + kiwixLibraryFactory + " }");
+ Log.d(TAG,
+ "startAndroidWebServer: LibName101: { " + kiwixLibraryFactory + " }");
ServerUtils.port = DEFAULT_PORT;
for (String path : selectedBooksPath) {
try {
- boolean isBookAdded = kiwixLibraryFactory.createKiwixLibrary().addBook(path);
- Log.d(TAG, "startAndroidWebServer: LibName102: { " + kiwixLibraryFactory.createKiwixLibrary() + " }");
+ boolean isBookAdded = kiwixLibraryFactory.addBook(path);
+ Log.d(TAG, "startAndroidWebServer: LibName102: { "
+ + kiwixLibraryFactory
+ + " }");
Log.v(TAG, "isBookAdded: " + isBookAdded + path);
} catch (JNIKiwixException e) {
Log.v(TAG, "Couldn't add book " + path);
From e973ffc14d8d2c7b99816d418d7548eb3cf9f282 Mon Sep 17 00:00:00 2001
From: "translatewiki.net"
Date: Mon, 7 Dec 2020 15:45:39 +0100
Subject: [PATCH 11/34] Localisation updates from https://translatewiki.net.
---
core/src/main/res/values-ar/strings.xml | 1 +
core/src/main/res/values-bg/strings.xml | 2 ++
core/src/main/res/values-diq/strings.xml | 1 +
core/src/main/res/values-el/strings.xml | 2 ++
core/src/main/res/values-eo/strings.xml | 2 ++
core/src/main/res/values-es/strings.xml | 2 ++
core/src/main/res/values-fr/strings.xml | 1 +
core/src/main/res/values-it/strings.xml | 1 +
core/src/main/res/values-iw/strings.xml | 2 ++
core/src/main/res/values-ku/strings.xml | 3 ++-
core/src/main/res/values-lb/strings.xml | 1 +
core/src/main/res/values-mk/strings.xml | 1 +
core/src/main/res/values-pl/strings.xml | 2 ++
core/src/main/res/values-pt-rBR/strings.xml | 1 +
core/src/main/res/values-pt/strings.xml | 2 ++
core/src/main/res/values-qq/strings.xml | 4 ++--
core/src/main/res/values-sl/strings.xml | 2 +-
core/src/main/res/values-sv/strings.xml | 1 +
core/src/main/res/values-tr/strings.xml | 1 +
core/src/main/res/values-zh-rTW/strings.xml | 1 +
20 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/core/src/main/res/values-ar/strings.xml b/core/src/main/res/values-ar/strings.xml
index bcd755c75..5620fe0d8 100644
--- a/core/src/main/res/values-ar/strings.xml
+++ b/core/src/main/res/values-ar/strings.xml
@@ -77,6 +77,7 @@
حذف هذا العنصر؟
إفراغ التاريخ
إفراغ عمليات البحث الحديثة وعلامات التبويب
+ ملاحظات
أُفرغ سجل التاريخ
حذف الإشارات المرجعية
مسح كل التاريخ
diff --git a/core/src/main/res/values-bg/strings.xml b/core/src/main/res/values-bg/strings.xml
index 8e92ff1da..8af2ce78c 100644
--- a/core/src/main/res/values-bg/strings.xml
+++ b/core/src/main/res/values-bg/strings.xml
@@ -1,6 +1,7 @@
@@ -68,6 +69,7 @@
Διαγραφή αυτού του αντικειμένου;
Εκκαθάριση ιστορικού
Εκκαθάριση ιστορικού πρόσφατων αναζητήσεων και ετικετών
+ Σημειώσεις
Όλο το ιστορικό καθαρίστηκε
Εκκαθάριση όλου του ιστορικού
Διαγραφή
diff --git a/core/src/main/res/values-eo/strings.xml b/core/src/main/res/values-eo/strings.xml
index e89022f27..607f38ca5 100644
--- a/core/src/main/res/values-eo/strings.xml
+++ b/core/src/main/res/values-eo/strings.xml
@@ -3,6 +3,7 @@
* Abijeet Patro
* Blahma
* Fitoschido
+* Javiero
* Kelson
* KuboF
* Mirin
@@ -49,6 +50,7 @@
Forigi ĉi tiu eron?
Forviŝi hisorion
Forviŝi ĵusajn serĉojn kaj historion de langetoj
+ Notoj
Forviŝis Ĉiun Historion
Forviŝi Ĉiun da Historio
Diskonigi
diff --git a/core/src/main/res/values-es/strings.xml b/core/src/main/res/values-es/strings.xml
index e912cac3a..c4b174063 100644
--- a/core/src/main/res/values-es/strings.xml
+++ b/core/src/main/res/values-es/strings.xml
@@ -12,6 +12,7 @@
* MarcoAurelio
* Mpayansilva
* Ncr
+* Rodney Araujo
* VegaDark
-->
@@ -76,6 +77,7 @@
¿Borrar este elemento?
Limpiar el historial
Borrar las búsquedas recientes y el historial de pestañas
+ Notas
Borrado todo el historial
Borrar marcadores
Borrar todo el historial?
diff --git a/core/src/main/res/values-fr/strings.xml b/core/src/main/res/values-fr/strings.xml
index 0ffe4048a..afd411718 100644
--- a/core/src/main/res/values-fr/strings.xml
+++ b/core/src/main/res/values-fr/strings.xml
@@ -84,6 +84,7 @@
Supprimer cet élément ?
Effacer l’historique
Effacer les recherches récentes et l’historique des onglets
+ Notes
Tout l’historique est effacé
Supprimer les marque-pages
Effacer tout l’historique ?
diff --git a/core/src/main/res/values-it/strings.xml b/core/src/main/res/values-it/strings.xml
index f6dcb6c3b..4e24314e5 100644
--- a/core/src/main/res/values-it/strings.xml
+++ b/core/src/main/res/values-it/strings.xml
@@ -50,6 +50,7 @@
Sei sicuro di voler cancellare la tua cronologia di ricerca e resettare tutte le tab attive?
Elimina questo elemento?
Cancella la cronologia
+ Note
Tutta la cronologia è stata cancellata
Cancellare tutta la cronologia?
Cancella
diff --git a/core/src/main/res/values-iw/strings.xml b/core/src/main/res/values-iw/strings.xml
index eb7392998..bac72d0ae 100644
--- a/core/src/main/res/values-iw/strings.xml
+++ b/core/src/main/res/values-iw/strings.xml
@@ -9,6 +9,7 @@
* Tuvalevsku
* YaronSh
* יאיר מן
+* ישראל קלר
-->
עזרה
@@ -77,6 +78,7 @@
למחוק את הפריט הזה?
ניקוי ההיסטוריה
ניקוי מילות חיפוש קודמות והיסטוריית כרטיסיות
+ הערות
כל ההיסטוריה נמחקה
ניקוי סימניות
לנקות את כל ההיסטוריה?
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index d48301e3e..411cadd9e 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -73,6 +73,7 @@
Vê pelê jê bibe?
Raboriyê paqij bike
Lêgerînên dawî û raboriya hilpekînan paqij bike
+ Not
Hemû Raborî Hat Paqijkirin
Bijareyan paqij bike
Hemû Dîrokê Paqij Bike
@@ -247,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
diff --git a/core/src/main/res/values-lb/strings.xml b/core/src/main/res/values-lb/strings.xml
index 766af916a..c02d42649 100644
--- a/core/src/main/res/values-lb/strings.xml
+++ b/core/src/main/res/values-lb/strings.xml
@@ -39,6 +39,7 @@
Sicht eng Sprooch eraus
Auteuren a Lizenzen
Dëst Element läschen?
+ Notizen
Lieszeechen ewechhuelen
Läschen
Ofbriechen
diff --git a/core/src/main/res/values-mk/strings.xml b/core/src/main/res/values-mk/strings.xml
index a3c15faa1..e4006471f 100644
--- a/core/src/main/res/values-mk/strings.xml
+++ b/core/src/main/res/values-mk/strings.xml
@@ -70,6 +70,7 @@
Да ја избришам ставкава?
Исчисти историја
Исчисти скорешни пребарувања и јазичиња
+ Белешки
Сета историја е исчистена
Исчисти обележувачи
Да ја исчистам сета историја
diff --git a/core/src/main/res/values-pl/strings.xml b/core/src/main/res/values-pl/strings.xml
index c238306f7..059869591 100644
--- a/core/src/main/res/values-pl/strings.xml
+++ b/core/src/main/res/values-pl/strings.xml
@@ -4,6 +4,7 @@
* Alan ffm
* DeRudySoulStorm
* InternerowyGołąb
+* Kareyac
* Kelson
* Krzyz23
* Macofe
@@ -79,6 +80,7 @@
Usunąć ten obiekt?
Wyczyść historię
Wyczyść historię ostatnich wyszukiwań i kart
+ Uwagi
Usunięto całą historię
Wyczyść zakładki
Wyczyść całą historię?
diff --git a/core/src/main/res/values-pt-rBR/strings.xml b/core/src/main/res/values-pt-rBR/strings.xml
index 456487851..7d08cc343 100644
--- a/core/src/main/res/values-pt-rBR/strings.xml
+++ b/core/src/main/res/values-pt-rBR/strings.xml
@@ -76,6 +76,7 @@
Eliminar este item?
Apagar histórico
Limpar pesquisas recentes e histórico de guias
+ Notas
Eliminando todo o histórico
Limpar marcadores
Limpar todo o histórico?
diff --git a/core/src/main/res/values-pt/strings.xml b/core/src/main/res/values-pt/strings.xml
index 4faf32a47..a3e37edf5 100644
--- a/core/src/main/res/values-pt/strings.xml
+++ b/core/src/main/res/values-pt/strings.xml
@@ -7,6 +7,7 @@
* Hamilton Abreu
* Imperadeiro90
* Imperadeiro98
+* Kareyac
* Kelson
* Macofe
* Mansil alfalb
@@ -53,6 +54,7 @@
Apagar este elemento?
Limpar o histórico
Limpar as pesquisas recentes e o histórico de separadores
+ Notas
Todo o historial foi apagado
Apagar todo o historial
Apagar
diff --git a/core/src/main/res/values-qq/strings.xml b/core/src/main/res/values-qq/strings.xml
index 22b31846d..085aaadf0 100644
--- a/core/src/main/res/values-qq/strings.xml
+++ b/core/src/main/res/values-qq/strings.xml
@@ -27,10 +27,9 @@
{{Identical|Information}}
{{Identical|Version}}
{{Identical|Back to top}}
- {{Identical|History}}
- {{Identical|Notes}}
{{Identical|Language}}
{{Identical|Choose language}}
+ {{Identical|Notes}}
{{Identical|Delete}}
{{identical|Cancel}}
{{Identical|Undo}}
@@ -47,6 +46,7 @@
{{Identical|Previous}}
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.
{{Identical|Yesterday}}
+ {{Identical|History}}
TODO: Unclear, must be documented. See https://github.com/kiwix/overview/issues/31
{{Identical|Save}}
Tell the user Location permission required for hosting zim file.
diff --git a/core/src/main/res/values-sl/strings.xml b/core/src/main/res/values-sl/strings.xml
index 49e16c90d..9eb57b554 100644
--- a/core/src/main/res/values-sl/strings.xml
+++ b/core/src/main/res/values-sl/strings.xml
@@ -156,7 +156,7 @@
Kazalo vsebine
Izberi jezike
Shrani jezike
- Sporoči svoje mnenje
+ Sporočite svoje mnenje
Razširi
Zgodovina
Zgodovina iz trenutne knjige
diff --git a/core/src/main/res/values-sv/strings.xml b/core/src/main/res/values-sv/strings.xml
index e92faa056..025389f35 100644
--- a/core/src/main/res/values-sv/strings.xml
+++ b/core/src/main/res/values-sv/strings.xml
@@ -75,6 +75,7 @@
Radera detta objekt?
Rensa historik
Rensa senaste sökningar och flikhistorik
+ Anteckningar
All historik rensades
Rensa bokmärken
Rensa all historik?
diff --git a/core/src/main/res/values-tr/strings.xml b/core/src/main/res/values-tr/strings.xml
index 8490f186e..dbe42042e 100644
--- a/core/src/main/res/values-tr/strings.xml
+++ b/core/src/main/res/values-tr/strings.xml
@@ -83,6 +83,7 @@
Bu öğe silinsin mi?
Geçmişi temizle
Son aramalar ve sekmeler geçmişini temizle
+ Notlar
Tüm geçmiş temizlendi
Yer imlerini temizle
Tüm Geçmişi Silinsin mi?
diff --git a/core/src/main/res/values-zh-rTW/strings.xml b/core/src/main/res/values-zh-rTW/strings.xml
index f9f33cbc8..baee4200d 100644
--- a/core/src/main/res/values-zh-rTW/strings.xml
+++ b/core/src/main/res/values-zh-rTW/strings.xml
@@ -75,6 +75,7 @@
刪除此項目?
清除歷史記錄
清除近期搜尋和分頁歷史記錄
+ 備註
所有歷史記錄已清除
清除書籤
清除所有歷史記錄?
From 73a6a7c3823f702d19268ae5280d13189def62f0 Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 8 Dec 2020 09:32:00 +0000
Subject: [PATCH 12/34] lint fix
---
core/src/main/res/values-ku/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index 411cadd9e..c96f0282e 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -248,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From 3388142142f4d77b06db6991c8889ddc008ca377 Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Wed, 9 Dec 2020 10:22:40 +0000
Subject: [PATCH 13/34] #2532 Video seeking does not work anymore with 3.4.2 -
readd range headers
---
.../core/ServiceWorkerInitialiser.kt | 2 +-
.../core/main/CoreWebViewClient.java | 7 ++---
.../kiwixmobile/core/main/KiwixWebView.kt | 2 +-
.../core/reader/ZimReaderContainer.kt | 27 ++++++++++++++-----
4 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/ServiceWorkerInitialiser.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/ServiceWorkerInitialiser.kt
index 707dd32d6..e2f801ca5 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/ServiceWorkerInitialiser.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/ServiceWorkerInitialiser.kt
@@ -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)
})
}
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreWebViewClient.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreWebViewClient.java
index ea42552fb..a2ca2a179 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreWebViewClient.java
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreWebViewClient.java
@@ -139,13 +139,10 @@ public class CoreWebViewClient extends WebViewClient {
@Nullable
@Override
- public WebResourceResponse shouldInterceptRequest(
- WebView view,
- WebResourceRequest request)
- {
+ 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);
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixWebView.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixWebView.kt
index f53124e95..c218bb1c9 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixWebView.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/KiwixWebView.kt
@@ -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))
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt
index f03c616e8..97814856c 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt
@@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.reader
import android.webkit.WebResourceResponse
import org.kiwix.kiwixmobile.core.reader.ZimFileReader.Factory
import java.io.File
+import java.net.HttpURLConnection
import javax.inject.Inject
import javax.inject.Singleton
@@ -45,12 +46,26 @@ class ZimReaderContainer @Inject constructor(private val zimFileReaderFactory: F
fun getRandomArticleUrl() = zimFileReader?.getRandomArticleUrl()
fun isRedirect(url: String): Boolean = zimFileReader?.isRedirect(url) == true
fun getRedirect(url: String): String = zimFileReader?.getRedirect(url) ?: ""
- fun load(url: String) =
- WebResourceResponse(
- zimFileReader?.readMimeType(url),
- Charsets.UTF_8.name(),
- zimFileReader?.load(url)
- )
+ fun load(url: String, requestHeaders: Map): WebResourceResponse {
+ val data = zimFileReader?.load(url)
+ return WebResourceResponse(zimFileReader?.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(): ZimFileReader? = zimFile?.let(zimFileReaderFactory::create)
From 45549d34461d2bd924de5beb7c3f39c24385f9da Mon Sep 17 00:00:00 2001
From: gouri-panda
Date: Thu, 10 Dec 2020 17:14:34 +0530
Subject: [PATCH 14/34] 2534_added bitmap in launch screen
---
custom/src/main/res/drawable-night/launch_screen.xml | 11 ++++-------
custom/src/main/res/drawable/launch_screen.xml | 11 ++++-------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/custom/src/main/res/drawable-night/launch_screen.xml b/custom/src/main/res/drawable-night/launch_screen.xml
index b11ad6354..05ca4c686 100644
--- a/custom/src/main/res/drawable-night/launch_screen.xml
+++ b/custom/src/main/res/drawable-night/launch_screen.xml
@@ -21,11 +21,8 @@
android:opacity="opaque">
-
+ -
+
+
diff --git a/custom/src/main/res/drawable/launch_screen.xml b/custom/src/main/res/drawable/launch_screen.xml
index e4495189c..9c42b700b 100644
--- a/custom/src/main/res/drawable/launch_screen.xml
+++ b/custom/src/main/res/drawable/launch_screen.xml
@@ -21,11 +21,8 @@
android:opacity="opaque">
-
+ -
+
+
From 912ed25d0a23628f1fb2d069d81e120442b7ea53 Mon Sep 17 00:00:00 2001
From: "translatewiki.net"
Date: Thu, 10 Dec 2020 13:49:23 +0100
Subject: [PATCH 15/34] Localisation updates from https://translatewiki.net.
---
core/src/main/res/values-de/strings.xml | 2 ++
core/src/main/res/values-ku/strings.xml | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/core/src/main/res/values-de/strings.xml b/core/src/main/res/values-de/strings.xml
index da6c558d2..64eb7f630 100644
--- a/core/src/main/res/values-de/strings.xml
+++ b/core/src/main/res/values-de/strings.xml
@@ -6,6 +6,7 @@
* FF11
* Killarnee
* Metalhead64
+* Pittigrilli
* Stephane
* Susann Schweden
* Symposiarch
@@ -74,6 +75,7 @@
Dieses Element löschen?
Verlauf löschen
Letzte Suchanfragen und Registerkartenverlauf löschen
+ Anmerkungen
Gesamter Verlauf gelöscht
Lesezeichen löschen
Gesamten Verlauf löschen?
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index c96f0282e..be77c7325 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -52,7 +52,7 @@
Vê adresa IPyê di geroka xwe de binivîsîne ji bo ku xwe bigihînî servera %s
Çewtîː Peldanka ZIM\'ê ya bijartî nehate dîtin.
Nikare dosyeya zim-ê veke
- Çewtîː Peldanka bijartî ne peldankeke ZIM\'ê ya derbasdar e.
+ Çewtîː Peldanka bijartî ne peldankeke ZIMê ya derbasdar e.
Çewtîː Barkirina gotara (Url: %1$s) têk çû.
Nîşan bide
Agahî
@@ -248,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From f0e874ea94c330818bd0545a9439311ab4f669ed Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 11 Dec 2020 03:13:08 +0530
Subject: [PATCH 16/34] Create KiwixServer & Factory, and set the hosting
working
---
.../kiwixmobile/di/modules/ServiceModule.kt | 31 +++++++++----------
.../nav/destination/library/LibraryFactory.kt | 13 ++------
.../kiwixmobile/webserver/KiwixServer.kt | 29 +++++++++++++++++
.../webserver/WebServerHelper.java | 28 +++++++----------
4 files changed, 57 insertions(+), 44 deletions(-)
create mode 100644 app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index 24e778374..cc75d5dd1 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -23,10 +23,8 @@ import android.app.Service
import android.content.Context
import dagger.Module
import dagger.Provides
-import org.kiwix.kiwixlib.JNIKiwixServer
-import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.di.ServiceScope
-import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
+import org.kiwix.kiwixmobile.webserver.KiwixServer
import org.kiwix.kiwixmobile.webserver.WebServerHelper
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver
@@ -39,29 +37,28 @@ class ServiceModule {
@Provides
@ServiceScope
fun providesWebServerHelper(
- jniKiwixLibrary: LibraryFactory,
- kiwixServer: JNIKiwixServer,
+ kiwixServer: KiwixServer,
ipAddressCallbacks: IpAddressCallbacks
- ): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks)
+ ): WebServerHelper = WebServerHelper(kiwixServer, ipAddressCallbacks)
@Provides
@ServiceScope
fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
service as IpAddressCallbacks
- @Provides
- @ServiceScope
- fun providesLibrary(): Library = Library()
+ // @Provides
+ // @ServiceScope
+ // fun providesLibrary(): Library = Library()
- @Provides
- @ServiceScope
- fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
- JNIKiwixServer(jniKiwixLibrary)
+ // @Provides
+ // @ServiceScope
+ // fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
+ // KiwixServer(jniKiwixLibrary)
- @Provides
- @ServiceScope
- fun providesKiwixLibraryFactory(kiwixLibrary: Library): Library =
- LibraryFactory(kiwixLibrary)
+ // @Provides
+ // @ServiceScope
+ // fun providesKiwixLibraryFactory(): Library =
+ // LibraryFactory()
@Provides
@ServiceScope
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
index 661c2ccad..5f48b1ab2 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -18,18 +18,9 @@
package org.kiwix.kiwixmobile.nav.destination.library
-import android.util.Log
import org.kiwix.kiwixlib.Library
import javax.inject.Inject
-private const val TAG = "LibraryFactory"
-
-class LibraryFactory @Inject constructor(libr: Library) : Library() {
- private val lib = libr
-
- fun createKiwixLibrary(): Library {
- Log.d(TAG, "createKiwixLibrary: instance check of lib: $lib")
- return lib
- }
- // works as previous one, nothing special also, ammend in this commit
+class LibraryFactory @Inject constructor() : Library() {
+ fun createKiwixLibrary(): Library = Library()
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
new file mode 100644
index 000000000..08b1388a2
--- /dev/null
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -0,0 +1,29 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2020 Kiwix
+ * 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 .
+ *
+ */
+
+package org.kiwix.kiwixmobile.webserver
+
+import org.kiwix.kiwixlib.JNIKiwixServer
+import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
+import javax.inject.Inject
+
+class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
+ val kiwixLibrary = kiwixLibraryFactory.createKiwixLibrary()
+
+ fun createKiwixServer(): JNIKiwixServer? = JNIKiwixServer(kiwixLibrary)
+}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 08812ff1e..56d1de162 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -29,8 +29,6 @@ import org.kiwix.kiwixlib.JNIKiwixException;
import org.kiwix.kiwixlib.JNIKiwixServer;
import org.kiwix.kiwixlib.Library;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
-import org.kiwix.kiwixmobile.di.components.ServiceComponent;
-import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory;
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
@@ -44,20 +42,17 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
public class WebServerHelper {
private static final String TAG = "WebServerHelper";
//private Library kiwixLibrary;
- private LibraryFactory kiwixLibraryFactory;
- private JNIKiwixServer kiwixServer;
+ private KiwixServer kiwixServer;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
-private ServiceComponent serviceComponent;
- @Inject public WebServerHelper(@NonNull LibraryFactory kiwixLibraryFactory,
- @NonNull JNIKiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) {
- this.kiwixLibraryFactory = kiwixLibraryFactory;
+ @Inject public WebServerHelper(@NonNull KiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) {
this.kiwixServer = kiwixServer;
this.ipAddressCallbacks = ipAddressCallbacks;
}
-
+ private JNIKiwixServer server;
public boolean startServerHelper(@NonNull ArrayList selectedBooksPath) {
String ip = ServerUtils.getIpAddress();
+ server = kiwixServer.createKiwixServer();
if (ip.length() == 0) {
return false;
} else if (startAndroidWebServer(selectedBooksPath)) {
@@ -68,7 +63,7 @@ private ServiceComponent serviceComponent;
public void stopAndroidWebServer() {
if (isServerStarted) {
- kiwixServer.stop();
+ server.stop();
updateServerState(false);
}
}
@@ -76,23 +71,24 @@ private ServiceComponent serviceComponent;
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
- Log.d(TAG, "startAndroidWebServer: KiwixLibFactory check: { " + kiwixLibraryFactory + " }");
+ Library kiwixLibrary = kiwixServer.getKiwixLibrary();
+ Log.d(TAG, "startAndroidWebServer: KiwixLibFactory check: { " + kiwixLibrary + " }");
Log.d(TAG,
- "startAndroidWebServer: LibName101: { " + kiwixLibraryFactory + " }");
+ "startAndroidWebServer: LibName101: { " + kiwixLibrary + " }");
ServerUtils.port = DEFAULT_PORT;
for (String path : selectedBooksPath) {
try {
- boolean isBookAdded = kiwixLibraryFactory.addBook(path);
+ boolean isBookAdded = kiwixLibrary.addBook(path);
Log.d(TAG, "startAndroidWebServer: LibName102: { "
- + kiwixLibraryFactory
+ + kiwixLibrary
+ " }");
Log.v(TAG, "isBookAdded: " + isBookAdded + path);
} catch (JNIKiwixException e) {
Log.v(TAG, "Couldn't add book " + path);
}
}
- kiwixServer.setPort(ServerUtils.port);
- updateServerState(kiwixServer.start());
+ server.setPort(ServerUtils.port);
+ updateServerState(server.start());
Log.v(TAG, "Server status" + isServerStarted);
}
return isServerStarted;
From 57fb4ba7b32b1de72cf6c08c0fa30e0d7ac038b8 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 11 Dec 2020 03:27:13 +0530
Subject: [PATCH 17/34] Potential Fix(does not work)
---
.../kiwix/kiwixmobile/webserver/WebServerHelper.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 56d1de162..484538255 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -41,18 +41,19 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
public class WebServerHelper {
private static final String TAG = "WebServerHelper";
- //private Library kiwixLibrary;
private KiwixServer kiwixServer;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
- @Inject public WebServerHelper(@NonNull KiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) {
+ private JNIKiwixServer server;
+
+ @Inject public WebServerHelper(@NonNull KiwixServer kiwixServer,
+ @NonNull IpAddressCallbacks ipAddressCallbacks) {
this.kiwixServer = kiwixServer;
this.ipAddressCallbacks = ipAddressCallbacks;
}
- private JNIKiwixServer server;
+
public boolean startServerHelper(@NonNull ArrayList selectedBooksPath) {
String ip = ServerUtils.getIpAddress();
- server = kiwixServer.createKiwixServer();
if (ip.length() == 0) {
return false;
} else if (startAndroidWebServer(selectedBooksPath)) {
@@ -70,6 +71,7 @@ public class WebServerHelper {
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
+ server = kiwixServer.createKiwixServer();
int DEFAULT_PORT = 8080;
Library kiwixLibrary = kiwixServer.getKiwixLibrary();
Log.d(TAG, "startAndroidWebServer: KiwixLibFactory check: { " + kiwixLibrary + " }");
From 1e7566bf78b758980f26b5371b14b7bbd310806f Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 11 Dec 2020 05:01:13 +0530
Subject: [PATCH 18/34] Close #2447 Set books updating on browser as soon as
updated on android client
---
.../nav/destination/library/LibraryFactory.kt | 7 +++-
.../kiwixmobile/webserver/KiwixServer.kt | 24 ++++++++++--
.../webserver/WebServerHelper.java | 37 ++++++++++---------
3 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
index 5f48b1ab2..0b755e7ed 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -18,9 +18,14 @@
package org.kiwix.kiwixmobile.nav.destination.library
+import android.util.Log
import org.kiwix.kiwixlib.Library
import javax.inject.Inject
+private const val TAG = "LibraryFactory"
class LibraryFactory @Inject constructor() : Library() {
- fun createKiwixLibrary(): Library = Library()
+ fun createKiwixLibrary(): Library {
+ Log.d(TAG, "createKiwixLibrary: instance check of Library from factory: { ${Library()} } ")
+ return Library()
+ }
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index 08b1388a2..b91a292f7 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -18,12 +18,30 @@
package org.kiwix.kiwixmobile.webserver
+import android.util.Log
+import org.kiwix.kiwixlib.JNIKiwixException
import org.kiwix.kiwixlib.JNIKiwixServer
+import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
import javax.inject.Inject
-class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
- val kiwixLibrary = kiwixLibraryFactory.createKiwixLibrary()
+private const val TAG = "KiwixServer"
- fun createKiwixServer(): JNIKiwixServer? = JNIKiwixServer(kiwixLibrary)
+class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
+ private val libFactory = kiwixLibraryFactory
+ private lateinit var kiwixLibrary: Library
+
+ fun createKiwixServer(selectedBooksPath: ArrayList): JNIKiwixServer? {
+ kiwixLibrary = libFactory.createKiwixLibrary()
+ // kiwixLibrary.addBook(selectedBooksPath)
+ for (path in selectedBooksPath) {
+ try {
+ var isBookAdded: Boolean = kiwixLibrary.addBook(path)
+ } catch (e: JNIKiwixException) {
+ Log.v(TAG, "Couldn't add book $path")
+ }
+ }
+ Log.d(TAG, "createKiwixServer: Library instance check in JNIKiwixServer: $kiwixLibrary ")
+ return JNIKiwixServer(kiwixLibrary)
+ }
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 484538255..035c113f4 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -25,7 +25,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
-import org.kiwix.kiwixlib.JNIKiwixException;
import org.kiwix.kiwixlib.JNIKiwixServer;
import org.kiwix.kiwixlib.Library;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
@@ -71,27 +70,29 @@ public class WebServerHelper {
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
- server = kiwixServer.createKiwixServer();
int DEFAULT_PORT = 8080;
- Library kiwixLibrary = kiwixServer.getKiwixLibrary();
- Log.d(TAG, "startAndroidWebServer: KiwixLibFactory check: { " + kiwixLibrary + " }");
- Log.d(TAG,
- "startAndroidWebServer: LibName101: { " + kiwixLibrary + " }");
+ //Library kiwixLibrary = kiwixServer.getKiwixLibrary();
+ Log.d(TAG, "startAndroidWebServer: KiwixServer instance check: { " + kiwixServer + " }");
+ //Log.d(TAG,
+ // "startAndroidWebServer: library instance check in WSH: { " + kiwixLibrary + " }");
ServerUtils.port = DEFAULT_PORT;
- for (String path : selectedBooksPath) {
- try {
- boolean isBookAdded = kiwixLibrary.addBook(path);
- Log.d(TAG, "startAndroidWebServer: LibName102: { "
- + kiwixLibrary
- + " }");
- Log.v(TAG, "isBookAdded: " + isBookAdded + path);
- } catch (JNIKiwixException e) {
- Log.v(TAG, "Couldn't add book " + path);
- }
- }
+ //for (String path : selectedBooksPath) {
+ // try {
+ // boolean isBookAdded = kiwixLibrary.addBook(path);
+ // Log.d(TAG, "startAndroidWebServer: LibName102: { "
+ // + kiwixLibrary
+ // + " }");
+ // Log.v(TAG, "isBookAdded: " + isBookAdded + path);
+ // } catch (JNIKiwixException e) {
+ // Log.v(TAG, "Couldn't add book " + path);
+ // }
+ //}
+ server = kiwixServer.createKiwixServer(selectedBooksPath);
+ //server = kiwixServer.createKiwixServer();
server.setPort(ServerUtils.port);
updateServerState(server.start());
- Log.v(TAG, "Server status" + isServerStarted);
+ Log.d(TAG, "startAndroidWebServer: checking server instance:{ " + server + " }");
+ Log.d(TAG, "Server status" + isServerStarted);
}
return isServerStarted;
}
From d66e2001da5361c9fb68bf50edcd493a7d0827ed Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 11 Dec 2020 05:04:08 +0530
Subject: [PATCH 19/34] Clean up and removed loggings
---
.../kiwixmobile/di/modules/ServiceModule.kt | 14 --------------
.../nav/destination/library/LibraryFactory.kt | 7 +------
.../kiwix/kiwixmobile/webserver/KiwixServer.kt | 4 +---
.../kiwixmobile/webserver/WebServerHelper.java | 17 -----------------
.../kiwixmobile/webserver/ZimHostFragment.kt | 2 --
5 files changed, 2 insertions(+), 42 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index cc75d5dd1..35e377898 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -46,20 +46,6 @@ class ServiceModule {
fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
service as IpAddressCallbacks
- // @Provides
- // @ServiceScope
- // fun providesLibrary(): Library = Library()
-
- // @Provides
- // @ServiceScope
- // fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
- // KiwixServer(jniKiwixLibrary)
-
- // @Provides
- // @ServiceScope
- // fun providesKiwixLibraryFactory(): Library =
- // LibraryFactory()
-
@Provides
@ServiceScope
fun providesHotspotNotificationManager(
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
index 0b755e7ed..5f48b1ab2 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
@@ -18,14 +18,9 @@
package org.kiwix.kiwixmobile.nav.destination.library
-import android.util.Log
import org.kiwix.kiwixlib.Library
import javax.inject.Inject
-private const val TAG = "LibraryFactory"
class LibraryFactory @Inject constructor() : Library() {
- fun createKiwixLibrary(): Library {
- Log.d(TAG, "createKiwixLibrary: instance check of Library from factory: { ${Library()} } ")
- return Library()
- }
+ fun createKiwixLibrary(): Library = Library()
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index b91a292f7..fa081e115 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -33,15 +33,13 @@ class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
fun createKiwixServer(selectedBooksPath: ArrayList): JNIKiwixServer? {
kiwixLibrary = libFactory.createKiwixLibrary()
- // kiwixLibrary.addBook(selectedBooksPath)
for (path in selectedBooksPath) {
try {
var isBookAdded: Boolean = kiwixLibrary.addBook(path)
} catch (e: JNIKiwixException) {
- Log.v(TAG, "Couldn't add book $path")
+ Log.v(TAG, "Couldn't add book with path:{ $path }")
}
}
- Log.d(TAG, "createKiwixServer: Library instance check in JNIKiwixServer: $kiwixLibrary ")
return JNIKiwixServer(kiwixLibrary)
}
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 035c113f4..9e1d4e938 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -71,27 +71,10 @@ public class WebServerHelper {
private boolean startAndroidWebServer(ArrayList selectedBooksPath) {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
- //Library kiwixLibrary = kiwixServer.getKiwixLibrary();
- Log.d(TAG, "startAndroidWebServer: KiwixServer instance check: { " + kiwixServer + " }");
- //Log.d(TAG,
- // "startAndroidWebServer: library instance check in WSH: { " + kiwixLibrary + " }");
ServerUtils.port = DEFAULT_PORT;
- //for (String path : selectedBooksPath) {
- // try {
- // boolean isBookAdded = kiwixLibrary.addBook(path);
- // Log.d(TAG, "startAndroidWebServer: LibName102: { "
- // + kiwixLibrary
- // + " }");
- // Log.v(TAG, "isBookAdded: " + isBookAdded + path);
- // } catch (JNIKiwixException e) {
- // Log.v(TAG, "Couldn't add book " + path);
- // }
- //}
server = kiwixServer.createKiwixServer(selectedBooksPath);
- //server = kiwixServer.createKiwixServer();
server.setPort(ServerUtils.port);
updateServerState(server.start());
- Log.d(TAG, "startAndroidWebServer: checking server instance:{ " + server + " }");
Log.d(TAG, "Server status" + isServerStarted);
}
return isServerStarted;
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
index 164431e3d..1cc344973 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/ZimHostFragment.kt
@@ -139,7 +139,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
startServerButton.setOnClickListener {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P || checkCoarseLocationAccessPermission()) {
- // bindService()
startStopServer()
}
}
@@ -212,7 +211,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
}
private fun stopServer() {
- // unbindService()
requireActivity().startService(createHotspotIntent(ACTION_STOP_SERVER))
}
From 1e502f5bec13c7277af5c6ace635a9c39d4e9032 Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Fri, 11 Dec 2020 10:12:51 +0000
Subject: [PATCH 20/34] lint fix
---
core/src/main/res/values-ku/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index be77c7325..bd52efdff 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -248,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From 7b1bca6debc1ff9d5d7fe228156687c64b36ac99 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Fri, 11 Dec 2020 16:03:57 +0530
Subject: [PATCH 21/34] Subtle refactors
---
.../java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index fa081e115..61325f0df 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.webserver
import android.util.Log
import org.kiwix.kiwixlib.JNIKiwixException
import org.kiwix.kiwixlib.JNIKiwixServer
-import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
import javax.inject.Inject
@@ -29,13 +28,12 @@ private const val TAG = "KiwixServer"
class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
private val libFactory = kiwixLibraryFactory
- private lateinit var kiwixLibrary: Library
fun createKiwixServer(selectedBooksPath: ArrayList): JNIKiwixServer? {
- kiwixLibrary = libFactory.createKiwixLibrary()
- for (path in selectedBooksPath) {
+ val kiwixLibrary = libFactory.createKiwixLibrary()
+ selectedBooksPath.forEach { path ->
try {
- var isBookAdded: Boolean = kiwixLibrary.addBook(path)
+ kiwixLibrary.addBook(path)
} catch (e: JNIKiwixException) {
Log.v(TAG, "Couldn't add book with path:{ $path }")
}
From 5d921ce747cbc1f6be71d590200ea9d205b43dfd Mon Sep 17 00:00:00 2001
From: gouri-panda
Date: Fri, 11 Dec 2020 17:35:07 +0530
Subject: [PATCH 22/34] #2534 created different xml file for api level 23 or
higher
---
.../res/drawable-night-v23/launch_screen.xml | 22 +++++++++++++++++++
.../main/res/drawable-v23/launch_screen.xml | 22 +++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100644 custom/src/main/res/drawable-night-v23/launch_screen.xml
create mode 100644 custom/src/main/res/drawable-v23/launch_screen.xml
diff --git a/custom/src/main/res/drawable-night-v23/launch_screen.xml b/custom/src/main/res/drawable-night-v23/launch_screen.xml
new file mode 100644
index 000000000..ac4db0c46
--- /dev/null
+++ b/custom/src/main/res/drawable-night-v23/launch_screen.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
diff --git a/custom/src/main/res/drawable-v23/launch_screen.xml b/custom/src/main/res/drawable-v23/launch_screen.xml
new file mode 100644
index 000000000..ac4db0c46
--- /dev/null
+++ b/custom/src/main/res/drawable-v23/launch_screen.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
From c96ffb29274d0bd4f7b61e52b6e0e69b078366bb Mon Sep 17 00:00:00 2001
From: gouri-panda
Date: Fri, 11 Dec 2020 17:40:30 +0530
Subject: [PATCH 23/34] added items for api equal and greater than 23
---
.../main/res/drawable-night-v23/launch_screen.xml | 15 ++++++++++++---
.../src/main/res/drawable-night/launch_screen.xml | 2 +-
.../src/main/res/drawable-v23/launch_screen.xml | 15 ++++++++++++---
3 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/custom/src/main/res/drawable-night-v23/launch_screen.xml b/custom/src/main/res/drawable-night-v23/launch_screen.xml
index ac4db0c46..e4495189c 100644
--- a/custom/src/main/res/drawable-night-v23/launch_screen.xml
+++ b/custom/src/main/res/drawable-night-v23/launch_screen.xml
@@ -17,6 +17,15 @@
~
-->
-
-
-
+
+
+
+
+
diff --git a/custom/src/main/res/drawable-night/launch_screen.xml b/custom/src/main/res/drawable-night/launch_screen.xml
index 05ca4c686..4cdbf9e86 100644
--- a/custom/src/main/res/drawable-night/launch_screen.xml
+++ b/custom/src/main/res/drawable-night/launch_screen.xml
@@ -6,7 +6,7 @@
~ 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
diff --git a/custom/src/main/res/drawable-v23/launch_screen.xml b/custom/src/main/res/drawable-v23/launch_screen.xml
index ac4db0c46..e4495189c 100644
--- a/custom/src/main/res/drawable-v23/launch_screen.xml
+++ b/custom/src/main/res/drawable-v23/launch_screen.xml
@@ -17,6 +17,15 @@
~
-->
-
-
-
+
+
+
+
+
From 13178f88a930014429622daaadca2c7d09005570 Mon Sep 17 00:00:00 2001
From: gouri-panda
Date: Fri, 11 Dec 2020 17:41:49 +0530
Subject: [PATCH 24/34] reformated code
---
custom/src/main/res/drawable-night-v23/launch_screen.xml | 3 +--
custom/src/main/res/drawable-night/launch_screen.xml | 8 ++++----
custom/src/main/res/drawable-v23/launch_screen.xml | 3 +--
custom/src/main/res/drawable/launch_screen.xml | 5 +++--
4 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/custom/src/main/res/drawable-night-v23/launch_screen.xml b/custom/src/main/res/drawable-night-v23/launch_screen.xml
index e4495189c..e34f35c7e 100644
--- a/custom/src/main/res/drawable-night-v23/launch_screen.xml
+++ b/custom/src/main/res/drawable-night-v23/launch_screen.xml
@@ -1,5 +1,4 @@
-
-
-
-
+
diff --git a/custom/src/main/res/drawable-v23/launch_screen.xml b/custom/src/main/res/drawable-v23/launch_screen.xml
index e4495189c..e34f35c7e 100644
--- a/custom/src/main/res/drawable-v23/launch_screen.xml
+++ b/custom/src/main/res/drawable-v23/launch_screen.xml
@@ -1,5 +1,4 @@
-
-
-
-
+
From 0ea288d3143a52b1ed6c78f3360d511b3981a4c1 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Sun, 13 Dec 2020 13:27:06 +0530
Subject: [PATCH 25/34] Removed libraryFactory
---
.../nav/destination/library/LibraryFactory.kt | 26 -------------------
.../kiwixmobile/webserver/KiwixServer.kt | 7 +++--
2 files changed, 3 insertions(+), 30 deletions(-)
delete mode 100644 app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
deleted file mode 100644
index 5f48b1ab2..000000000
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/library/LibraryFactory.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2020 Kiwix
- * 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 .
- *
- */
-
-package org.kiwix.kiwixmobile.nav.destination.library
-
-import org.kiwix.kiwixlib.Library
-import javax.inject.Inject
-
-class LibraryFactory @Inject constructor() : Library() {
- fun createKiwixLibrary(): Library = Library()
-}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index 61325f0df..c02d6c151 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -21,16 +21,15 @@ package org.kiwix.kiwixmobile.webserver
import android.util.Log
import org.kiwix.kiwixlib.JNIKiwixException
import org.kiwix.kiwixlib.JNIKiwixServer
-import org.kiwix.kiwixmobile.nav.destination.library.LibraryFactory
+import org.kiwix.kiwixlib.Library
import javax.inject.Inject
private const val TAG = "KiwixServer"
-class KiwixServer @Inject constructor(kiwixLibraryFactory: LibraryFactory) {
- private val libFactory = kiwixLibraryFactory
+class KiwixServer @Inject constructor() {
fun createKiwixServer(selectedBooksPath: ArrayList): JNIKiwixServer? {
- val kiwixLibrary = libFactory.createKiwixLibrary()
+ val kiwixLibrary = Library()
selectedBooksPath.forEach { path ->
try {
kiwixLibrary.addBook(path)
From 7faf13ee3a90dd29234efc12145b68099f9fe490 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Mon, 14 Dec 2020 15:55:51 +0530
Subject: [PATCH 26/34] #2447 Separated and Optimizedd the KiwixServer and
Factory Functionality, works now
---
.../kiwixmobile/di/modules/ServiceModule.kt | 11 ++++++++
.../kiwixmobile/webserver/KiwixServer.kt | 27 ++++++++++++-------
.../webserver/WebServerHelper.java | 9 +++----
3 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index 35e377898..756c5edef 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -23,6 +23,8 @@ import android.app.Service
import android.content.Context
import dagger.Module
import dagger.Provides
+import org.kiwix.kiwixlib.JNIKiwixServer
+import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.di.ServiceScope
import org.kiwix.kiwixmobile.webserver.KiwixServer
import org.kiwix.kiwixmobile.webserver.WebServerHelper
@@ -46,6 +48,15 @@ class ServiceModule {
fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
service as IpAddressCallbacks
+ @Provides
+ @ServiceScope
+ fun providesLibrary(): Library = Library()
+
+ @Provides
+ @ServiceScope
+ fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
+ JNIKiwixServer(jniKiwixLibrary)
+
@Provides
@ServiceScope
fun providesHotspotNotificationManager(
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index c02d6c151..a8ca3e123 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -26,17 +26,26 @@ import javax.inject.Inject
private const val TAG = "KiwixServer"
-class KiwixServer @Inject constructor() {
+class KiwixServer @Inject constructor(private val jniKiwixServer: JNIKiwixServer) {
- fun createKiwixServer(selectedBooksPath: ArrayList): JNIKiwixServer? {
- val kiwixLibrary = Library()
- selectedBooksPath.forEach { path ->
- try {
- kiwixLibrary.addBook(path)
- } catch (e: JNIKiwixException) {
- Log.v(TAG, "Couldn't add book with path:{ $path }")
+ class Factory {
+ fun createKiwixServer(selectedBooksPath: ArrayList): KiwixServer {
+ val kiwixLibrary = Library()
+ selectedBooksPath.forEach { path ->
+ try {
+ kiwixLibrary.addBook(path)
+ } catch (e: JNIKiwixException) {
+ Log.v(TAG, "Couldn't add book with path:{ $path }")
+ }
}
+ return KiwixServer(JNIKiwixServer(kiwixLibrary))
}
- return JNIKiwixServer(kiwixLibrary)
}
+
+ fun startServer(port: Int): Boolean {
+ jniKiwixServer.setPort(port)
+ return jniKiwixServer.start()
+ }
+
+ fun stopServer() = jniKiwixServer.stop()
}
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 9e1d4e938..9953a9c08 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.kiwix.kiwixlib.JNIKiwixServer;
-import org.kiwix.kiwixlib.Library;
import org.kiwix.kiwixmobile.core.utils.ServerUtils;
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks;
@@ -63,7 +62,7 @@ public class WebServerHelper {
public void stopAndroidWebServer() {
if (isServerStarted) {
- server.stop();
+ kiwixServer.stopServer();
updateServerState(false);
}
}
@@ -72,9 +71,9 @@ public class WebServerHelper {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
ServerUtils.port = DEFAULT_PORT;
- server = kiwixServer.createKiwixServer(selectedBooksPath);
- server.setPort(ServerUtils.port);
- updateServerState(server.start());
+ KiwixServer.Factory factory = new KiwixServer.Factory();
+ kiwixServer = factory.createKiwixServer(selectedBooksPath);
+ updateServerState(kiwixServer.startServer(ServerUtils.port));
Log.d(TAG, "Server status" + isServerStarted);
}
return isServerStarted;
From 1669a87d3c9dfc1d704aaff2f27c578a9e8222cc Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Mon, 14 Dec 2020 16:12:53 +0530
Subject: [PATCH 27/34] Injected proper classes in WebServerHelper
---
.../org/kiwix/kiwixmobile/di/modules/ServiceModule.kt | 4 ++--
.../java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt | 2 +-
.../org/kiwix/kiwixmobile/webserver/WebServerHelper.java | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index 756c5edef..a8f427220 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -39,9 +39,9 @@ class ServiceModule {
@Provides
@ServiceScope
fun providesWebServerHelper(
- kiwixServer: KiwixServer,
+ kiwixServerFactory: KiwixServer.Factory,
ipAddressCallbacks: IpAddressCallbacks
- ): WebServerHelper = WebServerHelper(kiwixServer, ipAddressCallbacks)
+ ): WebServerHelper = WebServerHelper(kiwixServerFactory, ipAddressCallbacks)
@Provides
@ServiceScope
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
index a8ca3e123..6457ddab6 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt
@@ -28,7 +28,7 @@ private const val TAG = "KiwixServer"
class KiwixServer @Inject constructor(private val jniKiwixServer: JNIKiwixServer) {
- class Factory {
+ class Factory @Inject constructor() {
fun createKiwixServer(selectedBooksPath: ArrayList): KiwixServer {
val kiwixLibrary = Library()
selectedBooksPath.forEach { path ->
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index 9953a9c08..b17322176 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -40,13 +40,14 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
public class WebServerHelper {
private static final String TAG = "WebServerHelper";
private KiwixServer kiwixServer;
+ private KiwixServer.Factory kiwixServerFactory;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
private JNIKiwixServer server;
- @Inject public WebServerHelper(@NonNull KiwixServer kiwixServer,
+ @Inject public WebServerHelper(@NonNull KiwixServer.Factory kiwixServerFactory,
@NonNull IpAddressCallbacks ipAddressCallbacks) {
- this.kiwixServer = kiwixServer;
+ this.kiwixServerFactory = kiwixServerFactory;
this.ipAddressCallbacks = ipAddressCallbacks;
}
@@ -71,8 +72,7 @@ public class WebServerHelper {
if (!isServerStarted) {
int DEFAULT_PORT = 8080;
ServerUtils.port = DEFAULT_PORT;
- KiwixServer.Factory factory = new KiwixServer.Factory();
- kiwixServer = factory.createKiwixServer(selectedBooksPath);
+ kiwixServer = kiwixServerFactory.createKiwixServer(selectedBooksPath);
updateServerState(kiwixServer.startServer(ServerUtils.port));
Log.d(TAG, "Server status" + isServerStarted);
}
From ba14a85bfbfdc6e42d3831f38b3cfb78be808d13 Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Mon, 14 Dec 2020 16:37:57 +0530
Subject: [PATCH 28/34] #2447 Cleaned up Service Module
---
.../org/kiwix/kiwixmobile/di/modules/ServiceModule.kt | 11 -----------
.../kiwix/kiwixmobile/webserver/WebServerHelper.java | 1 -
2 files changed, 12 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
index a8f427220..79db87181 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/di/modules/ServiceModule.kt
@@ -23,8 +23,6 @@ import android.app.Service
import android.content.Context
import dagger.Module
import dagger.Provides
-import org.kiwix.kiwixlib.JNIKiwixServer
-import org.kiwix.kiwixlib.Library
import org.kiwix.kiwixmobile.di.ServiceScope
import org.kiwix.kiwixmobile.webserver.KiwixServer
import org.kiwix.kiwixmobile.webserver.WebServerHelper
@@ -48,15 +46,6 @@ class ServiceModule {
fun providesIpAddressCallbacks(service: Service): IpAddressCallbacks =
service as IpAddressCallbacks
- @Provides
- @ServiceScope
- fun providesLibrary(): Library = Library()
-
- @Provides
- @ServiceScope
- fun providesJNIKiwixServer(jniKiwixLibrary: Library): JNIKiwixServer =
- JNIKiwixServer(jniKiwixLibrary)
-
@Provides
@ServiceScope
fun providesHotspotNotificationManager(
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
index b17322176..319f31339 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
+++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java
@@ -43,7 +43,6 @@ public class WebServerHelper {
private KiwixServer.Factory kiwixServerFactory;
private IpAddressCallbacks ipAddressCallbacks;
private boolean isServerStarted;
- private JNIKiwixServer server;
@Inject public WebServerHelper(@NonNull KiwixServer.Factory kiwixServerFactory,
@NonNull IpAddressCallbacks ipAddressCallbacks) {
From bffc80176fc865afb8a33079ed5a9a1c2ab96ac5 Mon Sep 17 00:00:00 2001
From: "translatewiki.net"
Date: Mon, 14 Dec 2020 15:08:20 +0100
Subject: [PATCH 29/34] Localisation updates from https://translatewiki.net.
---
core/src/main/res/values-ku/strings.xml | 2 +-
core/src/main/res/values-ru/strings.xml | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index bd52efdff..be77c7325 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -248,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
diff --git a/core/src/main/res/values-ru/strings.xml b/core/src/main/res/values-ru/strings.xml
index 66c24436f..ed1ec6b4a 100644
--- a/core/src/main/res/values-ru/strings.xml
+++ b/core/src/main/res/values-ru/strings.xml
@@ -85,6 +85,7 @@
Удалить этот элемент?
Очистить историю
Очистить недавние поисковые запросы и историю вкладок
+ Примечания
Вся история очищена
Очистить закладки
Очистить всю историю?
From a9390b3da93c195529ea3c81a7ab85ebf67b675e Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 15 Dec 2020 08:54:43 +0000
Subject: [PATCH 30/34] lint fix
---
core/src/main/res/values-ku/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/src/main/res/values-ku/strings.xml b/core/src/main/res/values-ku/strings.xml
index be77c7325..bd52efdff 100644
--- a/core/src/main/res/values-ku/strings.xml
+++ b/core/src/main/res/values-ku/strings.xml
@@ -248,7 +248,7 @@
Rewş
Hemû notan ji hemû gotaran bibe
Temamiya notan paqij bike
- Mezinahiya nivîsê bi bilindkirinên 25% biguherîne.
+ Mezinahiya nivîsê bi bilindkirinên 25\% biguherîne.
Wêne
Vîdeo
Tenê Nivîs
From a1932151e78b2376de79776595762128251de663 Mon Sep 17 00:00:00 2001
From: gouri-panda
Date: Tue, 15 Dec 2020 16:06:06 +0530
Subject: [PATCH 31/34] updated contributors list
---
app/src/main/assets/credits.html | 3 +++
custom/src/main/assets/credits.html | 3 +++
2 files changed, 6 insertions(+)
diff --git a/app/src/main/assets/credits.html b/app/src/main/assets/credits.html
index d4f7e78e2..5ccec14f4 100644
--- a/app/src/main/assets/credits.html
+++ b/app/src/main/assets/credits.html
@@ -24,9 +24,12 @@ Abdul Wadood
Adeel Zafar
Aditya Sood
Ayoub Dardory
+Ayush Shrivastava
Christian Pühringer
Elad Keyshawn
Emmanuel Engelhart
+Frans-Lukas Lövenvald
+Gourishankar Panda
Isaac Hutt
Joseph E. Reeve
Julian Harty
diff --git a/custom/src/main/assets/credits.html b/custom/src/main/assets/credits.html
index 01a7dcc37..e84853e6b 100644
--- a/custom/src/main/assets/credits.html
+++ b/custom/src/main/assets/credits.html
@@ -24,9 +24,12 @@
Adeel Zafar
Aditya Sood
Ayoub Dardory
+Ayush Shrivastava
Christian Pühringer
Elad Keyshawn
Emmanuel Engelhart
+Frans-Lukas Lövenvald
+Gourishankar Panda
Isaac Hutt
Joseph E. Reeve
Julian Harty
From f3ce4f9916d09178a238de8723e44807f01aa2fc Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 15 Dec 2020 11:16:37 +0000
Subject: [PATCH 32/34] #2545 New Tabs & recreation is loading home page on
other tabs - simplify tab restoration
---
.../destination/reader/KiwixReaderFragment.kt | 4 ++-
.../core/main/CoreReaderFragment.java | 27 ++++++-------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt
index 408dc7e76..550dd6290 100644
--- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt
+++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt
@@ -251,7 +251,9 @@ class KiwixReaderFragment : CoreReaderFragment() {
val zimFile = settings.getString(TAG_CURRENT_FILE, null)
if (zimFile != null) {
- openZimFile(File(zimFile))
+ if (zimReaderContainer.zimFile == null) {
+ openZimFile(File(zimFile))
+ }
} else {
getCurrentWebView().snack(R.string.zim_not_opened)
}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
index ffbd4c4ab..58450f8d3 100644
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.java
@@ -778,7 +778,7 @@ public abstract class CoreReaderFragment extends BaseFragment
private KiwixWebView newTab(String url, boolean selectTab) {
KiwixWebView webView = initalizeWebView(url);
webViewList.add(webView);
- if(selectTab) {
+ if (selectTab) {
selectTab(webViewList.size() - 1);
}
tabsAdapter.notifyDataSetChanged();
@@ -964,7 +964,6 @@ public abstract class CoreReaderFragment extends BaseFragment
@SuppressWarnings("SameReturnValue")
@OnLongClick(R2.id.bottom_toolbar_bookmark)
boolean goToBookmarks() {
- saveTabStates();
CoreMainActivity parentActivity = (CoreMainActivity) requireActivity();
parentActivity.navigate(parentActivity.getBookmarksFragmentResId());
return true;
@@ -1205,7 +1204,6 @@ public abstract class CoreReaderFragment extends BaseFragment
}
private void goToSearch(boolean isVoice) {
- saveTabStates();
openSearch("", false, isVoice);
}
@@ -1235,7 +1233,6 @@ public abstract class CoreReaderFragment extends BaseFragment
break;
case Intent.ACTION_VIEW:
if (intent.getType() == null || !intent.getType().equals("application/octet-stream")) {
- saveTabStates();
String searchString =
intent.getData() == null ? "" : intent.getData().getLastPathSegment();
openSearch(searchString, false, false);
@@ -1249,7 +1246,6 @@ public abstract class CoreReaderFragment extends BaseFragment
}
private void goToSearchWithText(Intent intent) {
- saveTabStates();
String searchString = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
? intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT)
: "";
@@ -1570,21 +1566,14 @@ public abstract class CoreReaderFragment extends BaseFragment
try {
JSONArray urls = new JSONArray(zimArticles);
JSONArray positions = new JSONArray(zimPositions);
- int i = 0;
- // tabs are already restored if the webViewList includes more tabs than the default
- if (webViewList.size() == 1) {
- getCurrentWebView().setScrollY(positions.getInt(0));
- i++;
- while (i < urls.length()) {
- newTab(UpdateUtils.reformatProviderUrl(urls.getString(i)));
- safelyGetWebView(i).setScrollY(positions.getInt(i));
- i++;
- }
+ webViewList.clear();
+ currentWebViewIndex=0;
+ tabsAdapter.notifyItemRemoved(0);
+ tabsAdapter.notifyDataSetChanged();
+ for (int i = 0; i < urls.length(); i++) {
+ newTab(UpdateUtils.reformatProviderUrl(urls.getString(i)), i == currentTab)
+ .setScrollY(positions.getInt(i));
}
- selectTab(currentTab);
- safelyGetWebView(currentTab)
- .loadUrl(UpdateUtils.reformatProviderUrl(urls.getString(currentTab)));
- getCurrentWebView().setScrollY(positions.getInt(currentTab));
} catch (JSONException e) {
Log.w(TAG_KIWIX, "Kiwix shared preferences corrupted", e);
ContextExtensionsKt.toast(getActivity(), "Could not restore tabs.", Toast.LENGTH_LONG);
From 8816e1136377d73a861d5d4e7ac73860f6c3792a Mon Sep 17 00:00:00 2001
From: Sean Mac Gillicuddy
Date: Tue, 15 Dec 2020 11:43:19 +0000
Subject: [PATCH 33/34] bump version
---
app/build.gradle.kts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 2eb07601a..c29ebf0ff 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -11,7 +11,7 @@ apply(from = rootProject.file("jacoco.gradle"))
ext {
set("versionMajor", 3)
set("versionMinor", 4)
- set("versionPatch", 2)
+ set("versionPatch", 3)
}
fun generateVersionName() = "${ext["versionMajor"]}.${ext["versionMinor"]}.${ext["versionPatch"]}"
From ae549b94f945338029f395d5545ab98cb590d1ac Mon Sep 17 00:00:00 2001
From: s-ayush2903
Date: Tue, 15 Dec 2020 19:09:01 +0530
Subject: [PATCH 34/34] Updated changelog
---
CHANGELOG | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index e0cbe3f8a..193d1b1dd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+3.4.3
+NEW: Updated translations
+BUGFIX: Video seek was not working
+BUGFIX: Back button in history and bookmarks toolbar always took to library
+BUGFIX: Books hosted from android client were not updating on browser dynamically
+BUGFIX: Creating multiple tabs was causing `loading` in previously opened tabs
+BUGFIX: Messages displayed when no books are present were inconsistent typographically
+
3.4.2
NEW: Service worker support for war2c zim files
NEW: Updated translations