-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from KoalaSat/amber-button
amber button
- Loading branch information
Showing
7 changed files
with
136 additions
and
69 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/koalasat/pokey/models/ExternalSigner.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,52 @@ | ||
package com.koalasat.pokey.models | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.util.Log | ||
import androidx.activity.result.ActivityResultLauncher | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.fragment.app.Fragment | ||
import com.koalasat.pokey.Pokey | ||
import com.vitorpamplona.quartz.signers.ExternalSignerLauncher | ||
import com.vitorpamplona.quartz.signers.SignerType | ||
import java.util.UUID | ||
import kotlin.coroutines.cancellation.CancellationException | ||
|
||
class ExternalSigner(fragment: Fragment) { | ||
private var nostrSignerLauncher: ActivityResultLauncher<Intent> | ||
private var externalSignerLauncher: ExternalSignerLauncher = ExternalSignerLauncher("", signerPackageName = "") | ||
|
||
init { | ||
nostrSignerLauncher = fragment.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> | ||
if (result.resultCode != Activity.RESULT_OK) { | ||
Log.e("Pokey", "ExternalSigner result error: ${result.resultCode}") | ||
} else { | ||
result.data?.let { externalSignerLauncher.newResult(it) } | ||
} | ||
} | ||
externalSignerLauncher.registerLauncher( | ||
launcher = { | ||
try { | ||
nostrSignerLauncher.launch(it) // This can remain if you still need to launch it | ||
} catch (e: Exception) { | ||
if (e is CancellationException) throw e | ||
Log.e("Pokey", "Error opening Signer app", e) | ||
} | ||
}, | ||
contentResolver = { Pokey.getInstance().contentResolverFn() }, | ||
) | ||
} | ||
|
||
fun savePubKey() { | ||
externalSignerLauncher.openSignerApp( | ||
"", | ||
SignerType.GET_PUBLIC_KEY, | ||
"", | ||
UUID.randomUUID().toString(), | ||
) { result -> | ||
val split = result.split("-") | ||
val pubkey = split.first() | ||
if (split.first().isNotEmpty()) EncryptedStorage.updatePubKey(pubkey) | ||
} | ||
} | ||
} |
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
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
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 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" | ||
android:viewportWidth="512" | ||
android:viewportHeight="512" | ||
android:width="24dp" | ||
android:height="24dp"> | ||
<path | ||
android:pathData="M25.438046 210.42424l209.016024 -2.11128 4.22256 263.90911z" | ||
android:fillColor="#FFFFFF" /> | ||
<path | ||
android:pathData="M490.70059 210.38399l-209.01604 -2.11126 -4.22257 263.90904z" | ||
android:fillColor="#FFFFFF" /> | ||
<path | ||
android:pathData="M14.881692 170.31006H143.66934L211.23008 39.411116 78.219875 37.299854Z" | ||
android:fillColor="#FFFFFF" /> | ||
<path | ||
android:pathData="M499.8572 169.51085H371.06957L303.50881 38.611891 436.51907 36.50063Z" | ||
android:fillColor="#FFFFFF" /> | ||
<path | ||
android:pathData="M186.53241 169.91315L255.56681 37.299854 329.46134 170.31006Z" | ||
android:fillColor="#FFFFFF" /> | ||
</vector> |
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
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