Minimum SDK version changed to 24: The NDK version in kiwix-build has been upgraded (as mentioned in https://github.com/kiwix/kiwix-build/issues/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.

This commit is contained in:
MohitMali 2023-07-27 18:00:11 +05:30 committed by Kelson
parent d188a8262a
commit f7517a2272
14 changed files with 44 additions and 144 deletions

View File

@ -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 content of a file in the ZIM format, a highly compressed open format
with additional metadata. 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 to 13 (like [mentioned
here](https://github.com/kiwix/kiwix-android/blob/develop/buildSrc/src/main/kotlin/Config.kt)). here](https://github.com/kiwix/kiwix-android/blob/develop/buildSrc/src/main/kotlin/Config.kt)).

View File

@ -27,8 +27,7 @@
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true">
tools:targetApi="m">
<activity <activity
android:name=".main.KiwixMainActivity" android:name=".main.KiwixMainActivity"

View File

@ -63,16 +63,12 @@ class HotspotNotificationManager @Inject constructor(
val stopIntent = Intent(context, HotspotService::class.java).setAction( val stopIntent = Intent(context, HotspotService::class.java).setAction(
HotspotService.ACTION_STOP_SERVER HotspotService.ACTION_STOP_SERVER
) )
val stopHotspot = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val stopHotspot = PendingIntent.getService(
PendingIntent.getService(
context, context,
0, 0,
stopIntent, stopIntent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
) )
} else {
PendingIntent.getService(context, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)
}
return NotificationCompat.Builder(context, HOTSPOT_SERVICE_CHANNEL_ID) return NotificationCompat.Builder(context, HOTSPOT_SERVICE_CHANNEL_ID)
.setContentTitle(context.getString(R.string.hotspot_notification_content_title)) .setContentTitle(context.getString(R.string.hotspot_notification_content_title))
.setContentText(context.getString(R.string.hotspot_running)) .setContentText(context.getString(R.string.hotspot_running))

View File

@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.webserver.wifi_hotspot
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import android.os.Binder import android.os.Binder
import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.widget.Toast import android.widget.Toast
import org.kiwix.kiwixmobile.KiwixApp import org.kiwix.kiwixmobile.KiwixApp
@ -84,6 +83,7 @@ class HotspotService :
onServerFailedToStart() onServerFailedToStart()
} }
} ?: kotlin.run(::onServerFailedToStart) } ?: kotlin.run(::onServerFailedToStart)
ACTION_STOP_SERVER -> { ACTION_STOP_SERVER -> {
Toast.makeText( Toast.makeText(
this, R.string.server_stopped_successfully_toast_message, this, R.string.server_stopped_successfully_toast_message,
@ -91,6 +91,7 @@ class HotspotService :
).show() ).show()
stopHotspotAndDismissNotification() stopHotspotAndDismissNotification()
} }
ACTION_CHECK_IP_ADDRESS -> webServerHelper?.pollForValidIpAddress() ACTION_CHECK_IP_ADDRESS -> webServerHelper?.pollForValidIpAddress()
else -> {} else -> {}
} }
@ -103,9 +104,7 @@ class HotspotService :
private fun stopHotspotAndDismissNotification() { private fun stopHotspotAndDismissNotification() {
webServerHelper?.stopAndroidWebServer() webServerHelper?.stopAndroidWebServer()
zimHostCallbacks?.onServerStopped() zimHostCallbacks?.onServerStopped()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
stopForeground(STOP_FOREGROUND_REMOVE) stopForeground(STOP_FOREGROUND_REMOVE)
}
stopSelf() stopSelf()
hotspotStateReceiver = null hotspotStateReceiver = null
hotspotNotificationManager?.dismissNotification() hotspotNotificationManager?.dismissNotification()

View File

@ -18,7 +18,6 @@
package org.kiwix.kiwixmobile.zimManager package org.kiwix.kiwixmobile.zimManager
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.os.Build
import android.os.FileObserver import android.os.FileObserver
import io.reactivex.Flowable import io.reactivex.Flowable
import io.reactivex.functions.BiFunction import io.reactivex.functions.BiFunction
@ -63,22 +62,12 @@ class Fat32Checker constructor(
) )
} }
@Suppress("DEPRECATION") private fun fileObserver(it: String): FileObserver =
private fun fileObserver(it: String): FileObserver { object : FileObserver(File(it), MOVED_FROM or DELETE) {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return object : FileObserver(File(it), MOVED_FROM or DELETE) {
override fun onEvent(event: Int, path: String?) { override fun onEvent(event: Int, path: String?) {
requestCheckSystemFileType.onNext(Unit) requestCheckSystemFileType.onNext(Unit)
} }
}.apply { startWatching() } }.apply { startWatching() }
} else {
object : FileObserver(it, FileObserver.MOVED_FROM or FileObserver.DELETE) {
override fun onEvent(event: Int, path: String?) {
requestCheckSystemFileType.onNext(Unit)
}
}.apply { startWatching() }
}
}
private fun toFileSystemState(it: String) = private fun toFileSystemState(it: String) =
when { when {

View File

@ -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 = 21 // Minimum SDK (Minimum Support Device) is 21 (Android 5.0 Lollipop). const val minSdk = 24 // Minimum SDK (Minimum Support Device) is 24 (Android 7.0 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

View File

@ -22,7 +22,6 @@ import android.app.Dialog
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
@ -446,16 +445,12 @@ class AddNoteDialog : DialogFragment() {
} }
val noteFile = File("$zimNotesDirectory$articleNoteFileName.txt") val noteFile = File("$zimNotesDirectory$articleNoteFileName.txt")
if (noteFile.exists()) { if (noteFile.exists()) {
val noteFileUri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// From Nougat 7 (API 24) access to files is shared temporarily with other apps // From Nougat 7 (API 24) access to files is shared temporarily with other apps
// Need to use FileProvider for the same // Need to use FileProvider for the same
FileProvider.getUriForFile( val noteFileUri = FileProvider.getUriForFile(
requireContext(), requireContext().packageName + ".fileprovider", requireContext(), requireContext().packageName + ".fileprovider",
noteFile noteFile
) )
} else {
Uri.fromFile(noteFile)
}
val noteFileShareIntent = Intent(Intent.ACTION_SEND).apply { val noteFileShareIntent = Intent(Intent.ACTION_SEND).apply {
type = "application/octet-stream" type = "application/octet-stream"
putExtra(Intent.EXTRA_STREAM, noteFileUri) putExtra(Intent.EXTRA_STREAM, noteFileUri)

View File

@ -20,7 +20,6 @@ package org.kiwix.kiwixmobile.core.main
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Build
import android.util.Log import android.util.Log
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import android.webkit.WebResourceError import android.webkit.WebResourceError
@ -94,18 +93,15 @@ open class CoreWebViewClient(
)?.let { )?.let {
if (it.exists()) { if (it.exists()) {
val context: Context = instance val context: Context = instance
val uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) val uri = FileProvider.getUriForFile(
FileProvider.getUriForFile(
context, context,
context.packageName + ".fileprovider", it context.packageName + ".fileprovider", it
) else Uri.fromFile(it) )
val intent = Intent(Intent.ACTION_VIEW).apply { val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(uri, DOCUMENT_TYPES[extension]) setDataAndType(uri, DOCUMENT_TYPES[extension])
flags = Intent.FLAG_ACTIVITY_NO_HISTORY flags = Intent.FLAG_ACTIVITY_NO_HISTORY
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
} }
}
callback.openExternalUrl(intent) callback.openExternalUrl(intent)
} }
} }

