Skip to content

Commit c11184a

Browse files
Minimum SDK version changed to 24: The NDK version in kiwix-build has been upgraded (as mentioned in kiwix/kiwix-build#544). However, to make this upgrade compatible, the minimum SDK version had to be updated to 24 since the NDK version is not compatible with Android API levels below 24. The README.md file has been updated to reflect the new minimum Android support version, which is now Android 7, due to the change in the minimum SDK version. Since the project's minimum SDK version is now 24, some conditions related to Android 23 and 24 have become unused. These unused conditions have been removed, and along with that, the drawable-night-23 and drawable-23 launch_screen.xml files, which were no longer in use, have also been removed.
1 parent 7b85a50 commit c11184a

File tree

14 files changed

+44
-143
lines changed

14 files changed

+44
-143
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ is to make Wikipedia available offline. This is done by reading the
1313
content of a file in the ZIM format, a highly compressed open format
1414
with additional metadata.
1515

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

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
android:allowBackup="true"
2828
android:icon="@mipmap/ic_launcher"
2929
android:roundIcon="@mipmap/ic_launcher_round"
30-
android:supportsRtl="true"
31-
tools:targetApi="m">
30+
android:supportsRtl="true">
3231

3332
<activity
3433
android:name=".main.KiwixMainActivity"

app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotNotificationManager.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,12 @@ class HotspotNotificationManager @Inject constructor(
6363
val stopIntent = Intent(context, HotspotService::class.java).setAction(
6464
HotspotService.ACTION_STOP_SERVER
6565
)
66-
val stopHotspot = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
67-
PendingIntent.getService(
68-
context,
69-
0,
70-
stopIntent,
71-
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
72-
)
73-
} else {
74-
PendingIntent.getService(context, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)
75-
}
66+
val stopHotspot = PendingIntent.getService(
67+
context,
68+
0,
69+
stopIntent,
70+
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
71+
)
7672
return NotificationCompat.Builder(context, HOTSPOT_SERVICE_CHANNEL_ID)
7773
.setContentTitle(context.getString(R.string.hotspot_notification_content_title))
7874
.setContentText(context.getString(R.string.hotspot_running))

app/src/main/java/org/kiwix/kiwixmobile/webserver/wifi_hotspot/HotspotService.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.webserver.wifi_hotspot
2020
import android.app.Service
2121
import android.content.Intent
2222
import android.os.Binder
23-
import android.os.Build
2423
import android.os.IBinder
2524
import android.widget.Toast
2625
import org.kiwix.kiwixmobile.KiwixApp
@@ -84,13 +83,15 @@ class HotspotService :
8483
onServerFailedToStart()
8584
}
8685
} ?: kotlin.run(::onServerFailedToStart)
86+
8787
ACTION_STOP_SERVER -> {
8888
Toast.makeText(
8989
this, R.string.server_stopped_successfully_toast_message,
9090
Toast.LENGTH_SHORT
9191
).show()
9292
stopHotspotAndDismissNotification()
9393
}
94+
9495
ACTION_CHECK_IP_ADDRESS -> webServerHelper?.pollForValidIpAddress()
9596
else -> {}
9697
}
@@ -103,9 +104,7 @@ class HotspotService :
103104
private fun stopHotspotAndDismissNotification() {
104105
webServerHelper?.stopAndroidWebServer()
105106
zimHostCallbacks?.onServerStopped()
106-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
107-
stopForeground(STOP_FOREGROUND_REMOVE)
108-
}
107+
stopForeground(STOP_FOREGROUND_REMOVE)
109108
stopSelf()
110109
hotspotStateReceiver = null
111110
hotspotNotificationManager?.dismissNotification()

app/src/main/java/org/kiwix/kiwixmobile/zimManager/Fat32Checker.kt

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.kiwix.kiwixmobile.zimManager
1919

2020
import android.annotation.SuppressLint
21-
import android.os.Build
2221
import android.os.FileObserver
2322
import io.reactivex.Flowable
2423
import io.reactivex.functions.BiFunction
@@ -63,21 +62,12 @@ class Fat32Checker constructor(
6362
)
6463
}
6564

66-
private fun fileObserver(it: String): FileObserver {
67-
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
68-
return object : FileObserver(File(it), MOVED_FROM or DELETE) {
69-
override fun onEvent(event: Int, path: String?) {
70-
requestCheckSystemFileType.onNext(Unit)
71-
}
72-
}.apply { startWatching() }
73-
} else {
74-
object : FileObserver(it, FileObserver.MOVED_FROM or FileObserver.DELETE) {
75-
override fun onEvent(event: Int, path: String?) {
76-
requestCheckSystemFileType.onNext(Unit)
77-
}
78-
}.apply { startWatching() }
79-
}
80-
}
65+
private fun fileObserver(it: String): FileObserver =
66+
object : FileObserver(File(it), MOVED_FROM or DELETE) {
67+
override fun onEvent(event: Int, path: String?) {
68+
requestCheckSystemFileType.onNext(Unit)
69+
}
70+
}.apply { startWatching() }
8171

