Merge pull request #332 from vector-im/feature/login_warning

Improve login screen
This commit is contained in:
Benoit Marty 2019-07-11 15:25:11 +02:00 committed by GitHub
commit c4c5069ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 87 additions and 40 deletions

View File

@ -24,15 +24,27 @@ buildscript {
allprojects {
repositories {
maven { url "http://dl.bintray.com/piasy/maven" }
maven { url 'https://jitpack.io' }
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
maven {
url 'https://jitpack.io'
content {
// Use this repo only for olm library
includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
// And also for FilePicker
includeGroupByRegex "com\\.github\\.jaiselrahman"
// And monarchy
includeGroupByRegex "com\\.github\\.Zhuinden"
}
}
maven {
url "http://dl.bintray.com/piasy/maven"
content {
includeGroupByRegex "com\\.github\\.piasy"
}
}
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
google()
jcenter()
// For Olm SDK
maven {
url 'https://jitpack.io'
}
}
}

View File

@ -6,7 +6,6 @@ apply plugin: 'realm-android'
apply plugin: 'okreplay'
buildscript {
repositories {
jcenter()
}
@ -15,11 +14,6 @@ buildscript {
}
}
repositories {
google()
jcenter()
}
androidExtensions {
experimental = true
}

View File

@ -19,10 +19,12 @@ package im.vector.riotx.core.extensions
import android.text.Spannable
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.text.style.UnderlineSpan
import android.widget.TextView
import androidx.annotation.AttrRes
import androidx.annotation.StringRes
import androidx.core.view.isVisible
import im.vector.riotx.R
import im.vector.riotx.features.themes.ThemeUtils
@ -43,11 +45,13 @@ fun TextView.setTextOrHide(newText: CharSequence?, hideWhenBlank: Boolean = true
* Set text with a colored part
* @param fullTextRes the resource id of the full text. Value MUST contains a parameter for string, which will be replaced by the colored part
* @param coloredTextRes the resource id of the colored part of the text
* @param colorAttribute attribute of the color
* @param colorAttribute attribute of the color. Default to colorAccent
* @param underline true to also underline the text. Default to false
*/
fun TextView.setTextWithColoredPart(@StringRes fullTextRes: Int,
@StringRes coloredTextRes: Int,
@AttrRes colorAttribute: Int) {
@AttrRes colorAttribute: Int = R.attr.colorAccent,
underline: Boolean = false) {
val coloredPart = resources.getString(coloredTextRes)
// Insert colored part into the full text
val fullText = resources.getString(fullTextRes, coloredPart)
@ -60,5 +64,8 @@ fun TextView.setTextWithColoredPart(@StringRes fullTextRes: Int,
text = SpannableString(fullText)
.apply {
setSpan(foregroundSpan, index, index + coloredPart.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
if (underline) {
setSpan(UnderlineSpan(), index, index + coloredPart.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}

View File

@ -45,12 +45,7 @@ fun showDisclaimerDialog(activity: Activity) {
val textView = (dialogLayout as ViewGroup).findViewById<TextView>(R.id.dialogDisclaimerContentLine2)
@Suppress("ConstantConditionIf")
if (BuildConfig.FLAVOR == "gplay") {
textView.setTextWithColoredPart(
R.string.alpha_disclaimer_content_line_2_gplay,
R.string.alpha_disclaimer_content_line_2_gplay_colored_part,
R.attr.colorAccent
)
textView.setTextWithColoredPart(R.string.alpha_disclaimer_content_line_2_gplay, R.string.alpha_disclaimer_content_line_2_gplay_colored_part)
textView.setOnClickListener {
openPlayStore(activity)

View File

@ -19,8 +19,8 @@ package im.vector.riotx.features.login
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.core.view.isVisible
import arrow.core.Try
import com.jakewharton.rxbinding2.widget.RxTextView
import im.vector.matrix.android.api.MatrixCallback
@ -31,8 +31,10 @@ import im.vector.riotx.R
import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.configureAndStart
import im.vector.riotx.core.extensions.setTextWithColoredPart
import im.vector.riotx.core.extensions.showPassword
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.utils.openUrlInExternalBrowser
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
import im.vector.riotx.features.home.HomeActivity
import im.vector.riotx.features.notifications.PushRuleTriggerListener
@ -61,11 +63,20 @@ class LoginActivity : VectorBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
setupNotice()
setupAuthButton()
setupPasswordReveal()
homeServerField.setText(DEFAULT_HOME_SERVER_URI)
}
private fun setupNotice() {
riotx_no_registration_notice.setTextWithColoredPart(R.string.riotx_no_registration_notice, R.string.riotx_no_registration_notice_colored_part)
riotx_no_registration_notice.setOnClickListener {
openUrlInExternalBrowser(this@LoginActivity, "https://about.riot.im/downloads")
}
}
override fun onResume() {
super.onResume()
@ -85,7 +96,8 @@ class LoginActivity : VectorBaseActivity() {
}
private fun authenticateWith(homeServerConnectionConfig: HomeServerConnectionConfig, login: String, password: String) {
progressBar.visibility = View.VISIBLE
progressBar.isVisible = true
touchArea.isVisible = true
authenticator.authenticate(homeServerConnectionConfig, login, password, object : MatrixCallback<Session> {
override fun onSuccess(data: Session) {
activeSessionHolder.setActiveSession(data)
@ -94,7 +106,8 @@ class LoginActivity : VectorBaseActivity() {
}
override fun onFailure(failure: Throwable) {
progressBar.visibility = View.GONE
progressBar.isVisible = false
touchArea.isVisible = false
Toast.makeText(this@LoginActivity, "Authenticate failure: $failure", Toast.LENGTH_LONG).show()
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -16,25 +16,32 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingLeft="24dp"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingRight="24dp"
android:paddingBottom="80dp">
android:padding="24dp">
<ImageView
android:id="@+id/logoImageView"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/riot_splash_0_blue" />
android:src="@drawable/riotx_logo" />
<TextView
android:id="@+id/riotx_no_registration_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
android:gravity="center"
android:padding="8dp"
android:text="@string/riotx_no_registration_notice"
android:textColor="?vctr_notice_secondary"
android:textSize="15sp" />
<com.google.android.material.textfield.TextInputLayout
style="@style/VectorTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="14dp"
android:hint="@string/auth_user_name_placeholder">
<com.google.android.material.textfield.TextInputEditText
@ -43,17 +50,18 @@
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<com.google.android.material.textfield.TextInputLayout
style="@style/VectorTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="@string/auth_password_placeholder">
<com.google.android.material.textfield.TextInputEditText
@ -66,6 +74,7 @@
android:paddingEnd="48dp"
android:paddingRight="48dp"
tools:ignore="RtlSymmetry" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
@ -73,7 +82,7 @@
android:layout_width="@dimen/layout_touch_size"
android:layout_height="@dimen/layout_touch_size"
android:layout_gravity="end"
android:layout_marginTop="24dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackground"
android:scaleType="center"
android:src="@drawable/ic_eye_black"
@ -86,7 +95,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="@string/auth_home_server">
android:hint="@string/settings_home_server">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/homeServerField"
@ -94,30 +103,43 @@
android:layout_height="wrap_content"
android:inputType="textUri"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/authenticateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="@dimen/layout_vertical_margin"
android:layout_marginTop="22dp"
android:text="@string/auth_login" />
</LinearLayout>
</ScrollView>
<View
android:id="@+id/touchArea"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?vctr_waiting_background_color"
android:clickable="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerInParent="true"
android:layout_margin="8dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -16,5 +16,9 @@
<string name="edited_suffix">"(edited)"</string>
<!-- param will be replaced by the value of riotx_no_registration_notice_colored_part -->
<string name="riotx_no_registration_notice">%1$s to create an account.</string>
<string name="riotx_no_registration_notice_colored_part">Use the old app</string>
</resources>