mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
feat: Group screen as fit window
This commit is contained in:
@@ -23,6 +23,7 @@ import android.app.SearchManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -35,6 +36,7 @@ import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
@@ -49,6 +51,7 @@ import androidx.appcompat.widget.SearchView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.isVisible
|
||||
@@ -105,6 +108,8 @@ import com.kunzisoft.keepass.view.AddNodeButtonView
|
||||
import com.kunzisoft.keepass.view.NavigationDatabaseView
|
||||
import com.kunzisoft.keepass.view.SearchFiltersView
|
||||
import com.kunzisoft.keepass.view.ToolbarAction
|
||||
import com.kunzisoft.keepass.view.WindowInsetPosition
|
||||
import com.kunzisoft.keepass.view.applyWindowInsets
|
||||
import com.kunzisoft.keepass.view.hideByFading
|
||||
import com.kunzisoft.keepass.view.showActionErrorIfNeeded
|
||||
import com.kunzisoft.keepass.view.updateLockPaddingLeft
|
||||
@@ -121,6 +126,8 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
MainCredentialDialogFragment.AskMainCredentialDialogListener {
|
||||
|
||||
// Views
|
||||
private var header: ViewGroup? = null
|
||||
private var footer: ViewGroup? = null
|
||||
private var drawerLayout: DrawerLayout? = null
|
||||
private var databaseNavView: NavigationDatabaseView? = null
|
||||
private var coordinatorLayout: CoordinatorLayout? = null
|
||||
@@ -267,6 +274,8 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
setContentView(layoutInflater.inflate(R.layout.activity_group, null))
|
||||
|
||||
// Initialize views
|
||||
header = findViewById(R.id.activity_group_header)
|
||||
footer = findViewById(R.id.activity_group_footer)
|
||||
drawerLayout = findViewById(R.id.drawer_layout)
|
||||
databaseNavView = findViewById(R.id.database_nav_view)
|
||||
coordinatorLayout = findViewById(R.id.group_coordinator)
|
||||
@@ -283,6 +292,15 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
lockView = findViewById(R.id.lock_button)
|
||||
loadingView = findViewById(R.id.loading)
|
||||
|
||||
// To apply fit window with transparency
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
this.window.navigationBarColor = Color.TRANSPARENT
|
||||
header?.applyWindowInsets(WindowInsetPosition.TOP)
|
||||
coordinatorLayout?.applyWindowInsets(WindowInsetPosition.LEGIT_TOP)
|
||||
footer?.applyWindowInsets(WindowInsetPosition.BOTTOM)
|
||||
}
|
||||
|
||||
lockView?.setOnClickListener {
|
||||
lockAndExit()
|
||||
}
|
||||
|
||||
@@ -44,7 +44,10 @@ import androidx.appcompat.widget.ActionMenuView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.graphics.drawable.DrawableCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -287,3 +290,40 @@ fun CollapsingToolbarLayout.changeTitleColor(color: Int) {
|
||||
setExpandedTitleColor(color)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a margin to a view to fix the window inset
|
||||
*/
|
||||
fun View.applyWindowInsets(position: WindowInsetPosition = WindowInsetPosition.BOTTOM) {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
|
||||
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
when (position) {
|
||||
WindowInsetPosition.TOP -> {
|
||||
if (view.layoutParams is ViewGroup.MarginLayoutParams) {
|
||||
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = insets.top
|
||||
}
|
||||
}
|
||||
}
|
||||
WindowInsetPosition.LEGIT_TOP -> {
|
||||
if (view.layoutParams is ViewGroup.MarginLayoutParams) {
|
||||
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
WindowInsetPosition.BOTTOM -> {
|
||||
if (view.layoutParams is ViewGroup.MarginLayoutParams) {
|
||||
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = insets.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
}
|
||||
|
||||
enum class WindowInsetPosition {
|
||||
TOP, BOTTOM, LEGIT_TOP
|
||||
}
|
||||
|
||||
4
app/src/main/res/color/surface_selector.xml
Normal file
4
app/src/main/res/color/surface_selector.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:alpha="0.60" android:color="?attr/colorSurface"/>
|
||||
</selector>
|
||||
@@ -144,8 +144,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="180dp"
|
||||
android:background="@drawable/background_item_selection"
|
||||
android:backgroundTint="?attr/colorSurfaceContainerLow"
|
||||
android:layout_marginBottom="@dimen/button_margin"
|
||||
android:backgroundTint="@color/surface_selector"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
app:tabMode="fixed"
|
||||
tools:targetApi="lollipop">
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
app:fabCustomSize="@dimen/button_small_size"
|
||||
app:layout_constraintTop_toTopOf="@+id/entry_edit_bottom_bar"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner"
|
||||
android:layout_marginBottom="6dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
|
||||
@@ -31,62 +31,68 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.kunzisoft.keepass.view.ToolbarSpecial
|
||||
android:id="@+id/special_mode_view"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/activity_group_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:title="@string/app_name"
|
||||
app:layout_constraintTop_toBottomOf="@+id/special_mode_view">
|
||||
<TextView
|
||||
android:id="@+id/database_name"
|
||||
android:layout_width="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
<com.kunzisoft.keepass.view.ToolbarSpecial
|
||||
android:id="@+id/special_mode_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="marquee"
|
||||
tools:text="Database"
|
||||
style="@style/KeepassDXStyle.Title.OnSurface" />
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginLeft="48dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/special_mode_view"
|
||||
app:layout_constraintBottom_toTopOf="@+id/group_coordinator">
|
||||
<ImageView
|
||||
android:id="@+id/database_color"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/background_rounded_square"
|
||||
android:contentDescription="@string/content_description_database_color"/>
|
||||
<ImageView
|
||||
android:id="@+id/database_modified"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_modified_white_12dp"
|
||||
android:contentDescription="@string/save"/>
|
||||
</FrameLayout>
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:title="@string/app_name"
|
||||
app:layout_constraintTop_toBottomOf="@+id/special_mode_view">
|
||||
<TextView
|
||||
android:id="@+id/database_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="marquee"
|
||||
tools:text="Database"
|
||||
style="@style/KeepassDXStyle.Title.OnSurface" />
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="48dp"
|
||||
android:layout_marginLeft="48dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/special_mode_view"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
<ImageView
|
||||
android:id="@+id/database_color"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/background_rounded_square"
|
||||
android:contentDescription="@string/content_description_database_color"/>
|
||||
<ImageView
|
||||
android:id="@+id/database_modified"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_modified_white_12dp"
|
||||
android:contentDescription="@string/save"/>
|
||||
</FrameLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/group_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/toolbar_action"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar">
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/activity_group_header">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar"
|
||||
@@ -124,26 +130,51 @@
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:layout_below="@+id/toolbar" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/activity_group_footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<com.kunzisoft.keepass.view.ToolbarAction
|
||||
android:id="@+id/toolbar_action"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner" />
|
||||
|
||||
<com.kunzisoft.keepass.view.AddNodeButtonView
|
||||
android:id="@+id/add_node_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_anchor="@+id/nodes_list_fragment_container"
|
||||
app:layout_anchorGravity="end|bottom" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.kunzisoft.keepass.view.ToolbarAction
|
||||
android:id="@+id/toolbar_action"
|
||||
<include
|
||||
layout="@layout/view_button_lock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_gravity="start|bottom" />
|
||||
|
||||
<include layout="@layout/view_screenshot_mode_banner" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/error_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner" />
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -151,21 +182,6 @@
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true" />
|
||||
</FrameLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/view_button_lock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner" />
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/error_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"
|
||||
app:layout_constraintBottom_toTopOf="@+id/screenshot_mode_banner"/>
|
||||
|
||||
<include layout="@layout/view_screenshot_mode_banner" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.kunzisoft.keepass.view.NavigationDatabaseView
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
android:scrollbarStyle="insideOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="64dp"
|
||||
android:paddingBottom="120dp"
|
||||
android:clipToPadding="false" />
|
||||
<LinearLayout
|
||||
android:id="@+id/not_found_container"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
app:useCompatPadding="true"
|
||||
android:layout_marginStart="-6dp"
|
||||
android:layout_marginLeft="-6dp"
|
||||
android:layout_marginBottom="-10dp"
|
||||
android:layout_marginBottom="-7dp"
|
||||
android:contentDescription="@string/lock"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="visible"
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
<item name="android:elevation">0dp</item>
|
||||
</style>
|
||||
|
||||
<!-- Action Style -->
|
||||
<style name="KeepassDXStyle.Toolbar.Action" parent="KeepassDXStyle.Toolbar">
|
||||
<item name="android:backgroundTint">@color/surface_selector</item>
|
||||
</style>
|
||||
|
||||
<!-- Preference Theme -->
|
||||
<style name="KeepassDXStyle.Preference.Theme" parent="@style/PreferenceThemeOverlay">
|
||||
<item name="android:tint">?attr/colorOnSurface</item>
|
||||
|
||||
@@ -20,12 +20,10 @@
|
||||
<resources>
|
||||
<style name="KeepassDXStyle.Light.v23" parent="KeepassDXStyle.Light.v21" >
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightStatusBar">true</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Night.v23" parent="KeepassDXStyle.Night.v21" >
|
||||
<item name="android:statusBarColor">?attr/colorSurface</item>
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
<style name="KeepassDXStyle.Light.v27" parent="KeepassDXStyle.Light.v23" >
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightNavigationBar">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
</style>
|
||||
<style name="KeepassDXStyle.Night.v27" parent="KeepassDXStyle.Night.v23" >
|
||||
<item name="android:navigationBarColor">?attr/colorSurface</item>
|
||||
<item name="android:windowLightNavigationBar">false</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user