Skip to content

Upgrade Flutter, packages and Android build dependencies #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ android {
// https://developer.android.com/reference/tools/gradle-api/8.5/com/android/build/api/dsl/Lint
checkAllWarnings = true
warningsAsErrors = true
baseline = file("lint-baseline.xml")
}
}

Expand Down
11 changes: 11 additions & 0 deletions android/app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.5.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.5.2)" variant="all" version="8.5.2">

<issue
id="InvalidPackage"
message="Invalid package reference in library; not included in Android: `javax.xml.stream`. Referenced from `org.apache.tika.utils.XMLReaderUtils`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.apache.tika/tika-core/3.1.0/6ba44a9ddf8f6f2b4bc88e8bc64269aea0424607/tika-core-3.1.0.jar"/>
Comment on lines +4 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, add a suppression of a lint error caused by
a dependency of this package [i.e., file_picker].

I see, annoying.

Seems like the impact of this, if there is one, would be that it crashes when trying to read some XML file. Is there a file_picker upstream issue for this? If we're lucky, someone has already investigated and has a convincing reason it won't matter for our use (or perhaps even for file_picker's use in general).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you said in today's call that you looked in the package's tracker and didn't find an issue for this.

That's fine and we can leave it there — this probably doesn't affect our app's behavior, and we're planning to switch off this library in the future anyway. The commit message should just mention that, though: the fact that you looked and didn't find an upstream issue.

</issue>

</issues>
184 changes: 158 additions & 26 deletions android/app/src/main/kotlin/com/zulip/flutter/Notifications.g.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v25.0.0), do not edit directly.
// Autogenerated from Pigeon (v25.3.1), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")

