altosdroid: Define strings for the tab names
authorKeith Packard <keithp@keithp.com>
Wed, 24 Jun 2015 04:37:25 +0000 (21:37 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 24 Jun 2015 04:42:35 +0000 (21:42 -0700)
Use these everywhere instead of replicating the same name; might
reduce errors.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
altosdroid/src/org/altusmetrum/AltosDroid/TabFlight.java
altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
altosdroid/src/org/altusmetrum/AltosDroid/TabRecover.java

index f1da27d..c2a6cb2 100644 (file)
@@ -87,6 +87,11 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
        private int mAgeNewColor;
        private int mAgeOldColor;
 
+       public static final String      tab_pad_name = "pad";
+       public static final String      tab_flight_name = "flight";
+       public static final String      tab_recover_name = "recover";
+       public static final String      tab_map_name = "map";
+
        // field to display the version at the bottom of the screen
        private TextView mVersion;
 
@@ -399,9 +404,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
                                if (prev_locked != locked) {
                                        String currentTab = mTabHost.getCurrentTabTag();
                                        if (locked) {
-                                               if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("flight");
+                                               if (currentTab.equals(tab_pad_name)) mTabHost.setCurrentTabByTag(tab_flight_name);
                                        } else {
-                                               if (currentTab.equals("flight")) mTabHost.setCurrentTabByTag("pad");
+                                               if (currentTab.equals(tab_flight_name)) mTabHost.setCurrentTabByTag(tab_pad_name);
                                        }
                                }
                        } else {
@@ -409,13 +414,13 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
                                        String currentTab = mTabHost.getCurrentTabTag();
                                        switch (state.state) {
                                        case AltosLib.ao_flight_boost:
-                                               if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("flight");
+                                               if (currentTab.equals(tab_pad_name)) mTabHost.setCurrentTabByTag(tab_flight_name);
                                                break;
                                        case AltosLib.ao_flight_landed:
-                                               if (currentTab.equals("flight")) mTabHost.setCurrentTabByTag("recover");
+                                               if (currentTab.equals(tab_flight_name)) mTabHost.setCurrentTabByTag(tab_recover_name);
                                                break;
                                        case AltosLib.ao_flight_stateless:
-                                               if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("flight");
+                                               if (currentTab.equals(tab_pad_name)) mTabHost.setCurrentTabByTag(tab_flight_name);
                                                break;
                                        }
                                }
@@ -535,10 +540,10 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
 
                mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
 
-               mTabsAdapter.addTab(mTabHost.newTabSpec("pad").setIndicator(create_tab_view("Pad")), TabPad.class, null);
-               mTabsAdapter.addTab(mTabHost.newTabSpec("flight").setIndicator(create_tab_view("Flight")), TabFlight.class, null);
-               mTabsAdapter.addTab(mTabHost.newTabSpec("recover").setIndicator(create_tab_view("Recover")), TabRecover.class, null);
-               mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator(create_tab_view("Map")), TabMap.class, null);
+               mTabsAdapter.addTab(mTabHost.newTabSpec(tab_pad_name).setIndicator(create_tab_view("Pad")), TabPad.class, null);
+               mTabsAdapter.addTab(mTabHost.newTabSpec(tab_flight_name).setIndicator(create_tab_view("Flight")), TabFlight.class, null);
+               mTabsAdapter.addTab(mTabHost.newTabSpec(tab_recover_name).setIndicator(create_tab_view("Recover")), TabRecover.class, null);
+               mTabsAdapter.addTab(mTabHost.newTabSpec(tab_map_name).setIndicator(create_tab_view("Map")), TabMap.class, null);
 
                // Display the Version
                mVersion = (TextView) findViewById(R.id.version);
index e1fc737..e0d49a1 100644 (file)
@@ -79,7 +79,7 @@ public class TabFlight extends AltosDroidTab {
                return v;
        }
 
-       public String tab_name() { return "flight"; }
+       public String tab_name() { return AltosDroid.tab_flight_name; }
 
        public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
                if (state != null) {
index cd59dfe..0ee202a 100644 (file)
@@ -88,7 +88,7 @@ public class TabMap extends AltosDroidTab {
                super.onDestroyView();
        }
 
-       public String tab_name() { return "map"; }
+       public String tab_name() { return AltosDroid.tab_map_name; }
 
        private void center(double lat, double lon, double accuracy) {
                if (map_offline != null)
index 92bb901..cfc5526 100644 (file)
@@ -105,7 +105,7 @@ public class TabPad extends AltosDroidTab {
         return v;
        }
 
-       public String tab_name() { return "pad"; }
+       public String tab_name() { return AltosDroid.tab_pad_name; }
 
        public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
                if (state != null) {
index cb394db..523ddb6 100644 (file)
@@ -58,7 +58,7 @@ public class TabRecover extends AltosDroidTab {
                return v;
        }
 
-       public String tab_name() { return "recover"; }
+       public String tab_name() { return AltosDroid.tab_recover_name; }
 
        public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
                if (from_receiver != null) {