/**
   * Zooms in or out of the board by scalling the size of each Box
   *
   * @param big increase or decrease the size
   */
  public void resizeMe(int big) {
    double resizeButton = 0.0;
    double resizeText = 0.0;
    boolean myCondition = false;
    if (big == 0) {
      resizeButton = 1.25;
      resizeText = 0.3125;
      myCondition = true;
    } else {
      resizeButton = 0.8;
      resizeText = 0.3125;
      myCondition = false;
    }

    for (int x = 0; x < this.getX(); ++x) {
      for (int y = 0; y < this.getY(); ++y) {
        Button change = this.board[x][y];
        LayoutParams params = change.getLayoutParams();

        if (((change.getHeight() * resizeButton > 70.0) && !myCondition)
            || ((change.getHeight() * resizeButton < 130.0) && myCondition)) {
          params.height = (int) (change.getHeight() * resizeButton);
          params.width = (int) (change.getWidth() * resizeButton);
          change.setLayoutParams(params);
          change.setTextSize((float) (params.height * resizeText));
        }
      }
    }
  }
Example #2
0
  private void drawZoomLevel(Canvas canvas) {
    String zoomText = view.getZoom() + "";
    float frac = view.getFloatZoom() - view.getZoom();
    while (frac > OsmandMapTileView.ZOOM_DELTA_1) {
      frac -= OsmandMapTileView.ZOOM_DELTA_1;
      zoomText += "'";
    }
    float length = zoomTextPaint.measureText(zoomText);
    if (zoomShadow.getBounds().width() == 0) {
      zoomShadow.setBounds(
          zoomInButton.getLeft() - 2,
          zoomInButton.getTop() - (int) (18 * scaleCoefficient),
          zoomInButton.getRight(),
          zoomInButton.getBottom());
    }
    zoomShadow.draw(canvas);

    ShadowText.draw(
        zoomText,
        canvas,
        zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
        zoomInButton.getTop() + 4 * scaleCoefficient,
        zoomTextPaint,
        shadowColor);
  }
  public void onClick(View view) {

    int id = view.getId();

    switch (id) {
      case R.id.delete:
        {
          // mParent.removeView(deleteSelf);
          deleteSelf.layout(10, 10, deleteSelf.getWidth(), deleteSelf.getHeight());
          break;
        }

      case R.id.delete_parent:
        {
          ((ViewGroup) mParent.getParent()).removeView(mParent);
          break;
        }

      case R.id.visible_parent:
        {
          mParent.setVisibility(View.GONE);
          break;
        }

      case R.id.visible_self:
        {
          visibleSelf.setVisibility(View.GONE);
          break;
        }
    }
  }
  private void SetDynamicButtonSize(MotionEvent event, Button bouton) {
    int largeur = bouton.getWidth();
    int hauteur = bouton.getHeight();

    float x = event.getX();
    float y = event.getY();

    bouton.setTextSize(Math.abs(x - largeur / 2) + Math.abs(y - hauteur / 2));
  }
