[Android] Harmonize selection color

Geoffrey Métais git at videolan.org
Mon Nov 21 09:55:37 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 21 09:53:11 2016 +0100| [68347f2f5b448e0ce21355b9aa7480af697d5e6d] | committer: Geoffrey Métais

Harmonize selection color

> https://code.videolan.org/videolan/vlc-android/commit/68347f2f5b448e0ce21355b9aa7480af697d5e6d
---

 .../src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java    |  3 +--
 .../src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java   | 10 +++++-----
 vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java      |  2 ++
 .../src/org/videolan/vlc/gui/video/VideoListAdapter.java       |  2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index 0f1cc33..0effa5f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -3,7 +3,6 @@ package org.videolan.vlc.gui.audio;
 import android.app.Activity;
 import android.content.Context;
 import android.databinding.ViewDataBinding;
-import android.support.v4.content.ContextCompat;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
@@ -317,7 +316,7 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
 
         private void setViewBackground(boolean focused, boolean selected) {
             itemView.setBackgroundColor(focused ? UiTools.ITEM_FOCUS_ON : UiTools.ITEM_FOCUS_OFF);
-            int selectionColor = selected ? ContextCompat.getColor(itemView.getContext(), R.color.orange200transparent) : 0;
+            int selectionColor = selected ? UiTools.ITEM_SELECTION_ON : 0;
             contentLayout.setBackgroundColor(selectionColor);
             ctxButton.setBackgroundColor(selectionColor);
         }
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 16f80d5..f23efde 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -120,7 +120,7 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<BaseBrowserAdapter
             vh.binding.setProtocol(getProtocol(media));
         vh.binding.setImage(getIcon(media));
         vh.setContextMenuListener();
-        vh.setViewBackground(mSelectedItems.contains(position));
+        vh.setViewBackground(vh.itemView.hasFocus(), mSelectedItems.contains(position));
     }
 
     @Override
@@ -222,14 +222,14 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<BaseBrowserAdapter
                 mSelectedItems.add(position);
             else
                 mSelectedItems.remove(position);
-            setViewBackground(mSelectedItems.contains(position));
+            setViewBackground(itemView.hasFocus(), mSelectedItems.contains(position));
         }
 
-        private void setViewBackground(boolean highlight) {
-            if (highlight)
+        private void setViewBackground(boolean focus, boolean selected) {
+            if (focus)
                 itemView.setBackgroundColor(UiTools.ITEM_FOCUS_ON);
             else
-                itemView.setBackgroundColor(UiTools.ITEM_FOCUS_OFF);
+                itemView.setBackgroundColor(selected ? UiTools.ITEM_SELECTION_ON : UiTools.ITEM_FOCUS_OFF);
         }
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index 41a0091..b957347 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -65,6 +65,8 @@ public class UiTools {
 
     public static final int ITEM_FOCUS_ON = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.orange500);
     public static final int ITEM_FOCUS_OFF = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.transparent);
+    public static final int ITEM_SELECTION_ON = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.orange200transparent);
+    public static final int ITEM_BG_TRANSPARENT = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.transparent);
 
     private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index f55ce8f..38e2599 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -337,7 +337,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
             else
                 mSelectedItems.remove(position);
             setOverlay(itemView.hasFocus() || mSelectedItems.contains(position));
-            binding.setVariable(BR.bgColor, ContextCompat.getColor(itemView.getContext(), mListMode && selected ? R.color.orange200transparent : R.color.transparent));
+            binding.setVariable(BR.bgColor, mListMode && selected ? UiTools.ITEM_SELECTION_ON : UiTools.ITEM_BG_TRANSPARENT);
         }
 
         private void setOverlay(boolean selected) {



More information about the Android mailing list