1/*
2 * Copyright (C) 2013 Google Inc.
3 * Licensed to The Android Open Source Project.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.mail.browse;
19
20/**
21 * Holds an {@link InlineAttachmentViewIntentBuilderCreator} that is used to create
22 * {@link InlineAttachmentViewIntentBuilder}s for the conversation views. <p/>
23 *
24 * Unfortunately, this pattern requires three layers. The holder (the top layer) is created at
25 * application start and should have its creator set in the {@link android.app.Application}
26 * so that each app has a creator that provides app-specific functionality.
27 * Typically, that functionality is creating a different type of
28 * {@link InlineAttachmentViewIntentBuilder} to do app-specific work. <p/>
29 *
30 * The middle layer is the {@link InlineAttachmentViewIntentBuilderCreator}. Only one of
31 * these exist and is created at {@link android.app.Application} start time (usually
32 * in a static block). During conversation view setup, this is used to create
33 * an {@link InlineAttachmentViewIntentBuilder}. The creation needs to be done at this
34 * time so that each conversation view can have its own builder that is passed
35 * conversation-specific data at builder creation time. <p/>
36 *
37 * The bottom layer is the {@link InlineAttachmentViewIntentBuilder}. This builder
38 * is passed into a {@link com.android.mail.browse.WebViewContextMenu} and used
39 * when an image is long-pressed to determine whether "View image" should be a menu
40 * option and what intent should fire when "View image" is selected.
41 */
42public class InlineAttachmentViewIntentBuilderCreatorHolder {
43    private static InlineAttachmentViewIntentBuilderCreator sCreator;
44
45    public static void setInlineAttachmentViewIntentCreator(
46            InlineAttachmentViewIntentBuilderCreator creator) {
47        sCreator = creator;
48    }
49
50    public static InlineAttachmentViewIntentBuilderCreator getInlineAttachmentViewIntentCreator() {
51        return sCreator;
52    }
53}
54