Skip to content

Commit

Permalink
add scan password button
Browse files Browse the repository at this point in the history
  • Loading branch information
eldad committed Jan 29, 2022
1 parent 1ae0009 commit 57bbbc0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
Expand Up @@ -12,6 +12,8 @@ import com.yogeshpaliyal.keypass.R
import com.yogeshpaliyal.keypass.databinding.FragmentDetailBinding
import com.yogeshpaliyal.keypass.utils.PasswordGenerator
import dagger.hilt.android.AndroidEntryPoint
import com.google.zxing.integration.android.IntentIntegrator


/*
* @author Yogesh Paliyal
Expand Down Expand Up @@ -85,6 +87,10 @@ class DetailActivity : AppCompatActivity() {
onBackPressed()
}
}

binding.btnScan.setOnClickListener {
IntentIntegrator(this).setPrompt("").initiateScan()
}
}

private fun deleteAccount() {
Expand All @@ -111,4 +117,21 @@ class DetailActivity : AppCompatActivity() {
menuInflater.inflate(R.menu.bottom_app_bar_detail, menu)
return super.onCreateOptionsMenu(menu)
}


override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)

if (result != null) {
if (result.contents != null) {
binding.etPassword.setText(result.contents)
}
} else {
super.onActivityResult(requestCode, resultCode, data)
}

if (requestCode == IntentIntegrator.REQUEST_CODE && resultCode == RESULT_OK) {
}
}
}
20 changes: 16 additions & 4 deletions app/src/main/res/layout/fragment_detail.xml
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

Expand All @@ -8,8 +10,7 @@
type="com.yogeshpaliyal.keypass.data.AccountModel" />
</data>

<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down Expand Up @@ -82,9 +83,9 @@
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_twotone_qr_code_scanner_24"
android:importantForAutofill="no"
android:inputType="textNoSuggestions|textPassword"
android:singleLine="true"
android:text="@={accountData.password}" />
</com.google.android.material.textfield.TextInputLayout>

Expand Down Expand Up @@ -151,6 +152,7 @@


<Space
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="@dimen/grid_1"
app:layout_constraintTop_toBottomOf="@id/tilNotes" />
Expand All @@ -176,6 +178,16 @@
android:orientation="horizontal"
app:layout_constraintGuide_begin="@dimen/grid_1" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/btnScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/space"
app:shapeAppearanceOverlay="@style/ShapeAppearance.KeyPass.Cirle"
app:srcCompat="@drawable/ic_twotone_qr_code_scanner_24" />


</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down

0 comments on commit 57bbbc0

Please sign in to comment.