changes: themes support, scale for direction text

This commit is contained in:
serso 2011-10-15 22:11:59 +04:00
parent c3817e417a
commit 071ae7cb36
22 changed files with 117 additions and 39 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<shape xmlns:a="http://schemas.android.com/apk/res/android">
<gradient a:startColor="#000d1f"
a:endColor="#002255"
a:angle="90"/>
<corners a:radius="0dp" />
</shape>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2009-2011. Created by serso aka se.solovyev.
~ For more information, please, contact se.solovyev@gmail.com
~ or visit http://se.solovyev.org
-->
<shape xmlns:a="http://schemas.android.com/apk/res/android">
<gradient a:startColor="#2b0325"
a:endColor="#4f1c47"
a:angle="90"/>
<corners a:radius="0dp"/>
</shape>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:a="http://schemas.android.com/apk/res/android"> <shape xmlns:a="http://schemas.android.com/apk/res/android">
<gradient a:startColor="#002761" <gradient a:startColor="#001c45"
a:endColor="#005ce5" a:endColor="#003481"
a:angle="90"/> a:angle="90"/>
<corners a:radius="0dp" /> <corners a:radius="0dp" />
</shape> </shape>

View File

@ -20,9 +20,10 @@
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android" <org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/leftButton" a:id="@+id/leftButton"
calc:textUp="↞" calc:textUp="◀◀"
a:text="←" a:text="◀"
style="@style/control_button_style" calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveLeftButtonClickHandler" a:onClick="moveLeftButtonClickHandler"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
@ -33,7 +34,7 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/eraseButton" a:id="@+id/eraseButton"
a:drawableTop="@drawable/sym_keyboard_delete" a:drawableTop="@drawable/sym_keyboard_delete"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="eraseButtonClickHandler" a:onClick="eraseButtonClickHandler"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
@ -50,7 +51,7 @@
a:id="@+id/clearButton" a:id="@+id/clearButton"
a:text="@string/c_clear" a:text="@string/c_clear"
a:textStyle="bold" a:textStyle="bold"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="clearButtonClickHandler" a:onClick="clearButtonClickHandler"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
@ -59,9 +60,10 @@
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android" <org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/rightButton" a:id="@+id/rightButton"
calc:textUp="↠" calc:textUp="▶▶"
a:text="→" a:text="▶"
style="@style/control_button_style" calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveRightButtonClickHandler" a:onClick="moveRightButtonClickHandler"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"

View File

@ -11,5 +11,5 @@
a:id="@+id/clearButton" a:id="@+id/clearButton"
a:text="@string/c_clear" a:text="@string/c_clear"
a:textStyle="bold" a:textStyle="bold"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="clearButtonClickHandler"/> a:onClick="clearButtonClickHandler"/>

View File

@ -10,5 +10,5 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/pasteButton" a:id="@+id/pasteButton"
a:drawableTop="@drawable/copy" a:drawableTop="@drawable/copy"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="copyButtonClickHandler"/> a:onClick="copyButtonClickHandler"/>

View File

@ -10,5 +10,5 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/pasteButton" a:id="@+id/pasteButton"
a:drawableTop="@drawable/heart" a:drawableTop="@drawable/heart"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="donateButtonClickHandler"/> a:onClick="donateButtonClickHandler"/>

View File

@ -11,5 +11,5 @@
a:text="=" a:text="="
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
style="@style/control_button_style" style="?controlButtonStyle"
a:onClick="numericButtonClickHandler"/> a:onClick="numericButtonClickHandler"/>

View File

@ -10,5 +10,5 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/eraseButton" a:id="@+id/eraseButton"
a:drawableTop="@drawable/sym_keyboard_delete" a:drawableTop="@drawable/sym_keyboard_delete"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="eraseButtonClickHandler"/> a:onClick="eraseButtonClickHandler"/>

View File

@ -11,7 +11,7 @@
a:text="@string/c_history_button" a:text="@string/c_history_button"
calc:textUp="@string/c_undo" calc:textUp="@string/c_undo"
calc:textDown="@string/c_redo" calc:textDown="@string/c_redo"
style="@style/control_button_style" style="?controlButtonStyle"
a:textSize="18dp" a:textSize="18dp"
a:textStyle="bold" a:textStyle="bold"
a:onClick="historyButtonClickHandler"/> a:onClick="historyButtonClickHandler"/>

View File

@ -9,7 +9,8 @@
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android" <org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/leftButton" a:id="@+id/leftButton"
calc:textUp="↞" calc:textUp="◀◀"
a:text="←" a:text="◀"
style="@style/control_button_style" calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveLeftButtonClickHandler"/> a:onClick="moveLeftButtonClickHandler"/>

View File

@ -10,5 +10,5 @@
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/pasteButton" a:id="@+id/pasteButton"
a:drawableTop="@drawable/paste" a:drawableTop="@drawable/paste"
style="@style/control_image_button_style" style="?controlImageButtonStyle"
a:onClick="pasteButtonClickHandler"/> a:onClick="pasteButtonClickHandler"/>

View File

