From 47cbfe71473179e23bcaba37c56353436f892c5a Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Thu, 9 Feb 2012 13:55:15 -0800 Subject: [PATCH] First pass at a Email2 overlay of UnifiedEmail Change-Id: I41de9a5307d56f358bc523bb139cdf90a0786dae --- email2/Android.mk | 47 ++++++++++ email2/AndroidManifest.xml | 93 +++++++++++++++++++ email2/proguard.flags | 25 +++++ email2/res/values/strings.xml | 20 ++++ .../browse/EmailConversationProvider.java | 32 +++++++ .../providers/EmailAccountCacheProvider.java | 30 ++++++ .../protos/boot/AccountReceiver.java | 35 +++++++ .../protos/boot/DummyMailProvider.java | 75 +++++++++++++++ 8 files changed, 357 insertions(+) create mode 100644 email2/Android.mk create mode 100644 email2/AndroidManifest.xml create mode 100644 email2/proguard.flags create mode 100644 email2/res/values/strings.xml create mode 100644 email2/src/com/android/mail/browse/EmailConversationProvider.java create mode 100644 email2/src/com/android/mail/providers/EmailAccountCacheProvider.java create mode 100644 email2/src/com/android/mail/providers/protos/boot/AccountReceiver.java create mode 100644 email2/src/com/android/mail/providers/protos/boot/DummyMailProvider.java diff --git a/email2/Android.mk b/email2/Android.mk new file mode 100644 index 000000000..b26a3e73b --- /dev/null +++ b/email2/Android.mk @@ -0,0 +1,47 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + + +# Include res dir from chips +chips_dir := ../../../../frameworks/ex/chips/res + +# Include res dir from UnifiedEmail +unified_email_dir := ../../UnifiedEmail/res +res_dirs := res $(chips_dir) $(unified_email_dir) + +LOCAL_MODULE_TAGS := optional + +src_dirs := src \ + ../../UnifiedEmail/src \ + ../../UnifiedEmail/email_src + + +LOCAL_STATIC_JAVA_LIBRARIES := android-common-chips +LOCAL_STATIC_JAVA_LIBRARIES += guava +LOCAL_STATIC_JAVA_LIBRARIES += android-common +LOCAL_STATIC_JAVA_LIBRARIES += com.android.emailcommon + +LOCAL_SDK_VERSION := 14 + + +LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs)) \ + $(call all-logtags-files-under, $(src_dirs)) + +LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dirs)) + +LOCAL_AAPT_FLAGS := \ + --auto-add-overlay \ + --rename-manifest-package com.android.email2 \ + --extra-packages com.android.ex.chips + +LOCAL_PACKAGE_NAME := Email2 + +LOCAL_OVERRIDES_PACKAGES := UnifiedEmail + +LOCAL_PROGUARD_FLAG_FILES := proguard.flags + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) + diff --git a/email2/AndroidManifest.xml b/email2/AndroidManifest.xml new file mode 100644 index 000000000..116e01b7f --- /dev/null +++ b/email2/AndroidManifest.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/email2/proguard.flags b/email2/proguard.flags new file mode 100644 index 000000000..87838223b --- /dev/null +++ b/email2/proguard.flags @@ -0,0 +1,25 @@ +# The support library contains references to newer platform versions. +# Don't warn about those in case this app is linking against an older +# platform version. We know about them, and they are safe. + +-dontwarn android.support.v4.** +-dontwarn android.support.v13.** + +# keep names that are used by reflection, from javascript or from unit tests + +-keepclasseswithmembers class com.android.mail.providers.UIProvider { + *** getAccountsUri(...); +} + +-keepclasseswithmembers class com.android.mail.utils.LogUtils { + public ; +} + + +-keepclasseswithmembers class com.google.common.collect.Sets { + *** of(...); +} + +-keepclasseswithmembers class com.android.mail.UnifiedEmail { + public ; +} diff --git a/email2/res/values/strings.xml b/email2/res/values/strings.xml new file mode 100644 index 000000000..d29b59f64 --- /dev/null +++ b/email2/res/values/strings.xml @@ -0,0 +1,20 @@ + + + Email2 + \ No newline at end of file diff --git a/email2/src/com/android/mail/browse/EmailConversationProvider.java b/email2/src/com/android/mail/browse/EmailConversationProvider.java new file mode 100644 index 000000000..ebff3137c --- /dev/null +++ b/email2/src/com/android/mail/browse/EmailConversationProvider.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 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 EmailConversationProvider 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.email2.conversation.provider"; + + @Override + protected String getAuthority() { + return sAuthority; + } +} \ No newline at end of file diff --git a/email2/src/com/android/mail/providers/EmailAccountCacheProvider.java b/email2/src/com/android/mail/providers/EmailAccountCacheProvider.java new file mode 100644 index 000000000..ed64a3d1d --- /dev/null +++ b/email2/src/com/android/mail/providers/EmailAccountCacheProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 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 EmailAccountCacheProvider 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.email2.accountcache"; + + @Override + protected String getAuthority() { + return sAuthority; + } +} \ No newline at end of file diff --git a/email2/src/com/android/mail/providers/protos/boot/AccountReceiver.java b/email2/src/com/android/mail/providers/protos/boot/AccountReceiver.java new file mode 100644 index 000000000..7f12c6609 --- /dev/null +++ b/email2/src/com/android/mail/providers/protos/boot/AccountReceiver.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 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.protos.boot; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +public class AccountReceiver extends BroadcastReceiver { + /** + * Intent used to notify interested parties that the Mail provider has been created. + */ + public static final String ACTION_PROVIDER_CREATED + = "com.android.mail.providers.protos.boot.intent.ACTION_PROVIDER_CREATED"; + + @Override + public void onReceive(Context context, Intent intent) { + intent.setClass(context, EmailAccountService.class); + context.startService(intent); + } +} diff --git a/email2/src/com/android/mail/providers/protos/boot/DummyMailProvider.java b/email2/src/com/android/mail/providers/protos/boot/DummyMailProvider.java new file mode 100644 index 000000000..5e6766287 --- /dev/null +++ b/email2/src/com/android/mail/providers/protos/boot/DummyMailProvider.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2012 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.protos.boot; + +import android.content.ContentProvider; +import android.content.ContentValues; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; + +import com.android.mail.providers.protos.boot.AccountReceiver; + +/** + * The sole purpose of this provider is to leverage on the fact that the system will create any + * listed content providers when the app starts up. We use this fact to initiate the load of the + * Gmail accounts, to cache them in the AccountCacheProvider. + * + * Ideally, this wouldn't be necessary, and instead the code that registers the Gmail accounts could + * use static initialization to kick off the process to cache the accounts. Unfortunately + * at that time, there is not a valid context + */ +public final class DummyMailProvider extends ContentProvider { + + @Override + public boolean onCreate() { + + final Intent intent = new Intent(AccountReceiver.ACTION_PROVIDER_CREATED); + getContext().sendBroadcast(intent); + + // TODO(pwestbro): consider putting the retrieval of the account list here. This would + // allow us to handle queries for the account uris + return true; + } + + @Override + public Cursor query(Uri url, String[] projection, String selection, String[] selectionArgs, + String sortOrder) { + throw new IllegalArgumentException("Don't Use this provider"); + } + + @Override + public Uri insert(Uri url, ContentValues values) { + throw new IllegalArgumentException("Don't Use this provider"); + } + + @Override + public int update(Uri url, ContentValues values, String selection, + String[] selectionArgs) { + throw new IllegalArgumentException("Don't Use this provider"); + } + + @Override + public int delete(Uri url, String selection, String[] selectionArgs) { + throw new IllegalArgumentException("Don't Use this provider"); + } + + @Override + public String getType(Uri uri) { + throw new IllegalArgumentException("Don't Use this provider"); + } +}