diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d8b0b75..4c7c3f0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,8 @@
+
+
+
diff --git a/app/src/main/java/it/pgp/currenttoggles/MainActivity.java b/app/src/main/java/it/pgp/currenttoggles/MainActivity.java
index 474a57f..7c22bcf 100644
--- a/app/src/main/java/it/pgp/currenttoggles/MainActivity.java
+++ b/app/src/main/java/it/pgp/currenttoggles/MainActivity.java
@@ -34,7 +34,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
}
- public static void toggleDataOrWifi(Context context, String channel, II ii) { // channel: "data" or "wifi
+ public static void toggleDataWifiBluetooth(Context context, String channel, II ii) { // channel: "data" or "wifi
String[][] cmdsAndErrors = {
{channel + " currently DISABLED -> enabling...", "enable"},
{channel + " currently ENABLED -> disabling...", "disable"}
@@ -70,10 +70,13 @@ public static void toggleAirplane(Context context) {
public void toggle(View v) {
switch(v.getId()) {
case R.id.toggleData:
- toggleDataOrWifi(this, "data", Misc::isDataConnectionEnabled);
+ toggleDataWifiBluetooth(this, "data", Misc::isDataConnectionEnabled);
break;
case R.id.toggleWifi:
- toggleDataOrWifi(this, "wifi", Misc::isWifiEnabled);
+ toggleDataWifiBluetooth(this, "wifi", Misc::isWifiEnabled);
+ break;
+ case R.id.toggleBt:
+ toggleDataWifiBluetooth(this, "bluetooth", Misc::isBluetoothEnabled);
break;
case R.id.toggleAirplane:
toggleAirplane(context);
diff --git a/app/src/main/java/it/pgp/currenttoggles/MainWidget.java b/app/src/main/java/it/pgp/currenttoggles/MainWidget.java
index ab7bb62..1279924 100644
--- a/app/src/main/java/it/pgp/currenttoggles/MainWidget.java
+++ b/app/src/main/java/it/pgp/currenttoggles/MainWidget.java
@@ -14,8 +14,11 @@
public class MainWidget extends AppWidgetProvider {
+ public static final String LOG_PREFIX = "CURRENTTOGGLES";
+
private static final String onDemandWifi = "it.pgp.currenttoggles.appwidget.action.ON_DEMAND_WIFI";
private static final String onDemandData = "it.pgp.currenttoggles.appwidget.action.ON_DEMAND_DATA";
+ private static final String onDemandBluetooth = "it.pgp.currenttoggles.appwidget.action.ON_DEMAND_BLUETOOTH";
private static final String onDemandAirplane = "it.pgp.currenttoggles.appwidget.action.ON_DEMAND_AIRPLANE";
public static void updateAllDirect(Context context) {
@@ -47,6 +50,14 @@ public static void updateAllDirect(Context context) {
PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.toggle_wifi, pi);
+ ii = new Intent(context, MainWidget.class);
+ ii.setAction(onDemandBluetooth);
+ ii.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, w_ids);
+ pi = PendingIntent.getBroadcast(
+ context, appWidgetId, ii,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ remoteViews.setOnClickPendingIntent(R.id.toggle_bt, pi);
+
ii = new Intent(context, MainWidget.class);
ii.setAction(onDemandAirplane);
ii.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, w_ids);
@@ -63,21 +74,25 @@ public static void updateAllDirect(Context context) {
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
String a = intent.getAction();
- Log.d("XRE_RHSS","onReceive action: "+intent.getAction());
+ Log.d(LOG_PREFIX,"onReceive action: "+intent.getAction());
if (a == null) return;
if(MainActivity.context == null) MainActivity.refreshAppContext(context);
try {
switch(a) {
case onDemandWifi:
- Log.d("XRE_RHSS","onDemand Wifi");
- MainActivity.toggleDataOrWifi(context, "wifi", Misc::isWifiEnabled);
+ Log.d(LOG_PREFIX,"onDemand Wifi");
+ MainActivity.toggleDataWifiBluetooth(context, "wifi", Misc::isWifiEnabled);
break;
case onDemandData:
- Log.d("XRE_RHSS","onDemand Data");
- MainActivity.toggleDataOrWifi(context, "data", Misc::isDataConnectionEnabled);
+ Log.d(LOG_PREFIX,"onDemand Data");
+ MainActivity.toggleDataWifiBluetooth(context, "data", Misc::isDataConnectionEnabled);
+ break;
+ case onDemandBluetooth:
+ Log.d(LOG_PREFIX,"onDemand Bluetooth");
+ MainActivity.toggleDataWifiBluetooth(context, "bluetooth", Misc::isBluetoothEnabled);
break;
case onDemandAirplane:
- Log.d("XRE_RHSS","onDemand Airplane");
+ Log.d(LOG_PREFIX,"onDemand Airplane");
MainActivity.toggleAirplane(context);
break;
default:
diff --git a/app/src/main/java/it/pgp/currenttoggles/utils/Misc.java b/app/src/main/java/it/pgp/currenttoggles/utils/Misc.java
index cd55e3b..5f2c721 100644
--- a/app/src/main/java/it/pgp/currenttoggles/utils/Misc.java
+++ b/app/src/main/java/it/pgp/currenttoggles/utils/Misc.java
@@ -1,6 +1,7 @@
package it.pgp.currenttoggles.utils;
import android.annotation.TargetApi;
+import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Build;
@@ -25,4 +26,8 @@ public static boolean isWifiEnabled(Context context) {
public static boolean isAirplaneModeEnabled(Context context) {
return Settings.System.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
}
+
+ public static boolean isBluetoothEnabled(Context unused){
+ return BluetoothAdapter.getDefaultAdapter().isEnabled();
+ }
}
diff --git a/app/src/main/res/drawable/bt.png b/app/src/main/res/drawable/bt.png
new file mode 100644
index 0000000..de1ace0
Binary files /dev/null and b/app/src/main/res/drawable/bt.png differ
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 3408bbe..ac03111 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -17,6 +17,12 @@
android:id="@+id/toggleWifi"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+
+
+
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
deleted file mode 100644
index 61da551..0000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
deleted file mode 100644
index db5080a..0000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
deleted file mode 100644
index da31a87..0000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
deleted file mode 100644
index b216f2d..0000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
deleted file mode 100644
index e96783c..0000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