Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: garthy/MWM-for-Android
base: 40e60c5116
...
head fork: garthy/MWM-for-Android
compare: 8a684ad1ea
Checking mergeability… Don't worry, you can still create the pull request.
  • 10 commits
  • 8 files changed
  • 0 commit comments
  • 2 contributors
View
BIN  assets/moon-inv.bmp
Binary file not shown
View
2  res/layout/test.xml
@@ -31,7 +31,7 @@
<PreferenceCategory android:title="Time">
<Preference android:key="set_rtc" android:title="Set RTC (LCD/OLED)"/>
- <Preference android:key="time_24hr" android:title="Set to 24hr mode (LCD)"/>
+ <Preference android:key="time_24hr" android:title="Set time / date formats (LCD)" android:summary="Set the watch's date and time formats to watch your phone. Note that this may cause the watch to crash on pre 0.9 versions of the firmware."/>
</PreferenceCategory>
<PreferenceCategory android:title="Media Control">
View
10 src/org/metawatch/manager/BootCompletedReceiver.java
@@ -12,11 +12,11 @@
@Override
public void onReceive(Context context, Intent intent)
{
- if(Preferences.autoConnect) {
- context.startService(new Intent(context, MetaWatchService.class));
- if (Preferences.logging) Log.v(MetaWatch.TAG, "Service loaded at start");
- }
-
+ MetaWatchService.loadPreferences(context);
+ if(Preferences.autoConnect) {
+ context.startService(new Intent(context, MetaWatchService.class));
+ if (Preferences.logging) Log.v(MetaWatch.TAG, "Service loaded at start");
+ }
}
}
View
2  src/org/metawatch/manager/MetaWatch.java
@@ -266,7 +266,7 @@ void showAbout() {
"<h1>MetaWatch</h1>" +
"<img src=\"splash.png\">" +
"<p>Version " + Utils.getVersion(this) + ".</p>" +
- "<p>Modified by Dobie Wollert, Chris Sewell, Prash D, Craig Oliver, Richard Munn, Matthias Gruenewald and Kyle Schroeder.</p>" +
+ "<p>Modified by Dobie Wollert, Chris Sewell, Prash D, Craig Oliver, Richard Munn, Matthias Gruenewald, Kyle Schroeder and Garth Bushell.</p>" +
"<p>© Copyright 2011-2012 Meta Watch Ltd.</p>" +
"</center></body></html>";
webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);
View
21 src/org/metawatch/manager/NotificationBuilder.java
@@ -185,7 +185,8 @@ public static void createTimezonechange(Context context) {
public static void createOtherNotification(Context context, String appName, String notificationText) {
VibratePattern vibratePattern = createVibratePatternFromPreference(context, "settingsOtherNotificationNumberBuzzes");
if (MetaWatchService.watchType == WatchType.DIGITAL) {
- Notification.addTextNotification(context, appName + ": " + notificationText, vibratePattern, Notification.getDefaultNotificationTimeout(context));
+ Bitmap bitmap = smartLines(context, null, appName, new String[] {notificationText});
+ Notification.addBitmapNotification(context, bitmap, vibratePattern, Notification.getDefaultNotificationTimeout(context));
} else {
byte[] scroll = new byte[800];
int len = Protocol.createOled2linesLong(context, notificationText, scroll);
@@ -243,12 +244,18 @@ static Bitmap smartLines(Context context, String iconPath, String header, String
canvas.drawColor(Color.WHITE);
- Bitmap icon = Utils.loadBitmapFromAssets(context, iconPath);
-
- canvas.drawBitmap(icon, 0, 0, paint);
- canvas.drawText(header, icon.getWidth()+1, icon.getHeight()-2, paintHead);
+ int iconWidth = 0;
+ int iconHeight = 16;
+ if (iconPath!=null) {
+ Bitmap icon = Utils.loadBitmapFromAssets(context, iconPath);
+ canvas.drawBitmap(icon, 0, 0, paint);
+ iconWidth = icon.getWidth();
+ iconHeight = icon.getHeight();
+ }
+
+ canvas.drawText(header, iconWidth+1, iconHeight-2, paintHead);
- canvas.drawLine(1, icon.getHeight(), 95, icon.getHeight(), paint);
+ canvas.drawLine(1, iconHeight, 95, iconHeight, paint);
String body = "";
for (String line : lines) {
@@ -262,7 +269,7 @@ static Bitmap smartLines(Context context, String iconPath, String header, String
android.text.Layout.Alignment.ALIGN_CENTER, 1.3f, 0, false);
int textHeight = staticLayout.getHeight();
- int headerHeight = icon.getHeight()+2;
+ int headerHeight = iconHeight+2;
int textY = (56) - (textHeight/2);
if (textY < headerHeight)
textY = headerHeight;
View
59 src/org/metawatch/manager/Protocol.java
@@ -303,26 +303,13 @@ public static void sendAdvanceHands() {
public static void sendRtcNow(Context context) {
try {
if (Preferences.logging) Log.d(MetaWatch.TAG, "Protocol.sendRtcNow()");
- boolean isMMDD = true;
- char[] ch = DateFormat.getDateFormatOrder(context);
-
- for (int i = 0; i < ch.length; i++) {
- if (ch[i] == DateFormat.DATE) {
- isMMDD = false;
- break;
- }
- if (ch[i] == DateFormat.MONTH) {
- isMMDD = true;
- break;
- }
- }
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
- byte[] bytes = new byte[14];
+ byte[] bytes = new byte[12];
bytes[0] = eMessageType.start;
bytes[1] = (byte) (bytes.length+2); // length
@@ -337,18 +324,8 @@ public static void sendRtcNow(Context context) {
bytes[9] = (byte) calendar.get(Calendar.HOUR_OF_DAY);
bytes[10] = (byte) calendar.get(Calendar.MINUTE);
bytes[11] = (byte) calendar.get(Calendar.SECOND);
- if (DateFormat.is24HourFormat(context))
- bytes[12] = (byte) 1; // 24hr
- else
- bytes[12] = (byte) 0; // 12hr
- if (isMMDD)
- bytes[13] = (byte) 0; // mm/dd
- else
- bytes[13] = (byte) 1; // dd/mm
-
- //send(bytes);
+
enqueue(bytes);
- //processSendQueue();
} catch (Exception x) {
}
@@ -671,7 +648,7 @@ public static void queryNvalTime() {
enqueue(bytes);
}
- public static void setNvalTime(Context context) {
+ public static void setTimeDateFormat(Context context) {
// Set the watch to 12h or 24h mode, depending on watch setting
if (DateFormat.is24HourFormat(context)) {
Protocol.setNvalTime(true);
@@ -681,6 +658,16 @@ public static void setNvalTime(Context context) {
Protocol.setNvalTime(false);
if (Preferences.logging) Log.d(MetaWatch.TAG, "Setting watch to 12h format");
}
+
+ char[] order = DateFormat.getDateFormatOrder(context);
+ if (order[0] == DateFormat.DATE) {
+ Protocol.setNvalDate(true);
+ if (Preferences.logging) Log.d(MetaWatch.TAG, "Setting watch to ddmm format");
+ }
+ else {
+ Protocol.setNvalDate(false);
+ if (Preferences.logging) Log.d(MetaWatch.TAG, "Setting watch to mmdd format");
+ }
}
public static void setNvalTime(boolean militaryTime) {
@@ -703,6 +690,26 @@ public static void setNvalTime(boolean militaryTime) {
enqueue(bytes);
}
+ public static void setNvalDate(boolean dayFirst) {
+ if (Preferences.logging) Log.d(MetaWatch.TAG, "Protocol.setNvalDate()");
+ byte[] bytes = new byte[8];
+
+ bytes[0] = eMessageType.start;
+ bytes[1] = (byte) (bytes.length+2); // length
+ bytes[2] = eMessageType.NvalOperationMsg.msg; // nval operations
+ bytes[3] = 0x02; // write
+
+ bytes[4] = 0x0a;
+ bytes[5] = 0x20;
+ bytes[6] = 0x01; // size
+ if (dayFirst)
+ bytes[7] = 0x01; // 24 hour mode
+ else
+ bytes[7] = 0x00; // 12 hour mode
+
+ enqueue(bytes);
+ }
+
public static void ledChange(boolean ledOn) {
if (Preferences.logging) Log.d(MetaWatch.TAG, "Protocol.ledChange()");
byte[] bytes = new byte[4];
View
4 src/org/metawatch/manager/Test.java
@@ -342,8 +342,8 @@ public boolean onPreferenceClick(Preference arg0) {
preferenceScreen.findPreference("time_24hr").setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference arg0) {
- Protocol.setNvalTime(true);
- //NotificationBuilder.createOtherNotification(context, "", "You'll need to reset your watch for this to take effect.");
+ Protocol.setTimeDateFormat(context);
+ NotificationBuilder.createOtherNotification(context, "Time and date", "Formats updated.");
return true;
}
});
View
16 src/org/metawatch/manager/WidgetSetup.java
@@ -198,26 +198,26 @@ public void onClick(View v) {
private void storeWidgetLayout() {
- String out = "";
+ StringBuilder out = new StringBuilder();
for(List<Map<String, String>> row : childData) {
if(out.length()>0)
- out+="|";
+ out.append("|");
- String line = "";
+ StringBuilder line = new StringBuilder();
for(Map<String, String> child : row) {
String id = child.get(ID);
if(id!="") {
if(line.length()>0)
- line+=",";
+ line.append(",");
- line+=id;
+ line.append(id);
}
}
- out+=line;
+ out.append(line);
}
- Preferences.widgets = out;
- MetaWatchService.saveWidgets(this, out);
+ Preferences.widgets = out.toString();
+ MetaWatchService.saveWidgets(this, out.toString());
}
}

No commit comments for this range

Something went wrong with that request. Please try again.