-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f62b84
commit 1ce319f
Showing
53 changed files
with
1,061 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Fri Mar 22 13:40:55 IST 2024 | ||
gradle.version=8.2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#Fri Mar 22 13:39:34 IST 2024 | ||
java.home=/Applications/Android Studio.app/Contents/jbr/Contents/Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "com.example.tkey_android_mpc" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.example.tkey_android_mpc" | ||
minSdk = 24 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
manifestPlaceholders["torusRedirectScheme"] = "torusapp" | ||
manifestPlaceholders [ "torusRedirectHost"] = "org.torusresearch.customauthandroid" | ||
manifestPlaceholders["torusRedirectPathPrefix"]= "/redirect" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
|
||
vectorDrawables { | ||
useSupportLibrary = true | ||
} | ||
} | ||
|
||
configurations { | ||
all { | ||
exclude("com.github.grvgoel81","fetch-node-details-java") | ||
exclude("org.torusresearch", "torus-utils-java") | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
compose = true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion = "1.5.1" | ||
} | ||
packaging { | ||
resources { | ||
excludes += "/META-INF/{AL2.0,LGPL2.1}" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("io.insert-koin:koin-android:3.5.3") | ||
implementation("org.torusresearch:customauth-android-sdk:5.0.2") | ||
implementation("com.github.tkey:tkey-mpc-android:0.1.1") | ||
implementation("androidx.core:core-ktx:1.12.0") | ||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") | ||
implementation("androidx.activity:activity-compose:1.8.2") | ||
implementation(platform("androidx.compose:compose-bom:2023.08.00")) | ||
implementation("androidx.compose.ui:ui") | ||
implementation("androidx.compose.ui:ui-graphics") | ||
implementation("androidx.compose.ui:ui-tooling-preview") | ||
implementation("androidx.compose.material3:material3") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
androidTestImplementation(platform("androidx.compose:compose-bom:2023.08.00")) | ||
androidTestImplementation("androidx.compose.ui:ui-test-junit4") | ||
debugImplementation("androidx.compose.ui:ui-tooling") | ||
debugImplementation("androidx.compose.ui:ui-test-manifest") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...roid-mpc/app/src/androidTest/java/com/example/tkey_android_mpc/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.tkey_android_mpc | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.example.tkey_android_mpc", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.AppCompat.Light" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:launchMode="singleTop" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme.Tkeyandroidmpc"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
38 changes: 38 additions & 0 deletions
38
tkey-android-mpc/app/src/main/java/com/example/tkey_android_mpc/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.example.tkey_android_mpc | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.ui.Modifier | ||
import com.example.tkey_android_mpc.di.appModule | ||
import com.example.tkey_android_mpc.ui.presentation.MainScreen | ||
import com.example.tkey_android_mpc.ui.theme.TkeyandroidmpcTheme | ||
import com.example.tkey_android_mpc.viewmodel.MainViewModel | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.context.GlobalContext.startKoin | ||
|
||
class MainActivity : ComponentActivity() { | ||
private val viewModel: MainViewModel by viewModel() | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
startKoin { | ||
androidContext(this@MainActivity) | ||
modules(appModule) | ||
} | ||
setContent { | ||
TkeyandroidmpcTheme { | ||
// A surface container using the 'background' color from the theme | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colorScheme.background | ||
) { | ||
MainScreen(viewModel = viewModel) | ||
} | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
tkey-android-mpc/app/src/main/java/com/example/tkey_android_mpc/di/appModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.example.tkey_android_mpc.di | ||
|
||
import android.content.Context | ||
import com.example.tkey_android_mpc.viewmodel.MainViewModel | ||
import org.koin.androidx.viewmodel.dsl.viewModel | ||
import org.koin.dsl.module | ||
import org.torusresearch.customauth.CustomAuth | ||
import org.torusresearch.customauth.types.CustomAuthArgs | ||
import org.torusresearch.fetchnodedetails.types.TorusNetwork | ||
|
||
val appModule = module { | ||
single { | ||
getCustomAuth(get()) | ||
} | ||
|
||
viewModel { MainViewModel(get()) } | ||
} | ||
|
||
private fun getCustomAuth(context: Context): CustomAuth { | ||
val customAuthArgs = CustomAuthArgs( | ||
"https://scripts.toruswallet.io/redirect.html", | ||
TorusNetwork.TESTNET, | ||
"torusapp://org.torusresearch.customauthandroid/redirect", | ||
) | ||
|
||
return CustomAuth(customAuthArgs, context) | ||
} |
48 changes: 48 additions & 0 deletions
48
...android-mpc/app/src/main/java/com/example/tkey_android_mpc/ui/presentation/LoginScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.example.tkey_android_mpc.ui.presentation | ||
|
||
import android.widget.Toast | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.example.tkey_android_mpc.viewmodel.MainViewModel | ||
|
||
@Composable | ||
fun LoginScreen(viewModel: MainViewModel) { | ||
val context = LocalContext.current | ||
Column( | ||
modifier = Modifier.fillMaxSize().padding(16.dp), | ||
verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterVertically), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
) { | ||
Text( | ||
text = "tKey Android Example", | ||
textAlign = TextAlign.Center, | ||
style = MaterialTheme.typography.headlineSmall | ||
) | ||
|
||
LoginButton { | ||
try { | ||
viewModel.loginWithOAuth() | ||
} catch (e: Exception) { | ||
Toast.makeText(context, e.localizedMessage, Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun LoginButton(onClick: () -> Unit) { | ||
Button(onClick = { onClick() }) { | ||
Text("Login with Google") | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...-android-mpc/app/src/main/java/com/example/tkey_android_mpc/ui/presentation/MainScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.tkey_android_mpc.ui.presentation | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import com.example.tkey_android_mpc.viewmodel.MainViewModel | ||
|
||
@Composable | ||
fun MainScreen(viewModel: MainViewModel) { | ||
val isLoggedIn = viewModel.isLoggedIn.collectAsState() | ||
if (!isLoggedIn.value) { | ||
return LoginScreen(viewModel) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tkey-android-mpc/app/src/main/java/com/example/tkey_android_mpc/ui/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example.tkey_android_mpc.ui.theme | ||
|
||
import androidx.compose.ui.graphics.Color | ||
|
||
val Purple80 = Color(0xFFD0BCFF) | ||
val PurpleGrey80 = Color(0xFFCCC2DC) | ||
val Pink80 = Color(0xFFEFB8C8) | ||
|
||
val Purple40 = Color(0xFF6650a4) | ||
val PurpleGrey40 = Color(0xFF625b71) | ||
val Pink40 = Color(0xFF7D5260) |
Oops, something went wrong.