From e0d1e53d149dc16ff97de3c1e071d097d60ec105 Mon Sep 17 00:00:00 2001 From: Martijn Brekhof Date: Fri, 26 Jan 2018 15:06:12 +0100 Subject: [PATCH] Refactored applying tint color on control pad (#505) ControlPad now uses AppCompatImageView to support theme colors. Instead of applying the colors programmatically they are now defined in the layout file. --- .../org/xbmc/kore/ui/widgets/ControlPad.java | 25 ++++------------ .../main/res/layout/remote_control_pad.xml | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/org/xbmc/kore/ui/widgets/ControlPad.java b/app/src/main/java/org/xbmc/kore/ui/widgets/ControlPad.java index 413dc7d..caa2621 100644 --- a/app/src/main/java/org/xbmc/kore/ui/widgets/ControlPad.java +++ b/app/src/main/java/org/xbmc/kore/ui/widgets/ControlPad.java @@ -108,7 +108,7 @@ public class ControlPad extends SquareGridLayout inflater.inflate(R.layout.remote_control_pad, this); ButterKnife.inject(this, this); - applyTheme(); + setBackgroundImage(); setupListeners(context); } @@ -160,28 +160,13 @@ public class ControlPad extends SquareGridLayout } @TargetApi(21) - private void applyTheme() { + private void setBackgroundImage() { Resources.Theme theme = getContext().getTheme(); - TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { - R.attr.remoteButtonColorFilter, - R.attr.contentBackgroundColor}); - Resources resources = getResources(); - int remoteButtonsColor = styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.white)), - remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.dark_content_background_dim_70pct)); + TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] {R.attr.contentBackgroundColor}); + int remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(0), + getResources().getColor(R.color.dark_content_background_dim_70pct)); styledAttributes.recycle(); - leftButton.setColorFilter(remoteButtonsColor); - rightButton.setColorFilter(remoteButtonsColor); - upButton.setColorFilter(remoteButtonsColor); - downButton.setColorFilter(remoteButtonsColor); - - selectButton.setColorFilter(remoteButtonsColor); - backButton.setColorFilter(remoteButtonsColor); - infoButton.setColorFilter(remoteButtonsColor); - osdButton.setColorFilter(remoteButtonsColor); - contextButton.setColorFilter(remoteButtonsColor); - - // On ICS the remote background isn't shown as the tinting isn't supported //int backgroundResourceId = R.drawable.remote_background_square_black_alpha; int backgroundResourceId = R.drawable.remote_background_square_black; diff --git a/app/src/main/res/layout/remote_control_pad.xml b/app/src/main/res/layout/remote_control_pad.xml index 243e60c..0cfeb2f 100644 --- a/app/src/main/res/layout/remote_control_pad.xml +++ b/app/src/main/res/layout/remote_control_pad.xml @@ -14,61 +14,71 @@ See the License for the specific language governing permissions and limitations under the License. --> - - + - - - - - - - - \ No newline at end of file