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 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"]}" 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/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..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,9 +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 import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotNotificationManager import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotStateReceiver @@ -38,25 +37,15 @@ class ServiceModule { @Provides @ServiceScope fun providesWebServerHelper( - jniKiwixLibrary: Library, - kiwixServer: JNIKiwixServer, + kiwixServerFactory: KiwixServer.Factory, ipAddressCallbacks: IpAddressCallbacks - ): WebServerHelper = WebServerHelper(jniKiwixLibrary, kiwixServer, ipAddressCallbacks) + ): WebServerHelper = WebServerHelper(kiwixServerFactory, ipAddressCallbacks) @Provides @ServiceScope 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/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/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/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..6457ddab6 --- /dev/null +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/KiwixServer.kt @@ -0,0 +1,51 @@ +/* + * 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 android.util.Log +import org.kiwix.kiwixlib.JNIKiwixException +import org.kiwix.kiwixlib.JNIKiwixServer +import org.kiwix.kiwixlib.Library +import javax.inject.Inject + +private const val TAG = "KiwixServer" + +class KiwixServer @Inject constructor(private val jniKiwixServer: JNIKiwixServer) { + + class Factory @Inject constructor() { + 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)) + } + } + + 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 e7a5e2463..319f31339 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java @@ -25,9 +25,7 @@ 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; import org.kiwix.kiwixmobile.webserver.wifi_hotspot.IpAddressCallbacks; @@ -41,15 +39,14 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP; public class WebServerHelper { private static final String TAG = "WebServerHelper"; - private Library kiwixLibrary; - private JNIKiwixServer kiwixServer; + private KiwixServer kiwixServer; + private KiwixServer.Factory kiwixServerFactory; private IpAddressCallbacks ipAddressCallbacks; private boolean isServerStarted; - @Inject public WebServerHelper(@NonNull Library kiwixLibrary, - @NonNull JNIKiwixServer kiwixServer, @NonNull IpAddressCallbacks ipAddressCallbacks) { - this.kiwixLibrary = kiwixLibrary; - this.kiwixServer = kiwixServer; + @Inject public WebServerHelper(@NonNull KiwixServer.Factory kiwixServerFactory, + @NonNull IpAddressCallbacks ipAddressCallbacks) { + this.kiwixServerFactory = kiwixServerFactory; this.ipAddressCallbacks = ipAddressCallbacks; } @@ -65,7 +62,7 @@ public class WebServerHelper { public void stopAndroidWebServer() { if (isServerStarted) { - kiwixServer.stop(); + kiwixServer.stopServer(); updateServerState(false); } } @@ -74,17 +71,9 @@ public class WebServerHelper { if (!isServerStarted) { int DEFAULT_PORT = 8080; ServerUtils.port = DEFAULT_PORT; - for (String path : selectedBooksPath) { - try { - boolean isBookAdded = kiwixLibrary.addBook(path); - Log.v(TAG, "isBookAdded: " + isBookAdded + path); - } catch (JNIKiwixException e) { - Log.v(TAG, "Couldn't add book " + path); - } - } - kiwixServer.setPort(ServerUtils.port); - updateServerState(kiwixServer.start()); - Log.v(TAG, "Server status" + isServerStarted); + kiwixServer = kiwixServerFactory.createKiwixServer(selectedBooksPath); + updateServerState(kiwixServer.startServer(ServerUtils.port)); + Log.d(TAG, "Server status" + isServerStarted); } return isServerStarted; } 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" />