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))
|
||||
entryProgress = findViewById(R.id.entry_progress)
|
||||
|
||||
findViewById<View>(R.id.lock_button)?.setOnClickListener {
|
||||
lockAndExit()
|
||||
}
|
||||
|
||||
// Init the clipboard helper
|
||||
clipboardHelper = ClipboardHelper(this)
|
||||
firstLaunchOfActivity = true
|
||||
@@ -526,10 +530,6 @@ class EntryActivity : LockingActivity() {
|
||||
!mReadOnly && mAutoSaveEnable)
|
||||
}
|
||||
}
|
||||
R.id.menu_lock -> {
|
||||
lockAndExit()
|
||||
return true
|
||||
}
|
||||
R.id.menu_save_database -> {
|
||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||
}
|
||||
|
||||
@@ -112,6 +112,11 @@ class EntryEditActivity : LockingActivity(),
|
||||
.show(supportFragmentManager, "DatePickerFragment")
|
||||
}
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.lock_button)?.setOnClickListener {
|
||||
lockAndExit()
|
||||
}
|
||||
|
||||
// Focus view to reinitialize timeout
|
||||
resetAppTimeoutWhenViewFocusedOrChanged(entryEditContentsView)
|
||||
|
||||
@@ -416,10 +421,6 @@ class EntryEditActivity : LockingActivity(),
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_lock -> {
|
||||
lockAndExit()
|
||||
return true
|
||||
}
|
||||
R.id.menu_save_database -> {
|
||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ class GroupActivity : LockingActivity(),
|
||||
|
||||
// Views
|
||||
private var coordinatorLayout: CoordinatorLayout? = null
|
||||
private var lockView: ImageView? = null
|
||||
private var toolbar: Toolbar? = null
|
||||
private var searchTitleView: View? = null
|
||||
private var toolbarAction: ToolbarAction? = null
|
||||
@@ -134,6 +135,11 @@ class GroupActivity : LockingActivity(),
|
||||
groupNameView = findViewById(R.id.group_name)
|
||||
toolbarAction = findViewById(R.id.toolbar_action)
|
||||
modeTitleView = findViewById(R.id.mode_title_view)
|
||||
lockView = findViewById(R.id.lock_button)
|
||||
|
||||
lockView?.setOnClickListener {
|
||||
lockAndExit()
|
||||
}
|
||||
|
||||
toolbar?.title = ""
|
||||
setSupportActionBar(toolbar)
|
||||
@@ -753,12 +759,10 @@ class GroupActivity : LockingActivity(),
|
||||
|
||||
if (!sortMenuEducationPerformed) {
|
||||
// lockMenuEducationPerformed
|
||||
toolbar != null
|
||||
&& toolbar!!.findViewById<View>(R.id.menu_lock) != null
|
||||
&& groupActivityEducation.checkAndPerformedLockMenuEducation(
|
||||
toolbar!!.findViewById(R.id.menu_lock),
|
||||
lockView != null
|
||||
&& groupActivityEducation.checkAndPerformedLockMenuEducation(lockView!!,
|
||||
{
|
||||
onOptionsItemSelected(menu.findItem(R.id.menu_lock))
|
||||
lockAndExit()
|
||||
},
|
||||
{
|
||||
performedNextEducation(groupActivityEducation, menu)
|
||||
@@ -777,10 +781,6 @@ class GroupActivity : LockingActivity(),
|
||||
R.id.menu_search ->
|
||||
//onSearchRequested();
|
||||
return true
|
||||
R.id.menu_lock -> {
|
||||
lockAndExit()
|
||||
return true
|
||||
}
|
||||
R.id.menu_save_database -> {
|
||||
mProgressDialogThread?.startDatabaseSave(!mReadOnly)
|
||||
return true
|
||||
|
||||
@@ -551,14 +551,10 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
|
||||
val settingActivity = activity as SettingsActivity?
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.menu_lock -> {
|
||||
settingActivity?.lock()
|
||||
return true
|
||||
}
|
||||
return when (item.itemId) {
|
||||
R.id.menu_save_database -> {
|
||||
settingActivity?.mProgressDialogThread?.startDatabaseSave(!mDatabaseReadOnly)
|
||||
return true
|
||||
true
|
||||
}
|
||||
|
||||
else -> {
|
||||
@@ -566,7 +562,7 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment() {
|
||||
settingActivity?.let {
|
||||
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.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -47,6 +49,7 @@ open class SettingsActivity
|
||||
|
||||
private var coordinatorLayout: CoordinatorLayout? = null
|
||||
private var toolbar: Toolbar? = null
|
||||
private var lockView: ImageView? = null
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -84,6 +87,11 @@ open class SettingsActivity
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
||||
lockView = findViewById(R.id.lock_button)
|
||||
lockView?.setOnClickListener {
|
||||
lockAndExit()
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.add(R.id.fragment_container, retrieveMainFragment())
|
||||
@@ -154,6 +162,19 @@ open class SettingsActivity
|
||||
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() {
|
||||
// this if statement is necessary to navigate through nested and main fragments
|
||||
if (supportFragmentManager.backStackEntryCount == 0) {
|
||||
@@ -162,6 +183,7 @@ open class SettingsActivity
|
||||
supportFragmentManager.popBackStack()
|
||||
}
|
||||
toolbar?.setTitle(R.string.settings)
|
||||
hideOrShowLockButton(NestedSettingsFragment.Screen.APPLICATION)
|
||||
}
|
||||
|
||||
private fun replaceFragment(key: NestedSettingsFragment.Screen) {
|
||||
@@ -173,6 +195,7 @@ open class SettingsActivity
|
||||
.commit()
|
||||
|
||||
toolbar?.title = NestedSettingsFragment.retrieveTitle(resources, key)
|
||||
hideOrShowLockButton(key)
|
||||
}
|
||||
|
||||
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.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>
|
||||
@@ -102,6 +102,15 @@
|
||||
|
||||
</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
|
||||
android:id="@+id/entry_edit_validate"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -140,12 +140,22 @@
|
||||
android:background="?android:attr/windowBackground" />
|
||||
</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
|
||||
android:id="@+id/add_node_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_anchor="@+id/node_list_container"
|
||||
app:layout_anchorGravity="right|bottom" />
|
||||
app:layout_anchorGravity="end|bottom" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.kunzisoft.keepass.view.ToolbarAction
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/toolbar_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -38,4 +38,14 @@
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</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>
|
||||
@@ -19,11 +19,6 @@
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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"
|
||||
android:icon="@drawable/ic_save_white_24dp"
|
||||
android:title="@string/menu_save_database"
|
||||
|
||||
Reference in New Issue
Block a user