From 864ad84952ca9003887b8cf8dfab450edc2c848c Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Thu, 1 Aug 2013 14:32:26 -0700 Subject: [PATCH 1/2] Update to ignore Android Studio metadata --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6bc71e0..e9fa834 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ignore metadata from IDEA (Android Studio) +*.iml +.idea/ bin/ gen/ *~ From b8f5e34462b2a50d8ff935d6733dfdf5440716c1 Mon Sep 17 00:00:00 2001 From: Stephen Beitzel Date: Mon, 5 Aug 2013 11:26:39 -0700 Subject: [PATCH 2/2] Upon deleting the access key (logging out) immediately display the login screen. Tested on a DROID 3 at API 10. --- .gitignore | 1 + .../SifterReader/SifterReader.java | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index e9fa834..d1c0ec9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore metadata from IDEA (Android Studio) *.iml .idea/ +out/ bin/ gen/ *~ diff --git a/src/com/BreakingBytes/SifterReader/SifterReader.java b/src/com/BreakingBytes/SifterReader/SifterReader.java index e42c6a7..738e9e4 100644 --- a/src/com/BreakingBytes/SifterReader/SifterReader.java +++ b/src/com/BreakingBytes/SifterReader/SifterReader.java @@ -107,13 +107,13 @@ public void onCreate(Bundle savedInstanceState) { mAccessKey = mSifterHelper.mAccessKey; } else { mLoginError = mSifterHelper.mLoginError; - loginKeys(); + loginKeys(null); return; } String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS; URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL); if (sifterConnection == null) { - loginKeys(); + loginKeys(null); return; } mDialog = ProgressDialog.show(this, "", "Loading ...",true); @@ -139,7 +139,7 @@ protected void onPostExecute(JSONObject sifterJSONObject) { if (sifterJSONObject == null) return; if (getSifterError(sifterJSONObject)) { - loginKeys(); + loginKeys(null); return; } try { @@ -188,7 +188,7 @@ public boolean onCreateOptionsMenu(Menu menu) { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case LOGIN_ID: - loginKeys(); + loginKeys(null); return true; case DELETE_ID: deleteKeys(); @@ -198,8 +198,11 @@ public boolean onOptionsItemSelected(MenuItem item) { } /** start LoginActivity to get domain and access key. */ - private void loginKeys() { + private void loginKeys(Integer flags) { Intent intent = new Intent(this, LoginActivity.class); + if (flags != null) { + intent.addFlags(flags); + } intent.putExtra(DOMAIN, mDomain); intent.putExtra(ACCESS_KEY, mAccessKey); intent.putExtra(LOGIN_ERROR, mLoginError.toString()); @@ -209,7 +212,8 @@ private void loginKeys() { private void deleteKeys() { File keyFile = getFileStreamPath(KEY_FILE); if (keyFile.exists()) { - keyFile.delete(); + //noinspection ResultOfMethodCallIgnored + keyFile.delete(); mAllProjects = null; mDomain = null; mAccessKey = null; @@ -223,6 +227,8 @@ private void deleteKeys() { setListAdapter(null); onContentChanged(); } + // launch the login activity + loginKeys(Intent.FLAG_ACTIVITY_CLEAR_TOP); } /** start ProjectDetail activity for clicked project in list. */ @@ -315,7 +321,7 @@ protected void onPostExecute(JSONObject sifterJSONObject) { if (sifterJSONObject == null) return; if (getSifterError(sifterJSONObject)) { - loginKeys(); + loginKeys(null); return; } if (PROJ_DETAIL.equals(ISSUES)) { @@ -432,7 +438,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent) if (mDomain.length()==0 || mAccessKey.length()==0) { try { mLoginError = mSifterHelper.onMissingToken(); - loginKeys(); + loginKeys(null); } catch (Exception e) { e.printStackTrace(); mSifterHelper.onException(e.toString()); @@ -443,7 +449,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent) String projectsURL = HTTPS_PREFIX + mDomain + PROJECTS_URL + PROJECTS; URLConnection sifterConnection = mSifterHelper.getSifterConnection(projectsURL); if (sifterConnection == null) { - loginKeys(); + loginKeys(null); break; } // if URL misformatted return to LoginActivity mDialog = ProgressDialog.show(this, "", "Loading ...",true);