Fixes an issue when no authorisation code has been retrieved
This commit is contained in:
parent
aa822f28c3
commit
d7387d903f
|
@ -17,6 +17,7 @@ package fr.gouv.etalab.mastodon.activities;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
@ -30,6 +31,7 @@ import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.loopj.android.http.AsyncHttpResponseHandler;
|
import com.loopj.android.http.AsyncHttpResponseHandler;
|
||||||
import com.loopj.android.http.RequestParams;
|
import com.loopj.android.http.RequestParams;
|
||||||
|
@ -54,9 +56,9 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
||||||
private AlertDialog alert;
|
private AlertDialog alert;
|
||||||
private String clientId, clientSecret;
|
private String clientId, clientSecret;
|
||||||
private String instance;
|
private String instance;
|
||||||
|
private int retry;
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||||
|
@ -71,7 +73,7 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
||||||
instance = b.getString("instance");
|
instance = b.getString("instance");
|
||||||
if( instance == null)
|
if( instance == null)
|
||||||
finish();
|
finish();
|
||||||
|
retry = 0;
|
||||||
clientId = sharedpreferences.getString(Helper.CLIENT_ID, null);
|
clientId = sharedpreferences.getString(Helper.CLIENT_ID, null);
|
||||||
clientSecret = sharedpreferences.getString(Helper.CLIENT_SECRET, null);
|
clientSecret = sharedpreferences.getString(Helper.CLIENT_SECRET, null);
|
||||||
|
|
||||||
|
@ -99,6 +101,13 @@ public class WebviewConnectActivity extends AppCompatActivity {
|
||||||
super.shouldOverrideUrlLoading(view,url);
|
super.shouldOverrideUrlLoading(view,url);
|
||||||
if( url.contains(Helper.REDIRECT_CONTENT_WEB)){
|
if( url.contains(Helper.REDIRECT_CONTENT_WEB)){
|
||||||
String val[] = url.split("code=");
|
String val[] = url.split("code=");
|
||||||
|
if (val.length< 2){
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.toast_code_error, Toast.LENGTH_LONG).show();
|
||||||
|
Intent myIntent = new Intent(WebviewConnectActivity.this, LoginActivity.class);
|
||||||
|
startActivity(myIntent);
|
||||||
|
finish();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String code = val[1];
|
String code = val[1];
|
||||||
|
|
||||||
String action = "/oauth/token";
|
String action = "/oauth/token";
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class Helper {
|
||||||
public static final String SCOPE = "scope";
|
public static final String SCOPE = "scope";
|
||||||
public static final String SCOPES = "scopes";
|
public static final String SCOPES = "scopes";
|
||||||
public static final String WEBSITE = "website";
|
public static final String WEBSITE = "website";
|
||||||
public static final String WEBSITE_VALUE = "https://play.google.com/store/apps/details?id=fr.gouv.etalab.mastodon";
|
public static final String WEBSITE_VALUE = "https://tom79.bitbucket.io/";
|
||||||
public static final String SHOW_BATTERY_SAVER_MESSAGE = "show_battery_saver_message";
|
public static final String SHOW_BATTERY_SAVER_MESSAGE = "show_battery_saver_message";
|
||||||
public static final String LAST_NOTIFICATION_MAX_ID = "last_notification_max_id";
|
public static final String LAST_NOTIFICATION_MAX_ID = "last_notification_max_id";
|
||||||
public static final String LAST_HOMETIMELINE_MAX_ID = "last_hometimeline_max_id";
|
public static final String LAST_HOMETIMELINE_MAX_ID = "last_hometimeline_max_id";
|
||||||
|
|
|
@ -227,6 +227,7 @@
|
||||||
<string name="toast_report">Le pouet a été signalé !</string>
|
<string name="toast_report">Le pouet a été signalé !</string>
|
||||||
<string name="toast_unstatus">Le pouet a été supprimé !</string>
|
<string name="toast_unstatus">Le pouet a été supprimé !</string>
|
||||||
<string name="toast_error">Oups ! Une erreur s\'est produite !</string>
|
<string name="toast_error">Oups ! Une erreur s\'est produite !</string>
|
||||||
|
<string name="toast_code_error">Une erreur s\'est produite ! L\'instance n\'a retourné aucun code d\authorisation !</string>
|
||||||
<string name="toast_error_loading_account">Une erreur s\'est produite en chargeant le compte !</string>
|
<string name="toast_error_loading_account">Une erreur s\'est produite en chargeant le compte !</string>
|
||||||
<string name="toast_error_search">Une erreur s\'est produite lors de la recherche !</string>
|
<string name="toast_error_search">Une erreur s\'est produite lors de la recherche !</string>
|
||||||
<string name="toast_error_login">Impossible de vous connecter !</string>
|
<string name="toast_error_login">Impossible de vous connecter !</string>
|
||||||
|
|
|
@ -232,6 +232,7 @@
|
||||||
<string name="toast_report">The toot was reported!</string>
|
<string name="toast_report">The toot was reported!</string>
|
||||||
<string name="toast_unstatus">The toot was deleted!</string>
|
<string name="toast_unstatus">The toot was deleted!</string>
|
||||||
<string name="toast_error">Oops ! An error occurred!</string>
|
<string name="toast_error">Oops ! An error occurred!</string>
|
||||||
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
<string name="toast_error_loading_account">An error occurred while switching between accounts!</string>
|
<string name="toast_error_loading_account">An error occurred while switching between accounts!</string>
|
||||||
<string name="toast_error_search">An error occurred while searching!</string>
|
<string name="toast_error_search">An error occurred while searching!</string>
|
||||||
<string name="toast_error_login">Can not log in!</string>
|
<string name="toast_error_login">Can not log in!</string>
|
||||||
|
|
Loading…
Reference in New Issue