Skip to content

Commit

Permalink
Closes #45 - Added the UTC Time and Satellites tiles to GPS FIX tab
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Dec 21, 2019
1 parent 93e8cb4 commit 8148e2a
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 75 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 28
versionName '2.2.5b_20191005'
versionName '2.2.5b_20191220'
}
buildTypes {
debug {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -58,19 +63,26 @@ 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;
private PhysicalData phdAltitude;
private PhysicalData phdSpeed;
private PhysicalData phdBearing;
private PhysicalData phdAccuracy;
private PhysicalData phdTime;

final GPSApplication gpsApplication = GPSApplication.getInstance();

Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -200,13 +223,44 @@ 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);
TLAltitude.setVisibility(View.INVISIBLE);
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import android.location.Location;

import java.text.SimpleDateFormat;
import java.util.TimeZone;

class PhysicalDataFormatter {

private final int NOT_AVAILABLE = -100000;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
95 changes: 93 additions & 2 deletions app/src/main/res/layout-land/fragment_gpsfix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
android:paddingTop="6dp"
android:weightSum="4">

<TableLayout
<LinearLayout
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"
android:orientation="vertical">

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner_dark"
android:layout_margin="3dp"
android:id="@+id/id_TableLayout_Coordinates"
android:layout_weight="2"
android:visibility="invisible">

<TableLayout
Expand Down Expand Up @@ -134,6 +139,92 @@
</TableLayout>

</TableLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/id_linearLayout_Time_Satellites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:weightSum="2">

<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/id_TableLayout_Time"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:background="@drawable/rounded_corner_dark"
android:layout_margin="3dp"
android:visibility="invisible">

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearanceLargeNumbers"
android:id="@+id/id_textView_Time"
android:freezesText="true"
android:textStyle="bold"
android:gravity="center_horizontal" />
</TableRow>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/time"
android:id="@+id/id_textView_TimeLabel"
android:textSize="13sp"
android:gravity="center_horizontal" />

</TableLayout>

<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/id_TableLayout_Satellites"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:layout_margin="3dp"
android:background="@drawable/rounded_corner_dark"
android:visibility="invisible">

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearanceLargeNumbers"
android:id="@+id/id_textView_Satellites"
android:freezesText="true"
android:textStyle="bold"
android:gravity="center_horizontal" />
</TableRow>

<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/satellites"
android:id="@+id/id_textView_SatellitesLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:gravity="center_horizontal" />

</TableLayout>
</LinearLayout>

</LinearLayout>

<LinearLayout
android:orientation="vertical"
Expand Down
Loading

0 comments on commit 8148e2a

Please sign in to comment.