Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions app/src/androidTest/java/to/bitkit/ui/components/TagButtonTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package to.bitkit.ui.components

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUi
import to.bitkit.ui.theme.AppThemeSurface

@HiltAndroidTest
@ComposeUi
class TagButtonTest {
@get:Rule
val hiltRule = HiltAndroidRule(this)

@get:Rule
val composeTestRule = createComposeRule()

@Before
fun setup() {
hiltRule.inject()
}

@Test
fun removableTagExposesItsAction() {
composeTestRule.setContent {
AppThemeSurface {
TagButton(
text = "Founder",
onClick = {},
accessibilityLabel = "Remove Founder tag",
displayIconClose = true,
)
}
}

composeTestRule.onNodeWithContentDescription("Remove Founder tag")
.assertHasClickAction()
composeTestRule.onNodeWithTag("Tag-Founder")
.assertHasClickAction()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package to.bitkit.ui.components.settings

import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsProperties
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsEnabled
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import to.bitkit.test.annotations.ComposeUi
import to.bitkit.ui.theme.AppThemeSurface

@HiltAndroidTest
@ComposeUi
class SettingsSwitchRowTest {
@get:Rule
val hiltRule = HiltAndroidRule(this)

@get:Rule
val composeTestRule = createComposeRule()

@Before
fun setup() {
hiltRule.inject()
}

@Test
fun switchSemanticsReflectCheckedState() {
composeTestRule.setContent {
AppThemeSurface {
SettingsSwitchRow(
title = "Contact payments",
isChecked = true,
onClick = {},
switchTestTag = "ContactPaymentsSwitch",
)
}
}

composeTestRule.onNodeWithTag("ContactPaymentsSwitch")
.assertIsOn()
.assertIsEnabled()
.assertHasClickAction()
.assert(SemanticsMatcher.expectValue(SemanticsProperties.Role, Role.Switch))
}

@Test
fun switchSemanticsReflectUncheckedState() {
composeTestRule.setContent {
AppThemeSurface {
SettingsSwitchRow(
title = "Contact payments",
isChecked = false,
onClick = {},
switchTestTag = "ContactPaymentsSwitch",
)
}
}

composeTestRule.onNodeWithTag("ContactPaymentsSwitch").assertIsOff()
}

@Test
fun switchSemanticsReflectDisabledState() {
composeTestRule.setContent {
AppThemeSurface {
SettingsSwitchRow(
title = "Contact payments",
isChecked = false,
onClick = {},
enabled = false,
switchTestTag = "ContactPaymentsSwitch",
)
}
}

composeTestRule.onNodeWithTag("ContactPaymentsSwitch")
.assertIsOff()
.assertIsNotEnabled()
}
}
15 changes: 14 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools">

<queries>
<package android:name="to.pubky.ring" />
<package android:name="app.pubkyring" />
<intent>
<action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />
</intent>
Expand All @@ -13,6 +13,12 @@
</intent>
</queries>

<permission
android:name="${applicationId}.permission.READ_SHARED_PUBKY"
android:protectionLevel="signature" />

<uses-permission android:name="app.pubkyring.permission.READ_SHARED_PUBKY" />

<uses-feature
android:name="android.hardware.camera"
android:required="false" />
Expand Down Expand Up @@ -188,6 +194,13 @@
android:exported="false"
tools:node="remove" />

<provider
android:name=".data.sharing.SharedPubkyProvider"
android:authorities="${applicationId}.sharedpubky"
android:exported="true"
android:readPermission="${applicationId}.permission.READ_SHARED_PUBKY"
android:writePermission="${applicationId}.permission.READ_SHARED_PUBKY" />

<!-- Set custom default icon.
This is used when no icon is set for incoming notification messages.
See https://goo.gl/l4GJaQ -->
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/to/bitkit/data/PubkyStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.serialization.Serializable
import to.bitkit.data.serializers.PubkyStoreSerializer
import to.bitkit.data.sharing.ExternalPubkyIdentityRef
import to.bitkit.models.PubkyProfileData
import javax.inject.Inject
import javax.inject.Singleton
Expand Down Expand Up @@ -38,4 +39,5 @@ data class PubkyStoreData(
val cachedName: String? = null,
val cachedImageUri: String? = null,
val contactProfileOverrides: Map<String, PubkyProfileData> = emptyMap(),
val externalIdentityRef: ExternalPubkyIdentityRef? = null,
)
10 changes: 9 additions & 1 deletion app/src/main/java/to/bitkit/data/SettingsStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SettingsStore @Inject constructor(

suspend fun restoreFromBackup(payload: SettingsBackupV1) =
runCatching {
val data = payload.settings.resetPin()
val data = payload.settings.resetPin().withDefaultPaykitPaymentMethods()
store.updateData { data }

val monitored = data.addressTypesToMonitor
Expand Down Expand Up @@ -164,6 +164,14 @@ fun SettingsData.resetPin() = this.copy(
isBiometricEnabled = false,
)

fun SettingsData.areContactPaymentsEnabled(): Boolean =
sharesPublicPaykitEndpoints || sharesPrivatePaykitEndpoints

fun SettingsData.withDefaultPaykitPaymentMethods() = copy(
publicPaykitLightningEnabled = true,
publicPaykitOnchainEnabled = true,
)

fun SettingsData.hasPublicPaykitPublicationState(): Boolean =
hasConfirmedPublicPaykitEndpoints ||
sharesPublicPaykitEndpoints ||
Expand Down
Loading
Loading