mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2026-01-02 01:10:08 -06:00
added copy option and improve searching
This commit is contained in:
@@ -27,8 +27,8 @@ android {
|
||||
applicationId appPackageId
|
||||
minSdkVersion 22
|
||||
targetSdkVersion 30
|
||||
versionCode 1306
|
||||
versionName "1.3.6"
|
||||
versionCode 1307
|
||||
versionName "1.3.7"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class DbDao {
|
||||
@Query("SELECT * FROM account ORDER BY title ASC")
|
||||
abstract fun getAllAccounts(): LiveData<List<AccountModel>>
|
||||
|
||||
@Query("SELECT * FROM account WHERE CASE WHEN :tag IS NOT NULL THEN tags = :tag ELSE 1 END AND (username LIKE '%'||:query||'%' ) ORDER BY title ASC")
|
||||
@Query("SELECT * FROM account WHERE CASE WHEN :tag IS NOT NULL THEN tags = :tag ELSE 1 END AND ((username LIKE '%'||:query||'%' ) OR (title LIKE '%'||:query||'%' ) OR (notes LIKE '%'||:query||'%' )) ORDER BY title ASC")
|
||||
abstract fun getAllAccounts(query: String?, tag: String?): LiveData<List<AccountModel>>
|
||||
|
||||
@Query("SELECT * FROM account WHERE id = :id")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yogeshpaliyal.keypass.listener
|
||||
|
||||
import android.view.View
|
||||
|
||||
|
||||
/*
|
||||
* @author Yogesh Paliyal
|
||||
* techpaliyal@gmail.com
|
||||
* https://techpaliyal.com
|
||||
* created on 31-01-2021 09:00
|
||||
*/
|
||||
interface AccountsClickListener<T> {
|
||||
fun onItemClick(view: View, model: T)
|
||||
fun onCopyClicked(model: T)
|
||||
}
|
||||
@@ -1,15 +1,20 @@
|
||||
package com.yogeshpaliyal.keypass.ui.home
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Observer
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.data.AccountModel
|
||||
import com.yogeshpaliyal.keypass.databinding.FragmentHomeBinding
|
||||
import com.yogeshpaliyal.keypass.listener.AccountsClickListener
|
||||
import com.yogeshpaliyal.keypass.listener.UniversalClickListener
|
||||
import com.yogeshpaliyal.keypass.ui.detail.DetailActivity
|
||||
import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
|
||||
@@ -43,10 +48,21 @@ class HomeFragment : Fragment() {
|
||||
).build()
|
||||
}
|
||||
|
||||
val mListener = object : UniversalClickListener<AccountModel> {
|
||||
val mListener = object : AccountsClickListener<AccountModel> {
|
||||
override fun onItemClick(view: View, model: AccountModel) {
|
||||
DetailActivity.start(context, model.id)
|
||||
}
|
||||
|
||||
override fun onCopyClicked(model: AccountModel) {
|
||||
val clipboard =
|
||||
ContextCompat.getSystemService(
|
||||
requireContext(),
|
||||
ClipboardManager::class.java
|
||||
)
|
||||
val clip = ClipData.newPlainText("KeyPass", model.password)
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(context, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
app:boxCornerRadiusTopEnd="@dimen/grid_1"
|
||||
app:boxCornerRadiusTopStart="@dimen/grid_1"
|
||||
app:hintAnimationEnabled="false"
|
||||
app:hintEnabled="false">
|
||||
app:hintEnabled="false"
|
||||
app:endIconMode="clear_text">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
type="AccountModel" />
|
||||
<variable
|
||||
name="listener"
|
||||
type="com.yogeshpaliyal.keypass.listener.UniversalClickListener<AccountModel>" />
|
||||
type="com.yogeshpaliyal.keypass.listener.AccountsClickListener<AccountModel>" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@@ -55,7 +55,7 @@
|
||||
android:text="@{model.title}"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toTopOf="@id/txtUsername"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/icnCopy"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/startIcon"
|
||||
app:layout_constraintTop_toTopOf="@id/startIcon"
|
||||
@@ -66,7 +66,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/txtTitle"
|
||||
app:layout_constraintStart_toStartOf="@id/txtTitle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/icnCopy"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
style="@style/TextStyle.SubHeading"
|
||||
android:text="@{model.username}"
|
||||
@@ -75,6 +75,17 @@
|
||||
tools:text="@tools:sample/full_names"
|
||||
app:layout_constrainedWidth="true"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_twotone_content_copy_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:padding="@dimen/grid_1"
|
||||
android:onClick="@{()->listener.onCopyClicked(model)}"
|
||||
android:id="@+id/icnCopy"/>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</com.yogeshpaliyal.keypass.custom_views.MaskedCardView>
|
||||
|
||||
15
app/src/staging/res/drawable/ic_twotone_content_copy_24.xml
Normal file
15
app/src/staging/res/drawable/ic_twotone_content_copy_24.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M8,7h11v14H8z"
|
||||
android:strokeAlpha="0.3"
|
||||
android:fillAlpha="0.3"/>
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"/>
|
||||
</vector>
|
||||
Reference in New Issue
Block a user