From 970b966bcbbadeb9aa1db63c17631f70833f99b9 Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Mon, 5 Aug 2019 12:25:48 +0200 Subject: [PATCH] Collapsing Toolbar for entry activity --- .../keepass/activities/EntryActivity.kt | 10 +- .../keepass/view/EntryCustomField.kt | 2 +- app/src/main/res/layout/activity_entry.xml | 103 ++++++++++-------- ...new_field.xml => item_entry_new_field.xml} | 0 app/src/main/res/values/dimens.xml | 2 + app/src/main/res/values/styles.xml | 15 +++ 6 files changed, 80 insertions(+), 52 deletions(-) rename app/src/main/res/layout/{view_entry_new_field.xml => item_entry_new_field.xml} (100%) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt index 02aa29c92..31c9e2ad3 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/EntryActivity.kt @@ -25,6 +25,7 @@ import android.graphics.Color import android.net.Uri import android.os.Bundle import android.os.Handler +import android.support.design.widget.CollapsingToolbarLayout import android.support.v7.app.AlertDialog import android.support.v7.widget.Toolbar import android.util.Log @@ -32,7 +33,6 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.widget.ImageView -import android.widget.TextView import android.widget.Toast import com.kunzisoft.keepass.R import com.kunzisoft.keepass.education.EntryActivityEducation @@ -54,8 +54,8 @@ import com.kunzisoft.keepass.utils.Util class EntryActivity : LockingHideActivity() { + private var collapsingToolbarLayout: CollapsingToolbarLayout? = null private var titleIconView: ImageView? = null - private var titleView: TextView? = null private var entryContentsView: EntryContentsView? = null private var toolbar: Toolbar? = null @@ -109,8 +109,8 @@ class EntryActivity : LockingHideActivity() { invalidateOptionsMenu() // Get views + collapsingToolbarLayout = findViewById(R.id.toolbar_layout) titleIconView = findViewById(R.id.entry_icon) - titleView = findViewById(R.id.entry_title) entryContentsView = findViewById(R.id.entry_contents) entryContentsView?.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this)) @@ -144,7 +144,9 @@ class EntryActivity : LockingHideActivity() { titleIconView?.assignDatabaseIcon(database.drawFactory, entry.icon, iconColor) // Assign title text - titleView?.text = entry.getVisualTitle() + val entryTitle = entry.getVisualTitle() + collapsingToolbarLayout?.title = entryTitle + toolbar?.title = entryTitle // Assign basic fields entryContentsView?.assignUserName(entry.username) diff --git a/app/src/main/java/com/kunzisoft/keepass/view/EntryCustomField.kt b/app/src/main/java/com/kunzisoft/keepass/view/EntryCustomField.kt index 30b96532c..b97dd5009 100644 --- a/app/src/main/java/com/kunzisoft/keepass/view/EntryCustomField.kt +++ b/app/src/main/java/com/kunzisoft/keepass/view/EntryCustomField.kt @@ -49,7 +49,7 @@ open class EntryCustomField(context: Context, init { val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater - inflater.inflate(R.layout.view_entry_new_field, this) + inflater.inflate(R.layout.item_entry_new_field, this) labelView = findViewById(R.id.title) valueView = findViewById(R.id.value) diff --git a/app/src/main/res/layout/activity_entry.xml b/app/src/main/res/layout/activity_entry.xml index e8b4c1bf5..aeed54e20 100644 --- a/app/src/main/res/layout/activity_entry.xml +++ b/app/src/main/res/layout/activity_entry.xml @@ -17,65 +17,74 @@ You should have received a copy of the GNU General Public License along with KeePass DX. If not, see . --> - + android:fitsSystemWindows="true"> - - - - - - + android:layout_height="@dimen/toolbar_parallax_height" + android:fitsSystemWindows="true"> - + + + + + + + + + + + + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/view_entry_new_field.xml b/app/src/main/res/layout/item_entry_new_field.xml similarity index 100% rename from app/src/main/res/layout/view_entry_new_field.xml rename to app/src/main/res/layout/item_entry_new_field.xml diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 7605cda2c..28462593b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -9,5 +9,7 @@ 1 + 220dp + 320 \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f216c780e..8215bad2d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -76,6 +76,9 @@ @style/KeepassDXStyle.Light.Toolbar.Popup @style/KeepassDXStyle.Toolbar.Night @style/KeepassDXStyle.ActionMode + + @style/KeepassDXStyle.Expanded.Title + @style/KeepassDXStyle.Collapsed.Title @style/KeepassDXStyle.Fab.White @@ -133,6 +136,9 @@ @style/KeepassDXStyle.Night.Toolbar.Popup @style/KeepassDXStyle.Toolbar.Night @style/KeepassDXStyle.ActionMode + + @style/KeepassDXStyle.Expanded.Title + @style/KeepassDXStyle.Collapsed.Title @style/KeepassDXStyle.Fab.White @@ -183,6 +189,15 @@ @color/green_dark + + + + +