@ -9,7 +9,8 @@
<org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android" <org.solovyev.android.view.widgets.DirectionDragButton xmlns:a="http://schemas.android.com/apk/res/android"
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator" xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
a:id="@+id/rightButton" a:id="@+id/rightButton"
calc:textUp="↠" calc:textUp="▶▶"
a:text="→" a:text="▶"
style="@style/control_button_style" calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveRightButtonClickHandler"/> a:onClick="moveRightButtonClickHandler"/>

View File

@ -11,4 +11,4 @@
a:text="π,…" a:text="π,…"
a:textStyle="italic" a:textStyle="italic"
a:onClick="varsButtonClickHandler" a:onClick="varsButtonClickHandler"
style="@style/control_button_style"/> style="?controlButtonStyle"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="c_app_name">Калькулятор</string> <string name="c_app_name">Калькулятор++</string>
<string name="c_app_settings">Калькулятор</string> <string name="c_app_settings">Настройки</string>
<string name="c_syntax_error">Ошибка</string> <string name="c_syntax_error">Ошибка</string>
<string name="c_result_copied">Результат скопирован в буфер!</string> <string name="c_result_copied">Результат скопирован в буфер!</string>
<string name="c_settings">Настройки</string> <string name="c_settings">Настройки</string>
@ -75,5 +75,12 @@
<string name="c_history_is_empty">История пуста!</string> <string name="c_history_is_empty">История пуста!</string>
<string name="c_app_history">История</string> <string name="c_app_history">История</string>
<string name="c_char_is_not_accepted">Символ \'%s\' не допустим в названии переменной!</string> <string name="c_char_is_not_accepted">Символ \'%s\' не допустим в названии переменной!</string>
<string name="c_calc_theme">Тема оформления</string>
<string name="p_default_theme">По умолчанию</string>
<string name="p_violet_theme">Фиолетовая</string>
<string name="p_light_blue_theme">Голубая</string>
<string name="c_calc_result_precision_summary">Точность результата(все вычисления производятся максимально точно)</string>
<string name="c_calc_color_display_summary">Включает/выключает подсветку синтаксиса в поле редактирования калькулятора</string>
<string name="c_calc_theme_summary">Устанавливает тему оформления приложения</string>
</resources> </resources>

View File

@ -6,9 +6,9 @@
<resources> <resources>
<string-array name="p_theme_names"> <string-array name="p_theme_names">
<item>Default</item> <item>@string/p_default_theme</item>
<item>Violet</item> <item>@string/p_violet_theme</item>
<item>Light blue</item> <item>@string/p_light_blue_theme</item>
</string-array> </string-array>
<string-array name="p_theme_values"> <string-array name="p_theme_values">
<item>default_theme</item> <item>default_theme</item>

View File

@ -12,5 +12,7 @@
</declare-styleable> </declare-styleable>
<attr name="digitButtonStyle" format="reference" /> <attr name="digitButtonStyle" format="reference" />
<attr name="controlButtonStyle" format="reference" />
<attr name="controlImageButtonStyle" format="reference" />
</resources> </resources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="c_app_name">Calculator</string> <string name="c_app_name">Calculator++</string>
<string name="c_app_settings">Calculator</string> <string name="c_app_settings">Settings</string>
<string name="c_syntax_error">Syntax error</string> <string name="c_syntax_error">Syntax error</string>
<string name="c_result_copied">Result copied to clipboard!</string> <string name="c_result_copied">Result copied to clipboard!</string>
<string name="c_settings">Settings</string> <string name="c_settings">Settings</string>
@ -76,4 +76,10 @@
<string name="c_app_history">History</string> <string name="c_app_history">History</string>
<string name="c_char_is_not_accepted">Character \'%s\' is not accepted in variable name!</string> <string name="c_char_is_not_accepted">Character \'%s\' is not accepted in variable name!</string>
<string name="c_calc_theme">Theme</string> <string name="c_calc_theme">Theme</string>
<string name="p_default_theme">Default</string>
<string name="p_violet_theme">Violet</string>
<string name="p_light_blue_theme">Light Blue</string>
<string name="c_calc_result_precision_summary">Precision of result value (all calculations are done with maximum precision regardless of the value of this option)</string>
<string name="c_calc_color_display_summary">Enables/disables colouring and styling in calculator editor</string>
<string name="c_calc_theme_summary">Sets the theme for calculator</string>
</resources> </resources>

View File

