Skip to content

Commit

Permalink
Adds the current altitude to the location view
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Nov 20, 2023
1 parent eb81b63 commit 4b8f1dc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ private void initializeLocationTextView()
private void updateLocationTextView(Location latestLocation)
{
final TextView locationTextView = binding.locationCard.location;
final TextView altitudeTextView = binding.locationCard.altitude;
final TextView accuracyTextView = binding.locationCard.accuracy;
if (latestLocation != null)
{
Expand All @@ -595,12 +596,16 @@ private void updateLocationTextView(Location latestLocation)
locationTextView.setText(latLonString);
locationTextView.setTextColor(getResources().getColor(R.color.normalText, null));

altitudeTextView.setText(getString(R.string.altitude_value, Long.toString(Math.round(latestLocation.getAltitude()))));

accuracyTextView.setText(getString(R.string.accuracy_value, Integer.toString(MathUtils.roundAccuracy(latestLocation.getAccuracy()))));
} else
{
locationTextView.setText(R.string.low_gps_confidence);
locationTextView.setTextColor(Color.YELLOW);

altitudeTextView.setText(getString(R.string.altitude_initial));

accuracyTextView.setText(getString(R.string.accuracy_initial));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.navigation.fragment.NavHostFragment;

import com.craxiom.messaging.CdmaRecord;
import com.craxiom.messaging.GsmRecord;
import com.craxiom.messaging.GsmRecordData;
import com.craxiom.messaging.LteRecord;
Expand Down Expand Up @@ -143,31 +142,6 @@ protected void onSurveyServiceDisconnecting(NetworkSurveyService service)
service.unregisterCellularSurveyRecordListener(this);
}

@Override
public void onGsmSurveyRecord(GsmRecord gsmRecord)
{
}

@Override
public void onCdmaSurveyRecord(CdmaRecord cdmaRecord)
{
}

@Override
public void onUmtsSurveyRecord(UmtsRecord umtsRecord)
{
}

@Override
public void onLteSurveyRecord(LteRecord lteRecord)
{
}

@Override
public void onNrSurveyRecord(NrRecord nrRecord)
{
}

@Override
public void onCellularBatch(List<CellularRecordWrapper> cellularGroup)
{
Expand Down Expand Up @@ -357,6 +331,7 @@ private void initializeLocationTextView()
private void updateLocationTextView(Location latestLocation)
{
final TextView locationTextView = binding.locationCard.location;
final TextView altitudeTextView = binding.locationCard.altitude;
final TextView accuracyTextView = binding.locationCard.accuracy;
if (latestLocation != null)
{
Expand All @@ -365,12 +340,16 @@ private void updateLocationTextView(Location latestLocation)
locationTextView.setText(latLonString);
locationTextView.setTextColor(getResources().getColor(R.color.normalText, null));

altitudeTextView.setText(getString(R.string.altitude_value, Long.toString(Math.round(latestLocation.getAltitude()))));

accuracyTextView.setText(getString(R.string.accuracy_value, Integer.toString(MathUtils.roundAccuracy(latestLocation.getAccuracy()))));
} else
{
locationTextView.setText(R.string.low_gps_confidence);
locationTextView.setTextColor(Color.YELLOW);

altitudeTextView.setText(getString(R.string.altitude_initial));

accuracyTextView.setText(getString(R.string.accuracy_initial));
}
}
Expand Down
20 changes: 17 additions & 3 deletions networksurvey/src/main/res/layout/location_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
style="@style/CardTitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/card_title_location" />
android:text="@string/card_title_location"
android:textIsSelectable="true" />

</LinearLayout>

Expand All @@ -47,7 +48,19 @@
android:layout_marginStart="@dimen/large_margin"
android:maxLines="1"
android:autoSizeTextType="uniform"
android:text="@string/searching_for_location" />
android:text="@string/searching_for_location"
android:textIsSelectable="true" />

<TextView
android:id="@+id/altitude"
style="@style/StandardText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/large_margin"
android:maxLines="1"
android:autoSizeTextType="uniform"
android:text="@string/altitude_initial"
android:textIsSelectable="true" />

<TextView
android:id="@+id/accuracy"
Expand All @@ -56,7 +69,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/large_margin"
android:layout_marginBottom="@dimen/small_margin"
android:text="@string/accuracy_initial" />
android:text="@string/accuracy_initial"
android:textIsSelectable="true" />

</LinearLayout>

Expand Down
2 changes: 2 additions & 0 deletions networksurvey/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ but work independently, so you have full control over how you handle your data.<
<string name="turn_on_gps">Please turn on GPS</string>
<string name="searching_for_location">Searching for GPS …</string>
<string name="low_gps_confidence">Low GPS Confidence</string>
<string name="altitude_initial">Altitude: </string>
<string name="altitude_value">Altitude: %1$s meters</string>
<string name="accuracy_initial">Accuracy: </string>
<string name="accuracy_value">Accuracy: %1$s meters</string>

Expand Down

0 comments on commit 4b8f1dc

Please sign in to comment.