OSDN Git Service

auto import from //branches/cupcake/...@130745
[android-x86/packages-apps-AlarmClock.git] / src / com / android / alarmclock / AnalogGadgetProvider.java
1 /*
2  * Copyright (C) 2009 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.alarmclock;
18
19 import android.app.AlarmManager;
20 import android.app.PendingIntent;
21 import android.content.BroadcastReceiver;
22 import android.content.ComponentName;
23 import android.content.ContentResolver;
24 import android.content.Context;
25 import android.content.Intent;
26 import android.content.res.Resources;
27 import android.database.Cursor;
28 import android.gadget.GadgetManager;
29 import android.graphics.PorterDuff;
30 import android.net.Uri;
31 import android.provider.Calendar;
32 import android.provider.Calendar.Attendees;
33 import android.provider.Calendar.Calendars;
34 import android.provider.Calendar.EventsColumns;
35 import android.provider.Calendar.Instances;
36 import android.provider.Calendar.Reminders;
37 import android.text.format.DateFormat;
38 import android.text.format.DateUtils;
39 import android.util.Config;
40 import android.util.Log;
41 import android.view.View;
42 import android.widget.RemoteViews;
43
44 import java.util.Arrays;
45
46 /**
47  * Simple gadget to show analog clock.
48  */
49 public class AnalogGadgetProvider extends BroadcastReceiver {
50     static final String TAG = "AnalogGadgetProvider";
51
52     public void onReceive(Context context, Intent intent) {
53         String action = intent.getAction();
54         
55         if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) {
56             RemoteViews views = new RemoteViews(context.getPackageName(),
57                     R.layout.analog_gadget);
58             
59             int[] gadgetIds = intent.getIntArrayExtra(GadgetManager.EXTRA_GADGET_IDS);
60             
61             GadgetManager gm = GadgetManager.getInstance(context);
62             gm.updateGadget(gadgetIds, views);
63         }
64     }
65 }
66