8272
private fun toFileSystemState(it: String) =
8373
when {

buildSrc/src/main/kotlin/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Config {
2323
// Here is a list of all Android versions with their corresponding API
2424
// levels: https://apilevels.com/
2525
const val compileSdk = 33 // SDK version used by Gradle to compile our app.
26-
const val minSdk = 21 // Minimum SDK (Minimum Support Device) is 21 (Android 5.0 Lollipop).
26+
const val minSdk = 24 // Minimum SDK (Minimum Support Device) is 24 (Android 7.0 Nougat).
2727
const val targetSdk = 33 // Target SDK (Maximum Support Device) is 33 (Android 13).
2828

2929
val javaVersion = JavaVersion.VERSION_1_8

core/src/main/java/org/kiwix/kiwixmobile/core/main/AddNoteDialog.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import android.app.Dialog
2222
import android.content.Context
2323
import android.content.Intent
2424
import android.content.pm.PackageManager
25-
import android.net.Uri
2625
import android.os.Build
2726
import android.os.Bundle
2827
import android.text.Editable
@@ -446,16 +445,12 @@ class AddNoteDialog : DialogFragment() {
446445
}
447446
val noteFile = File("$zimNotesDirectory$articleNoteFileName.txt")
448447
if (noteFile.exists()) {
449-
val noteFileUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
450-
// From Nougat 7 (API 24) access to files is shared temporarily with other apps
451-
// Need to use FileProvider for the same
452-
FileProvider.getUriForFile(
453-
requireContext(), requireContext().packageName + ".fileprovider",
454-
noteFile
455-
)
456-
} else {
457-
Uri.fromFile(noteFile)
458-
}
448+
// From Nougat 7 (API 24) access to files is shared temporarily with other apps
449+
// Need to use FileProvider for the same
450+
val noteFileUri = FileProvider.getUriForFile(
451+
requireContext(), requireContext().packageName + ".fileprovider",
452+
noteFile
453+
)
459454
val noteFileShareIntent = Intent(Intent.ACTION_SEND).apply {
460455
type = "application/octet-stream"
461456
putExtra(Intent.EXTRA_STREAM, noteFileUri)

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreWebViewClient.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.core.main
2020
import android.content.Context
2121
import android.content.Intent
2222
import android.net.Uri
23-
import android.os.Build
2423
import android.util.Log
2524
import android.webkit.MimeTypeMap
2625
import android.webkit.WebResourceError
@@ -94,17 +93,14 @@ open class CoreWebViewClient(
9493
)?.let {
9594
if (it.exists()) {
9695
val context: Context = instance
97-
val uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
98-
FileProvider.getUriForFile(
99-
context,
100-
context.packageName + ".fileprovider", it
101-
) else Uri.fromFile(it)
96+
val uri = FileProvider.getUriForFile(
97+
context,
98+
context.packageName + ".fileprovider", it
99+
)
102100
val intent = Intent(Intent.ACTION_VIEW).apply {
103101
setDataAndType(uri, DOCUMENT_TYPES[extension])
104102
flags = Intent.FLAG_ACTIVITY_NO_HISTORY
105-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
106-
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
107-
}
103+
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
108104
}
109105
callback.openExternalUrl(intent)
110106
}

core/src/main/java/org/kiwix/kiwixmobile/core/read_aloud/ReadAloudNotificationManger.kt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,21 @@ class ReadAloudNotificationManger @Inject constructor(
5757
val stopIntent = Intent(context, ReadAloudService::class.java).setAction(
5858
ReadAloudService.ACTION_STOP_TTS
5959
)
60-
val stopReadAloud = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
61-
PendingIntent.getService(
62-
context,
63-
0,
64-
stopIntent,
65-
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
66-
)
67-
} else {
68-
PendingIntent.getService(context, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)
69-
}
60+
val stopReadAloud = PendingIntent.getService(
61+
context,
62+
0,
63+
stopIntent,
64+
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
65+
)
7066
val pauseOrResumeIntent = Intent(context, ReadAloudService::class.java).setAction(
7167
ReadAloudService.ACTION_PAUSE_OR_RESUME_TTS
7268
).putExtra(IS_TTS_PAUSE_OR_RESUME, !isPauseTTS)
73-
val pauseOrResumeReadAloud = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
74-
PendingIntent.getService(
75-
context,
76-
0,
77-
pauseOrResumeIntent,
78-
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
79-
)
80-
} else {
81-
PendingIntent.getService(context, 0, pauseOrResumeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
82-
}
69+
val pauseOrResumeReadAloud = PendingIntent.getService(
70+
context,
71+
0,
72+
pauseOrResumeIntent,
73+
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
74+
)
8375
return NotificationCompat.Builder(context, READ_ALOUD_SERVICE_CHANNEL_ID)
8476
.setContentTitle(context.getString(R.string.menu_read_aloud))
8577
.setContentText(context.getString(R.string.read_aloud_running))

core/src/main/java/org/kiwix/kiwixmobile/core/read_aloud/ReadAloudService.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.core.read_aloud
2121
import android.app.Service
2222
import android.content.Intent
2323
import android.os.Binder
24-
import android.os.Build
2524
import android.os.IBinder
2625
import org.kiwix.kiwixmobile.core.CoreApp
2726
import java.lang.ref.WeakReference
@@ -49,6 +48,7 @@ class ReadAloudService : Service() {
4948
startForegroundNotificationHelper(isPauseTTS)
5049
readAloudCallbacks?.onReadAloudPauseOrResume(isPauseTTS)
5150
}
51+
5252
ACTION_STOP_TTS -> {
5353
stopReadAloudAndDismissNotification()
5454
}
@@ -58,9 +58,7 @@ class ReadAloudService : Service() {
5858

5959
private fun stopReadAloudAndDismissNotification() {
6060
readAloudCallbacks?.onReadAloudStop()
61-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
62-
stopForeground(STOP_FOREGROUND_REMOVE)
63-
}
61+
stopForeground(STOP_FOREGROUND_REMOVE)
6462
stopSelf()
6563
readAloudNotificationManager?.dismissNotification()
6664
}

0 commit comments

Comments
 (0)