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 float statusFontSize = 25; static float userFontSize = 25; static float myFontSize = 25; static int borderColor = 0xFFFFFFFF; static S lastEmotionImage, lastEmotion /*, onScreenText = ""*/; static TextView statusView, userTextView, myTextView; sS statusText; static EditText inputView; 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; androidUI(r { 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(statusFontSize, aSetForeground(aBlack(), aCenteredTextView())); if (statusText == null) statusText = baseStatus(); aSetText(statusView, statusText); if (inputView == null) inputView = aEditText(); if (userTextView == null) userTextView = aFontSize(userFontSize, aSetForeground(0xFF000055, aTextView()); if (myTextView == null) myTextView = aFontSize(myFontSize, aSetForeground(0xFF005500, aRightAlignedTextView()); androidShow(aVerticalLinearLayout( statusView, androidClickableImage(lastEmotionImage, borderColor, onClick), userTextView, myTextView, androidPrintLogScrollView(), inputView)); }); } 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 }); }); }