Skip to content

Commit

Permalink
Merge commit 'cbf5fc6544825b3649af88fddc3b09151265e7d5' into v9-andro…
Browse files Browse the repository at this point in the history
…id-testing
  • Loading branch information
AyushBherwani1998 committed Dec 6, 2024
2 parents ebd12a1 + cbf5fc6 commit e7ca240
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
implementation 'org.web3j:core:4.8.7-android'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
2 changes: 1 addition & 1 deletion android/android-auth0-example/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
implementation 'org.web3j:core:4.8.7-android'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Expand Down
2 changes: 1 addition & 1 deletion android/android-firebase-example/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
implementation 'org.web3j:core:4.8.7-android'
implementation platform('com.google.firebase:firebase-bom:31.0.2')
implementation 'com.google.firebase:firebase-auth-ktx'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.google.firebase.auth.GetTokenResult
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
import com.google.gson.Gson
import com.google.gson.JsonArray
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.*
import org.web3j.crypto.Credentials
Expand Down
2 changes: 1 addition & 1 deletion android/android-playground/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
implementation("com.google.accompanist:accompanist-pager:0.13.0")
implementation("com.google.accompanist:accompanist-pager-indicators:0.27.1")
implementation("androidx.compose.material:material-icons-extended:1.6.7")
implementation("com.github.web3auth:web3auth-android-sdk:9.0.0")
implementation("com.github.web3auth:web3auth-android-sdk:9.0.1")
debugImplementation("androidx.compose.ui:ui-tooling:1.6.7")
implementation("androidx.compose.ui:ui-tooling-preview:1.6.7")
implementation("androidx.activity:activity-compose:1.9.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class MainActivity : ComponentActivity() {
modules(appModule)
}

viewModel.setResultUrl(intent?.data)

setContent {
AndroidplaygroundTheme {
// A surface container using the 'background' color from the theme
Expand All @@ -43,6 +41,7 @@ class MainActivity : ComponentActivity() {
}
}
viewModel.initialise()
viewModel.setResultUrl(intent?.data)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Web3AuthHelperImpl(
}

override suspend fun initialize(): CompletableFuture<Void> {
return web3Auth.initialize()
return web3Auth.initialize()
}

override suspend fun setResultUrl(uri: Uri?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private fun getWeb3AuthHelper(context: Context): Web3AuthHelper {
clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
network = Network.SAPPHIRE_MAINNET,
redirectUrl = Uri.parse( "w3a://com.example.android_playground/auth")
), context
), context.applicationContext
)

return Web3AuthHelperImpl(web3Auth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper) : ViewModel() {

fun initialise() {
viewModelScope.launch {
web3AuthHelper.initialize().await()
try {
web3AuthHelper.initialize().await()
}catch (e: Exception) {
Log.e("Initialize", e.toString())
}
isUserLoggedIn()
}
}
Expand Down Expand Up @@ -122,9 +126,9 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper) : ViewModel() {
viewModelScope.launch {
try {
web3AuthHelper.logOut().await()
_isLoggedIn.emit(true)
} catch (e: Exception) {
_isLoggedIn.emit(false)
} catch (e: Exception) {
_isLoggedIn.emit(true)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/android-playground/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.7.2" apply false
id("com.android.application") version "8.2.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}
2 changes: 1 addition & 1 deletion android/android-quick-start/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.9.1'
// IMP START - Installation
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
// IMP END - Installation
implementation 'org.web3j:core:4.8.7-android'
testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class MainActivity : AppCompatActivity() {
val logoutCompletableFuture = web3Auth.logout()
// IMP END - Logout
logoutCompletableFuture.whenComplete { _, error ->

if (error == null) {
val user = web3Auth.getUserInfo()
Log.i("UserInfo", user.toString())
reRender()
} else {
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
Expand Down
4 changes: 2 additions & 2 deletions android/android-quick-start/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.7.2' apply false
id 'com.android.library' version '8.7.2' apply false
id 'com.android.application' version '8.2.0' apply false
id 'com.android.library' version '8.2.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

Expand Down
1 change: 0 additions & 1 deletion android/android-quick-start/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion android/android-solana-example/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("com.github.Web3Auth:web3auth-android-sdk:9.0.0")
implementation("com.github.Web3Auth:web3auth-android-sdk:9.0.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ class Web3AuthHelperImpl(
}

override suspend fun initialize(): CompletableFuture<Void> {
return web3Auth.initialize()
try {
return web3Auth.initialize()
} catch(e: Exception) {
// Something went wrong
throw e
}
}

override suspend fun setResultUrl(uri: Uri?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.androidsolanaexample.viewmodel
import android.net.Uri
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.androidsolanaexample.data.Web3AuthHelper
Expand Down Expand Up @@ -48,7 +49,11 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper, private val sola

fun initialise() {
viewModelScope.launch {
web3AuthHelper.initialize().await()
try {
web3AuthHelper.initialize().await()
} catch (e:Exception) {
Log.e("Initialization", e.toString())
}
isUserLoggedIn()
}
}
Expand Down Expand Up @@ -84,9 +89,10 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper, private val sola
viewModelScope.launch {
try {
web3AuthHelper.logOut().await()
_isLoggedIn.emit(true)
} catch (e: Exception) {
_isLoggedIn.emit(false)
} catch (e: Exception) {
Log.e("Logout", e.toString())
_isLoggedIn.emit(true)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/android-solana-example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.7.2" apply false
id("com.android.application") version "8.2.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}

0 comments on commit e7ca240

Please sign in to comment.