mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
(Bug 45370) Improve Error messages on Login Screen
This commit is contained in:
parent
f2a3666e0e
commit
b84d00330e
5 changed files with 62 additions and 6 deletions
|
|
@ -46,7 +46,8 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/target/unpack" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: com.actionbarsherlock:actionbarsherlock:apklib:4.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.keyboardsurfer.android.widget:crouton:1.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.android:support-v4:r11" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mediawiki:api:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: in.yuvi:http.fluent:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.2.2" level="project" />
|
||||
|
|
@ -54,12 +55,13 @@
|
|||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.actionbarsherlock:actionbarsherlock:apklib:4.2.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: android:android:4.1_r2" level="project" />
|
||||
<orderEntry type="library" name="Maven: android.support:compatibility-v4:11" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.akquinet.android.androlog:androlog:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nostra13.universalimageloader:universal-image-loader:1.7.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.acra:acra:4.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.keyboardsurfer.android.widget:crouton:1.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.android:support-v4:r11" level="project" />
|
||||
<orderEntry type="jdk" jdkName="Android 4.0.3 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="module" module-name="~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0" />
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@
|
|||
<artifactId>acra</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.keyboardsurfer.android.widget</groupId>
|
||||
<artifactId>crouton</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,13 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_margin="16dip"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<FrameLayout
|
||||
android:id="@+id/loginErrors"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="48dp"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/loginUsername"
|
||||
|
|
@ -54,6 +60,7 @@
|
|||
android:id="@+id/loginButton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:text="@string/login" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@
|
|||
<string name="menu_open_in_browser">View in Browser</string>
|
||||
<string name="share_title_hint">Title</string>
|
||||
<string name="share_description_hint">Description</string>
|
||||
<string name="login_failed_network">Login failed due to network failure</string>
|
||||
<string name="login_failed_username">Unable to login - please check your username</string>
|
||||
<string name="login_failed_password">Unable to login - Check your password</string>
|
||||
<string name="login_failed_throttled">You have had too many unsuccessfull attempts. Please try again in 5 minutes
|
||||
</string>
|
||||
<string name="login_failed_blocked">Sorry, this user has been blocked on Commons</string>
|
||||
<string name="login_failed_generic">Login failed</string>
|
||||
|
||||
<plurals name="contributions_subtitle">
|
||||
<item quantity="zero">No uploads yet</item>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ package org.wikimedia.commons.auth;
|
|||
import java.io.IOException;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import de.keyboardsurfer.android.widget.crouton.Crouton;
|
||||
import de.keyboardsurfer.android.widget.crouton.Style;
|
||||
import org.wikimedia.commons.CommonsApplication;
|
||||
import org.wikimedia.commons.EventLog;
|
||||
import org.wikimedia.commons.R;
|
||||
|
|
@ -75,9 +79,25 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
ContentResolver.setSyncAutomatically(account, ContributionsContentProvider.AUTHORITY, true); // Enable sync by default!
|
||||
context.finish();
|
||||
} else {
|
||||
Toast failureToast = Toast.makeText(context, R.string.login_failed, Toast.LENGTH_LONG);
|
||||
int response;
|
||||
if(result.equals("NetworkFailure")) {
|
||||
response = R.string.login_failed_network;
|
||||
} else if(result.equals("NotExists") || result.equals("Illegal") || result.equals("NotExists")) {
|
||||
response = R.string.login_failed_username;
|
||||
passwordEdit.setText("");
|
||||
} else if(result.equals("EmptyPass") || result.equals("WrongPass")) {
|
||||
response = R.string.login_failed_password;
|
||||
passwordEdit.setText("");
|
||||
} else if(result.equals("Throttled")) {
|
||||
response = R.string.login_failed_throttled;
|
||||
} else if(result.equals("Blocked")) {
|
||||
response = R.string.login_failed_blocked;
|
||||
} else {
|
||||
// Should never really happen
|
||||
response = R.string.login_failed_generic;
|
||||
}
|
||||
Crouton.makeText(context, response, Style.ALERT, id.loginErrors).show();
|
||||
dialog.dismiss();
|
||||
failureToast.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -104,7 +124,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
return app.getApi().login(username, password);
|
||||
} catch (IOException e) {
|
||||
// Do something better!
|
||||
return "Failure";
|
||||
return "NetworkFailure";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +139,21 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
|||
usernameEdit = (EditText) findViewById(R.id.loginUsername);
|
||||
passwordEdit = (EditText) findViewById(R.id.loginPassword);
|
||||
final Activity that = this;
|
||||
|
||||
usernameEdit.addTextChangedListener(new TextWatcher() {
|
||||
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) { }
|
||||
|
||||
public void onTextChanged(CharSequence charSequence, int start, int count, int after) { }
|
||||
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if(usernameEdit.getText().length() != 0) {
|
||||
loginButton.setEnabled(true);
|
||||
} else {
|
||||
loginButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue