diff --git a/app/build.gradle b/app/build.gradle index 1ebb35c6..a3e0cc47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,7 +34,7 @@ android { minSdkVersion 14 targetSdkVersion 28 versionCode 28 - versionName '2.2.5b_20191005' + versionName '2.2.5b_20191220' } buildTypes { debug { diff --git a/app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentGPSFix.java b/app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentGPSFix.java index 8dfb2896..e7887e5a 100644 --- a/app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentGPSFix.java +++ b/app/src/main/java/eu/basicairdata/graziano/gpslogger/FragmentGPSFix.java @@ -20,11 +20,14 @@ package eu.basicairdata.graziano.gpslogger; import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.TableLayout; import android.widget.TextView; @@ -45,6 +48,8 @@ public class FragmentGPSFix extends Fragment { private PhysicalDataFormatter phdformatter = new PhysicalDataFormatter(); + private FrameLayout FLGPSFix; + private TextView TVLatitude; private TextView TVLongitude; private TextView TVLatitudeUM; @@ -58,12 +63,18 @@ public class FragmentGPSFix extends Fragment { private TextView TVAccuracyUM; private TextView TVGPSFixStatus; private TextView TVDirectionUM; + private TextView TVTime; + private TextView TVSatellites; private TableLayout TLCoordinates; private TableLayout TLAltitude; private TableLayout TLSpeed; private TableLayout TLBearing; private TableLayout TLAccuracy; + private TableLayout TLTime; + private TableLayout TLSatellites; + + private LinearLayout LLTimeSatellites; private PhysicalData phdLatitude; private PhysicalData phdLongitude; @@ -71,6 +82,7 @@ public class FragmentGPSFix extends Fragment { private PhysicalData phdSpeed; private PhysicalData phdBearing; private PhysicalData phdAccuracy; + private PhysicalData phdTime; final GPSApplication gpsApplication = GPSApplication.getInstance(); @@ -96,6 +108,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_gpsfix, container, false); + FLGPSFix = (FrameLayout) view.findViewById(R.id.id_fragmentgpsfixFrameLayout); + TVLatitude = (TextView) view.findViewById(R.id.id_textView_Latitude); TVLongitude = (TextView) view.findViewById(R.id.id_textView_Longitude); TVLatitudeUM = (TextView) view.findViewById(R.id.id_textView_LatitudeUM); @@ -109,12 +123,18 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, TVAccuracyUM = (TextView) view.findViewById(R.id.id_textView_AccuracyUM); TVGPSFixStatus = (TextView) view.findViewById(R.id.id_textView_GPSFixStatus); TVDirectionUM = (TextView) view.findViewById(R.id.id_textView_BearingUM); + TVTime = (TextView) view.findViewById(R.id.id_textView_Time); + TVSatellites = (TextView) view.findViewById(R.id.id_textView_Satellites); TLCoordinates = (TableLayout) view.findViewById(R.id.id_TableLayout_Coordinates) ; TLAltitude = (TableLayout) view.findViewById(R.id.id_TableLayout_Altitude); TLSpeed = (TableLayout) view.findViewById(R.id.id_TableLayout_Speed); TLBearing = (TableLayout) view.findViewById(R.id.id_TableLayout_Bearing); TLAccuracy = (TableLayout) view.findViewById(R.id.id_TableLayout_Accuracy); + TLTime = (TableLayout) view.findViewById(R.id.id_TableLayout_Time); + TLSatellites = (TableLayout) view.findViewById(R.id.id_TableLayout_Satellites); + + LLTimeSatellites = (LinearLayout) view.findViewById(R.id.id_linearLayout_Time_Satellites); TVGPSFixStatus.setOnClickListener(new View.OnClickListener() { @Override @@ -173,6 +193,7 @@ public void Update() { phdSpeed = phdformatter.format(location.getSpeed(), PhysicalDataFormatter.FORMAT_SPEED); phdBearing = phdformatter.format(location.getBearing(), PhysicalDataFormatter.FORMAT_BEARING); phdAccuracy = phdformatter.format(location.getAccuracy(), PhysicalDataFormatter.FORMAT_ACCURACY); + phdTime = phdformatter.format(location.getTime(), PhysicalDataFormatter.FORMAT_TIME); TVLatitude.setText(phdLatitude.Value); TVLongitude.setText(phdLongitude.Value); @@ -185,6 +206,8 @@ public void Update() { TVBearing.setText(phdBearing.Value); TVAccuracy.setText(phdAccuracy.Value); TVAccuracyUM.setText(phdAccuracy.UM); + TVTime.setText(phdTime.Value); + TVSatellites.setText(location.getNumberOfSatellitesUsedInFix() != NOT_AVAILABLE ? location.getNumberOfSatellitesUsedInFix() + "/" + location.getNumberOfSatellites() : ""); // Colorize the Altitude textview depending on the altitude EGM Correction isValidAltitude = EGMAltitudeCorrection && (location.getAltitudeEGM96Correction() != NOT_AVAILABLE); @@ -200,6 +223,35 @@ public void Update() { TLSpeed.setVisibility(phdSpeed.Value.equals("") ? View.INVISIBLE : View.VISIBLE); TLBearing.setVisibility(phdBearing.Value.equals("") ? View.INVISIBLE : View.VISIBLE); TLAccuracy.setVisibility(phdAccuracy.Value.equals("") ? View.INVISIBLE : View.VISIBLE); + TLTime.setVisibility(View.VISIBLE); + TLSatellites.setVisibility(location.getNumberOfSatellitesUsedInFix() == NOT_AVAILABLE ? View.INVISIBLE : View.VISIBLE); + + FLGPSFix.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, + int oldLeft, int oldTop, int oldRight, int oldBottom) { + FLGPSFix.removeOnLayoutChangeListener(this); + + int ViewHeight = TLTime.getMeasuredHeight() + (int)(6*getResources().getDisplayMetrics().density); + int LayoutHeight = FLGPSFix.getHeight() - (int)(6*getResources().getDisplayMetrics().density); + //Log.w("myApp", "[#]"); + //Log.w("myApp", "[#] -----------------------------------"); + boolean isTimeAndSatellitesVisible; + if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){ + isTimeAndSatellitesVisible = LayoutHeight >= 6*ViewHeight; + //Log.w("myApp", "[#] " + LayoutHeight + " / " + 6*ViewHeight + " -> " + isTimeAndSatellitesVisible); + } else { + isTimeAndSatellitesVisible = LayoutHeight >= 4*ViewHeight; + //Log.w("myApp", "[#] " + LayoutHeight + " / " + 4*ViewHeight + " -> " + isTimeAndSatellitesVisible); + } + LLTimeSatellites.setVisibility(isTimeAndSatellitesVisible ? View.VISIBLE : View.GONE); + + //Log.w("myApp", "[#] -----------------------------------"); + //Log.w("myApp", "[#] Available Height = " + LayoutHeight + " px"); + //Log.w("myApp", "[#] Density = " + getResources().getDisplayMetrics().density); + //Log.w("myApp", "[#] Tile Height = " + ViewHeight + " px"); + } + }); } else { TLCoordinates.setVisibility(View.INVISIBLE); @@ -207,6 +259,8 @@ public void Update() { TLSpeed.setVisibility(View.INVISIBLE); TLBearing.setVisibility(View.INVISIBLE); TLAccuracy.setVisibility(View.INVISIBLE); + TLTime.setVisibility(View.INVISIBLE); + TLSatellites.setVisibility(View.INVISIBLE); TVGPSFixStatus.setVisibility(View.VISIBLE); switch (GPSStatus) { diff --git a/app/src/main/java/eu/basicairdata/graziano/gpslogger/PhysicalDataFormatter.java b/app/src/main/java/eu/basicairdata/graziano/gpslogger/PhysicalDataFormatter.java index 174ba7cd..72f8e24e 100644 --- a/app/src/main/java/eu/basicairdata/graziano/gpslogger/PhysicalDataFormatter.java +++ b/app/src/main/java/eu/basicairdata/graziano/gpslogger/PhysicalDataFormatter.java @@ -20,6 +20,9 @@ import android.location.Location; +import java.text.SimpleDateFormat; +import java.util.TimeZone; + class PhysicalDataFormatter { private final int NOT_AVAILABLE = -100000; @@ -40,7 +43,8 @@ class PhysicalDataFormatter { static final byte FORMAT_DURATION = 7; static final byte FORMAT_SPEED_AVG = 8; static final byte FORMAT_DISTANCE = 9; - + static final byte FORMAT_TIME = 10; + private final float M_TO_FT = 3.280839895f; private final float M_TO_NM = 0.000539957f; private final float MS_TO_MPH = 2.2369363f; @@ -257,6 +261,12 @@ public PhysicalData format(long Number, byte Format) { } _PhysicalData.Value = hours.equals("00") ? minutes + ":" + seconds : hours + ":" + minutes + ":" + seconds; return(_PhysicalData); + + case FORMAT_TIME: // Timestamps + SimpleDateFormat dfdTime = new SimpleDateFormat("HH:mm:ss"); // date and time formatter + dfdTime.setTimeZone(TimeZone.getTimeZone("GMT")); + _PhysicalData.Value = dfdTime.format(Number); + return(_PhysicalData); } return(_PhysicalData); } diff --git a/app/src/main/res/layout-land/fragment_gpsfix.xml b/app/src/main/res/layout-land/fragment_gpsfix.xml index 997cf380..ebe7984c 100644 --- a/app/src/main/res/layout-land/fragment_gpsfix.xml +++ b/app/src/main/res/layout-land/fragment_gpsfix.xml @@ -34,13 +34,18 @@ android:paddingTop="6dp" android:weightSum="4"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_weight="1" + android:id="@+id/id_TableLayout_Latitude" + android:paddingTop="3dp" + android:paddingBottom="3dp" + android:layout_marginBottom="6dp"> - - - - - - - - + android:layout_gravity="center_horizontal" + android:gravity="center_horizontal"> - + + + + + + + + + + - + android:textAppearance="@style/TextAppearanceLargeNumbers" + android:id="@+id/id_textView_Longitude" + android:freezesText="true" + android:textColor="@color/colorPrimaryLight" + android:textStyle="bold" + android:gravity="center_horizontal" /> - + android:textAppearance="@style/TextAppearanceLargeUM" + android:id="@+id/id_textView_LongitudeUM" + android:layout_weight="0" + android:layout_marginLeft="7dp" + android:layout_marginStart="7dp" /> + + + + + + + + + + + + + + + + + - + + + - + + - + +