From e88f93a9be35ca0a143b9a8e3ea410a6b625b2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Koles=C3=A1r=20Andr=C3=A1s?= Date: Wed, 26 Feb 2020 11:02:13 +0100 Subject: [PATCH 1/5] Display solution status in notification Make faster to check if status is still fixed --- src/gpsplus/rtkgps/RtkNaviService.java | 23 ++++++++++++++++++----- src/gpsplus/rtkgps/view/SolutionView.java | 6 ++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/gpsplus/rtkgps/RtkNaviService.java b/src/gpsplus/rtkgps/RtkNaviService.java index 864d73ad..008ec5f0 100644 --- a/src/gpsplus/rtkgps/RtkNaviService.java +++ b/src/gpsplus/rtkgps/RtkNaviService.java @@ -23,6 +23,7 @@ import android.provider.Settings; import android.support.v4.app.ActivityCompat; import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationManagerCompat; import android.util.Log; import android.widget.Toast; import butterknife.BindString; @@ -131,7 +132,9 @@ public RtkNaviService() { private static final String MM_MAP_HEADER = "COMPD_CS[\"WGS 84\",GEOGCS[\"\",DATUM[\"WGS 84\",SPHEROID[\"WGS 84\",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0],UNIT[\"Degrees\",0.0174532925199433],AXIS[\"Long\",East],AXIS[\"Lat\",North]],VERT_CS[\"\",VERT_DATUM[\"Ellipsoid\",2002],UNIT[\"Meters\",1],AXIS[\"Height\",Up]]]\r\n"; private static final String GPS_PROVIDER = LocationManager.GPS_PROVIDER; private boolean mHavePoint = false; - private int NOTIFICATION = R.string.local_service_started; + private static final int NOTIFICATION = R.string.local_service_started; + private static NotificationCompat.Builder notificationBuilder; + private static NotificationManagerCompat notificationManager; private RtkCommon rtkCommon; // Binder given to clients @@ -389,8 +392,9 @@ public void processStart() { mCpuLock.acquire(); - Notification notification = createForegroundNotification(); - startForeground(NOTIFICATION, notification); + notificationManager = NotificationManagerCompat.from(this); + notificationBuilder = createForegroundNotificationBuilder(); + startForeground(NOTIFICATION, notificationBuilder.build()); SharedPreferences prefs = this.getBaseContext().getSharedPreferences(SolutionOutputSettingsFragment.SHARED_PREFS_NAME, 0); mBoolMockLocationsPref = prefs.getBoolean(SolutionOutputSettingsFragment.KEY_OUTPUT_MOCK_LOCATION, false); @@ -437,6 +441,15 @@ public void processStart() { mBoolIsRunning = true; } + public static void updateNotificationText(String text) { + if ( + notificationBuilder == null || + notificationManager == null || + mbStarted == false + ) return; + notificationBuilder.setContentText(text); + notificationManager.notify(NOTIFICATION, notificationBuilder.build()); + } private void processStop() { mBoolIsRunning = false; @@ -628,7 +641,7 @@ public void onDestroy() { } @SuppressWarnings("deprecation") - private Notification createForegroundNotification() { + private NotificationCompat.Builder createForegroundNotificationBuilder() { CharSequence text = getText(R.string.local_service_started); // The PendingIntent to launch our activity if the user selects this @@ -645,7 +658,7 @@ private Notification createForegroundNotification() { builder.setNumber(100); builder.setAutoCancel(false); - return builder.build(); + return builder; } private class BluetoothCallbacks implements BluetoothToRtklib.Callbacks { diff --git a/src/gpsplus/rtkgps/view/SolutionView.java b/src/gpsplus/rtkgps/view/SolutionView.java index 51965d11..98dd1132 100644 --- a/src/gpsplus/rtkgps/view/SolutionView.java +++ b/src/gpsplus/rtkgps/view/SolutionView.java @@ -159,6 +159,7 @@ public String getProj4String() { private Format mSolutionFormat; private boolean mBoolIsGeodetic = false; + private SolutionStatus previousSolutionStatus; private final NumberFormat mCoordEcefFormatter; @@ -275,6 +276,11 @@ public void setStats(RtkControlResult status) { mSolutionIndicatorView.setStatus(solStatus); updateCoordinates(status); updateAgeText(sol); + if (previousSolutionStatus != solStatus) { + String solStatusText = this.getContext().getResources().getString(resId); + RtkNaviService.updateNotificationText(solStatusText); + } + previousSolutionStatus = solStatus; } public void setFormat(Format format) { From 3e5596651162a88f42521103e8ad90fba8033bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Koles=C3=A1r=20Andr=C3=A1s?= Date: Wed, 26 Feb 2020 12:10:28 +0100 Subject: [PATCH 2/5] Update notification from background service To be updated when application is not active --- src/gpsplus/rtkgps/RtkNaviService.java | 16 ++++++++++++++-- src/gpsplus/rtkgps/view/SolutionView.java | 6 ------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gpsplus/rtkgps/RtkNaviService.java b/src/gpsplus/rtkgps/RtkNaviService.java index 008ec5f0..7dac5baf 100644 --- a/src/gpsplus/rtkgps/RtkNaviService.java +++ b/src/gpsplus/rtkgps/RtkNaviService.java @@ -63,6 +63,7 @@ import gpsplus.rtklib.Solution; import gpsplus.rtklib.constants.EphemerisOption; import gpsplus.rtklib.constants.GeoidModel; +import gpsplus.rtklib.constants.SolutionStatus; import gpsplus.rtklib.constants.StreamType; import java.io.BufferedWriter; @@ -135,6 +136,8 @@ public RtkNaviService() { private static final int NOTIFICATION = R.string.local_service_started; private static NotificationCompat.Builder notificationBuilder; private static NotificationManagerCompat notificationManager; + private SolutionStatus previousSolutionStatus; + private RtkCommon rtkCommon; // Binder given to clients @@ -855,10 +858,19 @@ protected void onHandleIntent(Intent arg0) { { try { + RtkControlResult result = getRtkStatus(null); + Solution solution = result.getSolution(); + SolutionStatus solutionStatus = solution.getSolutionStatus(); + + if (previousSolutionStatus != solutionStatus) { + int resId = solutionStatus.getNameResId(); + String solutionStatusText = getString(resId); + RtkNaviService.updateNotificationText(solutionStatusText); + } + previousSolutionStatus = solutionStatus; + if (mBoolMockLocationsPref || mBoolGenerateGPXTrace) { - RtkControlResult result = getRtkStatus(null); - Solution solution = result.getSolution(); Position3d positionECEF = solution.getPosition(); if (RtkCommon.norm(positionECEF.getValues()) > 0.0) diff --git a/src/gpsplus/rtkgps/view/SolutionView.java b/src/gpsplus/rtkgps/view/SolutionView.java index 98dd1132..51965d11 100644 --- a/src/gpsplus/rtkgps/view/SolutionView.java +++ b/src/gpsplus/rtkgps/view/SolutionView.java @@ -159,7 +159,6 @@ public String getProj4String() { private Format mSolutionFormat; private boolean mBoolIsGeodetic = false; - private SolutionStatus previousSolutionStatus; private final NumberFormat mCoordEcefFormatter; @@ -276,11 +275,6 @@ public void setStats(RtkControlResult status) { mSolutionIndicatorView.setStatus(solStatus); updateCoordinates(status); updateAgeText(sol); - if (previousSolutionStatus != solStatus) { - String solStatusText = this.getContext().getResources().getString(resId); - RtkNaviService.updateNotificationText(solStatusText); - } - previousSolutionStatus = solStatus; } public void setFormat(Format format) { From 471033f5a3ef1d2f0f1cb22a757fa4532b6ea653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Koles=C3=A1r=20Andr=C3=A1s?= Date: Wed, 26 Feb 2020 13:18:33 +0100 Subject: [PATCH 3/5] Change notification icon to display solution status This way it's visible from any other app --- res/drawable-xxhdpi/solution_fix.png | Bin 0 -> 1610 bytes res/drawable-xxhdpi/solution_float.png | Bin 0 -> 2857 bytes res/drawable-xxhdpi/solution_none.png | Bin 0 -> 507 bytes res/drawable-xxhdpi/solution_single.png | Bin 0 -> 4317 bytes src/gpsplus/rtkgps/RtkNaviService.java | 32 +++++++++--------- .../rtklib/constants/SolutionStatus.java | 26 ++++++++------ 6 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 res/drawable-xxhdpi/solution_fix.png create mode 100644 res/drawable-xxhdpi/solution_float.png create mode 100644 res/drawable-xxhdpi/solution_none.png create mode 100644 res/drawable-xxhdpi/solution_single.png diff --git a/res/drawable-xxhdpi/solution_fix.png b/res/drawable-xxhdpi/solution_fix.png new file mode 100644 index 0000000000000000000000000000000000000000..ad889c3095e37280b724fb50d4f3f96a4288e73c GIT binary patch literal 1610 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zcalEX7WqAsj$Z!;#Vf2>u zcY-jZ;KQ@(Ktah8*NBqf{Irtt#G+J&^73-M%)IR4ybz1!+V$nJP++3O#jWxI%MJc; zD=p-6y~MA{rDSN;QR;Q=)ir)+-pOA!?9OSg{I=-#-1KKRZ&u#1doO+__4&;A=T7XY zeKvDuy4aQNnhE<1e0vM`D#e<<6Pog`5S;A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.png b/res/drawable-xxhdpi/solution_float.png new file mode 100644 index 0000000000000000000000000000000000000000..f1cf19fbf0716bf3055400eec89b74bc4c49b100 GIT binary patch literal 2857 zcmd6p`8U-67sp>S!)&rNNE%DXC)5X(Aw-g;AreC)COg$k_+U)QGD?_s3E5Lo;loTD zjntbcDNB|yVlsR_`dG)5XtI9w{eJ(5&pqef$GOjQ?m727f4Jwe+*}=Hv74{}09oPz zJNGq0zY>jHtL}p|)EcCsZHXlGTEwG+)7N@TXr}{*K2#j)hf+{kgo9RGdqX<|WS!QLBf%saBI`illFRLU*FK z>nQU^yZn2l(@8{_LZ1@&!{uL%)N(_J^$v>n-$+*aSzp0?4(YK~c6-GJe3m6qY*O2i zUI;4te1dhPwV?RaA-GZCKE5nXS_3BcZ`49aoQCT>TGP;VZJpuN$mC=nt%OY*$=c@}h@l*F#_S%LXdx~vt_ zz95oH77%plp^O%X{rbPaJ0VVNA3Y(>7*?psN?pXCW@ZI4kw z$S_OqXFtaFM6Tnf3vO2sJuRMLC1!%v-UOILS!`cv{v<1-<&`F8DPNTz(pCt)gww6A zQ5soxvY-$Cc6><~CsT{Bz0uzOz#iT?v05v0y8e>ITc+&T_$#RoNYjr$VRJiUZ7!^I zrG3{1F5PTMW9*J7EqRtZcr{prn|esyit4-s5tQnTn4giiPvFGr7V?dW{s9fAh@siA z>W?e8&972o4;BmOThTV%q^Zj9$Aa-~qpzTgnD9djgBC*cw0yQB=dqp9O;u)@J%5%N zTRe$=Cf`)j(Y+GNP^)DHx?I=NhXY>sj}4#pa;&e~3frSTt&S!slYJVWc}U+L#|leZ zO!1KASX9duXQo-Yroy2h%B}a;EdYpSQZlAZ*}r)THin6OKh@0BQ0@AhR0B9LmYJ*) zRMC&evIqw*Ad}mgcfwIbU#*wp2i*c(X3^3#D=9mQoRD)A}wlS1* z7F$XV1yEqNev)HT-}Ek&BS0+cN6fveJ9-#;c#m`j?X0RKvN3K#0kHFzj%YvKlP3Em z$C{xyY;;CVLK}&jzybDeUHp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`w$2buUI#Q#0^vN8QS_k9m8 z@=Cr$Dd0`XF~Q!duv_r>;>e_xT{#J3sYlw4WvGamzrjg=ik@lb@{>#TYvaPBw0mCn z=@BsN&e7N=7Ho=nk`W!h@Xb(+n$lG-c_?+r>?2qgxICLA^P<+8T-Off>t$S)1q!;KXsSTWw>70EK8Unc%h9YuIv<4l?hvI>!C%b8sMLx}O; z8Vf`XWy;0-PiqhL^65+Psh7bp(+vzvVIieGMv00Qqzg7)ikY_M)|owc{|$&UaPw)q z>E@<;*n;z=QOZAWV)D~V`8`H>O!x@5x29z^7qO(kx2L04G9h`_UTybW zT|QV$3T(R)qAm_1*Idr$h~#$eJ1IR;Kh7_(tKh8cpXK~ej2XDN>nh=ls5$h-=Zp1E zmk(59m8Cal5&1rSX&kq~4U&5N+Fzn{R<5MX`JHQT(792Qxb22j`d}mvzWLvcPpg0t X9j>xDjgYbS)&iovt6i0?|GEDFL4yFj literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/solution_none.png b/res/drawable-xxhdpi/solution_none.png new file mode 100644 index 0000000000000000000000000000000000000000..a151b4a30e439a70d1e86bac4afe05f67ff11e86 GIT binary patch literal 507 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zcalEX7WqAsj$Z!;#Vf2>u zcY-jZ;KQ@(Ktah8*NBqf{Irtt#G+J&^73-M%)IR4)#6gX@CBW;f4ysB^HNS3?9M^nM?}43`;m0Oc*Dq4HLoR-x|2*+-A-@ ilgmg%STQg>NZYq~E6Zly!&Qet>OEckT-G@yGywozIDWAJ literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/solution_single.png b/res/drawable-xxhdpi/solution_single.png new file mode 100644 index 0000000000000000000000000000000000000000..ab8c983dad57b32d2c4a1c38352627ff44d63ab7 GIT binary patch literal 4317 zcma)AcTm$?)BYtSp#}&op(7w%q)HKx9xxQ?ARP?Six5L^5_&N->Aiz;X#!HDMM0`c zy>oQjd-mBqNydiSa2gI8007{+I$EZen)F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s`^-ZIo`L}R1>2imu>@&Et; literal 0 HcmV?d00001 diff --git a/src/gpsplus/rtkgps/RtkNaviService.java b/src/gpsplus/rtkgps/RtkNaviService.java index 7dac5baf..91acc9c3 100644 --- a/src/gpsplus/rtkgps/RtkNaviService.java +++ b/src/gpsplus/rtkgps/RtkNaviService.java @@ -397,6 +397,8 @@ public void processStart() { notificationManager = NotificationManagerCompat.from(this); notificationBuilder = createForegroundNotificationBuilder(); + previousSolutionStatus = SolutionStatus.NONE; + setNotificationSolutionStatus(previousSolutionStatus); startForeground(NOTIFICATION, notificationBuilder.build()); SharedPreferences prefs = this.getBaseContext().getSharedPreferences(SolutionOutputSettingsFragment.SHARED_PREFS_NAME, 0); @@ -444,16 +446,6 @@ public void processStart() { mBoolIsRunning = true; } - public static void updateNotificationText(String text) { - if ( - notificationBuilder == null || - notificationManager == null || - mbStarted == false - ) return; - notificationBuilder.setContentText(text); - notificationManager.notify(NOTIFICATION, notificationBuilder.build()); - } - private void processStop() { mBoolIsRunning = false; mbStarted = false; @@ -847,6 +839,17 @@ private void stopUsb() { } } + private void setNotificationSolutionStatus(SolutionStatus solutionStatus) { + int resId = solutionStatus.getNameResId(); + String solutionStatusText = getString(resId); + notificationBuilder.setContentText(solutionStatusText); + notificationBuilder.setSmallIcon(solutionStatus.getIconResId()); + } + + private void updateNotification() { + notificationManager.notify(NOTIFICATION, notificationBuilder.build()); + } + /* (non-Javadoc) * @see android.app.IntentService#onHandleIntent(android.content.Intent) */ @@ -861,14 +864,11 @@ protected void onHandleIntent(Intent arg0) { RtkControlResult result = getRtkStatus(null); Solution solution = result.getSolution(); SolutionStatus solutionStatus = solution.getSolutionStatus(); - if (previousSolutionStatus != solutionStatus) { - int resId = solutionStatus.getNameResId(); - String solutionStatusText = getString(resId); - RtkNaviService.updateNotificationText(solutionStatusText); + setNotificationSolutionStatus(solutionStatus); + updateNotification(); + previousSolutionStatus = solutionStatus; } - previousSolutionStatus = solutionStatus; - if (mBoolMockLocationsPref || mBoolGenerateGPXTrace) { Position3d positionECEF = solution.getPosition(); diff --git a/src/gpsplus/rtklib/constants/SolutionStatus.java b/src/gpsplus/rtklib/constants/SolutionStatus.java index e3e19e1a..341d4d17 100644 --- a/src/gpsplus/rtklib/constants/SolutionStatus.java +++ b/src/gpsplus/rtklib/constants/SolutionStatus.java @@ -10,23 +10,25 @@ */ public enum SolutionStatus implements IHasRtklibId { - NONE(0, R.string.solq_none), - FIX(1, R.string.solq_fix), - FLOAT(2, R.string.solq_float), - SBAS(3, R.string.solq_sbas), - DGPS(4, R.string.solq_dgps), - SINGLE(5, R.string.solq_single), - PPP(6, R.string.solq_ppp), - DR(7, R.string.solq_dr), - INTERNAL(8,R.string.solq_internal) + NONE(0, R.string.solq_none, R.drawable.solution_none), + FIX(1, R.string.solq_fix, R.drawable.solution_fix), + FLOAT(2, R.string.solq_float, R.drawable.solution_float), + SBAS(3, R.string.solq_sbas, R.drawable.solution_single), + DGPS(4, R.string.solq_dgps, R.drawable.solution_single), + SINGLE(5, R.string.solq_single, R.drawable.solution_single), + PPP(6, R.string.solq_ppp, R.drawable.solution_fix), + DR(7, R.string.solq_dr, R.drawable.solution_none), + INTERNAL(8, R.string.solq_internal, R.drawable.solution_single) ; private final int mRtklibId; private final int mNameResId; + private final int mIconResId; - private SolutionStatus(int solqId, int nameResId) { + private SolutionStatus(int solqId, int nameResId, int iconResId) { mRtklibId = solqId; mNameResId = nameResId; + mIconResId = iconResId; } public static SolutionStatus valueOf(int solqId) { @@ -47,4 +49,8 @@ public int getRtklibId() { public int getNameResId() { return mNameResId; } + + public int getIconResId() { + return mIconResId; + } }; From 56386be377a2602af7a28f3f59519e4bf940432d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Koles=C3=A1r=20Andr=C3=A1s?= Date: Wed, 26 Feb 2020 15:37:54 +0100 Subject: [PATCH 4/5] Update notification when solution changes in activity Background task use different scheduling than activity --- src/gpsplus/rtkgps/RtkNaviService.java | 29 +++++++++++++++-------- src/gpsplus/rtkgps/view/SolutionView.java | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/gpsplus/rtkgps/RtkNaviService.java b/src/gpsplus/rtkgps/RtkNaviService.java index 91acc9c3..52487c2d 100644 --- a/src/gpsplus/rtkgps/RtkNaviService.java +++ b/src/gpsplus/rtkgps/RtkNaviService.java @@ -136,7 +136,8 @@ public RtkNaviService() { private static final int NOTIFICATION = R.string.local_service_started; private static NotificationCompat.Builder notificationBuilder; private static NotificationManagerCompat notificationManager; - private SolutionStatus previousSolutionStatus; + private static SolutionStatus previousSolutionStatus; + private static Context context; private RtkCommon rtkCommon; @@ -166,10 +167,10 @@ public RtkNaviService() { @Override public void onCreate() { super.onCreate(); + context = this.getBaseContext(); final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mCpuLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); - } @Override @@ -839,17 +840,29 @@ private void stopUsb() { } } - private void setNotificationSolutionStatus(SolutionStatus solutionStatus) { + private static void setNotificationSolutionStatus(SolutionStatus solutionStatus) { int resId = solutionStatus.getNameResId(); - String solutionStatusText = getString(resId); + String solutionStatusText = context.getString(resId); notificationBuilder.setContentText(solutionStatusText); notificationBuilder.setSmallIcon(solutionStatus.getIconResId()); } - private void updateNotification() { + private static void updateNotification() { notificationManager.notify(NOTIFICATION, notificationBuilder.build()); } + public static void setNotificationSolutionStatusWithUpdate(SolutionStatus solutionStatus) { + if ( + previousSolutionStatus != solutionStatus && + notificationBuilder != null && + notificationManager != null + ) { + setNotificationSolutionStatus(solutionStatus); + updateNotification(); + previousSolutionStatus = solutionStatus; + } + } + /* (non-Javadoc) * @see android.app.IntentService#onHandleIntent(android.content.Intent) */ @@ -864,11 +877,7 @@ protected void onHandleIntent(Intent arg0) { RtkControlResult result = getRtkStatus(null); Solution solution = result.getSolution(); SolutionStatus solutionStatus = solution.getSolutionStatus(); - if (previousSolutionStatus != solutionStatus) { - setNotificationSolutionStatus(solutionStatus); - updateNotification(); - previousSolutionStatus = solutionStatus; - } + setNotificationSolutionStatusWithUpdate(solutionStatus); if (mBoolMockLocationsPref || mBoolGenerateGPXTrace) { Position3d positionECEF = solution.getPosition(); diff --git a/src/gpsplus/rtkgps/view/SolutionView.java b/src/gpsplus/rtkgps/view/SolutionView.java index 51965d11..39e05238 100644 --- a/src/gpsplus/rtkgps/view/SolutionView.java +++ b/src/gpsplus/rtkgps/view/SolutionView.java @@ -275,6 +275,7 @@ public void setStats(RtkControlResult status) { mSolutionIndicatorView.setStatus(solStatus); updateCoordinates(status); updateAgeText(sol); + RtkNaviService.setNotificationSolutionStatusWithUpdate(solStatus); } public void setFormat(Format format) { From d7204f0db11727525d4cbde2ccf2ce44daa32c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Koles=C3=A1r=20Andr=C3=A1s?= Date: Sat, 29 Feb 2020 12:19:06 +0100 Subject: [PATCH 5/5] Display timestamp of current solution in notification --- res/values/strings.xml | 51 +++++++++++++------------- src/gpsplus/rtkgps/RtkNaviService.java | 9 ++++- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index b6a5210b..ae03deac 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -29,6 +29,7 @@ Geoportail aerial Local service started Local service stopped + %s since %s RtkGps N W @@ -52,7 +53,7 @@ Processing options Solution options Caster options - + Rover Base @@ -130,7 +131,7 @@ b: height: - + Single DGPS/DGNSS @@ -168,7 +169,7 @@ PPP Dead reckoning Internal - + Lat/Long/Height X/Y/Z — ECEF @@ -261,7 +262,7 @@ Rinex header RTCM Antenna position - + Processing options 1 Solution options @@ -327,7 +328,7 @@ 35 40 - + GPS Integer ambiguity resolution GPS Integer ambiguity resolution @@ -532,11 +533,11 @@ 30 60 - + Output header Set whether the header is output or not - + Output GPS mock locations Set if solution is sent to other applications like the internal GPS @@ -553,7 +554,7 @@ OFF Solid Solid, ocean, pole - + ddd.dddddddd : Degree ddd mm ss.sss : Degree minute second @@ -627,7 +628,7 @@ +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs Enable test mode If this is enabled and Rover/Base/Correction are off, it runs in a special test mode with positions coming from internal GPS. Obviously no algorithm from RTKLIB can work - + Type Format @@ -644,10 +645,10 @@ Receiver option Transmit GPGGA to Base Station Latitude - Longitude + Longitude Antenna Antenna official IGS name (for phase center variation) - + OFF Latitude/Longitude @@ -658,8 +659,8 @@ 1 2 - - + + Enable Solution 1 Enable Solution 2 @@ -668,7 +669,7 @@ Solution 2 GPX Trace - + Log rover Log base @@ -676,7 +677,7 @@ Log Rover Log Base Log Correction - + NTRIP client settings Host @@ -703,7 +704,7 @@ File settings - + Bluetooth receiver settings device not selected @@ -711,7 +712,7 @@ Bluetooth device Bluetooth system settings Display system Bluetooth settings screen - + Bluetooth connected Bluetooth connection lost @@ -744,10 +745,10 @@ - + USB connected USB connection lost - + USB receiver settings Baudrate @@ -794,7 +795,7 @@ 1 2 - + Send commands at startup Send commands at shutdown @@ -802,14 +803,14 @@ Commands at shutdown Load Select file - + Lat/Lon/Height (deg/m) Lat/Lon/Height (dms/m) X/Y/Z — ECEF For fixed mode For relative mode - + SNR Rover/Base SNR Rover/Base L1 @@ -817,7 +818,7 @@ SNR Rover/Base L5 Skyplot Rover L1 Skyplot Rover L2 - Skyplot Rover L5 + Skyplot Rover L5 Skyplot Base L1 Skyplot Base L2 Skyplot Base L5 @@ -830,12 +831,12 @@ Install EGM 2008 2.5\' Geoid (135MB) Install EGM 2008 1.0\' Geoid (825MB) Install EGM 96 15\' Geoid (2MB) - + Change Log What\'s New OK more… - + Enable experimental NTRIP Caster NTRIP Caster Ending NTRIP Caster will also shutown RTKGPS+, it is safer for being sure all connections are closed. diff --git a/src/gpsplus/rtkgps/RtkNaviService.java b/src/gpsplus/rtkgps/RtkNaviService.java index 52487c2d..9940368b 100644 --- a/src/gpsplus/rtkgps/RtkNaviService.java +++ b/src/gpsplus/rtkgps/RtkNaviService.java @@ -71,6 +71,8 @@ import java.io.FileWriter; import java.io.IOException; import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Locale; public class RtkNaviService extends IntentService implements LocationListener { @@ -843,7 +845,12 @@ private void stopUsb() { private static void setNotificationSolutionStatus(SolutionStatus solutionStatus) { int resId = solutionStatus.getNameResId(); String solutionStatusText = context.getString(resId); - notificationBuilder.setContentText(solutionStatusText); + String contentText = String.format( + context.getString(R.string.local_service_notification_content), + solutionStatusText, + new SimpleDateFormat("HH:mm:ss").format(new Date()) + ); + notificationBuilder.setContentText(contentText); notificationBuilder.setSmallIcon(solutionStatus.getIconResId()); }