diff --git a/.idea/runConfigurations/Tests.xml b/.idea/runConfigurations/Tests.xml
new file mode 100644
index 00000000..fc102088
--- /dev/null
+++ b/.idea/runConfigurations/Tests.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-app-tests/build.gradle b/android-app-tests/build.gradle
index a9321ff4..d08d0786 100644
--- a/android-app-tests/build.gradle
+++ b/android-app-tests/build.gradle
@@ -32,8 +32,10 @@ dependencies {
testCompile 'junit:junit:4.11'
testCompile 'org.robolectric:robolectric:2.3'
- testCompile "org.mockito:mockito-all:1.9.5"
- testCompile "org.skyscreamer:jsonassert:1.2.3"
+ testCompile 'org.mockito:mockito-all:1.9.5'
+ testCompile 'org.skyscreamer:jsonassert:1.2.3'
+ testCompile 'com.android.support:support-v4:21.0.3'
+ testCompile 'com.android.support:appcompat-v7:21.0.3'
}
tasks.withType(Test) {
diff --git a/android-app-tests/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java b/android-app-tests/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
index 09b0e378..98daee5f 100644
--- a/android-app-tests/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
+++ b/android-app-tests/src/test/java/org/solovyev/android/calculator/TextHighlighterTest.java
@@ -35,6 +35,8 @@ import java.util.Date;
import java.util.Random;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
/**
* User: serso
@@ -50,7 +52,7 @@ public class TextHighlighterTest {
@Test
public void testProcess() throws Exception {
- TextProcessor, String> textHighlighter = new TextHighlighter(0, false);
+ TextProcessor, String> textHighlighter = new TextHighlighter(Color.TRANSPARENT, false);
final Random random = new Random(new Date().getTime());
for (int i = 0; i < 1000; i++) {
@@ -176,4 +178,19 @@ public class TextHighlighterTest {
long endTime = System.currentTimeMillis();
System.out.println("Total time, ms: " + (endTime - startTime));
}
+
+ @Test
+ public void testDarkColor() throws Exception {
+ final TextProcessor, String> textHighlighter = new TextHighlighter(Color.BLACK, false);
+ assertEquals("", textHighlighter.process("sin(2cos(3))"));
+ }
+
+ @Test
+ public void testIsDark() throws Exception {
+ assertFalse(TextHighlighter.isDark(Color.WHITE));
+ assertFalse(TextHighlighter.isDark(Color.LTGRAY));
+ assertTrue(TextHighlighter.isDark(Color.DKGRAY));
+ assertTrue(TextHighlighter.isDark(Color.BLACK));
+
+ }
}
diff --git a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java b/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java
index d1e5bc95..5735e9a2 100644
--- a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java
+++ b/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java
@@ -22,21 +22,19 @@
package org.solovyev.android.calculator.wizard;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.util.ActivityController;
import org.solovyev.android.CalculatorTestRunner;
-import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.wizard.WizardUi;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
@RunWith(CalculatorTestRunner.class)
public class OnScreenCalculatorWizardStepTest {
@@ -86,22 +84,4 @@ public class OnScreenCalculatorWizardStepTest {
controller.restart();
assertFalse(fragment.getCheckbox().isChecked());
}
-
- @Test
- public void testShouldBeEnabledIfIconIsShown() throws Exception {
- testShouldBeEqualsToIconState(true);
- }
-
- @Test
- public void testShouldBeDisabledIfIconIsNotShown() throws Exception {
- testShouldBeEqualsToIconState(false);
- }
-
- private void testShouldBeEqualsToIconState(boolean iconEnabled) throws IllegalAccessException {
- final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
- Preferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
- createActivity();
- setFragment();
- assertEquals(iconEnabled, fragment.isOnscreenCalculatorEnabled());
- }
}
diff --git a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/WizardStepTest.java b/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/WizardStepTest.java
deleted file mode 100644
index fbb89292..00000000
--- a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/WizardStepTest.java
+++ /dev/null
@@ -1,181 +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.wizard;
-
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-import org.solovyev.android.CalculatorTestRunner;
-import org.solovyev.android.calculator.Preferences;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
-import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
-import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
-import static org.solovyev.android.calculator.Preferences.OnscreenCalculator.showAppIcon;
-import static org.solovyev.android.calculator.wizard.CalculatorLayout.big_buttons;
-import static org.solovyev.android.calculator.wizard.CalculatorLayout.optimized;
-import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer;
-import static org.solovyev.android.calculator.wizard.CalculatorMode.simple;
-import static org.solovyev.android.calculator.wizard.CalculatorWizardStep.*;
-import static org.solovyev.android.calculator.wizard.ChooseLayoutWizardStep.LAYOUT;
-import static org.solovyev.android.calculator.wizard.ChooseModeWizardStep.MODE;
-import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardStep.ONSCREEN_CALCULATOR_ENABLED;
-
-@RunWith(CalculatorTestRunner.class)
-public class WizardStepTest {
-
- private FragmentActivity activity;
-
- @Before
- public void setUp() throws Exception {
- activity = Robolectric.buildActivity(FragmentActivity.class).create().get();
- }
-
- @Test
- public void testFragmentsShouldBeInstantiated() throws Exception {
- for (CalculatorWizardStep wizardStep : CalculatorWizardStep.values()) {
- Fragment.instantiate(Robolectric.application, wizardStep.getFragmentClass().getName());
- }
- }
-
- @Test
- public void testShouldBeMainMobileLayout() throws Exception {
- chooseLayout(big_buttons);
- chooseMode(engineer);
-
- assertUiLayoutEquals(main_calculator_mobile);
- }
-
- @Test
- public void testShouldBeMainLayout() throws Exception {
- chooseLayout(optimized);
- chooseMode(engineer);
-
- assertUiLayoutEquals(main_calculator);
- }
-
- @Test
- public void testShouldBeSimpleLayout() throws Exception {
- chooseLayout(optimized);
- chooseMode(simple);
-
- assertUiLayoutEquals(Preferences.Gui.Layout.simple);
- }
-
- @Test
- public void testShouldBeSimpleMobileLayout() throws Exception {
- chooseLayout(big_buttons);
- chooseMode(simple);
-
- assertUiLayoutEquals(Preferences.Gui.Layout.simple_mobile);
- }
-
- private void assertUiLayoutEquals(Preferences.Gui.Layout uiLayout) {
- Assert.assertEquals(uiLayout, Preferences.Gui.layout.getPreference(PreferenceManager.getDefaultSharedPreferences(Robolectric.application)));
- }
-
- private void chooseMode(CalculatorMode mode) {
- final ChooseModeWizardStep modeFragment = mock(ChooseModeWizardStep.class);
- when(modeFragment.getSelectedMode()).thenReturn(mode);
- when(modeFragment.getActivity()).thenReturn(activity);
- CalculatorWizardStep.choose_mode.onNext(modeFragment);
- }
-
- private void chooseLayout(CalculatorLayout layout) {
- final ChooseLayoutWizardStep layoutFragment = mock(ChooseLayoutWizardStep.class);
- when(layoutFragment.getSelectedLayout()).thenReturn(layout);
- when(layoutFragment.getActivity()).thenReturn(activity);
- choose_layout.onNext(layoutFragment);
- }
-
-/* @Config(qualifiers = "large")
- @Test
- public void testChooseLayoutShouldBeVisibleForTablet() throws Exception {
- assertTrue(CalculatorWizardStep.choose_layout.isVisible());
- }*/
-
- @Config(qualifiers = "normal")
- @Test
- public void testChooseLayoutShouldNotBeVisibleForMobile() throws Exception {
- assertFalse(choose_layout.isVisible());
- }
-
- @Test
- public void testOnscreenCalculatorShouldNotBeShown() throws Exception {
- doOnscreenStep(false);
- assertFalse(showAppIcon.getPreference(getPreferences()));
- }
-
- @Test
- public void testOnscreenCalculatorShouldBeShown() throws Exception {
- doOnscreenStep(true);
- assertTrue(showAppIcon.getPreference(getPreferences()));
- }
-
-
- private void doOnscreenStep(boolean onscreenCalculatorEnabled) {
- final OnScreenCalculatorWizardStep f = mock(OnScreenCalculatorWizardStep.class);
- when(f.isOnscreenCalculatorEnabled()).thenReturn(onscreenCalculatorEnabled);
- when(f.getActivity()).thenReturn(activity);
- CalculatorWizardStep.on_screen_calculator.onNext(f);
- }
-
- @SuppressWarnings("ConstantConditions")
- @Test
- public void testChooseLayoutFragmentArgs() throws Exception {
- Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple);
- assertEquals(CalculatorLayout.optimized, choose_layout.getFragmentArgs().getSerializable(LAYOUT));
-
- Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple_mobile);
- assertEquals(CalculatorLayout.big_buttons, choose_layout.getFragmentArgs().getSerializable(LAYOUT));
- }
-
- @SuppressWarnings("ConstantConditions")
- @Test
- public void testChooseModeFragmentArgs() throws Exception {
- Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.main_calculator);
- assertEquals(CalculatorMode.engineer, choose_mode.getFragmentArgs().getSerializable(MODE));
-
- Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple_mobile);
- assertEquals(CalculatorMode.simple, choose_mode.getFragmentArgs().getSerializable(MODE));
- }
-
- @SuppressWarnings("ConstantConditions")
- @Test
- public void testOnscreenFragmentArgs() throws Exception {
- Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), true);
- assertTrue(on_screen_calculator.getFragmentArgs().getBoolean(ONSCREEN_CALCULATOR_ENABLED));
-
- Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), false);
- assertFalse(on_screen_calculator.getFragmentArgs().getBoolean(ONSCREEN_CALCULATOR_ENABLED));
- }
-}
diff --git a/android-app/android-app.iml b/android-app/android-app.iml
index f85e8adf..32487e6e 100644
--- a/android-app/android-app.iml
+++ b/android-app/android-app.iml
@@ -78,6 +78,7 @@
+
diff --git a/android-app/src/main/AndroidManifest.xml b/android-app/src/main/AndroidManifest.xml
index 3fd0b169..d58b3045 100644
--- a/android-app/src/main/AndroidManifest.xml
+++ b/android-app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
-
+
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java
index c1c6bdb6..81c1ce06 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java
@@ -66,6 +66,15 @@ public class ActivityUi extends BaseUi {
this.layoutId = layoutId;
}
+ public void onPreCreate(@Nonnull Activity activity) {
+ final SharedPreferences preferences = App.getPreferences();
+
+ theme = Preferences.Gui.getTheme(preferences);
+ activity.setTheme(theme.getThemeId(activity));
+
+ layout = Preferences.Gui.getLayout(preferences);
+ }
+
@Override
public void onCreate(@Nonnull Activity activity) {
super.onCreate(activity);
@@ -74,13 +83,6 @@ public class ActivityUi extends BaseUi {
Locator.getInstance().getCalculator().addCalculatorEventListener((CalculatorEventListener) activity);
}
- final SharedPreferences preferences = App.getPreferences();
-
- theme = Preferences.Gui.getTheme(preferences);
- activity.setTheme(theme.getThemeId(activity));
-
- this.layout = Preferences.Gui.getLayout(preferences);
-
activity.setContentView(layoutId);
final View root = activity.findViewById(R.id.main_layout);
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java b/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java
index 6587587a..8fa92fbe 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorDisplayView.java
@@ -24,7 +24,6 @@ package org.solovyev.android.calculator;
import android.content.Context;
import android.content.SharedPreferences;
-import android.graphics.Color;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
@@ -38,8 +37,6 @@ import org.solovyev.android.view.AutoResizeTextView;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* User: serso
@@ -57,7 +54,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
*/
@Nonnull
- private final static TextProcessor textHighlighter = new TextHighlighter(Color.WHITE, false);
+ private final TextProcessor textHighlighter;
/*
**********************************************************************
@@ -70,17 +67,12 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
@Nonnull
private volatile CalculatorDisplayViewState state = CalculatorDisplayViewStateImpl.newDefaultInstance();
- private volatile boolean viewStateChange = false;
-
@Nonnull
private final Object lock = new Object();
@Nonnull
private final Handler uiHandler = new Handler();
- @Nonnull
- private final ExecutorService bgExecutor = Executors.newSingleThreadExecutor();
-
private volatile boolean initialized = false;
/*
@@ -93,15 +85,17 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
public AndroidCalculatorDisplayView(Context context) {
super(context);
+ textHighlighter = new TextHighlighter(getTextColors().getDefaultColor(), false);
}
public AndroidCalculatorDisplayView(Context context, AttributeSet attrs) {
super(context, attrs);
-
+ textHighlighter = new TextHighlighter(getTextColors().getDefaultColor(), false);
}
public AndroidCalculatorDisplayView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ textHighlighter = new TextHighlighter(getTextColors().getDefaultColor(), false);
}
/*
@@ -121,14 +115,12 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
public void run() {
synchronized (lock) {
- try {
- viewStateChange = true;
final CharSequence text = prepareText(state.getStringResult(), state.isValid());
AndroidCalculatorDisplayView.this.state = state;
if (state.isValid()) {
- setTextColor(getResources().getColor(R.color.cpp_text));
+ setTextColor(getTextColor().normal);
setText(text);
adjustTextSize();
@@ -136,20 +128,21 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
} else {
// update text in order to get rid of HTML tags
setText(getText().toString());
- setTextColor(getResources().getColor(R.color.cpp_text_error));
+ setTextColor(getTextColor().error);
// error messages are never shown -> just greyed out text (error message will be shown on click)
//setText(state.getErrorMessage());
//redraw();
}
- } finally {
- viewStateChange = false;
- }
}
}
});
}
+ private Preferences.Gui.TextColor getTextColor() {
+ return App.getTheme().getTextColor(App.getApplication());
+ }
+
@Nonnull
@Override
public CalculatorDisplayViewState getState() {
@@ -159,13 +152,10 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
}
@Nullable
- private static CharSequence prepareText(@Nullable String text, boolean valid) {
+ private CharSequence prepareText(@Nullable String text, boolean valid) {
CharSequence result;
if (valid && text != null) {
-
- //Log.d(this.getClass().getName(), text);
-
try {
final TextProcessorEditorResult processedText = textHighlighter.process(text);
text = processedText.toString();
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/App.java b/android-app/src/main/java/org/solovyev/android/calculator/App.java
index 8a79d3b5..3057b6b9 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/App.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/App.java
@@ -225,4 +225,9 @@ public final class App {
public static SharedPreferences getPreferences() {
return preferences;
}
+
+ @Nonnull
+ public static Preferences.Gui.Theme getTheme() {
+ return Preferences.Gui.getTheme(getPreferences());
+ }
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/BaseActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/BaseActivity.java
index 2fe6b971..68ffcc49 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/BaseActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/BaseActivity.java
@@ -31,6 +31,7 @@ public class BaseActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ ui.onPreCreate(this);
super.onCreate(savedInstanceState);
ui.onCreate(this);
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java
index b9e3dbf0..e8a53990 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java
@@ -22,9 +22,13 @@
package org.solovyev.android.calculator;
-import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
+import android.content.res.TypedArray;
+import android.graphics.Color;
import android.support.annotation.StyleRes;
+import android.util.SparseArray;
+import android.view.ContextThemeWrapper;
import jscl.AngleUnit;
import jscl.NumeralBase;
import org.solovyev.android.calculator.math.MathType;
@@ -110,9 +114,11 @@ public final class Preferences {
metro_purple_theme(R.style.cpp_metro_purple_theme),
metro_green_theme(R.style.cpp_metro_green_theme),
material_theme(R.style.Cpp_Theme_Material),
- material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Wizard_Light, R.style.Cpp_Theme_Settings_Light),
+ material_light_theme(R.style.Cpp_Theme_Material_Light, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Settings_Light),
;
+ private static final SparseArray textColors = new SparseArray<>();
+
private final int themeId;
private final int wizardThemeId;
private final int settingsThemeId;
@@ -120,6 +126,7 @@ public final class Preferences {
Theme(@StyleRes int themeId) {
this(themeId, R.style.Cpp_Theme_Wizard, R.style.Cpp_Theme_Settings);
}
+
Theme(@StyleRes int themeId, @StyleRes int wizardThemeId, @StyleRes int settingsThemeId) {
this.themeId = themeId;
this.wizardThemeId = wizardThemeId;
@@ -130,15 +137,41 @@ public final class Preferences {
return getThemeId(null);
}
- public int getThemeId(@Nullable Activity activity) {
- if (activity instanceof WizardActivity) {
+ public int getThemeId(@Nullable Context context) {
+ if (context instanceof WizardActivity) {
return wizardThemeId;
}
- if (activity instanceof BasePreferencesActivity) {
+ if (context instanceof BasePreferencesActivity) {
return settingsThemeId;
}
return themeId;
}
+
+ @Nonnull
+ public TextColor getTextColor(@Nonnull Context context) {
+ final int themeId = getThemeId(context);
+ TextColor textColor = textColors.get(themeId);
+ if (textColor == null) {
+ final ContextThemeWrapper themeContext = new ContextThemeWrapper(context, themeId);
+ final TypedArray a = themeContext.obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary, android.R.attr.textColorPrimaryInverse});
+ final int normal = a.getColor(0, Color.BLACK);
+ final int error = a.getColor(1, Color.WHITE);
+ a.recycle();
+ textColor = new TextColor(normal, error);
+ textColors.append(themeId, textColor);
+ }
+ return textColor;
+ }
+ }
+
+ public static final class TextColor{
+ public final int normal;
+ public final int error;
+
+ TextColor(int normal, int error) {
+ this.normal = normal;
+ this.error = error;
+ }
}
public static enum Layout {
main_calculator(R.layout.main_calculator, R.string.p_layout_calculator, true),
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
index 44f30788..df4e3f34 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFragment.java
@@ -26,7 +26,7 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
-
+import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
@@ -69,7 +69,8 @@ public class CalculatorPlotFragment extends AbstractCalculatorPlotFragment {
graphView = new CalculatorGraph2dView(getActivity());
}
- graphView.init(PlotViewDef.newInstance(Color.WHITE, Color.WHITE, Color.DKGRAY, getBgColor()));
+ final int color = App.getTheme().getTextColor(getActivity()).normal;
+ graphView.init(PlotViewDef.newInstance(color, color, Color.DKGRAY, getBgColor()));
final PlotBoundaries boundaries = plotData.getBoundaries();
graphView.setXRange(boundaries.getXMin(), boundaries.getXMax());
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java b/android-app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java
index 4fee048f..58cd10c4 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java
@@ -1,18 +1,22 @@
package org.solovyev.android.calculator.view;
+import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.Html;
import android.util.Log;
+import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.CalculatorParseException;
+import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.text.TextProcessor;
import org.solovyev.android.calculator.text.TextProcessorEditorResult;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import static org.solovyev.android.calculator.Preferences.Gui.colorDisplay;
-import static org.solovyev.android.calculator.view.TextHighlighter.WHITE;
+import static org.solovyev.android.calculator.Preferences.Gui.theme;
/**
* User: serso
@@ -23,7 +27,8 @@ public final class EditorTextProcessor implements TextProcessor textHighlighter = new TextHighlighter(WHITE, true);
+ @Nullable
+ private TextProcessor textHighlighter;
public EditorTextProcessor() {
}
@@ -42,7 +47,7 @@ public final class EditorTextProcessor implements TextProcessor getTextHighlighter() {
+ if (textHighlighter == null) {
+ onSharedPreferenceChanged(App.getPreferences(), theme.getKey());
+ }
+ return textHighlighter;
+ }
+
public boolean isHighlightText() {
return highlightText;
}
@@ -68,8 +81,17 @@ public final class EditorTextProcessor implements TextProcessor> 16) & 0xFF;
- //this.colorGreen = Color.green(baseColor);
- this.colorGreen = (color >> 8) & 0xFF;
- //this.colorBlue = Color.blue(baseColor);
- this.colorBlue = color & 0xFF;
+ //this.red = Color.red(baseColor);
+ red = red(color);
+ //this.green = Color.green(baseColor);
+ green = green(color);
+ //this.blue = Color.blue(baseColor);
+ blue = blue(color);
+ dark = isDark(red, green, blue);
+ }
+
+ private static int blue(int color) {
+ return color & 0xFF;
+ }
+
+ private static int green(int color) {
+ return (color >> 8) & 0xFF;
+ }
+
+ private static int red(int color) {
+ return (color >> 16) & 0xFF;
+ }
+
+ public static boolean isDark(int color) {
+ return isDark(red(color), green(color), color & 0xFF);
+ }
+
+ public static boolean isDark(int red, int green, int blue) {
+ final float y = 0.2126f * red + 0.7152f * green + 0.0722f * blue;
+ return y < 128;
}
@Nonnull
@@ -201,13 +222,14 @@ public class TextHighlighter implements TextProcessor
+ a:color="@color/ripple_material_dark">
\ No newline at end of file
diff --git a/android-app/src/main/res/drawable-v21/material_blue_button.xml b/android-app/src/main/res/drawable-v21/material_blue_button.xml
index 5f9f634d..bd4d0a3c 100644
--- a/android-app/src/main/res/drawable-v21/material_blue_button.xml
+++ b/android-app/src/main/res/drawable-v21/material_blue_button.xml
@@ -23,7 +23,7 @@
-->
+ a:color="@color/ripple_material_dark">
-
diff --git a/android-app/src/main/res/drawable-v21/material_button_dark.xml b/android-app/src/main/res/drawable-v21/material_button_dark.xml
index 97c0ea90..e0c1898a 100644
--- a/android-app/src/main/res/drawable-v21/material_button_dark.xml
+++ b/android-app/src/main/res/drawable-v21/material_button_dark.xml
@@ -23,7 +23,7 @@
-->
+ a:color="@color/ripple_material_dark">
-
diff --git a/android-app/src/main/res/drawable-v21/material_button_light.xml b/android-app/src/main/res/drawable-v21/material_button_light.xml
index d26ac324..824a235f 100644
--- a/android-app/src/main/res/drawable-v21/material_button_light.xml
+++ b/android-app/src/main/res/drawable-v21/material_button_light.xml
@@ -23,7 +23,7 @@
-->
+ a:color="@color/ripple_material_dark">
-
diff --git a/android-app/src/main/res/drawable-v21/material_button_light_primary.xml b/android-app/src/main/res/drawable-v21/material_button_light_primary.xml
index 227ecb7d..19b747ca 100644
--- a/android-app/src/main/res/drawable-v21/material_button_light_primary.xml
+++ b/android-app/src/main/res/drawable-v21/material_button_light_primary.xml
@@ -23,7 +23,7 @@
-->
+ a:color="@color/ripple_material_dark">
-
diff --git a/android-app/src/main/res/drawable-v21/metro_blue_button.xml b/android-app/src/main/res/drawable-v21/metro_blue_button.xml
index b5813a69..fea6b1e1 100644
--- a/android-app/src/main/res/drawable-v21/metro_blue_button.xml
+++ b/android-app/src/main/res/drawable-v21/metro_blue_button.xml
@@ -23,6 +23,6 @@
-->
+ a:color="@color/ripple_material_dark">
diff --git a/android-app/src/main/res/drawable-v21/metro_button_dark.xml b/android-app/src/main/res/drawable-v21/metro_button_dark.xml
index 77abe94b..df51f009 100644
--- a/android-app/src/main/res/drawable-v21/metro_button_dark.xml
+++ b/android-app/src/main/res/drawable-v21/metro_button_dark.xml
@@ -23,6 +23,6 @@
-->
+ a:color="@color/ripple_material_dark">
\ No newline at end of file
diff --git a/android-app/src/main/res/drawable-v21/metro_button_green.xml b/android-app/src/main/res/drawable-v21/metro_button_green.xml
index 94aca4c9..b579690b 100644
--- a/android-app/src/main/res/drawable-v21/metro_button_green.xml
+++ b/android-app/src/main/res/drawable-v21/metro_button_green.xml
@@ -23,6 +23,6 @@
-->
+ a:color="@color/ripple_material_dark">
\ No newline at end of file
diff --git a/android-app/src/main/res/drawable-v21/metro_button_light.xml b/android-app/src/main/res/drawable-v21/metro_button_light.xml
index 5619f6ea..c8087378 100644
--- a/android-app/src/main/res/drawable-v21/metro_button_light.xml
+++ b/android-app/src/main/res/drawable-v21/metro_button_light.xml
@@ -23,6 +23,6 @@
-->
+ a:color="@color/ripple_material_dark">
\ No newline at end of file
diff --git a/android-app/src/main/res/drawable-v21/metro_button_purple.xml b/android-app/src/main/res/drawable-v21/metro_button_purple.xml
index 74f7b440..2a137955 100644
--- a/android-app/src/main/res/drawable-v21/metro_button_purple.xml
+++ b/android-app/src/main/res/drawable-v21/metro_button_purple.xml
@@ -23,6 +23,6 @@
-->
+ a:color="@color/ripple_material_dark">
\ No newline at end of file
diff --git a/android-app/src/main/res/layout/about_fragment.xml b/android-app/src/main/res/layout/about_fragment.xml
index 450e8d89..9fed2e3b 100644
--- a/android-app/src/main/res/layout/about_fragment.xml
+++ b/android-app/src/main/res/layout/about_fragment.xml
@@ -25,8 +25,7 @@
+ a:layout_height="fill_parent">
@@ -8,7 +9,8 @@
android:id="@+id/action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:minHeight="?attr/actionBarSize" />
+ android:minHeight="?attr/actionBarSize"
+ app:theme="?attr/cpp_toolbar_theme"/>
+ style="@style/CppListViewItemTextPrimary.History"/>
+ style="@style/CppListViewItemTextSecondary"/>
diff --git a/android-app/src/main/res/layout/math_entity.xml b/android-app/src/main/res/layout/math_entity.xml
index b2510c9c..ef574ed6 100644
--- a/android-app/src/main/res/layout/math_entity.xml
+++ b/android-app/src/main/res/layout/math_entity.xml
@@ -38,13 +38,13 @@
a:id="@+id/math_entity_text"
a:layout_height="wrap_content"
a:layout_width="match_parent"
- style="@style/math_entity_text"/>
+ style="@style/CppListViewItemTextPrimary"/>
+ style="@style/CppListViewItemTextSecondary"/>
+ a:layout_height="fill_parent">
+ style="@style/CppListViewItemTextPrimary.History" />
+ style="@style/CppListViewItemTextSecondary" />
+ style="@style/CppListViewItemTextSecondary" />
\ No newline at end of file
diff --git a/android-app/src/main/res/values-cs/text_strings.xml b/android-app/src/main/res/values-cs/text_strings.xml
index d5b6e40d..463d24cd 100644
--- a/android-app/src/main/res/values-cs/text_strings.xml
+++ b/android-app/src/main/res/values-cs/text_strings.xml
@@ -78,7 +78,7 @@
Šedá
Fialová
Světle modrá
- Metro Modrá (výchozí)
+ Metro Modrá
Metro Zelená
Metro Fialová
Přesnost výsledku (všechny výpočty jsou prováděny s maximální přesností bez ohledu na tuto hodnotu)
diff --git a/android-app/src/main/res/values-de/text_strings.xml b/android-app/src/main/res/values-de/text_strings.xml
index 024d3dc7..cd0bd8f6 100644
--- a/android-app/src/main/res/values-de/text_strings.xml
+++ b/android-app/src/main/res/values-de/text_strings.xml
@@ -78,7 +78,7 @@
Grau
Violett
Hellblau
- Metro Blau (Standard)
+ Metro Blau
Metro Grün
Metro Lila
Genauigkeit des Resultats (alle Berechnungen sind mit höchster Genauigkeit unabhängig von dieser Option)
diff --git a/android-app/src/main/res/values-el/text_strings.xml b/android-app/src/main/res/values-el/text_strings.xml
index 2cdcfe0d..3cf4ddd3 100644
--- a/android-app/src/main/res/values-el/text_strings.xml
+++ b/android-app/src/main/res/values-el/text_strings.xml
@@ -84,7 +84,7 @@
Γκρι
Βιολετί
Ανοιχτό μπλε
- Metro Blue (Default)
+ Metro Blue
Metro Green
Metro Purple
Ακρίβεια τιμής αποτελέσματος (όλοι οι υπολογισμοί γίνονται με τη μεγαλύτερη ακρίβεια
diff --git a/android-app/src/main/res/values-es/text_strings.xml b/android-app/src/main/res/values-es/text_strings.xml
index 6cdba6c9..5dd3048c 100644
--- a/android-app/src/main/res/values-es/text_strings.xml
+++ b/android-app/src/main/res/values-es/text_strings.xml
@@ -81,7 +81,7 @@
Gris
Violeta
Azul claro
- Metro Azul (Predeterminado)
+ Metro Azul
Metro Verde
Metro Morado
Precisión en el valor del resultado (todos los cálculos se realizan con la máxima precisión, independientemente del valor de esta opción)
diff --git a/android-app/src/main/res/values-fi/text_strings.xml b/android-app/src/main/res/values-fi/text_strings.xml
index ac3df930..91b1ffe1 100644
--- a/android-app/src/main/res/values-fi/text_strings.xml
+++ b/android-app/src/main/res/values-fi/text_strings.xml
@@ -78,7 +78,7 @@
Harmaa
Violetti
Vaaleansininen
- Metron Sininen (oletus)
+ Metron Sininen
Metron vihreä
Metro violetti
Tarkkuus tuloksen arvoa (kaikki laskelmat ovat tehneet tarkkuudella riippumatta tämän asetuksen arvosta)
diff --git a/android-app/src/main/res/values-fr/text_strings.xml b/android-app/src/main/res/values-fr/text_strings.xml
index 7bb519bf..0b3c844f 100644
--- a/android-app/src/main/res/values-fr/text_strings.xml
+++ b/android-app/src/main/res/values-fr/text_strings.xml
@@ -78,7 +78,7 @@
Gris
Violet
Bleu clair
- Métro bleu (par défaut)
+ Métro bleu
Métro vert
Métro violet
Précision de la valeur du résultat (tous les calculs sont faits avec la précision maximale quelle que soit la valeur de cette option)
diff --git a/android-app/src/main/res/values-it/text_strings.xml b/android-app/src/main/res/values-it/text_strings.xml
index 1e9dcf16..625b403a 100644
--- a/android-app/src/main/res/values-it/text_strings.xml
+++ b/android-app/src/main/res/values-it/text_strings.xml
@@ -81,7 +81,7 @@
Predefinito
Viola
Blu chiaro
- Metro Blue (Default)
+ Metro Blue
Metro Green
Metro Purple
Precisione del risultato (tutti i calcoli sono fatti con la massima
diff --git a/android-app/src/main/res/values-ja/text_strings.xml b/android-app/src/main/res/values-ja/text_strings.xml
index df5aa9c9..2f3affd4 100644
--- a/android-app/src/main/res/values-ja/text_strings.xml
+++ b/android-app/src/main/res/values-ja/text_strings.xml
@@ -80,7 +80,7 @@
グレー
バイオレット
ライトブルー
- メトロブルー(デフォルト)
+ メトロブルー
メトログリーン
メトロパープル
計算結果の有効桁数(計算はこの設定に関係なく最大精度で行われます)
diff --git a/android-app/src/main/res/values-nl/text_strings.xml b/android-app/src/main/res/values-nl/text_strings.xml
index 0ddca0d5..a01f2170 100644
--- a/android-app/src/main/res/values-nl/text_strings.xml
+++ b/android-app/src/main/res/values-nl/text_strings.xml
@@ -78,7 +78,7 @@
Grijs
Violet
Lichtblauw
- Metro blauw (standaard)
+ Metro blauw
Metro groen
Metro paars
Nauwkeurigheid van de uitkomst (alle berekeningen worden gedaan met maximale nauwkeurigheid, onafhankelijk van deze optie)
diff --git a/android-app/src/main/res/values-pl/text_strings.xml b/android-app/src/main/res/values-pl/text_strings.xml
index 2d38ab13..cc861c54 100644
--- a/android-app/src/main/res/values-pl/text_strings.xml
+++ b/android-app/src/main/res/values-pl/text_strings.xml
@@ -78,7 +78,7 @@
Szary
Fioletowy
Jasnoniebieski
- Niebieski Metro (domyślny)
+ Niebieski Metro
Zielony Metro
Fioletowy Metro
Dokładność wyświetlanego wyniku (wszystkie obliczenia są wykonywane przy maksymalnej dokładności, niezależnie od tej opcji)
diff --git a/android-app/src/main/res/values-pt-rbr/text_strings.xml b/android-app/src/main/res/values-pt-rbr/text_strings.xml
index 0ccb225c..92ab3252 100644
--- a/android-app/src/main/res/values-pt-rbr/text_strings.xml
+++ b/android-app/src/main/res/values-pt-rbr/text_strings.xml
@@ -78,7 +78,7 @@
Cinza
Violeta
Azul Claro
- Metro Blue (Padrão)
+ Metro Blue
Metro Green
Metro Purple (Roxo)
Precisão do resultado (todos os cálculos são feitos com precisão máxima, independentemente do valor desta opção)
diff --git a/android-app/src/main/res/values-ru/text_strings.xml b/android-app/src/main/res/values-ru/text_strings.xml
index 6ebb924d..4972c9b8 100644
--- a/android-app/src/main/res/values-ru/text_strings.xml
+++ b/android-app/src/main/res/values-ru/text_strings.xml
@@ -89,7 +89,7 @@
Серая
Фиолетовая
Голубая
- Метро Синяя (По умолчанию)
+ Метро Синяя
Метро Зелёная
Метро Фиолетовая
Точность результата(все вычисления производятся максимально точно)
diff --git a/android-app/src/main/res/values-uk/text_strings.xml b/android-app/src/main/res/values-uk/text_strings.xml
index 4e107849..8ba76c09 100644
--- a/android-app/src/main/res/values-uk/text_strings.xml
+++ b/android-app/src/main/res/values-uk/text_strings.xml
@@ -82,7 +82,7 @@
Сіра
Фіолетова
Блакитна
- Метро Синя (типова)
+ Метро Синя
Метро Зелена
Метро Пурпурова
Точність відображення результату (усі обчислення проводяться максимально точно, незалежно від цього параметру)
diff --git a/android-app/src/main/res/values-vi/text_strings.xml b/android-app/src/main/res/values-vi/text_strings.xml
index 38d77a1f..96d80ab8 100644
--- a/android-app/src/main/res/values-vi/text_strings.xml
+++ b/android-app/src/main/res/values-vi/text_strings.xml
@@ -78,7 +78,7 @@
Xám
Tím
Xanh nhạt
- Metro Blue (Mặc định)
+ Metro Blue
Metro Green
Metro Purple
Độ chính xác của giá trị kết quả (Tất cả tính toán được thực hiện với độ chính xác tối đa bất kể giá trị của tùy chọn này)
diff --git a/android-app/src/main/res/values-zh-rcn/text_strings.xml b/android-app/src/main/res/values-zh-rcn/text_strings.xml
index 99496299..0cf67dfa 100644
--- a/android-app/src/main/res/values-zh-rcn/text_strings.xml
+++ b/android-app/src/main/res/values-zh-rcn/text_strings.xml
@@ -78,7 +78,7 @@
灰色
紫色
浅蓝色
- Metro蓝 (默认)
+ Metro蓝
Metro绿
Metro紫
结果显示的精确度(无论此项如何设置,所有的计算都使用最大
diff --git a/android-app/src/main/res/values-zh-rtw/text_strings.xml b/android-app/src/main/res/values-zh-rtw/text_strings.xml
index 52543264..b933e324 100644
--- a/android-app/src/main/res/values-zh-rtw/text_strings.xml
+++ b/android-app/src/main/res/values-zh-rtw/text_strings.xml
@@ -83,7 +83,7 @@
灰色
紫色
淺藍色
- 現代藍(預設)
+ 現代藍
現代綠
現代紫
計算結果值的精確度(不論選項值為多少,所有計算都使用最大精確度)
diff --git a/android-app/src/main/res/values/arrays.xml b/android-app/src/main/res/values/arrays.xml
index df4d5504..6237ebdf 100644
--- a/android-app/src/main/res/values/arrays.xml
+++ b/android-app/src/main/res/values/arrays.xml
@@ -22,24 +22,18 @@
- - @string/p_default_theme
- - @string/p_violet_theme
- - @string/p_light_blue_theme
+ - @string/p_material_theme
+ - @string/p_material_light_theme
- @string/p_metro_blue_theme
- @string/p_metro_green_theme
- @string/p_metro_purple_theme
- - @string/p_material_theme
- - @string/p_material_light_theme
- - default_theme
- - violet_theme
- - light_blue_theme
+ - material_theme
+ - material_light_theme
- metro_blue_theme
- metro_green_theme
- metro_purple_theme
- - material_theme
- - material_light_theme
diff --git a/android-app/src/main/res/values/attributes.xml b/android-app/src/main/res/values/attributes.xml
index 542be23b..3b4eb506 100644
--- a/android-app/src/main/res/values/attributes.xml
+++ b/android-app/src/main/res/values/attributes.xml
@@ -28,5 +28,10 @@
+
+
+
+
+
diff --git a/android-app/src/main/res/values/colors.xml b/android-app/src/main/res/values/colors.xml
index 084e00a3..4557a146 100644
--- a/android-app/src/main/res/values/colors.xml
+++ b/android-app/src/main/res/values/colors.xml
@@ -22,8 +22,12 @@
#ff2e2e2e
- #ffeeeeee
- #ff393939
+
+ #ffe6e6e6
+ #424242
+ @color/cpp_text_inverse
+ @color/cpp_text
+
#ffffffff
#ffffff99
#ffffffff
@@ -32,7 +36,6 @@
#fff6f1ef
#FAFAFA
#9E9E9E
- @color/cpp_material_grey
#FAFAFA
#424242
#616161
diff --git a/android-app/src/main/res/values/styles.xml b/android-app/src/main/res/values/styles.xml
index 85ccb170..c794fda1 100644
--- a/android-app/src/main/res/values/styles.xml
+++ b/android-app/src/main/res/values/styles.xml
@@ -74,7 +74,7 @@
- @dimen/cpp_editor_text_size_mobile
-
+
+
+
+
+
+
-
-
-
-
\ No newline at end of file
diff --git a/android-app/src/main/res/values/styles_var.xml b/android-app/src/main/res/values/styles_var.xml
deleted file mode 100644
index 61599a1f..00000000
--- a/android-app/src/main/res/values/styles_var.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android-app/src/main/res/values/text_strings.xml b/android-app/src/main/res/values/text_strings.xml
index 8295d160..b7bd761b 100644
--- a/android-app/src/main/res/values/text_strings.xml
+++ b/android-app/src/main/res/values/text_strings.xml
@@ -86,7 +86,7 @@
Grey
Violet
Light Blue
- Metro Blue (Default)
+ Metro Blue
Metro Green
Metro Purple
Material
diff --git a/android-app/src/main/res/values/text_wizard.xml b/android-app/src/main/res/values/text_wizard.xml
index 4b7a268e..f76f2661 100644
--- a/android-app/src/main/res/values/text_wizard.xml
+++ b/android-app/src/main/res/values/text_wizard.xml
@@ -21,15 +21,15 @@
Start wizard
Excellent! Tap the button one more time to try again
Tap the button below once to use 9
- Drag from the center of the button up to use %
- Drag from the center of the button to the left to use sin
- Drag from the center of the button down to use ^2
+ Swipe from the center of the button up to use %
+ Swipe from the center of the button to the left to use sin
+ Swipe from the center of the button down to use ^2
Welcome
Choose layout
Choose mode
Choose theme
Calculator in a separate window
- Drag button basics
+ Swipe button basics
The app is set up and ready to use.
Almost done!
Calculator++ is free and open-source: all the features are free
@@ -44,7 +44,7 @@
using other apps on your device
Enable
- Drag button is an exclusive feature of Calculator++ which provides
+ Swipe button is an exclusive feature of Calculator++ which provides
fast access to the secondary functions
Do you really want to finish wizard?
diff --git a/android-app/src/main/res/values/theme.xml b/android-app/src/main/res/values/theme.xml
index b1a0678d..04729a6a 100644
--- a/android-app/src/main/res/values/theme.xml
+++ b/android-app/src/main/res/values/theme.xml
@@ -37,6 +37,9 @@
- @style/CppActionBar
- @color/cpp_main_bg
+ - @color/cpp_material_grey
+ - @color/cpp_text
+ - @color/cpp_text_error
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
index 43db39a2..e7dea297 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
@@ -32,7 +32,7 @@ import javax.annotation.Nonnull;
public enum PlotLineColor {
// Color.WHITE
- white(0xFFFFFFFF),
+ white(0xFFBBBBBB),
blue(0xFF10648C),