1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher2;
18
19import android.appwidget.AppWidgetHostView;
20import android.appwidget.AppWidgetProviderInfo;
21import android.content.ComponentName;
22import android.content.pm.ActivityInfo;
23import android.os.Bundle;
24import android.os.Parcelable;
25
26/**
27 * We pass this object with a drag from the customization tray
28 */
29class PendingAddItemInfo extends ItemInfo {
30    /**
31     * The component that will be created.
32     */
33    ComponentName componentName;
34}
35
36class PendingAddShortcutInfo extends PendingAddItemInfo {
37
38    ActivityInfo shortcutActivityInfo;
39
40    public PendingAddShortcutInfo(ActivityInfo activityInfo) {
41        shortcutActivityInfo = activityInfo;
42    }
43
44    @Override
45    public String toString() {
46        return "Shortcut: " + shortcutActivityInfo.packageName;
47    }
48}
49
50class PendingAddWidgetInfo extends PendingAddItemInfo {
51    int minWidth;
52    int minHeight;
53    int minResizeWidth;
54    int minResizeHeight;
55    int previewImage;
56    int icon;
57    AppWidgetProviderInfo info;
58    AppWidgetHostView boundWidget;
59    Bundle bindOptions = null;
60
61    // Any configuration data that we want to pass to a configuration activity when
62    // starting up a widget
63    String mimeType;
64    Parcelable configurationData;
65
66    public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) {
67        itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
68        this.info = i;
69        componentName = i.provider;
70        minWidth = i.minWidth;
71        minHeight = i.minHeight;
72        minResizeWidth = i.minResizeWidth;
73        minResizeHeight = i.minResizeHeight;
74        previewImage = i.previewImage;
75        icon = i.icon;
76        if (dataMimeType != null && data != null) {
77            mimeType = dataMimeType;
78            configurationData = data;
79        }
80    }
81
82    // Copy constructor
83    public PendingAddWidgetInfo(PendingAddWidgetInfo copy) {
84        minWidth = copy.minWidth;
85        minHeight = copy.minHeight;
86        minResizeWidth = copy.minResizeWidth;
87        minResizeHeight = copy.minResizeHeight;
88        previewImage = copy.previewImage;
89        icon = copy.icon;
90        info = copy.info;
91        boundWidget = copy.boundWidget;
92        mimeType = copy.mimeType;
93        configurationData = copy.configurationData;
94        componentName = copy.componentName;
95        itemType = copy.itemType;
96        spanX = copy.spanX;
97        spanY = copy.spanY;
98        minSpanX = copy.minSpanX;
99        minSpanY = copy.minSpanY;
100        bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone();
101    }
102
103    @Override
104    public String toString() {
105        return "Widget: " + componentName.toShortString();
106    }
107}
108