From a92f94703ad23ca1b4cb789dd5eb877e5233ee17 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Fri, 26 Aug 2011 15:49:02 -0700 Subject: [PATCH] Sync prefs pages now show name or email of logged in user --- api/res/values/strings.xml | 3 +++ .../com/todoroo/astrid/sync/SyncProviderPreferences.java | 6 +++++- api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java | 3 +++ .../todoroo/astrid/actfm/sync/ActFmPreferenceService.java | 5 +++++ .../com/todoroo/astrid/gtasks/GtasksPreferenceService.java | 5 +++++ .../com/todoroo/astrid/opencrx/OpencrxCoreUtils.java | 5 ++++- .../com/todoroo/astrid/producteev/ProducteevUtilities.java | 5 +++++ astrid/res/xml/preferences_gtasks.xml | 3 ++- astrid/rmilk-src/org/weloveastrid/rmilk/MilkUtilities.java | 5 +++++ 9 files changed, 37 insertions(+), 3 deletions(-) diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml index eb73c53de..5bc8ee5ae 100644 --- a/api/res/values/strings.xml +++ b/api/res/values/strings.xml @@ -189,6 +189,9 @@ Log In & Synchronize! + + Logged in as: + Log Out diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java index adae98072..7dabcedce 100644 --- a/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java +++ b/api/src/com/todoroo/astrid/sync/SyncProviderPreferences.java @@ -185,8 +185,12 @@ abstract public class SyncProviderPreferences extends TodorooPreferenceActivity return true; } }); - if(!loggedIn) + if(!loggedIn) { preference.setTitle(R.string.sync_SPr_sync_log_in); + preference.setSummary(""); + } + else + preference.setSummary(r.getString(R.string.sync_SPr_logged_in_prefix) + " " + getUtilities().getLoggedInUserName()); } // log out button diff --git a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java index b6a020117..eaca9101d 100644 --- a/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java +++ b/api/src/com/todoroo/astrid/sync/SyncProviderUtilities.java @@ -51,6 +51,9 @@ abstract public class SyncProviderUtilities { return getPrefs().getString(getIdentifier() + PREF_TOKEN, null); } + /** Returns something like "Logged in as: user@gmail.com" */ + abstract public String getLoggedInUserName(); + /** Sets the authentication token. Set to null to clear. */ public void setToken(String setting) { Editor editor = getPrefs().edit(); diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java index 256d22561..a4927e170 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/ActFmPreferenceService.java @@ -111,4 +111,9 @@ public class ActFmPreferenceService extends SyncProviderUtilities { return user; } + @Override + public String getLoggedInUserName() { + return Preferences.getStringValue(PREF_NAME); + } + } \ No newline at end of file diff --git a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferenceService.java b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferenceService.java index 0696c9961..9524ef459 100644 --- a/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferenceService.java +++ b/astrid/plugin-src/com/todoroo/astrid/gtasks/GtasksPreferenceService.java @@ -48,4 +48,9 @@ public class GtasksPreferenceService extends SyncProviderUtilities { /** Pref that is set once migration to new GTasks API has occurred */ public static final String PREF_MIGRATION_HAS_OCCURRED = IDENTIFIER + "_migrated"; //$NON-NLS-1$ + @Override + public String getLoggedInUserName() { + return Preferences.getStringValue(PREF_USER_NAME); + } + } diff --git a/astrid/plugin-src/com/todoroo/astrid/opencrx/OpencrxCoreUtils.java b/astrid/plugin-src/com/todoroo/astrid/opencrx/OpencrxCoreUtils.java index 0d00b831f..8679aa44c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/opencrx/OpencrxCoreUtils.java +++ b/astrid/plugin-src/com/todoroo/astrid/opencrx/OpencrxCoreUtils.java @@ -120,5 +120,8 @@ public class OpencrxCoreUtils extends SyncProviderUtilities{ return 0; } - + @Override + public String getLoggedInUserName() { + return ""; + } } diff --git a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java index 4e83a77f7..d0bbfd1be 100644 --- a/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java +++ b/astrid/plugin-src/com/todoroo/astrid/producteev/ProducteevUtilities.java @@ -71,4 +71,9 @@ public class ProducteevUtilities extends SyncProviderUtilities { // prevent instantiation } + @Override + public String getLoggedInUserName() { + return Preferences.getStringValue(R.string.producteev_PPr_email); + } + } \ No newline at end of file diff --git a/astrid/res/xml/preferences_gtasks.xml b/astrid/res/xml/preferences_gtasks.xml index 76ab5ab30..00ca30776 100644 --- a/astrid/res/xml/preferences_gtasks.xml +++ b/astrid/res/xml/preferences_gtasks.xml @@ -34,7 +34,8 @@ + android:title="@string/sync_SPr_sync" + android:summary=""/>