Changeset 93
- Timestamp:
- 08/24/07 22:05:08 (4 years ago)
- Files:
-
- 1 added
- 5 edited
-
bbtracker/trunk/src/org/bbtracker/mobile/Preferences.java (modified) (4 diffs)
-
bbtracker/trunk/src/org/bbtracker/mobile/gui/DetailsTile.java (added)
-
bbtracker/trunk/src/org/bbtracker/mobile/gui/MainCanvas.java (modified) (6 diffs)
-
bbtracker/trunk/src/org/bbtracker/mobile/gui/OptionsForm.java (modified) (6 diffs)
-
bbtracker_common/trunk/src/org/bbtracker/Track.java (modified) (1 diff)
-
bbtracker_common/trunk/src/org/bbtracker/Utils.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bbtracker/trunk/src/org/bbtracker/mobile/Preferences.java
r79 r93 93 93 private int statusFontSize = Font.SIZE_MEDIUM; 94 94 95 private int detailsFontSize = Font.SIZE_LARGE; 96 95 97 private String trackDirectory; 96 98 … … 182 184 } 183 185 186 public int getDetailsFontSize() { 187 return detailsFontSize; 188 } 189 190 public void setDetailsFontSize(final int detailsFontSize) { 191 this.detailsFontSize = detailsFontSize; 192 } 193 184 194 public int getNextTrackNumber() { 185 195 return trackNumber++; … … 207 217 final DataInputStream in = new DataInputStream(new ByteArrayInputStream(data)); 208 218 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 222 240 } catch (final RecordStoreNotFoundException e) { 223 241 // ignore, don't load anything, but show options screen … … 260 278 out.writeInt(units); 261 279 out.writeInt(statusFontSize); 280 out.writeInt(detailsFontSize); 262 281 263 282 out.close(); -
bbtracker/trunk/src/org/bbtracker/mobile/gui/MainCanvas.java
r89 r93 52 52 private final StatusTile statusTile; 53 53 54 private final Tile detailsTile; 55 54 56 private final Command newTrackCommand; 55 57 … … 79 81 speedProfileTile = new SpeedPlotterTile(manager, DataProvider.TIME); 80 82 statusTile = new StatusTile(manager); 83 detailsTile = new DetailsTile(manager); 81 84 82 85 switchViewCommand = new Command("Switch View", Command.SCREEN, 0); … … 94 97 addCommand(aboutCommand); 95 98 addCommand(exitCommand); 99 96 100 setCommandListener(this); 97 101 … … 101 105 protected void setMainTile(final Tile mainTile, final boolean withStatus) { 102 106 visibleTiles[0] = mainTile; 103 if (withStatus ) {107 if (withStatus == true) { 104 108 visibleTiles[1] = statusTile; 105 109 } else { … … 200 204 201 205 private void nextTileConfiguration() { 202 tileConfiguration = (tileConfiguration + 1) % 3;206 tileConfiguration = (tileConfiguration + 1) % 4; 203 207 switch (tileConfiguration) { 204 208 case 0: … … 213 217 setMainTile(speedProfileTile, true); 214 218 setStatusMessage("Speed over time"); 219 break; 220 case 3: 221 setMainTile(detailsTile, false); 222 setStatusMessage("Details"); 215 223 break; 216 224 } -
bbtracker/trunk/src/org/bbtracker/mobile/gui/OptionsForm.java
r88 r93 42 42 43 43 public class OptionsForm extends Form implements CommandListener, ItemCommandListener { 44 private static final String[] FONT_SIZE_NAMES = new String[] { "Small", "Medium", "Large" }; 45 44 46 private final TrackManager trackManager; 45 47 … … 61 63 62 64 private final ChoiceGroup statusFontSizeGroup; 65 66 private final ChoiceGroup detailsFontSizeGroup; 63 67 64 68 public OptionsForm(final TrackManager trackManager) { … … 75 79 unitsGroup.setSelectedIndex(pref.getUnits(), true); 76 80 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); 94 88 95 89 startTypeGroup = new ChoiceGroup("Startup action: ", Choice.POPUP, Preferences.START_ACTIONS, null); … … 113 107 append(unitsGroup); 114 108 append(statusFontSizeGroup); 109 append(detailsFontSizeGroup); 115 110 append(startTypeGroup); 116 111 append(directoryField); … … 123 118 addCommand(cancelCommand); 124 119 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; 125 156 } 126 157 … … 206 237 pref.setUnits(unitsGroup.getSelectedIndex()); 207 238 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); 223 244 224 245 pref.store(); -
bbtracker_common/trunk/src/org/bbtracker/Track.java
r72 r93 96 96 } 97 97 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 98 105 public int getSegmentCount() { 99 106 return segments.size(); -
bbtracker_common/trunk/src/org/bbtracker/Utils.java
r61 r93 242 242 return result.toString(); 243 243 } 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 } 244 269 }
Note: See TracChangeset
for help on using the changeset viewer.