() -> ( )
This commit is contained in:
parent
7b19427222
commit
7407b7d5d2
@ -8,5 +8,5 @@
|
|||||||
|
|
||||||
<Button xmlns:a="http://schemas.android.com/apk/res/android"
|
<Button xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
a:id="@id/cpp_button_round_brackets"
|
a:id="@id/cpp_button_round_brackets"
|
||||||
a:text="()"
|
a:text="( )"
|
||||||
style="@style/cpp_simple_metro_digit_button_style" />
|
style="@style/cpp_simple_metro_digit_button_style" />
|
@ -10,7 +10,7 @@
|
|||||||
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:c="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@id/cpp_button_round_brackets"
|
a:id="@id/cpp_button_round_brackets"
|
||||||
c:textUp="("
|
c:textUp="("
|
||||||
a:text="()"
|
a:text="( )"
|
||||||
c:textDown=")"
|
c:textDown=")"
|
||||||
c:textLeft="(…)"
|
c:textLeft="(…)"
|
||||||
c:directionTextScale="0.5;0.5;0.5;0.33"
|
c:directionTextScale="0.5;0.5;0.5;0.33"
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package org.solovyev.android.calculator;
|
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.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
|
||||||
import org.solovyev.common.text.Strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -29,6 +30,12 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
|
|||||||
boolean processed = processSpecialButtons(text);
|
boolean processed = processSpecialButtons(text);
|
||||||
|
|
||||||
if (!processed) {
|
if (!processed) {
|
||||||
|
processText(prepareText(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processText(@Nonnull String text) {
|
||||||
int cursorPositionOffset = 0;
|
int cursorPositionOffset = 0;
|
||||||
final StringBuilder textToBeInserted = new StringBuilder(text);
|
final StringBuilder textToBeInserted = new StringBuilder(text);
|
||||||
|
|
||||||
@ -56,6 +63,13 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
|
|||||||
final CalculatorEditor editor = Locator.getInstance().getEditor();
|
final CalculatorEditor editor = Locator.getInstance().getEditor();
|
||||||
editor.insert(textToBeInserted.toString(), cursorPositionOffset);
|
editor.insert(textToBeInserted.toString(), cursorPositionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private String prepareText(@Nonnull String text) {
|
||||||
|
if ("( )".equals(text)) {
|
||||||
|
return "()";
|
||||||
|
} else {
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user