aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/com/zeapo
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/zeapo')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt19
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableConstraintLayout.kt (renamed from app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableLinearLayout.kt)14
2 files changed, 17 insertions, 16 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt
index 9bcb96e4..176f4a82 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt
@@ -10,11 +10,10 @@ import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
-
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.utils.PasswordItem
-import com.zeapo.pwdstore.widget.MultiselectableLinearLayout
-
+import com.zeapo.pwdstore.widget.MultiselectableConstraintLayout
+import java.io.File
import java.util.ArrayList
import java.util.TreeSet
@@ -81,12 +80,20 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
holder.name.text = pass.toString()
if (pass.type == PasswordItem.TYPE_CATEGORY) {
holder.type.visibility = View.GONE
- holder.typeImage.setImageResource(R.drawable.ic_folder_tinted_24dp)
+ holder.typeImage.setImageResource(R.drawable.ic_multiple_files_tinted_24dp)
+ holder.folderIndicator.visibility = View.VISIBLE
+ val childCount = (pass.file.list { current, name -> File(current, name).isFile } ?: emptyArray<File>()).size
+ if (childCount > 0) {
+ holder.childCount.visibility = View.VISIBLE
+ holder.childCount.text = "$childCount"
+ }
} else {
holder.typeImage.setImageResource(R.drawable.ic_action_secure)
holder.name.text = pass.toString()
holder.type.visibility = View.VISIBLE
holder.type.text = pass.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
+ holder.childCount.visibility = View.GONE
+ holder.folderIndicator.visibility = View.GONE
}
holder.view.setOnClickListener(getOnClickListener(holder, pass))
@@ -96,7 +103,7 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
// after removal, everything is rebound for some reason; views are shuffled?
val selected = selectedItems.contains(position)
holder.view.isSelected = selected
- (holder.itemView as MultiselectableLinearLayout).setMultiSelected(selected)
+ (holder.itemView as MultiselectableConstraintLayout).setMultiSelected(selected)
}
protected abstract fun getOnClickListener(holder: ViewHolder, pass: PasswordItem): View.OnClickListener
@@ -122,5 +129,7 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
val name: AppCompatTextView = view.findViewById(R.id.label)
val type: AppCompatTextView = view.findViewById(R.id.type)
val typeImage: AppCompatImageView = view.findViewById(R.id.type_image)
+ val childCount: AppCompatTextView = view.findViewById(R.id.child_count)
+ val folderIndicator: AppCompatImageView = view.findViewById(R.id.folder_indicator)
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableLinearLayout.kt b/app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableConstraintLayout.kt
index c857c4d4..3cd88eb4 100644
--- a/app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableLinearLayout.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/widget/MultiselectableConstraintLayout.kt
@@ -7,15 +7,15 @@ package com.zeapo.pwdstore.widget
import android.content.Context
import android.util.AttributeSet
import android.view.View
-import android.widget.LinearLayout
+import androidx.constraintlayout.widget.ConstraintLayout
import com.zeapo.pwdstore.R
-class MultiselectableLinearLayout @JvmOverloads constructor(
+class MultiselectableConstraintLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
-) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) {
+) : ConstraintLayout(context, attrs, defStyleAttr, defStyleRes) {
private var multiselected: Boolean = false
override fun onCreateDrawableState(extraSpace: Int): IntArray {
@@ -35,14 +35,6 @@ class MultiselectableLinearLayout @JvmOverloads constructor(
isActivated = on
}
- fun setSingleSelected(on: Boolean) {
- if (multiselected) {
- multiselected = false
- refreshDrawableState()
- }
- isActivated = on
- }
-
companion object {
private val STATE_MULTISELECTED = intArrayOf(R.attr.state_multiselected)
}