Example #5
0
 private void lockButtonSizes(int NUM_ROWS, int NUM_COLS) {
   for (int row = 0; row != NUM_ROWS; row++) {
     for (int col = 0; col != NUM_COLS; col++) {
       Button button = buttons[row][col];
       int width = button.getWidth();
       button.setMinWidth(width);
       button.setMaxWidth(width);
       int height = button.getHeight();
       button.setMinHeight(height);
       button.setMaxHeight(height);
     }
   }
 }
  private void setMarginsOnBtns(int midScreen) {
    Button btn = (Button) this.findViewById(R.id.playBtn);
    RelativeLayout.LayoutParams playParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    playParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    playParams.setMargins(midScreen + 100, 0, 0, 0);
    btn.setLayoutParams(playParams);

    Button btn2 = (Button) this.findViewById(R.id.passBtn);
    RelativeLayout.LayoutParams passParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    passParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    passParams.setMargins(midScreen - 100 - btn2.getWidth(), 0, 0, 0);
    btn2.setLayoutParams(passParams);
  }
  public void testColorNewColorButtonChangesStandard() {
    int numberOfColorsToTest = 20;

    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));
    mSolo.clickOnView(mButtonTopColor);
    mSolo.sleep(COLOR_PICKER_DIALOGUE_APPERANCE_DELAY);

    TypedArray presetColors = getActivity().getResources().obtainTypedArray(R.array.preset_colors);

    numberOfColorsToTest = Math.min(numberOfColorsToTest, presetColors.length());

    for (int counterColors = 0; counterColors < numberOfColorsToTest; counterColors++) {
      Log.d(PaintroidApplication.TAG, "test color # " + counterColors);
      Button colorButton = mSolo.getButton(counterColors);

      if (!(colorButton.getParent() instanceof TableRow)) {
        Log.d(
            PaintroidApplication.TAG, "button parent is no table row: " + colorButton.getParent());
        continue;
      }

      mSolo.clickOnButton(counterColors);
      mSolo.sleep(200);
      int colorColor = presetColors.getColor(counterColors, 0);

      String buttonNewColorName = getActivity().getResources().getString(R.string.done);
      Button button = mSolo.getButton(buttonNewColorName);
      Drawable drawable = button.getBackground();
      int buttonTextColor = button.getCurrentTextColor();

      Bitmap bitmap = drawableToBitmap(drawable, button.getWidth(), button.getHeight());
      int buttonColor = bitmap.getPixel(1, 1);
      assertEquals("New Color button has unexpected color", colorColor, buttonColor);
      assertTrue(
          "Button textcolor and backgroundcolor ar the same", buttonColor != buttonTextColor);
      assertTrue(
          "Unexpected text color in butten text",
          (buttonTextColor == Color.BLACK || buttonTextColor == Color.WHITE));
      assertTrue(
          "Color not set yet", colorColor == mTopBar.getCurrentTool().getDrawPaint().getColor());
      bitmap.recycle();
      bitmap = null;
    }
  }
  private void clearAnimation() {
    final Animator startAnimator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      final int revealSize = resultContainerView.getWidth();
      final int[] location = new int[2];
      deleteButton.getLocationInWindow(location);
      final int centerX = location[0] + deleteButton.getWidth() / 2;
      startAnimator =
          ViewAnimationUtils.createCircularReveal(
              revealView, centerX, resultContainerView.getHeight(), 0, revealSize);
    } else {
      startAnimator =
          ObjectAnimator.ofFloat(
              revealView, View.TRANSLATION_Y, resultContainerView.getHeight(), 0);
    }
    startAnimator.setDuration(ANIMATION_DURATION_CLEAR_START);

    final Animator endAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 1, 0);

    final AnimatorSet animator = new AnimatorSet();
    animator.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            revealView.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            revealView.setVisibility(View.GONE);
            revealView.setAlpha(1);
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animator.playSequentially(startAnimator, endAnimator);
    animator.start();
  }
  private void hideLogInButtonAndShowPanel() {
    int cx = (logInButton.getLeft() + logInButton.getRight()) / 2;
    int cy = logInButton.getBottom();

    // get the final radius for the clipping circle
    int initialRadius = logInButton.getWidth();

    // create and start the animator for this view
    // (the start radius is zero)
    ValueAnimator anim =
        ViewAnimationUtils.createCircularReveal(logInButton, cx, cy, initialRadius, 0);
    anim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            logInButton.setVisibility(View.GONE);
            showLoginPanel();
          }
        });

    anim.setDuration(500).start();
  }
Example #10
0
 private void gridButtonClicked(int col, int row, int NUM_ROWS, int NUM_COLS) {
   String tokens[] = tokenize(dataStrings[currentSelected]);
   String infoText = formatInfo(tokens);
   data.setText(infoText);
   Button button = buttons[row][col];
   // Lock Button Sizes: lockButtonSizes(NUM_ROWS, NUM_COLS); // Does not scale image.
   // button.setBackgroundResource(R.drawable.­action_lock_pink); // Scale image to button: Only
   // works in JellyBean!
   // Image from Crystal Clear icon set, under LGPL // http://commons.wikimedia.org/wiki/Cry...
   int newWidth = button.getWidth();
   int newHeight = button.getHeight();
   buttons[row][col].setPressed(true);
   money.setText(Html.fromHtml(getMoney()), TextView.BufferType.SPANNABLE);
   science.setText(Html.fromHtml(getScience()), TextView.BufferType.SPANNABLE);
   marketing.setText(Html.fromHtml(getMarketing()), TextView.BufferType.SPANNABLE);
   income.setText(Html.fromHtml(getIncome()), TextView.BufferType.SPANNABLE);
   // Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(),
   // R.drawable.action_lock_pink);
   // Bitmap scaledBitmap = Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, true);
   // Resources resource = getResources();
   // button.setBackground(new BitmapDrawable(resource, scaledBitmap)); // Change text on button:
   // button.setText();
 }
Example #11
0
  public void resizeMe(int big) {
    double resizeButton;
    double resizeText;
    boolean myCondition;
    boolean isSizeChanged = false;
    if (big == 0) {
      resizeButton = 1.25;
      resizeText = 0.175;
      // resizeText = 1;
      myCondition = true;
    } else {
      resizeButton = 0.8;
      resizeText = 0.175;
      myCondition = false;
    }

    for (int x = 0; x < minesweeperGame.getRows(); ++x) {
      for (int y = 0; y < minesweeperGame.getCols(); ++y) {
        Button change = minesweeperGame.board[x][y];
        ViewGroup.LayoutParams params = change.getLayoutParams();
        if (params != null) {
          if (((change.getHeight() * resizeButton > 50.0) && !myCondition)
              || ((change.getHeight() * resizeButton < 100.0) && myCondition)) {
            params.height = (int) (change.getHeight() * resizeButton);
            params.width = (int) (change.getWidth() * resizeButton);
            change.setLayoutParams(params);
            change.setTextSize((float) (params.height * resizeText));
            isSizeChanged = true;
          }
        }
      }
    }

    if (isSizeChanged) {
      minesweeperGame.createNewImages();
    }
  }
