From 9f94f9fd9064d46fbb88808dbbed74dc547df31f Mon Sep 17 00:00:00 2001 From: serso Date: Tue, 15 Mar 2016 21:02:14 +0100 Subject: [PATCH] Fix alpha in a floating keyboard --- .../android/calculator/keyboard/BaseFloatingKeyboard.java | 4 ++++ .../android/views/dragbutton/DirectionDragButton.java | 6 ++++++ .../android/views/dragbutton/DirectionTextView.java | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseFloatingKeyboard.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseFloatingKeyboard.java index e6603929..50e93d2f 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseFloatingKeyboard.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseFloatingKeyboard.java @@ -60,6 +60,9 @@ public abstract class BaseFloatingKeyboard implements FloatingKeyboard { protected DirectionDragButton makeButton(@IdRes int id, @NonNull String text) { final DirectionDragButton button = new DirectionDragButton(user.getContext()); fillButton(button, id); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + button.setAllCaps(false); + } button.setText(text); button.setTextColor(textColor); button.setDirectionTextColor(textColorSecondary); @@ -104,6 +107,7 @@ public abstract class BaseFloatingKeyboard implements FloatingKeyboard { final DirectionDragButton button = addButton(row, id, text); button.setBackgroundResource(R.drawable.material_button_light_primary); button.setTextColor(Color.WHITE); + button.setDirectionTextAlpha(0.7f); return button; } diff --git a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java index b3d8b1ed..127a809c 100644 --- a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java +++ b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionDragButton.java @@ -80,4 +80,10 @@ public class DirectionDragButton extends DragButton implements DirectionDragView getText(direction).setColor(color); } } + + public void setDirectionTextAlpha(float alpha) { + for (DragDirection direction : DragDirection.values()) { + getText(direction).setAlpha(alpha); + } + } } diff --git a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java index 82ee2129..1af276b0 100644 --- a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java +++ b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java @@ -156,7 +156,11 @@ public class DirectionTextView { } public void setColor(int color) { - setColor(color, this.alpha); + setColor(color, alpha); + } + + public void setAlpha(float alpha) { + setColor(color, alpha); } public void setColor(int color, float alpha) {