mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-29 07:17:17 +00:00
TRACKING APP: report number of unsent gps fixes to API
This commit is contained in:
1 parent
bfd81b85ed
commit
5214b0a1f5
12 files changed
+230
-103
No files matched your search
@@ -1 +0,0 @@
|
||||
/com/
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package com.sap.sailing.android.tracking.app.test;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.sap.sailing.android.tracking.app.test;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int ic_launcher=0x7f020000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f030000;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/mode_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/qps_quality"
|
||||
android:gravity="center_vertical"
|
||||
@@ -27,12 +27,33 @@
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/tracking_mode_caching"
|
||||
android:textColor="@color/sap_green" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_unsent_fixes_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/mode_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_unsent_fixes" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_unsent_fixes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignBaseline="@id/tracking_unsent_fixes_label"
|
||||
android:layout_alignBottom="@id/tracking_unsent_fixes_label"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/sap_green"
|
||||
android:text="@string/zero" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_below="@+id/mode_label"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/tracking_unsent_fixes_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_status" />
|
||||
@@ -52,7 +73,7 @@
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_below="@+id/tracking_status_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
@@ -66,6 +87,12 @@
|
||||
android:layout_below="@id/mode_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@id/tracking_unsent_fixes_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
@@ -84,7 +111,7 @@
|
||||
android:id="@+id/start_tracking_box"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_above="@id/bottomLayout"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/gray" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansButton
|
||||
@@ -101,27 +128,10 @@
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/darker_gray" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_time_info_label"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/tracking_time"
|
||||
android:gravity="center_vertical"
|
||||
@@ -131,7 +141,7 @@
|
||||
<com.sap.sailing.android.tracking.app.views.AutoResizeTextView
|
||||
android:id="@+id/tracking_time_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignBaseline="@+id/tracking_time_info_label"
|
||||
android:layout_alignBottom="@+id/tracking_time_info_label"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.sap.sailing.android.tracking.app.customviews.OpenSansToolbar>
|
||||
|
||||
@@ -27,12 +27,33 @@
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/sap_green"
|
||||
android:text="@string/tracking_mode_caching" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_unsent_fixes_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_below="@+id/mode_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_unsent_fixes" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_unsent_fixes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignBaseline="@id/tracking_unsent_fixes_label"
|
||||
android:layout_alignBottom="@id/tracking_unsent_fixes_label"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/sap_green"
|
||||
android:text="@string/zero" />
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:id="@+id/tracking_status_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_below="@+id/mode_label"
|
||||
android:layout_below="@+id/tracking_unsent_fixes_label"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/tracking_status" />
|
||||
@@ -112,6 +133,12 @@
|
||||
android:layout_below="@id/tracking_status_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_below="@id/tracking_unsent_fixes_label"
|
||||
android:background="@android:color/darker_gray" />
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
@@ -122,7 +149,7 @@
|
||||
android:id="@+id/start_tracking_box"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_above="@id/bottomLayout"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/gray" >
|
||||
|
||||
<View
|
||||
@@ -148,22 +175,4 @@
|
||||
android:textStyle="bold"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/bottomLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/darker_gray"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true" >
|
||||
|
||||
<com.sap.sailing.android.tracking.app.customviews.OpenSansTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -44,6 +44,7 @@
|
||||
<string name="tracking_mode_battery_saving">Energie sparen</string>
|
||||
<string name="tracking_mode_caching">Offline</string>
|
||||
<string name="tracking_mode_api_error">API-Fehler</string>
|
||||
<string name="tracking_unsent_fixes">Ungesendete Tracking-Fixes</string>
|
||||
<string name="add_team_photo">Team Foto hinzufügen</string>
|
||||
<string name="do_you_want_to_choose_existing_img_or_take_a_new_one">Bild auswählen oder neues Foto aufnehmen?</string>
|
||||
<string name="existing_image">Auswählen</string>
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
<string name="tracking_qps_quality">GPS Quality</string>
|
||||
<string name="tracking_mode">Mode</string>
|
||||
<string name="tracking_mode_live">Live</string>
|
||||
<string name="tracking_mode_battery_saving">Battery Saving</string>
|
||||
<string name="tracking_mode_battery_saving">Battery Saving</string>
|
||||
<string name="tracking_unsent_fixes">Unsent fixes</string>
|
||||
<string name="zero">0</string>
|
||||
<string name="tracking_mode_caching">Offline</string>
|
||||
<string name="tracking_mode_api_error">API-Error</string>
|
||||
<string name="tracking_mode_offline">Offline</string>
|
||||
|
||||
+63
@@ -8,6 +8,7 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@@ -261,6 +262,7 @@ public class TransmittingService extends Service {
|
||||
}
|
||||
|
||||
sendFixesToAPI(null);
|
||||
reportUnsentGPSFixesCount(getNumberOfUnsentGPSFixes());
|
||||
}
|
||||
|
||||
private boolean getTrackingServiceIsCurrentlyTracking()
|
||||
@@ -362,6 +364,54 @@ public class TransmittingService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a count of ALL unsent GPS-fixes.
|
||||
*
|
||||
* This method is only interested in the GPS-fixes for the currently tracked event,
|
||||
* and needs to find out the id of that event first.
|
||||
* @return
|
||||
*/
|
||||
private int getNumberOfUnsentGPSFixes()
|
||||
{
|
||||
String selectionClause = SensorGps.GPS_SYNCED + " = 0";
|
||||
String sortAndLimitClause = SensorGps.GPS_TIME + " DESC LIMIT 1";
|
||||
|
||||
int eventId = -1;
|
||||
|
||||
Cursor cur = getContentResolver().query(
|
||||
EventGpsFixesJoined.CONTENT_URI,
|
||||
new String[] { "events._id as _eid" },
|
||||
selectionClause,
|
||||
null,
|
||||
sortAndLimitClause);
|
||||
|
||||
while (cur.moveToNext()) {
|
||||
eventId = cur.getInt(0);
|
||||
}
|
||||
|
||||
cur.close();
|
||||
|
||||
if (eventId == -1)
|
||||
{
|
||||
if (BuildConfig.DEBUG)
|
||||
{
|
||||
ExLog.i(this, TAG, "no event id, reporting 0 gps-fixes.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
String selectionClause2 = "events._id = " + eventId;
|
||||
Cursor countCursor = getContentResolver().query(
|
||||
EventGpsFixesJoined.CONTENT_URI,
|
||||
new String[] { "count(*) AS count" }, selectionClause2, null, null);
|
||||
|
||||
countCursor.moveToFirst();
|
||||
int count = countCursor.getInt(0);
|
||||
countCursor.close();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private float getBatteryPercentage()
|
||||
{
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
@@ -421,6 +471,18 @@ public class TransmittingService extends Service {
|
||||
apiConnectivityListener.apiConnectivityUpdated( apiConnectivity );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the number of currently unsent GPS-fixes
|
||||
* @param unsentGPSFixesCount
|
||||
*/
|
||||
private void reportUnsentGPSFixesCount( int unsentGPSFixesCount )
|
||||
{
|
||||
if (apiConnectivityListener != null)
|
||||
{
|
||||
apiConnectivityListener.setUnsentGPSFixesCount(unsentGPSFixesCount);
|
||||
}
|
||||
}
|
||||
|
||||
// might need this class in the future:
|
||||
//
|
||||
@@ -627,6 +689,7 @@ public class TransmittingService extends Service {
|
||||
|
||||
public interface APIConnectivityListener {
|
||||
public void apiConnectivityUpdated( APIConnectivity apiConnectivity );
|
||||
public void setUnsentGPSFixesCount( int count );
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -160,6 +160,13 @@ public class TrackingActivity extends BaseActivity implements GPSQualityListener
|
||||
trackingFragment.setAPIConnectivityStatus(apiConnectivity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnsentGPSFixesCount(int count) {
|
||||
TrackingFragment trackingFragment = (TrackingFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.content_frame);
|
||||
trackingFragment.setUnsentGPSFixesCount(count);
|
||||
}
|
||||
|
||||
private void startTrackingService(int eventId)
|
||||
{
|
||||
Intent intent = new Intent(this, TrackingService.class);
|
||||
|
||||
+10
@@ -288,6 +288,16 @@ public class TrackingFragment extends BaseFragment implements OnClickListener {
|
||||
lastGPSQualityUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setUnsentGPSFixesCount(final int count)
|
||||
{
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TextView unsentGpsFixesTextView = (TextView)getActivity().findViewById(R.id.tracking_unsent_fixes);
|
||||
unsentGpsFixesTextView.setText(String.valueOf(count));
|
||||
}});
|
||||
}
|
||||
|
||||
private class TimerRunnable implements Runnable {
|
||||
|
||||
public Thread t;
|
||||
|
||||
Reference in new issue
Block a user