Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d62d439
Refactored the code to support the java-libkiwix 11.0.0
MohitMaliDeveloper Jul 13, 2023
64f2620
Changes to support libkiwix 11.0.0 wrapper * Get correct zim file tit…
MohitMaliDeveloper Jul 14, 2023
3e59e97
Refactoring the search functionality to support the latest wrapper
MohitMaliDeveloper Jul 14, 2023
a1ee8be
Fixed zim file size issue in library section
MohitMaliDeveloper Jul 17, 2023
161337a
Start using libkiwix 11.0.0 from maven, loading wrappers .so files fo…
MohitMaliDeveloper Jul 17, 2023
384bacc
Refactored code to safely get the metadata of zim files
MohitMaliDeveloper Jul 17, 2023
e69499f
Removed the relinker dependency from the project, since now we are lo…
Jul 22, 2023
75fab06
Refactored search functionality according to the new wrapper
MohitMaliDeveloper Jul 24, 2023
bbd23d1
Fixed loading content which contains a query params, mostly this fix …
MohitMaliDeveloper Jul 25, 2023
6e0336e
Using newly published 'libkiwix 1.0.0' from maven
MohitMaliDeveloper Jul 25, 2023
02a6d0f
Fix the instrumentation test cases
MohitMaliDeveloper Jul 26, 2023
e363889
Fixed search functionality crash if any FT Xapian index not found in …
MohitMaliDeveloper Jul 26, 2023
46d4aeb
Refactored SearchFragmentTest
MohitMaliDeveloper Jul 26, 2023
d188a82
Improved search functionality
MohitMaliDeveloper Jul 27, 2023
f7517a2
Minimum SDK version changed to 24: The NDK version in kiwix-build has…
MohitMaliDeveloper Jul 27, 2023
632bb4a
Refactored code to remove lint errors
MohitMaliDeveloper Aug 7, 2023
3e40c09
Refactored ci to support minimum api level 24
MohitMaliDeveloper Jul 27, 2023
69982e9
Fixed ZimMangeViewModelTest
MohitMaliDeveloper Jul 28, 2023
adea940
Introduced an endless suggestion list in search.
MohitMaliDeveloper Aug 1, 2023
3edfd88
Updated test cases to accommodate the new search functionality.
MohitMaliDeveloper Aug 1, 2023
dd1ae68
Fixed duplicate searched items are showing
MohitMaliDeveloper Aug 1, 2023
376776c
Imrpvoed pagination search, avoid loading unnecessary data when user …
MohitMaliDeveloper Aug 2, 2023
ac78a67
Improved the code, removed unnecessary parentheses
MohitMaliDeveloper Aug 2, 2023
f29be04
Improved article loading.
MohitMaliDeveloper Aug 2, 2023
ed237a4
Keep everything in `libkiwix/libzim` in release variant.
MohitMaliDeveloper Aug 7, 2023
51ef8af
Use `SuggestionSearch` instead of `Search` for better search function…
MohitMaliDeveloper Aug 8, 2023
4f2b54e
Improved `SearchFragmentTest`:
MohitMaliDeveloper Aug 8, 2023
609e9e2
Improved 'Search' Functionality:
MohitMaliDeveloper Aug 9, 2023
f1889ee
Fixed bugs and enhanced search functionality.
MohitMaliDeveloper Aug 10, 2023
ad81bbd
Fixed server crashing issue when we open it on web browser
MohitMaliDeveloper Aug 15, 2023
644521c
Add library dependence libkiiwx to the README
kelson42 Aug 28, 2023
fff9196
Started using new `libkiwix` from new maven repo `org.kiwix/libkiwix`.
MohitMaliDeveloper Aug 28, 2023
1281c0c
Improved test cases and fixed memory leak in application.
MohitMaliDeveloper Aug 29, 2023
221f84b
Improved the "load more" functionality for search and introduced seve…
Sep 15, 2023
ec007e4
Moved the load more data logic to SearchViewModel class to manage sep…
MohitMaliDeveloper Sep 18, 2023
9ff91ba
Remove the unnecessary `SearchState` object since we no longer need i…
MohitMaliDeveloper Sep 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Automated tests
strategy:
matrix:
api-level: [ 21, 30, 33 ]
api-level: [ 24, 30, 33 ]
fail-fast: false
runs-on: macos-11
steps:
Expand Down Expand Up @@ -79,16 +79,16 @@ jobs:
path: screencap.png

- name: create unit coverage
if: ${{ matrix.api-level==21 }}
if: ${{ matrix.api-level==24 }}
run: ./gradlew testDebugUnitTest testCustomexampleDebugUnitTest

- name: Upload coverage to Codecov
if: ${{ matrix.api-level==21 }}
if: ${{ matrix.api-level==24 }}
uses: codecov/codecov-action@v3

