Improved login error messages. Also, updated readme with F-Droid removed and no mention of alpha status.

This commit is contained in:
Vavassor 2017-03-19 23:15:36 -04:00
parent f2a400ab38
commit 7f4637c04c
3 changed files with 17 additions and 7 deletions

View File

@ -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. 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 ## Features

View File

@ -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 * Chain together the key-value pairs into a query string, for either appending to a URL or
* as the content of an HTTP request. * as the content of an HTTP request.
*/ */
private String toQueryString(Map<String, String> parameters) { private static String toQueryString(Map<String, String> parameters) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
String between = ""; String between = "";
for (Map.Entry<String, String> entry : parameters.entrySet()) { for (Map.Entry<String, String> 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. */ /** 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("http://", "");
s = s.replaceFirst("https://", ""); s = s.replaceFirst("https://", "");
return s.trim(); return s.trim();
@ -248,7 +248,8 @@ public class LoginActivity extends AppCompatActivity {
preferences = getSharedPreferences( preferences = getSharedPreferences(
getString(R.string.preferences_file_key), Context.MODE_PRIVATE); 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 // We are already logged in, go to MainActivity
Intent intent = new Intent(this, MainActivity.class); Intent intent = new Intent(this, MainActivity.class);
startActivity(intent); startActivity(intent);
@ -276,13 +277,19 @@ public class LoginActivity extends AppCompatActivity {
if (response.isSuccessful()) { if (response.isSuccessful()) {
onLoginSuccess(response.body().accessToken); onLoginSuccess(response.body().accessToken);
} else { } 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 @Override
public void onFailure(Call<AccessToken> call, Throwable t) { public void onFailure(Call<AccessToken> 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) { } else if (error != null) {
/* Authorization failed. Put the error response where the user can read it and they /* Authorization failed. Put the error response where the user can read it and they
* can try again. */ * 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 { } else {
// This case means a junk response was received somehow. // This case means a junk response was received somehow.
editText.setError(getString(R.string.error_authorization_unknown)); editText.setError(getString(R.string.error_authorization_unknown));

View File

@ -7,6 +7,8 @@
<string name="preferences_file_key">com.keylesspalace.tusky.PREFERENCES</string> <string name="preferences_file_key">com.keylesspalace.tusky.PREFERENCES</string>
<string name="error_authorization_unknown">An unidentified authorization error occurred.</string> <string name="error_authorization_unknown">An unidentified authorization error occurred.</string>
<string name="error_authorization_denied">Authorization was denied.</string>
<string name="error_retrieving_oauth_token">Failed getting a login token.</string>
<string name="error_fetching_notifications">Notifications could not be fetched.</string> <string name="error_fetching_notifications">Notifications could not be fetched.</string>
<string name="error_compose_character_limit">The status is too long!</string> <string name="error_compose_character_limit">The status is too long!</string>
<string name="error_sending_status">The status failed to be sent.</string> <string name="error_sending_status">The status failed to be sent.</string>