mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 02:36:24 -04:00
Updated minimum SDK version to 25.
* Updated the `README.md` file for this new change. * Removed the API level 24 from CI and added the API level 25 since now our minimum SDK version is 25. * Renamed CompatV24 file since we have upgraded the minimum SDK version so this fileName was irrelevant.
This commit is contained in:
parent
c03c376ea1
commit
34928323d5
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
name: Automated tests
|
name: Automated tests
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
api-level: [ 24, 30, 33 ]
|
api-level: [ 25, 30, 33 ]
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
@ -65,7 +65,7 @@ jobs:
|
|||||||
sdcard-path-or-size: 2048M
|
sdcard-path-or-size: 2048M
|
||||||
cores: 4
|
cores: 4
|
||||||
disable-animations: false
|
disable-animations: false
|
||||||
heap-size: ${{ matrix.api-level != 24 && '512M' || '' }}
|
heap-size: ${{ matrix.api-level != 25 && '512M' || '' }}
|
||||||
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
||||||
channel: canary
|
channel: canary
|
||||||
script: echo "Generated AVD snapshot for caching."
|
script: echo "Generated AVD snapshot for caching."
|
||||||
@ -85,7 +85,7 @@ jobs:
|
|||||||
force-avd-creation: false
|
force-avd-creation: false
|
||||||
sdcard-path-or-size: 2048M
|
sdcard-path-or-size: 2048M
|
||||||
disable-animations: true
|
disable-animations: true
|
||||||
heap-size: ${{ matrix.api-level != 24 && '512M' || '' }}
|
heap-size: ${{ matrix.api-level != 25 && '512M' || '' }}
|
||||||
channel: canary
|
channel: canary
|
||||||
script: bash contrib/instrumentation.sh
|
script: bash contrib/instrumentation.sh
|
||||||
|
|
||||||
@ -98,18 +98,18 @@ jobs:
|
|||||||
path: screencap.png
|
path: screencap.png
|
||||||
|
|
||||||
- name: create unit coverage
|
- name: create unit coverage
|
||||||
if: ${{ matrix.api-level==24 }}
|
if: ${{ matrix.api-level==25 }}
|
||||||
run: ./gradlew testDebugUnitTest testCustomexampleDebugUnitTest
|
run: ./gradlew testDebugUnitTest testCustomexampleDebugUnitTest
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
if: ${{ matrix.api-level==24 }}
|
if: ${{ matrix.api-level==25 }}
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
- name: Upload Coverage to GH-Actions
|
- name: Upload Coverage to GH-Actions
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
if: ${{ matrix.api-level==24 }}
|
if: ${{ matrix.api-level==25 }}
|
||||||
with:
|
with:
|
||||||
name: Tests Coverage Report
|
name: Tests Coverage Report
|
||||||
path: |
|
path: |
|
||||||
|
@ -14,7 +14,7 @@ offline. This is achieved by reading the content of a file in the
|
|||||||
[ZIM](https://openzim.org) format, a highly compressed open format
|
[ZIM](https://openzim.org) format, a highly compressed open format
|
||||||
with additional metadata.
|
with additional metadata.
|
||||||
|
|
||||||
This is the version for Android, with [support versions ranging from 7
|
This is the version for Android, with [support versions ranging from 7.1
|
||||||
to 13](https://github.com/kiwix/kiwix-android/blob/main/buildSrc/src/main/kotlin/Config.kt).
|
to 13](https://github.com/kiwix/kiwix-android/blob/main/buildSrc/src/main/kotlin/Config.kt).
|
||||||
|
|
||||||
**Important Note**: Starting from Android 11, the ZIM file picker
|
**Important Note**: Starting from Android 11, the ZIM file picker
|
||||||
|
@ -23,7 +23,7 @@ object Config {
|
|||||||
// Here is a list of all Android versions with their corresponding API
|
// Here is a list of all Android versions with their corresponding API
|
||||||
// levels: https://apilevels.com/
|
// levels: https://apilevels.com/
|
||||||
const val compileSdk = 33 // SDK version used by Gradle to compile our app.
|
const val compileSdk = 33 // SDK version used by Gradle to compile our app.
|
||||||
const val minSdk = 24 // Minimum SDK (Minimum Support Device) is 24 (Android 7.0 Nougat).
|
const val minSdk = 25 // Minimum SDK (Minimum Support Device) is 25 (Android 7.1 Nougat).
|
||||||
const val targetSdk = 33 // Target SDK (Maximum Support Device) is 33 (Android 13).
|
const val targetSdk = 33 // Target SDK (Maximum Support Device) is 33 (Android 13).
|
||||||
|
|
||||||
val javaVersion = JavaVersion.VERSION_1_8
|
val javaVersion = JavaVersion.VERSION_1_8
|
||||||
|
@ -32,7 +32,7 @@ import android.net.ConnectivityManager
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Each implementation ends with a `V<n>` suffix, identifying the minimum API version on which this implementation
|
* Each implementation ends with a `V<n>` suffix, identifying the minimum API version on which this implementation
|
||||||
* can be used. For example, see [CompatV24].
|
* can be used. For example, see [CompatV25].
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Each implementation `CompatVn` should extend the implementation `CompatVm` for the greatest m<n such that `CompatVm`
|
* Each implementation `CompatVn` should extend the implementation `CompatVm` for the greatest m<n such that `CompatVm`
|
||||||
|
@ -29,7 +29,7 @@ class CompatHelper private constructor() {
|
|||||||
// Note: Needs ": Compat" or the type system assumes `Compat21`
|
// Note: Needs ": Compat" or the type system assumes `Compat21`
|
||||||
private val compatValue: Compat = when {
|
private val compatValue: Compat = when {
|
||||||
sdkVersion >= Build.VERSION_CODES.TIRAMISU -> CompatV33()
|
sdkVersion >= Build.VERSION_CODES.TIRAMISU -> CompatV33()
|
||||||
else -> CompatV24()
|
else -> CompatV25()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -27,7 +27,7 @@ import android.net.ConnectivityManager
|
|||||||
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET
|
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET
|
||||||
import android.net.NetworkCapabilities.TRANSPORT_WIFI
|
import android.net.NetworkCapabilities.TRANSPORT_WIFI
|
||||||
|
|
||||||
open class CompatV24 : Compat {
|
open class CompatV25 : Compat {
|
||||||
|
|
||||||
override fun queryIntentActivities(
|
override fun queryIntentActivities(
|
||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
@ -30,7 +30,7 @@ const val API_33 = 33
|
|||||||
|
|
||||||
@TargetApi(API_33)
|
@TargetApi(API_33)
|
||||||
open class CompatV33 : Compat {
|
open class CompatV33 : Compat {
|
||||||
private val compatV24 = CompatV24()
|
private val compatV25 = CompatV25()
|
||||||
override fun queryIntentActivities(
|
override fun queryIntentActivities(
|
||||||
packageManager: PackageManager,
|
packageManager: PackageManager,
|
||||||
intent: Intent,
|
intent: Intent,
|
||||||
@ -48,8 +48,8 @@ open class CompatV33 : Compat {
|
|||||||
packageManager.getPackageInfo(packageName, PackageInfoFlags.of(flag.toLong()))
|
packageManager.getPackageInfo(packageName, PackageInfoFlags.of(flag.toLong()))
|
||||||
|
|
||||||
override fun isNetworkAvailable(connectivity: ConnectivityManager): Boolean =
|
override fun isNetworkAvailable(connectivity: ConnectivityManager): Boolean =
|
||||||
compatV24.isNetworkAvailable(connectivity)
|
compatV25.isNetworkAvailable(connectivity)
|
||||||
|
|
||||||
override fun isWifi(connectivity: ConnectivityManager): Boolean =
|
override fun isWifi(connectivity: ConnectivityManager): Boolean =
|
||||||
compatV24.isWifi(connectivity)
|
compatV25.isWifi(connectivity)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import org.junit.Assert.assertFalse
|
|||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.compat.CompatV24
|
import org.kiwix.kiwixmobile.core.compat.CompatV25
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
class NetworkUtilsTest {
|
class NetworkUtilsTest {
|
||||||
@ -43,43 +43,43 @@ class NetworkUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testNetworkAvailability_CompatV24() {
|
fun testNetworkAvailability_CompatV24() {
|
||||||
every { context.getSystemService(Context.CONNECTIVITY_SERVICE) } returns connectivity
|
every { context.getSystemService(Context.CONNECTIVITY_SERVICE) } returns connectivity
|
||||||
val compatV23 = CompatV24()
|
val compatV25 = CompatV25()
|
||||||
val network: Network = mockk()
|
val network: Network = mockk()
|
||||||
|
|
||||||
every { connectivity.activeNetwork } returns network
|
every { connectivity.activeNetwork } returns network
|
||||||
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
||||||
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true
|
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns true
|
||||||
|
|
||||||
assertTrue(compatV23.isNetworkAvailable(connectivity))
|
assertTrue(compatV25.isNetworkAvailable(connectivity))
|
||||||
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false
|
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false
|
||||||
assertFalse(compatV23.isNetworkAvailable(connectivity))
|
assertFalse(compatV25.isNetworkAvailable(connectivity))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun test_isWifi_CompatV24() {
|
fun test_isWifi_CompatV24() {
|
||||||
val compatV23 = CompatV24()
|
val compatV25 = CompatV25()
|
||||||
val network: Network = mockk()
|
val network: Network = mockk()
|
||||||
|
|
||||||
every { connectivity.activeNetwork } returns network
|
every { connectivity.activeNetwork } returns network
|
||||||
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
||||||
every { networkCapabilities.hasTransport(TRANSPORT_WIFI) } returns true
|
every { networkCapabilities.hasTransport(TRANSPORT_WIFI) } returns true
|
||||||
|
|
||||||
assertTrue(compatV23.isWifi(connectivity))
|
assertTrue(compatV25.isWifi(connectivity))
|
||||||
every { networkCapabilities.hasTransport(TRANSPORT_WIFI) } returns false
|
every { networkCapabilities.hasTransport(TRANSPORT_WIFI) } returns false
|
||||||
assertFalse(compatV23.isWifi(connectivity))
|
assertFalse(compatV25.isWifi(connectivity))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNetworkAvailability_NoNetwork_CompatV24() {
|
fun testNetworkAvailability_NoNetwork_CompatV24() {
|
||||||
every { context.getSystemService(Context.CONNECTIVITY_SERVICE) } returns connectivity
|
every { context.getSystemService(Context.CONNECTIVITY_SERVICE) } returns connectivity
|
||||||
val compatV23 = CompatV24()
|
val compatV25 = CompatV25()
|
||||||
val network: Network = mockk()
|
val network: Network = mockk()
|
||||||
|
|
||||||
every { connectivity.activeNetwork } returns network
|
every { connectivity.activeNetwork } returns network
|
||||||
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
every { connectivity.getNetworkCapabilities(network) } returns networkCapabilities
|
||||||
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false
|
every { networkCapabilities.hasCapability(NET_CAPABILITY_INTERNET) } returns false
|
||||||
|
|
||||||
assertFalse(compatV23.isNetworkAvailable(connectivity))
|
assertFalse(compatV25.isNetworkAvailable(connectivity))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user