First pass at a Email2 overlay of UnifiedEmail

Change-Id: I41de9a5307d56f358bc523bb139cdf90a0786dae
This commit is contained in:
Paul Westbrook 2012-02-09 13:55:15 -08:00
parent 1e16274776
commit 47cbfe7147
8 changed files with 357 additions and 0 deletions

47
email2/Android.mk Normal file
View File

@ -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))

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.mail"
android:versionCode="1"
android:versionName="1.0" >
<original-package android:name="com.android.mail" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Allows mail to access the user's contacts, for email address auto-completion -->
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<!-- Allows access to EmailProvider (EAS/IMAP/POP3) -->
<uses-permission android:name="com.android.email.permission.ACCESS_PROVIDER"/>
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="com.google.android.gm.permission.READ_CONTENT_PROVIDER"/>
<uses-permission android:name="com.google.android.gm.permission.READ_GMAIL"/>
<uses-permission android:name="com.google.android.gm.permission.WRITE_GMAIL"/>
<application
android:icon="@mipmap/ic_launcher_mail"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light" >
<activity
android:label="@string/app_name"
android:name=".UnifiedEmail" >
</activity>
<activity android:name=".compose.ComposeActivity" />
<activity android:name=".browse.ConversationListActivity" android:label="@string/app_name">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".browse.ConversationViewActivity" />
<activity android:name=".browse.FolderItem" />
<activity
android:name=".ui.ActionbarActivity"
android:uiOptions="splitActionBarWhenNarrow" />
<activity
android:name=".ui.MailActivity"
android:uiOptions="splitActionBarWhenNarrow" />
<provider
android:authorities="com.android.email2.conversation.provider"
android:label="@string/conversation_content_provider"
android:multiprocess="false"
android:name=".browse.EmailConversationProvider" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
<provider
android:authorities="com.android.email2.accountcache"
android:label="@string/account_cache_provider"
android:multiprocess="false"
android:name=".providers.EmailAccountCacheProvider" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
<provider
android:authorities="com.android.email2.dummymailprovider"
android:label="@string/dummy_gmail_provider"
android:multiprocess="false"
android:name=".providers.protos.boot.DummyMailProvider" >
<grant-uri-permission android:pathPattern=".*" />
</provider>
<receiver android:name=".providers.protos.boot.AccountReceiver">
<intent-filter>
<action android:name="com.android.mail.providers.protos.boot.intent.ACTION_PROVIDER_CREATED" />
</intent-filter>
</receiver>
<service android:name=".providers.protos.boot.EmailAccountService"/>
<service android:name=".compose.EmptyService"/>
</application>
</manifest>

25
email2/proguard.flags Normal file
View File

@ -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 <methods>;
}
-keepclasseswithmembers class com.google.common.collect.Sets {
*** of(...);
}
-keepclasseswithmembers class com.android.mail.UnifiedEmail {
public <methods>;
}

View File

@ -0,0 +1,20 @@
<!--
/**
* 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.
*/
-->
<resources>
<string name="app_name">Email2</string>
</resources>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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");
}
}