X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FAltosDroid.java;h=e10982f7cc8873832c99fa21e2937c260deab64f;hp=5ce6f81069eae5bb7222f9d4c447ce211d8b28e1;hb=cc674d8f991a3a055236ad8b51fecd99080540e1;hpb=6592a5be127a9c95d3b2e7d5aa6ffba71c6748b9 diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 5ce6f810..e10982f7 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -37,7 +37,7 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.FragmentActivity; -import android.support.v4.view.ViewPager; +import android.util.DisplayMetrics; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -82,10 +82,11 @@ public class AltosDroid extends FragmentActivity { private TextView mVersion; // Tabs - TabHost mTabHost; - AltosViewPager mViewPager; - TabsAdapter mTabsAdapter; + TabHost mTabHost; + AltosViewPager mViewPager; + TabsAdapter mTabsAdapter; ArrayList mTabs = new ArrayList(); + int tabHeight; // Timer and Saved flight state for Age calculation private Timer timer = new Timer(); @@ -265,6 +266,8 @@ public class AltosDroid extends FragmentActivity { static String pos(double p, String pos, String neg) { String h = pos; + if (p == AltosRecord.MISSING) + return ""; if (p < 0) { h = neg; p = -p; @@ -274,6 +277,18 @@ public class AltosDroid extends FragmentActivity { return String.format("%d°%9.4f\" %s", deg, min, h); } + static String number(String format, double value) { + if (value == AltosRecord.MISSING) + return ""; + return String.format(format, value); + } + + static String integer(String format, int value) { + if (value == AltosRecord.MISSING) + return ""; + return String.format(format, value); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -298,6 +313,7 @@ public class AltosDroid extends FragmentActivity { setContentView(R.layout.altosdroid); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); + // Create the Tabs and ViewPager mTabHost = (TabHost)findViewById(android.R.id.tabhost); mTabHost.setup(); @@ -312,8 +328,27 @@ 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); + + // Scale the size of the Tab bar for different screen densities + // This probably won't be needed when we start supporting ICS+ tabs. + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + int density = metrics.densityDpi; + + if (density==DisplayMetrics.DENSITY_XHIGH) + tabHeight = 65; + else if (density==DisplayMetrics.DENSITY_HIGH) + tabHeight = 45; + else if (density==DisplayMetrics.DENSITY_MEDIUM) + tabHeight = 35; + else if (density==DisplayMetrics.DENSITY_LOW) + tabHeight = 25; + else + tabHeight = 65; + for (int i = 0; i < 5; i++) - mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 45; + mTabHost.getTabWidget().getChildAt(i).getLayoutParams().height = tabHeight; + // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text); @@ -379,7 +414,7 @@ public class AltosDroid extends FragmentActivity { super.onDestroy(); if(D) Log.e(TAG, "--- ON DESTROY ---"); - mAltosVoice.stop(); + if (mAltosVoice != null) mAltosVoice.stop(); } public void onActivityResult(int requestCode, int resultCode, Intent data) {