Permalink
Browse files

Remake "Replay Notification" button to a configurable "Quick Button".

For Digital only, since we don't know what button to use for this on the
Analog.

The Quick Button can be configured to either do nothing, replay last
notification or open the Actions app.

Using this, the Actions app is toggleable, but only if it's set as the
Quick Button action.
  • Loading branch information...
1 parent 88c32a9 commit 3fecc90c98d3d265eb1b2085e66f38dcb56e50cb @firetech firetech committed Jun 1, 2012
@@ -186,12 +186,6 @@
android:summary="List of applications to ignore notifications from"
/>
- <CheckBoxPreference
- android:title="Last Notification Replay (Beta)"
- android:key="IdleReplay"
- android:summary="Enable replay of last notification on Idle screen"
- android:defaultValue="false"
- />
<ListPreference
android:entries="@array/settings_font_size_name"
android:entryValues="@array/settings_font_size_value"
@@ -241,7 +235,18 @@
<PreferenceScreen
android:title="@string/settings_Digital"
>
-
+
+ <ListPreference
+ android:entries="@array/settings_quick_button_name"
+ android:entryValues="@array/settings_quick_button_value"
+ android:dialogTitle="Quick Button Action"
+ android:key="QuickButton"
+ android:title="Quick Button Action"
+ android:summary="Action for Left Middle Button on non-app idle pages"
+ android:negativeButtonText="Cancel"
+ android:defaultValue="0"
+ />
+
<CheckBoxPreference
android:title="Sticky Notifications"
android:key="stickyNotifications"
@@ -120,6 +120,18 @@
<item>1</item>
</string-array>
+ <string-array name="settings_quick_button_name">
+ <item>Disabled</item>
+ <item>Replay Latest Notification</item>
+ <item>Open/Go to the Actions App</item>
+ </string-array>
+
+ <string-array name="settings_quick_button_value">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
<string name="settings_Digital">Digital Watch</string>
<string name="settings_Analog">Analog Watch</string>
<string name="settings_Other">Other</string>
@@ -38,7 +38,6 @@
import org.metawatch.manager.MetaWatchService.Preferences;
import org.metawatch.manager.MetaWatchService.WatchType;
-import org.metawatch.manager.Notification.VibratePattern;
import org.metawatch.manager.apps.ActionsApp;
import org.metawatch.manager.apps.AppManager;
import org.metawatch.manager.apps.InternalApp;
@@ -58,6 +57,12 @@
final static byte IDLE_NEXT_PAGE = 60;
final static byte IDLE_OLED_DISPLAY = 61;
+ final static byte QUICK_BUTTON = 62;
+
+ // Quick Button modes.
+ public final static int QB_DISABLED = 0;
+ public final static int QB_NOTIFICATION_REPLAY = 1;
+ public final static int QB_OPEN_ACTIONS = 2;
private interface IdlePage {
public void activate(int watchType);
@@ -77,9 +82,19 @@ public WidgetPage(List<WidgetRow> r, int p) {
pageIndex = p;
}
- public void activate(int watchType) {}
+ public void activate(int watchType) {
+ if (Preferences.quickButton != QB_DISABLED) {
+ if (watchType == MetaWatchService.WatchType.DIGITAL)
+ Protocol.enableButton(1, 0, Idle.QUICK_BUTTON, screenMode(watchType));
+ }
+ }
- public void deactivate(int watchType) {}
+ public void deactivate(int watchType) {
+ if (Preferences.quickButton != QB_DISABLED) {
+ if (watchType == MetaWatchService.WatchType.DIGITAL)
+ Protocol.disableButton(1, 0, screenMode(watchType));
+ }
+ }
public Bitmap draw(Context context, boolean preview, Bitmap bitmap, int watchType) {
@@ -326,11 +341,6 @@ else if (MetaWatchService.watchType == MetaWatchService.WatchType.ANALOG)
}
idlePages = screens;
-
- if (prevList == null) {
- //First run of this function, activate buttons for initial screen.
- toPage(currentPage);
- }
}
static Bitmap createIdle(Context context) {
@@ -455,18 +465,30 @@ public static void sendOledIdle(Context context) {
Protocol.oledChangeMode(mode);
}
- public static void oledTest(Context context, String msg) {
- VibratePattern vibratePattern = new VibratePattern(false, 0, 0, 1);
- Notification.addOledNotification(context, Protocol.createOled1line(context, null, "Testing"), Protocol.createOled1line(context, null, msg), null, 0, vibratePattern, "oled test");
- }
-
public static int appButtonPressed(Context context, int id) {
if(idlePages != null && idlePages.size()>currentPage) {
return idlePages.get(currentPage).buttonPressed(context, id);
}
return InternalApp.BUTTON_NOT_USED;
}
+ public static void quickButtonAction(Context context) {
+ switch(Preferences.quickButton) {
+ case QB_NOTIFICATION_REPLAY:
+ Notification.replay(context);
+ break;
+ case QB_OPEN_ACTIONS:
+ AppManager.getApp(ActionsApp.APP_ID).open(context);
+ break;
+ }
+ }
+
+ public static void activateButtons() {
+ if(idlePages != null && idlePages.size()>currentPage) {
+ idlePages.get(currentPage).activate(MetaWatchService.watchType);
+ }
+ }
+
public static void deactivateButtons() {
if(idlePages != null && idlePages.size()>currentPage) {
idlePages.get(currentPage).deactivate(MetaWatchService.watchType);
@@ -171,7 +171,7 @@
public static boolean idleMusicControls = false;
public static int idleMusicControlMethod = MediaControl.MUSICSERVICECOMMAND;
public static boolean actionsEnabled = false;
- public static boolean idleReplay = false;
+ public static int quickButton = Idle.QB_DISABLED;
public static boolean notificationLarger = false;
public static boolean autoConnect = false;
public static boolean autoRestart = false;
@@ -246,8 +246,9 @@ public static void loadPreferences(Context context) {
Preferences.idleMusicControlMethod = Integer.parseInt(
sharedPreferences.getString("IdleMusicControlMethod",
Integer.toString(Preferences.idleMusicControlMethod)));
- Preferences.idleReplay = sharedPreferences.getBoolean("IdleReplay",
- Preferences.idleReplay);
+ Preferences.quickButton = Integer.parseInt(
+ sharedPreferences.getString("QuickButton",
+ Integer.toString(Preferences.quickButton)));
Preferences.autoConnect = sharedPreferences.getBoolean(
"AutoConnect", Preferences.autoConnect);
Preferences.autoRestart = sharedPreferences.getBoolean("AutoRestart",
@@ -513,11 +514,6 @@ void connect(Context context) {
Protocol.getDeviceType();
Notification.startNotificationSender(this);
-
- if (Preferences.idleReplay)
- Protocol.enableReplayButton();
- else
- Protocol.disableReplayButton();
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
@@ -826,6 +822,9 @@ else if (bytes[2] == eMessageType.GetDeviceTypeResponse.msg) { // device
Protocol.queryNvalTime();
}
+
+ Idle.activateButtons();
+
} else if (bytes[2] == eMessageType.ReadBatteryVoltageResponse.msg) {
boolean powerGood = bytes[4] > 0;
boolean batteryCharging = bytes[5] > 0;
@@ -920,16 +919,15 @@ void pressedButton(byte button) {
switch (button) {
- case Protocol.REPLAY:
- Notification.replay(this);
+ case Idle.QUICK_BUTTON:
+ Idle.quickButtonAction(this);
break;
case Idle.IDLE_NEXT_PAGE:
if (MetaWatchService.watchType == MetaWatchService.WatchType.DIGITAL) {
Idle.nextPage();
Idle.updateIdle(this, true);
}
-
break;
case Idle.IDLE_OLED_DISPLAY:
@@ -975,19 +973,7 @@ else if (idleAppButton != InternalApp.BUTTON_USED_DONT_UPDATE)
break;
case WatchStates.NOTIFICATION:
- switch (button) {
- case Notification.NOTIFICATION_UP:
- Notification.buttonPressed(button);
- break;
-
- case Notification.NOTIFICATION_DOWN:
- Notification.buttonPressed(button);
- break;
-
- case Notification.NOTIFICATION_DISMISS:
- Notification.buttonPressed(button);
- break;
- }
+ Notification.buttonPressed(button);
break;
}
@@ -45,6 +45,8 @@
public class Notification {
private static NotificationType currentNotification = null;
+
+ public static final byte REPLAY = 30;
final static byte NOTIFICATION_NONE = 0;
final static byte NOTIFICATION_UP = 30;
@@ -55,8 +55,6 @@
import android.util.Log;
public class Protocol {
-
- public static final byte REPLAY = 30;
private static volatile BlockingQueue<byte[]> sendQueue = new LinkedBlockingQueue<byte[]>();
@@ -515,14 +513,6 @@ public static void disableButton(int button, int type, int mode) {
enqueue(bytes);
}
- public static void enableReplayButton() {
- enableButton(1, 0, REPLAY, MetaWatchService.WatchBuffers.IDLE);
- }
-
- public static void disableReplayButton() {
- disableButton(1, 0, MetaWatchService.WatchBuffers.IDLE);
- }
-
public static void readButtonConfiguration() {
if (Preferences.logging) Log.d(MetaWatch.TAG, "Protocol.readButtonConfiguration()");
byte[] bytes = new byte[9];
@@ -8,6 +8,7 @@
import org.metawatch.manager.FontCache;
import org.metawatch.manager.Idle;
import org.metawatch.manager.MetaWatchService;
+import org.metawatch.manager.MetaWatchService.Preferences;
import org.metawatch.manager.Notification;
import org.metawatch.manager.Protocol;
import org.metawatch.manager.Notification.NotificationType;
@@ -43,8 +44,6 @@
supportsDigital = true;
supportsAnalog = true;
-
- toggleable = false;
}};
public final static byte ACTION_NEXT = 30;
@@ -75,6 +74,17 @@ public AppData getInfo() {
return appData;
}
+ public boolean isToggleable() {
+ // Always provide a way to reach the Actions app (since it's quite central).
+ if (MetaWatchService.watchType == MetaWatchService.WatchType.DIGITAL &&
+ Preferences.quickButton == Idle.QB_OPEN_ACTIONS) {
+ // Only set toggleable if Quick Button can open it again.
+ return true;
+ }
+
+ return false;
+ }
+
List<Action> internalActions = null;
Stack<ContainerAction> containerStack = new Stack<ContainerAction>(); //Contains the stack of ContainerActions opened (empty if at root).
List<Action> currentActions = null; //Contains the list as it's shown on the screen (including a "back" item for sub level lists).
@@ -327,7 +337,7 @@ private Bitmap drawDigital(final Context context, boolean preview) {
int y = textHeight + 5; //Make room for a title.
boolean scrolled = false;
- for (int i = Math.max(0, currentSelection - 96/textHeight + (containerStack.isEmpty() ? 3 : 4));
+ for (int i = Math.max(0, currentSelection - 96/textHeight + 4);
(i < currentActions.size() && (i <= currentSelection || y <= 96));
i++) {
Action a = currentActions.get(i);
@@ -400,7 +410,7 @@ private Bitmap drawDigital(final Context context, boolean preview) {
}
String title = (containerStack.isEmpty() ? "Actions" : containerStack.peek().getTitle());
canvas.drawText((String) TextUtils.ellipsize(title, paint, 84, TruncateAt.END), 2, textHeight+1, paint);
- canvas.drawLine(1, textHeight+2, 86, textHeight+2, paint);
+ canvas.drawLine(1, textHeight+2, (isToggleable() ? 79 : 87), textHeight+2, paint);
// Draw icons.
drawDigitalAppSwitchIcon(context, canvas, preview);

0 comments on commit 3fecc90

Please sign in to comment.