Clean up sendMessage calls
[fonbot.git] / src / ro / ieval / fonbot / ProtectedBroadcastReceiver.java
CommitLineData
8dfb76c9
MG
1package ro.ieval.fonbot;
2
3import static ro.ieval.fonbot.R.string.*;
4
5import static ro.ieval.fonbot.Utils.toNonNull;
6
7import org.eclipse.jdt.annotation.Nullable;
8
9import ro.ieval.fonbot.Utils.MessageType;
10import android.content.BroadcastReceiver;
11import android.content.Context;
12import android.content.Intent;
ca40a5cc 13import android.net.ConnectivityManager;
8dfb76c9
MG
14
15/*
16 * Copyright © 2013 Marius Gavrilescu
17 *
18 * This file is part of FonBot.
19 *
20 * FonBot is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * FonBot is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with FonBot. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34/**
35 * BroadcastReceiver that receives various broadcasts sent by the sistem
36 *
37 * @author Marius Gavrilescu <marius@ieval.ro>
38 */
39public final class ProtectedBroadcastReceiver extends BroadcastReceiver {
40 @Override
41 public void onReceive(@Nullable final Context context, @Nullable final Intent intent) {
42 if(context==null || intent==null)
43 return;
44
45 final String action=intent.getAction();
46
47 if(action.equals(Intent.ACTION_BATTERY_LOW)){
e4e4926f 48 Utils.sendMessage(context, toNonNull(MessageType.BATTERY), battery_low);
8dfb76c9
MG
49 Heavy.describeBatteryLevel(context, null, toNonNull(MessageType.BATTERY));
50 } else if(action.equals(Intent.ACTION_BATTERY_OKAY)){
e4e4926f 51 Utils.sendMessage(context, toNonNull(MessageType.BATTERY),battery_okay);
8dfb76c9 52 Heavy.describeBatteryLevel(context, null, toNonNull(MessageType.BATTERY));
582cbf06 53 } else if(action.equals(Intent.ACTION_BOOT_COMPLETED)){
e4e4926f 54 Utils.sendMessage(context, toNonNull(MessageType.BOOT), device_booted);
ca40a5cc
MG
55 } else if(action.equals(ConnectivityManager.CONNECTIVITY_ACTION))
56 context.startService(new Intent(context, FonBotMainService.class));
8dfb76c9
MG
57 }
58
59}
This page took 0.017348 seconds and 4 git commands to generate.