static boolean showPicture = true; // global switch. if false, you get the normal text display instead of the smiley static L emotions = litlist( "#1001283", "happy", "#1001284", "unhappy", "#1001285", "oh", "#1001286", "bored", "#1001287", "wide mouth"); static int borderColor = 0xFFFFFFFF; static S lastEmotionImage, lastEmotion /*, onScreenText = ""*/; static TextView statusView; sS statusText; static void showText(S text) { print(text); /*if (neq(onScreenText, text) && lastEmotion != null) { onScreenText = text; emo_show(); }*/ } static void emo(S emotion) { if (!showPicture) return; int i; for (i = 0; i < emotions.size(); i += 2) if (emotions.get(i+1).equalsIgnoreCase(emotion)) break; if (i >= emotions.size()) { print("Emotion not found: " + emotion); // use the last one from the list as default i -= 2; } lastEmotionImage = emotions.get(i); lastEmotion = emotions.get(i+1); emo_show(); } static void emo_show() { if (!showPicture) return; Runnable onClick = r { if (!manualMode) ret; //if (listening) if (borderColor != -1) { //androidLater(500, r { stopListening(); }); showText("stop"); stopListening(); } else { showText ("start"); newRecognizer(); } }; if (statusView == null) statusView = aFontSize(30, aSetForeground(aBlack(), aCenteredTextView())); if (statusText == null) statusText = baseStatus(); aSetText(statusView, statusText); androidShow(aVerticalLinearLayout( statusView, androidClickableImage(lastEmotionImage, borderColor, onClick), androidPrintLogScrollView())); //androidShowClickableImageAndPrintLog(lastEmotionImage, borderColor, onClick); } static void setBorderAndStatus(int color, S status) { if (color != borderColor || neq(status, statusText)) { borderColor = color; statusText = status; if (lastEmotion != null) emo(lastEmotion); } } static void setBorderColor(int color) { if (color != borderColor) { borderColor = color; if (lastEmotion != null) emo(lastEmotion); } } static void happy() { emo("happy"); } static void unhappy() { emo("unhappy"); } static void oh() { emo("oh"); } static void bored() { emo("bored"); } static void wideMouth() { emo("wide mouth"); } static void disappear() { if (!showPicture) return; happy(); androidLater(1000, runnable { androidShowFullScreenColor(0xFFFFFFFF); androidLater(1000, runnable { System.exit(0); // totally unrecommended but works }); }); }