1 package ro
.ieval
.fonbot
;
3 import static ro
.ieval
.fonbot
.R
.string
.*;
5 import static ro
.ieval
.fonbot
.Utils
.toNonNull
;
7 import org
.eclipse
.jdt
.annotation
.Nullable
;
9 import ro
.ieval
.fonbot
.Utils
.MessageType
;
10 import android
.content
.BroadcastReceiver
;
11 import android
.content
.Context
;
12 import android
.content
.Intent
;
15 * Copyright © 2013 Marius Gavrilescu
17 * This file is part of FonBot.
19 * FonBot is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * FonBot is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with FonBot. If not, see <http://www.gnu.org/licenses/>.
34 * BroadcastReceiver that receives various broadcasts sent by the sistem
36 * @author Marius Gavrilescu <marius@ieval.ro>
38 public final class ProtectedBroadcastReceiver
extends BroadcastReceiver
{
40 public void onReceive(@Nullable final Context context
, @Nullable final Intent intent
) {
41 if(context
==null || intent
==null)
44 final String action
=intent
.getAction();
46 if(action
.equals(Intent
.ACTION_BATTERY_LOW
)){
47 Utils
.sendMessage(context
, toNonNull(MessageType
.BATTERY
),
48 toNonNull(context
.getString(battery_low
)));
49 Heavy
.describeBatteryLevel(context
, null, toNonNull(MessageType
.BATTERY
));
50 } else if(action
.equals(Intent
.ACTION_BATTERY_OKAY
)){
51 Utils
.sendMessage(context
, toNonNull(MessageType
.BATTERY
),
52 toNonNull(context
.getString(battery_okay
)));
53 Heavy
.describeBatteryLevel(context
, null, toNonNull(MessageType
.BATTERY
));