IMEManager

Contents

Introduction

IMEManager provides an keyboard let user can input text in VR scene. APIs are listed below to let developers check the status and open keyboard when needed.

IMEManager Class

  • void getInstance()

Get the instance of IMEManager.

  • void setContext(Context ctx)

Before using IMEManager, the context must be passed into. . - **void onCreate()*. When App in onCreate state, call this function to sync state.

  • void onPauseAndReturnFail()

When App in onPause state, call this function to sync state.

  • void onResume()

When App state in onPesume, call this function to sync state.

  • void onDestory()

When App in onDestory state, call this function to sync state.

  • boolean isInitialized()

Report true/false to checkout the status of IMEManager.

  • void showKeyboard(IMEParameter parameter, IMECallback cb)

Show keyboard.

  • void hideKeyboard()

Close keyboard.

IMECallback Interface

  • void onInputCompletedwithObject(InputResult res);

The developer must implement the callback function to receive input result data from the IMEManager.

InputResult Class

  • int id

The input id which developer defined.

  • int errorCode

Error code.

  • String inputContent

The input result.

The Constructor of IMEParameter Class

  • public IMEParameter(int id, int type, int mode, double[] position, double[] rotation, int width, int height, int shadow, String locale, String title, int buttonId)

    int id : The ID which developer defined.

    int type : The type of keyboard. Not yet supported, please use 0 be the default value.

    int mode : 0 auto hide. 1 fix overlay. 2 fix position. Not yet supported, please use 0 be the default value.

    double[] position : The position. Not yet supported, please use double[]{0, 0, 0} be the default value.

    double[] rotation : The rotation. Not yet supported, please use null be the default value.

    int width : The width. Not yet supported, please use 0 be the default value.

    int height : The height. Not yet supported, please use 0 be the default value.

    int shadow : The shadow. Not yet supported, please use 0 be the default value.

    String locale : Define locale launguage. Not yet supported, please use ‘en_US’ be the defalut value.

    String title : The title on keyboard.

    int buttonId Defind choose button. Not yet supported, please use 16 to designate touchpad button.

How to Use

  1. Copy wvr_ime_client.aar to libs folder in project.
  2. In build.gradle add reference. ex: compile (name:’wvr_ime_client’, ext:’aar’).
  3. Call Instance.getInstace() to get the instance of IMEManager.
  4. Call Instance.setContext(Context ctx) to set Context.
  5. Implement callback function to get notification from IMEManager.
  6. Call Instance.isInitialized() to check the status of IMEManager.
  7. Call Instance.showKeyboard(IMEParameter parameter, IMECallback cb) to show keyboard.
  8. Get input result from IMEManager.

Sample Code

import com.htc.vr.ime.client.IMEManager;
import com.htc.vr.ime.client.IMECallback;
import com.htc.vr.ime.client.InputResult;
import com.htc.vr.ime.server.IMEParameter;

public class MainActivity extends VRActivity {
    private static final String TAG = "IME_MANAGER_TEST";
    private IMEManager mIME = null;
    private IMEParameter mParameter = null;

    private IMECallback mCallBack = new IMECallback() {
        @Override
        public void onInputCompletedwithObject(InputResult res){
           Log.d(TAG, "tay The input result :" + res.inputContent);
        }
    };

    public MainActivity(){
        mIME = IMEManager.getInstance();
        mIME.setContext(this);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate();
        mIME.onCreate();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mIME.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mIME.onPauseAndReturnFail();
    }

    @Override
    protected void onDestory() {
        super.onDestory();
        mIME.onDestory();
    }

    private void showKeyboard() {
        int id = 0;
        int type = 0;
        int mode = 0;
        double[] pos = new double[] { 0 , 0, 0};
        double[] rot = null;
        int width = 0;
        int height = 0;
        int shadow = 0;
        String locale = "en_US";
        String title = "IMETest Title";
        int extraInt = 0;
        int buttonId = 16;//System:0 , Menu:1 , Grip:2, Touchpad:16, Trigger:17
        mParameter = new IMEParameter(id, type, mode, pos, rot, width, height,
                                      shadow, locale, title, buttonId);
        if(mIME.isInitialized()){
            mIME.showKeyboard(mParameter, mCallBack);
            mIME.hideKeyboard();
        }
    }
}