Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String lName = WritePadManager.getLanguageName();
    WritePadManager.setLanguage(lName, this);

    // initialize ink inkView class
    inkView = (InkView) findViewById(R.id.ink_view);

    recognizedTextContainer = (LinearLayout) findViewById(R.id.recognized_text_container);
    readyText = (TextView) findViewById(R.id.ready_text);

    Display defaultDisplay = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    defaultDisplay.getSize(size);
    int screenHeight = size.y;
    int textViewHeight = 15 * screenHeight / 100;
    final LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textViewHeight);
    recognizedTextContainer.setLayoutParams(params);
    readyText.setLayoutParams(params);

    inkView.setRecognizedTextContainer(recognizedTextContainer);
    inkView.setReadyText(readyText);

    mConnection =
        new ServiceConnection() {
          public void onServiceConnected(ComponentName className, IBinder service) {
            // This is called when the connection with the service has been
            // established, giving us the service object we can use to
            // interact with the service.  Because we have bound to a explicit
            // service that we know is running in our own process, we can
            // cast its IBinder to a concrete class and directly access it.
            mBoundService = ((RecognizerService.RecognizerBinder) service).getService();
            mBoundService.mHandler = inkView.getHandler();
          }

          public void onServiceDisconnected(ComponentName className) {
            // This is called when the connection with the service has been
            // unexpectedly disconnected -- that is, its process crashed.
            // Because it is running in our same process, we should never
            // see this happen.
            mBoundService = null;
          }
        };

    bindService(
        new Intent(RecoTest.this, RecognizerService.class), mConnection, Context.BIND_AUTO_CREATE);
  }
Ejemplo n.º 2
0
  @Override
  protected void onResume() {
    if (inkView != null) {
      inkView.cleanView(true);
    }

    WritePadFlagManager.initialize(this);
    super.onResume();
  }
Ejemplo n.º 3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case CLEAR_MENU_ID:
        inkView.cleanView(true);
        return true;
      case SETTINGS_MENU_ID:
        Intent intent = new Intent(this, MainSettings.class);
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
  }