diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 55c1f801a..6229ffce7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -129,8 +129,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun checkIfColorChanged() { - if (media_grid.adapter != null && getRecyclerAdapter().foregroundColor != config.primaryColor) { - getRecyclerAdapter().updatePrimaryColor(config.primaryColor) + if (media_grid.adapter != null && getRecyclerAdapter().primaryColor != config.primaryColor) { + getRecyclerAdapter().primaryColor = config.primaryColor media_horizontal_fastscroller.updateHandleColor() media_vertical_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 18feb60e0..daec3c8cc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -109,8 +109,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, var actMode: ActionMode? = null var itemViews = SparseArray() val selectedPositions = HashSet() - var foregroundColor = config.primaryColor + var primaryColor = config.primaryColor var displayFilenames = config.displayFileNames var scrollVertically = !config.scrollHorizontally fun toggleItemSelection(select: Boolean, pos: Int) { - if (itemViews[pos] != null) - getProperView(itemViews[pos]!!).isSelected = select - - if (select) + if (select) { + itemViews[pos].medium_check.background.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN) selectedPositions.add(pos) - else + } else selectedPositions.remove(pos) + itemViews[pos]?.medium_check?.beVisibleIf(select) + if (selectedPositions.isEmpty()) { actMode?.finish() return @@ -53,40 +52,16 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, updateTitle(selectedPositions.size) } - fun getProperView(itemView: View): View { - return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) - itemView.medium_thumbnail_holder - else - itemView.medium_thumbnail - } - fun updateTitle(cnt: Int) { actMode?.title = "$cnt / ${media.size}" actMode?.invalidate() } - fun updatePrimaryColor(color: Int) { - foregroundColor = color - (0..itemViews.size() - 1).mapNotNull { itemViews[it] } - .forEach { setupItemViewForeground(it) } - } - - private fun setupItemViewForeground(itemView: View) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) - (getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector() - else - getProperView(itemView).foreground = foregroundColor.createSelector() - } - val adapterListener = object : MyAdapterListener { override fun toggleItemSelectionAdapter(select: Boolean, position: Int) { toggleItemSelection(select, position) } - override fun setupItemForeground(itemView: View) { - setupItemViewForeground(itemView) - } - override fun getSelectedPositions(): HashSet = selectedPositions } @@ -127,8 +102,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, override fun onDestroyActionMode(actionMode: ActionMode?) { super.onDestroyActionMode(actionMode) selectedPositions.forEach { - if (itemViews[it] != null) - getProperView(itemViews[it]!!).isSelected = false + itemViews[it]?.medium_check?.beGone() } selectedPositions.clear() actMode = null @@ -348,8 +322,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, setOnClickListener { viewClicked(medium) } setOnLongClickListener { if (isPickIntent) viewClicked(medium) else viewLongClicked(); true } - - adapterListener.setupItemForeground(this) } return itemView } @@ -383,8 +355,6 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, interface MyAdapterListener { fun toggleItemSelectionAdapter(select: Boolean, position: Int) - fun setupItemForeground(itemView: View) - fun getSelectedPositions(): HashSet } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Int.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Int.kt deleted file mode 100644 index 064c348b6..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Int.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import android.content.res.ColorStateList -import android.graphics.Color -import android.graphics.drawable.ColorDrawable -import android.graphics.drawable.RippleDrawable -import android.graphics.drawable.StateListDrawable -import android.os.Build -import com.simplemobiletools.commons.extensions.adjustAlpha - -fun Int.createSelector(): StateListDrawable { - val statelist = StateListDrawable() - val selectedDrawable = ColorDrawable(adjustAlpha(0.5f)) - statelist.addState(intArrayOf(android.R.attr.state_selected), selectedDrawable) - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - val pressedDrawable = ColorDrawable(adjustAlpha(0.2f)) - statelist.addState(intArrayOf(android.R.attr.state_pressed), pressedDrawable) - } else { - val pressedDrawable = RippleDrawable(ColorStateList.valueOf(adjustAlpha(0.2f)), null, ColorDrawable(Color.WHITE)) - statelist.addState(intArrayOf(), pressedDrawable) - } - return statelist -} diff --git a/app/src/main/res/layout-v23/photo_video_tmb.xml b/app/src/main/res/layout-v23/photo_video_tmb.xml deleted file mode 100644 index 5044be391..000000000 --- a/app/src/main/res/layout-v23/photo_video_tmb.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/app/src/main/res/layout/photo_video_item.xml b/app/src/main/res/layout/photo_video_item.xml index 1ba94a083..f8fe7a6b6 100644 --- a/app/src/main/res/layout/photo_video_item.xml +++ b/app/src/main/res/layout/photo_video_item.xml @@ -6,14 +6,22 @@ android:layout_height="wrap_content" android:padding="1px"> - + android:layout_height="match_parent"/> - - - + - - - - - - - -