X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosDroid.java;h=5ce6f81069eae5bb7222f9d4c447ce211d8b28e1;hb=3cd8ff18a7546c1e251747ba26240cb130003ef1;hp=b1d080dbb9d67aee5eb986d1e3e4b4d894dab943;hpb=9212ce268f3a4a9f3f019f23f6eef8b57207d340;p=fw%2Faltos diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index b1d080db..5ce6f810 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -126,7 +126,6 @@ public class AltosDroid extends FragmentActivity { ad.mTitle.setText(R.string.title_connected_to); ad.mTitle.append(str); Toast.makeText(ad.getApplicationContext(), "Connected to " + str, Toast.LENGTH_SHORT).show(); - ad.mAltosVoice.speak("Connected"); break; case TelemetryService.STATE_CONNECTING: ad.mTitle.setText(R.string.title_connecting); @@ -206,13 +205,11 @@ public class AltosDroid extends FragmentActivity { void set_location(Location location) { saved_location = location; - if (saved_state != null) { - update_ui(saved_state); - } + update_ui(saved_state); } void update_ui(AltosState state) { - if (saved_state != null) { + if (state != null && saved_state != null) { if (saved_state.state != state.state) { String currentTab = mTabHost.getCurrentTabTag(); switch (state.state) { @@ -232,25 +229,31 @@ public class AltosDroid extends FragmentActivity { AltosGreatCircle from_receiver = null; - if (saved_location != null && state.gps != null && state.gps.locked) { + if (state != null && saved_location != null && state.gps != null && state.gps.locked) { + double altitude = 0; + if (saved_location.hasAltitude()) + altitude = saved_location.getAltitude(); from_receiver = new AltosGreatCircle(saved_location.getLatitude(), saved_location.getLongitude(), - saved_location.getAltitude(), + altitude, state.gps.lat, state.gps.lon, state.gps.alt); } - mCallsignView.setText(state.data.callsign); - mSerialView.setText(String.format("%d", state.data.serial)); - mFlightView.setText(String.format("%d", state.data.flight)); - mStateView.setText(state.data.state()); - mRSSIView.setText(String.format("%d", state.data.rssi)); + if (state != null) { + mCallsignView.setText(state.data.callsign); + mSerialView.setText(String.format("%d", state.data.serial)); + mFlightView.setText(String.format("%d", state.data.flight)); + mStateView.setText(state.data.state()); + mRSSIView.setText(String.format("%d", state.data.rssi)); + } for (AltosDroidTab mTab : mTabs) - mTab.update_ui(state, from_receiver); + mTab.update_ui(state, from_receiver, saved_location); - mAltosVoice.tell(state); + if (state != null) + mAltosVoice.tell(state); } private void onTimerTick() { @@ -268,7 +271,7 @@ public class AltosDroid extends FragmentActivity { } int deg = (int) Math.floor(p); double min = (p - Math.floor(p)) * 60.0; - return String.format("%d° %9.6f\" %s", deg, min, h); + return String.format("%d°%9.4f\" %s", deg, min, h); } @Override @@ -309,6 +312,8 @@ public class AltosDroid extends FragmentActivity { mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator("Landed"), TabLanded.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator("Map"), TabMap.class, null); + for (int i = 0; i < 5; i++) + mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 45; // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text);