From 15159de4e981d2abdfb0c1a8cd0f11e510fa9ce7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 5 Aug 2017 16:55:12 +0200 Subject: [PATCH] add colored background to the currently selected directory thumbnail --- .../gallery/activities/MainActivity.kt | 4 ++-- .../gallery/adapters/DirectoryAdapter.kt | 23 ++++++++----------- .../main/res/drawable/circle_background.xml | 9 ++++++++ app/src/main/res/layout/directory_item.xml | 6 +++-- app/src/main/res/values-sw600dp/dimens.xml | 1 + app/src/main/res/values/dimens.xml | 1 + 6 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable/circle_background.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 3da7e96c0..b665c7f06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index f359bccf1..18feb60e0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -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() val selectedPositions = HashSet() - 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 + + + + + diff --git a/app/src/main/res/layout/directory_item.xml b/app/src/main/res/layout/directory_item.xml index 1f71cde77..98e94a3e2 100644 --- a/app/src/main/res/layout/directory_item.xml +++ b/app/src/main/res/layout/directory_item.xml @@ -13,12 +13,14 @@ 150dp 120dp 30dp + 38dp 60dp 230dp 32dp diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 7e8edefbe..7301b88ac 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,6 +3,7 @@ 150dp 100dp 20dp + 26dp 40dp 150dp 24dp