diff --git a/demoapp/build.gradle b/demoapp/build.gradle index d4ccf4e..d78ddfd 100644 --- a/demoapp/build.gradle +++ b/demoapp/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +apply plugin: "kotlin-kapt" android { compileSdkVersion 29 @@ -13,7 +14,7 @@ android { defaultConfig { applicationId "com.mushare.demoapp" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -30,6 +31,11 @@ android { } +repositories { + jcenter() + maven { url "https://jitpack.io" } //Make sure to add this in your project for uCrop +} + dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" @@ -39,6 +45,10 @@ dependencies { implementation 'androidx.annotation:annotation:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' + implementation 'com.github.dhaval2404:imagepicker:1.7.5' + implementation 'com.github.florent37:inline-activity-result-kotlin:1.0.4' + implementation 'com.github.bumptech.glide:glide:4.11.0' + kapt 'com.github.bumptech.glide:compiler:4.11.0' testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' diff --git a/demoapp/src/main/AndroidManifest.xml b/demoapp/src/main/AndroidManifest.xml index 8a91dc4..9fd7c18 100644 --- a/demoapp/src/main/AndroidManifest.xml +++ b/demoapp/src/main/AndroidManifest.xml @@ -10,7 +10,8 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:requestLegacyExternalStorage="true"> diff --git a/demoapp/src/main/java/com/mushare/demoapp/ui/login/ProfileActivity.kt b/demoapp/src/main/java/com/mushare/demoapp/ui/login/ProfileActivity.kt index 80e9432..a5a1d68 100644 --- a/demoapp/src/main/java/com/mushare/demoapp/ui/login/ProfileActivity.kt +++ b/demoapp/src/main/java/com/mushare/demoapp/ui/login/ProfileActivity.kt @@ -1,17 +1,14 @@ package com.mushare.demoapp.ui.login; +import android.app.Activity import android.os.Bundle import android.util.Log -import android.widget.Button -import android.widget.EditText -import android.widget.TextView -import android.widget.Toast +import android.widget.* import androidx.appcompat.app.AppCompatActivity +import com.bumptech.glide.Glide +import com.github.dhaval2404.imagepicker.ImagePicker import com.mushare.demoapp.R -import com.mushare.plutosdk.Pluto -import com.mushare.plutosdk.getToken -import com.mushare.plutosdk.myInfo -import com.mushare.plutosdk.updateName +import com.mushare.plutosdk.* import java.lang.ref.WeakReference class ProfileActivity : AppCompatActivity() { @@ -21,30 +18,70 @@ class ProfileActivity : AppCompatActivity() { } private lateinit var nameEditText: WeakReference + private lateinit var avatarImageView: WeakReference override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_profile) - nameEditText = WeakReference(findViewById(R.id.profile_name)) + nameEditText = WeakReference(findViewById(R.id.profile_name)) + avatarImageView = WeakReference(findViewById(R.id.profile_avatar)) - Pluto.getInstance()?.myInfo(success = { - nameEditText.get()?.setText(it.name) - }) + updateUserInfo() Pluto.getInstance()?.getToken(completion = { findViewById(R.id.profile_access_token).text = it ?: "Refresh failed" }) + findViewById