ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

EditableSurfaceView.java

Go to the documentation of this file.
00001 package org.residualvm.residualvm;
00002 
00003 import android.content.Context;
00004 import android.text.InputType;
00005 import android.util.AttributeSet;
00006 import android.view.SurfaceView;
00007 import android.view.inputmethod.BaseInputConnection;
00008 import android.view.inputmethod.EditorInfo;
00009 import android.view.inputmethod.InputConnection;
00010 import android.view.inputmethod.InputMethodManager;
00011 
00012 public class EditableSurfaceView extends SurfaceView {
00013     public EditableSurfaceView(Context context) {
00014         super(context);
00015     }
00016 
00017     public EditableSurfaceView(Context context, AttributeSet attrs) {
00018         super(context, attrs);
00019     }
00020 
00021     public EditableSurfaceView(Context context, AttributeSet attrs,
00022                                 int defStyle) {
00023         super(context, attrs, defStyle);
00024     }
00025 
00026     @Override
00027     public boolean onCheckIsTextEditor() {
00028         return false;
00029     }
00030 
00031     private class MyInputConnection extends BaseInputConnection {
00032         public MyInputConnection() {
00033             super(EditableSurfaceView.this, false);
00034         }
00035 
00036         @Override
00037         public boolean performEditorAction(int actionCode) {
00038             if (actionCode == EditorInfo.IME_ACTION_DONE) {
00039                 InputMethodManager imm = (InputMethodManager)
00040                     getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
00041                 imm.hideSoftInputFromWindow(getWindowToken(), 0);
00042             }
00043 
00044             // Sends enter key
00045             return super.performEditorAction(actionCode);
00046         }
00047     }
00048 
00049     @Override
00050     public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
00051         outAttrs.initialCapsMode = 0;
00052         outAttrs.initialSelEnd = outAttrs.initialSelStart = -1;
00053         outAttrs.inputType = (InputType.TYPE_CLASS_TEXT |
00054                                 InputType.TYPE_TEXT_VARIATION_NORMAL |
00055                                 InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
00056         outAttrs.imeOptions = (EditorInfo.IME_ACTION_DONE |
00057                                 EditorInfo.IME_FLAG_NO_EXTRACT_UI);
00058 
00059         return new MyInputConnection();
00060     }
00061 }


Generated on Sat May 18 2019 05:01:00 for ResidualVM by doxygen 1.7.1
curved edge   curved edge