16
16
import android .graphics .PorterDuff ;
17
17
import android .graphics .Typeface ;
18
18
import android .graphics .drawable .Drawable ;
19
+ import android .location .Address ;
19
20
import android .os .Bundle ;
20
21
import android .os .Handler ;
21
22
import android .os .IBinder ;
@@ -88,6 +89,7 @@ public class DashboardFragment extends CarFragment {
88
89
private TextView mValueElement1 , mValueElement2 , mValueElement3 , mValueElement4 , mTitleElement ,
89
90
mTitleElementRight , mTitleElementLeft , mTitleElementNavDistance , mTitleElementNavTime , mTitleNAVDestinationAddress ;
90
91
private TextView mTitleIcon1 , mTitleIcon2 , mTitleIcon3 , mTitleIcon4 , mTitleClockLeft , mTitleClockCenter , mTitleClockRight ;
92
+ private TextView mTitleConsumptionLeft , mTitleConsumptionCenter , mTitleConsumptionRight ;
91
93
private ConstraintLayout mConstraintClockLeft , mConstraintClockRight , mConstraintClockCenter ;
92
94
private ConstraintLayout mConstraintGraphLeft , mConstraintGraphRight , mConstraintGraphCenter ;
93
95
private ConstraintLayout mConstraintElementLeft , mConstraintElementRight , mConstraintElementCenter ;
@@ -141,6 +143,7 @@ public class DashboardFragment extends CarFragment {
141
143
private static final String FORMAT_VOLT0 = "-,-V" ;
142
144
private boolean celsiusTempUnit ;
143
145
private boolean showStreetName , useGoogleGeocoding , forceGoogleGeocoding ;
146
+ private String sourceLocation ;
144
147
private String selectedFont ;
145
148
private boolean selectedPressureUnits ;
146
149
private int updateSpeed = 2000 ;
@@ -406,7 +409,9 @@ private void setupViews(View rootView) {
406
409
mTitleClockLeft = rootView .findViewById (R .id .textTitleLabel1 );
407
410
mTitleClockCenter = rootView .findViewById (R .id .textTitleLabel2 );
408
411
mTitleClockRight = rootView .findViewById (R .id .textTitleLabel3 );
409
-
412
+ mTitleConsumptionLeft = rootView .findViewById (R .id .textTitleConsumptionLeft );
413
+ mTitleConsumptionCenter = rootView .findViewById (R .id .textTitleConsumptionCenter );
414
+ mTitleConsumptionRight = rootView .findViewById (R .id .textTitleConsumptionRight );
410
415
mTitleElementNavDistance = rootView .findViewById (R .id .textTitleNavDistance );
411
416
mTitleElementNavTime = rootView .findViewById (R .id .textTitleNavTime );
412
417
@@ -523,16 +528,16 @@ private void setupTypeface(String selectedFont) {
523
528
mTitleClockLeft .setTypeface (typeface );
524
529
mTitleClockCenter .setTypeface (typeface );
525
530
mTitleClockRight .setTypeface (typeface );
531
+ mTitleConsumptionLeft .setTypeface (typeface );
532
+ mTitleConsumptionCenter .setTypeface (typeface );
533
+ mTitleConsumptionRight .setTypeface (typeface );
526
534
mTitleElementNavDistance .setTypeface (typeface );
527
535
mTitleElementNavTime .setTypeface (typeface );
528
536
mtextTitleMain .setTypeface (typeface );
529
537
530
538
//max
531
- //mTextMinLeft.setTypeface(typeface);
532
539
mTextMaxLeft .setTypeface (typeface );
533
- //mTextMinCenter.setTypeface(typeface);
534
540
mTextMaxCenter .setTypeface (typeface );
535
- //mTextMinRight.setTypeface(typeface);
536
541
mTextMaxRight .setTypeface (typeface );
537
542
538
543
Log .d (TAG , "font: " + typeface );
@@ -554,6 +559,7 @@ private void onPreferencesChangeHandler() {
554
559
mBtnNext .setVisibility (View .VISIBLE );
555
560
mBtnPrev .setVisibility (View .VISIBLE );
556
561
mtextTitleMain .setVisibility (View .VISIBLE );
562
+ mtextTitleMain .setTextColor (Color .WHITE );
557
563
}
558
564
559
565
// Load this only on first run, then leave it alone
@@ -563,6 +569,7 @@ private void onPreferencesChangeHandler() {
563
569
showStreetName = sharedPreferences .getBoolean ("showStreetNameInTitle" , true );
564
570
useGoogleGeocoding = sharedPreferences .getBoolean ("useGoogleGeocoding" , false );
565
571
forceGoogleGeocoding = sharedPreferences .getBoolean ("forceGoogleGeocoding" , false );
572
+ sourceLocation = sharedPreferences .getString ("locationSourceData" ,"Geocoding" );
566
573
fueltanksize = Float .parseFloat (sharedPreferences .getString ("fueltanksize" , "50" ));
567
574
568
575
float speedLeft = MaxspeedLeft [dashboardNum ];
@@ -578,7 +585,12 @@ private void onPreferencesChangeHandler() {
578
585
mTextMaxRight .setText (String .format (Locale .US , FORMAT_DECIMALS , speedRight ));
579
586
580
587
String dashboardId = String .valueOf (dashboardNum );
581
- String mtextTitlePerformance = sharedPreferences .getString ("performanceTitle" + dashboardId , "Performance monitor" + dashboardId );
588
+ String mtextTitlePerformance ;
589
+ if (dashboardNum <4 ) {
590
+ mtextTitlePerformance = sharedPreferences .getString ("performanceTitle" + dashboardId , "Performance monitor" + dashboardId );
591
+ } else {
592
+ mtextTitlePerformance = getResources ().getString (R .string .pref_title_performance_4 );
593
+ }
582
594
583
595
mtextTitleMain .setText (mtextTitlePerformance );
584
596
@@ -957,14 +969,14 @@ public void onResume() {
957
969
getContext ().bindService (serviceIntent , mVexServiceConnection , Context .BIND_AUTO_CREATE );
958
970
startTorque ();
959
971
createAndStartUpdateTimer ();
960
- /* if (useGoogleGeocoding) {
972
+ if (useGoogleGeocoding ) {
961
973
if (!getContext ().bindService (new Intent (getContext (), GeocodeLocationService .class ),
962
974
mGeocodingServiceConnection ,
963
975
Context .BIND_AUTO_CREATE )) {
964
976
Log .e ("Geocode" , "Cannot bind?!" );
965
977
}
966
978
}
967
- */
979
+
968
980
LocalBroadcastManager .getInstance (getContext ())
969
981
.registerReceiver (onNoticeGoogleNavigationUpdate , new IntentFilter ("GoogleNavigationUpdate" ));
970
982
LocalBroadcastManager .getInstance (getContext ())
@@ -982,7 +994,7 @@ public void onResume() {
982
994
//Dashboard5_On = sharedPreferences.getBoolean("d5_active", false); //Enabled dasboard5
983
995
Dashboard5_On = false ;
984
996
}
985
- /*
997
+
986
998
private final GeocodeLocationService .IGeocodeResult geocodeResultListener = new GeocodeLocationService .IGeocodeResult () {
987
999
@ Override
988
1000
public void onNewGeocodeResult (Address result ) {
@@ -999,25 +1011,29 @@ public void onNewGeocodeResult(Address result) {
999
1011
// tmp = result.getPostalCode(); //PostalCode
1000
1012
// if (tmp != null)
1001
1013
// sb.append("("+tmp+")");
1014
+ tmp = result .getUrl (); //URL -> Altitude
1015
+ if (tmp != null )
1016
+ sb .append ("(" +tmp +")" );
1017
+
1002
1018
googleGeocodeLocationStr = sb .toString ();
1003
1019
}
1004
1020
};
1005
1021
1006
1022
private final ServiceConnection mGeocodingServiceConnection = new ServiceConnection () {
1007
1023
@ Override
1008
1024
public void onServiceConnected (ComponentName name , IBinder service ) {
1009
- // mGeocodingService = ((GeocodeLocationService.LocalBinder)service).getService();
1010
- // mGeocodingService.setOnNewGeocodeListener(geocodeResultListener);
1025
+ mGeocodingService = ((GeocodeLocationService .LocalBinder )service ).getService ();
1026
+ mGeocodingService .setOnNewGeocodeListener (geocodeResultListener );
1011
1027
Log .d ("Geocode" , "Service connected" );
1012
1028
}
1013
1029
1014
1030
@ Override
1015
1031
public void onServiceDisconnected (ComponentName name ) {
1016
1032
Log .e ("Geocode" , "Service disconnected" );
1017
- // mGeocodingService = null;
1033
+ mGeocodingService = null ;
1018
1034
}
1019
1035
};
1020
- */
1036
+
1021
1037
private void startTorque () {
1022
1038
Intent intent = new Intent ();
1023
1039
intent .setClassName ("org.prowl.torque" , "org.prowl.torque.remote.TorqueService" );
@@ -1069,7 +1085,7 @@ public void onPause() {
1069
1085
mStatsClient .unregisterListener (mCarStatsListener );
1070
1086
getContext ().unbindService (mVexServiceConnection );
1071
1087
if (useGoogleGeocoding ) {
1072
- // getContext().unbindService(mGeocodingServiceConnection);
1088
+ getContext ().unbindService (mGeocodingServiceConnection );
1073
1089
}
1074
1090
1075
1091
if (torqueBind )
@@ -1115,6 +1131,9 @@ public void onDestroyView() {
1115
1131
mTitleClockLeft = null ;
1116
1132
mTitleClockCenter = null ;
1117
1133
mTitleClockRight = null ;
1134
+ mTitleConsumptionLeft = null ;
1135
+ mTitleConsumptionCenter = null ;
1136
+ mTitleConsumptionRight = null ;
1118
1137
mTitleElementNavDistance = null ;
1119
1138
mTitleElementNavTime = null ;
1120
1139
mTitleIcon1 = null ;
@@ -1212,7 +1231,7 @@ private void SetLayoutElements(TextView mValueElement, String mMeasurements, Str
1212
1231
if (mGetMeasurement ==null ) mGetMeasurement = Float .valueOf (0 );
1213
1232
mGetMeasurement = mGetMeasurement * fueltanksize ;
1214
1233
Float mShortCons = (Float ) mLastMeasurements .get ("shortTermConsumptionPrimary" );
1215
- Float mLongCons = (Float ) mLastMeasurements .get ("shortTermConsumptionPrimary " );
1234
+ Float mLongCons = (Float ) mLastMeasurements .get ("LongTermConsumptionPrimary " );
1216
1235
if (mShortCons ==null || mShortCons ==0 ){
1217
1236
if (mLongCons ==null || mLongCons ==0 ){
1218
1237
mGetMeasurement = Float .valueOf (0 );
@@ -1364,7 +1383,6 @@ private void doUpdate() {
1364
1383
mConstraintClockCenter .setVisibility (View .INVISIBLE );
1365
1384
mConstraintClockRight .setVisibility (View .INVISIBLE );
1366
1385
1367
- //TODO: Refresh elements
1368
1386
UpdateLayoutElements ();
1369
1387
}
1370
1388
@@ -2363,21 +2381,34 @@ private void updateTitle() {
2363
2381
mTitleClockRight .setText (mLabelClockR );
2364
2382
mBtnNext .setVisibility (View .VISIBLE );
2365
2383
mBtnPrev .setVisibility (View .VISIBLE );
2366
- mtextTitleMain .setVisibility (View .VISIBLE );
2384
+ //mtextTitleMain.setVisibility(View.VISIBLE);
2385
+ mtextTitleMain .setTextColor (Color .WHITE );
2386
+ mTitleConsumptionRight .setVisibility (View .VISIBLE );
2387
+ mTitleConsumptionLeft .setVisibility (View .VISIBLE );
2388
+ mTitleConsumptionCenter .setVisibility (View .VISIBLE );
2367
2389
} else if (!proximityOn ) {
2368
2390
mTitleClockLeft .setText ("" );
2369
2391
mTitleClockCenter .setText ("" );
2370
2392
mTitleClockRight .setText ("" );
2371
2393
mBtnNext .setVisibility (View .VISIBLE );
2372
2394
mBtnPrev .setVisibility (View .VISIBLE );
2373
- mtextTitleMain .setVisibility (View .VISIBLE );
2395
+ //mtextTitleMain.setVisibility(View.VISIBLE);
2396
+ mtextTitleMain .setTextColor (Color .WHITE );
2397
+ mTitleConsumptionRight .setVisibility (View .INVISIBLE );
2398
+ mTitleConsumptionLeft .setVisibility (View .INVISIBLE );
2399
+ mTitleConsumptionCenter .setVisibility (View .INVISIBLE );
2374
2400
} else {
2375
2401
mTitleClockLeft .setText ("" );
2376
2402
mTitleClockCenter .setText ("" );
2377
2403
mTitleClockRight .setText ("" );
2378
2404
mBtnNext .setVisibility (View .INVISIBLE );
2379
2405
mBtnPrev .setVisibility (View .INVISIBLE );
2380
- mtextTitleMain .setVisibility (View .INVISIBLE );
2406
+ //mtextTitleMain.setVisibility(View.VISIBLE);
2407
+ mtextTitleMain .setTextColor (Color .DKGRAY );
2408
+ mTitleConsumptionRight .setVisibility (View .INVISIBLE );
2409
+ mTitleConsumptionLeft .setVisibility (View .INVISIBLE );
2410
+ mTitleConsumptionCenter .setVisibility (View .INVISIBLE );
2411
+
2381
2412
}
2382
2413
2383
2414
String currentTime = getTime ();
@@ -2389,8 +2420,13 @@ private void updateTitle() {
2389
2420
// Display location in left side of Title bar
2390
2421
if (showStreetName ) {
2391
2422
String leftTitle ="" ;
2392
- if (googleMapsLocationStr != null && !googleMapsLocationStr .isEmpty ()) { // Google maps has always priority for now
2393
- leftTitle = googleMapsLocationStr ;
2423
+ Log .v (TAG ,"SourceLocation: " +sourceLocation +"!!!" );
2424
+ if (sourceLocation .equals ("Geocoding" )) {
2425
+ leftTitle = googleGeocodeLocationStr ;
2426
+ } else {
2427
+ if (googleMapsLocationStr != null && !googleMapsLocationStr .isEmpty ()) {
2428
+ leftTitle = googleMapsLocationStr ;
2429
+ }
2394
2430
}
2395
2431
if (!forceGoogleGeocoding ) {
2396
2432
String location1 = (String ) mLastMeasurements .get ("Nav_CurrentPosition.Street" );
@@ -2644,6 +2680,11 @@ private void updateElement(String queryElement, TextView value, TextView label)
2644
2680
Float mTemperature = (Float ) mLastMeasurements .get (queryElement );
2645
2681
if (mTemperature != null && mTemperature > 0 ) {
2646
2682
value .setText (String .format (Locale .US , FORMAT_DEGREES , mTemperature ));
2683
+ if (mTemperature < 70 ) {
2684
+ value .setTextColor (Color .RED );
2685
+ } else {
2686
+ value .setTextColor (Color .WHITE );
2687
+ }
2647
2688
}
2648
2689
break ;
2649
2690
case "outsideTemperature" :
0 commit comments