Home | History | Annotate | Download | only in launcher2
      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.Bundle;
     24 import android.os.Parcelable;
     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;
     34 }
     35 
     36 class PendingAddShortcutInfo extends PendingAddItemInfo {
     37 
     38     ActivityInfo shortcutActivityInfo;
     39 
     40     public PendingAddShortcutInfo(ActivityInfo activityInfo) {
     41         shortcutActivityInfo = activityInfo;
     42     }
     43 
     44     @Override
     45     public String toString() {
     46         return "Shortcut: " + shortcutActivityInfo.packageName;
     47     }
     48 }
     49 
     50 class PendingAddWidgetInfo extends PendingAddItemInfo {
     51     AppWidgetProviderInfo info;
     52     AppWidgetHostView boundWidget;
     53     Bundle bindOptions = null;
     54 
     55     // Any configuration data that we want to pass to a configuration activity when
     56     // starting up a widget
     57     String mimeType;
     58     Parcelable configurationData;
     59 
     60     public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) {
     61         itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
     62         this.info = i;
     63         componentName = i.provider;
     64         if (dataMimeType != null && data != null) {
     65             mimeType = dataMimeType;
     66             configurationData = data;
     67         }
     68     }
     69 
     70     // Copy constructor
     71     public PendingAddWidgetInfo(PendingAddWidgetInfo copy) {
     72         info = copy.info;
     73         boundWidget = copy.boundWidget;
     74         mimeType = copy.mimeType;
     75         configurationData = copy.configurationData;
     76         componentName = copy.componentName;
     77         itemType = copy.itemType;
     78         spanX = copy.spanX;
     79         spanY = copy.spanY;
     80         minSpanX = copy.minSpanX;
     81         minSpanY = copy.minSpanY;
     82         bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone();
     83     }
     84 
     85     @Override
     86     public String toString() {
     87         return "Widget: " + componentName.toShortString();
     88     }
     89 }
     90