blob: b9d8ae6769434d88df33cce096a5125bdc3037ca [file] [log] [blame]
The Android Open Source Projectc8f00b62008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2008 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
17package com.android.launcher;
18
19import android.content.ContentValues;
20import android.graphics.Bitmap;
21import com.android.internal.provider.Settings;
22
23/**
24 * Represents one instance of a Launcher widget (clock, search, photo frame).
25 *
26 */
27class Widget extends ItemInfo {
28
29 int layoutResource;
30 Bitmap photo;
31
32 static Widget makeClock() {
33 Widget w = new Widget();
34 w.itemType = Settings.Favorites.ITEM_TYPE_WIDGET_CLOCK;
35 w.spanX = 2;
36 w.spanY = 2;
37 w.layoutResource = R.layout.widget_clock;
38 return w;
39 }
40
41 static Widget makePhotoFrame() {
42 Widget w = new Widget();
43 w.itemType = Settings.Favorites.ITEM_TYPE_WIDGET_PHOTO_FRAME;
44 w.spanX = 2;
45 w.spanY = 2;
46 w.layoutResource = R.layout.widget_photo_frame;
47 return w;
48 }
49
50 static Widget makeSearch() {
51 Widget w = new Widget();
52 w.itemType = Settings.Favorites.ITEM_TYPE_WIDGET_SEARCH;
53 w.spanX = 4;
54 w.spanY = 1;
55 w.layoutResource = R.layout.widget_search;
56 return w;
57 }
58
59 @Override
60 void onAddToDatabase(ContentValues values) {
61 super.onAddToDatabase(values);
62 writeBitmap(values, photo);
63 }
64
65}