• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 package com.android.launcher3.widget;
17 
18 import android.appwidget.AppWidgetHostView;
19 import android.content.Context;
20 import android.os.Bundle;
21 import android.os.Parcelable;
22 
23 import com.android.launcher3.Launcher;
24 import com.android.launcher3.LauncherAppWidgetProviderInfo;
25 import com.android.launcher3.LauncherSettings;
26 import com.android.launcher3.PendingAddItemInfo;
27 import com.android.launcher3.compat.AppWidgetManagerCompat;
28 
29 /**
30  * Meta data used for late binding of {@link LauncherAppWidgetProviderInfo}.
31  *
32  * @see {@link PendingAddItemInfo}
33  */
34 public class PendingAddWidgetInfo extends PendingAddItemInfo {
35     public int previewImage;
36     public int icon;
37     public LauncherAppWidgetProviderInfo info;
38     public AppWidgetHostView boundWidget;
39     public Bundle bindOptions = null;
40 
PendingAddWidgetInfo(Context context, LauncherAppWidgetProviderInfo i)41     public PendingAddWidgetInfo(Context context, LauncherAppWidgetProviderInfo i) {
42         if (i.isCustomWidget) {
43             itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
44         } else {
45             itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
46         }
47         this.info = i;
48         user = AppWidgetManagerCompat.getInstance(context).getUser(i);
49         componentName = i.provider;
50         previewImage = i.previewImage;
51         icon = i.icon;
52 
53         spanX = i.spanX;
54         spanY = i.spanY;
55         minSpanX = i.minSpanX;
56         minSpanY = i.minSpanY;
57     }
58 
isCustomWidget()59     public boolean isCustomWidget() {
60         return itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
61     }
62 }
63