blob: 9648ec1132c908b440d40b892d3961a0fe6f3269 [file] [log] [blame]
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2007 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.settings;
18
19import android.app.Notification;
20import android.app.NotificationManager;
21import android.content.Context;
22import android.content.Intent;
23import android.content.BroadcastReceiver;
24import android.util.Config;
25import android.util.Log;
26
27/**
28 *
29 */
30public class SdCardIntentReceiver extends BroadcastReceiver {
31
32 private static final int SDCARD_STATUS = 1;
33 private static final String TAG = "SdCardIntentReceiver";
34
35 @Override
36 public void onReceive(Context context, Intent intent) {
37 NotificationManager nm = (NotificationManager) context
38 .getSystemService(Context.NOTIFICATION_SERVICE);
39 String action = intent.getAction();
40 if (Config.LOGD) Log.d(TAG, "onReceiveIntent " + action);
41
42 if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
43 nm.cancel(SDCARD_STATUS);
44
45 Intent statusIntent = new Intent(Intent.ACTION_MAIN, null);
46 statusIntent.setClass(context, SdCardSettings.class);
47 nm.notify(SDCARD_STATUS, new Notification(context,
48 android.R.drawable.stat_notify_sdcard,
49 null,
50 System.currentTimeMillis(),
51 context.getText(R.string.sdcard_setting),
52 null,
53 statusIntent));
54 } else if (action.equals(Intent.ACTION_MEDIA_REMOVED)) {
55 nm.cancel(SDCARD_STATUS);
56 } else if (action.equals(Intent.ACTION_MEDIA_SHARED)) {
57 nm.cancel(SDCARD_STATUS);
58
59 Intent statusIntent = new Intent(Intent.ACTION_MAIN, null);
60 statusIntent.setClass(context, SdCardSettings.class);
61 nm.notify(SDCARD_STATUS, new Notification(context,
62 android.R.drawable.stat_notify_sdcard_usb,
63 null,
64 System.currentTimeMillis(),
65 "SD Card",
66 null,
67 statusIntent));
68 }
69 }
70}