Vibrator has been removed from the app
This commit is contained in:
parent
0c78ac3322
commit
7774d87d97
@ -64,7 +64,7 @@ dependencies {
|
||||
compile('ch.acra:acra:4.7.0') {
|
||||
exclude group: 'org.json'
|
||||
}
|
||||
compile 'org.solovyev.android.views.dragbutton:drag-button:1.0@aar'
|
||||
compile 'org.solovyev.android.views.dragbutton:drag-button:1.1@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'
|
||||
|
Binary file not shown.
BIN
app/misc/libs/drag-button-1.1.aar
Normal file
BIN
app/misc/libs/drag-button-1.1.aar
Normal file
Binary file not shown.
@ -3,7 +3,6 @@
|
||||
package="org.solovyev.android.calculator"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
@ -1,105 +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;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 11/18/12
|
||||
* Time: 6:05 PM
|
||||
*/
|
||||
public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
|
||||
|
||||
@Nonnull
|
||||
private final CalculatorKeyboard calculatorKeyboard;
|
||||
|
||||
@Nonnull
|
||||
private final Context context;
|
||||
|
||||
@android.support.annotation.Nullable
|
||||
private org.solovyev.android.calculator.Vibrator vibrator;
|
||||
|
||||
public AndroidCalculatorKeyboard(@Nonnull Application application,
|
||||
@Nonnull CalculatorKeyboard calculatorKeyboard) {
|
||||
this.context = application;
|
||||
this.calculatorKeyboard = calculatorKeyboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buttonPressed(@Nullable String text) {
|
||||
App.getGa().onButtonPressed(text);
|
||||
final boolean processed = calculatorKeyboard.buttonPressed(text);
|
||||
if (processed) {
|
||||
vibrate();
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
private void vibrate() {
|
||||
if (vibrator == null) {
|
||||
vibrator = App.getVibrator();
|
||||
}
|
||||
vibrator.vibrate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roundBracketsButtonPressed() {
|
||||
vibrate();
|
||||
calculatorKeyboard.roundBracketsButtonPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteButtonPressed() {
|
||||
vibrate();
|
||||
calculatorKeyboard.pasteButtonPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearButtonPressed() {
|
||||
vibrate();
|
||||
calculatorKeyboard.clearButtonPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyButtonPressed() {
|
||||
vibrate();
|
||||
calculatorKeyboard.copyButtonPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveCursorLeft() {
|
||||
vibrate();
|
||||
calculatorKeyboard.moveCursorLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveCursorRight() {
|
||||
vibrate();
|
||||
calculatorKeyboard.moveCursorRight();
|
||||
}
|
||||
}
|
@ -103,8 +103,6 @@ public final class App {
|
||||
@Nullable
|
||||
private static Boolean lg = null;
|
||||
@Nonnull
|
||||
private static volatile Vibrator vibrator;
|
||||
@Nonnull
|
||||
private static volatile ScreenMetrics screenMetrics;
|
||||
|
||||
private App() {
|
||||
@ -150,7 +148,6 @@ public final class App {
|
||||
}
|
||||
});
|
||||
App.broadcaster = new CalculatorBroadcaster(application, preferences);
|
||||
App.vibrator = new Vibrator(application, preferences);
|
||||
App.screenMetrics = new ScreenMetrics(application);
|
||||
App.languages.init(App.preferences);
|
||||
|
||||
@ -273,11 +270,6 @@ public final class App {
|
||||
return isLg() && Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Vibrator getVibrator() {
|
||||
return vibrator;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ScreenMetrics getScreenMetrics() {
|
||||
return screenMetrics;
|
||||
|
@ -312,7 +312,6 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
|
||||
@Override
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.support.annotation.IdRes;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
@ -31,47 +32,49 @@ final class ButtonOnClickListener implements View.OnClickListener {
|
||||
case R.id.cpp_button_plus:
|
||||
case R.id.cpp_button_right:
|
||||
case R.id.cpp_button_round_brackets:
|
||||
onClick(((Button) v).getText().toString());
|
||||
onClick(v, ((Button) v).getText().toString());
|
||||
break;
|
||||
case R.id.cpp_button_clear:
|
||||
onClick(CalculatorSpecialButton.clear);
|
||||
onClick(v, CalculatorSpecialButton.clear);
|
||||
break;
|
||||
case R.id.cpp_button_functions:
|
||||
onClick(CalculatorSpecialButton.functions);
|
||||
onClick(v, CalculatorSpecialButton.functions);
|
||||
break;
|
||||
case R.id.cpp_button_history:
|
||||
onClick(CalculatorSpecialButton.history);
|
||||
onClick(v, CalculatorSpecialButton.history);
|
||||
break;
|
||||
case R.id.cpp_button_erase:
|
||||
onClick(CalculatorSpecialButton.erase);
|
||||
onClick(v, CalculatorSpecialButton.erase);
|
||||
break;
|
||||
case R.id.cpp_button_paste:
|
||||
onClick(CalculatorSpecialButton.paste);
|
||||
onClick(v, CalculatorSpecialButton.paste);
|
||||
break;
|
||||
case R.id.cpp_button_copy:
|
||||
onClick(CalculatorSpecialButton.copy);
|
||||
onClick(v, CalculatorSpecialButton.copy);
|
||||
break;
|
||||
case R.id.cpp_button_like:
|
||||
onClick(CalculatorSpecialButton.like);
|
||||
onClick(v, CalculatorSpecialButton.like);
|
||||
break;
|
||||
case R.id.cpp_button_operators:
|
||||
onClick(CalculatorSpecialButton.operators);
|
||||
onClick(v, CalculatorSpecialButton.operators);
|
||||
break;
|
||||
case R.id.cpp_button_vars:
|
||||
onClick(CalculatorSpecialButton.vars);
|
||||
onClick(v, CalculatorSpecialButton.vars);
|
||||
break;
|
||||
case R.id.cpp_button_equals:
|
||||
onClick(CalculatorSpecialButton.equals);
|
||||
onClick(v, CalculatorSpecialButton.equals);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void onClick(@Nonnull CalculatorSpecialButton b) {
|
||||
onClick(b.getActionCode());
|
||||
private void onClick(@Nonnull View v, @Nonnull CalculatorSpecialButton b) {
|
||||
onClick(v, b.getActionCode());
|
||||
}
|
||||
|
||||
private void onClick(@Nonnull String s) {
|
||||
Locator.getInstance().getKeyboard().buttonPressed(s);
|
||||
private void onClick(@Nonnull View v, @Nonnull String s) {
|
||||
if (Locator.getInstance().getKeyboard().buttonPressed(s)) {
|
||||
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
public void attachToViews(@Nonnull ViewsCache views) {
|
||||
|
@ -171,7 +171,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
||||
new AndroidCalculatorHistory(this, calculator),
|
||||
new AndroidCalculatorLogger(),
|
||||
new AndroidCalculatorPreferenceService(this),
|
||||
new AndroidCalculatorKeyboard(this, new CalculatorKeyboardImpl()),
|
||||
new CalculatorKeyboard(),
|
||||
new AndroidCalculatorPlotter(this, new CalculatorPlotterImpl(calculator)),
|
||||
editorTextProcessor);
|
||||
|
||||
|
@ -138,14 +138,15 @@ public enum CalculatorButton {
|
||||
}
|
||||
}
|
||||
|
||||
public void onLongClick() {
|
||||
public boolean onLongClick() {
|
||||
if (onLongClickText != null) {
|
||||
Locator.getInstance().getKeyboard().buttonPressed(onLongClickText);
|
||||
return Locator.getInstance().getKeyboard().buttonPressed(onLongClickText);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
Locator.getInstance().getKeyboard().buttonPressed(onClickText);
|
||||
public boolean onClick() {
|
||||
return Locator.getInstance().getKeyboard().buttonPressed(onClickText);
|
||||
}
|
||||
|
||||
public int getButtonId() {
|
||||
|
@ -33,8 +33,7 @@ import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
|
||||
import org.solovyev.android.Views;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.view.AngleUnitsButton;
|
||||
@ -47,6 +46,9 @@ import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
|
||||
public final class CalculatorButtons {
|
||||
|
||||
private CalculatorButtons() {
|
||||
@ -115,18 +117,13 @@ public final class CalculatorButtons {
|
||||
private final DigitButtonDragProcessor upDownProcessor = new DigitButtonDragProcessor(getKeyboard());
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
final boolean result;
|
||||
|
||||
if (dragDirection == DragDirection.left) {
|
||||
App.getVibrator().vibrate();
|
||||
public boolean processDragEvent(@Nonnull DragDirection direction, @Nonnull DragButton button, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
if (direction == DragDirection.left) {
|
||||
getKeyboard().roundBracketsButtonPressed();
|
||||
result = true;
|
||||
} else {
|
||||
result = upDownProcessor.processDragEvent(dragDirection, dragButton, startPoint, motionEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return upDownProcessor.processDragEvent(direction, button, startPoint, motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,18 +141,12 @@ public final class CalculatorButtons {
|
||||
@Nonnull DragButton dragButton,
|
||||
@Nonnull PointF startPoint,
|
||||
@Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragDirection == DragDirection.up) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_create_var_dialog, null, context);
|
||||
result = true;
|
||||
}/* else if (dragDirection == DragDirection.down) {
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_create_matrix_dialog, null, context);
|
||||
result = true;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,8 +168,6 @@ public final class CalculatorButtons {
|
||||
@Nonnull DragButton dragButton,
|
||||
@Nonnull PointF startPoint,
|
||||
@Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof AngleUnitsButton) {
|
||||
if (dragDirection != DragDirection.left) {
|
||||
final String directionText = ((AngleUnitsButton) dragButton).getText(dragDirection);
|
||||
@ -191,21 +180,19 @@ public final class CalculatorButtons {
|
||||
|
||||
final AngleUnit oldAngleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(preferences);
|
||||
if (oldAngleUnits != angleUnits) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getPreferenceService().setAngleUnits(angleUnits);
|
||||
}
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported angle units: " + directionText);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (dragDirection == DragDirection.left) {
|
||||
result = processor.processDragEvent(dragDirection, dragButton, startPoint, motionEvent);
|
||||
return processor.processDragEvent(dragDirection, dragButton, startPoint, motionEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,31 +210,26 @@ public final class CalculatorButtons {
|
||||
@Nonnull DragButton dragButton,
|
||||
@Nonnull PointF startPoint,
|
||||
@Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof NumeralBasesButton) {
|
||||
final String directionText = ((NumeralBasesButton) dragButton).getText(dragDirection);
|
||||
if (directionText != null) {
|
||||
try {
|
||||
|
||||
final NumeralBase numeralBase = NumeralBase.valueOf(directionText);
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
final NumeralBase oldNumeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(preferences);
|
||||
if (oldNumeralBase != numeralBase) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getPreferenceService().setNumeralBase(numeralBase);
|
||||
}
|
||||
|
||||
result = true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(this.getClass().getName(), "Unsupported numeral base: " + directionText);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,15 +247,11 @@ public final class CalculatorButtons {
|
||||
@Nonnull DragButton dragButton,
|
||||
@Nonnull PointF startPoint,
|
||||
@Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragDirection == DragDirection.up) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.show_create_function_dialog, null, context);
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,26 +22,115 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/22/12
|
||||
* Time: 1:08 PM
|
||||
*/
|
||||
public interface CalculatorKeyboard {
|
||||
public class CalculatorKeyboard {
|
||||
|
||||
boolean buttonPressed(@Nullable String text);
|
||||
public boolean buttonPressed(@Nullable final String text) {
|
||||
App.getGa().onButtonPressed(text);
|
||||
if (!Strings.isEmpty(text)) {
|
||||
// process special buttons
|
||||
boolean processed = processSpecialButtons(text);
|
||||
|
||||
void roundBracketsButtonPressed();
|
||||
if (!processed) {
|
||||
processText(prepareText(text));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void pasteButtonPressed();
|
||||
private void processText(@Nonnull String text) {
|
||||
int cursorPositionOffset = 0;
|
||||
final StringBuilder textToBeInserted = new StringBuilder(text);
|
||||
|
||||
void clearButtonPressed();
|
||||
final MathType.Result mathType = MathType.getType(text, 0, false);
|
||||
switch (mathType.type) {
|
||||
case function:
|
||||
textToBeInserted.append("()");
|
||||
cursorPositionOffset = -1;
|
||||
break;
|
||||
case operator:
|
||||
textToBeInserted.append("()");
|
||||
cursorPositionOffset = -1;
|
||||
break;
|
||||
case comma:
|
||||
textToBeInserted.append(" ");
|
||||
break;
|
||||
}
|
||||
|
||||
void copyButtonPressed();
|
||||
if (cursorPositionOffset == 0) {
|
||||
if (MathType.groupSymbols.contains(text)) {
|
||||
cursorPositionOffset = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void moveCursorLeft();
|
||||
final Editor editor = Locator.getInstance().getEditor();
|
||||
editor.insert(textToBeInserted.toString(), cursorPositionOffset);
|
||||
}
|
||||
|
||||
void moveCursorRight();
|
||||
@Nonnull
|
||||
private String prepareText(@Nonnull String text) {
|
||||
if ("( )".equals(text) || "( )".equals(text)) {
|
||||
return "()";
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processSpecialButtons(@Nonnull String text) {
|
||||
boolean result = false;
|
||||
|
||||
final CalculatorSpecialButton button = CalculatorSpecialButton.getByActionCode(text);
|
||||
if (button != null) {
|
||||
button.onClick(this);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void roundBracketsButtonPressed() {
|
||||
final Editor editor = Locator.getInstance().getEditor();
|
||||
EditorState viewState = editor.getState();
|
||||
|
||||
final int cursorPosition = viewState.selection;
|
||||
final CharSequence oldText = viewState.text;
|
||||
|
||||
editor.setText("(" + oldText.subSequence(0, cursorPosition) + ")" + oldText.subSequence(cursorPosition, oldText.length()), cursorPosition + 2);
|
||||
}
|
||||
|
||||
public void pasteButtonPressed() {
|
||||
final String text = Locator.getInstance().getClipboard().getText();
|
||||
if (text != null) {
|
||||
Locator.getInstance().getEditor().insert(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearButtonPressed() {
|
||||
Locator.getInstance().getEditor().clear();
|
||||
}
|
||||
|
||||
public void copyButtonPressed() {
|
||||
final DisplayState displayViewState = Locator.getInstance().getDisplay().getViewState();
|
||||
if (displayViewState.isValid()) {
|
||||
final CharSequence text = displayViewState.getText();
|
||||
if (!Strings.isEmpty(text)) {
|
||||
Locator.getInstance().getClipboard().setText(text);
|
||||
Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void moveCursorLeft() {
|
||||
Locator.getInstance().getEditor().moveCursorLeft();
|
||||
}
|
||||
|
||||
public void moveCursorRight() {
|
||||
Locator.getInstance().getEditor().moveCursorRight();
|
||||
}
|
||||
}
|
||||
|
@ -1,142 +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;
|
||||
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.common.text.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CalculatorKeyboardImpl implements CalculatorKeyboard {
|
||||
|
||||
@Override
|
||||
public boolean buttonPressed(@Nullable final String text) {
|
||||
if (!Strings.isEmpty(text)) {
|
||||
// process special buttons
|
||||
boolean processed = processSpecialButtons(text);
|
||||
|
||||
if (!processed) {
|
||||
processText(prepareText(text));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void processText(@Nonnull String text) {
|
||||
int cursorPositionOffset = 0;
|
||||
final StringBuilder textToBeInserted = new StringBuilder(text);
|
||||
|
||||
final MathType.Result mathType = MathType.getType(text, 0, false);
|
||||
switch (mathType.type) {
|
||||
case function:
|
||||
textToBeInserted.append("()");
|
||||
cursorPositionOffset = -1;
|
||||
break;
|
||||
case operator:
|
||||
textToBeInserted.append("()");
|
||||
cursorPositionOffset = -1;
|
||||
break;
|
||||
case comma:
|
||||
textToBeInserted.append(" ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (cursorPositionOffset == 0) {
|
||||
if (MathType.groupSymbols.contains(text)) {
|
||||
cursorPositionOffset = -1;
|
||||
}
|
||||
}
|
||||
|
||||
final Editor editor = Locator.getInstance().getEditor();
|
||||
editor.insert(textToBeInserted.toString(), cursorPositionOffset);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private String prepareText(@Nonnull String text) {
|
||||
if ("( )".equals(text) || "( )".equals(text)) {
|
||||
return "()";
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean processSpecialButtons(@Nonnull String text) {
|
||||
boolean result = false;
|
||||
|
||||
final CalculatorSpecialButton button = CalculatorSpecialButton.getByActionCode(text);
|
||||
if (button != null) {
|
||||
button.onClick(this);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roundBracketsButtonPressed() {
|
||||
final Editor editor = Locator.getInstance().getEditor();
|
||||
EditorState viewState = editor.getState();
|
||||
|
||||
final int cursorPosition = viewState.selection;
|
||||
final CharSequence oldText = viewState.text;
|
||||
|
||||
editor.setText("(" + oldText.subSequence(0, cursorPosition) + ")" + oldText.subSequence(cursorPosition, oldText.length()), cursorPosition + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteButtonPressed() {
|
||||
final String text = Locator.getInstance().getClipboard().getText();
|
||||
if (text != null) {
|
||||
Locator.getInstance().getEditor().insert(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearButtonPressed() {
|
||||
Locator.getInstance().getEditor().clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyButtonPressed() {
|
||||
final DisplayState displayViewState = Locator.getInstance().getDisplay().getViewState();
|
||||
if (displayViewState.isValid()) {
|
||||
final CharSequence text = displayViewState.getText();
|
||||
if (!Strings.isEmpty(text)) {
|
||||
Locator.getInstance().getClipboard().setText(text);
|
||||
Locator.getInstance().getNotifier().showMessage(CalculatorMessage.newInfoMessage(CalculatorMessages.result_copied));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveCursorLeft() {
|
||||
Locator.getInstance().getEditor().moveCursorLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveCursorRight() {
|
||||
Locator.getInstance().getEditor().moveCursorRight();
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ package org.solovyev.android.calculator;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
@ -31,33 +32,21 @@ import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/16/11
|
||||
* Time: 11:45 PM
|
||||
*/
|
||||
public class CursorDragProcessor implements SimpleDragListener.DragProcessor {
|
||||
|
||||
public CursorDragProcessor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof DirectionDragButton) {
|
||||
String text = ((DirectionDragButton) dragButton).getText(dragDirection);
|
||||
final String text = ((DirectionDragButton) dragButton).getText(dragDirection);
|
||||
if ("◁◁".equals(text)) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getEditor().setCursorOnStart();
|
||||
result = true;
|
||||
return true;
|
||||
} else if ("▷▷".equals(text)) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getEditor().setCursorOnEnd();
|
||||
result = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,6 @@ import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/16/11
|
||||
* Time: 11:48 PM
|
||||
*/
|
||||
public class DigitButtonDragProcessor implements SimpleDragListener.DragProcessor {
|
||||
|
||||
@Nonnull
|
||||
@ -46,11 +41,8 @@ public class DigitButtonDragProcessor implements SimpleDragListener.DragProcesso
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
return true;
|
||||
public boolean processDragEvent(@Nonnull DragDirection direction, @Nonnull DragButton button, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
final String text = ((DirectionDragButton) button).getText(direction);
|
||||
return calculatorKeyboard.buttonPressed(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ package org.solovyev.android.calculator;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
@ -31,35 +32,21 @@ import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 10/24/11
|
||||
* Time: 9:52 PM
|
||||
*/
|
||||
public class EqualsDragProcessor implements SimpleDragListener.DragProcessor {
|
||||
|
||||
public EqualsDragProcessor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processDragEvent(@Nonnull DragDirection dragDirection, @Nonnull DragButton dragButton, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
boolean result = false;
|
||||
|
||||
if (dragButton instanceof DirectionDragButton) {
|
||||
if (dragDirection == DragDirection.down) {
|
||||
App.getVibrator().vibrate();
|
||||
CalculatorActivityLauncher.tryPlot();
|
||||
result = true;
|
||||
} else {
|
||||
final String text = ((DirectionDragButton) dragButton).getText(dragDirection);
|
||||
if ("≡".equals(text)) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getCalculator().simplify();
|
||||
result = true;
|
||||
}
|
||||
public boolean processDragEvent(@Nonnull DragDirection direction, @Nonnull DragButton button, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
if (direction == DragDirection.down) {
|
||||
CalculatorActivityLauncher.tryPlot();
|
||||
return true;
|
||||
} else if (button instanceof DirectionDragButton) {
|
||||
final String text = ((DirectionDragButton) button).getText(direction);
|
||||
if ("≡".equals(text)) {
|
||||
Locator.getInstance().getCalculator().simplify();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -31,23 +31,31 @@ import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.util.SparseArray;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
|
||||
import org.solovyev.android.Check;
|
||||
import org.solovyev.android.calculator.language.Languages;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
|
||||
import org.solovyev.android.calculator.wizard.WizardActivity;
|
||||
import org.solovyev.android.prefs.*;
|
||||
import org.solovyev.android.prefs.BooleanPreference;
|
||||
import org.solovyev.android.prefs.IntegerPreference;
|
||||
import org.solovyev.android.prefs.LongPreference;
|
||||
import org.solovyev.android.prefs.NumberToStringPreference;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.prefs.StringPreference;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
|
||||
import static org.solovyev.android.Android.isPhoneModel;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
|
||||
@ -126,18 +134,6 @@ public final class Preferences {
|
||||
// renew value after each application start
|
||||
Calculations.showCalculationMessagesDialog.putDefault(preferences);
|
||||
Calculations.lastPreferredPreferencesCheck.putDefault(preferences);
|
||||
|
||||
if (!Gui.hapticFeedback.isSet(preferences)) {
|
||||
final Preference<Boolean> hfEnabled = Gui.hapticFeedbackEnabled;
|
||||
final boolean enabled = !hfEnabled.isSet(preferences) ? true : hfEnabled.getPreference(preferences);
|
||||
if (enabled) {
|
||||
final Preference<Long> hfDuration = Gui.hapticFeedbackDuration;
|
||||
final long duration = !hfDuration.isSet(preferences) ? 60L : hfDuration.getPreference(preferences);
|
||||
Gui.hapticFeedback.putPreference(preferences, duration);
|
||||
} else {
|
||||
Gui.hapticFeedback.putPreference(preferences, 0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyDefaultPreference(@Nonnull SharedPreferences preferences, @Nonnull Preference<?> preference) {
|
||||
@ -281,9 +277,6 @@ public final class Preferences {
|
||||
public static final Preference<Boolean> colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true);
|
||||
public static final Preference<Long> hapticFeedback = NumberToStringPreference.of("hapticFeedback", 60L, Long.class);
|
||||
|
||||
private static final Preference<Boolean> hapticFeedbackEnabled = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_haptic_feedback", false);
|
||||
private static final Preference<Long> hapticFeedbackDuration = NumberToStringPreference.of("org.solovyev.android.calculator.CalculatorActivity_calc_haptic_feedback_duration_key", 60L, Long.class);
|
||||
|
||||
@Nonnull
|
||||
public static Theme getTheme(@Nonnull SharedPreferences preferences) {
|
||||
return theme.getPreferenceNoError(preferences);
|
||||
|
@ -1,42 +0,0 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class Vibrator implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@Nonnull
|
||||
private final android.os.Vibrator service;
|
||||
|
||||
private long time = 0;
|
||||
|
||||
public Vibrator(@Nonnull Context context, @Nonnull SharedPreferences preferences) {
|
||||
service = (android.os.Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
updateTime(preferences);
|
||||
}
|
||||
|
||||
private void updateTime(@Nonnull SharedPreferences preferences) {
|
||||
time = Preferences.Gui.hapticFeedback.getPreference(preferences) / 2;
|
||||
}
|
||||
|
||||
public void vibrate() {
|
||||
try {
|
||||
if (time > 0) {
|
||||
service.vibrate(time);
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
Log.e("Vibrator", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(@Nonnull SharedPreferences preferences, String key) {
|
||||
if (Preferences.Gui.hapticFeedback.isSameKey(key)) {
|
||||
updateTime(preferences);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,6 @@ import android.widget.ListView;
|
||||
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.CalculatorApplication;
|
||||
import org.solovyev.android.calculator.CalculatorEventData;
|
||||
import org.solovyev.android.calculator.CalculatorEventListener;
|
||||
@ -105,13 +104,6 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
@Nonnull
|
||||
private static final String TAG = "CalculatorHistoryFragment";
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* FIELDS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
private final ActivityMenu<Menu, MenuItem> menu = ListActivityMenu.fromResource(R.menu.history_menu, HistoryMenu.class, AndroidMenuHelper.getInstance(), new HistoryMenuFilter());
|
||||
@Nonnull
|
||||
private final SharedPreferences.OnSharedPreferenceChangeListener preferencesListener = new HistoryOnPreferenceChangeListener();
|
||||
@ -160,9 +152,8 @@ public abstract class BaseHistoryFragment extends ListFragment implements Calcul
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void useHistoryItem(@Nonnull final HistoryState historyState) {
|
||||
App.getVibrator().vibrate();
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, historyState);
|
||||
public static void useHistoryItem(@Nonnull final HistoryState state) {
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.use_history_state, state);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -23,9 +23,8 @@
|
||||
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.views.dragbutton.DragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
@ -33,12 +32,8 @@ import org.solovyev.common.history.HistoryAction;
|
||||
import org.solovyev.common.history.HistoryControl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 9/16/11
|
||||
* Time: 11:36 PM
|
||||
*/
|
||||
public class HistoryDragProcessor<T> implements SimpleDragListener.DragProcessor {
|
||||
|
||||
@Nonnull
|
||||
@ -49,26 +44,22 @@ public class HistoryDragProcessor<T> implements SimpleDragListener.DragProcessor
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
final HistoryAction historyAction;
|
||||
if (dragDirection == DragDirection.up) {
|
||||
historyAction = HistoryAction.undo;
|
||||
} else if (dragDirection == DragDirection.down) {
|
||||
historyAction = HistoryAction.redo;
|
||||
} else {
|
||||
historyAction = null;
|
||||
public boolean processDragEvent(@Nonnull DragDirection direction, @Nonnull DragButton button, @Nonnull PointF startPoint, @Nonnull MotionEvent motionEvent) {
|
||||
final HistoryAction action = getActionFromDirection(direction);
|
||||
if (action != null) {
|
||||
historyControl.doHistoryAction(action);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (historyAction != null) {
|
||||
App.getVibrator().vibrate();
|
||||
result = true;
|
||||
historyControl.doHistoryAction(historyAction);
|
||||
@Nullable
|
||||
private HistoryAction getActionFromDirection(@Nonnull DragDirection direction) {
|
||||
if (direction == DragDirection.up) {
|
||||
return HistoryAction.undo;
|
||||
} else if (direction == DragDirection.down) {
|
||||
return HistoryAction.redo;
|
||||
}
|
||||
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -31,16 +31,26 @@ import android.preference.PreferenceManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import org.solovyev.android.calculator.*;
|
||||
|
||||
import org.solovyev.android.calculator.AndroidCalculatorDisplayView;
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.CalculatorButton;
|
||||
import org.solovyev.android.calculator.DisplayState;
|
||||
import org.solovyev.android.calculator.EditorState;
|
||||
import org.solovyev.android.calculator.EditorView;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.prefs.Preference;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@ -217,7 +227,9 @@ public class CalculatorOnscreenView {
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
widgetButton.onClick();
|
||||
if (widgetButton.onClick()) {
|
||||
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
}
|
||||
if (widgetButton == CalculatorButton.app) {
|
||||
minimize();
|
||||
}
|
||||
@ -226,7 +238,9 @@ public class CalculatorOnscreenView {
|
||||
button.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
widgetButton.onLongClick();
|
||||
if (widgetButton.onLongClick()) {
|
||||
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -250,7 +264,6 @@ public class CalculatorOnscreenView {
|
||||
onscreenFoldButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
App.getVibrator().vibrate();
|
||||
if (folded) {
|
||||
unfold();
|
||||
} else {
|
||||
@ -263,7 +276,6 @@ public class CalculatorOnscreenView {
|
||||
onscreenHideButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
App.getVibrator().vibrate();
|
||||
minimize();
|
||||
}
|
||||
});
|
||||
@ -271,7 +283,6 @@ public class CalculatorOnscreenView {
|
||||
root.findViewById(R.id.onscreen_close_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
App.getVibrator().vibrate();
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.solovyev.android.calculator.view;
|
||||
|
||||
import android.view.GestureDetector;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
@ -42,7 +43,8 @@ public final class LongClickEraser implements View.OnTouchListener {
|
||||
}
|
||||
|
||||
public static void createAndAttach(@Nonnull View view) {
|
||||
view.setOnTouchListener(new LongClickEraser(view));
|
||||
final LongClickEraser l = new LongClickEraser(view);
|
||||
view.setOnTouchListener(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,11 +63,11 @@ public final class LongClickEraser implements View.OnTouchListener {
|
||||
}
|
||||
|
||||
private class Eraser implements Runnable {
|
||||
private static final int DELAY = 500;
|
||||
private static final int DELAY = 300;
|
||||
private long delay;
|
||||
private boolean wasCalculatingOnFly;
|
||||
private boolean erasing;
|
||||
private boolean tracking = true;
|
||||
private boolean wasCalculatingOnFly;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@ -84,12 +86,13 @@ public final class LongClickEraser implements View.OnTouchListener {
|
||||
}
|
||||
erasing = true;
|
||||
delay = DELAY;
|
||||
view.removeCallbacks(this);
|
||||
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
|
||||
wasCalculatingOnFly = calculator.isCalculateOnFly();
|
||||
if (wasCalculatingOnFly) {
|
||||
calculator.setCalculateOnFly(false);
|
||||
}
|
||||
view.removeCallbacks(this);
|
||||
view.post(this);
|
||||
run();
|
||||
}
|
||||
|
||||
void stop() {
|
||||
|
@ -27,16 +27,17 @@ 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.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 java.util.Arrays;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DragButtonWizardStep extends WizardFragment {
|
||||
|
||||
@ -161,7 +162,6 @@ public class DragButtonWizardStep extends WizardFragment {
|
||||
private class DragButtonOnClickListener implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
App.getVibrator().vibrate();
|
||||
if (action == DragButtonAction.center || action == DragButtonAction.end) {
|
||||
setNextAction();
|
||||
}
|
||||
@ -174,10 +174,6 @@ public class DragButtonWizardStep extends WizardFragment {
|
||||
@Nonnull DragButton dragButton,
|
||||
@Nonnull PointF startPoint,
|
||||
@Nonnull MotionEvent motionEvent) {
|
||||
if (dragDirection == DragDirection.up || dragDirection == DragDirection.down) {
|
||||
App.getVibrator().vibrate();
|
||||
}
|
||||
|
||||
if (action.dragDirection == dragDirection) {
|
||||
setNextAction();
|
||||
return true;
|
||||
|
@ -36,13 +36,6 @@
|
||||
a:summary="@string/c_calc_color_display_summary"
|
||||
a:title="@string/c_calc_color_display_title" />
|
||||
|
||||
<ListPreference
|
||||
a:entries="@array/cpp_haptic_feedback_names"
|
||||
a:entryValues="@array/cpp_haptic_feedback_values"
|
||||
a:key="hapticFeedback"
|
||||
a:summary="@string/c_calc_haptic_feedback_summary"
|
||||
a:title="@string/c_calc_haptic_feedback_title" />
|
||||
|
||||
<ListPreference
|
||||
a:entries="@array/p_multiplication_sign_values"
|
||||
a:entryValues="@array/p_multiplication_sign_values"
|
||||
|
Loading…
Reference in New Issue
Block a user