Skip to content

Commit 203298f

Browse files
committed
Fix conflicts and suggestions
1 parent 3b21274 commit 203298f

File tree

7 files changed

+71
-83
lines changed

7 files changed

+71
-83
lines changed

Shrine/app/src/main/java/com/authentication/shrine/CredentialManagerUtils.kt

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package com.authentication.shrine
1717

1818
import android.annotation.SuppressLint
1919
import android.content.Context
20+
import android.util.Log
2021
import androidx.credentials.ClearCredentialStateRequest
2122
import androidx.credentials.ClearCredentialStateRequest.Companion.TYPE_CLEAR_RESTORE_CREDENTIAL
2223
import androidx.credentials.CreateCredentialRequest
@@ -60,6 +61,7 @@ class CredentialManagerUtils @Inject constructor(
6061
private val dataStore: DataStore<Preferences>,
6162
) {
6263

64+
private val TAG = "CredentialManagerUtils"
6365
/**
6466
* Retrieves a passkey or password credential from the credential manager.
6567
*
@@ -264,46 +266,66 @@ class CredentialManagerUtils @Inject constructor(
264266
suspend fun signalUnknown(
265267
credentialId: String,
266268
) {
267-
credentialManager.signalCredentialState(
268-
request = SignalUnknownCredentialRequest(
269-
requestJson = JSONObject().apply {
270-
put("rpId", dataStore.read(RP_ID_KEY))
271-
put("credentialId", credentialId)
272-
}.toString()
273-
),
274-
)
269+
dataStore.read(RP_ID_KEY)?.let { rpId ->
270+
credentialManager.signalCredentialState(
271+
request = SignalUnknownCredentialRequest(
272+
requestJson = JSONObject().apply {
273+
put("rpId", rpId)
274+
put("credentialId", credentialId)
275+
}.toString()
276+
),
277+
)
278+
} ?: Log.e(TAG, "RP ID not present")
275279
}
276280

277281
@SuppressLint("RestrictedApi")
278282
suspend fun signalAcceptedIds(
279283
credentialIds: List<String>,
280284
) {
281-
credentialManager.signalCredentialState(
282-
request = SignalAllAcceptedCredentialIdsRequest(
283-
requestJson = JSONObject().apply {
284-
put("rpId", dataStore.read(RP_ID_KEY))
285-
put("userId", dataStore.read(USER_ID_KEY))
286-
put("allAcceptedCredentialIds", JSONArray(credentialIds))
287-
}.toString()
288-
),
289-
)
285+
val rpId = dataStore.read(RP_ID_KEY)
286+
val userId = dataStore.read(USER_ID_KEY)
287+
288+
if (rpId.isNullOrBlank()) {
289+
Log.e(TAG, "RP ID not present")
290+
} else if (userId.isNullOrBlank()) {
291+
Log.e(TAG, "User ID not present")
292+
} else {
293+
credentialManager.signalCredentialState(
294+
request = SignalAllAcceptedCredentialIdsRequest(
295+
requestJson = JSONObject().apply {
296+
put("rpId", rpId)
297+
put("userId", userId)
298+
put("allAcceptedCredentialIds", JSONArray(credentialIds))
299+
}.toString()
300+
),
301+
)
302+
}
290303
}
291304

292305
@SuppressLint("RestrictedApi")
293306
suspend fun signalUserDetails(
294307
newName: String,
295308
newDisplayName: String,
296309
) {
297-
credentialManager.signalCredentialState(
298-
request = SignalCurrentUserDetailsRequest(
299-
requestJson = JSONObject().apply {
300-
put("rpId", dataStore.read(RP_ID_KEY))
301-
put("userId", dataStore.read(USER_ID_KEY))
302-
put("name", newName)
303-
put("displayName", newDisplayName)
304-
}.toString()
305-
),
306-
)
310+
val rpId = dataStore.read(RP_ID_KEY)
311+
val userId = dataStore.read(USER_ID_KEY)
312+
313+
if (rpId.isNullOrBlank()) {
314+
Log.e(TAG, "RP ID not present")
315+
} else if (userId.isNullOrBlank()) {
316+
Log.e(TAG, "User ID not present")
317+
} else {
318+
credentialManager.signalCredentialState(
319+
request = SignalCurrentUserDetailsRequest(
320+
requestJson = JSONObject().apply {
321+
put("rpId", rpId)
322+
put("userId", userId)
323+
put("name", newName)
324+
put("displayName", newDisplayName)
325+
}.toString()
326+
),
327+
)
328+
}
307329
}
308330
}
309331

Shrine/app/src/main/java/com/authentication/shrine/repository/AuthRepository.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,10 @@ class AuthRepository @Inject constructor(
451451
*/
452452
suspend fun signInWithFederatedTokenResponse(
453453
sessionId: String,
454-
<<<<<<< HEAD
455454
credentialResponse: GetCredentialResponse
456455
): AuthResult<Unit> {
457456
return try {
458457
val credential = credentialResponse.credential
459-
=======
460-
credentialResponse: GetCredentialResponse,
461-
): Boolean {
462-
val credential = credentialResponse.credential
463-
try {
464-
>>>>>>> b12d692 (Add spotless fixes)
465458
if (credential is CustomCredential) {
466459
val isSuccess = verifyIdToken(
467460
sessionId,

Shrine/app/src/main/java/com/authentication/shrine/ui/AuthenticationScreen.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,6 @@ fun AuthenticationScreen(
202202
)
203203
)
204204
}
205-
206-
// Sign in with Google image
207-
Image(
208-
painter = painterResource(id = R.drawable.siwg_button_light),
209-
contentDescription = stringResource(R.string.sign_in_with_google_button),
210-
modifier = Modifier
211-
.height(dimensionResource(R.dimen.siwg_button_height))
212-
.clickable(
213-
enabled = !uiState.isLoading,
214-
onClick = onSignInWithSignInWithGoogleRequest,
215-
),
216-
)
217205
}
218206

219207
if (uiState.isLoading) {

Shrine/app/src/main/java/com/authentication/shrine/ui/PasskeyManagementScreen.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ import androidx.compose.material3.TextButton
4242
import androidx.compose.runtime.Composable
4343
import androidx.compose.runtime.LaunchedEffect
4444
import androidx.compose.runtime.collectAsState
45-
<<<<<<< HEAD
46-
=======
47-
>>>>>>> b12d692 (Add spotless fixes)
4845
import androidx.compose.runtime.remember
4946
import androidx.compose.ui.Alignment
5047
import androidx.compose.ui.Modifier
@@ -255,6 +252,7 @@ fun PasskeysListColumn(
255252
credentialProviderName = item.name,
256253
passkeyCreationDate = item.registeredAt.toReadableDate(),
257254
isChecked = item.isSelected,
255+
onCheckboxClick = { onItemClick(index) },
258256
modifier = Modifier.clickable { onItemClick(index) },
259257
)
260258

@@ -288,6 +286,7 @@ fun PasskeysDetailsRow(
288286
credentialProviderName: String,
289287
passkeyCreationDate: String,
290288
isChecked: Boolean,
289+
onCheckboxClick: () -> Unit,
291290
modifier: Modifier = Modifier,
292291
) {
293292
Row(
@@ -306,8 +305,7 @@ fun PasskeysDetailsRow(
306305

307306
Checkbox(
308307
checked = isChecked,
309-
onCheckedChange = {},
310-
modifier = Modifier.clickable(enabled = false, onClick = { }),
308+
onCheckedChange = { onCheckboxClick() },
311309
)
312310

313311
Image(
@@ -373,18 +371,10 @@ fun PasskeyManagementScreenPreview() {
373371
providerIcon = ""
374372
)
375373
),
376-
<<<<<<< HEAD
377374
aaguidData = mapOf(),
378375
onItemClick = { _ -> },
379376
onSignal = { },
380377
)
381378
}
382-
=======
383-
),
384-
aaguidData = mapOf(),
385-
{ _ -> },
386-
{},
387-
)
388-
>>>>>>> b12d692 (Add spotless fixes)
389379
}
390380
}

Shrine/app/src/main/java/com/authentication/shrine/ui/UpdateProfileScreen.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package com.authentication.shrine.ui
1717

1818
import androidx.compose.foundation.layout.Column
1919
import androidx.compose.foundation.layout.fillMaxSize
20-
import androidx.compose.foundation.layout.fillMaxWidth
2120
import androidx.compose.runtime.Composable
2221
import androidx.compose.runtime.getValue
2322
import androidx.compose.runtime.mutableStateOf
@@ -46,13 +45,13 @@ fun UpdateProfileScreen(
4645
viewModel: UpdateProfileViewModel,
4746
) {
4847
var username by remember { mutableStateOf("") }
49-
var email by remember { mutableStateOf("") }
48+
var displayName by remember { mutableStateOf("") }
5049

5150
UpdateProfileScreen(
5251
username = username,
5352
onUsernameChanged = { username = it },
54-
displayName = email,
55-
onDisplayNameChanged = { email = it },
53+
displayName = displayName,
54+
onDisplayNameChanged = { displayName = it },
5655
onMetadataUpdate = viewModel::updateMetadata,
5756
onBackClicked = onBackClicked,
5857
)
@@ -86,17 +85,17 @@ fun UpdateProfileScreen(
8685
)
8786

8887
ShrineTextField(
89-
value = username,
90-
onValueChange = onUsernameChanged,
91-
hint = stringResource(R.string.username),
92-
modifier = Modifier.fillMaxWidth(),
88+
title = stringResource(R.string.username),
89+
text = username,
90+
enabled = true,
91+
onValueChanged = onUsernameChanged
9392
)
9493

9594
ShrineTextField(
96-
value = displayName,
97-
onValueChange = onDisplayNameChanged,
98-
hint = stringResource(R.string.display_name),
99-
modifier = Modifier.fillMaxWidth(),
95+
title = stringResource(R.string.display_name),
96+
text = displayName,
97+
enabled = true,
98+
onValueChanged = onDisplayNameChanged,
10099
)
101100

102101
ShrineButton(

Shrine/app/src/main/java/com/authentication/shrine/ui/common/ShrineTextField.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,22 @@ import androidx.compose.material3.Text
2828
import androidx.compose.runtime.Composable
2929
import androidx.compose.ui.Modifier
3030
import androidx.compose.ui.res.dimensionResource
31-
<<<<<<< HEAD
32-
=======
33-
import androidx.compose.ui.res.stringResource
34-
>>>>>>> b12d692 (Add spotless fixes)
3531
import androidx.compose.ui.tooling.preview.Preview
3632
import com.authentication.shrine.R
3733
import com.authentication.shrine.ui.theme.ShrineTheme
3834

3935
/**
4036
* A custom TextField composable for the Shrine app.
4137
*
42-
* @param modifier The modifier to be applied to the TextField.
43-
* @param value The current value of the TextField.
44-
* @param onValueChange The callback to be invoked when the TextField value changes.
38+
* @param title The current value of the TextField.
39+
* @param text The callback to be invoked when the TextField value changes.
4540
*/
4641
@Composable
4742
fun ShrineTextField(
4843
title: String,
4944
text: String = "",
45+
enabled: Boolean = false,
46+
onValueChanged: (String) -> Unit = {}
5047
) {
5148
Column(
5249
modifier = Modifier
@@ -61,10 +58,9 @@ fun ShrineTextField(
6158

6259
OutlinedTextField(
6360
value = text,
64-
onValueChange = { },
65-
modifier = Modifier
66-
.fillMaxWidth(),
67-
enabled = false,
61+
onValueChange = onValueChanged,
62+
modifier = Modifier.fillMaxWidth(),
63+
enabled = enabled,
6864
shape = RoundedCornerShape(dimensionResource(R.dimen.size_standard)),
6965
colors = OutlinedTextFieldDefaults.colors(
7066
disabledTextColor = MaterialTheme.colorScheme.onSurface

Shrine/gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ browser = "1.8.0"
66
coil = "2.7.0"
77
coilSvg = "2.6.0"
88
coreSplashscreen = "1.0.1"
9-
credentials = "1.6.0-alpha05"
9+
credentials = "1.6.0-beta02"
1010
datastorePrefs = "1.1.1"
1111
googleFonts = "1.6.8"
1212
googleServicesPlugin = "4.4.1"

0 commit comments

Comments
 (0)