Fix crash on illegal characters in URL. Fixed caret and error color on login form.

This commit is contained in:
Antoine POPINEAU 2019-10-23 22:05:56 +02:00
parent 0fa0b5d212
commit 2d5e73dcd4
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
4 changed files with 36 additions and 30 deletions

View File

@ -49,8 +49,6 @@ class LoginActivity : AppCompatActivity() {
else e.message
hostname_field.error = message
return@setOnClickListener
}
hostname_field.error = ""
@ -65,6 +63,7 @@ class LoginActivity : AppCompatActivity() {
}
GlobalScope.launch(Main) {
try {
val result = Fuel.post("$hostname/api/v1/token", body)
.awaitObjectResult(gsonDeserializerOf(FwCredentials::class.java))
@ -86,6 +85,15 @@ class LoginActivity : AppCompatActivity() {
hostname_field.error = error.localizedMessage
}
)
} catch (e: Exception) {
dialog.dismiss()
val message =
if (e.message?.isEmpty() == true) getString(R.string.login_error_hostname)
else e.message
hostname_field.error = message
}
}
}
}

View File

@ -33,7 +33,6 @@
android:hint="@string/login_hostname"
android:textColorHint="@drawable/login_input"
app:boxStrokeColor="@drawable/login_input"
app:errorTextAppearance="@style/AppTheme.ErrorStyle"
app:hintTextColor="@drawable/login_input">
<com.google.android.material.textfield.TextInputEditText
@ -42,7 +41,8 @@
android:layout_height="wrap_content"
android:inputType="textUri"
android:lines="1"
android:textColor="@android:color/white" />
android:textColor="@android:color/white"
android:textCursorDrawable="@null" />
</com.google.android.material.textfield.TextInputLayout>
@ -55,7 +55,6 @@
android:hint="@string/login_username"
android:textColorHint="@drawable/login_input"
app:boxStrokeColor="@drawable/login_input"
app:errorTextAppearance="@style/AppTheme.ErrorStyle"
app:hintTextColor="@drawable/login_input">
<com.google.android.material.textfield.TextInputEditText
@ -64,7 +63,8 @@
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:lines="1"
android:textColor="@android:color/white" />
android:textColor="@android:color/white"
android:textCursorDrawable="@null" />
</com.google.android.material.textfield.TextInputLayout>
@ -77,7 +77,6 @@
android:hint="@string/login_password"
android:textColorHint="@drawable/login_input"
app:boxStrokeColor="@drawable/login_input"
app:errorTextAppearance="@style/AppTheme.ErrorStyle"
app:hintTextColor="@drawable/login_input"
app:passwordToggleEnabled="true">
@ -87,7 +86,8 @@
android:layout_height="wrap_content"
android:inputType="textPassword"
android:lines="1"
android:textColor="@android:color/white" />
android:textColor="@android:color/white"
android:textCursorDrawable="@null" />
</com.google.android.material.textfield.TextInputLayout>

View File

@ -6,7 +6,7 @@
<color name="colorPrimary">#327eae</color>
<color name="colorPrimaryDark">#3d3e40</color>
<color name="colorAccent">#d35400</color>
<color name="colorError">#b94705</color>
<color name="colorError">#fdcfbb</color>
<color name="colorSelected">#dadada</color>
<color name="colorFavorite">#e17055</color>

View File

@ -11,6 +11,8 @@
<item name="materialButtonStyle">@style/AppTheme.ButtonStyle</item>
<item name="preferenceTheme">@style/AppTheme.Preference</item>
<item name="colorError">@color/colorError</item>
</style>
<style name="AppTheme.Fragment">
@ -76,8 +78,4 @@
<item name="android:background">@android:color/transparent</item>
</style>
<style name="AppTheme.ErrorStyle" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/colorError</item>
</style>
</resources>