Skip to content

Commit

Permalink
Merge pull request #3546 from kiwix/develop
Browse files Browse the repository at this point in the history
3.8.0 code patch
  • Loading branch information
kelson42 committed Nov 22, 2023
2 parents d828f52 + 0dac73c commit 4929c5a
Show file tree
Hide file tree
Showing 280 changed files with 5,921 additions and 1,967 deletions.
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Static Analysis
run: ./gradlew detekt
run: ./gradlew detektDebug detektCustomExampleDebug
- name: Upload Lint Reports
uses: actions/upload-artifact@v3
if: ${{ always() }}
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
3.8.0
New Features:
* Download pause/resume feature. (https://github.com/kiwix/kiwix-android/pull/3459)
* Added support to read ZIM files from USB-OTG stick. (https://github.com/kiwix/kiwix-android/pull/3471)
* Endless suggestion list while searching articles. (https://github.com/kiwix/kiwix-android/pull/3217)
* Refactored LocalFileTransfer UI to educate users on how to use this feature. (https://github.com/kiwix/kiwix-android/pull/3497)

Bug Fixes:
* All books notes switch is always enabled. (https://github.com/kiwix/kiwix-android/pull/3449)
* Download remained pending indefinitely if we canceled it from the notification. (https://github.com/kiwix/kiwix-android/pull/3451)
* Enhanced permission asking scenario for custom apps. (https://github.com/kiwix/kiwix-android/pull/3439)
* If the storage is already configured, it was again showing while downloading. (https://github.com/kiwix/kiwix-android/pull/3464)
* The keyboard repeatedly disappears and reappears while searching articles. (https://github.com/kiwix/kiwix-android/pull/3469)
* Bookmark toggle is not ON for saved bookmarks. (https://github.com/kiwix/kiwix-android/pull/3473)
* Article opening after search page result leads to a blank page. (https://github.com/kiwix/kiwix-android/pull/3217)
* Random article function not working. (https://github.com/kiwix/kiwix-android/pull/3217)
* 500 Error happens on the server. (https://github.com/kiwix/kiwix-android/pull/3217)
* Unable to open the support link with the default browser. (https://github.com/kiwix/kiwix-android/pull/3504)
* Unable to upload APK on the play store. (https://github.com/kiwix/kiwix-android/pull/3506)
* Hosted Books don't update on Application. (https://github.com/kiwix/kiwix-android/pull/3218)
* Cannot open ZIM files from phone storage via the file picker in Android 13. (https://github.com/kiwix/kiwix-android/pull/3518)
* The redundancy of the 'All-Books-Mode' option for Bookmarks, Notes, and History in custom apps. (https://github.com/kiwix/kiwix-android/pull/3525)
* The same Note saves multiple times while we are updating existing notes. (https://github.com/kiwix/kiwix-android/issues/3519)
* Reduced mass-storage consumption with Android custom apps with embedded ZIM. (https://github.com/kiwix/kiwix-android/pull/3516)
* Hitting back in the custom apps exits it. (https://github.com/kiwix/kiwix-android/pull/3512)
* Multiple memory leaks
* Updated README file to show file picker restriction. (https://github.com/kiwix/kiwix-android/pull/3414)
+ More

Compilation/CI/CD:
* Adapted libkiwix `1.0.0`. (https://github.com/kiwix/kiwix-android/pull/3217)
* Deprecated code check in CI. (https://github.com/kiwix/kiwix-android/pull/3440)
* Added/improved test cases.

3.7.1
* FIX: Useless permission request at start for custom apps
* FIX: Few code deprecations
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,30 @@ 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)).

**Important Note**: Starting from Android 11, the ZIM file picker
feature has been restricted in the Play Store variant due to Play
Store policies. This means that users running Android 11 and above
will not be able to load ZIM files from internal/external storage
directly within the app if they have downloaded Kiwix from the Google
Play Store. This restriction is in place to comply with the Play
Store policies. The Play Store variant of Kiwix does not require the
`MANAGE_EXTERNAL_STORAGE` permission anymore, which is necessary to
scan storage and access ZIM files at arbitrary locations. Therefore,
the storage scanning & file picking functionalities are not available
in this variant anymore. To use the full version of Kiwix and benefit
of the ZIM file picker feature, you can download it directly from the
[official
repository](https://download.kiwix.org/release/kiwix-android/) or use
[F-Droid](https://fdroid.kiwix.org). We understand that this
restriction may cause inconvenience, but it is necessary to comply
with the Play Store policies and ensure a smooth user experience. We
recommend using the official version of the app available on our
website to access the complete set of features.

Kiwix Android is written in [Kotlin](https://kotlinlang.org/)

[![Build Status](https://github.com/kiwix/kiwix-android/workflows/CI/badge.svg?query=branch%3Adevelop+workflow%3ANightly)](https://github.com/kiwix/kiwix-android/actions?query=workflow%3ACI+branch%3Adevelop)
Expand All @@ -43,13 +63,14 @@ 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
- [Butterknife](https://jakewharton.github.io/butterknife/) - View "injection" library for Android
- [Mockito](https://github.com/mockito/mockito) - Most popular Mocking framework for unit tests written in Java
- [RxJava](https://github.com/ReactiveX/RxJava) - Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
- [ObjectBox](https://github.com/objectbox/objectbox-java) - Reactive NoSQL Databse
- [ObjectBox](https://github.com/objectbox/objectbox-java) - Reactive NoSQL Database
- [MockK](https://github.com/mockk/mockk) - Kotlin mocking library that allows mocking of final classes by default.
- [JUnit5](https://github.com/junit-team/junit5/) - The next generation of JUnit
- [AssertJ](https://github.com/joel-costigliola/assertj-core) - Fluent assertions for test code
Expand Down
16 changes: 5 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ plugins.apply(KiwixConfigurationPlugin::class)

apply(from = rootProject.file("jacoco.gradle"))

ext {
set("versionMajor", 3)
set("versionMinor", 7)
set("versionPatch", 1)
}

fun generateVersionName() = "${ext["versionMajor"]}.${ext["versionMinor"]}.${ext["versionPatch"]}"
fun generateVersionName() = "${Config.versionMajor}.${Config.versionMinor}.${Config.versionPatch}"

/*
* max version code: 21-0-0-00-00-00
Expand All @@ -30,9 +24,9 @@ fun generateVersionName() = "${ext["versionMajor"]}.${ext["versionMinor"]}.${ext

fun generateVersionCode() =
20 * 10000 +
ext["versionMajor"] as Int * 10000 +
ext["versionMinor"] as Int * 100 +
ext["versionPatch"] as Int
Config.versionMajor * 10000 +
Config.versionMinor * 100 +
Config.versionPatch

val apkPrefix get() = System.getenv("TAG") ?: "kiwix"

Expand Down Expand Up @@ -73,7 +67,7 @@ android {
}
create("nightly") {
initWith(getByName("debug"))
setMatchingFallbacks("debug")
matchingFallbacks += "debug"
}
}
bundle {
Expand Down
7 changes: 2 additions & 5 deletions app/detekt_baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<ID>MagicNumber:ShareFiles.kt$ShareFiles$24</ID>
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$5</ID>
<ID>MagicNumber:ZimManageViewModel.kt$ZimManageViewModel$500</ID>
<ID>NestedBlockDepth:LocalLibraryFragment.kt$LocalLibraryFragment$private fun checkPermissions()</ID>
<ID>MagicNumber:LocalFileTransferFragment.kt$LocalFileTransferFragment$500</ID>
<ID>NestedBlockDepth:LocalLibraryFragment.kt$LocalLibraryFragment$private fun checkManageExternalStoragePermission()</ID>
<ID>NestedBlockDepth:PeerGroupHandshake.kt$PeerGroupHandshake$private fun readHandshakeAndExchangeMetaData(): InetAddress?</ID>
<ID>NestedBlockDepth:ReceiverHandShake.kt$ReceiverHandShake$override fun exchangeFileTransferMetadata(inputStream: InputStream, outputStream: OutputStream)</ID>
<ID>PackageNaming:AvailableSpaceCalculator.kt$package
Expand All @@ -25,10 +26,6 @@
org.kiwix.kiwixmobile.zimManager.fileselectView</ID>
<ID>PackageNaming:FileSystemChecker.kt$package org.kiwix.kiwixmobile.zimManager</ID>
<ID>PackageNaming:FileWritingFileSystemChecker.kt$package org.kiwix.kiwixmobile.zimManager</ID>
<ID>PackageNaming:HotspotNotificationManager.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
<ID>PackageNaming:HotspotStateReceiver.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
<ID>PackageNaming:IpAddressCallbacks.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
<ID>PackageNaming:HotspotService.kt$package org.kiwix.kiwixmobile.webserver.wifi_hotspot</ID>
<ID>PackageNaming:LibraryAdapter.kt$package
org.kiwix.kiwixmobile.zimManager.libraryView.adapter</ID>
<ID>PackageNaming:LibraryDelegate.kt$package
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 @@ -20,7 +20,7 @@ package org.kiwix.kiwixmobile

import android.Manifest.permission
import android.content.Context
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 @@ -32,16 +32,16 @@ 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>

@get:Rule
var readPermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(permission.READ_EXTERNAL_STORAGE)
private val permissions = arrayOf(
permission.READ_EXTERNAL_STORAGE,
permission.WRITE_EXTERNAL_STORAGE
)

@get:Rule
var writePermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(permission.WRITE_EXTERNAL_STORAGE)
var permissionRules: GrantPermissionRule =
GrantPermissionRule.grant(*permissions)

val context: Context by lazy {
getInstrumentation().targetContext.applicationContext
Expand Down
22 changes: 8 additions & 14 deletions app/src/androidTest/java/org/kiwix/kiwixmobile/NetworkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package org.kiwix.kiwixmobile

import android.Manifest
import android.util.Log
import androidx.test.InstrumentationRegistry
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso
import androidx.test.espresso.IdlingPolicies
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.interaction.BaristaDialogInteractions
Expand Down Expand Up @@ -57,21 +57,15 @@ class NetworkTest {
// @Inject
// MockWebServer mockWebServer

@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(
KiwixMainActivity::class.java, false, false
private val permissions = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)

@Rule
@JvmField
var readPermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE)

@Rule
@JvmField
var writePermissionRule: GrantPermissionRule =
GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE)
var permissionRules: GrantPermissionRule =
GrantPermissionRule.grant(*permissions)

@Before fun setUp() {
val component = DaggerTestComponent.builder().context(
Expand Down Expand Up @@ -99,7 +93,7 @@ class NetworkTest {

@Test @Ignore("Broken in 2.5") // TODO Fix in 3.0
fun networkTest() {
mActivityTestRule.launchActivity(null)
ActivityScenario.launch(KiwixMainActivity::class.java)
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
clickMenu(TestUtils.getResourceString(R.string.library))
TestUtils.allowStoragePermissionsIfNeeded()
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 @@ -61,10 +61,12 @@ class DownloadRobot : BaseRobot() {
}

private fun assertDeleteDialogDisplayed() {
pauseForBetterTestPerformance()
onView(withText("DELETE")).check(matches(isDisplayed()))
}

private fun clickOnDeleteZimFile() {
pauseForBetterTestPerformance()
onView(withText("DELETE")).perform(click())
}

Expand All @@ -73,9 +75,8 @@ class DownloadRobot : BaseRobot() {
longClickOnZimFile()
clickOnFileDeleteIcon()
assertDeleteDialogDisplayed()
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
clickOnDeleteZimFile()
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
pauseForBetterTestPerformance()
} catch (e: Exception) {
if (shouldDeleteZimFile) {
throw Exception(
Expand Down Expand Up @@ -122,6 +123,28 @@ class DownloadRobot : BaseRobot() {
}
}

private fun stopDownload() {
clickOn(ViewId(R.id.stop))
}

fun pauseDownload() {
clickOn(ViewId(R.id.pauseResume))
}

fun assertDownloadPaused() {
pauseForBetterTestPerformance()
onView(withText(org.kiwix.kiwixmobile.core.R.string.paused_state)).check(matches(isDisplayed()))
}

fun resumeDownload() {
pauseDownload()
}

fun assertDownloadResumed() {
pauseForBetterTestPerformance()
onView(withText(org.kiwix.kiwixmobile.core.R.string.paused_state)).check(doesNotExist())
}

fun waitUntilDownloadComplete() {
try {
onView(withId(R.id.stop)).check(doesNotExist())
Expand All @@ -132,4 +155,34 @@ class DownloadRobot : BaseRobot() {
waitUntilDownloadComplete()
}
}

private fun pauseForBetterTestPerformance() {
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS.toLong())
}

private fun assertStopDownloadDialogDisplayed() {
pauseForBetterTestPerformance()
isVisible(Text("Stop download?"))
}

private fun clickOnYesButton() {
onView(withText("YES")).perform(click())
}

fun stopDownloadIfAlreadyStarted() {
try {
pauseForBetterTestPerformance()
onView(withId(R.id.stop)).check(matches(isDisplayed()))
stopDownload()
assertStopDownloadDialogDisplayed()
clickOnYesButton()
pauseForBetterTestPerformance()
} catch (e: Exception) {
Log.i(
"DOWNLOAD_TEST",
"Failed to stop download with title [" + zimFileTitle + "]... " +
"Probably because it doesn't download the zim file"
)
}
}
}
Loading

0 comments on commit 4929c5a

Please sign in to comment.