Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make actions hidable using the HidableAction interface.

Using this, empty ContainerActions are now hidden.
  • Loading branch information...
commit ea58bfab2f420083ceac813ade85490fb41eb7dc 1 parent f761cfa
@firetech firetech authored
View
6 src/org/metawatch/manager/actions/ContainerAction.java
@@ -5,7 +5,7 @@
import android.content.Context;
-public abstract class ContainerAction implements Action {
+public abstract class ContainerAction implements HidableAction {
protected List<Action> subActions = new ArrayList<Action>();
public List<Action> getSubActions() {
@@ -16,6 +16,10 @@ public int size() {
return subActions.size();
}
+ public boolean isHidden() {
+ return subActions.isEmpty();
+ }
+
// Overridable by subclasses, but default to the name.
public String getTitle() {
return getName();
View
5 src/org/metawatch/manager/actions/HidableAction.java
@@ -0,0 +1,5 @@
+package org.metawatch.manager.actions;
+
+public interface HidableAction extends Action {
+ public boolean isHidden();
+}
View
17 src/org/metawatch/manager/apps/ActionsApp.java
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
import java.util.Stack;
import org.metawatch.manager.FontCache;
@@ -12,6 +13,7 @@
import org.metawatch.manager.Notification.NotificationType;
import org.metawatch.manager.actions.Action;
import org.metawatch.manager.actions.ContainerAction;
+import org.metawatch.manager.actions.HidableAction;
import org.metawatch.manager.actions.InternalActions;
import org.metawatch.manager.actions.ResettableAction;
import org.metawatch.manager.actions.TimestampAction;
@@ -197,6 +199,10 @@ public int performAction(Context context) {
}
*/
}
+
+ if (currentActions == null) {
+ currentActions = new ArrayList<Action>();
+ }
}
public void activate(int watchType) {
@@ -261,7 +267,7 @@ public Bitmap update(final Context context, boolean preview, int watchType) {
notifications.addAll(getNotificationActions());
}
- currentActions = new ArrayList<Action>();
+ currentActions.clear();
if (containerStack.isEmpty()) {
// At the root.
//TODO Add external actions using intents, similar to widgets.
@@ -274,6 +280,15 @@ public Bitmap update(final Context context, boolean preview, int watchType) {
currentActions.addAll(containerStack.peek().getSubActions());
}
+ // Clean away empty actions.
+ ListIterator<Action> it = currentActions.listIterator();
+ while (it.hasNext()) {
+ Action a = it.next();
+ if (a instanceof HidableAction && ((HidableAction)a).isHidden()) {
+ it.remove();
+ }
+ }
+
if (currentSelection >= currentActions.size()) {
currentSelection = 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.