Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 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 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame^] | 17 | package com.android.launcher3; |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 18 | |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 19 | import android.appwidget.AppWidgetHostView; |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 20 | import android.appwidget.AppWidgetProviderInfo; |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 21 | import android.content.ComponentName; |
Michael Jurka | dac8591 | 2012-05-18 15:04:49 -0700 | [diff] [blame] | 22 | import android.content.pm.ActivityInfo; |
Adam Cohen | dd70d66 | 2012-10-04 16:53:44 -0700 | [diff] [blame] | 23 | import android.os.Bundle; |
Winson Chung | 55cef26 | 2010-10-28 14:14:18 -0700 | [diff] [blame] | 24 | import android.os.Parcelable; |
Michael Jurka | 0280c3b | 2010-09-17 15:00:07 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * We pass this object with a drag from the customization tray |
| 28 | */ |
| 29 | class PendingAddItemInfo extends ItemInfo { |
| 30 | /** |
| 31 | * The component that will be created. |
| 32 | */ |
| 33 | ComponentName componentName; |
Michael Jurka | 3e7c763 | 2010-10-02 16:01:03 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Michael Jurka | dac8591 | 2012-05-18 15:04:49 -0700 | [diff] [blame] | 36 | class PendingAddShortcutInfo extends PendingAddItemInfo { |
| 37 | |
| 38 | ActivityInfo shortcutActivityInfo; |
| 39 | |
| 40 | public PendingAddShortcutInfo(ActivityInfo activityInfo) { |
| 41 | shortcutActivityInfo = activityInfo; |
| 42 | } |
Winson Chung | 7ce9985 | 2012-05-24 17:34:08 -0700 | [diff] [blame] | 43 | |
| 44 | @Override |
| 45 | public String toString() { |
| 46 | return "Shortcut: " + shortcutActivityInfo.packageName; |
| 47 | } |
Michael Jurka | dac8591 | 2012-05-18 15:04:49 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Michael Jurka | 3e7c763 | 2010-10-02 16:01:03 -0700 | [diff] [blame] | 50 | class PendingAddWidgetInfo extends PendingAddItemInfo { |
| 51 | int minWidth; |
| 52 | int minHeight; |
Adam Cohen | d41fbf5 | 2012-02-16 23:53:59 -0800 | [diff] [blame] | 53 | int minResizeWidth; |
| 54 | int minResizeHeight; |
Michael Jurka | 038f9d8 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 55 | int previewImage; |
| 56 | int icon; |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 57 | AppWidgetProviderInfo info; |
| 58 | AppWidgetHostView boundWidget; |
Adam Cohen | dd70d66 | 2012-10-04 16:53:44 -0700 | [diff] [blame] | 59 | Bundle bindOptions = null; |
Winson Chung | 55cef26 | 2010-10-28 14:14:18 -0700 | [diff] [blame] | 60 | |
| 61 | // Any configuration data that we want to pass to a configuration activity when |
| 62 | // starting up a widget |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 63 | String mimeType; |
Winson Chung | 55cef26 | 2010-10-28 14:14:18 -0700 | [diff] [blame] | 64 | Parcelable configurationData; |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 65 | |
Michael Jurka | c9d95c5 | 2011-08-29 14:03:34 -0700 | [diff] [blame] | 66 | public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) { |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 67 | itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 68 | this.info = i; |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 69 | componentName = i.provider; |
| 70 | minWidth = i.minWidth; |
| 71 | minHeight = i.minHeight; |
Adam Cohen | d41fbf5 | 2012-02-16 23:53:59 -0800 | [diff] [blame] | 72 | minResizeWidth = i.minResizeWidth; |
| 73 | minResizeHeight = i.minResizeHeight; |
Michael Jurka | 038f9d8 | 2011-11-03 13:50:45 -0700 | [diff] [blame] | 74 | previewImage = i.previewImage; |
| 75 | icon = i.icon; |
Winson Chung | 68846fd | 2010-10-29 11:00:27 -0700 | [diff] [blame] | 76 | if (dataMimeType != null && data != null) { |
| 77 | mimeType = dataMimeType; |
| 78 | configurationData = data; |
| 79 | } |
| 80 | } |
Adam Cohen | 1b36dc3 | 2012-02-13 19:27:37 -0800 | [diff] [blame] | 81 | |
| 82 | // Copy constructor |
| 83 | public PendingAddWidgetInfo(PendingAddWidgetInfo copy) { |
| 84 | minWidth = copy.minWidth; |
| 85 | minHeight = copy.minHeight; |
Adam Cohen | d41fbf5 | 2012-02-16 23:53:59 -0800 | [diff] [blame] | 86 | minResizeWidth = copy.minResizeWidth; |
| 87 | minResizeHeight = copy.minResizeHeight; |
Adam Cohen | 1b36dc3 | 2012-02-13 19:27:37 -0800 | [diff] [blame] | 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; |
Adam Cohen | 1f36270 | 2012-04-04 14:58:12 -0700 | [diff] [blame] | 96 | spanX = copy.spanX; |
| 97 | spanY = copy.spanY; |
| 98 | minSpanX = copy.minSpanX; |
| 99 | minSpanY = copy.minSpanY; |
Adam Cohen | dd70d66 | 2012-10-04 16:53:44 -0700 | [diff] [blame] | 100 | bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone(); |
Adam Cohen | 1b36dc3 | 2012-02-13 19:27:37 -0800 | [diff] [blame] | 101 | } |
Winson Chung | 7ce9985 | 2012-05-24 17:34:08 -0700 | [diff] [blame] | 102 | |
| 103 | @Override |
| 104 | public String toString() { |
| 105 | return "Widget: " + componentName.toShortString(); |
| 106 | } |
Adam Cohen | 1b36dc3 | 2012-02-13 19:27:37 -0800 | [diff] [blame] | 107 | } |