Skip to content
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 25.0.0

* Breaking: `avatars.getScreenshot` `theme` parameter now uses the `BrowserTheme` enum
* Breaking: Removed generic type parameters from `presences` service methods
* Added: `BrowserTheme` enum
* Updated: `Presence` model is now concrete and adds a `metadata` field

## 24.1.1

* Fixed: Removed `Advisor` service and `Insight`, `InsightCTA`, `InsightList`, `Report`, `ReportList` models (admin-only endpoints, not intended for client SDKs)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-android:24.2.0")
implementation("io.appwrite:sdk-for-android:25.0.0")
```

### Maven
Expand All @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>24.2.0</version>
<version>25.0.0</version>
</dependency>
</dependencies>
```
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/java/avatars/get-screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Avatars;
import io.appwrite.enums.Theme;
import io.appwrite.enums.BrowserTheme;
import io.appwrite.enums.Timezone;
import io.appwrite.enums.BrowserPermission;
import io.appwrite.enums.ImageFormat;
Expand All @@ -22,7 +22,7 @@ avatars.getScreenshot(
1920, // viewportWidth (optional)
1080, // viewportHeight (optional)
2, // scale (optional)
Theme.LIGHT, // theme (optional)
BrowserTheme.LIGHT, // theme (optional)
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // userAgent (optional)
true, // fullpage (optional)
"en-US", // locale (optional)
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/kotlin/avatars/get-screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Avatars
import io.appwrite.enums.Theme
import io.appwrite.enums.BrowserTheme
import io.appwrite.enums.Timezone
import io.appwrite.enums.BrowserPermission
import io.appwrite.enums.ImageFormat
Expand All @@ -22,11 +22,11 @@ val result = avatars.getScreenshot(
viewportWidth = 1920, // (optional)
viewportHeight = 1080, // (optional)
scale = 2, // (optional)
theme = theme.LIGHT, // (optional)
theme = BrowserTheme.LIGHT, // (optional)
userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // (optional)
fullpage = true, // (optional)
locale = "en-US", // (optional)
timezone = timezone.AFRICA_ABIDJAN, // (optional)
timezone = Timezone.AFRICA_ABIDJAN, // (optional)
latitude = 37.7749, // (optional)
longitude = -122.4194, // (optional)
accuracy = 100, // (optional)
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "24.2.0",
"x-sdk-version" to "25.0.0",
"x-appwrite-response-format" to "1.9.5"
)
config = mutableMapOf()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.appwrite.enums

import com.google.gson.annotations.SerializedName

enum class Theme(val value: String) {
enum class BrowserTheme(val value: String) {
@SerializedName("light")
LIGHT("light"),
@SerializedName("dark")
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/models/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ data class Document<T>(
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<String>,
data = map["data"]?.jsonCast(to = nestedType) ?: emptyMap<String, Any>().jsonCast(to = nestedType)
data = map["data"]?.jsonCast(to = nestedType) ?: map.jsonCast(to = nestedType)
)
}
}
37 changes: 8 additions & 29 deletions library/src/main/java/io/appwrite/models/Presence.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast
/**
* Presence
*/
data class Presence<T>(
data class Presence(
/**
* Presence ID.
*/
Expand Down Expand Up @@ -56,10 +56,11 @@ data class Presence<T>(
var expiresAt: String?,

/**
* Additional properties
* Presence metadata.
*/
@SerializedName("metadata")
val metadata: T
var metadata: Any?,

) {
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
Expand All @@ -70,37 +71,15 @@ data class Presence<T>(
"status" to status as Any,
"source" to source as Any,
"expiresAt" to expiresAt as Any,
"metadata" to metadata!!.jsonCast(to = Map::class.java)
"metadata" to metadata as Any,
)

companion object {
operator fun invoke(
id: String,
createdAt: String,
updatedAt: String,
permissions: List<String>,
userId: String,
status: String?,
source: String,
expiresAt: String?,
metadata: Map<String, Any>
) = Presence<Map<String, Any>>(
id,
createdAt,
updatedAt,
permissions,
userId,
status,
source,
expiresAt,
metadata
)

@Suppress("UNCHECKED_CAST")
fun <T> from(
fun from(
map: Map<String, Any>,
nestedType: Class<T>
) = Presence<T>(
) = Presence(
id = map["\$id"] as String,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
Expand All @@ -109,7 +88,7 @@ data class Presence<T>(
status = map["status"] as? String,
source = map["source"] as String,
expiresAt = map["expiresAt"] as? String,
metadata = map["metadata"]?.jsonCast(to = nestedType) ?: emptyMap<String, Any>().jsonCast(to = nestedType)
metadata = map["metadata"] as? Any,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 map["metadata"] already returns Any?, so as? Any is a safe cast that always succeeds and is effectively a no-op. The assignment can be simplified to just map["metadata"].

Suggested change
metadata = map["metadata"] as? Any,
metadata = map["metadata"],

)
}
}
18 changes: 5 additions & 13 deletions library/src/main/java/io/appwrite/models/PresenceList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast
/**
* Presences List
*/
data class PresenceList<T>(
data class PresenceList(
/**
* Total number of presences that matched your query.
*/
Expand All @@ -17,7 +17,7 @@ data class PresenceList<T>(
* List of presences.
*/
@SerializedName("presences")
val presences: List<Presence<T>>,
val presences: List<Presence>,

) {
fun toMap(): Map<String, Any> = mapOf(
Expand All @@ -26,21 +26,13 @@ data class PresenceList<T>(
)

companion object {
operator fun invoke(
total: Long,
presences: List<Presence<Map<String, Any>>>,
) = PresenceList<Map<String, Any>>(
total,
presences,
)

@Suppress("UNCHECKED_CAST")
fun <T> from(
fun from(
map: Map<String, Any>,
nestedType: Class<T>
) = PresenceList<T>(
) = PresenceList(
total = (map["total"] as Number).toLong(),
presences = (map["presences"] as List<Map<String, Any>>).map { Presence.from(map = it, nestedType) },
presences = (map["presences"] as List<Map<String, Any>>).map { Presence.from(map = it) },
)
}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/models/Row.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ data class Row<T>(
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
permissions = map["\$permissions"] as List<String>,
data = map["data"]?.jsonCast(to = nestedType) ?: emptyMap<String, Any>().jsonCast(to = nestedType)
data = map["data"]?.jsonCast(to = nestedType) ?: map.jsonCast(to = nestedType)
)
}
}
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/services/Avatars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class Avatars(client: Client) : Service(client) {
viewportWidth: Long? = null,
viewportHeight: Long? = null,
scale: Double? = null,
theme: io.appwrite.enums.Theme? = null,
theme: io.appwrite.enums.BrowserTheme? = null,
userAgent: String? = null,
fullpage: Boolean? = null,
locale: String? = null,
Expand Down
Loading