cpp-123: Wrong colors in floating calculator

Fixes #123
This commit is contained in:
serso 2015-02-13 09:30:54 +01:00
parent d82cbcb7fc
commit c1813c1860
5 changed files with 17 additions and 4 deletions

View File

@ -140,7 +140,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
} }
private Preferences.Gui.TextColor getTextColor() { private Preferences.Gui.TextColor getTextColor() {
return App.getTheme().getTextColor(App.getApplication()); return App.getTheme().getTextColor(getContext());
} }
@Nonnull @Nonnull

View File

@ -30,6 +30,8 @@ import android.text.TextWatcher;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.widget.EditText; import android.widget.EditText;
import org.solovyev.android.calculator.onscreen.CalculatorOnscreenService;
import org.solovyev.common.collections.Collections; import org.solovyev.common.collections.Collections;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -120,7 +122,12 @@ public class AndroidCalculatorEditorView extends EditText implements CalculatorE
try { try {
editorView.viewStateChange = true; editorView.viewStateChange = true;
editorView.viewState = viewState; editorView.viewState = viewState;
if (App.getTheme().isLight() && getContext() instanceof CalculatorOnscreenService) {
// don't need formatting
editorView.setText(viewState.getText());
} else {
editorView.setText(viewState.getTextAsCharSequence(), BufferType.EDITABLE); editorView.setText(viewState.getTextAsCharSequence(), BufferType.EDITABLE);
}
final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText()); final int selection = CalculatorEditorImpl.correctSelection(viewState.getSelection(), editorView.getText());
editorView.setSelection(selection); editorView.setSelection(selection);
} finally { } finally {

View File

@ -33,6 +33,7 @@ import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.onscreen.CalculatorOnscreenService;
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity; import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
import org.solovyev.android.calculator.wizard.WizardActivity; import org.solovyev.android.calculator.wizard.WizardActivity;
import org.solovyev.android.prefs.*; import org.solovyev.android.prefs.*;
@ -139,6 +140,9 @@ public final class Preferences {
if (context instanceof PurchaseDialogActivity) { if (context instanceof PurchaseDialogActivity) {
return dialogThemeId; return dialogThemeId;
} }
if (App.getTheme().isLight() && context instanceof CalculatorOnscreenService) {
return R.style.Cpp_Theme_Material;
}
return themeId; return themeId;
} }

View File

@ -15,7 +15,7 @@
<org.solovyev.android.calculator.AndroidCalculatorEditorView <org.solovyev.android.calculator.AndroidCalculatorEditorView
a:id="@+id/calculator_editor" a:id="@+id/calculator_editor"
style="@style/cpp_onscreen_editor_style" style="@style/CppText.Editor.Onscreen"
a:textIsSelectable="true" /> a:textIsSelectable="true" />
</LinearLayout> </LinearLayout>

View File

@ -40,13 +40,14 @@
<item name="directionTextColor">@color/cpp_button_text</item> <item name="directionTextColor">@color/cpp_button_text</item>
</style> </style>
<style name="cpp_onscreen_editor_style" parent="CppText.Editor"> <style name="CppText.Editor.Onscreen" parent="CppText.Editor">
<item name="android:ellipsize">none</item> <item name="android:ellipsize">none</item>
<item name="android:singleLine">true</item> <item name="android:singleLine">true</item>
<item name="android:maxLines">1</item> <item name="android:maxLines">1</item>
<item name="android:minLines">1</item> <item name="android:minLines">1</item>
<item name="android:lines">1</item> <item name="android:lines">1</item>
<item name="android:scrollbars">horizontal</item> <item name="android:scrollbars">horizontal</item>
<item name="android:textColor">@color/cpp_text</item>
</style> </style>
<style name="CppText.Editor"> <style name="CppText.Editor">
@ -70,6 +71,7 @@
<style name="CppText.Display.Onscreen" parent="CppText.Display"> <style name="CppText.Display.Onscreen" parent="CppText.Display">
<item name="android:textSize">@dimen/cpp_onscreen_display_text_size</item> <item name="android:textSize">@dimen/cpp_onscreen_display_text_size</item>
<item name="android:textColor">@color/cpp_text</item>
</style> </style>
<style name="CppText.About"> <style name="CppText.About">