From c2146dc0f60c79da7cf1b9f261510c084dcd198e Mon Sep 17 00:00:00 2001 From: serso Date: Tue, 5 Jan 2016 00:25:36 +0100 Subject: [PATCH] Use Drag Button library --- android-app/build.gradle | 1 + android-app/misc/libs/drag-button-1.0.aar | Bin 0 -> 22980 bytes .../calculator/AndroidNumeralBase.java | 4 +- .../solovyev/android/calculator/BaseUi.java | 13 +- .../android/calculator/CalculatorButtons.java | 28 +- .../calculator/CursorDragProcessor.java | 13 +- .../calculator/DigitButtonDragProcessor.java | 13 +- .../calculator/EqualsDragProcessor.java | 13 +- .../calculator/drag/DirectionDragButton.java | 417 ------------------ .../android/calculator/drag/DragButton.java | 132 ------ .../calculator/drag/DragDirection.java | 31 -- .../android/calculator/drag/DragEvent.java | 61 --- .../android/calculator/drag/DragListener.java | 44 -- .../calculator/drag/DragListenerWrapper.java | 50 --- .../calculator/drag/SimpleDragListener.java | 140 ------ .../history/HistoryDragProcessor.java | 11 +- .../calculator/view/AngleUnitsButton.java | 2 +- .../calculator/view/DragListenerVibrator.java | 8 +- .../calculator/view/NumeralBasesButton.java | 2 +- .../wizard/ChooseModeWizardStep.java | 17 +- .../wizard/DragButtonWizardStep.java | 16 +- .../src/main/res/layout/cpp_app_button_0.xml | 2 +- .../src/main/res/layout/cpp_app_button_1.xml | 2 +- .../src/main/res/layout/cpp_app_button_2.xml | 2 +- .../src/main/res/layout/cpp_app_button_3.xml | 2 +- .../src/main/res/layout/cpp_app_button_4.xml | 2 +- .../src/main/res/layout/cpp_app_button_5.xml | 2 +- .../src/main/res/layout/cpp_app_button_7.xml | 2 +- .../src/main/res/layout/cpp_app_button_8.xml | 2 +- .../src/main/res/layout/cpp_app_button_9.xml | 2 +- .../res/layout/cpp_app_button_division.xml | 2 +- .../main/res/layout/cpp_app_button_dot.xml | 2 +- .../main/res/layout/cpp_app_button_empty.xml | 2 +- .../main/res/layout/cpp_app_button_equals.xml | 2 +- .../layout/cpp_app_button_equals_no_bg.xml | 2 +- .../res/layout/cpp_app_button_functions.xml | 2 +- .../res/layout/cpp_app_button_history.xml | 2 +- .../main/res/layout/cpp_app_button_left.xml | 2 +- .../main/res/layout/cpp_app_button_minus.xml | 2 +- .../layout/cpp_app_button_multiplication.xml | 2 +- .../res/layout/cpp_app_button_operators.xml | 2 +- .../main/res/layout/cpp_app_button_plus.xml | 2 +- .../main/res/layout/cpp_app_button_right.xml | 2 +- .../layout/cpp_app_button_round_brackets.xml | 2 +- .../main/res/layout/cpp_app_button_vars.xml | 2 +- .../layout/cpp_wizard_step_choose_mode.xml | 2 +- .../layout/cpp_wizard_step_drag_button.xml | 2 +- android-app/src/main/res/values/dimens.xml | 1 - .../src/main/res/values/preferences.xml | 9 - build.gradle | 3 +- 50 files changed, 96 insertions(+), 985 deletions(-) create mode 100644 android-app/misc/libs/drag-button-1.0.aar delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DirectionDragButton.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DragButton.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DragDirection.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DragEvent.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DragListener.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/DragListenerWrapper.java delete mode 100644 android-app/src/main/java/org/solovyev/android/calculator/drag/SimpleDragListener.java diff --git a/android-app/build.gradle b/android-app/build.gradle index 2685f6b7..51458120 100644 --- a/android-app/build.gradle +++ b/android-app/build.gradle @@ -71,6 +71,7 @@ dependencies { compile('ch.acra:acra:4.5.0') { exclude group: 'org.json' } + compile 'org.solovyev.android.views.dragbutton:drag-button:1.0@aar' compile 'org.solovyev.android:android-common-lists:1.1.18@aar' compile 'org.solovyev.android:android-common-core:1.1.18@aar' compile 'org.solovyev.android:android-common-other:1.1.18@aar' diff --git a/android-app/misc/libs/drag-button-1.0.aar b/android-app/misc/libs/drag-button-1.0.aar new file mode 100644 index 0000000000000000000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/android-app/src/main/java/org/solovyev/android/calculator/AndroidNumeralBase.java b/android-app/src/main/java/org/solovyev/android/calculator/AndroidNumeralBase.java index d78a1318..c71d425f 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/AndroidNumeralBase.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/AndroidNumeralBase.java @@ -24,8 +24,8 @@ package org.solovyev.android.calculator; import android.app.Activity; -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragDirection; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragDirection; import org.solovyev.android.calculator.units.CalculatorNumeralBase; import java.util.ArrayList; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java b/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java index 2380aebf..91c6b42f 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/BaseUi.java @@ -26,6 +26,7 @@ import android.app.Activity; import android.app.KeyguardManager; import android.content.Context; import android.content.SharedPreferences; +import android.graphics.PointF; import android.graphics.Typeface; import android.preference.PreferenceManager; import android.util.Log; @@ -34,11 +35,11 @@ import android.view.View; import android.widget.TextView; import org.solovyev.android.Views; -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.DragListener; -import org.solovyev.android.calculator.drag.SimpleDragListener; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.DragListener; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import org.solovyev.android.calculator.history.CalculatorHistoryState; import org.solovyev.android.calculator.history.HistoryDragProcessor; import org.solovyev.android.calculator.view.AngleUnitsButton; @@ -310,7 +311,7 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan private static class OperatorsDragProcessor implements SimpleDragListener.DragProcessor { @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { if (dragDirection == DragDirection.down) { App.getVibrator().vibrate(); Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_operators, null); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 5b5b43e7..dd34b3ab 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -26,6 +26,7 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.PointF; import android.preference.PreferenceManager; import android.util.Log; import android.util.TypedValue; @@ -33,23 +34,20 @@ import android.view.MotionEvent; import android.view.View; import android.widget.Button; import android.widget.RemoteViews; - +import jscl.AngleUnit; +import jscl.NumeralBase; import org.solovyev.android.Views; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.view.AngleUnitsButton; import org.solovyev.android.calculator.view.NumeralBasesButton; import org.solovyev.android.calculator.view.ScreenMetrics; -import org.solovyev.common.math.Point2d; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import jscl.AngleUnit; -import jscl.NumeralBase; - /** * User: serso * Date: 9/28/12 @@ -135,7 +133,7 @@ public final class CalculatorButtons { private final DigitButtonDragProcessor upDownProcessor = new DigitButtonDragProcessor(getKeyboard()); @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { final boolean result; if (dragDirection == DragDirection.left) { @@ -143,7 +141,7 @@ public final class CalculatorButtons { getKeyboard().roundBracketsButtonPressed(); result = true; } else { - result = upDownProcessor.processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent); + result = upDownProcessor.processDragEvent(dragDirection, dragButton, startPoint, motionEvent); } return result; @@ -162,7 +160,7 @@ public final class CalculatorButtons { @Override public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, - @Nonnull Point2d startPoint2d, + @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; @@ -195,7 +193,7 @@ public final class CalculatorButtons { @Override public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, - @Nonnull Point2d startPoint2d, + @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; @@ -221,7 +219,7 @@ public final class CalculatorButtons { } } } else if (dragDirection == DragDirection.left) { - result = processor.processDragEvent(dragDirection, dragButton, startPoint2d, motionEvent); + result = processor.processDragEvent(dragDirection, dragButton, startPoint, motionEvent); } } @@ -241,7 +239,7 @@ public final class CalculatorButtons { @Override public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, - @Nonnull Point2d startPoint2d, + @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; @@ -283,7 +281,7 @@ public final class CalculatorButtons { @Override public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, - @Nonnull Point2d startPoint2d, + @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java b/android-app/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java index a8ab1fc3..36675f24 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java @@ -22,13 +22,12 @@ package org.solovyev.android.calculator; +import android.graphics.PointF; import android.view.MotionEvent; - -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; -import org.solovyev.common.math.Point2d; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import javax.annotation.Nonnull; @@ -43,7 +42,7 @@ public class CursorDragProcessor implements SimpleDragListener.DragProcessor { } @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; if (dragButton instanceof DirectionDragButton) { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/DigitButtonDragProcessor.java b/android-app/src/main/java/org/solovyev/android/calculator/DigitButtonDragProcessor.java index e618aaf9..d57caf6e 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/DigitButtonDragProcessor.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/DigitButtonDragProcessor.java @@ -22,13 +22,12 @@ package org.solovyev.android.calculator; +import android.graphics.PointF; import android.view.MotionEvent; - -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; -import org.solovyev.common.math.Point2d; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import javax.annotation.Nonnull; @@ -47,7 +46,7 @@ public class DigitButtonDragProcessor implements SimpleDragListener.DragProcesso } @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { if (!(dragButton instanceof DirectionDragButton)) throw new AssertionError(); final String text = ((DirectionDragButton) dragButton).getText(dragDirection); calculatorKeyboard.buttonPressed(text); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/EqualsDragProcessor.java b/android-app/src/main/java/org/solovyev/android/calculator/EqualsDragProcessor.java index 81bdbf26..61c84ffb 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/EqualsDragProcessor.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/EqualsDragProcessor.java @@ -22,13 +22,12 @@ package org.solovyev.android.calculator; +import android.graphics.PointF; import android.view.MotionEvent; - -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; -import org.solovyev.common.math.Point2d; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import javax.annotation.Nonnull; @@ -43,7 +42,7 @@ public class EqualsDragProcessor implements SimpleDragListener.DragProcessor { } @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; if (dragButton instanceof DirectionDragButton) { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DirectionDragButton.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DirectionDragButton.java deleted file mode 100644 index 52261b1d..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DirectionDragButton.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.text.TextPaint; -import android.text.TextUtils; -import android.util.AttributeSet; - -import org.solovyev.common.math.Point2d; -import org.solovyev.common.text.NumberParser; -import org.solovyev.common.text.StringCollections; -import org.solovyev.common.text.Strings; - -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class DirectionDragButton extends DragButton { - - @Nonnull - private final static Float DEFAULT_DIRECTION_TEXT_SCALE_FLOAT = 0.33f; - - @Nonnull - private final static Integer DEFAULT_DIRECTION_TEXT_ALPHA = 140; - - private final static int DEFAULT_DIRECTION_TEXT_COLOR = Color.WHITE; - - @Nonnull - private final static String DEFAULT_DIRECTION_TEXT_SCALE = "0.33;0.33;0.33;0.33"; - @Nonnull - private final Map textDataMap = new EnumMap<>(GuiDragDirection.class); - @Nonnull - protected String directionTextScale = DEFAULT_DIRECTION_TEXT_SCALE; - @Nonnull - protected Integer directionTextAlpha = DEFAULT_DIRECTION_TEXT_ALPHA; - protected int directionTextColor = DEFAULT_DIRECTION_TEXT_COLOR; - private boolean initialized = false; - - public DirectionDragButton(Context context, @Nonnull AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - private void init(@Nonnull Context context, @Nonnull AttributeSet attrs) { - - TypedArray a = context.obtainStyledAttributes(attrs, org.solovyev.android.view.R.styleable.DirectionDragButton); - - for (int i = 0; i < a.getIndexCount(); i++) { - int attr = a.getIndex(i); - - if (a.hasValue(attr)) { - if (attr == org.solovyev.android.view.R.styleable.DirectionDragButton_directionTextColor) { - this.directionTextColor = a.getColor(attr, DEFAULT_DIRECTION_TEXT_COLOR); - } else if (attr == org.solovyev.android.view.R.styleable.DirectionDragButton_directionTextScale) { - this.directionTextScale = a.getString(attr); - } else if (attr == org.solovyev.android.view.R.styleable.DirectionDragButton_directionTextAlpha) { - this.directionTextAlpha = a.getInt(attr, DEFAULT_DIRECTION_TEXT_ALPHA); - } else { - // try drag direction text - for (GuiDragDirection guiDragDirection : GuiDragDirection.values()) { - if (guiDragDirection.getAttributeId() == attr) { - this.textDataMap.put(guiDragDirection, new DirectionTextData(guiDragDirection, a.getString(attr))); - break; - } - } - } - } - } - - a.recycle(); - - for (Map.Entry entry : getDirectionTextScales().entrySet()) { - final DirectionTextData td = textDataMap.get(entry.getKey()); - if (td != null) { - td.scale = entry.getValue(); - } - } - - initialized = true; - } - - @Override - public void onSizeChanged(int w, int h, int oldW, int oldH) { - measureText(); - } - - @Override - protected void onTextChanged(CharSequence text, int start, int before, int after) { - measureText(); - } - - protected void measureText() { - if (initialized) { - final Paint basePaint = getPaint(); - for (DirectionTextData textData : textDataMap.values()) { - initDirectionTextPaint(basePaint, textData); - textData.position = textData.direction.getTextPosition(textData.paint, basePaint, textData.text, getText(), getWidth(), getHeight()); - } - invalidate(); - } - } - - protected void initDirectionTextPaint(@Nonnull Paint basePaint, @Nonnull DirectionTextData textData) { - textData.init(basePaint, directionTextColor, directionTextAlpha); - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - - final TextPaint paint = getPaint(); - for (DirectionTextData td : textDataMap.values()) { - if (td.show) { - initDirectionTextPaint(paint, td); - final String text = td.text; - final Point2d position = td.position; - canvas.drawText(text, 0, text.length(), position.getX(), position.getY(), td.paint); - } - } - } - - @SuppressWarnings("UnusedDeclaration") - @Nullable - public String getTextUp() { - return getText(GuiDragDirection.up); - } - - @SuppressWarnings("UnusedDeclaration") - @Nullable - public String getTextDown() { - return getText(GuiDragDirection.down); - } - - @Nullable - public String getText(@Nonnull DragDirection direction) { - final GuiDragDirection guiDragDirection = GuiDragDirection.valueOf(direction); - return guiDragDirection == null ? null : getText(guiDragDirection); - } - - @SuppressWarnings("UnusedDeclaration") - public void showDirectionText(boolean show, @Nonnull DragDirection direction) { - final GuiDragDirection guiDragDirection = GuiDragDirection.valueOf(direction); - final DirectionTextData td = this.textDataMap.get(guiDragDirection); - if (td != null) { - td.show = show; - } - } - - public void setText(@Nullable String text, @Nonnull GuiDragDirection direction) { - if (!TextUtils.isEmpty(text)) { - final DirectionTextData data = new DirectionTextData(direction, text); - initDirectionTextPaint(getPaint(), data); - textDataMap.put(direction, data); - } else { - textDataMap.remove(direction); - } - measureText(); - } - - @Nullable - private String getText(@Nonnull GuiDragDirection direction) { - DirectionTextData td = textDataMap.get(direction); - if (td == null) { - return null; - } else { - if (td.show) { - return td.text; - } else { - return null; - } - } - } - - @Nonnull - public String getDirectionTextScale() { - return directionTextScale; - } - - @Nonnull - private Map getDirectionTextScales() { - final List scales = StringCollections.split(getDirectionTextScale(), ";", NumberParser.of(Float.class)); - - final Map result = new HashMap<>(); - for (GuiDragDirection direction : GuiDragDirection.values()) { - result.put(direction, DEFAULT_DIRECTION_TEXT_SCALE_FLOAT); - } - - if (scales.size() == 1) { - final Float scale = scales.get(0); - for (Map.Entry entry : result.entrySet()) { - entry.setValue(scale); - } - } else { - for (int i = 0; i < scales.size(); i++) { - for (GuiDragDirection direction : GuiDragDirection.values()) { - if (direction.getAttributePosition() == i) { - result.put(direction, scales.get(i)); - } - } - } - } - - return result; - } - - - public static enum GuiDragDirection { - up(DragDirection.up, 0) { - @Override - public int getAttributeId() { - return org.solovyev.android.view.R.styleable.DirectionDragButton_textUp; - } - - @Nonnull - @Override - public Point2d getTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, int w, int h) { - return getUpDownTextPosition(paint, basePaint, text, baseText, 1, w, h); - } - }, - down(DragDirection.down, 2) { - @Override - public int getAttributeId() { - return org.solovyev.android.view.R.styleable.DirectionDragButton_textDown; - } - - @Nonnull - @Override - public Point2d getTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, int w, int h) { - return getUpDownTextPosition(paint, basePaint, text, baseText, -1, w, h); - } - }, - left(DragDirection.left, 3) { - @Override - public int getAttributeId() { - return org.solovyev.android.view.R.styleable.DirectionDragButton_textLeft; - } - - @Nonnull - @Override - public Point2d getTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, int w, int h) { - return getLeftRightTextPosition(paint, basePaint, text, baseText, w, h, true); - } - }, - - right(DragDirection.right, 1) { - @Override - public int getAttributeId() { - return org.solovyev.android.view.R.styleable.DirectionDragButton_textRight; - } - - @Nonnull - @Override - public Point2d getTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, int w, int h) { - return getLeftRightTextPosition(paint, basePaint, text, baseText, w, h, false); - } - }; - - @Nonnull - private final DragDirection dragDirection; - - private final int attributePosition; - - GuiDragDirection(@Nonnull DragDirection dragDirection, int attributePosition) { - this.dragDirection = dragDirection; - this.attributePosition = attributePosition; - } - - @Nonnull - private static Point2d getLeftRightTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, CharSequence text, @Nonnull CharSequence baseText, int w, int h, boolean left) { - final Point2d result = new Point2d(); - - if (left) { - float width = paint.measureText(" "); - result.setX(width); - } else { - float width = paint.measureText(text.toString() + " "); - result.setX(w - width); - } - - float selfHeight = paint.ascent() + paint.descent(); - - basePaint.measureText(Strings.getNotEmpty(baseText, "|")); - - result.setY(h / 2 - selfHeight / 2); - - return result; - } - - @Nonnull - private static Point2d getUpDownTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, float direction, int w, int h) { - final Point2d result = new Point2d(); - - float width = paint.measureText(text.toString() + " "); - result.setX(w - width); - - float selfHeight = paint.ascent() + paint.descent(); - - basePaint.measureText(Strings.getNotEmpty(baseText, "|")); - - if (direction < 0) { - result.setY(h / 2 + h / 3 - selfHeight / 2); - } else { - result.setY(h / 2 - h / 3 - selfHeight / 2); - } - - return result; - } - - @Nullable - public static GuiDragDirection valueOf(@Nonnull DragDirection dragDirection) { - for (GuiDragDirection guiDragDirection : values()) { - if (guiDragDirection.dragDirection == dragDirection) { - return guiDragDirection; - } - } - return null; - } - - public abstract int getAttributeId(); - - public int getAttributePosition() { - return attributePosition; - } - - @Nonnull - public abstract Point2d getTextPosition(@Nonnull Paint paint, @Nonnull Paint basePaint, @Nonnull CharSequence text, CharSequence baseText, int w, int h); - } - - protected static class DirectionTextData { - - @Nonnull - private final GuiDragDirection direction; - @Nonnull - private final TextPaint paint = new TextPaint(); - @Nonnull - private String text; - @Nonnull - private Point2d position; - @Nonnull - private Float scale = 0.5f; - - private boolean show = true; - - private DirectionTextData(@Nonnull GuiDragDirection direction, @Nonnull String text) { - this.direction = direction; - this.text = text; - } - - protected void init(@Nonnull Paint basePaint, - int color, - int alpha) { - paint.set(basePaint); - paint.setColor(color); - paint.setAlpha(alpha); - paint.setTextSize(basePaint.getTextSize() * scale); - } - - @Nonnull - public GuiDragDirection getDirection() { - return direction; - } - - @Nonnull - public String getText() { - return text; - } - - @Nonnull - public Point2d getPosition() { - return position; - } - - @Nonnull - public TextPaint getPaint() { - return paint; - } - - @Nonnull - public Float getScale() { - return scale; - } - - public boolean isShow() { - return show; - } - } - -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragButton.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DragButton.java deleted file mode 100644 index c99d11a5..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragButton.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import android.content.Context; -import android.graphics.Canvas; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.widget.Button; - -import org.solovyev.android.view.AndroidViewUtils; -import org.solovyev.common.math.Point2d; -import org.solovyev.common.text.Strings; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class DragButton extends Button { - - @Nullable - private Point2d startPoint = null; - - @Nullable - private DragListener onDragListener; - - private boolean showText = true; - - @Nullable - private CharSequence textBackup; - - public DragButton(@Nonnull Context context, @Nonnull AttributeSet attrs) { - super(context, attrs); - } - - public void setOnDragListener(@Nullable DragListener onDragListener) { - this.onDragListener = onDragListener; - } - - @Override - public boolean onTouchEvent(@Nonnull MotionEvent event) { - boolean consumed = false; - - // in order to avoid possible NPEs - final Point2d localStartPoint = startPoint; - final DragListener localOnDragListener = onDragListener; - - if (localOnDragListener != null) { - // only if onDrag() listener specified - - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - // start tracking: set start point - startPoint = new Point2d(event.getX(), event.getY()); - break; - - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_UP: - // stop tracking - - startPoint = null; - if (localStartPoint != null) { - consumed = localOnDragListener.onDrag(DragButton.this, new DragEvent(localStartPoint, event)); - if (consumed && localOnDragListener.isSuppressOnClickEvent()) { - final MotionEvent newEvent = MotionEvent.obtain(event); - newEvent.setAction(MotionEvent.ACTION_CANCEL); - super.onTouchEvent(newEvent); - newEvent.recycle(); - return true; - } - } - break; - } - } - - return super.onTouchEvent(event) || consumed; - } - - @Override - public boolean dispatchTouchEvent(@Nonnull MotionEvent event) { - return super.dispatchTouchEvent(event); - } - - @Override - protected void onDraw(Canvas canvas) { - CharSequence text = getText(); - if (!Strings.isEmpty(text)) { - super.onDraw(canvas); - } else { - if (!AndroidViewUtils.drawDrawables(canvas, this)) { - super.onDraw(canvas); - } - } - } - - - public boolean isShowText() { - return showText; - } - - public void setShowText(boolean showText) { - if (this.showText != showText) { - if (showText) { - setText(textBackup); - textBackup = null; - } else { - textBackup = this.getText(); - setText(null); - } - this.showText = showText; - } - } -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragDirection.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DragDirection.java deleted file mode 100644 index c1d45d4e..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragDirection.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -public enum DragDirection { - - up, - down, - left, - right; -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragEvent.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DragEvent.java deleted file mode 100644 index 032d6d3e..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import android.view.MotionEvent; - -import org.solovyev.common.math.Point2d; - -import javax.annotation.Nonnull; - -public class DragEvent { - - @Nonnull - private final Point2d startPoint; - - @Nonnull - private final MotionEvent motionEvent; - - public DragEvent(@Nonnull Point2d startPoint, @Nonnull MotionEvent motionEvent) { - this.startPoint = startPoint; - this.motionEvent = motionEvent; - } - - /** - * @return motion event started at start point - */ - @Nonnull - public MotionEvent getMotionEvent() { - return motionEvent; - } - - /** - * @return start point of dragging - */ - @Nonnull - public Point2d getStartPoint() { - return startPoint; - } - - -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListener.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListener.java deleted file mode 100644 index 8700397a..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListener.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import java.util.EventListener; - -import javax.annotation.Nonnull; - - -public interface DragListener extends EventListener { - - /** - * @return 'true': if drag event has taken place (i.e. onDrag() method returned true) then click action will be suppresed - */ - boolean isSuppressOnClickEvent(); - - /** - * @param dragButton drag button object for which onDrag listener was set - * @param event drag event - * @return 'true' if drag event occurred, 'false' otherwise - */ - boolean onDrag(@Nonnull DragButton dragButton, @Nonnull DragEvent event); - -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListenerWrapper.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListenerWrapper.java deleted file mode 100644 index 4ca9dfd6..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/DragListenerWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import javax.annotation.Nonnull; - -/** - * User: serso - * Date: 10/26/11 - * Time: 10:37 PM - */ -public class DragListenerWrapper implements DragListener { - - @Nonnull - private final DragListener dragListener; - - public DragListenerWrapper(@Nonnull DragListener dragListener) { - this.dragListener = dragListener; - } - - @Override - public boolean isSuppressOnClickEvent() { - return this.dragListener.isSuppressOnClickEvent(); - } - - @Override - public boolean onDrag(@Nonnull DragButton dragButton, @Nonnull DragEvent event) { - return this.dragListener.onDrag(dragButton, event); - } -} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/drag/SimpleDragListener.java b/android-app/src/main/java/org/solovyev/android/calculator/drag/SimpleDragListener.java deleted file mode 100644 index 5b8a4a2d..00000000 --- a/android-app/src/main/java/org/solovyev/android/calculator/drag/SimpleDragListener.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.drag; - -import android.content.Context; -import android.view.MotionEvent; - -import org.solovyev.android.calculator.R; -import org.solovyev.common.MutableObject; -import org.solovyev.common.interval.Interval; -import org.solovyev.common.interval.Intervals; -import org.solovyev.common.math.Maths; -import org.solovyev.common.math.Point2d; - -import java.util.EnumMap; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class SimpleDragListener implements DragListener { - - @Nonnull - private static final Point2d axis = new Point2d(0, 1); - - @Nonnull - private static final EnumMap> sAngleIntervals = new EnumMap<>(DragDirection.class); - - static { - for (DragDirection direction : DragDirection.values()) { - sAngleIntervals.put(direction, makeAngleInterval(direction, 0, 45)); - } - } - - @Nonnull - private final DragProcessor processor; - - private final float minDistancePxs; - - public SimpleDragListener(@Nonnull DragProcessor processor, @Nonnull Context context) { - this.processor = processor; - this.minDistancePxs = context.getResources().getDimensionPixelSize(R.dimen.cpp_min_drag_distance); - } - - @Nonnull - private static Interval makeAngleInterval(@Nonnull DragDirection direction, - float leftLimit, - float rightLimit) { - final Float newLeftLimit; - final Float newRightLimit; - switch (direction) { - case up: - newLeftLimit = 180f - rightLimit; - newRightLimit = 180f - leftLimit; - break; - case down: - newLeftLimit = leftLimit; - newRightLimit = rightLimit; - break; - case left: - newLeftLimit = 90f - rightLimit; - newRightLimit = 90f + rightLimit; - break; - case right: - newLeftLimit = 90f - rightLimit; - newRightLimit = 90f + rightLimit; - break; - default: - throw new AssertionError(); - } - - return Intervals.newClosedInterval(newLeftLimit, newRightLimit); - } - - @Override - public boolean onDrag(@Nonnull DragButton dragButton, @Nonnull DragEvent event) { - boolean consumed = false; - - final MotionEvent motionEvent = event.getMotionEvent(); - - final Point2d start = event.getStartPoint(); - final Point2d end = new Point2d(motionEvent.getX(), motionEvent.getY()); - final float distance = Maths.getDistance(start, end); - - final MutableObject right = new MutableObject<>(); - final double angle = Math.toDegrees(Maths.getAngle(start, Maths.sum(start, axis), end, right)); - - final long duration = motionEvent.getEventTime() - motionEvent.getDownTime(); - final DragDirection direction = getDirection(distance, (float) angle, right.getObject()); - if (direction != null && duration > 40 && duration < 2500) { - consumed = processor.processDragEvent(direction, dragButton, start, motionEvent); - } - - return consumed; - } - - @Nullable - private DragDirection getDirection(float distance, float angle, boolean right) { - if (distance > minDistancePxs) { - for (DragDirection direction : DragDirection.values()) { - final Interval angleInterval = sAngleIntervals.get(direction); - final boolean wrongDirection = (direction == DragDirection.left && right) || - (direction == DragDirection.right && !right); - if (!wrongDirection && angleInterval.contains(angle)) { - return direction; - } - } - } - return null; - } - - @Override - public boolean isSuppressOnClickEvent() { - return true; - } - - public interface DragProcessor { - - boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent); - } -} \ No newline at end of file diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/HistoryDragProcessor.java b/android-app/src/main/java/org/solovyev/android/calculator/history/HistoryDragProcessor.java index de3abb4f..9b3f5400 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/history/HistoryDragProcessor.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/history/HistoryDragProcessor.java @@ -22,16 +22,15 @@ package org.solovyev.android.calculator.history; +import android.graphics.PointF; import android.util.Log; import android.view.MotionEvent; - import org.solovyev.android.calculator.App; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import org.solovyev.common.history.HistoryAction; import org.solovyev.common.history.HistoryControl; -import org.solovyev.common.math.Point2d; import javax.annotation.Nonnull; @@ -50,7 +49,7 @@ public class HistoryDragProcessor implements SimpleDragListener.DragProcessor } @Override - public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull Point2d startPoint2d, @Nonnull MotionEvent motionEvent) { + public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { boolean result = false; Log.d(String.valueOf(dragButton.getId()), "History on drag event start: " + dragDirection); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java b/android-app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java index 36653bde..c9e224e8 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java @@ -30,7 +30,7 @@ import android.util.AttributeSet; import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.drag.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DirectionDragButton; import javax.annotation.Nonnull; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/view/DragListenerVibrator.java b/android-app/src/main/java/org/solovyev/android/calculator/view/DragListenerVibrator.java index 39c77023..0058b981 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/view/DragListenerVibrator.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/view/DragListenerVibrator.java @@ -25,10 +25,10 @@ package org.solovyev.android.calculator.view; import android.content.SharedPreferences; import android.os.Vibrator; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragEvent; -import org.solovyev.android.calculator.drag.DragListener; -import org.solovyev.android.calculator.drag.DragListenerWrapper; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragEvent; +import org.solovyev.android.views.dragbutton.DragListener; +import org.solovyev.android.views.dragbutton.DragListenerWrapper; import org.solovyev.android.view.VibratorContainer; import javax.annotation.Nonnull; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java b/android-app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java index ffb231ae..e7d21544 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java @@ -29,7 +29,7 @@ import android.util.AttributeSet; import org.solovyev.android.calculator.Locator; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.drag.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DirectionDragButton; import javax.annotation.Nonnull; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java index faa40ebe..5dd97429 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java @@ -30,13 +30,16 @@ import android.widget.TextView; import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.drag.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DirectionDragButton; import javax.annotation.Nonnull; import static org.solovyev.android.calculator.CalculatorApplication.getPreferences; import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer; import static org.solovyev.android.calculator.wizard.CalculatorMode.simple; +import static org.solovyev.android.views.dragbutton.DirectionDragButton.Direction.down; +import static org.solovyev.android.views.dragbutton.DirectionDragButton.Direction.left; +import static org.solovyev.android.views.dragbutton.DirectionDragButton.Direction.up; /** * User: serso @@ -72,13 +75,13 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView. boolean simple = mode == CalculatorMode.simple; description.setText(simple ? R.string.cpp_wizard_mode_simple_description : R.string.cpp_wizard_mode_engineer_description); if (simple) { - button.setText("", DirectionDragButton.GuiDragDirection.up); - button.setText("", DirectionDragButton.GuiDragDirection.down); - button.setText("", DirectionDragButton.GuiDragDirection.left); + button.setText("", up); + button.setText("", down); + button.setText("", left); } else { - button.setText("sin", DirectionDragButton.GuiDragDirection.up); - button.setText("ln", DirectionDragButton.GuiDragDirection.down); - button.setText("i", DirectionDragButton.GuiDragDirection.left); + button.setText("sin", up); + button.setText("ln", down); + button.setText("i", left); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java index 17075542..5a911b0b 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java @@ -22,23 +22,21 @@ package org.solovyev.android.calculator.wizard; +import android.graphics.PointF; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.TextView; - import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.drag.DirectionDragButton; -import org.solovyev.android.calculator.drag.DragButton; -import org.solovyev.android.calculator.drag.DragDirection; -import org.solovyev.android.calculator.drag.SimpleDragListener; -import org.solovyev.common.math.Point2d; - -import java.util.Arrays; +import org.solovyev.android.views.dragbutton.DirectionDragButton; +import org.solovyev.android.views.dragbutton.DragButton; +import org.solovyev.android.views.dragbutton.DragDirection; +import org.solovyev.android.views.dragbutton.SimpleDragListener; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.util.Arrays; public class DragButtonWizardStep extends WizardFragment { @@ -174,7 +172,7 @@ public class DragButtonWizardStep extends WizardFragment { @Override public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, - @Nonnull Point2d startPoint2d, + @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) { if (dragDirection == DragDirection.up || dragDirection == DragDirection.down) { App.getVibrator().vibrate(); diff --git a/android-app/src/main/res/layout/cpp_app_button_0.xml b/android-app/src/main/res/layout/cpp_app_button_0.xml index a3f39a45..72c85266 100644 --- a/android-app/src/main/res/layout/cpp_app_button_0.xml +++ b/android-app/src/main/res/layout/cpp_app_button_0.xml @@ -22,7 +22,7 @@ ~ Site: http://se.solovyev.org --> - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/android-app/src/main/res/layout/cpp_app_button_equals.xml b/android-app/src/main/res/layout/cpp_app_button_equals.xml index 49ffc0b5..b96040ce 100644 --- a/android-app/src/main/res/layout/cpp_app_button_equals.xml +++ b/android-app/src/main/res/layout/cpp_app_button_equals.xml @@ -21,7 +21,7 @@ ~ Email: se.solovyev@gmail.com ~ Site: http://se.solovyev.org --> - - - - - - - - - - - - - - 5dp 5dp 5dp - 25dp 1dp \ No newline at end of file diff --git a/android-app/src/main/res/values/preferences.xml b/android-app/src/main/res/values/preferences.xml index 40830989..5abe7118 100644 --- a/android-app/src/main/res/values/preferences.xml +++ b/android-app/src/main/res/values/preferences.xml @@ -21,15 +21,6 @@ --> - org.solovyev.android.calculator.DragButtonCalibrationActivity_distance - 35;350 - - org.solovyev.android.calculator.DragButtonCalibrationActivity_angle - 0;45 - - org.solovyev.android.calculator.DragButtonCalibrationActivity_duration - 40;2500 - org.solovyev.android.calculator.CalculatorModel_result_precision 5 diff --git a/build.gradle b/build.gradle index 980e5236..022b3dd6 100644 --- a/build.gradle +++ b/build.gradle @@ -19,9 +19,8 @@ public String android_min_sdk_version() { } buildscript { - repositories { - mavenCentral() + jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0'