From 77177b171c483d485bdbff0178564394e8f57d0f Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Tue, 7 Feb 2012 15:23:42 -0800 Subject: 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 --- unified_src/README | 9 +++++ .../mail/browse/UnifiedConversationProvider.java | 33 +++++++++++++++++++ .../providers/UnifiedAccountCacheProvider.java | 32 ++++++++++++++++++ .../providers/protos/boot/AccountReceiver.java | 38 ++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 unified_src/README create mode 100644 unified_src/com/android/mail/browse/UnifiedConversationProvider.java create mode 100644 unified_src/com/android/mail/providers/UnifiedAccountCacheProvider.java create mode 100644 unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java (limited to 'unified_src') 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/unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java b/unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java new file mode 100644 index 000000000..dafc03f5d --- /dev/null +++ b/unified_src/com/android/mail/providers/protos/boot/AccountReceiver.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2011, Google Inc. + * + * 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 com.android.mail.providers.protos.mock.MockUiProvider; +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) { + MockUiProvider.initializeMockProvider(); + intent.setClass(context, GmailAccountService.class); + context.startService(intent); + intent.setClass(context, EmailAccountService.class); + context.startService(intent); + } +} -- cgit v1.2.3