diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthChooseProfilePictureFragment.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthChooseProfilePictureFragment.kt index bc1bf0c8bc..81300932db 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthChooseProfilePictureFragment.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthChooseProfilePictureFragment.kt @@ -22,6 +22,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.core.view.isInvisible import com.airbnb.mvrx.withState import im.vector.app.R import im.vector.app.core.di.ActiveSessionHolder @@ -70,6 +71,8 @@ class FtueAuthChooseProfilePictureFragment @Inject constructor( } override fun updateWithState(state: OnboardingViewState) { + views.profilePictureToolbar.isInvisible = !state.personalizationState.supportsChangingDisplayName + val hasSetPicture = state.personalizationState.selectedPictureUri != null views.profilePictureSubmit.isEnabled = hasSetPicture views.changeProfilePictureIcon.setImageResource(if (hasSetPicture) R.drawable.ic_edit else R.drawable.ic_camera_plain) @@ -93,4 +96,14 @@ class FtueAuthChooseProfilePictureFragment @Inject constructor( override fun resetViewModel() { // Nothing to do } + + override fun onBackPressed(toolbarButton: Boolean): Boolean { + return when (withState(viewModel) { it.personalizationState.supportsChangingDisplayName }) { + true -> super.onBackPressed(toolbarButton) + false -> { + viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnTakeMeHome)) + true + } + } + } } diff --git a/vector/src/main/res/layout/fragment_ftue_profile_picture.xml b/vector/src/main/res/layout/fragment_ftue_profile_picture.xml index 0def088062..6ebb5cc2f6 100644 --- a/vector/src/main/res/layout/fragment_ftue_profile_picture.xml +++ b/vector/src/main/res/layout/fragment_ftue_profile_picture.xml @@ -31,6 +31,7 @@ style="@style/Widget.Vector.Toolbar.Settings" android:layout_width="match_parent" android:layout_height="wrap_content" + android:visibility="invisible" app:layout_constraintBottom_toTopOf="@id/profilePictureView" app:layout_constraintTop_toBottomOf="@id/profilePictureToolbar" app:layout_constraintTop_toTopOf="parent"