mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
add colored background to the currently selected directory thumbnail
This commit is contained in:
parent
fa775e35e3
commit
15159de4e9
6 changed files with 26 additions and 18 deletions
|
@ -227,8 +227,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
}
|
||||
|
||||
private fun checkIfColorChanged() {
|
||||
if (directories_grid.adapter != null && getRecyclerAdapter().foregroundColor != config.primaryColor) {
|
||||
getRecyclerAdapter().updatePrimaryColor(config.primaryColor)
|
||||
if (directories_grid.adapter != null && getRecyclerAdapter().primaryColor != config.primaryColor) {
|
||||
getRecyclerAdapter().primaryColor = config.primaryColor
|
||||
directories_vertical_fastscroller.updateHandleColor()
|
||||
directories_horizontal_fastscroller.updateHandleColor()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.gallery.adapters
|
||||
|
||||
import android.graphics.PorterDuff
|
||||
import android.support.v7.view.ActionMode
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.SparseArray
|
||||
|
@ -33,19 +34,19 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
var actMode: ActionMode? = null
|
||||
var itemViews = SparseArray<View>()
|
||||
val selectedPositions = HashSet<Int>()
|
||||
var foregroundColor = config.primaryColor
|
||||
var primaryColor = config.primaryColor
|
||||
var pinnedFolders = config.pinnedFolders
|
||||
var scrollVertically = !config.scrollHorizontally
|
||||
|
||||
fun toggleItemSelection(select: Boolean, pos: Int) {
|
||||
if (itemViews[pos] != null)
|
||||
itemViews[pos].dir_check.beVisibleIf(select)
|
||||
|
||||
if (select)
|
||||
if (select) {
|
||||
itemViews[pos].dir_check.background.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
||||
selectedPositions.add(pos)
|
||||
else
|
||||
} else
|
||||
selectedPositions.remove(pos)
|
||||
|
||||
itemViews[pos]?.dir_check?.beVisibleIf(select)
|
||||
|
||||
if (selectedPositions.isEmpty()) {
|
||||
actMode?.finish()
|
||||
return
|
||||
|
@ -59,14 +60,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
actMode?.invalidate()
|
||||
}
|
||||
|
||||
fun updatePrimaryColor(color: Int) {
|
||||
foregroundColor = color
|
||||
(0..itemViews.size() - 1).mapNotNull { itemViews[it] }
|
||||
.forEach {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val adapterListener = object : MyAdapterListener {
|
||||
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
|
||||
toggleItemSelection(select, position)
|
||||
|
@ -411,6 +404,8 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
|
||||
setOnClickListener { viewClicked(directory) }
|
||||
setOnLongClickListener { if (isPickIntent) viewClicked(directory) else viewLongClicked(); true }
|
||||
|
||||
|
||||
}
|
||||
return itemView
|
||||
}
|
||||
|
|
9
app/src/main/res/drawable/circle_background.xml
Normal file
9
app/src/main/res/drawable/circle_background.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<solid
|
||||
android:color="@color/color_primary"/>
|
||||
|
||||
</shape>
|
|
@ -13,12 +13,14 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/dir_check"
|
||||
android:layout_width="@dimen/pin_size"
|
||||
android:layout_height="@dimen/pin_size"
|
||||
android:layout_width="@dimen/selection_check_size"
|
||||
android:layout_height="@dimen/selection_check_size"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_margin="@dimen/small_margin"
|
||||
android:background="@drawable/circle_background"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_check"/>
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<dimen name="dir_tmb_size">150dp</dimen>
|
||||
<dimen name="medium_tmb_size">120dp</dimen>
|
||||
<dimen name="pin_size">30dp</dimen>
|
||||
<dimen name="selection_check_size">38dp</dimen>
|
||||
<dimen name="play_outline_size">60dp</dimen>
|
||||
<dimen name="play_outline_size_big">230dp</dimen>
|
||||
<dimen name="timer_padding">32dp</dimen>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<dimen name="dir_tmb_size">150dp</dimen>
|
||||
<dimen name="medium_tmb_size">100dp</dimen>
|
||||
<dimen name="pin_size">20dp</dimen>
|
||||
<dimen name="selection_check_size">26dp</dimen>
|
||||
<dimen name="play_outline_size">40dp</dimen>
|
||||
<dimen name="play_outline_size_big">150dp</dimen>
|
||||
<dimen name="timer_padding">24dp</dimen>
|
||||
|
|
Loading…
Reference in a new issue