blob: ac54a262fd5239001d5f840a3499098c790a868f [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;
Michael Jurka0280c3b2010-09-17 15:00:07 -070020import android.content.ComponentName;
Michael Jurkadac85912012-05-18 15:04:49 -070021import android.content.pm.ActivityInfo;
Adam Cohendd70d662012-10-04 16:53:44 -070022import android.os.Bundle;
Winson Chung55cef262010-10-28 14:14:18 -070023import android.os.Parcelable;
Michael Jurka0280c3b2010-09-17 15:00:07 -070024
25/**
26 * We pass this object with a drag from the customization tray
27 */
28class PendingAddItemInfo extends ItemInfo {
29 /**
30 * The component that will be created.
31 */
32 ComponentName componentName;
Michael Jurka3e7c7632010-10-02 16:01:03 -070033}
34
Michael Jurkadac85912012-05-18 15:04:49 -070035class PendingAddShortcutInfo extends PendingAddItemInfo {
36
37 ActivityInfo shortcutActivityInfo;
38
39 public PendingAddShortcutInfo(ActivityInfo activityInfo) {
40 shortcutActivityInfo = activityInfo;
41 }
Winson Chung7ce99852012-05-24 17:34:08 -070042
43 @Override
44 public String toString() {
45 return "Shortcut: " + shortcutActivityInfo.packageName;
46 }
Michael Jurkadac85912012-05-18 15:04:49 -070047}
48
Michael Jurka3e7c7632010-10-02 16:01:03 -070049class PendingAddWidgetInfo extends PendingAddItemInfo {
50 int minWidth;
51 int minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080052 int minResizeWidth;
53 int minResizeHeight;
Michael Jurka038f9d82011-11-03 13:50:45 -070054 int previewImage;
55 int icon;
Adam Cohen59400422014-03-05 18:07:04 -080056 LauncherAppWidgetProviderInfo info;
Adam Cohened66b2b2012-01-23 17:28:51 -080057 AppWidgetHostView boundWidget;
Adam Cohendd70d662012-10-04 16:53:44 -070058 Bundle bindOptions = null;
Winson Chung55cef262010-10-28 14:14:18 -070059
Adam Cohen59400422014-03-05 18:07:04 -080060 public PendingAddWidgetInfo(LauncherAppWidgetProviderInfo i, Parcelable data) {
61 if (i.isCustomWidget) {
62 itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
63 } else {
64 itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
65 }
Adam Cohened66b2b2012-01-23 17:28:51 -080066 this.info = i;
Winson Chung68846fd2010-10-29 11:00:27 -070067 componentName = i.provider;
68 minWidth = i.minWidth;
69 minHeight = i.minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080070 minResizeWidth = i.minResizeWidth;
71 minResizeHeight = i.minResizeHeight;
Michael Jurka038f9d82011-11-03 13:50:45 -070072 previewImage = i.previewImage;
73 icon = i.icon;
Adam Cohen59400422014-03-05 18:07:04 -080074
75 spanX = i.spanX;
76 spanY = i.spanY;
77 minSpanX = i.minSpanX;
78 minSpanY = i.minSpanY;
79 }
80
81 public boolean isCustomWidget() {
82 return itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
Winson Chung68846fd2010-10-29 11:00:27 -070083 }
Adam Cohen1b36dc32012-02-13 19:27:37 -080084
85 // Copy constructor
86 public PendingAddWidgetInfo(PendingAddWidgetInfo copy) {
87 minWidth = copy.minWidth;
88 minHeight = copy.minHeight;
Adam Cohend41fbf52012-02-16 23:53:59 -080089 minResizeWidth = copy.minResizeWidth;
90 minResizeHeight = copy.minResizeHeight;
Adam Cohen1b36dc32012-02-13 19:27:37 -080091 previewImage = copy.previewImage;
92 icon = copy.icon;
93 info = copy.info;
94 boundWidget = copy.boundWidget;
Adam Cohen1b36dc32012-02-13 19:27:37 -080095 componentName = copy.componentName;
96 itemType = copy.itemType;
Adam Cohen1f362702012-04-04 14:58:12 -070097 spanX = copy.spanX;
98 spanY = copy.spanY;
99 minSpanX = copy.minSpanX;
100 minSpanY = copy.minSpanY;
Adam Cohendd70d662012-10-04 16:53:44 -0700101 bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone();
Adam Cohen1b36dc32012-02-13 19:27:37 -0800102 }
Winson Chung7ce99852012-05-24 17:34:08 -0700103
104 @Override
105 public String toString() {
106 return "Widget: " + componentName.toShortString();
107 }
Adam Cohen1b36dc32012-02-13 19:27:37 -0800108}