- name: Upload Coverage to GH-Actions
uses: actions/upload-artifact@v3
if: ${{ matrix.api-level==21 }}
if: ${{ matrix.api-level==24 }}
with:
name: Tests Coverage Report
path: |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ is to make Wikipedia available offline. This is done by reading the
content of a file in the ZIM format, a highly compressed open format
with additional metadata.

This is the version for Android, with support versions ranging from 5
This is the version for Android, with support versions ranging from 7
to 13 (like [mentioned
here](https://github.com/kiwix/kiwix-android/blob/develop/buildSrc/src/main/kotlin/Config.kt)).

Expand Down Expand Up @@ -63,6 +63,7 @@ If you are interested in our custom apps they have their own repo [kiwix-android

## Libraries Used

- [Libkiwix](https://github.com/kiwix/java-libkiwix) - Kotlin/Java binding for the core Kiwix library
- [Dagger 2](https://github.com/google/dagger) - A fast dependency injector for Android and Java
- [Retrofit](https://square.github.io/retrofit/) - Retrofit turns your REST API into a Java interface
- [OkHttp](https://github.com/square/okhttp) - An HTTP+SPDY client for Android and Java applications
Expand Down
7 changes: 5 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@

-keepclassmembers class org.kiwix.videowebview.VideoEnabledWebView$JavascriptInterface { public *; }

#keep everything in kiwixlib
-keep class org.kiwix.kiwixlib.** { *; }
#keep everything in libkiwix
-keep class org.kiwix.libkiwix.** { *; }

#keep everything in libzim
-keep class org.kiwix.libzim.** { *; }

## SimpleXml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.kiwix.kiwixmobile
import android.Manifest.permission
import android.content.Context
import android.os.Build
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.rule.GrantPermissionRule
Expand All @@ -33,8 +33,7 @@ import org.kiwix.kiwixmobile.main.KiwixMainActivity

@RunWith(AndroidJUnit4::class)
abstract class BaseActivityTest {
@get:Rule
open var activityScenarioRule = ActivityScenarioRule(KiwixMainActivity::class.java)
open lateinit var activityScenario: ActivityScenario<KiwixMainActivity>

private val permissions = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
arrayOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.kiwix.kiwixmobile.core.di.modules
import dagger.Module
import dagger.Provides
import io.mockk.mockk
import org.kiwix.kiwixlib.JNIKiwix
import org.kiwix.libkiwix.JNIKiwix
import javax.inject.Singleton

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.kiwix.kiwixmobile.download

import android.util.Log
import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.IdlingPolicies
Expand Down Expand Up @@ -73,11 +74,13 @@ class DownloadTest : BaseActivityTest() {
putBoolean(SharedPreferenceUtil.IS_PLAY_STORE_BUILD, true)
putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun downloadTest() {
ActivityScenario.launch(KiwixMainActivity::class.java)
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
try {
downloadRobot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.kiwix.kiwixmobile.help

import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import leakcanary.LeakAssertions
Expand All @@ -25,6 +27,7 @@ import org.junit.Rule
import org.junit.Test
import org.kiwix.kiwixmobile.BaseActivityTest
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.testutils.RetryRule
import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs
import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible
Expand All @@ -39,6 +42,9 @@ class HelpFragmentTest : BaseActivityTest() {
}
waitForIdle()
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Rule
Expand All @@ -47,7 +53,7 @@ class HelpFragmentTest : BaseActivityTest() {

@Test
fun verifyHelpActivity() {
activityScenarioRule.scenario.onActivity {
activityScenario.onActivity {
it.navigate(R.id.helpFragment)
}
help {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.kiwix.kiwixmobile.initial.download

import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -63,11 +64,13 @@ class InitialDownloadTest : BaseActivityTest() {
putBoolean(SharedPreferenceUtil.IS_PLAY_STORE_BUILD, true)
putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun initialDownloadTest() {
ActivityScenario.launch(KiwixMainActivity::class.java)
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
initialDownload {
clickLibraryOnBottomNav()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package org.kiwix.kiwixmobile.intro

import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import leakcanary.LeakAssertions
Expand All @@ -28,6 +30,7 @@ import org.junit.Test
import org.kiwix.kiwixmobile.BaseActivityTest
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.testutils.RetryRule
import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs
import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible
Expand All @@ -40,7 +43,7 @@ class IntroFragmentTest : BaseActivityTest() {

@Test
fun viewIsSwipeableAndNavigatesToMain() {
activityScenarioRule.scenario.onActivity {
activityScenario.onActivity {
it.navigate(R.id.introFragment)
}
intro(IntroRobot::swipeLeft) clickGetStarted {}
Expand All @@ -58,5 +61,8 @@ class IntroFragmentTest : BaseActivityTest() {
PreferenceManager.getDefaultSharedPreferences(context).edit {
putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, true)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.kiwix.kiwixmobile.main

import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
Expand Down Expand Up @@ -59,11 +60,13 @@ class TopLevelDestinationTest : BaseActivityTest() {
putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true)
putBoolean(SharedPreferenceUtil.PREF_EXTERNAL_LINK_POPUP, true)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun testTopLevelDestination() {
ActivityScenario.launch(KiwixMainActivity::class.java)
topLevel {
clickReaderOnBottomNav {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
package org.kiwix.kiwixmobile.mimetype

import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.kiwix.kiwixlib.JNIKiwixReader
import org.kiwix.libzim.Archive
import org.kiwix.kiwixmobile.BaseActivityTest
import org.kiwix.kiwixmobile.core.NightModeConfig
import org.kiwix.kiwixmobile.core.reader.ZimFileReader
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs
import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible
import java.io.File
Expand All @@ -50,6 +53,9 @@ class MimeTypeTest : BaseActivityTest() {
putBoolean(SharedPreferenceUtil.PREF_SHOW_INTRO, false)
putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
Expand All @@ -70,23 +76,32 @@ class MimeTypeTest : BaseActivityTest() {
}
val zimFileReader = ZimFileReader(
zimFile,
JNIKiwixReader(zimFile.canonicalPath),
Archive(zimFile.canonicalPath),
Comment on lines -73 to +79
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Archive do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gouri-panda Here Archive works like Reader we were previously using, it has all the data about the Zim file e.g. illustration, metadata, main page entry etc. you can see all methods of Archive class here https://github.com/kiwix/java-libkiwix/blob/main/lib/src/main/java/org/kiwix/libzim/Archive.java

NightModeConfig(SharedPreferenceUtil(context), context)
)
zimFileReader.getRandomArticleUrl()?.let {
val mimeType = zimFileReader.readContentAndMimeType(it)
if (mimeType.contains("^([^ ]+).*$") || mimeType.contains(";")) {
val mimeType = zimFileReader.getMimeTypeFromUrl(it)
if (mimeType?.contains("^([^ ]+).*$") == true || mimeType?.contains(";") == true) {
Assert.fail(
"Unable to get mime type from zim file. File = " +
" $zimFile and url of article = $it"
)
}
}.also {
zimFileReader.dispose()
} ?: kotlin.run {
Assert.fail("Unable to get article from zim file $zimFile")
}.also {
zimFileReader.dispose()
}
// test mimetypes for some actual url
Assert.assertEquals(
"text/html",
zimFileReader.getMimeTypeFromUrl("https://kiwix.app/A/index.html")
)
Assert.assertEquals(
"text/css",
zimFileReader.getMimeTypeFromUrl("https://kiwix.app/-/assets/style1.css")
)
// test mimetype for invalid url
Assert.assertEquals(null, zimFileReader.getMimeTypeFromUrl("https://kiwix.app/A/test.html"))
// dispose the ZimFileReader
zimFileReader.dispose()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.nav.destination.library

import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
Expand Down Expand Up @@ -65,11 +66,14 @@ class LocalLibraryTest : BaseActivityTest() {
// manage external storage permission dialog on android 11 and above
putBoolean(SharedPreferenceUtil.PREF_MANAGE_EXTERNAL_FILES, false)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun testLocalLibrary() {
ActivityScenario.launch(KiwixMainActivity::class.java).onActivity {
activityScenario.onActivity {
it.navigate(R.id.libraryFragment)
}
library {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.kiwix.kiwixmobile.note

import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import leakcanary.LeakAssertions
Expand All @@ -26,6 +28,7 @@ import org.junit.Rule
import org.junit.Test
import org.kiwix.kiwixmobile.BaseActivityTest
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.main.KiwixMainActivity
import org.kiwix.kiwixmobile.testutils.RetryRule
import org.kiwix.kiwixmobile.testutils.TestUtils.closeSystemDialogs
import org.kiwix.kiwixmobile.testutils.TestUtils.isSystemUINotRespondingDialogVisible
Expand All @@ -44,11 +47,14 @@ class NoteFragmentTest : BaseActivityTest() {
}
waitForIdle()
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun verifyNoteFragment() {
activityScenarioRule.scenario.onActivity {
activityScenario.onActivity {
it.navigate(R.id.notesFragment)
}
note {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.page.history

import androidx.core.content.edit
import androidx.core.net.toUri
import androidx.lifecycle.Lifecycle
import androidx.preference.PreferenceManager
import androidx.test.core.app.ActivityScenario
import androidx.test.internal.runner.junit4.statement.UiThreadStatement
Expand Down Expand Up @@ -63,11 +64,14 @@ class NavigationHistoryTest : BaseActivityTest() {
putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false)
putBoolean(SharedPreferenceUtil.PREF_IS_TEST, true)
}
activityScenario = ActivityScenario.launch(KiwixMainActivity::class.java).apply {
moveToState(Lifecycle.State.RESUMED)
}
}

@Test
fun navigationHistoryDialogTest() {
ActivityScenario.launch(KiwixMainActivity::class.java).onActivity {
activityScenario.onActivity {
kiwixMainActivity = it
kiwixMainActivity.navigate(R.id.libraryFragment)
}
Expand Down
Loading