|
|
@ -205,10 +205,12 @@ public class LoginActivity extends BaseActivity { |
|
|
|
editor.putString("domain", domain); |
|
|
|
editor.putString("domain", domain); |
|
|
|
editor.putString("clientId", clientId); |
|
|
|
editor.putString("clientId", clientId); |
|
|
|
editor.putString("clientSecret", clientSecret); |
|
|
|
editor.putString("clientSecret", clientSecret); |
|
|
|
editor.commit(); |
|
|
|
editor.apply(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void onLoginSuccess(String accessToken) { |
|
|
|
private void onLoginSuccess(String accessToken) { |
|
|
|
|
|
|
|
preferences = getSharedPreferences( |
|
|
|
|
|
|
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE); |
|
|
|
SharedPreferences.Editor editor = preferences.edit(); |
|
|
|
SharedPreferences.Editor editor = preferences.edit(); |
|
|
|
editor.putString("accessToken", accessToken); |
|
|
|
editor.putString("accessToken", accessToken); |
|
|
|
editor.apply(); |
|
|
|
editor.apply(); |
|
|
@ -233,6 +235,8 @@ public class LoginActivity extends BaseActivity { |
|
|
|
/* During the redirect roundtrip this Activity usually dies, which wipes out the |
|
|
|
/* During the redirect roundtrip this Activity usually dies, which wipes out the |
|
|
|
* instance variables, so they have to be recovered from where they were saved in |
|
|
|
* instance variables, so they have to be recovered from where they were saved in |
|
|
|
* SharedPreferences. */ |
|
|
|
* SharedPreferences. */ |
|
|
|
|
|
|
|
preferences = getSharedPreferences( |
|
|
|
|
|
|
|
getString(R.string.preferences_file_key), Context.MODE_PRIVATE); |
|
|
|
domain = preferences.getString("domain", null); |
|
|
|
domain = preferences.getString("domain", null); |
|
|
|
clientId = preferences.getString("clientId", null); |
|
|
|
clientId = preferences.getString("clientId", null); |
|
|
|
clientSecret = preferences.getString("clientSecret", null); |
|
|
|
clientSecret = preferences.getString("clientSecret", null); |
|
|
@ -247,6 +251,7 @@ public class LoginActivity extends BaseActivity { |
|
|
|
parameters.put("grant_type", "authorization_code"); |
|
|
|
parameters.put("grant_type", "authorization_code"); |
|
|
|
} catch (JSONException e) { |
|
|
|
} catch (JSONException e) { |
|
|
|
errorText.setText("Heck."); |
|
|
|
errorText.setText("Heck."); |
|
|
|
|
|
|
|
return; |
|
|
|
//TODO: I don't even know how to handle this error state.
|
|
|
|
//TODO: I don't even know how to handle this error state.
|
|
|
|
} |
|
|
|
} |
|
|
|
String endpoint = getString(R.string.endpoint_token); |
|
|
|
String endpoint = getString(R.string.endpoint_token); |
|
|
@ -256,11 +261,12 @@ public class LoginActivity extends BaseActivity { |
|
|
|
new Response.Listener<JSONObject>() { |
|
|
|
new Response.Listener<JSONObject>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onResponse(JSONObject response) { |
|
|
|
public void onResponse(JSONObject response) { |
|
|
|
String accessToken = ""; |
|
|
|
String accessToken; |
|
|
|
try { |
|
|
|
try { |
|
|
|
accessToken = response.getString("access_token"); |
|
|
|
accessToken = response.getString("access_token"); |
|
|
|
} catch(JSONException e) { |
|
|
|
} catch(JSONException e) { |
|
|
|
errorText.setText("Heck."); |
|
|
|
errorText.setText("Heck."); |
|
|
|
|
|
|
|
return; |
|
|
|
//TODO: I don't even know how to handle this error state.
|
|
|
|
//TODO: I don't even know how to handle this error state.
|
|
|
|
} |
|
|
|
} |
|
|
|
onLoginSuccess(accessToken); |
|
|
|
onLoginSuccess(accessToken); |
|
|
|