() -> ( )

This commit is contained in:
Sergey Solovyev 2013-06-16 16:24:22 +04:00
parent 7b19427222
commit 7407b7d5d2
3 changed files with 44 additions and 30 deletions

View File

@ -1,9 +1,10 @@
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;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.common.text.Strings;
/**
* User: serso
@ -29,6 +30,12 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
boolean processed = processSpecialButtons(text);
if (!processed) {
processText(prepareText(text));
}
}
}
private void processText(@Nonnull String text) {
int cursorPositionOffset = 0;
final StringBuilder textToBeInserted = new StringBuilder(text);
@ -56,6 +63,13 @@ public class CalculatorKeyboardImpl implements CalculatorKeyboard {
final CalculatorEditor editor = Locator.getInstance().getEditor();
editor.insert(textToBeInserted.toString(), cursorPositionOffset);
}
@Nonnull
private String prepareText(@Nonnull String text) {
if ("( )".equals(text)) {
return "()";
} else {
return text;
}
}