mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #1592 from misaochan/fix-failed-uploads
Attempt to fix failed uploads
This commit is contained in:
commit
b3b45679bc
4 changed files with 14 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ import android.accounts.AccountAuthenticatorResponse;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
@ -136,6 +137,11 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void startYourself(Context context) {
|
||||||
|
Intent intent = new Intent(context, LoginActivity.class);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
private void forgotPassword() {
|
private void forgotPassword() {
|
||||||
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
|
Utils.handleWebUrl(this, Uri.parse(BuildConfig.FORGOT_PASSWORD_URL));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,12 @@ public class SessionManager {
|
||||||
return sharedPreferences.getBoolean("isUserLoggedIn", false);
|
return sharedPreferences.getBoolean("isUserLoggedIn", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forceLogin(Context context) {
|
||||||
|
if (context != null) {
|
||||||
|
LoginActivity.startYourself(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Completable clearAllAccounts() {
|
public Completable clearAllAccounts() {
|
||||||
AccountManager accountManager = AccountManager.get(context);
|
AccountManager accountManager = AccountManager.get(context);
|
||||||
Account[] allAccounts = accountManager.getAccountsByType(ACCOUNT_TYPE);
|
Account[] allAccounts = accountManager.getAccountsByType(ACCOUNT_TYPE);
|
||||||
|
|
|
||||||
|
|
@ -239,10 +239,10 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
Timber.d("Successfully revalidated token!");
|
Timber.d("Successfully revalidated token!");
|
||||||
} else {
|
} else {
|
||||||
Timber.d("Unable to revalidate :(");
|
Timber.d("Unable to revalidate :(");
|
||||||
// TODO: Put up a new notification, ask them to re-login
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
Toast failureToast = Toast.makeText(this, R.string.authentication_failed, Toast.LENGTH_LONG);
|
Toast failureToast = Toast.makeText(this, R.string.authentication_failed, Toast.LENGTH_LONG);
|
||||||
failureToast.show();
|
failureToast.show();
|
||||||
|
sessionManager.forceLogin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<string name="login_success">Login success!</string>
|
<string name="login_success">Login success!</string>
|
||||||
<string name="login_failed">Login failed!</string>
|
<string name="login_failed">Login failed!</string>
|
||||||
<string name="upload_failed">File not found. Please try another file.</string>
|
<string name="upload_failed">File not found. Please try another file.</string>
|
||||||
<string name="authentication_failed">Authentication failed!</string>
|
<string name="authentication_failed">Authentication failed, please login again</string>
|
||||||
<string name="uploading_started">Upload started!</string>
|
<string name="uploading_started">Upload started!</string>
|
||||||
<string name="upload_completed_notification_title">%1$s uploaded!</string>
|
<string name="upload_completed_notification_title">%1$s uploaded!</string>
|
||||||
<string name="upload_completed_notification_text">Tap to view your upload</string>
|
<string name="upload_completed_notification_text">Tap to view your upload</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue