@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mLibrary = GestureLibraries.fromRawResource(this, R.raw.spells);
    if (!mLibrary.load()) {
      finish();
    }

    GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
    gestures.addOnGesturePerformedListener(this);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.gestures_list);

    mAdapter = new GesturesAdapter(this);
    setListAdapter(mAdapter);

    if (sStore == null) {
      sStore = GestureLibraries.fromFile(mStoreFile);
    }
    mEmpty = (TextView) findViewById(android.R.id.empty);
    loadGestures();

    registerForContextMenu(getListView());
  }
Beispiel #3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.mContext = this;
    // Allow long clicks
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.custom, null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gestureLib.load()) {
      finish();
    }
    // Init Handler
    setContentView(R.layout.activity_main);
    inflate.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            // Play start focus sound
            SoundPlayer.playSound(arg0.getContext(), SoundPlayer.S9);
            mView.focusCamera(false);
          }
        });

    inflate.setOnLongClickListener(
        new OnLongClickListener() {
          public boolean onLongClick(View arg0) {
            // perform auto focus and take picture
            focusAndTakePhoto();
            return true;
          }
        });

    LayoutParams layoutParamsControl =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    this.addContentView(gestureOverlayView, layoutParamsControl);
    // icSeeTutorial.initMediaPlayer();
  }
Beispiel #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.note_edit);

    GestureOverlayView gestureView = (GestureOverlayView) findViewById(R.id.edit_gestures);
    gestureView.setGestureColor(Color.TRANSPARENT);
    gestureView.setUncertainGestureColor(Color.TRANSPARENT);

    gLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gLib.load()) {
      NotelyLogger.Log(TAG, "could not load gestures library");
      finish();
    } else {
      NotelyLogger.Log(TAG, "gestures library loaded");
    }

    gestureView.addOnGesturePerformedListener(handleGestureListener);

    Button confirmButton = (Button) findViewById(R.id.confirm);
    Button cancelButton = (Button) findViewById(R.id.cancel);

    // get shit back if there was a saved state
    mRowId =
        (savedInstanceState == null)
            ? null
            : (Long) savedInstanceState.getSerializable(NoteDb.KEY_ROWID);
    isEditable =
        (savedInstanceState == null)
            ? false
            : (Boolean) savedInstanceState.getSerializable(EDITABLE_FLAG);

    // also see if the id was passed in via an edit activity call
    if (mRowId == null) {
      Bundle extras = getIntent().getExtras();
      mRowId = extras != null ? extras.getLong(NoteDb.KEY_ROWID) : null;
    }

    // if you're editing an existing note, have it say edit since the default is to not be editable
    if (mRowId != null) {
      confirmButton.setText(R.string.edit);
      setTitle(R.string.edit_note);
    } else {
      setTitle(R.string.create_note);
    }

    instanceState = savedInstanceState;

    confirmButton.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View view) {

            EditText mTitleText = (EditText) findViewById(R.id.title);
            EditText mBodyText = (EditText) findViewById(R.id.body);
            EditText mBody2Text = (EditText) findViewById(R.id.body2);

            if (mRowId != null && isEditable == false) {

              NotelyLogger.Log(TAG, "setting things editable");

              isEditable = true;

              // swap views
              mBodyText.setVisibility(View.GONE);
              mBody2Text.setVisibility(View.VISIBLE);

              mTitleText.setFocusableInTouchMode(true);
              mTitleText.setCursorVisible(true);

              Button confirmButton = (Button) findViewById(R.id.confirm);
              Button cancelButton = (Button) findViewById(R.id.cancel);

              confirmButton.setText(R.string.confirm);
              cancelButton.setText(R.string.cancel);

            } else {

              boolean res = saveNote();

              if (res) {

                NotelyLogger.Log(TAG, "setting things not editable");

                isEditable = false;

                // update old text field
                String body2 = mBody2Text.getText().toString();
                mBodyText.setText(body2);

                // swap views
                mBodyText.setVisibility(View.VISIBLE);
                mBody2Text.setVisibility(View.GONE);

                mTitleText.setFocusable(false);
                mTitleText.setCursorVisible(false);

                Button confirmButton = (Button) findViewById(R.id.confirm);
                Button cancelButton = (Button) findViewById(R.id.cancel);

                confirmButton.setText(R.string.edit);
                cancelButton.setText(R.string.back);

                // close soft keyboard
                InputMethodManager inputManager =
                    (InputMethodManager)
                        NoteEdit.this.getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.hideSoftInputFromWindow(
                    mBody2Text.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

              } else {

                if (mRowId != null) {
                  Toast.makeText(NoteEdit.this, R.string.toast_noupdateempty, Toast.LENGTH_SHORT)
                      .show();
                } else {
                  Toast.makeText(NoteEdit.this, R.string.toast_nocreateempty, Toast.LENGTH_SHORT)
                      .show();
                }
              }
            }
          }
        });

    cancelButton.setOnClickListener(
        new View.OnClickListener() {

          public void onClick(View v) {

            EditText mTitleText = (EditText) findViewById(R.id.title);
            EditText mBodyText = (EditText) findViewById(R.id.body);
            EditText mBody2Text = (EditText) findViewById(R.id.body2);

            if (isEditable == true) {

              isEditable = false;

              // set possibly edited text back
              String body = mBodyText.getText().toString();
              mBody2Text.setText(body);

              // set possibly edited title back too
              Note note = NoteHelper.getNote(NoteEdit.this, mRowId);
              mTitleText.setText(note.getTitle());

              // swap views
              mBodyText.setVisibility(View.VISIBLE);
              mBody2Text.setVisibility(View.GONE);

              mTitleText.setFocusable(false);
              mTitleText.setCursorVisible(false);

              Button confirmButton = (Button) findViewById(R.id.confirm);
              Button cancelButton = (Button) findViewById(R.id.cancel);

              confirmButton.setText(R.string.edit);
              cancelButton.setText(R.string.back);

              // close soft keyboard
              InputMethodManager inputManager =
                  (InputMethodManager) NoteEdit.this.getSystemService(Context.INPUT_METHOD_SERVICE);
              inputManager.hideSoftInputFromWindow(
                  mBody2Text.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

            } else {
              setResult(RESULT_OK);
              finish();
            }
          }
        });

    NotelyLogger.Log(TAG, "oncreate called");
  }