Merge pull request #10 from appwrite/dev

feat: Bug fixes and version bump
This commit is contained in:
Christy Jacob
2021-07-02 17:25:30 +05:30
committed by GitHub
7 changed files with 77 additions and 15 deletions
+2 -2
View File
@@ -2,12 +2,12 @@
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
+26
View File
@@ -0,0 +1,26 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.getSession(
sessionId = "[SESSION_ID]"
)
val json = response.body?.string()
}
}
}
@@ -8,8 +8,8 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import io.appwrite.android.R
import io.appwrite.android.databinding.FragmentAccountBinding
@@ -17,14 +17,13 @@ import io.appwrite.android.databinding.FragmentAccountBinding
class AccountsFragment : Fragment() {
private lateinit var binding: FragmentAccountBinding
private lateinit var viewModel: AccountsViewModel
private val viewModel: AccountsViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater ,
container: ViewGroup? ,
savedInstanceState: Bundle?
): View? {
viewModel = ViewModelProvider(this).get(AccountsViewModel::class.java)
): View {
binding = DataBindingUtil.inflate(
inflater,
R.layout.fragment_account,
+2 -2
View File
@@ -28,13 +28,13 @@ android {
targetSdkVersion(30)
versionCode = 1
versionName = "1.0"
buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\""
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
buildTypes {
named("release") {
release {
minifyEnabled false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
+10 -3
View File
@@ -3,6 +3,7 @@ package io.appwrite
import android.content.Context
import android.content.pm.PackageManager
import com.google.gson.Gson
import io.appwrite.appwrite.BuildConfig
import io.appwrite.exceptions.AppwriteException
import io.appwrite.extensions.JsonExtensions.fromJson
import io.appwrite.models.Error
@@ -69,8 +70,8 @@ class Client @JvmOverloads constructor(
"content-type" to "application/json",
"origin" to "appwrite-android://${context.packageName}",
"user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}",
"x-sdk-version" to "appwrite:android:0.0.1",
"x-appwrite-response-format" to "0.8.0"
"x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}",
"x-appwrite-response-format" to "0.9.0"
)
config = mutableMapOf()
@@ -227,7 +228,13 @@ class Client @JvmOverloads constructor(
return@forEach
}
is List<*> -> {
httpBuilder.addQueryParameter(it.key + "[]", it.value.toString())
val list = it.value as List<*>
for (index in list.indices) {
httpBuilder.addQueryParameter(
"${it.key}[]",
list[index].toString()
)
}
}
else -> {
httpBuilder.addQueryParameter(it.key, it.value.toString())
@@ -134,7 +134,8 @@ class Account(private val client: Client) : BaseService(client) {
* Use this endpoint to create a JSON Web Token. You can use the resulting JWT
* to authenticate on behalf of the current user when working with the
* Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes
* from its creation and will be invalid if the user will logout.
* from its creation and will be invalid if the user will logout in that time
* frame.
*
* @return [Response]
*/
@@ -431,9 +432,10 @@ class Account(private val client: Client) : BaseService(client) {
*
* Use this endpoint to allow a new user to register an anonymous account in
* your project. This route will also create a new session for the user. To
* allow the new user to convert an anonymous account to a normal account
* account, you need to update its [email and
* password](/docs/client/account#accountUpdateEmail).
* allow the new user to convert an anonymous account to a normal account, you
* need to update its [email and
* password](/docs/client/account#accountUpdateEmail) or create an [OAuth2
* session](/docs/client/account#accountCreateOAuth2Session).
*
* @return [Response]
*/
@@ -527,6 +529,31 @@ class Account(private val client: Client) : BaseService(client) {
}
/**
* Get Session By ID
*
* Use this endpoint to get a logged in user's session using a Session ID.
* Inputting 'current' will return the current session being used.
*
* @param sessionId
* @return [Response]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun getSession(
sessionId: String
): Response {
val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
val params = mapOf<String, Any?>(
)
val headers = mapOf(
"content-type" to "application/json"
)
return client.call("GET", path, headers, params)
}
/**
* Delete Account Session
*
@@ -195,6 +195,7 @@ class Storage(private val client: Client) : BaseService(client) {
* @param fileId
* @param width
* @param height
* @param gravity
* @param quality
* @param borderWidth
* @param borderColor
@@ -211,6 +212,7 @@ class Storage(private val client: Client) : BaseService(client) {
fileId: String,
width: Int? = null,
height: Int? = null,
gravity: String? = null,
quality: Int? = null,
borderWidth: Int? = null,
borderColor: String? = null,
@@ -224,6 +226,7 @@ class Storage(private val client: Client) : BaseService(client) {
val params = mapOf<String, Any?>(
"width" to width,
"height" to height,
"gravity" to gravity,
"quality" to quality,
"borderWidth" to borderWidth,
"borderColor" to borderColor,