diff --git a/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt b/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt
index ca8f0a5..df14a2b 100644
--- a/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt
+++ b/app/src/main/java/com/github/apognu/otter/activities/LoginActivity.kt
@@ -49,8 +49,6 @@ class LoginActivity : AppCompatActivity() {
else e.message
hostname_field.error = message
-
- return@setOnClickListener
}
hostname_field.error = ""
@@ -65,27 +63,37 @@ class LoginActivity : AppCompatActivity() {
}
GlobalScope.launch(Main) {
- val result = Fuel.post("$hostname/api/v1/token", body)
- .awaitObjectResult(gsonDeserializerOf(FwCredentials::class.java))
-
- result.fold(
- { data ->
- PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).apply {
- setString("hostname", hostname)
- setString("username", username)
- setString("password", password)
- setString("access_token", data.token)
+ try {
+ val result = Fuel.post("$hostname/api/v1/token", body)
+ .awaitObjectResult(gsonDeserializerOf(FwCredentials::class.java))
+
+ result.fold(
+ { data ->
+ PowerPreference.getFileByName(AppContext.PREFS_CREDENTIALS).apply {
+ setString("hostname", hostname)
+ setString("username", username)
+ setString("password", password)
+ setString("access_token", data.token)
+ }
+
+ dialog.dismiss()
+ startActivity(Intent(this@LoginActivity, MainActivity::class.java))
+ },
+ { error ->
+ dialog.dismiss()
+
+ hostname_field.error = error.localizedMessage
}
+ )
+ } catch (e: Exception) {
+ dialog.dismiss()
- dialog.dismiss()
- startActivity(Intent(this@LoginActivity, MainActivity::class.java))
- },
- { error ->
- dialog.dismiss()
+ val message =
+ if (e.message?.isEmpty() == true) getString(R.string.login_error_hostname)
+ else e.message
- hostname_field.error = error.localizedMessage
- }
- )
+ hostname_field.error = message
+ }
}
}
}
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 681af59..e2a3632 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -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">
+ android:textColor="@android:color/white"
+ android:textCursorDrawable="@null" />
@@ -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">
+ android:textColor="@android:color/white"
+ android:textCursorDrawable="@null" />
@@ -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" />
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index aa9d2b8..2c29aa5 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -6,7 +6,7 @@
#327eae
#3d3e40
#d35400
- #b94705
+ #fdcfbb
#dadada
#e17055
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 45f5eee..f239413 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -11,6 +11,8 @@
- @style/AppTheme.ButtonStyle
- @style/AppTheme.Preference
+
+ - @color/colorError
-
-