@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_stage_three, container, false);

    GestureOverlayView gOverlay = (GestureOverlayView) view.findViewById(R.id.gOverlay);

    gOverlay.addOnGesturePerformedListener((MainActivity) getActivity());

    return view;
  }
  @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);
  }
Example #3
0
  private void init(Context context) {
    int[] screenDimen = ScreenUtil.getScreenSize(context);
    int screenWidth = screenDimen[0];
    int screenHeight = screenDimen[1];
    mTouchSlop =
        -ViewConfiguration.get(context)
            .getScaledTouchSlop(); // negative value, so detect for swipe left
    Resources res = context.getResources();
    mGestureIconWidth =
        SizeCalculator.gestureIconWidth(
            res); // reserve space at left, showing gesture icons in listview

    LayoutInflater.from(context).inflate(R.layout.view_shortcut, this, true);
    mGestureListView = (GestureListView) findViewById(R.id.sc_gesture_list);
    mOverlay = (ViewGroup) findViewById(R.id.sc_overlay);
    mGestureOverLay = (GestureOverlayView) findViewById(R.id.sc_ges_overlay);
    mKnob = (OverlayKnob) findViewById(R.id.sc_knob);
    mIvTargetApp = (ImageView) findViewById(R.id.sc_target_icon);

    mOverlayKnobPresenter = new OverlayKnobPresenter(this);
    mOverlayGesturePresenter = new OverlayGesturePresenter(context, this, mTouchSlop);
    mStartTaskPresenter = new StartTaskPresenter(this, mIvTargetApp, -screenHeight / 2);

    mGestureListView
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new ViewTreeObserver.OnPreDrawListener() {
              @Override
              public boolean onPreDraw() {
                mGestureListView.getViewTreeObserver().removeOnPreDrawListener(this);
                startShowAnim();
                return true;
              }
            });
    // mGestureListView.setOnGestureIconClickedListener(mStartTaskPresenter);
    mGestureListView.setOnItemClickListener(mStartTaskPresenter);
    mGestureListView.setOnEmptyViewClickedListener(mGestureListEmptyViewClicked);

    // as the width of the overlay will be changed below, while its layout_gravity is right,
    // so calculation of translationX is then affected.
    mTargetOverlayTranslationX = 0;
    mInitialOverlayTranslationX = screenWidth - mGestureIconWidth;

    mOverlay.setTranslationX(mInitialOverlayTranslationX);

    mGestureOverLay.addOnGesturePerformedListener(mStartTaskPresenter);
    mGestureOverLay.getLayoutParams().width = screenWidth - mGestureIconWidth;
    mOverlay.getLayoutParams().width = screenWidth - (mGestureIconWidth - mKnob.getRadius());
  }
Example #4
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

    mHomeListView = (ListView) findViewById(R.id.HomeListView);
    mGallery = (Gallery) findViewById(R.id.Gallery);
    mProgressBar = (ProgressBar) findViewById(R.id.ProgressBar);
    mFailureBar = (FailureBar) findViewById(R.id.FailureBar);
    mViewFlipper = (ViewFlipper) findViewById(R.id.ViewFlipper);

    mGestureOverlayView = (GestureOverlayView) findViewById(R.id.gestures);
    mGestureOverlayView.addOnGesturePerformedListener(
        Dian1Application.getInstance().getPlayerGestureHandler());

    new NewsTask().execute((Void) null);
  }
Example #5
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();
  }
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_draw_gesture);
		
		Intent last = getIntent();
		path = last.getStringExtra("path");
		
		saveBt = (Button) findViewById(R.id.saveBt);
		clearBt = (Button) findViewById(R.id.clearBt);

		mDrawGestureView = (GestureOverlayView) findViewById(R.id.gesture);

		// 设置手势可多笔画绘制,默认情况为单笔画绘制
		mDrawGestureView
				.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_MULTIPLE);
		// 设置手势的颜色(蓝色)
		mDrawGestureView.setGestureColor(gestureColor(R.color.gestureColor));
		// 设置还没未能形成手势绘制是的颜色(红色)
		mDrawGestureView
				.setUncertainGestureColor(gestureColor(R.color.ungestureColor));
		// 设置手势的粗细
		mDrawGestureView.setGestureStrokeWidth(4);
		/*
		 * 手势绘制完成后淡出屏幕的时间间隔,即绘制完手指离开屏幕后相隔多长时间手势从屏幕上消失;
		 * 可以理解为手势绘制完成手指离开屏幕后到调用onGesturePerformed的时间间隔 默认值为420毫秒,这里设置为2秒
		 */
		mDrawGestureView.setFadeOffset(3600000);
		mDrawGestureView.setSaveEnabled(true);

		// 绑定监听器
		mDrawGestureView.addOnGesturePerformedListener(this);
		mDrawGestureView.addOnGesturingListener(this);

		mDrawGestureView.addOnGestureListener(new OnGestureListener() {

			@Override
			public void onGestureStarted(GestureOverlayView overlay,
					MotionEvent event) {
				// TODO Auto-generated method stub
				// mButton1.setEnabled(false);
				mGesture = null;
			}

			@Override
			public void onGesture(GestureOverlayView overlay, MotionEvent event) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onGestureEnded(GestureOverlayView overlay,
					MotionEvent event) {
				// TODO Auto-generated method stub
				mGesture = overlay.getGesture();
				if (mGesture != null) {
					// mButton1.setEnabled(true);
				}
			}

			@Override
			public void onGestureCancelled(GestureOverlayView overlay,
					MotionEvent event) {
				// TODO Auto-generated method stub

			}

		});
		
		saveBt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				saveMyBitmap();
				
				Intent intent = new Intent ();
				intent.putExtra("data", DrawGestureActivity.this.pathAndName);
				setResult(200,intent);
				finish();
				
			}
		});
		
		clearBt.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mDrawGestureView.setFadeOffset(10);//清除前设置时间间隔缩小
				mDrawGestureView.clear(true);
				mDrawGestureView.setFadeOffset(3600000);//清楚后恢复时间间隔
			}
		});

	}
Example #7
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");
  }