diff --git a/androidgcs/default.properties b/androidgcs/default.properties index 420db56e3..728f51f97 100644 --- a/androidgcs/default.properties +++ b/androidgcs/default.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=Google Inc.:Google APIs:8 +target=Google Inc.:Google APIs:11 diff --git a/androidgcs/res/xml/preferences.xml b/androidgcs/res/xml/preferences.xml index d731f59dd..24fd43b5e 100644 --- a/androidgcs/res/xml/preferences.xml +++ b/androidgcs/res/xml/preferences.xml @@ -1,12 +1,15 @@ - - - + + + + + + diff --git a/androidgcs/src/org/openpilot/androidgcs/TelemetryWidget.java b/androidgcs/src/org/openpilot/androidgcs/TelemetryWidget.java index d316526ef..51afdf568 100644 --- a/androidgcs/src/org/openpilot/androidgcs/TelemetryWidget.java +++ b/androidgcs/src/org/openpilot/androidgcs/TelemetryWidget.java @@ -2,11 +2,34 @@ package org.openpilot.androidgcs; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; +import android.content.ComponentName; import android.content.Context; +import android.content.Intent; import android.widget.RemoteViews; public class TelemetryWidget extends AppWidgetProvider { + @Override + public void onReceive(Context context, Intent intent) { + if(intent.getAction().equals(OPTelemetryService.INTENT_ACTION_CONNECTED)) { + changeStatus(context, true); + } + if(intent.getAction().equals(OPTelemetryService.INTENT_ACTION_DISCONNECTED)) { + changeStatus(context, false); + } + + super.onReceive(context, intent); + } + + public void changeStatus(Context context, boolean status) { + RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.telemetry_widget); + updateViews.setTextViewText(R.id.telemetryWidgetStatus, "Connection status: " + status); + ComponentName thisWidget = new ComponentName(context, TelemetryWidget.class); + AppWidgetManager manager = AppWidgetManager.getInstance(context); + manager.updateAppWidget(thisWidget, updateViews); + + } + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N = appWidgetIds.length; @@ -16,7 +39,6 @@ public class TelemetryWidget extends AppWidgetProvider { // Get the layout for the App Widget and attach an on-click listener to the button RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.telemetry_widget); - //views.setOnClickPendingIntent(R.id.button, pendingIntent); // Tell the AppWidgetManager to perform an update on the current App Widget appWidgetManager.updateAppWidget(appWidgetId, views); diff --git a/androidgcs/src/org/openpilot/uavtalk/uavobjects/UAVObjectsInitialize.java b/androidgcs/src/org/openpilot/uavtalk/uavobjects/UAVObjectsInitialize.java index 4eca6ea82..d1d47aebb 100644 --- a/androidgcs/src/org/openpilot/uavtalk/uavobjects/UAVObjectsInitialize.java +++ b/androidgcs/src/org/openpilot/uavtalk/uavobjects/UAVObjectsInitialize.java @@ -28,7 +28,7 @@ package org.openpilot.uavtalk.uavobjects; -import org.openpilot.uavtalk.uavobjects.*; +//import org.openpilot.uavtalk.uavobjects.*; import org.openpilot.uavtalk.UAVObjectManager; public class UAVObjectsInitialize {