Example #12
0
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.pattern_done) {
      endTime = new SimpleDateFormat("mmss").format(Calendar.getInstance().getTime());
      timePassed = calculateTimePassedInSeconds(startTime, endTime);
      Log.d("timePassed", String.valueOf(timePassed));
      int points = calculatePoints();
      Log.d("score", String.valueOf(points));
      saveToSharedPreference(points);
      // startActivity(new Intent(this, Clock.class));
      // startActivity(new Intent(this, DrawingActivity.class));
      startActivity(new Intent(this, NumberRecall.class));
    } else if (v.getId() == R.id.pattern_redo) {
      // setContentView(R.layout.activity_pattern_draw);
      // showArrows();
      Intent intent = getIntent();
      finish();
      startActivity(intent);
    } else if (v.getId() == R.id.pattern_button5
        || v.getId() == R.id.pattern_buttonK
        || v.getId() == R.id.pattern_button6) {
      Toast.makeText(this, "Please start tapping from 'L'  ", Toast.LENGTH_LONG).show();
    } else {
      int[] location = new int[2];
      String text = "";
      float centerX = 0;
      float centerY = 0;
      int id = v.getId();
      Button b = (Button) findViewById(id);
      text = b.getText().toString();
      stringBuilder.append(text);
      b.getLocationOnScreen(location);
      centerX = location[0] + b.getWidth() / 2;
      centerY = location[1];
      Log.d("text , x , y", text + " " + centerX + " " + centerY);
      if (buttonClickCount == 0) {
        previousButtonPosition[0] = centerX;
        previousButtonPosition[1] = centerY;
      } else if (buttonClickCount == 1) {
        currentButtonPosition[0] = centerX;
        currentButtonPosition[1] = centerY;
      } else {
        previousButtonPosition[0] = currentButtonPosition[0];
        previousButtonPosition[1] = currentButtonPosition[1];
        currentButtonPosition[0] = centerX;
        currentButtonPosition[1] = centerY;
      }

      if (buttonClickCount > 0) {
        myview =
            new LineView(
                this,
                previousButtonPosition[0],
                previousButtonPosition[1],
                currentButtonPosition[0],
                currentButtonPosition[1]);
        addContentView(myview, new ViewGroup.LayoutParams(1000, 1000));
      }
      buttonClickCount++;
    }
  }
Example #13
0
  public void showArrows() {
    int[] location5 = new int[2];
    int[] locationK = new int[2];
    int[] location6 = new int[2];
    int[] locationL = new int[2];
    int location5CenterX,
        location5CenterY,
        locationKCenterX,
        locationKCenterY,
        location6CenterX,
        location6CenterY,
        locationLCenterX,
        locationLCenterY;
    Button button5 = (Button) findViewById(R.id.pattern_button5);
    Button buttonK = (Button) findViewById(R.id.pattern_buttonK);
    Button button6 = (Button) findViewById(R.id.pattern_button6);
    Button buttonL = (Button) findViewById(R.id.pattern_buttonL);

    button5.getLocationOnScreen(location5);
    location5CenterX = location5[0] + button5.getWidth() / 2;
    location5CenterY = location5[1];

    buttonK.getLocationOnScreen(locationK);
    locationKCenterX = locationK[0] + buttonK.getWidth() / 2;
    locationKCenterY = locationK[1];

    button6.getLocationOnScreen(location6);
    location6CenterX = location6[0] + button6.getWidth() / 2;
    location6CenterY = location6[1];

    buttonL.getLocationOnScreen(locationL);
    locationLCenterX = locationL[0] + buttonL.getWidth() / 2;
    locationLCenterY = locationL[1];

    arrowView =
        new ArrowView(
            getApplicationContext(),
            location5CenterX,
            location5CenterY,
            locationKCenterX,
            locationKCenterY);
    addContentView(arrowView, new ViewGroup.LayoutParams(1000, 1000));

    arrowView =
        new ArrowView(
            getApplicationContext(),
            locationKCenterX,
            locationKCenterY,
            location6CenterX,
            location6CenterY);
    addContentView(arrowView, new ViewGroup.LayoutParams(1000, 1000));

    arrowView =
        new ArrowView(
            getApplicationContext(),
            location6CenterX,
            location6CenterY,
            locationLCenterX,
            locationLCenterY);
    addContentView(arrowView, new ViewGroup.LayoutParams(1000, 1000));
  }