# HG changeset patch # User Martin Gerhardy # Date 1364711650 -7200 # Node ID 17eaa9643495d0205198f480463a9e7a62ccd55b # Parent 1d93c5748d5ab37c5cb622b9c76e917d50909f86 * android: also extract the class ShowTextInputHandler diff -r 1d93c5748d5a -r 17eaa9643495 android-project/src/org/libsdl/app/SDLActivity.java --- a/android-project/src/org/libsdl/app/SDLActivity.java Sun Mar 31 08:33:12 2013 +0200 +++ b/android-project/src/org/libsdl/app/SDLActivity.java Sun Mar 31 08:34:10 2013 +0200 @@ -283,44 +283,6 @@ } } - static class ShowTextInputHandler implements Runnable { - /* - * This is used to regulate the pan&scan method to have some offset from - * the bottom edge of the input region and the top edge of an input - * method (soft keyboard) - */ - static final int HEIGHT_PADDING = 15; - - public int x, y, w, h; - - public ShowTextInputHandler(int x, int y, int w, int h) { - this.x = x; - this.y = y; - this.w = w; - this.h = h; - } - - public void run() { - AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams( - w, h + HEIGHT_PADDING, x, y); - - if (mTextEdit == null) { - mTextEdit = new DummyEdit(getContext()); - - mLayout.addView(mTextEdit, params); - } else { - mTextEdit.setLayoutParams(params); - } - - mTextEdit.setVisibility(View.VISIBLE); - mTextEdit.requestFocus(); - - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextEdit, 0); - } - - } - public static void showTextInput(int x, int y, int w, int h) { // Transfer the task to the main thread as a Runnable mSingleton.commandHandler.post(new ShowTextInputHandler(x, y, w, h)); diff -r 1d93c5748d5a -r 17eaa9643495 android-project/src/org/libsdl/app/ShowTextInputHandler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/android-project/src/org/libsdl/app/ShowTextInputHandler.java Sun Mar 31 08:34:10 2013 +0200 @@ -0,0 +1,44 @@ +package org.libsdl.app; + +import android.content.Context; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.AbsoluteLayout; + +class ShowTextInputHandler implements Runnable { + /* + * This is used to regulate the pan&scan method to have some offset from + * the bottom edge of the input region and the top edge of an input + * method (soft keyboard) + */ + static final int HEIGHT_PADDING = 15; + + public int x, y, w, h; + + public ShowTextInputHandler(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + + public void run() { + AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams( + w, h + HEIGHT_PADDING, x, y); + + if (SDLActivity.mTextEdit == null) { + SDLActivity.mTextEdit = new DummyEdit(SDLActivity.getContext()); + + SDLActivity.mLayout.addView(SDLActivity.mTextEdit, params); + } else { + SDLActivity.mTextEdit.setLayoutParams(params); + } + + SDLActivity.mTextEdit.setVisibility(View.VISIBLE); + SDLActivity.mTextEdit.requestFocus(); + + InputMethodManager imm = (InputMethodManager) SDLActivity.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(SDLActivity.mTextEdit, 0); + } + +} \ No newline at end of file