changes: themes support, scale for direction text

This commit is contained in:
serso 2011-10-15 22:11:59 +04:00
parent 5ee51fc3f0
commit 6e45eb176c
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"?>
<shape xmlns:a="http://schemas.android.com/apk/res/android">
<gradient a:startColor="#002761"
a:endColor="#005ce5"
<gradient a:startColor="#001c45"
a:endColor="#003481"
a:angle="90"/>
<corners a:radius="0dp" />
</shape>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,8 @@
<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"
a:id="@+id/leftButton"
calc:textUp="↞"
a:text="←"
style="@style/control_button_style"
calc:textUp="◀◀"
a:text="◀"
calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveLeftButtonClickHandler"/>

View File

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

View File

@ -9,7 +9,8 @@
<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"
a:id="@+id/rightButton"
calc:textUp="↠"
a:text="→"
style="@style/control_button_style"
calc:textUp="▶▶"
a:text="▶"
calc:directionTextScale="0.5"
style="?controlButtonStyle"
a:onClick="moveRightButtonClickHandler"/>

View File

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

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="c_app_name">Калькулятор</string>
<string name="c_app_settings">Калькулятор</string>
<string name="c_app_name">Калькулятор++</string>
<string name="c_app_settings">Настройки</string>
<string name="c_syntax_error">Ошибка</string>
<string name="c_result_copied">Результат скопирован в буфер!</string>
<string name="c_settings">Настройки</string>
@ -75,5 +75,12 @@
<string name="c_history_is_empty">История пуста!</string>
<string name="c_app_history">История</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>

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="c_app_name">Calculator</string>
<string name="c_app_settings">Calculator</string>
<string name="c_app_name">Calculator++</string>
<string name="c_app_settings">Settings</string>
<string name="c_syntax_error">Syntax error</string>
<string name="c_result_copied">Result copied to clipboard!</string>
<string name="c_settings">Settings</string>
@ -76,4 +76,10 @@
<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_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>

View File

@ -30,9 +30,25 @@
<item name="android:background">@drawable/light_blue_button</item>
</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>
</style>
@ -68,14 +84,20 @@
<style name="default_theme">
<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 name="violet_theme">
<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 name="light_blue_theme">
<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>
</resources>

View File

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

View File

@ -14,13 +14,13 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import org.jetbrains.annotations.NotNull;
import org.solovyev.common.utils.*;
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.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@ -62,6 +62,13 @@ public class CalculatorHistoryActivity extends ListActivity {
private static List<CalculatorHistoryState> getHistoryList() {
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>();
filterRulesChain.addFilterRule(new FilterRule<CalculatorHistoryState>() {
@Override

View File

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