From 74c79a50432fcbf127fbfeadc1a461263ea92135 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 10 Sep 2012 17:18:32 -0700 Subject: [PATCH] Modify intent names Change-Id: Iad8b4842056a7f553363f9af47e65665c2b26a5d --- build/res/values/strings.xml | 1 + .../emailcommon/service/ServiceProxy.java | 21 ++++++++++++++----- res/xml/account_preferences.xml | 4 ++-- .../email/activity/setup/AccountSettings.java | 9 ++++++-- .../activity/setup/AccountSetupBasics.java | 4 +++- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/build/res/values/strings.xml b/build/res/values/strings.xml index 5451e6fa6..b46fb13db 100644 --- a/build/res/values/strings.xml +++ b/build/res/values/strings.xml @@ -20,6 +20,7 @@ com.android.pop3 com.android.imap com.android.email.EXCHANGE_INTENT + com.android.email.ACCOUNT_MANAGER_ENTRY_INTENT com.android.email.provider imap pop3 diff --git a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java index f93ce9d65..e4ac3001a 100644 --- a/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/ServiceProxy.java @@ -57,13 +57,24 @@ public abstract class ServiceProxy { private boolean mDead = false; public static Intent getIntentForEmailPackage(Context context, String actionName) { + return new Intent(getIntentStringForEmailPackage(context, actionName)); + } + + /** + * Create Intent action based on the Email package name + * Package com.android.email + ACTION -> com.android.email.ACTION + * Package com.google.android.email + ACTION -> com.google.android.email.ACTION + * Package com.android.exchange + ACTION -> com.android.email.ACTION + * Package com.google.exchange + ACTION -> com.google.android.email.ACTION + * + * @param context the caller's context + * @param actionName the Intent action + * @return an Intent action based on the package name + */ + public static String getIntentStringForEmailPackage(Context context, String actionName) { String packageName = context.getPackageName(); int lastDot = packageName.lastIndexOf('.'); - String intentString = - packageName.substring(0, lastDot + 1) + "email." + actionName; - // STOPSHIP Remove logging - Log.d("ServiceProxy", actionName + " -> " + intentString); - return new Intent(intentString); + return packageName.substring(0, lastDot + 1) + "email." + actionName; } public abstract void onConnected(IBinder binder); diff --git a/res/xml/account_preferences.xml b/res/xml/account_preferences.xml index f5b45a657..88b106d78 100644 --- a/res/xml/account_preferences.xml +++ b/res/xml/account_preferences.xml @@ -25,8 +25,8 @@ android:title="@string/account_settings_action" android:summary="@string/account_settings_summary"> + android:action="@string/intent_account_manager_entry" + /> diff --git a/src/com/android/email/activity/setup/AccountSettings.java b/src/com/android/email/activity/setup/AccountSettings.java index 102eff04c..5a2994764 100644 --- a/src/com/android/email/activity/setup/AccountSettings.java +++ b/src/com/android/email/activity/setup/AccountSettings.java @@ -49,6 +49,7 @@ import com.android.email.provider.EmailProvider; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent.AccountColumns; +import com.android.emailcommon.service.ServiceProxy; import com.android.emailcommon.utility.IntentUtilities; import com.android.emailcommon.utility.Utility; import com.android.mail.providers.Folder; @@ -88,8 +89,7 @@ public class AccountSettings extends PreferenceActivity { // Intent extras for launch directly from system account manager // NOTE: This string must match the one in res/xml/account_preferences.xml - private static final String ACTION_ACCOUNT_MANAGER_ENTRY = - "com.android.email.activity.setup.ACCOUNT_MANAGER_ENTRY"; + private static String ACTION_ACCOUNT_MANAGER_ENTRY; // NOTE: This constant should eventually be defined in android.accounts.Constants private static final String EXTRA_ACCOUNT_MANAGER_ACCOUNT = "account"; @@ -177,6 +177,11 @@ public class AccountSettings extends PreferenceActivity { // If we are not restarting from a previous instance, we need to // figure out the initial prefs to show. (Otherwise, we want to // continue showing whatever the user last selected.) + if (ACTION_ACCOUNT_MANAGER_ENTRY == null) { + ACTION_ACCOUNT_MANAGER_ENTRY = + ServiceProxy.getIntentStringForEmailPackage(this, + getString(R.string.intent_account_manager_entry)); + } if (ACTION_ACCOUNT_MANAGER_ENTRY.equals(i.getAction())) { // This case occurs if we're changing account settings from Settings -> Accounts mGetAccountIdFromAccountTask = diff --git a/src/com/android/email/activity/setup/AccountSetupBasics.java b/src/com/android/email/activity/setup/AccountSetupBasics.java index 9117167db..c53e7d0ef 100644 --- a/src/com/android/email/activity/setup/AccountSetupBasics.java +++ b/src/com/android/email/activity/setup/AccountSetupBasics.java @@ -51,6 +51,7 @@ import com.android.emailcommon.VendorPolicyLoader.Provider; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent; import com.android.emailcommon.provider.HostAuth; +import com.android.emailcommon.service.ServiceProxy; import com.android.emailcommon.utility.Utility; import java.net.URISyntaxException; @@ -202,7 +203,8 @@ public class AccountSetupBasics extends AccountSetupActivity } if (intentData != null) { SetupData.init(intentData); - } else if (ACTION_CREATE_ACCOUNT.equals(action)) { + } else if (ServiceProxy.getIntentStringForEmailPackage( + this, ACTION_CREATE_ACCOUNT).equals(action)) { SetupData.init(SetupData.FLOW_MODE_FORCE_CREATE); } else { int intentFlowMode =