diff --git a/cicada/assets/fonts b/cicada/assets/fonts deleted file mode 120000 index 1d90179..0000000 --- a/cicada/assets/fonts +++ /dev/null @@ -1 +0,0 @@ -../../apollolib/assets/fonts \ No newline at end of file diff --git a/cicada/assets/fonts/metawatch_16pt_11pxl_proto1.ttf b/cicada/assets/fonts/metawatch_16pt_11pxl_proto1.ttf new file mode 100644 index 0000000..9aeb8b3 Binary files /dev/null and b/cicada/assets/fonts/metawatch_16pt_11pxl_proto1.ttf differ diff --git a/cicada/assets/fonts/metawatch_8pt_5pxl_CAPS_proto1.ttf b/cicada/assets/fonts/metawatch_8pt_5pxl_CAPS_proto1.ttf new file mode 100644 index 0000000..a6b8f30 Binary files /dev/null and b/cicada/assets/fonts/metawatch_8pt_5pxl_CAPS_proto1.ttf differ diff --git a/cicada/assets/fonts/metawatch_8pt_7pxl_CAPS_proto1.ttf b/cicada/assets/fonts/metawatch_8pt_7pxl_CAPS_proto1.ttf new file mode 100644 index 0000000..72eda9e Binary files /dev/null and b/cicada/assets/fonts/metawatch_8pt_7pxl_CAPS_proto1.ttf differ diff --git a/cicada/src/org/cicadasong/cicada/AppList.java b/cicada/src/org/cicadasong/cicada/AppList.java index 534a023..8633b70 100644 --- a/cicada/src/org/cicadasong/cicada/AppList.java +++ b/cicada/src/org/cicadasong/cicada/AppList.java @@ -138,8 +138,12 @@ protected void onButtonPress(WatchButton button) { private void changeSelection(int newIndex) { selectedIndex = newIndex; - selectedIndex = Math.min(apps.size() - 1, selectedIndex); - selectedIndex = Math.max(0, selectedIndex); + // Wrap around across top or bottom + if (selectedIndex < 0) { + selectedIndex = apps.size() - 1; + } else if (selectedIndex >= apps.size()) { + selectedIndex = 0; + } invalidate(); } @@ -154,20 +158,37 @@ private void launchSelectedApp() { sendBroadcast(intent); } + private int lastStartIndex = -1; + private final int listSize = 7; + protected void onDraw(Canvas canvas) { float y = -paint.ascent(); - int startIndex = Math.max(0, selectedIndex - 2); - for (int i = startIndex; (i < apps.size()) && (i < startIndex + 7); i++) { - if (i == selectedIndex) { - paint.setColor(Color.BLACK); - canvas.drawRect(new Rect(0, - (int)(y + paint.ascent()), canvas.getWidth(), (int)(y + paint.descent() + 1)), paint); - } - paint.setColor(i == selectedIndex ? Color.WHITE : Color.BLACK); - canvas.drawText(apps.get(i).appName, LEFT_MARGIN, y, paint); - y += paint.getFontSpacing(); + int startIndex = 0; + if (selectedIndex < lastStartIndex) { + startIndex = selectedIndex - (int)(listSize/2); // Put our item in the centre of the list if scrolling upwards + } else if (selectedIndex > (lastStartIndex + listSize -1)) { + startIndex = selectedIndex - (int)(listSize/2); // Put our item in the centre of the list if scrolling downwards } + if ((startIndex + listSize) >= apps.size()) { + startIndex = apps.size() - listSize; // If there would be blank lines then adjust so that doesn't happen if we can + } + if (startIndex < 0) { + startIndex = 0; // If we're off the top then fix it + } + + lastStartIndex = startIndex; + + for (int i = startIndex; (i < apps.size()) && (i < startIndex + 7); i++) { + if (i == selectedIndex) { + paint.setColor(Color.BLACK); + canvas.drawRect(new Rect(0, + (int)(y + paint.ascent()), canvas.getWidth(), (int)(y + paint.descent() + 1)), paint); + } + paint.setColor(i == selectedIndex ? Color.WHITE : Color.BLACK); + canvas.drawText(apps.get(i).appName, LEFT_MARGIN, y, paint); + y += paint.getFontSpacing(); + } } }