in storage/testapp/src/android/java/com/google/firebase/example/LoggingUtils.java [44:83]
public static void initLogWindow(Activity activity, boolean monospace) {
LinearLayout linearLayout = new LinearLayout(activity);
scrollView = new ScrollView(activity);
textView = new TextView(activity);
textView.setTag("Logger");
if (monospace) {
textView.setTypeface(Typeface.MONOSPACE);
textView.setTextSize(10);
}
linearLayout.addView(scrollView);
scrollView.addView(textView);
Window window = activity.getWindow();
window.takeSurface(null);
window.setContentView(linearLayout);
// Force the TextView to stay scrolled to the bottom.
textView.addTextChangedListener(
new TextWatcher() {
@Override
public void afterTextChanged(Editable e) {
if (scrollView != null && !didTouch) {
// If the user never interacted with the screen, scroll to bottom.
scrollView.fullScroll(View.FOCUS_DOWN);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int count, int after) {}
});
textView.setOnTouchListener(
new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
didTouch = true;
return false;
}
});
}