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 17 package com.android.launcher2; 18 19 import android.appwidget.AppWidgetHostView; 20 import android.appwidget.AppWidgetProviderInfo; 21 import android.content.ComponentName; 22 import android.content.pm.ActivityInfo; 23 import android.os.Parcelable; 24 25 /** 26 * We pass this object with a drag from the customization tray 27 */ 28 class PendingAddItemInfo extends ItemInfo { 29 /** 30 * The component that will be created. 31 */ 32 ComponentName componentName; 33 } 34 35 class PendingAddShortcutInfo extends PendingAddItemInfo { 36 37 ActivityInfo shortcutActivityInfo; 38 PendingAddShortcutInfo(ActivityInfo activityInfo)39 public PendingAddShortcutInfo(ActivityInfo activityInfo) { 40 shortcutActivityInfo = activityInfo; 41 } 42 43 @Override toString()44 public String toString() { 45 return "Shortcut: " + shortcutActivityInfo.packageName; 46 } 47 } 48 49 class PendingAddWidgetInfo extends PendingAddItemInfo { 50 int minWidth; 51 int minHeight; 52 int minResizeWidth; 53 int minResizeHeight; 54 int previewImage; 55 int icon; 56 AppWidgetProviderInfo info; 57 AppWidgetHostView boundWidget; 58 59 // Any configuration data that we want to pass to a configuration activity when 60 // starting up a widget 61 String mimeType; 62 Parcelable configurationData; 63 PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data)64 public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) { 65 itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; 66 this.info = i; 67 componentName = i.provider; 68 minWidth = i.minWidth; 69 minHeight = i.minHeight; 70 minResizeWidth = i.minResizeWidth; 71 minResizeHeight = i.minResizeHeight; 72 previewImage = i.previewImage; 73 icon = i.icon; 74 if (dataMimeType != null && data != null) { 75 mimeType = dataMimeType; 76 configurationData = data; 77 } 78 } 79 80 // Copy constructor PendingAddWidgetInfo(PendingAddWidgetInfo copy)81 public PendingAddWidgetInfo(PendingAddWidgetInfo copy) { 82 minWidth = copy.minWidth; 83 minHeight = copy.minHeight; 84 minResizeWidth = copy.minResizeWidth; 85 minResizeHeight = copy.minResizeHeight; 86 previewImage = copy.previewImage; 87 icon = copy.icon; 88 info = copy.info; 89 boundWidget = copy.boundWidget; 90 mimeType = copy.mimeType; 91 configurationData = copy.configurationData; 92 componentName = copy.componentName; 93 itemType = copy.itemType; 94 spanX = copy.spanX; 95 spanY = copy.spanY; 96 minSpanX = copy.minSpanX; 97 minSpanY = copy.minSpanY; 98 } 99 100 @Override toString()101 public String toString() { 102 return "Widget: " + componentName.toShortString(); 103 } 104 } 105