From 6e45eb176c6427ff3323bf2162f2d86e4c775fc6 Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 15 Oct 2011 22:11:59 +0400 Subject: [PATCH] changes: themes support, scale for direction text --- res/drawable/dark_blue_button.xml | 14 ++++++++++ res/drawable/dark_violet_button.xml | 14 ++++++++++ res/drawable/light_blue_button.xml | 4 +-- res/layout-land/main.xml | 18 +++++++------ res/layout/calc_clear_button.xml | 2 +- res/layout/calc_copy_button.xml | 2 +- res/layout/calc_donate_button.xml | 2 +- res/layout/calc_equals_button.xml | 2 +- res/layout/calc_erase_button.xml | 2 +- res/layout/calc_history_button.xml | 2 +- res/layout/calc_left_button.xml | 7 ++--- res/layout/calc_paste_button.xml | 2 +- res/layout/calc_right_button.xml | 7 ++--- res/layout/calc_vars_button.xml | 2 +- res/values-ru/strings.xml | 11 ++++++-- res/values/arrays.xml | 6 ++--- res/values/attrs.xml | 2 ++ res/values/strings.xml | 10 +++++-- res/values/styles.xml | 26 +++++++++++++++++-- res/xml/main_preferences.xml | 4 ++- .../calculator/CalculatorHistoryActivity.java | 13 +++++++--- .../calculator/CursorDragProcessor.java | 4 +-- 22 files changed, 117 insertions(+), 39 deletions(-) create mode 100644 res/drawable/dark_blue_button.xml create mode 100644 res/drawable/dark_violet_button.xml diff --git a/res/drawable/dark_blue_button.xml b/res/drawable/dark_blue_button.xml new file mode 100644 index 00000000..a2bde68b --- /dev/null +++ b/res/drawable/dark_blue_button.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/res/drawable/dark_violet_button.xml b/res/drawable/dark_violet_button.xml new file mode 100644 index 00000000..b8553175 --- /dev/null +++ b/res/drawable/dark_violet_button.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/res/drawable/light_blue_button.xml b/res/drawable/light_blue_button.xml index 6c2b2aca..4e0ef759 100644 --- a/res/drawable/light_blue_button.xml +++ b/res/drawable/light_blue_button.xml @@ -1,8 +1,8 @@ - diff --git a/res/layout-land/main.xml b/res/layout-land/main.xml index f6172c11..81c635c3 100644 --- a/res/layout-land/main.xml +++ b/res/layout-land/main.xml @@ -20,9 +20,10 @@ \ No newline at end of file diff --git a/res/layout/calc_copy_button.xml b/res/layout/calc_copy_button.xml index f355567c..25349d3a 100644 --- a/res/layout/calc_copy_button.xml +++ b/res/layout/calc_copy_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_donate_button.xml b/res/layout/calc_donate_button.xml index dbf2b420..35b7e7c5 100644 --- a/res/layout/calc_donate_button.xml +++ b/res/layout/calc_donate_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_equals_button.xml b/res/layout/calc_equals_button.xml index 11a5eb96..5bb61c7a 100644 --- a/res/layout/calc_equals_button.xml +++ b/res/layout/calc_equals_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_erase_button.xml b/res/layout/calc_erase_button.xml index bf6c7057..cf59ee93 100644 --- a/res/layout/calc_erase_button.xml +++ b/res/layout/calc_erase_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_history_button.xml b/res/layout/calc_history_button.xml index 210556c0..732f86b1 100644 --- a/res/layout/calc_history_button.xml +++ b/res/layout/calc_history_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_left_button.xml b/res/layout/calc_left_button.xml index b4b3d283..94a44505 100644 --- a/res/layout/calc_left_button.xml +++ b/res/layout/calc_left_button.xml @@ -9,7 +9,8 @@ \ No newline at end of file diff --git a/res/layout/calc_paste_button.xml b/res/layout/calc_paste_button.xml index d592b9f8..45e383ab 100644 --- a/res/layout/calc_paste_button.xml +++ b/res/layout/calc_paste_button.xml @@ -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"/> \ No newline at end of file diff --git a/res/layout/calc_right_button.xml b/res/layout/calc_right_button.xml index a3166423..c3855471 100644 --- a/res/layout/calc_right_button.xml +++ b/res/layout/calc_right_button.xml @@ -9,7 +9,8 @@ \ No newline at end of file diff --git a/res/layout/calc_vars_button.xml b/res/layout/calc_vars_button.xml index ec814a4d..f23111df 100644 --- a/res/layout/calc_vars_button.xml +++ b/res/layout/calc_vars_button.xml @@ -11,4 +11,4 @@ a:text="π,…" a:textStyle="italic" a:onClick="varsButtonClickHandler" - style="@style/control_button_style"/> \ No newline at end of file + style="?controlButtonStyle"/> \ No newline at end of file diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 642e793d..6a7c99f2 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -1,7 +1,7 @@ - Калькулятор - Калькулятор + Калькулятор++ + Настройки Ошибка Результат скопирован в буфер! Настройки @@ -75,5 +75,12 @@ История пуста! История Символ \'%s\' не допустим в названии переменной! + Тема оформления + По умолчанию + Фиолетовая + Голубая + Точность результата(все вычисления производятся максимально точно) + Включает/выключает подсветку синтаксиса в поле редактирования калькулятора + Устанавливает тему оформления приложения diff --git a/res/values/arrays.xml b/res/values/arrays.xml index eebb966c..5c57dc96 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -6,9 +6,9 @@ - Default - Violet - Light blue + @string/p_default_theme + @string/p_violet_theme + @string/p_light_blue_theme default_theme diff --git a/res/values/attrs.xml b/res/values/attrs.xml index dbfabffb..62a9826e 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -12,5 +12,7 @@ + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 604d8e0b..f61e1a53 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,7 +1,7 @@ - Calculator - Calculator + Calculator++ + Settings Syntax error Result copied to clipboard! Settings @@ -76,4 +76,10 @@ History Character \'%s\' is not accepted in variable name! Theme + Default + Violet + Light Blue + Precision of result value (all calculations are done with maximum precision regardless of the value of this option) + Enables/disables colouring and styling in calculator editor + Sets the theme for calculator diff --git a/res/values/styles.xml b/res/values/styles.xml index 38631ef0..9eb4eb98 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -30,9 +30,25 @@ @drawable/light_blue_button - + + + + + + + + @@ -68,14 +84,20 @@ diff --git a/res/xml/main_preferences.xml b/res/xml/main_preferences.xml index efc486d3..7c266342 100644 --- a/res/xml/main_preferences.xml +++ b/res/xml/main_preferences.xml @@ -7,20 +7,22 @@ diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorHistoryActivity.java b/src/main/java/org/solovyev/android/calculator/CalculatorHistoryActivity.java index 09e156d0..788a4ba3 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorHistoryActivity.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorHistoryActivity.java @@ -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 getHistoryList() { final List calculatorHistoryStates = new ArrayList(CalculatorHistory.instance.getStates()); + Collections.sort(calculatorHistoryStates, new Comparator() { + @Override + public int compare(CalculatorHistoryState state1, CalculatorHistoryState state2) { + return state2.getTime().compareTo(state1.getTime()); + } + }); + final FilterRulesChain filterRulesChain = new FilterRulesChain(); filterRulesChain.addFilterRule(new FilterRule() { @Override diff --git a/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java b/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java index f14ce212..29f75f21 100644 --- a/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java +++ b/src/main/java/org/solovyev/android/calculator/CursorDragProcessor.java @@ -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(); } }