Browse Source

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

housekeeping/remove-warnings
Antoine POPINEAU 5 years ago
parent
commit
2d5e73dcd4
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 12
      app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt
  2. 12
      app/src/main/res/layout/activity_login.xml
  3. 2
      app/src/main/res/values/colors.xml
  4. 6
      app/src/main/res/values/styles.xml

12
app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt

@ -49,8 +49,6 @@ class LoginActivity : AppCompatActivity() { @@ -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() { @@ -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() { @@ -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
}
}
}
}

12
app/src/main/res/layout/activity_login.xml

@ -33,7 +33,6 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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>

2
app/src/main/res/values/colors.xml

@ -6,7 +6,7 @@ @@ -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>

6
app/src/main/res/values/styles.xml

@ -11,6 +11,8 @@ @@ -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 @@ @@ -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>

Loading…
Cancel
Save