Skip to content
Snippets Groups Projects
Commit 68347f2f authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Harmonize selection color

parent 51104b5c
Branches master
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment