From 7f4637c04c58d7fdc5f8e92c0dd71afef75239e0 Mon Sep 17 00:00:00 2001 From: Vavassor Date: Sun, 19 Mar 2017 23:15:36 -0400 Subject: [PATCH] Improved login error messages. Also, updated readme with F-Droid removed and no mention of alpha status. --- README.md | 2 +- .../keylesspalace/tusky/LoginActivity.java | 20 +++++++++++++------ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e987f953..f85716bc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tusky is a beautiful Android client for [Mastodon](https://github.com/tootsuite/mastodon). Mastodon is a GNU social-compatible federated social network. That means not one entity controls the whole network, rather, like e-mail, volunteers and organisations operate their own independent servers, users from which can all interact with each other seamlessly. -It is currently available for alpha testing on [Google Play](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky). You can also find it on F-Droid or at its [F-Droid page](https://f-droid.org/repository/browse/?fdid=com.keylesspalace.tusky). +It is currently available on [Google Play](https://play.google.com/store/apps/details?id=com.keylesspalace.tusky). ## Features diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java index 7076e908..796b0ee0 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.java @@ -61,7 +61,7 @@ public class LoginActivity extends AppCompatActivity { * Chain together the key-value pairs into a query string, for either appending to a URL or * as the content of an HTTP request. */ - private String toQueryString(Map parameters) { + private static String toQueryString(Map parameters) { StringBuilder s = new StringBuilder(); String between = ""; for (Map.Entry entry : parameters.entrySet()) { @@ -75,7 +75,7 @@ public class LoginActivity extends AppCompatActivity { } /** Make sure the user-entered text is just a fully-qualified domain name. */ - private String validateDomain(String s) { + private static String validateDomain(String s) { s = s.replaceFirst("http://", ""); s = s.replaceFirst("https://", ""); return s.trim(); @@ -248,7 +248,8 @@ public class LoginActivity extends AppCompatActivity { preferences = getSharedPreferences( getString(R.string.preferences_file_key), Context.MODE_PRIVATE); - if (preferences.getString("accessToken", null) != null && preferences.getString("domain", null) != null) { + if (preferences.getString("accessToken", null) != null + && preferences.getString("domain", null) != null) { // We are already logged in, go to MainActivity Intent intent = new Intent(this, MainActivity.class); startActivity(intent); @@ -276,13 +277,19 @@ public class LoginActivity extends AppCompatActivity { if (response.isSuccessful()) { onLoginSuccess(response.body().accessToken); } else { - editText.setError(response.message()); + editText.setError(getString(R.string.error_retrieving_oauth_token)); + Log.e(TAG, String.format("%s %s", + getString(R.string.error_retrieving_oauth_token), + response.message())); } } @Override public void onFailure(Call call, Throwable t) { - editText.setError(t.getMessage()); + editText.setError(getString(R.string.error_retrieving_oauth_token)); + Log.e(TAG, String.format("%s %s", + getString(R.string.error_retrieving_oauth_token), + t.getMessage())); } }; @@ -291,7 +298,8 @@ public class LoginActivity extends AppCompatActivity { } else if (error != null) { /* Authorization failed. Put the error response where the user can read it and they * can try again. */ - editText.setError(error); + editText.setError(getString(R.string.error_authorization_denied)); + Log.e(TAG, getString(R.string.error_authorization_denied) + error); } else { // This case means a junk response was received somehow. editText.setError(getString(R.string.error_authorization_unknown)); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a4ad549c..860429ab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,8 @@ com.keylesspalace.tusky.PREFERENCES An unidentified authorization error occurred. + Authorization was denied. + Failed getting a login token. Notifications could not be fetched. The status is too long! The status failed to be sent.