summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2019-11-04 18:20:49 +0530
committerHarsh Shandilya <msfjarvis@gmail.com>2019-11-04 20:13:19 +0530
commita21353cb063902dff73d5a371f17978f177910f5 (patch)
tree33427b4912b51857487f310a462386a15dcc0ca0 /app
parent159e8967b637623af5eb73306fdafc99ef98d17e (diff)
Add child count to folders
Fixes #559 Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ui/adapters/EntryRecyclerAdapter.kt8
-rw-r--r--app/src/main/res/layout/password_row_layout.xml11
2 files changed, 19 insertions, 0 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 211394fb..ba66ed6f 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
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.utils.PasswordItem
import com.zeapo.pwdstore.widget.MultiselectableLinearLayout
+import java.io.File
import java.util.ArrayList
import java.util.TreeSet
@@ -81,11 +82,17 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
holder.type.visibility = View.GONE
holder.typeImage.setImageResource(R.drawable.ic_folder_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
}
@@ -122,6 +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/res/layout/password_row_layout.xml b/app/src/main/res/layout/password_row_layout.xml
index 689898c2..e5e8e0b6 100644
--- a/app/src/main/res/layout/password_row_layout.xml
+++ b/app/src/main/res/layout/password_row_layout.xml
@@ -47,6 +47,17 @@
app:layout_constraintTop_toBottomOf="@id/type"
tools:text="FILE_NAME" />
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/child_count"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="18sp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/folder_indicator"
+ android:layout_marginEnd="12dp"
+ tools:text="12" />
+
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/folder_indicator"
android:layout_width="wrap_content"