Changeset 93


Ignore:
Timestamp:
08/24/07 22:05:08 (6 years ago)
Author:
saua
Message:

Implement details screen (issue #18)

Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • bbtracker/trunk/src/org/bbtracker/mobile/Preferences.java

    r79 r93  
    9393        private int statusFontSize = Font.SIZE_MEDIUM; 
    9494 
     95        private int detailsFontSize = Font.SIZE_LARGE; 
     96 
    9597        private String trackDirectory; 
    9698 
     
    182184        } 
    183185 
     186        public int getDetailsFontSize() { 
     187                return detailsFontSize; 
     188        } 
     189 
     190        public void setDetailsFontSize(final int detailsFontSize) { 
     191                this.detailsFontSize = detailsFontSize; 
     192        } 
     193 
    184194        public int getNextTrackNumber() { 
    185195                return trackNumber++; 
     
    207217                        final DataInputStream in = new DataInputStream(new ByteArrayInputStream(data)); 
    208218 
    209                         startAction = in.readShort(); 
    210                         sampleInterval = in.readInt(); 
    211                         trackNumber = in.readInt(); 
    212                         if (in.readByte() != 0) { 
    213                                 trackDirectory = in.readUTF(); 
    214                         } else { 
    215                                 trackDirectory = null; 
    216                         } 
    217                         exportFormats = in.readInt(); 
    218                         units = in.readInt(); 
    219                         statusFontSize = in.readInt(); 
    220  
    221                         in.close(); 
     219                        try { 
     220                                startAction = in.readShort(); 
     221                                sampleInterval = in.readInt(); 
     222                                trackNumber = in.readInt(); 
     223                                if (in.readByte() != 0) { 
     224                                        trackDirectory = in.readUTF(); 
     225                                } else { 
     226                                        trackDirectory = null; 
     227                                } 
     228                                exportFormats = in.readInt(); 
     229                                units = in.readInt(); 
     230                                statusFontSize = in.readInt(); 
     231                                detailsFontSize = in.readInt(); 
     232                        } finally { 
     233                                try { 
     234                                        in.close(); 
     235                                } catch (final IOException ignored) { 
     236                                        // ignore 
     237                                } 
     238                        } 
     239 
    222240                } catch (final RecordStoreNotFoundException e) { 
    223241                        // ignore, don't load anything, but show options screen 
     
    260278                        out.writeInt(units); 
    261279                        out.writeInt(statusFontSize); 
     280                        out.writeInt(detailsFontSize); 
    262281 
    263282                        out.close(); 
  • bbtracker/trunk/src/org/bbtracker/mobile/gui/MainCanvas.java

    r89 r93  
    5252        private final StatusTile statusTile; 
    5353 
     54        private final Tile detailsTile; 
     55 
    5456        private final Command newTrackCommand; 
    5557 
     
    7981                speedProfileTile = new SpeedPlotterTile(manager, DataProvider.TIME); 
    8082                statusTile = new StatusTile(manager); 
     83                detailsTile = new DetailsTile(manager); 
    8184 
    8285                switchViewCommand = new Command("Switch View", Command.SCREEN, 0); 
     
    9497                addCommand(aboutCommand); 
    9598                addCommand(exitCommand); 
     99 
    96100                setCommandListener(this); 
    97101 
     
    101105        protected void setMainTile(final Tile mainTile, final boolean withStatus) { 
    102106                visibleTiles[0] = mainTile; 
    103                 if (withStatus) { 
     107                if (withStatus == true) { 
    104108                        visibleTiles[1] = statusTile; 
    105109                } else { 
     
    200204 
    201205        private void nextTileConfiguration() { 
    202                 tileConfiguration = (tileConfiguration + 1) % 3; 
     206                tileConfiguration = (tileConfiguration + 1) % 4; 
    203207                switch (tileConfiguration) { 
    204208                case 0: 
     
    213217                        setMainTile(speedProfileTile, true); 
    214218                        setStatusMessage("Speed over time"); 
     219                        break; 
     220                case 3: 
     221                        setMainTile(detailsTile, false); 
     222                        setStatusMessage("Details"); 
    215223                        break; 
    216224                } 
  • bbtracker/trunk/src/org/bbtracker/mobile/gui/OptionsForm.java

    r88 r93  
    4242 
    4343public class OptionsForm extends Form implements CommandListener, ItemCommandListener { 
     44        private static final String[] FONT_SIZE_NAMES = new String[] { "Small", "Medium", "Large" }; 
     45 
    4446        private final TrackManager trackManager; 
    4547 
     
    6163 
    6264        private final ChoiceGroup statusFontSizeGroup; 
     65 
     66        private final ChoiceGroup detailsFontSizeGroup; 
    6367 
    6468        public OptionsForm(final TrackManager trackManager) { 
     
    7579                unitsGroup.setSelectedIndex(pref.getUnits(), true); 
    7680 
    77                 statusFontSizeGroup = new ChoiceGroup("Status text size: ", Choice.POPUP, new String[] { "Small", "Medium", 
    78                                 "Large" }, null); 
    79                 int selectedFontSizeItem; 
    80                 switch (pref.getStatusFontSize()) { 
    81                 case Font.SIZE_SMALL: 
    82                         selectedFontSizeItem = 0; 
    83                         break; 
    84                 case Font.SIZE_MEDIUM: 
    85                         selectedFontSizeItem = 1; 
    86                         break; 
    87                 case Font.SIZE_LARGE: 
    88                         selectedFontSizeItem = 2; 
    89                         break; 
    90                 default: 
    91                         selectedFontSizeItem = 1; 
    92                 } 
    93                 statusFontSizeGroup.setSelectedIndex(selectedFontSizeItem, true); 
     81                statusFontSizeGroup = new ChoiceGroup("Status text size: ", Choice.POPUP, FONT_SIZE_NAMES, null); 
     82                final int statusFontSizeIndex = getSelectedFontIndex(pref.getStatusFontSize()); 
     83                statusFontSizeGroup.setSelectedIndex(statusFontSizeIndex, true); 
     84 
     85                detailsFontSizeGroup = new ChoiceGroup("Details text size: ", Choice.POPUP, FONT_SIZE_NAMES, null); 
     86                final int detailsFontSizeIndex = getSelectedFontIndex(pref.getDetailsFontSize()); 
     87                detailsFontSizeGroup.setSelectedIndex(detailsFontSizeIndex, true); 
    9488 
    9589                startTypeGroup = new ChoiceGroup("Startup action: ", Choice.POPUP, Preferences.START_ACTIONS, null); 
     
    113107                append(unitsGroup); 
    114108                append(statusFontSizeGroup); 
     109                append(detailsFontSizeGroup); 
    115110                append(startTypeGroup); 
    116111                append(directoryField); 
     
    123118                addCommand(cancelCommand); 
    124119                setCommandListener(this); 
     120        } 
     121 
     122        private int getSelectedFontIndex(final int fontSize) { 
     123                int selectedIndex; 
     124                switch (fontSize) { 
     125                case Font.SIZE_SMALL: 
     126                        selectedIndex = 0; 
     127                        break; 
     128                case Font.SIZE_MEDIUM: 
     129                        selectedIndex = 1; 
     130                        break; 
     131                case Font.SIZE_LARGE: 
     132                        selectedIndex = 2; 
     133                        break; 
     134                default: 
     135                        selectedIndex = 1; 
     136                } 
     137                return selectedIndex; 
     138        } 
     139 
     140        private int getFontSize(final int selectedIndex) { 
     141                int fontSize; 
     142                switch (selectedIndex) { 
     143                case 0: 
     144                        fontSize = Font.SIZE_SMALL; 
     145                        break; 
     146                case 1: 
     147                        fontSize = Font.SIZE_MEDIUM; 
     148                        break; 
     149                case 2: 
     150                        fontSize = Font.SIZE_LARGE; 
     151                        break; 
     152                default: 
     153                        throw new IllegalStateException(); 
     154                } 
     155                return fontSize; 
    125156        } 
    126157 
     
    206237                        pref.setUnits(unitsGroup.getSelectedIndex()); 
    207238 
    208                         final int newFontSize; 
    209                         switch (statusFontSizeGroup.getSelectedIndex()) { 
    210                         case 0: 
    211                                 newFontSize = Font.SIZE_SMALL; 
    212                                 break; 
    213                         case 1: 
    214                                 newFontSize = Font.SIZE_MEDIUM; 
    215                                 break; 
    216                         case 2: 
    217                                 newFontSize = Font.SIZE_LARGE; 
    218                                 break; 
    219                         default: 
    220                                 throw new IllegalStateException(); 
    221                         } 
    222                         pref.setStatusFontSize(newFontSize); 
     239                        final int statusFontSize = getFontSize(statusFontSizeGroup.getSelectedIndex()); 
     240                        pref.setStatusFontSize(statusFontSize); 
     241 
     242                        final int detailsFontSize = getFontSize(detailsFontSizeGroup.getSelectedIndex()); 
     243                        pref.setDetailsFontSize(detailsFontSize); 
    223244 
    224245                        pref.store(); 
  • bbtracker_common/trunk/src/org/bbtracker/Track.java

    r72 r93  
    9696        } 
    9797 
     98        public long getPointOffset(final TrackPoint point) { 
     99                if (getPointCount() == 0) { 
     100                        throw new IllegalStateException("No points yet, can't calculate point offset."); 
     101                } 
     102                return point.getTimestamp() - getPoint(0).getTimestamp(); 
     103        } 
     104 
    98105        public int getSegmentCount() { 
    99106                return segments.size(); 
  • bbtracker_common/trunk/src/org/bbtracker/Utils.java

    r61 r93  
    242242                return result.toString(); 
    243243        } 
     244 
     245        public static String durationToString(final long msec) { 
     246                // i do hope no one uses bbTracker do record tracks that 
     247                // are longer than Integer.MAX_VALUE seconds. 
     248                final StringBuffer sb = new StringBuffer(8); 
     249                int sec = (int) (msec / 1000); 
     250                if (sec > 60 * 60) { 
     251                        final int hours = sec / (60 * 60); 
     252                        sb.append(hours); 
     253                        sec -= hours * (60 * 60); 
     254                        sb.append(':'); 
     255                } 
     256 
     257                final int minutes = sec / 60; 
     258                if (sb.length() > 0) { 
     259                        appendTwoDigits(sb, minutes, '0'); 
     260                } else { 
     261                        sb.append(minutes); 
     262                } 
     263                sb.append(':'); 
     264 
     265                appendTwoDigits(sb, sec, '0'); 
     266 
     267                return sb.toString(); 
     268        } 
    244269} 
Note: See TracChangeset for help on using the changeset viewer.