Tweak password row layout some more (#567)

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
Harsh Shandilya 2019-11-16 12:08:31 +05:30 committed by Aditya Wasan
parent de9a201587
commit 1d081b9054
2 changed files with 9 additions and 21 deletions

View file

@ -5,6 +5,8 @@
package com.zeapo.pwdstore.ui.adapters package com.zeapo.pwdstore.ui.adapters
import android.content.SharedPreferences import android.content.SharedPreferences
import android.text.SpannableString
import android.text.style.RelativeSizeSpan
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -84,7 +86,6 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
val showHidden = settings?.getBoolean("show_hidden_folders", false) ?: false val showHidden = settings?.getBoolean("show_hidden_folders", false) ?: false
holder.name.text = pass.toString() holder.name.text = pass.toString()
if (pass.type == PasswordItem.TYPE_CATEGORY) { if (pass.type == PasswordItem.TYPE_CATEGORY) {
holder.type.visibility = View.GONE
holder.typeImage.setImageResource(R.drawable.ic_multiple_files_24dp) holder.typeImage.setImageResource(R.drawable.ic_multiple_files_24dp)
holder.folderIndicator.visibility = View.VISIBLE holder.folderIndicator.visibility = View.VISIBLE
val children = pass.file.listFiles { pathname -> val children = pass.file.listFiles { pathname ->
@ -97,15 +98,15 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
} }
} else { } else {
holder.typeImage.setImageResource(R.drawable.ic_action_secure_24dp) holder.typeImage.setImageResource(R.drawable.ic_action_secure_24dp)
holder.name.text = pass.toString() val parentPath = pass.fullPathToParent.replace("(^/)|(/$)".toRegex(), "")
holder.type.visibility = View.VISIBLE val source = "$parentPath\n$pass"
holder.type.text = pass.fullPathToParent.replace("(^/)|(/$)".toRegex(), "") val spannable = SpannableString(source)
spannable.setSpan(RelativeSizeSpan(0.7f), 0, parentPath.length, 0)
holder.name.text = spannable
holder.childCount.visibility = View.GONE holder.childCount.visibility = View.GONE
holder.folderIndicator.visibility = View.GONE holder.folderIndicator.visibility = View.GONE
} }
holder.view.setOnClickListener(getOnClickListener(holder, pass)) holder.view.setOnClickListener(getOnClickListener(holder, pass))
holder.view.setOnLongClickListener(getOnLongClickListener(holder, pass)) holder.view.setOnLongClickListener(getOnLongClickListener(holder, pass))
// after removal, everything is rebound for some reason; views are shuffled? // after removal, everything is rebound for some reason; views are shuffled?
@ -135,7 +136,6 @@ abstract class EntryRecyclerAdapter internal constructor(val values: ArrayList<P
*/ */
class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) { class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
val name: AppCompatTextView = view.findViewById(R.id.label) 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 typeImage: AppCompatImageView = view.findViewById(R.id.type_image)
val childCount: AppCompatTextView = view.findViewById(R.id.child_count) val childCount: AppCompatTextView = view.findViewById(R.id.child_count)
val folderIndicator: AppCompatImageView = view.findViewById(R.id.folder_indicator) val folderIndicator: AppCompatImageView = view.findViewById(R.id.folder_indicator)

View file

@ -20,18 +20,6 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
tools:src="@drawable/ic_multiple_files_24dp" /> tools:src="@drawable/ic_multiple_files_24dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="start"
android:singleLine="true"
android:textColor="?android:attr/textColor"
android:textSize="14sp"
app:layout_constraintStart_toEndOf="@id/type_image"
app:layout_constraintTop_toTopOf="parent"
tools:text="TYPE" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/label" android:id="@+id/label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -39,9 +27,9 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:textColor="?android:attr/textColor" android:textColor="?android:attr/textColor"
android:textSize="18sp" android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/type_image" app:layout_constraintStart_toEndOf="@id/type_image"
app:layout_constraintTop_toBottomOf="@id/type" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/type_image"
tools:text="FILE_NAME" /> tools:text="FILE_NAME" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView