adding barebones server selection UI

This commit is contained in:
Adam Brown 2022-03-30 17:08:51 +01:00
parent 15cf0657e8
commit c3cf22158b
7 changed files with 349 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import androidx.appcompat.app.AppCompatActivity
import androidx.autofill.HintConstants
import androidx.core.text.isDigitsOnly
import androidx.core.view.isVisible
@ -29,6 +30,8 @@ import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.withState
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import im.vector.app.R
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.commitTransaction
import im.vector.app.core.extensions.content
import im.vector.app.core.extensions.editText
import im.vector.app.core.extensions.hasContentFlow
@ -36,6 +39,7 @@ import im.vector.app.core.extensions.hasSurroundingSpaces
import im.vector.app.core.extensions.hideKeyboard
import im.vector.app.core.extensions.hidePassword
import im.vector.app.core.extensions.realignPercentagesToParent
import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.databinding.FragmentFtueSignUpCombinedBinding
import im.vector.app.features.login.LoginMode
import im.vector.app.features.login.SSORedirectRouterActivity
@ -67,6 +71,12 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
views.createAccountRoot.realignPercentagesToParent()
views.editServerButton.debouncedClicks {
requireActivity().supportFragmentManager.commitTransaction(true) {
add(R.id.loginFragmentContainer, FtueAuthCombinedServerSelectionFragment(), null)
}
}
views.createAccountPasswordInput.editText().setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
submit()

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.onboarding.ftueauth
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import im.vector.app.databinding.FragmentFtueServerSelectionCombinedBinding
import im.vector.app.features.onboarding.OnboardingAction
import im.vector.app.features.onboarding.OnboardingViewEvents
import javax.inject.Inject
class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractSSOFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() {
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentFtueServerSelectionCombinedBinding {
return FragmentFtueServerSelectionCombinedBinding.inflate(inflater, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
views.chooseServerToolbar.setNavigationOnClickListener {
viewModel.handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnBack))
}
}
override fun resetViewModel() {
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="70dp"
android:height="70dp"
android:viewportWidth="70"
android:viewportHeight="70">
<path
android:pathData="M47.25,36.75H22.75C20.825,36.75 19.25,38.325 19.25,40.25V47.25C19.25,49.175 20.825,50.75 22.75,50.75H47.25C49.175,50.75 50.75,49.175 50.75,47.25V40.25C50.75,38.325 49.175,36.75 47.25,36.75ZM26.25,47.25C24.325,47.25 22.75,45.675 22.75,43.75C22.75,41.825 24.325,40.25 26.25,40.25C28.175,40.25 29.75,41.825 29.75,43.75C29.75,45.675 28.175,47.25 26.25,47.25ZM47.25,19.25H22.75C20.825,19.25 19.25,20.825 19.25,22.75V29.75C19.25,31.675 20.825,33.25 22.75,33.25H47.25C49.175,33.25 50.75,31.675 50.75,29.75V22.75C50.75,20.825 49.175,19.25 47.25,19.25ZM26.25,29.75C24.325,29.75 22.75,28.175 22.75,26.25C22.75,24.325 24.325,22.75 26.25,22.75C28.175,22.75 29.75,24.325 29.75,26.25C29.75,28.175 28.175,29.75 26.25,29.75Z"
android:fillColor="#ff0000"/>
</vector>

View File

@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="50dp"
android:height="50dp"
android:viewportWidth="50"
android:viewportHeight="50">
<path
android:pathData="M20.43,11.649C20.43,10.64 21.249,9.822 22.26,9.822C29.114,9.822 34.671,15.366 34.671,22.206C34.671,23.215 33.851,24.033 32.84,24.033C31.828,24.033 31.008,23.215 31.008,22.206C31.008,17.385 27.092,13.476 22.26,13.476C21.249,13.476 20.43,12.658 20.43,11.649Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M38.347,20.379C39.359,20.379 40.178,21.197 40.178,22.206C40.178,29.045 34.622,34.59 27.768,34.59C26.757,34.59 25.937,33.772 25.937,32.763C25.937,31.754 26.757,30.936 27.768,30.936C32.6,30.936 36.516,27.027 36.516,22.206C36.516,21.197 37.336,20.379 38.347,20.379Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M29.6,38.352C29.6,39.361 28.78,40.18 27.768,40.18C20.915,40.18 15.359,34.635 15.359,27.795C15.359,26.786 16.178,25.968 17.19,25.968C18.201,25.968 19.021,26.786 19.021,27.795C19.021,32.617 22.937,36.525 27.768,36.525C28.78,36.525 29.6,37.343 29.6,38.352Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
<path
android:pathData="M11.653,29.622C10.642,29.622 9.822,28.804 9.822,27.795C9.822,20.956 15.378,15.411 22.232,15.411C23.243,15.411 24.063,16.229 24.063,17.238C24.063,18.247 23.243,19.065 22.232,19.065C17.401,19.065 13.484,22.974 13.484,27.795C13.484,28.804 12.664,29.622 11.653,29.622Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</vector>

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/LoginFormScrollView"
android:layout_height="match_parent"
android:background="?android:colorBackground"
android:fillViewport="true"
android:paddingTop="0dp"
android:paddingBottom="0dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/chooseServerRoot"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/chooseServerGutterStart"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="@dimen/ftue_auth_gutter_start_percent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/chooseServerGutterEnd"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintGuide_percent="@dimen/ftue_auth_gutter_end_percent" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/chooseServerToolbar"
style="@style/Widget.Vector.Toolbar.Settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:layout_constraintBottom_toTopOf="@id/chooseServerHeaderIcon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0"
app:layout_constraintVertical_chainStyle="packed"
app:navigationIcon="@drawable/ic_close_24dp" />
<ImageView
android:id="@+id/chooseServerHeaderIcon"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:background="@drawable/circle"
android:backgroundTint="?colorSecondary"
android:contentDescription="@null"
android:src="@drawable/ic_choose_server"
app:layout_constraintBottom_toTopOf="@id/chooseServerHeaderTitle"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintHeight_percent="0.10"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerToolbar"
app:tint="@color/palette_white" />
<TextView
android:id="@+id/chooseServerHeaderTitle"
style="@style/Widget.Vector.TextView.Title.Medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:text="@string/ftue_auth_choose_server_title"
android:textColor="?vctr_content_primary"
app:layout_constraintBottom_toTopOf="@id/chooseServerHeaderSubtitle"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerHeaderIcon" />
<TextView
android:id="@+id/chooseServerHeaderSubtitle"
style="@style/Widget.Vector.TextView.Subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center"
android:text="@string/ftue_auth_choose_server_subtitle"
android:textColor="?vctr_content_secondary"
app:layout_constraintBottom_toTopOf="@id/titleContentSpacing"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerHeaderTitle" />
<Space
android:id="@+id/titleContentSpacing"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/chooseServerInput"
app:layout_constraintHeight_percent="0.03"
app:layout_constraintTop_toBottomOf="@id/chooseServerHeaderSubtitle" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/chooseServerInput"
style="@style/Widget.Vector.TextInputLayout.Username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/ftue_auth_choose_server_entry_hint"
app:layout_constraintBottom_toTopOf="@id/chooseServerEntryFooter"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/titleContentSpacing">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/chooseServerEntryFooter"
style="@style/Widget.Vector.TextView.Micro"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/ftue_auth_choose_server_entry_footer"
app:layout_constraintBottom_toTopOf="@id/actionSpacing"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerInput" />
<Space
android:id="@+id/actionSpacing"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/chooseServerSubmit"
app:layout_constraintHeight_percent="0.02"
app:layout_constraintTop_toBottomOf="@id/chooseServerEntryFooter" />
<Button
android:id="@+id/chooseServerSubmit"
style="@style/Widget.Vector.Button.Login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/login_signup_submit"
android:textAllCaps="true"
app:layout_constraintBottom_toTopOf="@id/chooseServerEmsContainer"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/actionSpacing" />
<Space
android:id="@+id/submitSpacing"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/emsTopSpacing"
app:layout_constraintHeight_percent="0.02"
app:layout_constraintTop_toBottomOf="@id/chooseServerSubmit" />
<View
android:id="@+id/chooseServerEmsContainer"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/rounded_rect_shape_8"
android:backgroundTint="?vctr_system"
app:layout_constraintBottom_toBottomOf="@id/emsCtaSpacing"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toTopOf="@id/emsTopSpacing"
app:layout_constraintVertical_bias="0.0" />
<Space
android:id="@+id/emsTopSpacing"
android:layout_width="match_parent"
android:layout_height="24dp"
app:layout_constraintBottom_toTopOf="@id/chooseServerEmsIcon"
app:layout_constraintTop_toBottomOf="@id/chooseServerSubmit"
app:layout_constraintVertical_bias="1"
app:layout_constraintVertical_chainStyle="packed" />
<ImageView
android:id="@+id/chooseServerEmsIcon"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="22dp"
android:adjustViewBounds="true"
android:background="@drawable/circle"
android:backgroundTint="@color/palette_ems"
android:contentDescription="@null"
android:src="@drawable/ic_ems_logo"
app:layout_constraintBottom_toTopOf="@id/chooseServerEmsTitle"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintHeight_percent="0.08"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/emsTopSpacing"
app:layout_constraintVertical_bias="1"
app:tint="@color/palette_white" />
<TextView
android:id="@+id/chooseServerEmsTitle"
style="@style/Widget.Vector.TextView.HeadlineMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="12dp"
android:gravity="center"
android:text="@string/ftue_auth_choose_server_ems_title"
app:layout_constraintBottom_toTopOf="@id/chooseServerEmsSubtitle"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerEmsIcon" />
<TextView
android:id="@+id/chooseServerEmsSubtitle"
style="@style/Widget.Vector.TextView.Body"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:text="@string/ftue_auth_choose_server_ems_subtitle"
app:layout_constraintBottom_toTopOf="@id/chooseServerGetInTouch"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerEmsTitle" />
<Button
android:id="@+id/chooseServerGetInTouch"
style="@style/Widget.Vector.Button.Login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:backgroundTint="@color/palette_ems"
android:text="@string/ftue_auth_choose_server_ems_cta"
android:textAllCaps="true"
app:layout_constraintBottom_toTopOf="@id/emsCtaSpacing"
app:layout_constraintEnd_toEndOf="@id/chooseServerGutterEnd"
app:layout_constraintStart_toStartOf="@id/chooseServerGutterStart"
app:layout_constraintTop_toBottomOf="@id/chooseServerEmsSubtitle" />
<Space
android:id="@+id/emsCtaSpacing"
android:layout_width="match_parent"
android:layout_height="16dp"
app:layout_constraintBottom_toTopOf="@id/footerSpacing"
app:layout_constraintTop_toBottomOf="@id/chooseServerGetInTouch" />
<Space
android:id="@+id/footerSpacing"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHeight_percent="0.03"
app:layout_constraintTop_toBottomOf="@id/emsCtaSpacing" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -139,7 +139,6 @@
android:paddingEnd="12dp"
android:text="@string/ftue_auth_create_account_edit_server_selection"
android:textAllCaps="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/selectedServerDescription"
app:layout_constraintEnd_toEndOf="@id/createAccountGutterEnd"
app:layout_constraintTop_toTopOf="@id/chooseYourServerHeader" />

View File

@ -20,4 +20,12 @@
<string name="ftue_auth_create_account_matrix_dot_org_server_name">matrix.org</string>
<string name="ftue_auth_create_account_edit_server_selection">Edit</string>
<string name="ftue_auth_choose_server_title">Choose your server</string>
<string name="ftue_auth_choose_server_subtitle">What is the address of your server? Server is like a home for all your data</string>
<string name="ftue_auth_choose_server_entry_hint">Server URL</string>
<string name="ftue_auth_choose_server_entry_footer">You can only connect to a server that has already been set up</string>
<string name="ftue_auth_choose_server_ems_title">Want to host your own server?</string>
<string name="ftue_auth_choose_server_ems_subtitle">Element Matrix Services (EMS) is a robust and reliable hosting service for fast, secure and real time communication. Find out how on element.io.ems</string>
<string name="ftue_auth_choose_server_ems_cta">Get in touch</string>
</resources>