Add Edit Toolbar menu on top

This commit is contained in:
J-Jamet
2020-03-13 17:06:09 +01:00
parent 0ff129c5ca
commit 8e83615a22
6 changed files with 68 additions and 32 deletions

View File

@@ -127,7 +127,8 @@
android:configChanges="keyboardHidden" />
<activity
android:name="com.kunzisoft.keepass.activities.EntryEditActivity"
android:configChanges="keyboardHidden" />
android:configChanges="keyboardHidden"
android:windowSoftInputMode="adjustResize" />
<!-- About and Settings -->
<activity
android:name="com.kunzisoft.keepass.activities.AboutActivity"

View File

@@ -26,10 +26,10 @@ import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.widget.ActionMenuView
import androidx.appcompat.widget.Toolbar
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomappbar.BottomAppBar
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.dialogs.GeneratePasswordDialogFragment
import com.kunzisoft.keepass.activities.dialogs.IconPickerDialogFragment
@@ -73,7 +73,7 @@ class EntryEditActivity : LockingActivity(),
private var coordinatorLayout: CoordinatorLayout? = null
private var scrollView: NestedScrollView? = null
private var entryEditContentsView: EntryEditContentsView? = null
private var entryEditBottomBar: BottomAppBar? = null
private var entryEditAddToolBar: ActionMenuView? = null
private var saveView: View? = null
// Education
@@ -170,9 +170,9 @@ class EntryEditActivity : LockingActivity(),
entryEditContentsView?.setOnIconViewClickListener { IconPickerDialogFragment.launch(this@EntryEditActivity) }
// Bottom Bar
entryEditBottomBar = findViewById(R.id.entry_edit_bottom_bar)
entryEditBottomBar?.apply {
inflateMenu(R.menu.entry_edit)
entryEditAddToolBar = findViewById(R.id.entry_edit_bottom_bar)
entryEditAddToolBar?.apply {
menuInflater.inflate(R.menu.entry_edit, menu)
menu.findItem(R.id.menu_add_field).apply {
val allowCustomField = mNewEntry?.allowCustomFields() == true

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFF"
android:pathData="M16.5,6v11.5c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4V5c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5v10.5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1V6H10v9.5c0,1.38 1.12,2.5 2.5,2.5s2.5,-1.12 2.5,-2.5V5c0,-2.21 -1.79,-4 -4,-4S7,2.79 7,5v12.5c0,3.04 2.46,5.5 5.5,5.5s5.5,-2.46 5.5,-5.5V6h-1.5z"/>
</vector>

View File

@@ -21,14 +21,15 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:importantForAutofill="noExcludeDescendants"
tools:targetApi="o"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent"
android:importantForAutofill="noExcludeDescendants"
tools:targetApi="o" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_default"
android:elevation="0dp"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.coordinatorlayout.widget.CoordinatorLayout
@@ -36,16 +37,43 @@
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
app:layout_constraintBottom_toBottomOf="parent" >
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="?attr/colorPrimaryDark">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="enterAlways|enterAlwaysCollapsed|scroll|snap">
<androidx.appcompat.widget.Toolbar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="?attr/toolbarAppearance"
android:popupTheme="?attr/toolbarPopupAppearance">
<androidx.appcompat.widget.ActionMenuView
android:id="@+id/entry_edit_bottom_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="parallax"/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/entry_edit_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="insideOverlay"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
android:scrollbars="none">
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
@@ -55,34 +83,24 @@
android:id="@+id/entry_edit_contents"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintWidth_percent="@dimen/content_percent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="@dimen/content_percent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/entry_edit_bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="?android:attr/colorAccent"
app:fabAlignmentMode="end"
app:hideOnScroll="true"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_gravity="bottom" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/entry_edit_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@+id/toolbar_layout"
app:layout_anchorGravity="bottom|end"
android:src="@drawable/ic_save_white_24dp"
android:contentDescription="@string/content_description_entry_save"
app:useCompatPadding="true"
app:layout_anchor="@id/entry_edit_bottom_bar"
style="@style/KeepassDXStyle.Fab"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -23,15 +23,22 @@
android:icon="@drawable/ic_key_white_24dp"
android:title="@string/entry_password_generator"
android:orderInCategory="91"
app:showAsAction="ifRoom" />
app:showAsAction="always" />
<item android:id="@+id/menu_add_field"
android:icon="@drawable/ic_add_white_24dp"
android:title="@string/entry_add_field"
android:orderInCategory="91"
android:orderInCategory="92"
app:showAsAction="always" />
<!--
<item android:id="@+id/menu_add_attachment"
android:icon="@drawable/ic_attach_file_white_24dp"
android:title="@string/entry_add_attachment"
android:orderInCategory="93"
app:showAsAction="ifRoom" />
-->
<item android:id="@+id/menu_add_otp"
android:icon="@drawable/ic_av_timer_white_24dp"
android:title="@string/entry_setup_otp"
android:orderInCategory="92"
android:orderInCategory="94"
app:showAsAction="ifRoom" />
</menu>

View File

@@ -61,6 +61,7 @@
<string name="entry_password_generator">Password generator</string>
<string name="content_description_password_length">Password length</string>
<string name="entry_add_field">Add field</string>
<string name="entry_add_attachment">Add attachment</string>
<string name="content_description_remove_field">Remove field</string>
<string name="content_description_update_from_list">Update</string>
<string name="content_description_remove_from_list">Remove</string>