From f7015ce3fd7d8965c49f875081cf071fd277be10 Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 18 Apr 2016 00:23:21 +0200 Subject: [PATCH] Buttons changes Special glyphs in the built-in font were introduced to be used instead of images --- app/build.gradle | 5 - app/src/main/assets/fonts/Roboto-Regular.ttf | Bin 115204 -> 134436 bytes .../solovyev/android/calculator/Keyboard.java | 91 +++++++++-- .../android/calculator/buttons/CppButton.java | 3 +- .../calculator/buttons/CppSpecialButton.java | 65 +++++++- .../calculator/keyboard/BaseKeyboardUi.java | 28 +++- .../calculator/keyboard/KeyboardUi.java | 150 +----------------- .../keyboard/PartialKeyboardUi.java | 51 ------ .../calculator/view/AngleUnitsButton.java | 68 -------- .../calculator/view/NumeralBasesButton.java | 68 -------- .../android/views/dragbutton/DragView.java | 1 + .../ic_keyboard_arrow_left_white_48dp.png | Bin 226 -> 0 bytes .../ic_keyboard_arrow_right_white_48dp.png | Bin 227 -> 0 bytes .../ic_keyboard_arrow_left_white_48dp.png | Bin 164 -> 0 bytes .../ic_keyboard_arrow_right_white_48dp.png | Bin 163 -> 0 bytes .../ic_keyboard_arrow_left_white_48dp.png | Bin 203 -> 0 bytes .../ic_keyboard_arrow_right_white_48dp.png | Bin 233 -> 0 bytes .../ic_keyboard_arrow_left_white_48dp.png | Bin 285 -> 0 bytes .../ic_keyboard_arrow_right_white_48dp.png | Bin 286 -> 0 bytes .../ic_keyboard_arrow_left_white_48dp.png | Bin 349 -> 0 bytes .../ic_keyboard_arrow_right_white_48dp.png | Bin 354 -> 0 bytes ...4dp.xml => ic_chevron_left_white_24dp.xml} | 10 +- .../ic_favorite_border_white_48dp.xml | 9 ++ .../ic_keyboard_arrow_left_white_48dp.xml | 9 ++ .../ic_keyboard_arrow_right_white_48dp.xml | 9 ++ .../main/res/layout-land/cpp_app_keyboard.xml | 2 +- .../main/res/layout/cpp_app_button_copy.xml | 2 +- .../layout/cpp_app_button_equals_no_bg.xml | 2 +- .../res/layout/cpp_app_button_history.xml | 4 +- .../main/res/layout/cpp_app_button_like.xml | 29 ++++ .../main/res/layout/cpp_app_button_paste.xml | 2 +- app/src/main/res/menu/main.xml | 6 +- app/src/main/res/values/text_glyphs.xml | 13 ++ .../main/res/values/text_non_translatable.xml | 2 - .../buttons/CppSpecialButtonTest.java | 20 +++ .../calculator/view/AngleUnitsButtonTest.java | 61 ------- .../view/NumeralBasesButtonTest.java | 61 ------- 37 files changed, 266 insertions(+), 505 deletions(-) delete mode 100644 app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java delete mode 100644 app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java delete mode 100644 app/src/main/res/drawable-hdpi/ic_keyboard_arrow_left_white_48dp.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_keyboard_arrow_right_white_48dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_keyboard_arrow_left_white_48dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_keyboard_arrow_right_white_48dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_white_48dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_right_white_48dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_left_white_48dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_right_white_48dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_left_white_48dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_right_white_48dp.png rename app/src/main/res/drawable/{ic_chevron_left_24dp.xml => ic_chevron_left_white_24dp.xml} (55%) create mode 100644 app/src/main/res/drawable/ic_favorite_border_white_48dp.xml create mode 100644 app/src/main/res/drawable/ic_keyboard_arrow_left_white_48dp.xml create mode 100644 app/src/main/res/drawable/ic_keyboard_arrow_right_white_48dp.xml create mode 100644 app/src/main/res/layout/cpp_app_button_like.xml create mode 100644 app/src/main/res/values/text_glyphs.xml create mode 100644 app/src/test/java/org/solovyev/android/calculator/buttons/CppSpecialButtonTest.java delete mode 100644 app/src/test/java/org/solovyev/android/calculator/view/AngleUnitsButtonTest.java delete mode 100644 app/src/test/java/org/solovyev/android/calculator/view/NumeralBasesButtonTest.java diff --git a/app/build.gradle b/app/build.gradle index ac367c1b..87dd0323 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,7 +34,6 @@ android { versionCode 148 versionName '2.2.1' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - generatedDensities = [] } buildTypes { release { @@ -58,10 +57,6 @@ android { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } - // This is handled for you by the 2.0+ Gradle Plugin - aaptOptions { - additionalParameters "--no-version-vectors" - } } dependencies { diff --git a/app/src/main/assets/fonts/Roboto-Regular.ttf b/app/src/main/assets/fonts/Roboto-Regular.ttf index bca461d0ad1191eafa7b69302d6cea8315228a18..cae96938114d963e7e3b42fb0a8d86660affb431 100644 GIT binary patch delta 36497 zcmb{537phaqW1rsq`I3`cA9o!r$I&$5m8omK;SxvhzJO%D4>9VfFMhdK@gOYYdf?s zDvP)QD$>d}$RY?T`yz;nh(fc=?s!!?@9!jes%t*~_rCYu_y1CSbDlm~t16XBQYTg8 z$7jr)QN(wQ<2a?9v5w~qY}vBozxC?f{}#tBS%lilTit#~%i<5FpLR@}()@i@tM-4s z=gci7(;aiyJC3umXRCYey>;uwjW5%`nd2n-{rR428Z7*znN_k&Lk3D_OH|7eLubMA1QD!W*a`h6aGuvgJPf3lCBf1ptx zDvDoKv@a8E$lo>l^dB<3^pJ{+c<~X&kcT9B#;}O`{VDao8rJ7xE zirWQqoSluAwNsf>)!dNL)DD$sn$z7}Vdm$JGKov77IEBp*vA-~a4-1V%*0bgoM1-Y z*iw5vQ#7wjx$8{vK_xycG9>Y|H^wo!4=y&-^RBJ1-gra3VR^q*teD|H{70{{y|R0C z?lrep!6VflY5B;sN9I1V^pS0k{PAd!N6SB2^U<2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C)RL>_$@DyeyN znjUVN;iegGn&D>0Qu?Ca--7TfP>XfAR=UzkX_oZsOuH_YQAM&_u;3M#+QMH);SONo zTe0v*P{2=FwfZ);(Iy1C8I2}sey~gi+0!x7TFET3S(mE2<&6+8LnC)Yp6eq=Espsvc0^oi+_}heedWGYWCEF@wvt55 zshHC-lhsz&yl3d2sN$N7sBX-oEx)R(?9^4BLHBp-DFr>%;p&@1Pt!ras-e_2B`%M* zxl-SVzDmoZy(Go4gl=&ao9IaPuPx?eiti^h-LDos2_35ZaE=af-73L%?f*n1FGSH_vD6S#yU+z*Egz79YPhn_a{;QEswargv#c-o~G2_^jZbeMPy z@5I7MINB@}&ygOU5!XJ%h%c8rhT~-KM7s?C8gajxZ|>hqT*J>pfkM3(ev5gDAc8Ot zb=l_rz0}1eh#(Y`@ZWNtDcfN{?lu`9K6Nnq^9lAHLqei_NWU;S-w)H5-=L^>PR`@n z60!3SUNJrxqV`U~5EbNA^j1>i@=txY$sPUD3<5t883&SJ)ZRP6>>AuKFGttlhWUu* zEt0Q8cziju()0fu7=YN_> zho{-+ebRmMfV&UgqkLtw*(qe7yRO_j(Vr_ky2roDq1(_slM@Uhn_@`tz;!^Ji}^-raG>Rj+Lu<$zua z)roz8LWc)yrQ+SMO$Kh?=xCgYF__v_%O(aKG(3ss|H*3e=iik4_~A$BTdr(LT551z i@|9v(KmIn0zbj!-{&9Rl%}IVe)E+#7U-3V*1^)yj+Y)sE diff --git a/app/src/main/java/org/solovyev/android/calculator/Keyboard.java b/app/src/main/java/org/solovyev/android/calculator/Keyboard.java index ab314896..4b37ea06 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Keyboard.java +++ b/app/src/main/java/org/solovyev/android/calculator/Keyboard.java @@ -25,11 +25,15 @@ package org.solovyev.android.calculator; import android.content.SharedPreferences; import android.support.annotation.NonNull; import android.text.TextUtils; +import android.util.Log; import com.squareup.otto.Bus; import dagger.Lazy; +import jscl.math.Expression; +import jscl.math.Generic; import org.solovyev.android.Check; import org.solovyev.android.calculator.buttons.CppSpecialButton; import org.solovyev.android.calculator.ga.Ga; +import org.solovyev.android.calculator.history.History; import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.memory.Memory; @@ -43,16 +47,14 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe @Nonnull private final MathType.Result mathType = new MathType.Result(); - @Nonnull - private static final String GLYPH_PASTE = "\uE000"; - @Nonnull - private static final String GLYPH_COPY = "\uE001"; @Inject Editor editor; @Inject Display display; @Inject + History history; + @Inject Lazy memory; @Inject Calculator calculator; @@ -83,10 +85,14 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe return false; } - if (text.equals(GLYPH_COPY)) { - text = CppSpecialButton.copy.action; - } else if (text.equals(GLYPH_PASTE)) { - text = CppSpecialButton.paste.action; + if (text.length() == 1) { + final char glyph = text.charAt(0); + final CppSpecialButton button = CppSpecialButton.getByGlyph(glyph); + if (button != null) { + ga.onButtonPressed(button.action); + handleSpecialAction(button); + return true; + } } ga.onButtonPressed(text); @@ -138,15 +144,21 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe if (button == null) { return false; } - onSpecialButtonPressed(button); + handleSpecialAction(button); return true; } - private void onSpecialButtonPressed(@NonNull CppSpecialButton button) { + private void handleSpecialAction(@NonNull CppSpecialButton button) { switch (button) { case history: launcher.showHistory(); break; + case history_undo: + history.undo(); + break; + case history_redo: + history.redo(); + break; case cursor_right: editor.moveCursorRight(); break; @@ -171,6 +183,15 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe case memory: memory.get().requestValue(); break; + case memory_plus: + handleMemoryButton(true); + break; + case memory_minus: + handleMemoryButton(false); + break; + case memory_clear: + memory.get().clear(); + break; case erase: editor.erase(); break; @@ -183,6 +204,9 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe case copy: bus.get().post(new Display.CopyOperation()); break; + case brackets_wrap: + handleBracketsWrap(); + break; case equals: equalsButtonPressed(); break; @@ -192,6 +216,15 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe case functions: launcher.showFunctions(); break; + case function_add: + launcher.showFunctionEditor(); + break; + case var_add: + launcher.showConstantEditor(); + break; + case plot_add: + launcher.plotDisplayedExpression(); + break; case open_app: launcher.openApp(); break; @@ -201,6 +234,9 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe case operators: launcher.showOperators(); break; + case simplify: + calculator.simplify(); + break; default: Check.shouldNotHappen(); } @@ -220,15 +256,38 @@ public class Keyboard implements SharedPreferences.OnSharedPreferenceChangeListe editor.setText(state.text); } - public void roundBracketsButtonPressed() { - EditorState viewState = editor.getState(); - - final int cursorPosition = viewState.selection; - final CharSequence oldText = viewState.text; - + public void handleBracketsWrap() { + final EditorState state = editor.getState(); + final int cursorPosition = state.selection; + final CharSequence oldText = state.text; editor.setText("(" + oldText.subSequence(0, cursorPosition) + ")" + oldText.subSequence(cursorPosition, oldText.length()), cursorPosition + 2); } + private boolean handleMemoryButton(boolean plus) { + final DisplayState state = display.getState(); + if (!state.valid) { + return false; + } + Generic value = state.getResult(); + if (value == null) { + try { + value = Expression.valueOf(state.text); + } catch (jscl.text.ParseException e) { + Log.w(App.TAG, e.getMessage(), e); + } + } + if (value == null) { + memory.get().requestShow(); + return false; + } + if (plus) { + memory.get().add(value); + } else { + memory.get().subtract(value); + } + return true; + } + @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { if (Preferences.Gui.vibrateOnKeypress.isSameKey(key)) { diff --git a/app/src/main/java/org/solovyev/android/calculator/buttons/CppButton.java b/app/src/main/java/org/solovyev/android/calculator/buttons/CppButton.java index 2a5c9cef..a8e57189 100644 --- a/app/src/main/java/org/solovyev/android/calculator/buttons/CppButton.java +++ b/app/src/main/java/org/solovyev/android/calculator/buttons/CppButton.java @@ -51,6 +51,7 @@ public enum CppButton { period(R.id.cpp_button_period, "."), brackets(R.id.cpp_button_round_brackets, "()"), + memory(R.id.cpp_button_memory, CppSpecialButton.memory), settings(R.id.cpp_button_settings, CppSpecialButton.settings), settings_widget(R.id.cpp_button_settings_widget, CppSpecialButton.settings_widget), like(R.id.cpp_button_like, CppSpecialButton.like), @@ -65,7 +66,7 @@ public enum CppButton { history(R.id.cpp_button_history, CppSpecialButton.history), /*operations*/ - multiplication(R.id.cpp_button_multiplication, "*"), + multiplication(R.id.cpp_button_multiplication, "×"), division(R.id.cpp_button_division, "/"), plus(R.id.cpp_button_plus, "+"), subtraction(R.id.cpp_button_subtraction, "−"), diff --git a/app/src/main/java/org/solovyev/android/calculator/buttons/CppSpecialButton.java b/app/src/main/java/org/solovyev/android/calculator/buttons/CppSpecialButton.java index 875431dc..ae1c4324 100644 --- a/app/src/main/java/org/solovyev/android/calculator/buttons/CppSpecialButton.java +++ b/app/src/main/java/org/solovyev/android/calculator/buttons/CppSpecialButton.java @@ -29,9 +29,12 @@ import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; +// see values/text_glyphs.xml for glyph constants public enum CppSpecialButton { history("history"), + history_undo("↶", '\ue007'), + history_redo("↷", '\ue008'), cursor_right("▷"), cursor_to_end(">>"), cursor_left("◁"), @@ -40,39 +43,85 @@ public enum CppSpecialButton { settings_widget("settings_widget"), like("like"), memory("memory"), + memory_plus("M+"), + memory_minus("M-"), + memory_clear("MC"), erase("erase"), - paste("paste"), - copy("copy"), + paste("paste", '\uE000'), + copy("copy", '\uE001'), + brackets_wrap("(…)"), equals("="), clear("clear"), functions("functions"), + function_add("+ƒ"), + var_add("+π"), + plot_add("+plot", '\uE009'), open_app("open_app"), vars("vars"), - operators("operators"); + operators("operators"), + simplify("≡"); @Nonnull - private static Map buttonsByActions = new HashMap<>(); + private static final Map buttonsByActions = new HashMap<>(); + @Nonnull + private static final CppSpecialButton[] buttonsByGlyphs = new CppSpecialButton[values().length]; + private static final char FIRST_GLYPH = '\uE000'; @Nonnull public final String action; + public final char glyph; CppSpecialButton(@Nonnull String action) { + this(action, (char) 0); + } + + CppSpecialButton(@Nonnull String action, char glyph) { this.action = action; + this.glyph = glyph; } @Nullable public static CppSpecialButton getByAction(@Nonnull String action) { - initButtonsByActionsMap(); + initButtonsByActions(); return buttonsByActions.get(action); } - private static void initButtonsByActionsMap() { + private static void initButtonsByActions() { Check.isMainThread(); if (!buttonsByActions.isEmpty()) { return; } - for (CppSpecialButton specialButton : values()) { - buttonsByActions.put(specialButton.action, specialButton); + for (CppSpecialButton button : values()) { + buttonsByActions.put(button.action, button); + } + } + + @Nullable + public static CppSpecialButton getByGlyph(char glyph) { + initButtonsByGlyphs(); + final int position = glyphToPosition(glyph); + if (position < 0 || position >= buttonsByGlyphs.length) { + return null; + } + return buttonsByGlyphs[position]; + } + + private static int glyphToPosition(char glyph) { + return glyph - FIRST_GLYPH; + } + + private static void initButtonsByGlyphs() { + Check.isMainThread(); + if (buttonsByGlyphs[0] != null) { + return; + } + for (CppSpecialButton button : values()) { + if(button.glyph == 0) { + continue; + } + final int position = glyphToPosition(button.glyph); + Check.isNull(buttonsByGlyphs[position], "Glyph is already taken, glyph=" + button.glyph); + buttonsByGlyphs[position] = button; } } diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java index c8098c7c..9e71605d 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java @@ -7,14 +7,16 @@ import android.content.SharedPreferences; import android.graphics.Typeface; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import dagger.Lazy; +import org.solovyev.android.Check; import org.solovyev.android.calculator.*; -import org.solovyev.android.calculator.buttons.CppSpecialButton; +import org.solovyev.android.calculator.buttons.CppButton; import org.solovyev.android.calculator.memory.Memory; import org.solovyev.android.views.Adjuster; import org.solovyev.android.views.dragbutton.*; @@ -68,7 +70,15 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer if (!Drag.hasDirectionText(view, direction)) { return false; } - return BaseKeyboardUi.this.onDrag(view, direction, ((DirectionDragView) view).getText(direction).getValue()); + final DirectionDragView dragView = (DirectionDragView) view; + final String text = dragView.getText(direction).getValue(); + if (TextUtils.isEmpty(text)) { + // hasDirectionText should return false for empty text + Check.shouldNotHappen(); + return false; + } + keyboard.buttonPressed(text); + return true; } }; textScale = getTextScale(application); @@ -85,7 +95,15 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer } } - protected abstract boolean onDrag(@NonNull View view, @NonNull DragDirection direction, @Nonnull String value); + @Override + public void onClick(View v) { + final CppButton button = CppButton.getById(v.getId()); + if (button == null) { + Check.shouldNotHappen(); + return; + } + onClick(v, button.action); + } public void onCreateView(@Nonnull Activity activity, @Nonnull View view) { cast(activity.getApplication()).getComponent().inject(this); @@ -197,10 +215,6 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer v.performHapticFeedback(KEYBOARD_TAP, FLAG_IGNORE_GLOBAL_SETTING | FLAG_IGNORE_VIEW_SETTING); } - protected final void onClick(@Nonnull View v, @Nonnull CppSpecialButton b) { - onClick(v, b.action); - } - private static class AdjusterHelper implements Adjuster.Helper { public static AdjusterHelper instance = new AdjusterHelper(); diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java index 5990bf86..7c45b836 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java @@ -3,31 +3,23 @@ package org.solovyev.android.calculator.keyboard; import android.app.Activity; import android.app.Application; import android.content.SharedPreferences; -import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import android.view.View; -import android.widget.Button; import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import jscl.NumeralBase; -import jscl.math.Expression; -import jscl.math.Generic; -import org.solovyev.android.calculator.*; -import org.solovyev.android.calculator.buttons.CppSpecialButton; -import org.solovyev.android.calculator.history.History; -import org.solovyev.android.calculator.view.AngleUnitsButton; -import org.solovyev.android.calculator.view.NumeralBasesButton; +import org.solovyev.android.calculator.Display; +import org.solovyev.android.calculator.Engine; +import org.solovyev.android.calculator.R; import org.solovyev.android.views.dragbutton.DirectionDragButton; import org.solovyev.android.views.dragbutton.DirectionDragImageButton; -import org.solovyev.android.views.dragbutton.DirectionDragView; -import org.solovyev.android.views.dragbutton.DragDirection; import javax.annotation.Nonnull; import javax.inject.Inject; -import static org.solovyev.android.calculator.Engine.Preferences.*; +import static org.solovyev.android.calculator.Engine.Preferences.multiplicationSign; +import static org.solovyev.android.calculator.Engine.Preferences.numeralBase; import static org.solovyev.android.views.dragbutton.DragDirection.*; public class KeyboardUi extends BaseKeyboardUi { @@ -53,10 +45,6 @@ public class KeyboardUi extends BaseKeyboardUi { @Bind(R.id.cpp_button_9) public DirectionDragButton button9; @Inject - History history; - @Inject - ActivityLauncher launcher; - @Inject Engine engine; @Inject Display display; @@ -85,10 +73,10 @@ public class KeyboardUi extends BaseKeyboardUi { DirectionDragButton bracketsButton; @Nullable @Bind(R.id.cpp_button_copy) - NumeralBasesButton copyButton; + DirectionDragImageButton copyButton; @Nullable @Bind(R.id.cpp_button_paste) - AngleUnitsButton pasteButton; + DirectionDragImageButton pasteButton; @Nullable @Bind(R.id.cpp_button_like) ImageButton likeButton; @@ -146,11 +134,9 @@ public class KeyboardUi extends BaseKeyboardUi { if (copyButton != null) { prepareButton(copyButton); - copyButton.setNumeralBase(numeralBase.getPreference(preferences)); } if (pasteButton != null) { prepareButton(pasteButton); - pasteButton.setAngleUnit(angleUnit.getPreference(preferences)); } prepareButton(likeButton); prepareButton(memoryButton); @@ -182,133 +168,11 @@ public class KeyboardUi extends BaseKeyboardUi { @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { super.onSharedPreferenceChanged(preferences, key); - if (angleUnit.isSameKey(key) && pasteButton != null) { - pasteButton.setAngleUnit(angleUnit.getPreference(preferences)); - } if (numeralBase.isSameKey(key)) { toggleNumericDigits(); - if (copyButton != null) { - copyButton.setNumeralBase(numeralBase.getPreference(preferences)); - } } if (multiplicationSign.isSameKey(key)) { multiplicationButton.setText(multiplicationSign.getPreference(preferences)); } } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.cpp_button_0: - case R.id.cpp_button_1: - case R.id.cpp_button_2: - case R.id.cpp_button_3: - case R.id.cpp_button_4: - case R.id.cpp_button_5: - case R.id.cpp_button_6: - case R.id.cpp_button_7: - case R.id.cpp_button_8: - case R.id.cpp_button_9: - case R.id.cpp_button_division: - case R.id.cpp_button_period: - case R.id.cpp_button_percent: - case R.id.cpp_button_subtraction: - case R.id.cpp_button_multiplication: - case R.id.cpp_button_plus: - case R.id.cpp_button_round_brackets: - onClick(v, ((Button) v).getText().toString()); - break; - case R.id.cpp_button_functions: - onClick(v, CppSpecialButton.functions); - break; - case R.id.cpp_button_history: - onClick(v, CppSpecialButton.history); - break; - case R.id.cpp_button_paste: - onClick(v, CppSpecialButton.paste); - break; - case R.id.cpp_button_copy: - onClick(v, CppSpecialButton.copy); - break; - case R.id.cpp_button_like: - onClick(v, CppSpecialButton.like); - break; - case R.id.cpp_button_memory: - onClick(v, CppSpecialButton.memory); - break; - case R.id.cpp_button_operators: - onClick(v, CppSpecialButton.operators); - break; - case R.id.cpp_button_vars: - onClick(v, CppSpecialButton.vars); - break; - } - } - - @Override - protected boolean onDrag(@NonNull View view, @NonNull DragDirection direction, @Nonnull String value) { - switch (view.getId()) { - case R.id.cpp_button_functions: - if (direction == up) { - launcher.showFunctionEditor(); - return true; - } else if (direction == down) { - launcher.showConstantEditor(); - return true; - } - return false; - case R.id.cpp_button_history: - if (direction == up) { - history.undo(); - return true; - } else if (direction == down) { - history.redo(); - return true; - } - return false; - case R.id.cpp_button_memory: - return processMemoryButton(direction); - case R.id.cpp_button_round_brackets: - if (direction == left) { - keyboard.roundBracketsButtonPressed(); - return true; - } - return processDefault(direction, (DirectionDragView) view); - default: - return processDefault(direction, (DirectionDragView) view); - } - } - - private boolean processMemoryButton(@NonNull DragDirection direction) { - final DisplayState state = display.getState(); - if (!state.valid) { - return false; - } - Generic value = state.getResult(); - if (value == null) { - try { - value = Expression.valueOf(state.text); - } catch (jscl.text.ParseException e) { - Log.w(App.TAG, e.getMessage(), e); - } - } - if (value == null) { - memory.get().requestShow(); - return false; - } - switch (direction) { - case up: - memory.get().add(value); - return true; - case down: - memory.get().subtract(value); - return true; - } - return false; - } - - private boolean processDefault(@Nonnull DragDirection direction, @Nonnull DirectionDragView button) { - final String text = button.getText(direction).getValue(); - return keyboard.buttonPressed(text); - } } \ No newline at end of file diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java index dd503ded..94a4c58a 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java @@ -10,18 +10,15 @@ import android.widget.ImageButton; import butterknife.Bind; import butterknife.ButterKnife; import org.solovyev.android.calculator.R; -import org.solovyev.android.calculator.buttons.CppSpecialButton; import org.solovyev.android.calculator.view.EditorLongClickEraser; import org.solovyev.android.views.dragbutton.DirectionDragButton; import org.solovyev.android.views.dragbutton.DirectionDragImageButton; -import org.solovyev.android.views.dragbutton.DragDirection; import javax.annotation.Nonnull; import javax.inject.Inject; import static org.solovyev.android.calculator.Preferences.Gui.vibrateOnKeypress; import static org.solovyev.android.views.dragbutton.DragDirection.down; -import static org.solovyev.android.views.dragbutton.DragDirection.up; public class PartialKeyboardUi extends BaseKeyboardUi { @@ -73,52 +70,4 @@ public class PartialKeyboardUi extends BaseKeyboardUi { longClickEraser.setVibrateOnKeypress(vibrateOnKeypress.getPreference(preferences)); } } - - @Override - protected boolean onDrag(@NonNull View view, @NonNull DragDirection direction, @Nonnull String value) { - switch (view.getId()) { - case R.id.cpp_button_right: - case R.id.cpp_button_left: - keyboard.buttonPressed(value); - return true; - case R.id.cpp_button_clear: - if(direction == up) { - memory.get().clear(); - return true; - } - return false; - case R.id.cpp_button_equals: - if (direction == down) { - launcher.plotDisplayedExpression(); - return true; - } else if (direction == up) { - calculator.simplify(); - return true; - } - - return false; - } - return false; - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.cpp_button_left: - onClick(v, CppSpecialButton.cursor_left); - break; - case R.id.cpp_button_right: - onClick(v, CppSpecialButton.cursor_right); - break; - case R.id.cpp_button_clear: - onClick(v, CppSpecialButton.clear); - break; - case R.id.cpp_button_erase: - onClick(v, CppSpecialButton.erase); - break; - case R.id.cpp_button_equals: - onClick(v, CppSpecialButton.equals); - break; - } - } } diff --git a/app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java b/app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java deleted file mode 100644 index 12769efc..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/view/AngleUnitsButton.java +++ /dev/null @@ -1,68 +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.view; - -import android.content.Context; -import android.support.v4.content.ContextCompat; -import android.util.AttributeSet; -import jscl.AngleUnit; -import org.solovyev.android.calculator.R; -import org.solovyev.android.views.dragbutton.DirectionDragImageButton; -import org.solovyev.android.views.dragbutton.DirectionTextView; -import org.solovyev.android.views.dragbutton.DragDirection; - -import javax.annotation.Nonnull; - -public class AngleUnitsButton extends DirectionDragImageButton { - - @Nonnull - private AngleUnit angleUnit = AngleUnit.deg; - - public AngleUnitsButton(Context context, @Nonnull AttributeSet attrs) { - super(context, attrs); - updateDirectionColors(); - } - - boolean isCurrentAngleUnits(@Nonnull String directionText) { - return angleUnit.name().equals(directionText); - } - - public void setAngleUnit(@Nonnull AngleUnit angleUnit) { - if (this.angleUnit == angleUnit) { - return; - } - this.angleUnit = angleUnit; - updateDirectionColors(); - } - - private void updateDirectionColors() { - for (DragDirection direction : DragDirection.values()) { - final DirectionTextView.Text text = getText(direction); - if (isCurrentAngleUnits(text.getValue())) { - text.setColor(ContextCompat.getColor(getContext(), R.color.yellow_100), 1f); - } else { - text.setColor(ContextCompat.getColor(getContext(), R.color.cpp_text), DirectionTextView.DEF_ALPHA); - } - } - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java b/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java deleted file mode 100644 index 5c489004..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/view/NumeralBasesButton.java +++ /dev/null @@ -1,68 +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.view; - -import android.content.Context; -import android.support.v4.content.ContextCompat; -import android.util.AttributeSet; -import jscl.NumeralBase; -import org.solovyev.android.calculator.R; -import org.solovyev.android.views.dragbutton.DirectionDragImageButton; -import org.solovyev.android.views.dragbutton.DirectionTextView; -import org.solovyev.android.views.dragbutton.DragDirection; - -import javax.annotation.Nonnull; - -public class NumeralBasesButton extends DirectionDragImageButton { - - @Nonnull - private NumeralBase numeralBase = NumeralBase.dec; - - public NumeralBasesButton(Context context, @Nonnull AttributeSet attrs) { - super(context, attrs); - updateDirectionColors(); - } - - boolean isCurrentNumberBase(@Nonnull String directionText) { - return numeralBase.name().equals(directionText); - } - - public void setNumeralBase(@Nonnull NumeralBase numeralBase) { - if (this.numeralBase == numeralBase) { - return; - } - this.numeralBase = numeralBase; - updateDirectionColors(); - } - - private void updateDirectionColors() { - for (DragDirection direction : DragDirection.values()) { - final DirectionTextView.Text text = getText(direction); - if (isCurrentNumberBase(text.getValue())) { - text.setColor(ContextCompat.getColor(getContext(), R.color.yellow_100), 1f); - } else { - text.setColor(ContextCompat.getColor(getContext(), R.color.cpp_text), DirectionTextView.DEF_ALPHA); - } - } - } -} diff --git a/app/src/main/java/org/solovyev/android/views/dragbutton/DragView.java b/app/src/main/java/org/solovyev/android/views/dragbutton/DragView.java index a7a139d5..06c3813a 100644 --- a/app/src/main/java/org/solovyev/android/views/dragbutton/DragView.java +++ b/app/src/main/java/org/solovyev/android/views/dragbutton/DragView.java @@ -3,6 +3,7 @@ package org.solovyev.android.views.dragbutton; import android.support.annotation.Nullable; public interface DragView { + int getId(); void setOnDragListener(@Nullable DragListener listener); void setVibrateOnDrag(boolean vibrateOnDrag); } diff --git a/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_left_white_48dp.png b/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_left_white_48dp.png deleted file mode 100644 index d8af01c85ab1fbed7f641baf3b0fee50b79b74ff..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawR(iTPhGg7(d*du`lLG^5BG(4C zyFz~*1$EAL_iB`U+B0zlXPgPoNgvkxncv@rO`Qn@e|Jm~5lcVOptv-}Lx>~uiGhdy z9F>=wl?o^6c5j|+eDLOG3wE*PX@z|{=Q@vOM$Fkfhtu!$qms|}UT!x(H`UB&5_kWV zj~;7Penf7O2~y^?b80ZowOkT)Dg09Hwe5e|UrscA>D+cu(zDh~bh(Jg@iRd1X1^_? Y`On}(7bdyL0UgcY>FVdQ&MBb@0B}oQssI20 diff --git a/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_right_white_48dp.png b/app/src/main/res/drawable-hdpi/ic_keyboard_arrow_right_white_48dp.png deleted file mode 100644 index e9bc3889e0263bff935d25ad2368f91bb64e9f7b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawR(ZNOhGg7(dv&*9Qvd^NpwY>k zlly;YUXu*eJeb8Jx+wdQ1=At!`=RC97B|&61%cqN*Da0WM>(M@w0!STHO+!Ab}~bR;9J?n6v1p z=9EK)Ph%eN6r3xlvQ(b?poU+)-S~i|RH0ptlHPLXuJf4_Y%KIA@h?}iEbIV+7yeaD YJEW3&7S3+&0lJ#O)78&qol`;+06LLbwEzGB diff --git a/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_left_white_48dp.png b/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_left_white_48dp.png deleted file mode 100644 index 2b4d614a17813189eca5158c7df64b8b06613bc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DY)==*kch)?FYo4Ta1dyD=y=fR z3)eNJ8kT8^s*9%flq-mHvd4y3NO#GZ>y8IVpF+_r<68M;MGZ8_3C3C?EM^dG{gE OS_V&7KbLh*2~7Zs%S0#u diff --git a/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_right_white_48dp.png b/app/src/main/res/drawable-mdpi/ic_keyboard_arrow_right_white_48dp.png deleted file mode 100644 index aa55964e73db339eb94e30b751b8ee3cf183eecd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DEKe85kch)?&mQD;aA07)XuF6Z z>Q8%2hTMq11H*W9PAo@e;k7hy~$2rUL@F^m<{vOd#UNM6)g~c{ps;SM_e~nt4 z(-nV#)9M|z!p%%CKG_NG{r*q=ci1leMh~HP#tU!HZz*~|r}z<{Vv9`Vfyhe=KwB9+ MUHx3vIVCg!0BGzwyZ`_I diff --git a/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_white_48dp.png b/app/src/main/res/drawable-xhdpi/ic_keyboard_arrow_left_white_48dp.png deleted file mode 100644 index 36cfbc9a904ad0126a126ea5752d73d08faa89fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 203 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%xcgCV9FzhE&{odwsW{BcnviMSJ)D zFAod7ofoW~%JEKO;)z+sS~v9XNCH(d)WuKJx%+wY6}3IjwyUjqX0Ep9Y`*so1A9-t zyPx0RoRz=tXYXh8XS4s`{WJULv)T78{%7s``K+AHW>a?k9w8Nv2?~x)ESw<5hvS^T xXFh9rTvF+6;X6On>G7Y?LzPvjCsRSTG^n?DGDja<L(SB+ zeJ%wTrqxZ^bj5KVcW29Po1go*?$zI(JJS%ToZ-jbHAbfA=NF$0nmxgCx{9Xni8Pw?JTE4_s7GB%;HgcAmz;|# z|Ds9kfhU_+JhAMUSFvf@j>iX^+4<#cWIxt?cmQFBKic^a!m3zz=<_kKbj61+%qH$v zSNGnL=l*q!Sy0KPLqO4~g##DEYIa7+f+h}suPu*Gc6?akQW3PM^o952NiW*fl@A3A iJe-K^P!&(9<+68Pd|fzEZZQYYzYLzPelF{r5}E+)er+EB diff --git a/app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_right_white_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_keyboard_arrow_right_white_48dp.png deleted file mode 100644 index 25503d1b49f1382d10f694205e1a785012ca7d80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 286 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q1xWh(YZ(Knr=Bj3Ar-gYUf9jay@0VeDybd z+pb-4jeei zAnMR$V<*hxc*vP0a#oKu=i5y{)u>>??9wpNQ-6$;9cSNfvf0mCS;zh9kJyu+x+gwI zPk6pv;e5X1JfOt?Gu3=uQ-A7roz%Dgbh`h~C*}Qra%TQtGXu;z0Tg_1^WVGf=TrB( zpA+Njo=l&g`+2^|WDrXpB3Qqj*{(SB3=_A=<^xPebv8H{a_a<;&VBG+Tt-w|{LU3E z@e}j)CfLUogs+HEsNd!AujHWf)S|{eFPVN`X7yJ+#rlaE)u%w-0seh%i&Af_Uv?o1 OBK4 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_right_white_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_keyboard_arrow_right_white_48dp.png deleted file mode 100644 index 034a3eff4dc443ac589699f86d6d697bf20c480a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvG8AvYpRA>UE3<7*YT!Hj|Qh>EDivds%e@T#E zFhj#fi}xQ)7>!Mvn_6TVdoHF;14>=;ba4!+hlL4CeQr``(An{)ZV)7>9CXF|cvg=|qj^Bcd-?G!qty7?f( zlz?+HH6ChLPi0xqGT&!Pz`CC+5*em_n0``dTJ)@fNf#z7B>D?KyR6_bVZ&igY0mE| z9uW^(9#?Y+0U3vxH(!0-&B7s|;LyOp$OL8_(C6uBWclJIc7fBM!7Ibj^gx5(3x;U{ o%sFpBWNywuvnw+k(qO=RW9^jKb0LbQK;JQVy85}Sb4q9e0D^I%=l}o! diff --git a/app/src/main/res/drawable/ic_chevron_left_24dp.xml b/app/src/main/res/drawable/ic_chevron_left_white_24dp.xml similarity index 55% rename from app/src/main/res/drawable/ic_chevron_left_24dp.xml rename to app/src/main/res/drawable/ic_chevron_left_white_24dp.xml index c339eccc..a32c74ac 100644 --- a/app/src/main/res/drawable/ic_chevron_left_24dp.xml +++ b/app/src/main/res/drawable/ic_chevron_left_white_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportHeight="24.0" + android:viewportWidth="24.0"> + android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z" /> diff --git a/app/src/main/res/drawable/ic_favorite_border_white_48dp.xml b/app/src/main/res/drawable/ic_favorite_border_white_48dp.xml new file mode 100644 index 00000000..534260f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_favorite_border_white_48dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_left_white_48dp.xml b/app/src/main/res/drawable/ic_keyboard_arrow_left_white_48dp.xml new file mode 100644 index 00000000..b215b841 --- /dev/null +++ b/app/src/main/res/drawable/ic_keyboard_arrow_left_white_48dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_right_white_48dp.xml b/app/src/main/res/drawable/ic_keyboard_arrow_right_white_48dp.xml new file mode 100644 index 00000000..7c99a11f --- /dev/null +++ b/app/src/main/res/drawable/ic_keyboard_arrow_right_white_48dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout-land/cpp_app_keyboard.xml b/app/src/main/res/layout-land/cpp_app_keyboard.xml index 8b210807..e40d246f 100644 --- a/app/src/main/res/layout-land/cpp_app_keyboard.xml +++ b/app/src/main/res/layout-land/cpp_app_keyboard.xml @@ -84,7 +84,7 @@ a:baselineAligned="false" a:orientation="horizontal"> - + diff --git a/app/src/main/res/layout/cpp_app_button_copy.xml b/app/src/main/res/layout/cpp_app_button_copy.xml index 5a26e8b6..abf9433b 100644 --- a/app/src/main/res/layout/cpp_app_button_copy.xml +++ b/app/src/main/res/layout/cpp_app_button_copy.xml @@ -22,7 +22,7 @@ ~ Site: http://se.solovyev.org --> - \ No newline at end of file diff --git a/app/src/main/res/layout/cpp_app_button_history.xml b/app/src/main/res/layout/cpp_app_button_history.xml index 1b29e5fc..a7291251 100644 --- a/app/src/main/res/layout/cpp_app_button_history.xml +++ b/app/src/main/res/layout/cpp_app_button_history.xml @@ -28,5 +28,5 @@ style="?attr/cpp_button_style_control" a:src="@drawable/ic_history_white_48dp" app:directionTextScale="0.5" - app:directionTextDown="@string/cpp_kb_redo" - app:directionTextUp="@string/cpp_kb_undo" /> \ No newline at end of file + app:directionTextDown="@string/cpp_glyph_redo" + app:directionTextUp="@string/cpp_glyph_undo" /> \ No newline at end of file diff --git a/app/src/main/res/layout/cpp_app_button_like.xml b/app/src/main/res/layout/cpp_app_button_like.xml new file mode 100644 index 00000000..88497724 --- /dev/null +++ b/app/src/main/res/layout/cpp_app_button_like.xml @@ -0,0 +1,29 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/cpp_app_button_paste.xml b/app/src/main/res/layout/cpp_app_button_paste.xml index b995e86f..718e80dc 100644 --- a/app/src/main/res/layout/cpp_app_button_paste.xml +++ b/app/src/main/res/layout/cpp_app_button_paste.xml @@ -22,7 +22,7 @@ ~ Site: http://se.solovyev.org --> - + + "\ue000" + "\ue001" + "\ue002" + "\ue003" + "\ue004" + "\ue005" + "\ue006" + "\ue007" + "\ue008" + "\ue009" + \ No newline at end of file diff --git a/app/src/main/res/values/text_non_translatable.xml b/app/src/main/res/values/text_non_translatable.xml index 6144e7a8..c7026931 100644 --- a/app/src/main/res/values/text_non_translatable.xml +++ b/app/src/main/res/values/text_non_translatable.xml @@ -17,8 +17,6 @@ αβγ E %1$s (AMOLED) - "\ue000" - "\ue001" 0 1 diff --git a/app/src/test/java/org/solovyev/android/calculator/buttons/CppSpecialButtonTest.java b/app/src/test/java/org/solovyev/android/calculator/buttons/CppSpecialButtonTest.java new file mode 100644 index 00000000..e26e7818 --- /dev/null +++ b/app/src/test/java/org/solovyev/android/calculator/buttons/CppSpecialButtonTest.java @@ -0,0 +1,20 @@ +package org.solovyev.android.calculator.buttons; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class CppSpecialButtonTest { + + @Test + public void testShouldReturnButtonByGlyph() throws Exception { + assertEquals(CppSpecialButton.copy, CppSpecialButton.getByGlyph(CppSpecialButton.copy.glyph)); + assertEquals(CppSpecialButton.paste, CppSpecialButton.getByGlyph(CppSpecialButton.paste.glyph)); + } + + @Test + public void testShouldReturnNullForButtonWithoutGlyph() throws Exception { + assertNull(CppSpecialButton.getByGlyph(CppSpecialButton.brackets_wrap.glyph)); + } +} \ No newline at end of file diff --git a/app/src/test/java/org/solovyev/android/calculator/view/AngleUnitsButtonTest.java b/app/src/test/java/org/solovyev/android/calculator/view/AngleUnitsButtonTest.java deleted file mode 100644 index fac85081..00000000 --- a/app/src/test/java/org/solovyev/android/calculator/view/AngleUnitsButtonTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.solovyev.android.calculator.view; - -import android.app.Activity; -import android.os.Build; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricGradleTestRunner; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.res.Attribute; -import org.robolectric.shadows.ShadowActivity; -import org.solovyev.android.calculator.BuildConfig; - -import java.util.ArrayList; - -import static jscl.AngleUnit.deg; -import static jscl.AngleUnit.grad; -import static jscl.AngleUnit.rad; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP) -@RunWith(RobolectricGradleTestRunner.class) -public class AngleUnitsButtonTest { - - private AngleUnitsButton button; - - @Before - public void setUp() throws Exception { - final Activity context = Robolectric.buildActivity(Activity.class).create().get(); - final ShadowActivity activity = Shadows.shadowOf(context); - button = new AngleUnitsButton(context, activity.createAttributeSet(new ArrayList(), AngleUnitsButton.class)); - } - - @Test - public void testIsCurrentAngleUnits() throws Exception { - button.setAngleUnit(rad); - assertTrue(button.isCurrentAngleUnits(rad.name())); - assertFalse(button.isCurrentAngleUnits(deg.name())); - assertFalse(button.isCurrentAngleUnits(grad.name())); - } - - @Test - public void testInvalidateShouldBeCalledOnlyWhenChangeIsDone() throws Exception { - button.setAngleUnit(rad); - - button = Mockito.spy(button); - - button.setAngleUnit(deg); - verify(button, times(1)).invalidate(); - - button.setAngleUnit(deg); - verify(button, times(1)).invalidate(); - } -} diff --git a/app/src/test/java/org/solovyev/android/calculator/view/NumeralBasesButtonTest.java b/app/src/test/java/org/solovyev/android/calculator/view/NumeralBasesButtonTest.java deleted file mode 100644 index 41d91c70..00000000 --- a/app/src/test/java/org/solovyev/android/calculator/view/NumeralBasesButtonTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.solovyev.android.calculator.view; - -import android.app.Activity; -import android.os.Build; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricGradleTestRunner; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.res.Attribute; -import org.robolectric.shadows.ShadowActivity; -import org.solovyev.android.calculator.BuildConfig; - -import java.util.ArrayList; - -import static jscl.NumeralBase.bin; -import static jscl.NumeralBase.dec; -import static jscl.NumeralBase.hex; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP) -@RunWith(RobolectricGradleTestRunner.class) -public class NumeralBasesButtonTest { - - private NumeralBasesButton button; - - @Before - public void setUp() throws Exception { - final Activity context = Robolectric.buildActivity(Activity.class).create().get(); - final ShadowActivity activity = Shadows.shadowOf(context); - button = new NumeralBasesButton(context, activity.createAttributeSet(new ArrayList(), NumeralBasesButton.class)); - } - - @Test - public void testIsCurrentNumeralBase() throws Exception { - button.setNumeralBase(dec); - assertTrue(button.isCurrentNumberBase(dec.name())); - assertFalse(button.isCurrentNumberBase(hex.name())); - assertFalse(button.isCurrentNumberBase(bin.name())); - } - - @Test - public void testInvalidateShouldBeCalledOnlyWhenChangeIsDone() throws Exception { - button.setNumeralBase(dec); - - button = Mockito.spy(button); - - button.setNumeralBase(hex); - verify(button, times(1)).invalidate(); - - button.setNumeralBase(hex); - verify(button, times(1)).invalidate(); - } -}