@ -30,9 +30,25 @@
<item name="android:background">@drawable/light_blue_button</item> <item name="android:background">@drawable/light_blue_button</item>
</style> </style>
<style name="control_button_style" parent="button_style"/> <style name="default_control_button_style" parent="button_style"/>
<style name="control_image_button_style" parent="control_button_style"> <style name="violet_control_button_style" parent="button_style">
<item name="android:background">@drawable/dark_violet_button</item>
</style>
<style name="light_blue_control_button_style" parent="button_style">
<item name="android:background">@drawable/dark_blue_button</item>
</style>
<style name="default_control_image_button_style" parent="default_control_button_style">
<item name="android:padding">6dp</item>
</style>
<style name="violet_control_image_button_style" parent="violet_control_button_style">
<item name="android:padding">6dp</item>
</style>
<style name="light_blue_control_image_button_style" parent="light_blue_control_button_style">
<item name="android:padding">6dp</item> <item name="android:padding">6dp</item>
</style> </style>
@ -68,14 +84,20 @@
<style name="default_theme"> <style name="default_theme">
<item name="digitButtonStyle">@style/default_digit_button_style</item> <item name="digitButtonStyle">@style/default_digit_button_style</item>
<item name="controlButtonStyle">@style/default_control_button_style</item>
<item name="controlImageButtonStyle">@style/default_control_image_button_style</item>
</style> </style>
<style name="violet_theme"> <style name="violet_theme">
<item name="digitButtonStyle">@style/violet_digit_button_style</item> <item name="digitButtonStyle">@style/violet_digit_button_style</item>
<item name="controlButtonStyle">@style/violet_control_button_style</item>
<item name="controlImageButtonStyle">@style/violet_control_image_button_style</item>
</style> </style>
<style name="light_blue_theme"> <style name="light_blue_theme">
<item name="digitButtonStyle">@style/light_blue_digit_button_style</item> <item name="digitButtonStyle">@style/light_blue_digit_button_style</item>
<item name="controlButtonStyle">@style/light_blue_control_button_style</item>
<item name="controlImageButtonStyle">@style/light_blue_control_image_button_style</item>
</style> </style>
</resources> </resources>

View File

@ -7,20 +7,22 @@
<org.solovyev.android.view.prefs.NumberPickerDialogPreference <org.solovyev.android.view.prefs.NumberPickerDialogPreference
a:key="@string/p_calc_result_precision_key" a:key="@string/p_calc_result_precision_key"
a:title="@string/p_calc_result_precision_title" a:title="@string/p_calc_result_precision_title"
a:summary="@string/c_calc_result_precision_summary"
a:defaultValue="5" a:defaultValue="5"
range:boundaries="0;10"/> range:boundaries="0;10"/>
<android.preference.CheckBoxPreference <android.preference.CheckBoxPreference
a:key="@string/p_calc_color_display_key" a:key="@string/p_calc_color_display_key"
a:summary="@string/c_calc_color_display_summary"
a:title="@string/c_calc_color_display_title" a:title="@string/c_calc_color_display_title"
a:defaultValue="true"/> a:defaultValue="true"/>
<ListPreference a:key="@string/p_calc_theme_key" <ListPreference a:key="@string/p_calc_theme_key"
a:title="@string/c_calc_theme" a:title="@string/c_calc_theme"
a:entries="@array/p_theme_names" a:entries="@array/p_theme_names"
a:summary="@string/c_calc_theme_summary"
a:entryValues="@array/p_theme_values" a:entryValues="@array/p_theme_values"
a:persistent="true" a:persistent="true"
a:defaultValue="2"
a:shouldDisableView="false"/> a:shouldDisableView="false"/>

View File

@ -14,13 +14,13 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.*; import android.widget.*;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.solovyev.common.utils.*;
import org.solovyev.common.utils.Filter; import org.solovyev.common.utils.Filter;
import org.solovyev.common.utils.FilterRule;
import org.solovyev.common.utils.FilterRulesChain;
import org.solovyev.common.utils.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
/** /**
@ -62,6 +62,13 @@ public class CalculatorHistoryActivity extends ListActivity {
private static List<CalculatorHistoryState> getHistoryList() { private static List<CalculatorHistoryState> getHistoryList() {
final List<CalculatorHistoryState> calculatorHistoryStates = new ArrayList<CalculatorHistoryState>(CalculatorHistory.instance.getStates()); final List<CalculatorHistoryState> calculatorHistoryStates = new ArrayList<CalculatorHistoryState>(CalculatorHistory.instance.getStates());
Collections.sort(calculatorHistoryStates, new Comparator<CalculatorHistoryState>() {
@Override
public int compare(CalculatorHistoryState state1, CalculatorHistoryState state2) {
return state2.getTime().compareTo(state1.getTime());
}
});
final FilterRulesChain<CalculatorHistoryState> filterRulesChain = new FilterRulesChain<CalculatorHistoryState>(); final FilterRulesChain<CalculatorHistoryState> filterRulesChain = new FilterRulesChain<CalculatorHistoryState>();
filterRulesChain.addFilterRule(new FilterRule<CalculatorHistoryState>() { filterRulesChain.addFilterRule(new FilterRule<CalculatorHistoryState>() {
@Override @Override

View File

@ -34,9 +34,9 @@ public class CursorDragProcessor implements SimpleOnDragListener.DragProcessor{
if (dragButton instanceof DirectionDragButton) { if (dragButton instanceof DirectionDragButton) {
String text = ((DirectionDragButton) dragButton).getText(dragDirection); String text = ((DirectionDragButton) dragButton).getText(dragDirection);
if ("".equals(text)) { if ("◀◀".equals(text)) {
cursorControl.setCursorOnStart(); cursorControl.setCursorOnStart();
} else if ("".equals(text)) { } else if ("▶▶".equals(text)) {
cursorControl.setCursorOnEnd(); cursorControl.setCursorOnEnd();
} }
} }