summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Westbrook <pwestbro@google.com>2012-02-07 15:23:42 -0800
committerPaul Westbrook <pwestbro@google.com>2012-02-08 10:28:08 -0800
commit77177b171c483d485bdbff0178564394e8f57d0f (patch)
tree516f9c43c4d0ad02d66cd92124aad62603c5eadf
parente7a2422ebff93a73340aceab4c006909bccca8a9 (diff)
downloadandroid_packages_apps_UnifiedEmail-77177b171c483d485bdbff0178564394e8f57d0f.tar.gz
android_packages_apps_UnifiedEmail-77177b171c483d485bdbff0178564394e8f57d0f.tar.bz2
android_packages_apps_UnifiedEmail-77177b171c483d485bdbff0178564394e8f57d0f.zip
Start of restructuring to allow overlays include subset of providers
This allows us to build a UnifiedEmail that supports all providers and use this base to build applications that only supports a subset of the providers Made AccountCacheProvider and ConversationProvider abstract. This allows the extending class to specify the authority that should be used (This allows both UnifiedEmail and Gmail to be installed at the same time) Change-Id: I31295f4630906e7182e423fcbb7b47c33ba4cd4f
-rw-r--r--Android.mk2
-rw-r--r--AndroidManifest.xml4
-rw-r--r--email_src/README (renamed from src/com/android/mail/providers/protos/boot/README)0
-rw-r--r--email_src/com/android/mail/providers/proto/boot/EmailAccountService.java (renamed from src/com/android/mail/providers/protos/boot/EmailAccountService.java)3
-rw-r--r--gmail_src/README9
-rw-r--r--gmail_src/com/android/mail/providers/proto/boot/GmailAccountService.java (renamed from src/com/android/mail/providers/protos/boot/GmailAccountService.java)3
-rw-r--r--gmail_src/com/android/mail/providers/proto/gmail/DummyGmailProvider.java (renamed from src/com/android/mail/providers/protos/gmail/DummyGmailProvider.java)0
-rw-r--r--src/com/android/mail/browse/ConversationCursor.java17
-rw-r--r--src/com/android/mail/providers/AccountCacheProvider.java16
-rw-r--r--src/com/android/mail/providers/protos/mock/MockUiProvider.java15
-rw-r--r--unified_src/README9
-rw-r--r--unified_src/com/android/mail/browse/UnifiedConversationProvider.java33
-rw-r--r--unified_src/com/android/mail/providers/UnifiedAccountCacheProvider.java32
-rw-r--r--unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java (renamed from src/com/android/mail/providers/protos/boot/AccountReceiver.java)2
14 files changed, 122 insertions, 23 deletions
diff --git a/Android.mk b/Android.mk
index 92084fc7f..71fc13ea2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -22,7 +22,7 @@ res_dirs := $(chips_dir) res
# Build APK
include $(CLEAR_VARS)
-src_dirs := src
+src_dirs := src unified_src email_src gmail_src
LOCAL_PACKAGE_NAME := UnifiedEmail
LOCAL_STATIC_JAVA_LIBRARIES := android-common-chips
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6206d4e0c..cd78cc20d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -64,7 +64,7 @@
android:authorities="com.android.mail.conversation.provider"
android:label="@string/conversation_content_provider"
android:multiprocess="false"
- android:name=".browse.ConversationCursor$ConversationProvider" >
+ android:name=".browse.UnifiedConversationProvider" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
@@ -72,7 +72,7 @@
android:authorities="com.android.mail.accountcache"
android:label="@string/account_cache_provider"
android:multiprocess="false"
- android:name=".providers.AccountCacheProvider" >
+ android:name=".providers.UnifiedAccountCacheProvider" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
diff --git a/src/com/android/mail/providers/protos/boot/README b/email_src/README
index 2c8088384..2c8088384 100644
--- a/src/com/android/mail/providers/protos/boot/README
+++ b/email_src/README
diff --git a/src/com/android/mail/providers/protos/boot/EmailAccountService.java b/email_src/com/android/mail/providers/proto/boot/EmailAccountService.java
index 682a07024..b2122b6bf 100644
--- a/src/com/android/mail/providers/protos/boot/EmailAccountService.java
+++ b/email_src/com/android/mail/providers/proto/boot/EmailAccountService.java
@@ -65,7 +65,8 @@ public class EmailAccountService extends IntentService {
int i = 0;
while (c.moveToNext()) {
final Map<String, Object> mockAccountMap =
- MockUiProvider.createAccountDetailsMap(i % MockUiProvider.NUM_MOCK_ACCOUNTS);
+ MockUiProvider.createAccountDetailsMap(i % MockUiProvider.NUM_MOCK_ACCOUNTS,
+ true);
// Send our account information to the cache provider
String accountName = c.getString(Account.CONTENT_EMAIL_ADDRESS_COLUMN);
final AccountCacheProvider.CachedAccount cachedAccount =
diff --git a/gmail_src/README b/gmail_src/README
new file mode 100644
index 000000000..ea96076c3
--- /dev/null
+++ b/gmail_src/README
@@ -0,0 +1,9 @@
+This is a temporary directory that is being used to enable email and Gmail content to be shown
+in the UnifiedEmail application
+
+This code should only be used for development. For shipping, this code (or something similar)
+should go in the Gmail/Email overlay of UnifiedEmail. But for now, this allows us to use a single
+application to test multiple content sources
+
+This code is just a shim to register existing accounts (Gmail and Email) from the device with the
+AccountCacheProvider. All subsequent uris will actually be handled by the appropriate application.
diff --git a/src/com/android/mail/providers/protos/boot/GmailAccountService.java b/gmail_src/com/android/mail/providers/proto/boot/GmailAccountService.java
index 62524c59f..f7d935d47 100644
--- a/src/com/android/mail/providers/protos/boot/GmailAccountService.java
+++ b/gmail_src/com/android/mail/providers/proto/boot/GmailAccountService.java
@@ -107,7 +107,8 @@ public class GmailAccountService extends IntentService {
// NOTE: This doesn't completely populate the provider. A query for the account uri
// will not return a cursor.
final Map<String, Object> mockAccountMap =
- MockUiProvider.createAccountDetailsMap(i % MockUiProvider.NUM_MOCK_ACCOUNTS);
+ MockUiProvider.createAccountDetailsMap(i % MockUiProvider.NUM_MOCK_ACCOUNTS,
+ false /* don't cache */);
// TODO: where should this really be stored?
long capabilities = Long.valueOf(
AccountCapabilities.SYNCABLE_FOLDERS |
diff --git a/src/com/android/mail/providers/protos/gmail/DummyGmailProvider.java b/gmail_src/com/android/mail/providers/proto/gmail/DummyGmailProvider.java
index ed9a0759f..ed9a0759f 100644
--- a/src/com/android/mail/providers/protos/gmail/DummyGmailProvider.java
+++ b/gmail_src/com/android/mail/providers/proto/gmail/DummyGmailProvider.java
diff --git a/src/com/android/mail/browse/ConversationCursor.java b/src/com/android/mail/browse/ConversationCursor.java
index 05c1e69cb..30f7dddf1 100644
--- a/src/com/android/mail/browse/ConversationCursor.java
+++ b/src/com/android/mail/browse/ConversationCursor.java
@@ -52,10 +52,6 @@ public final class ConversationCursor implements Cursor {
private static final String TAG = "ConversationCursor";
private static final boolean DEBUG = true; // STOPSHIP Set to false before shipping
- // The authority of our conversation provider (a forwarding provider)
- // This string must match the declaration in AndroidManifest.xml
- private static final String sAuthority = "com.android.mail.conversation.provider";
-
// The cursor instantiator's activity
private static Activity sActivity;
// The cursor underlying the caching cursor
@@ -243,7 +239,8 @@ public final class ConversationCursor implements Cursor {
*/
private static String uriToCachingUriString (Uri uri) {
String provider = uri.getAuthority();
- return uri.getScheme() + "://" + sAuthority + "/" + provider + uri.getPath();
+ return uri.getScheme() + "://" + ConversationProvider.AUTHORITY
+ + "/" + provider + uri.getPath();
}
/**
@@ -653,12 +650,18 @@ public final class ConversationCursor implements Cursor {
* and inserts directly, and caches updates/deletes before passing them through. The caching
* will cause a redraw of the list with updated values.
*/
- public static class ConversationProvider extends ContentProvider {
- public static final String AUTHORITY = sAuthority;
+ public abstract static class ConversationProvider extends ContentProvider {
+ public static String AUTHORITY;
+
+ /**
+ * Allows the implmenting provider to specify the authority that should be used.
+ */
+ protected abstract String getAuthority();
@Override
public boolean onCreate() {
sProvider = this;
+ AUTHORITY = getAuthority();
return true;
}
diff --git a/src/com/android/mail/providers/AccountCacheProvider.java b/src/com/android/mail/providers/AccountCacheProvider.java
index 8f1fcb810..e2120bf25 100644
--- a/src/com/android/mail/providers/AccountCacheProvider.java
+++ b/src/com/android/mail/providers/AccountCacheProvider.java
@@ -41,19 +41,25 @@ import java.util.Map;
* In the future, once other processes can add new accounts, this could allow other "mail"
* applications have their content appear within the application
*/
-public final class AccountCacheProvider extends ContentProvider {
-
- private static final String AUTHORITY = "com.android.mail.accountcache";
- private static final String BASE_URI_STRING = "content://" + AUTHORITY;
+public abstract class AccountCacheProvider extends ContentProvider {
private final static Map<String, CachedAccount> ACCOUNT_CACHE = Maps.newHashMap();
+ private static String sAuthority;
+
+ /**
+ * Allows the implmenting provider to specify the authority that should be used.
+ */
+ protected abstract String getAuthority();
+
+
public static Uri getAccountsUri() {
- return Uri.parse(BASE_URI_STRING + "/");
+ return Uri.parse("content://" + sAuthority + "/");
}
@Override
public boolean onCreate() {
+ sAuthority = getAuthority();
return true;
}
diff --git a/src/com/android/mail/providers/protos/mock/MockUiProvider.java b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
index 80b72729b..1d7302094 100644
--- a/src/com/android/mail/providers/protos/mock/MockUiProvider.java
+++ b/src/com/android/mail/providers/protos/mock/MockUiProvider.java
@@ -59,9 +59,10 @@ public final class MockUiProvider extends ContentProvider {
// A map of query result for uris
// TODO(pwestbro) read this map from an external
- private static final Map<String, List<Map<String, Object>>> MOCK_QUERY_RESULTS;
+ private static Map<String, List<Map<String, Object>>> MOCK_QUERY_RESULTS = Maps.newHashMap();
- static {
+
+ public static void initializeMockProvider() {
ImmutableMap.Builder<String, List<Map<String, Object>>> builder = ImmutableMap.builder();
// Add results for account list
@@ -69,14 +70,14 @@ public final class MockUiProvider extends ContentProvider {
Map<String, Object> accountDetailsMap0;
// Account 1
- accountDetailsMap0 = createAccountDetailsMap(0);
+ accountDetailsMap0 = createAccountDetailsMap(0, true);
accountList.add(accountDetailsMap0);
String accountUri1 = (String)accountDetailsMap0.get(AccountColumns.URI);
builder.put(accountUri1, ImmutableList.of(accountDetailsMap0));
// Account 2
- Map<String, Object> accountDetailsMap1 = createAccountDetailsMap(1);
+ Map<String, Object> accountDetailsMap1 = createAccountDetailsMap(1, true);
accountList.add(accountDetailsMap1);
String accountUri2 = (String) accountDetailsMap1.get(AccountColumns.URI);
@@ -241,7 +242,7 @@ public final class MockUiProvider extends ContentProvider {
}
// Temporarily made this public to allow the Gmail accounts to use the mock ui provider uris
- public static Map<String, Object> createAccountDetailsMap(int accountId) {
+ public static Map<String, Object> createAccountDetailsMap(int accountId, boolean cacheMap) {
final String accountUri = getMockAccountUri(accountId);
Map<String, Object> accountMap = Maps.newHashMap();
accountMap.put(BaseColumns._ID, Long.valueOf(accountId));
@@ -271,7 +272,9 @@ public final class MockUiProvider extends ContentProvider {
accountMap.put(AccountColumns.EXPUNGE_MESSAGE_URI, accountUri + "/expungeMessage");
accountMap.put(AccountColumns.UNDO_URI, accountUri + "/undo");
- addAccountInfoToAccountCache(accountMap);
+ if (cacheMap) {
+ addAccountInfoToAccountCache(accountMap);
+ }
return accountMap;
}
diff --git a/unified_src/README b/unified_src/README
new file mode 100644
index 000000000..ea96076c3
--- /dev/null
+++ b/unified_src/README
@@ -0,0 +1,9 @@
+This is a temporary directory that is being used to enable email and Gmail content to be shown
+in the UnifiedEmail application
+
+This code should only be used for development. For shipping, this code (or something similar)
+should go in the Gmail/Email overlay of UnifiedEmail. But for now, this allows us to use a single
+application to test multiple content sources
+
+This code is just a shim to register existing accounts (Gmail and Email) from the device with the
+AccountCacheProvider. All subsequent uris will actually be handled by the appropriate application.
diff --git a/unified_src/com/android/mail/browse/UnifiedConversationProvider.java b/unified_src/com/android/mail/browse/UnifiedConversationProvider.java
new file mode 100644
index 000000000..bde2a209b
--- /dev/null
+++ b/unified_src/com/android/mail/browse/UnifiedConversationProvider.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+
+package com.android.mail.browse;
+
+import com.android.mail.browse.ConversationCursor.ConversationProvider;
+
+import java.lang.Override;
+
+public class UnifiedConversationProvider extends ConversationProvider {
+ // The authority of our conversation provider (a forwarding provider)
+ // This string must match the declaration in AndroidManifest.xml
+ private static final String sAuthority = "com.android.mail.conversation.provider";
+
+ @Override
+ protected String getAuthority() {
+ return sAuthority;
+ }
+} \ No newline at end of file
diff --git a/unified_src/com/android/mail/providers/UnifiedAccountCacheProvider.java b/unified_src/com/android/mail/providers/UnifiedAccountCacheProvider.java
new file mode 100644
index 000000000..2308e9653
--- /dev/null
+++ b/unified_src/com/android/mail/providers/UnifiedAccountCacheProvider.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (C) 2012 Google Inc.
+ * Licensed to The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *******************************************************************************/
+
+package com.android.mail.providers;
+
+
+import java.lang.Override;
+
+public class UnifiedAccountCacheProvider extends AccountCacheProvider {
+ // The authority of our conversation provider (a forwarding provider)
+ // This string must match the declaration in AndroidManifest.xml
+ private static final String sAuthority = "com.android.mail.accountcache";
+
+ @Override
+ protected String getAuthority() {
+ return sAuthority;
+ }
+} \ No newline at end of file
diff --git a/src/com/android/mail/providers/protos/boot/AccountReceiver.java b/unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java
index 8e67ea5e1..dafc03f5d 100644
--- a/src/com/android/mail/providers/protos/boot/AccountReceiver.java
+++ b/unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java
@@ -15,6 +15,7 @@
*/
package com.android.mail.providers.protos.boot;
+import com.android.mail.providers.protos.mock.MockUiProvider;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -28,6 +29,7 @@ public class AccountReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
+ MockUiProvider.initializeMockProvider();
intent.setClass(context, GmailAccountService.class);
context.startService(intent);
intent.setClass(context, EmailAccountService.class);