mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
First commit for new lock button
This commit is contained in:
@@ -125,6 +125,10 @@ class EntryActivity : LockingActivity() {
|
|||||||
entryContentsView?.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this))
|
entryContentsView?.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this))
|
||||||
entryProgress = findViewById(R.id.entry_progress)
|
entryProgress = findViewById(R.id.entry_progress)
|
||||||
|
|
||||||
|
findViewById<View>(R.id.lock_button)?.setOnClickListener {
|
||||||
|
lockAndExit()
|
||||||
|
}
|
||||||
|
|
||||||
// Init the clipboard helper
|
// Init the clipboard helper
|
||||||
clipboardHelper = ClipboardHelper(this)
|
clipboardHelper = ClipboardHelper(this)
|
||||||
firstLaunchOfActivity = true
|
firstLaunchOfActivity = true
|
||||||
@@ -526,10 +530,6 @@ class EntryActivity : LockingActivity() {
|
|||||||
!mReadOnly && mAutoSaveEnable)
|
!mReadOnly && mAutoSaveEnable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.menu_lock -> {
|
|
||||||
lockAndExit()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.menu_save_database -> {
|
R.id.menu_save_database -> {
|
||||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
.show(supportFragmentManager, "DatePickerFragment")
|
.show(supportFragmentManager, "DatePickerFragment")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findViewById<View>(R.id.lock_button)?.setOnClickListener {
|
||||||
|
lockAndExit()
|
||||||
|
}
|
||||||
|
|
||||||
// Focus view to reinitialize timeout
|
// Focus view to reinitialize timeout
|
||||||
resetAppTimeoutWhenViewFocusedOrChanged(entryEditContentsView)
|
resetAppTimeoutWhenViewFocusedOrChanged(entryEditContentsView)
|
||||||
|
|
||||||
@@ -416,10 +421,6 @@ class EntryEditActivity : LockingActivity(),
|
|||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_lock -> {
|
|
||||||
lockAndExit()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.menu_save_database -> {
|
R.id.menu_save_database -> {
|
||||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class GroupActivity : LockingActivity(),
|
|||||||
|
|
||||||
// Views
|
// Views
|
||||||
private var coordinatorLayout: CoordinatorLayout? = null
|
private var coordinatorLayout: CoordinatorLayout? = null
|
||||||
|
private var lockView: ImageView? = null
|
||||||
private var toolbar: Toolbar? = null
|
private var toolbar: Toolbar? = null
|
||||||
private var searchTitleView: View? = null
|
private var searchTitleView: View? = null
|
||||||
private var toolbarAction: ToolbarAction? = null
|
private var toolbarAction: ToolbarAction? = null
|
||||||
@@ -134,6 +135,11 @@ class GroupActivity : LockingActivity(),
|
|||||||
groupNameView = findViewById(R.id.group_name)
|
groupNameView = findViewById(R.id.group_name)
|
||||||
toolbarAction = findViewById(R.id.toolbar_action)
|
toolbarAction = findViewById(R.id.toolbar_action)
|
||||||
modeTitleView = findViewById(R.id.mode_title_view)
|
modeTitleView = findViewById(R.id.mode_title_view)
|
||||||
|
lockView = findViewById(R.id.lock_button)
|
||||||
|
|
||||||
|
lockView?.setOnClickListener {
|
||||||
|
lockAndExit()
|
||||||
|
}
|
||||||
|
|
||||||
toolbar?.title = ""
|
toolbar?.title = ""
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
@@ -753,12 +759,10 @@ class GroupActivity : LockingActivity(),
|
|||||||
|
|
||||||
if (!sortMenuEducationPerformed) {
|
if (!sortMenuEducationPerformed) {
|
||||||
// lockMenuEducationPerformed
|
// lockMenuEducationPerformed
|
||||||
toolbar != null
|
lockView != null
|
||||||
&& toolbar!!.findViewById<View>(R.id.menu_lock) != null
|
&& groupActivityEducation.checkAndPerformedLockMenuEducation(lockView!!,
|
||||||
&& groupActivityEducation.checkAndPerformedLockMenuEducation(
|
|
||||||
toolbar!!.findViewById(R.id.menu_lock),
|
|
||||||
{
|
{
|
||||||
onOptionsItemSelected(menu.findItem(R.id.menu_lock))
|
lockAndExit()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
performedNextEducation(groupActivityEducation, menu)
|
performedNextEducation(groupActivityEducation, menu)
|
||||||
@@ -777,10 +781,6 @@ class GroupActivity : LockingActivity(),
|
|||||||
R.id.menu_search ->
|
R.id.menu_search ->
|
||||||
//onSearchRequested();
|
//onSearchRequested();
|
||||||
return true
|
return true
|
||||||
R.id.menu_lock -> {
|
|
||||||
lockAndExit()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.menu_save_database -> {
|
R.id.menu_save_database -> {
|
||||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -551,14 +551,10 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
|||||||
|
|
||||||
val settingActivity = activity as SettingsActivity?
|
val settingActivity = activity as SettingsActivity?
|
||||||
|
|
||||||
when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.menu_lock -> {
|
|
||||||
settingActivity?.lock()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
R.id.menu_save_database -> {
|
R.id.menu_save_database -> {
|
||||||
settingActivity?.mProgressDialogThread?.startDatabaseSave(!mDatabaseReadOnly)
|
settingActivity?.mProgressDialogThread?.startDatabaseSave(!mDatabaseReadOnly)
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
@@ -566,7 +562,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
|||||||
settingActivity?.let {
|
settingActivity?.let {
|
||||||
MenuUtil.onDefaultMenuOptionsItemSelected(it, item, mDatabaseReadOnly, true)
|
MenuUtil.onDefaultMenuOptionsItemSelected(it, item, mDatabaseReadOnly, true)
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item)
|
super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import android.content.Intent
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@@ -47,6 +49,7 @@ open class SettingsActivity
|
|||||||
|
|
||||||
private var coordinatorLayout: CoordinatorLayout? = null
|
private var coordinatorLayout: CoordinatorLayout? = null
|
||||||
private var toolbar: Toolbar? = null
|
private var toolbar: Toolbar? = null
|
||||||
|
private var lockView: ImageView? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -84,6 +87,11 @@ open class SettingsActivity
|
|||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
||||||
|
lockView = findViewById(R.id.lock_button)
|
||||||
|
lockView?.setOnClickListener {
|
||||||
|
lockAndExit()
|
||||||
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.add(R.id.fragment_container, retrieveMainFragment())
|
.add(R.id.fragment_container, retrieveMainFragment())
|
||||||
@@ -154,6 +162,19 @@ open class SettingsActivity
|
|||||||
keyFile: Uri?) {
|
keyFile: Uri?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun hideOrShowLockButton(key: NestedSettingsFragment.Screen) {
|
||||||
|
when (key) {
|
||||||
|
NestedSettingsFragment.Screen.DATABASE,
|
||||||
|
NestedSettingsFragment.Screen.DATABASE_MASTER_KEY,
|
||||||
|
NestedSettingsFragment.Screen.DATABASE_SECURITY -> {
|
||||||
|
lockView?.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
lockView?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
// this if statement is necessary to navigate through nested and main fragments
|
// this if statement is necessary to navigate through nested and main fragments
|
||||||
if (supportFragmentManager.backStackEntryCount == 0) {
|
if (supportFragmentManager.backStackEntryCount == 0) {
|
||||||
@@ -162,6 +183,7 @@ open class SettingsActivity
|
|||||||
supportFragmentManager.popBackStack()
|
supportFragmentManager.popBackStack()
|
||||||
}
|
}
|
||||||
toolbar?.setTitle(R.string.settings)
|
toolbar?.setTitle(R.string.settings)
|
||||||
|
hideOrShowLockButton(NestedSettingsFragment.Screen.APPLICATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun replaceFragment(key: NestedSettingsFragment.Screen) {
|
private fun replaceFragment(key: NestedSettingsFragment.Screen) {
|
||||||
@@ -173,6 +195,7 @@ open class SettingsActivity
|
|||||||
.commit()
|
.commit()
|
||||||
|
|
||||||
toolbar?.title = NestedSettingsFragment.retrieveTitle(resources, key)
|
toolbar?.title = NestedSettingsFragment.retrieveTitle(resources, key)
|
||||||
|
hideOrShowLockButton(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNestedPreferenceSelected(key: NestedSettingsFragment.Screen) {
|
override fun onNestedPreferenceSelected(key: NestedSettingsFragment.Screen) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:color="@color/white"
|
||||||
|
tools:targetApi="lollipop">
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="0dp"
|
||||||
|
android:topRightRadius="40dp"
|
||||||
|
android:bottomLeftRadius="0dp"
|
||||||
|
android:bottomRightRadius="0dp"/>
|
||||||
|
<padding
|
||||||
|
android:left="0dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:top="16dp"
|
||||||
|
android:bottom="8dp"/>
|
||||||
|
<solid android:color="?attr/colorPrimaryDark"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</ripple>
|
||||||
33
app/src/main/res/drawable/background_start_bottom_button.xml
Normal file
33
app/src/main/res/drawable/background_start_bottom_button.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape>
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="0dp"
|
||||||
|
android:topRightRadius="40dp"
|
||||||
|
android:bottomLeftRadius="0dp"
|
||||||
|
android:bottomRightRadius="0dp"/>
|
||||||
|
<padding
|
||||||
|
android:left="0dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:top="16dp"
|
||||||
|
android:bottom="8dp"/>
|
||||||
|
<solid android:color="@color/green"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape>
|
||||||
|
<corners
|
||||||
|
android:topLeftRadius="0dp"
|
||||||
|
android:topRightRadius="40dp"
|
||||||
|
android:bottomLeftRadius="0dp"
|
||||||
|
android:bottomRightRadius="0dp"/>
|
||||||
|
<padding
|
||||||
|
android:left="0dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:top="16dp"
|
||||||
|
android:bottom="8dp"/>
|
||||||
|
<solid android:color="@color/green_dark"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
||||||
@@ -126,4 +126,13 @@
|
|||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/lock_button"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_lock_white_24dp"
|
||||||
|
android:background="@drawable/background_start_bottom_button"
|
||||||
|
android:contentDescription="@string/menu_lock"
|
||||||
|
android:layout_gravity="start|bottom" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -102,6 +102,15 @@
|
|||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/lock_button"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_lock_white_24dp"
|
||||||
|
android:background="@drawable/background_start_bottom_button"
|
||||||
|
android:contentDescription="@string/menu_lock"
|
||||||
|
android:layout_gravity="start|bottom" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/entry_edit_validate"
|
android:id="@+id/entry_edit_validate"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -140,12 +140,22 @@
|
|||||||
android:background="?android:attr/windowBackground" />
|
android:background="?android:attr/windowBackground" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/lock_button"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:src="@drawable/ic_lock_white_24dp"
|
||||||
|
android:background="@drawable/background_start_bottom_button"
|
||||||
|
android:contentDescription="@string/menu_lock"
|
||||||
|
app:layout_anchor="@+id/node_list_container"
|
||||||
|
app:layout_anchorGravity="start|bottom" />
|
||||||
|
|
||||||
<com.kunzisoft.keepass.view.AddNodeButtonView
|
<com.kunzisoft.keepass.view.AddNodeButtonView
|
||||||
android:id="@+id/add_node_button"
|
android:id="@+id/add_node_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_anchor="@+id/node_list_container"
|
app:layout_anchor="@+id/node_list_container"
|
||||||
app:layout_anchorGravity="right|bottom" />
|
app:layout_anchorGravity="end|bottom" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
<com.kunzisoft.keepass.view.ToolbarAction
|
<com.kunzisoft.keepass.view.ToolbarAction
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/toolbar_coordinator"
|
android:id="@+id/toolbar_coordinator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@@ -38,4 +38,14 @@
|
|||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/lock_button"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:src="@drawable/ic_lock_white_24dp"
|
||||||
|
android:background="@drawable/background_start_bottom_button"
|
||||||
|
android:contentDescription="@string/menu_lock"
|
||||||
|
android:layout_gravity="start|bottom" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -19,11 +19,6 @@
|
|||||||
-->
|
-->
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item android:id="@+id/menu_lock"
|
|
||||||
android:icon="@drawable/ic_lock_white_24dp"
|
|
||||||
android:title="@string/menu_lock"
|
|
||||||
android:orderInCategory="81"
|
|
||||||
app:showAsAction="always" />
|
|
||||||
<item android:id="@+id/menu_save_database"
|
<item android:id="@+id/menu_save_database"
|
||||||
android:icon="@drawable/ic_save_white_24dp"
|
android:icon="@drawable/ic_save_white_24dp"
|
||||||
android:title="@string/menu_save_database"
|
android:title="@string/menu_save_database"
|
||||||
|
|||||||
Reference in New Issue
Block a user