Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import com.microsoft.identity.nativeauth.statemachine.results.SignInResult
import com.microsoft.identity.nativeauth.statemachine.results.SignUpResult
import com.microsoft.identity.nativeauth.statemachine.states.SignInContinuationState
import com.microsoft.identity.nativeauth.statemachine.states.SignUpAttributesRequiredState
import com.microsoft.identity.nativeauth.statemachine.states.SignUpCodeRequiredState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -80,23 +79,15 @@ class SignUpAttributesFragment : Fragment() {
try {
val attributes = UserAttributes.Builder

// val attr1Key = binding.attr1KeyText.text.toString()
// if (attr1Key.isNotBlank()) {
// val attr1Value = binding.attr1ValueText.toString()
// attributes
// .customAttribute(attr1Key, attr1Value)
// }
//
// val attr2Key = binding.attr2KeyText.text.toString()
// if (attr2Key.isNotBlank()) {
// val attr2Value = binding.attr2ValueText.toString()
// attributes
// .customAttribute(attr2Key, attr2Value)
// }
val attr1Key = binding.attr1KeyText.text.toString()
val attr1Value = binding.attr1ValueText.text.toString()
attributes.customAttribute(attr1Key, attr1Value)

val testAttribute1 = UserAttributes.country("China").build()
val attr2Key = binding.attr2KeyText.text.toString()
val attr2Value = binding.attr2ValueText.text.toString()
attributes.customAttribute(attr2Key, attr2Value)

val actionResult = currentState.submitAttributes(testAttribute1)
val actionResult = currentState.submitAttributes(attributes.build())

when (actionResult) {
is SignUpResult.Complete -> {
Expand All @@ -108,17 +99,9 @@ class SignUpAttributesFragment : Fragment() {
signInAfterSignUp(actionResult.nextState)
}
is SignUpResult.AttributesRequired -> {
val testAttribute2 = UserAttributes.city("Shanghai").build()
val nextState = actionResult.nextState
val result = nextState.submitAttributes(testAttribute2)
if (result is SignUpResult.Complete) {
Toast.makeText(
requireContext(),
getString(R.string.sign_up_successful_message),
Toast.LENGTH_SHORT
).show()
signInAfterSignUp(result.nextState)
}
navigateToAttributes(
nextState = actionResult.nextState
)
}
else -> {
displayDialog(getString(R.string.msal_exception_title),"Unexpected result: $actionResult")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SignUpPasswordFragment : Fragment() {
_binding = FragmentPasswordBinding.inflate(inflater, container, false)

val bundle = this.arguments
currentState = bundle!!.getSerializable(Constants.STATE) as SignUpPasswordRequiredState
currentState = (bundle?.getParcelable(Constants.STATE) as? SignUpPasswordRequiredState)!!

init()

Expand Down
228 changes: 115 additions & 113 deletions testapps/testapp/src/main/res/layout/fragment_attribute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,126 +10,128 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<!-- <TextView-->
<!-- android:id="@+id/intro"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/attributes_intro"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="parent"-->
<!-- />-->

<!-- <TextView-->
<!-- android:id="@+id/attr1_key_hint"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/attribute_attr1_key"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/intro"-->
<!-- style="@style/TextViewStyle" />-->

<!-- <com.google.android.material.textfield.TextInputLayout-->
<!-- android:id="@+id/attr1_key_input"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr1_key_hint"-->
<!-- style="@style/TextInputLayoutStyle">-->

<!-- <com.google.android.material.textfield.TextInputEditText-->
<!-- android:id="@+id/attr1_key_text"-->
<!-- android:layout_width="match_parent"-->
<!-- android:inputType="textPersonName"-->
<!-- tools:ignore="SpeakableTextPresentCheck"-->
<!-- style="@style/TextInputEditTextStyle" />-->
<!-- </com.google.android.material.textfield.TextInputLayout>-->

<!-- <TextView-->
<!-- android:id="@+id/attr1_value_hint"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/attribute_attr1_value"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr1_key_input"-->
<!-- style="@style/TextViewStyle" />-->

<!-- <com.google.android.material.textfield.TextInputLayout-->
<!-- android:id="@+id/attr1_value_input"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr1_value_hint"-->
<!-- style="@style/TextInputLayoutStyle">-->

<!-- <com.google.android.material.textfield.TextInputEditText-->
<!-- android:id="@+id/attr1_value_text"-->
<!-- android:layout_width="match_parent"-->
<!-- android:inputType="textPersonName"-->
<!-- tools:ignore="SpeakableTextPresentCheck"-->
<!-- style="@style/TextInputEditTextStyle" />-->
<!-- </com.google.android.material.textfield.TextInputLayout>-->

<!-- <TextView-->
<!-- android:id="@+id/attr2_key_hint"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/attribute_attr2_key"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr1_value_input"-->
<!-- style="@style/TextViewStyle" />-->

<!-- <com.google.android.material.textfield.TextInputLayout-->
<!-- android:id="@+id/attr2_key_input"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr2_key_hint"-->
<!-- style="@style/TextInputLayoutStyle">-->

<!-- <com.google.android.material.textfield.TextInputEditText-->
<!-- android:id="@+id/attr2_key_text"-->
<!-- android:layout_width="match_parent"-->
<!-- android:inputType="textPersonName"-->
<!-- tools:ignore="SpeakableTextPresentCheck"-->
<!-- style="@style/TextInputEditTextStyle" />-->
<!-- </com.google.android.material.textfield.TextInputLayout>-->

<!-- <TextView-->
<!-- android:id="@+id/attr2_value_hint"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="@string/attribute_attr2_value"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr2_key_input"-->
<!-- style="@style/TextViewStyle" />-->

<!-- <com.google.android.material.textfield.TextInputLayout-->
<!-- android:id="@+id/attr2_value_input"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/attr2_value_hint"-->
<!-- style="@style/TextInputLayoutStyle">-->

<!-- <com.google.android.material.textfield.TextInputEditText-->
<!-- android:id="@+id/attr2_value_text"-->
<!-- android:layout_width="match_parent"-->
<!-- android:inputType="textPersonName"-->
<!-- tools:ignore="SpeakableTextPresentCheck"-->
<!-- style="@style/TextInputEditTextStyle" />-->
<!-- </com.google.android.material.textfield.TextInputLayout>-->
<TextView
android:id="@+id/intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/attributes_intro"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/TextViewStyle"
/>

<TextView
android:id="@+id/attr1_key_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/attribute_attr1_key"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/intro"
style="@style/TextViewStyle" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/attr1_key_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr1_key_hint"
style="@style/TextInputLayoutStyle">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/attr1_key_text"
android:layout_width="match_parent"
android:inputType="textPersonName"
tools:ignore="SpeakableTextPresentCheck"
style="@style/TextInputEditTextStyle" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/attr1_value_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/attribute_attr1_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr1_key_input"
style="@style/TextViewStyle" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/attr1_value_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr1_value_hint"
style="@style/TextInputLayoutStyle">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/attr1_value_text"
android:layout_width="match_parent"
android:inputType="textPersonName"
tools:ignore="SpeakableTextPresentCheck"
style="@style/TextInputEditTextStyle" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/attr2_key_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/attribute_attr2_key"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr1_value_input"
style="@style/TextViewStyle" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/attr2_key_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr2_key_hint"
style="@style/TextInputLayoutStyle">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/attr2_key_text"
android:layout_width="match_parent"
android:inputType="textPersonName"
tools:ignore="SpeakableTextPresentCheck"
style="@style/TextInputEditTextStyle" />
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:id="@+id/attr2_value_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/attribute_attr2_value"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr2_key_input"
style="@style/TextViewStyle" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/attr2_value_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr2_value_hint"
style="@style/TextInputLayoutStyle">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/attr2_value_text"
android:layout_width="match_parent"
android:inputType="textPersonName"
tools:ignore="SpeakableTextPresentCheck"
style="@style/TextInputEditTextStyle" />
</com.google.android.material.textfield.TextInputLayout>

<Button
android:id="@+id/submit_attributes"
android:text="@string/submit_attributes"
android:layout_marginTop="@dimen/dimens_30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/attr2_value_input"
style="@style/ActionButtonStyle" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down