Warning: session_start(): open(/var/lib/php/sessions/sess_ocam6a1i1ul1i14m0uotnot5gj, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
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*/17;
static float userFontSize = 25;
static float myFontSize = 25;
static int borderColor = 0xFFFFFFFF;
static S lastEmotionImage, lastEmotion /*, onScreenText = ""*/;
static ImageView emoView;
static TextView statusView, userTextView, myTextView, lblInputView;
sS statusText;
static EditText inputView;
sbool recogOnActivate = true; // start listening when app activated
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 {
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) {
// init UI
statusView = aFontSize(statusFontSize, aSetForeground(aBlack(), aCenteredTextView()));
inputView = aSingleLineEditText();
aOnEnter(inputView, r { onInput(aGetText(inputView), true) });
//aOnChange(inputView, f cancelRecognition); // freezes!?
//aOnChange(inputView, r { listening = false });
//aOnChange(inputView, f cancelRecognition);
lblInputView = aFontSize(20, aBottomTextView(inputViewLabel()));
userTextView = aFontSize(userFontSize, aSetForeground(0xFF000055, aTextViewWithWindowFocusChangeNotify(voidfunc(bool windowFocused) {
if (windowFocused && recogOnActivate) recog();
})));
myTextView = aFontSize(myFontSize, aSetForeground(0xFF005500, aRightAlignedTextView());
androidShow(aVerticalLinearLayout(
statusView,
emoView = androidClickableImage(lastEmotionImage, aWhite(), onClick),
userTextView,
myTextView,
androidPrintLogScrollView(),
aWestAndCenter(lblInputView, inputView)));
}
if (statusText == null) statusText = baseStatus();
aSetText(statusView, statusText);
aSetImageFromSnippet(emoView, lastEmotionImage);
/*doEvery(1000, new Runnable {
S text = "";
public void run() {
S s = aGetText(inputView);
if (eq(s, text)) ret;
text = s;
cancelRecognition();
}
});*/
}
}
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) ret;
happy();
androidLater(1000, r {
androidShowFullScreenColor(0xFFFFFFFF);
androidLater(1000, r {
System.exit(0); // totally unrecommended but works
});
});
}
sS inputViewLabel() {
ret lang("Or type here:", "Oder hier tippen:");
}