mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Collapsing Toolbar for entry activity
This commit is contained in:
@@ -25,6 +25,7 @@ import android.graphics.Color
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.support.design.widget.CollapsingToolbarLayout
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.widget.Toolbar
|
import android.support.v7.widget.Toolbar
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -32,7 +33,6 @@ import android.view.Menu
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
import com.kunzisoft.keepass.education.EntryActivityEducation
|
import com.kunzisoft.keepass.education.EntryActivityEducation
|
||||||
@@ -54,8 +54,8 @@ import com.kunzisoft.keepass.utils.Util
|
|||||||
|
|
||||||
class EntryActivity : LockingHideActivity() {
|
class EntryActivity : LockingHideActivity() {
|
||||||
|
|
||||||
|
private var collapsingToolbarLayout: CollapsingToolbarLayout? = null
|
||||||
private var titleIconView: ImageView? = null
|
private var titleIconView: ImageView? = null
|
||||||
private var titleView: TextView? = null
|
|
||||||
private var entryContentsView: EntryContentsView? = null
|
private var entryContentsView: EntryContentsView? = null
|
||||||
private var toolbar: Toolbar? = null
|
private var toolbar: Toolbar? = null
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ class EntryActivity : LockingHideActivity() {
|
|||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
|
||||||
// Get views
|
// Get views
|
||||||
|
collapsingToolbarLayout = findViewById(R.id.toolbar_layout)
|
||||||
titleIconView = findViewById(R.id.entry_icon)
|
titleIconView = findViewById(R.id.entry_icon)
|
||||||
titleView = findViewById(R.id.entry_title)
|
|
||||||
entryContentsView = findViewById(R.id.entry_contents)
|
entryContentsView = findViewById(R.id.entry_contents)
|
||||||
entryContentsView?.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this))
|
entryContentsView?.applyFontVisibilityToFields(PreferencesUtil.fieldFontIsInVisibility(this))
|
||||||
|
|
||||||
@@ -144,7 +144,9 @@ class EntryActivity : LockingHideActivity() {
|
|||||||
titleIconView?.assignDatabaseIcon(database.drawFactory, entry.icon, iconColor)
|
titleIconView?.assignDatabaseIcon(database.drawFactory, entry.icon, iconColor)
|
||||||
|
|
||||||
// Assign title text
|
// Assign title text
|
||||||
titleView?.text = entry.getVisualTitle()
|
val entryTitle = entry.getVisualTitle()
|
||||||
|
collapsingToolbarLayout?.title = entryTitle
|
||||||
|
toolbar?.title = entryTitle
|
||||||
|
|
||||||
// Assign basic fields
|
// Assign basic fields
|
||||||
entryContentsView?.assignUserName(entry.username)
|
entryContentsView?.assignUserName(entry.username)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ open class EntryCustomField(context: Context,
|
|||||||
init {
|
init {
|
||||||
|
|
||||||
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
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)
|
labelView = findViewById(R.id.title)
|
||||||
valueView = findViewById(R.id.value)
|
valueView = findViewById(R.id.value)
|
||||||
|
|||||||
@@ -17,65 +17,74 @@
|
|||||||
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 KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.design.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:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.design.widget.AppBarLayout
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:id="@+id/app_bar"
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:title="@string/app_name"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="@dimen/toolbar_parallax_height"
|
||||||
android:background="?attr/colorPrimary"
|
android:fitsSystemWindows="true">
|
||||||
app:theme="?attr/toolbarAppearance"
|
|
||||||
app:popupTheme="?attr/toolbarPopupAppearance"
|
|
||||||
android:elevation="4dp"
|
|
||||||
tools:targetApi="lollipop"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/title_block"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:translationZ="10dp"
|
|
||||||
style="@style/KeepassDXStyle.TextAppearance.Default">
|
|
||||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/entry_icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="end|center_vertical"
|
|
||||||
android:scaleType="fitXY"/>
|
|
||||||
<android.support.v7.widget.AppCompatTextView android:id="@+id/entry_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:gravity="start|center_vertical"
|
|
||||||
android:layout_marginLeft="10dp"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_gravity="start|center_vertical"
|
|
||||||
style="@style/KeepassDXStyle.TextAppearance.Title.TextOnPrimary" />
|
|
||||||
</LinearLayout>
|
|
||||||
</android.support.v7.widget.Toolbar>
|
|
||||||
|
|
||||||
<ScrollView
|
<android.support.design.widget.CollapsingToolbarLayout
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/toolbar_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="?attr/colorPrimary"
|
||||||
|
app:expandedTitleMarginStart="32dp"
|
||||||
|
app:expandedTitleGravity="center_horizontal|bottom"
|
||||||
|
app:expandedTitleMarginEnd="32dp"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/title_block"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_collapseMode="parallax"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/background_repeat"
|
||||||
|
android:gravity="center"
|
||||||
|
style="@style/KeepassDXStyle.TextAppearance.Default">
|
||||||
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
android:id="@+id/entry_icon"
|
||||||
|
android:layout_width="64dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginBottom="28dp"
|
||||||
|
android:scaleType="fitXY"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
app:theme="?attr/toolbarAppearance"
|
||||||
|
app:popupTheme="?attr/toolbarPopupAppearance"
|
||||||
|
app:layout_collapseMode="pin"
|
||||||
|
tools:targetApi="lollipop">
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
</android.support.design.widget.CollapsingToolbarLayout>
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<android.support.v4.widget.NestedScrollView
|
||||||
android:id="@+id/entry_scroll"
|
android:id="@+id/entry_scroll"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true"
|
|
||||||
android:scrollbarStyle="insideOverlay"
|
android:scrollbarStyle="insideOverlay"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintWidth_percent="@dimen/content_percent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<com.kunzisoft.keepass.view.EntryContentsView
|
<com.kunzisoft.keepass.view.EntryContentsView
|
||||||
android:id="@+id/entry_contents"
|
android:id="@+id/entry_contents"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"/>
|
android:layout_width="match_parent"/>
|
||||||
|
|
||||||
</ScrollView>
|
</android.support.v4.widget.NestedScrollView>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
||||||
@@ -9,5 +9,7 @@
|
|||||||
|
|
||||||
<dimen name="content_percent">1</dimen>
|
<dimen name="content_percent">1</dimen>
|
||||||
|
|
||||||
|
<dimen name="toolbar_parallax_height">220dp</dimen>
|
||||||
|
|
||||||
<integer name="animation_duration">320</integer>
|
<integer name="animation_duration">320</integer>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -76,6 +76,9 @@
|
|||||||
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Light.Toolbar.Popup</item>
|
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Light.Toolbar.Popup</item>
|
||||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
||||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
||||||
|
<!-- CollapsingToolbarLayout -->
|
||||||
|
<item name="expandedTitleTextAppearance">@style/KeepassDXStyle.Expanded.Title</item>
|
||||||
|
<item name="collapsedTitleTextAppearance">@style/KeepassDXStyle.Collapsed.Title</item>
|
||||||
|
|
||||||
<!-- White FAB -->
|
<!-- White FAB -->
|
||||||
<item name="whiteFab">@style/KeepassDXStyle.Fab.White</item>
|
<item name="whiteFab">@style/KeepassDXStyle.Fab.White</item>
|
||||||
@@ -133,6 +136,9 @@
|
|||||||
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Night.Toolbar.Popup</item>
|
<item name="toolbarPopupAppearance">@style/KeepassDXStyle.Night.Toolbar.Popup</item>
|
||||||
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
<item name="toolbarBottomAppearance">@style/KeepassDXStyle.Toolbar.Night</item>
|
||||||
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
<item name="actionModeStyle">@style/KeepassDXStyle.ActionMode</item>
|
||||||
|
<!-- CollapsingToolbarLayout -->
|
||||||
|
<item name="expandedTitleTextAppearance">@style/KeepassDXStyle.Expanded.Title</item>
|
||||||
|
<item name="collapsedTitleTextAppearance">@style/KeepassDXStyle.Collapsed.Title</item>
|
||||||
|
|
||||||
<!-- White FAB -->
|
<!-- White FAB -->
|
||||||
<item name="whiteFab">@style/KeepassDXStyle.Fab.White</item>
|
<item name="whiteFab">@style/KeepassDXStyle.Fab.White</item>
|
||||||
@@ -183,6 +189,15 @@
|
|||||||
<item name="background">@color/green_dark</item>
|
<item name="background">@color/green_dark</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- CollapsingToolbarLayout -->
|
||||||
|
<style name="KeepassDXStyle.Expanded.Title" parent="KeepassDXStyle.TextAppearance.Title.TextOnPrimary">
|
||||||
|
<item name="android:textSize">28sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="KeepassDXStyle.Collapsed.Title" parent="KeepassDXStyle.TextAppearance.Title.TextOnPrimary">
|
||||||
|
<item name="android:textSize">18sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- Dialog -->
|
<!-- Dialog -->
|
||||||
<style name="KeepassDXStyle.Night.Dialog" parent="Theme.AppCompat.Dialog.Alert">
|
<style name="KeepassDXStyle.Night.Dialog" parent="Theme.AppCompat.Dialog.Alert">
|
||||||
<item name="colorAccent">@color/orange</item>
|
<item name="colorAccent">@color/orange</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user