View File

@ -57,29 +57,21 @@ class ReadAloudNotificationManger @Inject constructor(
val stopIntent = Intent(context, ReadAloudService::class.java).setAction( val stopIntent = Intent(context, ReadAloudService::class.java).setAction(
ReadAloudService.ACTION_STOP_TTS ReadAloudService.ACTION_STOP_TTS
) )
val stopReadAloud = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val stopReadAloud = PendingIntent.getService(
PendingIntent.getService(
context, context,
0, 0,
stopIntent, stopIntent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
) )
} else {
PendingIntent.getService(context, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)
}
val pauseOrResumeIntent = Intent(context, ReadAloudService::class.java).setAction( val pauseOrResumeIntent = Intent(context, ReadAloudService::class.java).setAction(
ReadAloudService.ACTION_PAUSE_OR_RESUME_TTS ReadAloudService.ACTION_PAUSE_OR_RESUME_TTS
).putExtra(IS_TTS_PAUSE_OR_RESUME, !isPauseTTS) ).putExtra(IS_TTS_PAUSE_OR_RESUME, !isPauseTTS)
val pauseOrResumeReadAloud = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { val pauseOrResumeReadAloud = PendingIntent.getService(
PendingIntent.getService(
context, context,
0, 0,
pauseOrResumeIntent, pauseOrResumeIntent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
) )
} else {
PendingIntent.getService(context, 0, pauseOrResumeIntent, PendingIntent.FLAG_UPDATE_CURRENT)
}
return NotificationCompat.Builder(context, READ_ALOUD_SERVICE_CHANNEL_ID) return NotificationCompat.Builder(context, READ_ALOUD_SERVICE_CHANNEL_ID)
.setContentTitle(context.getString(R.string.menu_read_aloud)) .setContentTitle(context.getString(R.string.menu_read_aloud))
.setContentText(context.getString(R.string.read_aloud_running)) .setContentText(context.getString(R.string.read_aloud_running))

