Skip to content

Commit

Permalink
Increase SDK level to 35 (#1003)
Browse files Browse the repository at this point in the history
* Increase SDK level

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Fixed nullability issues

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Increase SDK level

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Fixed nullability issues

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Replaced `removeFirst()` by `removeAt(0)`

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Switched to null check instead of NPE catch

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

* Using orEmpty

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>

---------

Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
  • Loading branch information
ArnyminerZ authored Sep 10, 2024
1 parent f8fb016 commit 0581417
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {

// Android configuration
android {
compileSdk = 34
compileSdk = 35

defaultConfig {
applicationId = "at.bitfire.davdroid"
Expand All @@ -24,7 +24,7 @@ android {
setProperty("archivesBaseName", "davx5-ose-$versionName")

minSdk = 24 // Android 7.0
targetSdk = 34 // Android 14
targetSdk = 35 // Android 15

testInstrumentationRunner = "at.bitfire.davdroid.HiltTestRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import android.content.pm.PackageManager
import at.bitfire.davdroid.db.AppDatabase
import at.bitfire.davdroid.db.SyncStats
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import java.text.Collator
import java.util.logging.Logger
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class DavSyncStatsRepository @Inject constructor(
@ApplicationContext val context: Context,
Expand Down Expand Up @@ -62,7 +62,12 @@ class DavSyncStatsRepository @Inject constructor(
val packageName = packageManager.resolveContentProvider(authority, 0)?.packageName ?: authority
return try {
val appInfo = packageManager.getPackageInfo(packageName, 0).applicationInfo
packageManager.getApplicationLabel(appInfo).toString()
if (appInfo != null) {
packageManager.getApplicationLabel(appInfo).toString()
} else {
logger.warning("Package name ($packageName) not found for authority: $authority")
authority
}
} catch (e: PackageManager.NameNotFoundException) {
logger.warning("Application name not found for authority: $authority")
authority
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import at.bitfire.ical4android.TaskProvider
import at.bitfire.ical4android.TaskProvider.ProviderName
import dagger.Lazy
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.logging.Logger
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import java.util.logging.Logger
import javax.inject.Inject

/**
* Responsible for setting/getting the currently used tasks app, and for communicating with it.
Expand Down Expand Up @@ -168,7 +168,7 @@ class TasksAppManager @Inject constructor(

val pm = context.packageManager
val tasksAppInfo = pm.getPackageInfo(e.provider.packageName, 0)
val tasksAppLabel = tasksAppInfo.applicationInfo.loadLabel(pm)
val tasksAppLabel = tasksAppInfo.applicationInfo?.loadLabel(pm)

val notify = NotificationCompat.Builder(context, registry.CHANNEL_SYNC_ERRORS)
.setSmallIcon(R.drawable.ic_sync_problem_notify)
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/kotlin/at/bitfire/davdroid/ui/DebugInfoModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.dmfs.tasks.contract.TaskContract
import java.io.File
import java.io.IOException
import java.io.Writer
Expand All @@ -67,6 +64,9 @@ import java.util.logging.Level
import java.util.logging.Logger
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.dmfs.tasks.contract.TaskContract
import at.bitfire.ical4android.util.MiscUtils.asSyncAdapter as asCalendarSyncAdapter
import at.bitfire.vcard4android.Utils.asSyncAdapter as asContactsSyncAdapter
import at.techbee.jtx.JtxContract.asSyncAdapter as asJtxSyncAdapter
Expand Down Expand Up @@ -239,9 +239,9 @@ class DebugInfoModel @AssistedInject constructor(
val info = pm.getPackageInfo(packageName, 0)
val appInfo = info.applicationInfo
val notes = mutableListOf<String>()
if (!appInfo.enabled)
if (appInfo?.enabled == false)
notes += "disabled"
if (appInfo.flags.and(ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)
if (appInfo?.flags?.and(ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0)
notes += "<em>on external storage</em>"
table.addLine(
info.packageName, info.versionName, PackageInfoCompat.getLongVersionCode(info),
Expand Down Expand Up @@ -366,7 +366,7 @@ class DebugInfoModel @AssistedInject constructor(
// permissions
writer.append("Permissions:\n")
val ownPkgInfo = context.packageManager.getPackageInfo(BuildConfig.APPLICATION_ID, PackageManager.GET_PERMISSIONS)
for (permission in ownPkgInfo.requestedPermissions) {
for (permission in ownPkgInfo.requestedPermissions.orEmpty()) {
val shortPermission = permission.removePrefix("android.permission.")
writer.append(" - $shortPermission: ")
.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DiskCache(
files.sortBy { file -> file.lastModified() } // sort by modification time (ascending)

while (files.sumOf { file -> file.length() } > maxSize) {
val file = files.removeFirst() // take first (= oldest) file
val file = files.removeAt(0) // take first (= oldest) file
logger.finer("Removing $file")
file.delete()
removed++
Expand Down

0 comments on commit 0581417

Please sign in to comment.