blob: 967cc928e17ea6f2dc237fc3066849fb1eea0586 [file] [log] [blame]
Michael Jurka0280c3b2010-09-17 15:00:07 -07001/*
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 Sandler325dc232013-06-05 22:57:57 -040017package com.android.launcher3;
Michael Jurka0280c3b2010-09-17 15:00:07 -070018
Adam Cohened66b2b2012-01-23 17:28:51 -080019import android.appwidget.AppWidgetHostView;
Winson Chung68846fd2010-10-29 11:00:27 -070020import android.appwidget.AppWidgetProviderInfo;
Michael Jurka0280c3b2010-09-17 15:00:07 -070021import android.content.ComponentName;
Michael Jurkadac85912012-05-18 15:04:49 -070022import android.content.pm.ActivityInfo;
Adam Cohendd70d662012-10-04 16:53:44 -070023import android.os.Bundle;
Winson Chung55cef262010-10-28 14:14:18 -070024import android.os.Parcelable;
Michael Jurka0280c3b2010-09-17 15:00:07 -070025
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;
Michael Jurka3e7c7632010-10-02 16:01:03 -070034}
35
Michael Jurkadac85912012-05-18 15:04:49 -070036class PendingAddShortcutInfo extends PendingAddItemInfo {
37
38 ActivityInfo shortcutActivityInfo;
39
40 public PendingAddShortcutInfo(ActivityInfo activityInfo) {
41 shortcutActivityInfo = activityInfo;
42 }
Winson Chung7ce99852012-05-24 17:34:08 -070043
44 @Override
45 public String toString() {
46 return "Shortcut: " + shortcutActivityInfo.packageName;
47 }
Michael Jurkadac85912012-05-18 15:04:49 -070048}
49
Michael Jurka3e7c7632010-10-02 16:01:03 -070050class PendingAddWidgetInfo extends PendingAddItemInfo {
51 int minWidth;
52 int minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080053 int minResizeWidth;
54 int minResizeHeight;
Michael Jurka038f9d82011-11-03 13:50:45 -070055 int previewImage;
56 int icon;
Adam Cohened66b2b2012-01-23 17:28:51 -080057 AppWidgetProviderInfo info;
58 AppWidgetHostView boundWidget;
Adam Cohendd70d662012-10-04 16:53:44 -070059 Bundle bindOptions = null;
Winson Chung55cef262010-10-28 14:14:18 -070060
61 // Any configuration data that we want to pass to a configuration activity when
62 // starting up a widget
Winson Chung68846fd2010-10-29 11:00:27 -070063 String mimeType;
Winson Chung55cef262010-10-28 14:14:18 -070064 Parcelable configurationData;
Winson Chung68846fd2010-10-29 11:00:27 -070065
Michael Jurkac9d95c52011-08-29 14:03:34 -070066 public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) {
Winson Chung68846fd2010-10-29 11:00:27 -070067 itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
Adam Cohened66b2b2012-01-23 17:28:51 -080068 this.info = i;
Winson Chung68846fd2010-10-29 11:00:27 -070069 componentName = i.provider;
70 minWidth = i.minWidth;
71 minHeight = i.minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080072 minResizeWidth = i.minResizeWidth;
73 minResizeHeight = i.minResizeHeight;
Michael Jurka038f9d82011-11-03 13:50:45 -070074 previewImage = i.previewImage;
75 icon = i.icon;
Winson Chung68846fd2010-10-29 11:00:27 -070076 if (dataMimeType != null && data != null) {
77 mimeType = dataMimeType;
78 configurationData = data;
79 }
80 }
Adam Cohen1b36dc32012-02-13 19:27:37 -080081
82 // Copy constructor
83 public PendingAddWidgetInfo(PendingAddWidgetInfo copy) {
84 minWidth = copy.minWidth;
85 minHeight = copy.minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080086 minResizeWidth = copy.minResizeWidth;
87 minResizeHeight = copy.minResizeHeight;
Adam Cohen1b36dc32012-02-13 19:27:37 -080088 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 Cohen1f362702012-04-04 14:58:12 -070096 spanX = copy.spanX;
97 spanY = copy.spanY;
98 minSpanX = copy.minSpanX;
99 minSpanY = copy.minSpanY;
Adam Cohendd70d662012-10-04 16:53:44 -0700100 bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone();
Adam Cohen1b36dc32012-02-13 19:27:37 -0800101 }
Winson Chung7ce99852012-05-24 17:34:08 -0700102
103 @Override
104 public String toString() {
105 return "Widget: " + componentName.toShortString();
106 }
Adam Cohen1b36dc32012-02-13 19:27:37 -0800107}