Expand All @@ -13,25 +13,57 @@ import io.flutter.plugin.common.StandardMethodCodec
import io.flutter.plugin.common.StandardMessageCodec
import java.io.ByteArrayOutputStream
import java.nio.ByteBuffer
private object NotificationsPigeonUtils {

private fun wrapResult(result: Any?): List<Any?> {
return listOf(result)
}
fun wrapResult(result: Any?): List<Any?> {
return listOf(result)
}

private fun wrapError(exception: Throwable): List<Any?> {
return if (exception is FlutterError) {
listOf(
exception.code,
exception.message,
exception.details
)
} else {
listOf(
exception.javaClass.simpleName,
exception.toString(),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
)
fun wrapError(exception: Throwable): List<Any?> {
return if (exception is FlutterError) {
listOf(
exception.code,
exception.message,
exception.details
)
} else {
listOf(
exception.javaClass.simpleName,
exception.toString(),
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
)
}
}
fun deepEquals(a: Any?, b: Any?): Boolean {
if (a is ByteArray && b is ByteArray) {
return a.contentEquals(b)
}
if (a is IntArray && b is IntArray) {
return a.contentEquals(b)
}
if (a is LongArray && b is LongArray) {
return a.contentEquals(b)
}
if (a is DoubleArray && b is DoubleArray) {
return a.contentEquals(b)
}
if (a is Array<*> && b is Array<*>) {
return a.size == b.size &&
a.indices.all{ deepEquals(a[it], b[it]) }
}
if (a is List<*> && b is List<*>) {
return a.size == b.size &&
a.indices.all{ deepEquals(a[it], b[it]) }
}
if (a is Map<*, *> && b is Map<*, *>) {
return a.size == b.size && a.all {
(b as Map<Any?, Any?>).containsKey(it.key) &&
deepEquals(it.value, b[it.key])
}
}
return a == b
}

}

/**
Expand Down Expand Up @@ -89,6 +121,16 @@ data class NotificationChannel (
vibrationPattern,
)
}
override fun equals(other: Any?): Boolean {
if (other !is NotificationChannel) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -122,6 +164,16 @@ data class AndroidIntent (
flags,
)
}
override fun equals(other: Any?): Boolean {
if (other !is AndroidIntent) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -156,6 +208,16 @@ data class PendingIntent (
flags,
)
}
override fun equals(other: Any?): Boolean {
if (other !is PendingIntent) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand All @@ -180,6 +242,16 @@ data class InboxStyle (
summaryText,
)
}
override fun equals(other: Any?): Boolean {
if (other !is InboxStyle) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -220,6 +292,16 @@ data class Person (
name,
)
}
override fun equals(other: Any?): Boolean {
if (other !is Person) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -250,6 +332,16 @@ data class MessagingStyleMessage (
person,
)
}
override fun equals(other: Any?): Boolean {
if (other !is MessagingStyleMessage) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -283,6 +375,16 @@ data class MessagingStyle (
isGroupConversation,
)
}
override fun equals(other: Any?): Boolean {
if (other !is MessagingStyle) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -310,6 +412,16 @@ data class Notification (
extras,
)
}
override fun equals(other: Any?): Boolean {
if (other !is Notification) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -340,6 +452,16 @@ data class StatusBarNotification (
notification,
)
}
override fun equals(other: Any?): Boolean {
if (other !is StatusBarNotification) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand Down Expand Up @@ -380,6 +502,16 @@ data class StoredNotificationSound (
contentUrl,
)
}
override fun equals(other: Any?): Boolean {
if (other !is StoredNotificationSound) {
return false
}
if (this === other) {
return true
}
return NotificationsPigeonUtils.deepEquals(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}
private open class NotificationsPigeonCodec : StandardMessageCodec() {
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
Expand Down Expand Up @@ -605,7 +737,7 @@ interface AndroidNotificationHostApi {
api.createNotificationChannel(channelArg)
listOf(null)
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -620,7 +752,7 @@ interface AndroidNotificationHostApi {
val wrapped: List<Any?> = try {
listOf(api.getNotificationChannels())
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -638,7 +770,7 @@ interface AndroidNotificationHostApi {
api.deleteNotificationChannel(channelIdArg)
listOf(null)
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -653,7 +785,7 @@ interface AndroidNotificationHostApi {
val wrapped: List<Any?> = try {
listOf(api.listStoredSoundsInNotificationsDirectory())
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -671,7 +803,7 @@ interface AndroidNotificationHostApi {
val wrapped: List<Any?> = try {
listOf(api.copySoundResourceToMediaStore(targetFileDisplayNameArg, sourceResourceNameArg))
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand Down Expand Up @@ -703,7 +835,7 @@ interface AndroidNotificationHostApi {
api.notify(tagArg, idArg, autoCancelArg, channelIdArg, colorArg, contentIntentArg, contentTextArg, contentTitleArg, extrasArg, groupKeyArg, inboxStyleArg, isGroupSummaryArg, messagingStyleArg, numberArg, smallIconResourceNameArg)
listOf(null)
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -720,7 +852,7 @@ interface AndroidNotificationHostApi {
val wrapped: List<Any?> = try {
listOf(api.getActiveNotificationMessagingStyleByTag(tagArg))
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -737,7 +869,7 @@ interface AndroidNotificationHostApi {
val wrapped: List<Any?> = try {
listOf(api.getActiveNotifications(desiredExtrasArg))
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand All @@ -756,7 +888,7 @@ interface AndroidNotificationHostApi {
api.cancel(tagArg, idArg)
listOf(null)
} catch (exception: Throwable) {
wrapError(exception)
NotificationsPigeonUtils.wrapError(exception)
}
reply.reply(wrapped)
}
Expand Down
5 changes: 3 additions & 2 deletions android/app/src/main/kotlin/com/zulip/flutter/ZulipPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.graphics.drawable.IconCompat
import io.flutter.embedding.engine.plugins.FlutterPlugin
import androidx.core.net.toUri

private const val TAG = "ZulipPlugin"

Expand Down Expand Up @@ -64,7 +65,7 @@ private class AndroidNotificationHost(val context: Context)
channel.name?.let { setName(it) }
channel.lightsEnabled?.let { setLightsEnabled(it) }
channel.soundUrl?.let {
setSound(Uri.parse(it),
setSound(it.toUri(),
AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build())
}
channel.vibrationPattern?.let { setVibrationPattern(it) }
Expand Down Expand Up @@ -199,7 +200,7 @@ private class AndroidNotificationHost(val context: Context)
it.requestCode.toInt(),
it.intent.let { intent -> Intent(
intent.action,
Uri.parse(intent.dataUrl),
intent.dataUrl.toUri(),
context,
MainActivity::class.java
).apply {
Expand Down
4 changes: 2 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ android.enableJetifier=true
# Defining them here makes them available both in
# settings.gradle and in the build.gradle files.

agpVersion=8.5.2
agpVersion=8.9.1

# Generally update this to the version found in recent releases
# of Android Studio, as listed in this table:
# https://kotlinlang.org/docs/releases.html#release-details
# A helpful discussion is at:
# https://stackoverflow.com/a/74425347
kotlinVersion=2.0.10
kotlinVersion=2.1.20
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the wrapper is the one from the new Gradle too.)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading