Esempio n. 1
0
        public void onClick(View v) {
          if (mEraseMenuWindow.lastClosedByAnchorTouch() == true) {
            return;
          }

          if (eraserButton.previousStateWasChecked()) {
            Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
            vibrator.vibrate(40);
            mEraseMenuWindow.show();
          }
        }
Esempio n. 2
0
  @SuppressWarnings("deprecation")
  public ActionBar(Context context, AttributeSet attributes) {
    super(context, attributes);

    density = this.getContext().getResources().getDisplayMetrics().density;

    initBarButtons();
    initMenuButtons();

    LinearLayout eraseMenu = (LinearLayout) inflate(getContext(), R.layout.eraser_menu, null);
    mEraseMenuWindow =
        new AnchorWindow(
            eraserButton,
            eraseMenu,
            (int) (320 * getResources().getDisplayMetrics().density),
            LayoutParams.WRAP_CONTENT);

    final SizeSliderView eraseSizeSlider =
        (SizeSliderView) eraseMenu.findViewById(R.id.eraser_size_slider);
    eraseSizeSlider.setActionBarListener(mListener);

    mEraseMenuWindow.setDismissListener(
        new PopupWindow.OnDismissListener() {
          public void onDismiss() {
            eraserSize = eraseSizeSlider.getSize();
            mListener.setTool(IActionBarListener.Tool.STROKE_ERASER, eraserSize, 0);
          }
        });

    mMenuWindow = new PopupWindow(menuLayout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mMenuWindow.setOutsideTouchable(true);
    mMenuWindow.setBackgroundDrawable(
        new BitmapDrawable()); // PopupWindow doesn't close on outside touch without background...
  }
Esempio n. 3
0
        public boolean onLongClick(View v) {
          eraserButton.setChecked(true);
          Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
          vibrator.vibrate(40);
          mEraseMenuWindow.show();

          return true;
        }
Esempio n. 4
0
  public void closeWindows() {
    mMenuWindow.dismiss();
    mEraseMenuWindow.dismiss();

    for (PenRadioButton b : penButtons) {
      b.closePenCreatorWindow();
    }
  }
Esempio n. 5
0
  public boolean hasOpenWindows() {
    if (mMenuWindow.isShowing()) {
      return true;
    }

    if (mEraseMenuWindow.isShowing()) {
      return true;
    }

    for (PenRadioButton b : penButtons) {
      if (b.getPenCreatorShowing()) {
        return true;
      }
    }

    return false;
  }