Skip to content

Commit

Permalink
Merge pull request #37 from greenart7c3/content_resolver
Browse files Browse the repository at this point in the history
Fix Content resolver not working
  • Loading branch information
KoalaSat authored Nov 6, 2024
2 parents 3314eb3 + 2038702 commit a8e7edd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<action android:name="android.intent.action.VIEW" />
<data android:scheme="nostr" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="nostrsigner" />
</intent>
</queries>

<application
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/koalasat/pokey/models/EncryptedStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ object PrefKeys {
const val NOTIFY_MENTIONS = "notify_mentions"
const val NOTIFY_REPOSTS = "notify_reposts"
const val NOTIFY_FOLLOWS = "notify_follows"
const val EXTERNAL_SIGNER = "external_signer"
}
object DefaultKeys {
const val BROADCAST = true
Expand All @@ -29,6 +30,7 @@ object DefaultKeys {
const val NOTIFY_MENTIONS = true
const val NOTIFY_REPOSTS = true
const val NOTIFY_FOLLOWS = true
const val EXTERNAL_SIGNER = "com.greenart7c3.nostrsigner"
}

object EncryptedStorage {
Expand Down Expand Up @@ -57,6 +59,8 @@ object EncryptedStorage {
val notifyResposts: LiveData<Boolean> get() = _notifyResposts
private val _notifyFollows = MutableLiveData<Boolean>().apply { DefaultKeys.NOTIFY_FOLLOWS }
val notifyFollows: LiveData<Boolean> get() = _notifyFollows
private val _externalSigner = MutableLiveData<String>().apply { DefaultKeys.EXTERNAL_SIGNER }
val externalSigner: LiveData<String> get() = _externalSigner

fun init(context: Context) {
val masterKey: MasterKey =
Expand All @@ -82,6 +86,12 @@ object EncryptedStorage {
_notifyMentions.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_MENTIONS, DefaultKeys.NOTIFY_MENTIONS)
_notifyResposts.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_REPOSTS, DefaultKeys.NOTIFY_REPOSTS)
_notifyFollows.value = sharedPreferences.getBoolean(PrefKeys.NOTIFY_FOLLOWS, DefaultKeys.NOTIFY_FOLLOWS)
_externalSigner.value = sharedPreferences.getString(PrefKeys.EXTERNAL_SIGNER, DefaultKeys.EXTERNAL_SIGNER) ?: DefaultKeys.EXTERNAL_SIGNER
}

fun updateExternalSigner(newValue: String) {
sharedPreferences.edit().putString(PrefKeys.EXTERNAL_SIGNER, newValue).apply()
_externalSigner.value = newValue
}

fun updatePubKey(newValue: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ object ExternalSigner {
val pubkey = split.first()
if (split.first().isNotEmpty()) {
EncryptedStorage.updatePubKey(pubkey)
if (split.size > 1) {
EncryptedStorage.updateExternalSigner(split[1])
}
startLauncher()
}
}
Expand Down Expand Up @@ -98,7 +101,10 @@ object ExternalSigner {
private fun startLauncher() {
var pubKey = EncryptedStorage.pubKey.value
if (pubKey == null) pubKey = ""
externalSignerLauncher = ExternalSignerLauncher(pubKey, signerPackageName = "")
var externalSignerPackage = EncryptedStorage.externalSigner.value
if (externalSignerPackage == null) externalSignerPackage = ""
if (pubKey.isEmpty()) externalSignerPackage = ""
externalSignerLauncher = ExternalSignerLauncher(pubKey, signerPackageName = externalSignerPackage)
externalSignerLauncher.registerLauncher(
launcher = {
try {
Expand Down

0 comments on commit a8e7edd

Please sign in to comment.