View File

@ -21,7 +21,6 @@ package org.kiwix.kiwixmobile.core.read_aloud
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import android.os.Binder import android.os.Binder
import android.os.Build
import android.os.IBinder import android.os.IBinder
import org.kiwix.kiwixmobile.core.CoreApp import org.kiwix.kiwixmobile.core.CoreApp
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
@ -49,6 +48,7 @@ class ReadAloudService : Service() {
startForegroundNotificationHelper(isPauseTTS) startForegroundNotificationHelper(isPauseTTS)
readAloudCallbacks?.onReadAloudPauseOrResume(isPauseTTS) readAloudCallbacks?.onReadAloudPauseOrResume(isPauseTTS)
} }
ACTION_STOP_TTS -> { ACTION_STOP_TTS -> {
stopReadAloudAndDismissNotification() stopReadAloudAndDismissNotification()
} }
@ -58,9 +58,7 @@ class ReadAloudService : Service() {
private fun stopReadAloudAndDismissNotification() { private fun stopReadAloudAndDismissNotification() {
readAloudCallbacks?.onReadAloudStop() readAloudCallbacks?.onReadAloudStop()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
stopForeground(STOP_FOREGROUND_REMOVE) stopForeground(STOP_FOREGROUND_REMOVE)
}
stopSelf() stopSelf()
readAloudNotificationManager?.dismissNotification() readAloudNotificationManager?.dismissNotification()
} }

View File

@ -8,8 +8,7 @@
android:name=".CustomApp" android:name=".CustomApp"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true">
tools:targetApi="m">
<activity <activity
android:name=".main.CustomMainActivity" android:name=".main.CustomMainActivity"

View File

@ -18,9 +18,7 @@
package org.kiwix.kiwixmobile.custom.main package org.kiwix.kiwixmobile.custom.main
import android.annotation.TargetApi
import android.app.Dialog import android.app.Dialog
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
@ -138,7 +136,6 @@ class CustomReaderFragment : CoreReaderFragment() {
) )
} }
@TargetApi(Build.VERSION_CODES.M)
private fun openObbOrZim() { private fun openObbOrZim() {
customFileValidator.validate( customFileValidator.validate(
onFilesFound = { onFilesFound = {

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ 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 <http://www.gnu.org/licenses/>.
~
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/alabaster_white" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
</layer-list>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Kiwix Android
~ Copyright (c) 2020 Kiwix <android.kiwix.org>
~ 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 <http://www.gnu.org/licenses/>.
~
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<!-- The background color, preferably the same as your normal theme -->
<item android:drawable="@color/alabaster_white" />
<item
android:bottom="24dp"
android:drawable="@mipmap/ic_launcher"
android:gravity="center"
android:left="24dp"
android:right="24dp"
android:top="24dp" />
</layer-list>