Fixes
This commit is contained in:
parent
3d0eacd601
commit
4637547691
@ -16,7 +16,8 @@ public interface CalculatorLocator {
|
||||
@NotNull CalculatorNotifier notifier,
|
||||
@NotNull CalculatorHistory history,
|
||||
@NotNull CalculatorLogger logger,
|
||||
@NotNull CalculatorPreferenceService preferenceService);
|
||||
@NotNull CalculatorPreferenceService preferenceService,
|
||||
@NotNull CalculatorKeyboard keyboard);
|
||||
|
||||
@NotNull
|
||||
Calculator getCalculator();
|
||||
|
@ -53,7 +53,8 @@ public class CalculatorLocatorImpl implements CalculatorLocator {
|
||||
@NotNull CalculatorNotifier notifier,
|
||||
@NotNull CalculatorHistory history,
|
||||
@NotNull CalculatorLogger logger,
|
||||
@NotNull CalculatorPreferenceService preferenceService) {
|
||||
@NotNull CalculatorPreferenceService preferenceService,
|
||||
@NotNull CalculatorKeyboard keyboard) {
|
||||
|
||||
this.calculator = calculator;
|
||||
this.calculatorEngine = engine;
|
||||
@ -65,7 +66,7 @@ public class CalculatorLocatorImpl implements CalculatorLocator {
|
||||
|
||||
calculatorEditor = new CalculatorEditorImpl(this.calculator);
|
||||
calculatorDisplay = new CalculatorDisplayImpl(this.calculator);
|
||||
calculatorKeyboard = new CalculatorKeyboardImpl(this.calculator);
|
||||
calculatorKeyboard = keyboard;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -11,7 +11,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory;
|
||||
public class AbstractCalculatorTest {
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
|
||||
CalculatorLocatorImpl.getInstance().getEngine().init();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class CalculatorTestUtils {
|
||||
public static final int TIMEOUT = 3;
|
||||
|
||||
public static void staticSetUp() throws Exception {
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
|
||||
CalculatorLocatorImpl.getInstance().getEngine().init();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,13 @@
|
||||
<Button
|
||||
a:id="@+id/function_add_param_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="+" />
|
||||
|
||||
<TextView
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="5"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -8,25 +8,29 @@
|
||||
<Button
|
||||
a:id="@+id/function_remove_param_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="-" />
|
||||
|
||||
<Button
|
||||
a:id="@+id/function_up_param_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="↑" />
|
||||
|
||||
<Button
|
||||
a:id="@+id/function_down_param_button"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="1"
|
||||
a:text="↓" />
|
||||
|
||||
<org.solovyev.android.calculator.function.FunctionParamEditText
|
||||
a:id="@+id/function_param_edit_text"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_width="0dp"
|
||||
a:layout_weight="3"
|
||||
style="@style/cpp_default_text_size"
|
||||
a:inputType="text" />
|
||||
|
||||
|
@ -230,5 +230,16 @@
|
||||
3. Ручные вычисления (Настройки->Настройки вычислений->Результат вычисляется…)
|
||||
</string>
|
||||
|
||||
<string name="c_release_notes_for_107">
|
||||
1. Поддержка пользовательских функций (кнопка +f или кнопка + на экране функций)\n
|
||||
2. Добавлены различные размеры виджета: 3x3, 3x4, 4x4\n
|
||||
3. Добавлено несколько функций: re(x), im(x), √3(x), √4(x), √n(x, n)\n
|
||||
4. Система счисления/единицы измерения углов по умолчанию + окно с ошибками расчётов\n
|
||||
5. Ускорена работа приложения\n
|
||||
6. Исправлена проблема размера шрифта кнопок в мобильной раскладке (для планшетов)\n
|
||||
7. Другие исправления
|
||||
</string>
|
||||
|
||||
|
||||
|
||||
</resources>
|
@ -229,4 +229,14 @@
|
||||
3. Manual calculations (Preferences->Calculations Preferences->Result is calculated…)
|
||||
</string>
|
||||
|
||||
<string name="c_release_notes_for_107">
|
||||
1. Support for user-defined functions (see +f button or + button inside functions screen)\n
|
||||
2. Widget in different sizes: 3x3, 3x4, 4x4\n
|
||||
3. Several functions added: re(x), im(x), √3(x), √4(x), √n(x, n)\n
|
||||
4. Default number systems/angle units + special warning dialog in case of calculations errors\n
|
||||
5. Performance improvements\n
|
||||
6. Text size in mobile layout for tablets fixed\n
|
||||
7. Bug fixes
|
||||
</string>
|
||||
|
||||
</resources>
|
@ -0,0 +1,86 @@
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.view.VibratorContainer;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 11/18/12
|
||||
* Time: 6:05 PM
|
||||
*/
|
||||
public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
|
||||
|
||||
@NotNull
|
||||
private final CalculatorKeyboard calculatorKeyboard;
|
||||
|
||||
@NotNull
|
||||
private final Context context;
|
||||
|
||||
private VibratorContainer vibrator;
|
||||
|
||||
public AndroidCalculatorKeyboard(@NotNull Application application,
|
||||
@NotNull CalculatorKeyboard calculatorKeyboard) {
|
||||
this.context = application;
|
||||
this.calculatorKeyboard = calculatorKeyboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed(@Nullable String text) {
|
||||
vibrate();
|
||||
calculatorKeyboard.buttonPressed(text);
|
||||
}
|
||||
|
||||
private void vibrate() {
|
||||
if (this.vibrator == null) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final Vibrator vibrator = (Vibrator) context.getSystemService(Activity.VIBRATOR_SERVICE);
|
||||
|
||||
this.vibrator = new VibratorContainer(vibrator, preferences, 0.5f);
|
||||
}
|
||||
|
||||
this.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();
|
||||
}
|
||||
}
|
@ -91,7 +91,8 @@ public class CalculatorApplication extends android.app.Application {
|
||||
new AndroidCalculatorNotifier(this),
|
||||
new AndroidCalculatorHistory(this, calculator),
|
||||
new AndroidCalculatorLogger(),
|
||||
new AndroidCalculatorPreferenceService(this));
|
||||
new AndroidCalculatorPreferenceService(this),
|
||||
new AndroidCalculatorKeyboard(this, new CalculatorKeyboardImpl(calculator)));
|
||||
|
||||
CalculatorLocatorImpl.getInstance().getCalculator().init();
|
||||
|
||||
|
@ -15,7 +15,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory;
|
||||
public class CalculatorTestUtils {
|
||||
|
||||
public static void staticSetUp(@Nullable Context context) throws Exception {
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
|
||||
CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
|
||||
CalculatorLocatorImpl.getInstance().getEngine().init();
|
||||
|
||||
if ( context != null ) {
|
||||
|
Loading…
Reference in New Issue
Block a user