mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Change add node button view
This commit is contained in:
@@ -465,7 +465,6 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
|
||||
private fun retrieveCurrentGroup(intent: Intent, savedInstanceState: Bundle?): Group? {
|
||||
|
||||
// Force read only if the database is like that
|
||||
mReadOnly = mDatabase?.isReadOnly == true || mReadOnly
|
||||
|
||||
@@ -542,8 +541,13 @@ class GroupActivity : LockingActivity(),
|
||||
// Assign number of children
|
||||
refreshNumberOfChildren()
|
||||
|
||||
// Show button if allowed
|
||||
// Hide button
|
||||
initAddButton()
|
||||
}
|
||||
|
||||
private fun initAddButton() {
|
||||
addNodeButtonView?.apply {
|
||||
closeButtonIfOpen()
|
||||
// To enable add button
|
||||
val addGroupEnabled = !mReadOnly && mCurrentGroup?.isVirtual != true
|
||||
var addEntryEnabled = !mReadOnly && mCurrentGroup?.isVirtual != true
|
||||
@@ -553,7 +557,6 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
enableAddGroup(addGroupEnabled)
|
||||
enableAddEntry(addEntryEnabled)
|
||||
|
||||
if (mCurrentGroup?.isVirtual == true)
|
||||
hideButton()
|
||||
else if (actionNodeMode == null)
|
||||
|
||||
@@ -42,8 +42,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
: RelativeLayout(context, attrs, defStyle) {
|
||||
|
||||
var addButtonView: FloatingActionButton? = null
|
||||
private var addEntryView: View? = null
|
||||
private var addGroupView: View? = null
|
||||
private lateinit var addEntryView: View
|
||||
private lateinit var addGroupView: View
|
||||
|
||||
private var addEntryEnable: Boolean = false
|
||||
private var addGroupEnable: Boolean = false
|
||||
@@ -82,8 +82,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
animationDuration = 300L
|
||||
|
||||
viewButtonMenuAnimation = AddButtonAnimation(addButtonView)
|
||||
viewMenuAnimationAddEntry = ViewMenuAnimation(addEntryView, 0L, 150L)
|
||||
viewMenuAnimationAddGroup = ViewMenuAnimation(addGroupView, 150L, 0L)
|
||||
viewMenuAnimationAddEntry = ViewMenuAnimation(addEntryView, 150L, 0L)
|
||||
viewMenuAnimationAddGroup = ViewMenuAnimation(addGroupView, 0L, 150L)
|
||||
|
||||
allowAction = true
|
||||
state = State.CLOSE
|
||||
@@ -111,8 +111,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
val viewEntryRect = Rect()
|
||||
val viewGroupRect = Rect()
|
||||
addButtonView?.getGlobalVisibleRect(viewButtonRect)
|
||||
addEntryView?.getGlobalVisibleRect(viewEntryRect)
|
||||
addGroupView?.getGlobalVisibleRect(viewGroupRect)
|
||||
addEntryView.getGlobalVisibleRect(viewEntryRect)
|
||||
addGroupView.getGlobalVisibleRect(viewGroupRect)
|
||||
if (!(viewButtonRect.contains(event.rawX.toInt(), event.rawY.toInt())
|
||||
&& viewEntryRect.contains(event.rawX.toInt(), event.rawY.toInt())
|
||||
&& viewGroupRect.contains(event.rawX.toInt(), event.rawY.toInt()))) {
|
||||
@@ -165,8 +165,8 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
*/
|
||||
fun enableAddEntry(enable: Boolean) {
|
||||
this.addEntryEnable = enable
|
||||
if (enable && addEntryView != null && addEntryView!!.visibility != View.VISIBLE)
|
||||
addEntryView!!.visibility = View.INVISIBLE
|
||||
if (enable && addEntryView.visibility != View.VISIBLE)
|
||||
addEntryView.visibility = View.INVISIBLE
|
||||
disableViewIfNoAddAvailable()
|
||||
}
|
||||
|
||||
@@ -176,13 +176,13 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
*/
|
||||
fun enableAddGroup(enable: Boolean) {
|
||||
this.addGroupEnable = enable
|
||||
if (enable && addGroupView != null && addGroupView!!.visibility != View.VISIBLE)
|
||||
addGroupView?.visibility = View.INVISIBLE
|
||||
if (enable && addGroupView.visibility != View.VISIBLE)
|
||||
addGroupView.visibility = View.INVISIBLE
|
||||
disableViewIfNoAddAvailable()
|
||||
}
|
||||
|
||||
private fun disableViewIfNoAddAvailable() {
|
||||
visibility = if (!addEntryEnable || !addGroupEnable) {
|
||||
visibility = if (!addEntryEnable && !addGroupEnable) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
@@ -191,7 +191,7 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
fun setAddGroupClickListener(onClickListener: OnClickListener) {
|
||||
if (addGroupEnable)
|
||||
addGroupView?.setOnClickListener { view ->
|
||||
addGroupView.setOnClickListener { view ->
|
||||
onClickListener.onClick(view)
|
||||
closeButtonIfOpen()
|
||||
}
|
||||
@@ -199,11 +199,11 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
fun setAddEntryClickListener(onClickListener: OnClickListener) {
|
||||
if (addEntryEnable) {
|
||||
addEntryView?.setOnClickListener { view ->
|
||||
addEntryView.setOnClickListener { view ->
|
||||
onClickListener.onClick(view)
|
||||
closeButtonIfOpen()
|
||||
}
|
||||
addEntryView?.setOnClickListener { view ->
|
||||
addEntryView.setOnClickListener { view ->
|
||||
onClickListener.onClick(view)
|
||||
closeButtonIfOpen()
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
override fun onAnimationCancel(view: View) {}
|
||||
|
||||
internal fun startAnimation() {
|
||||
fun startAnimation() {
|
||||
view?.let { view ->
|
||||
if (!isRotate) {
|
||||
ViewCompat.animate(view)
|
||||
@@ -298,7 +298,7 @@ class AddNodeButtonView @JvmOverloads constructor(context: Context,
|
||||
|
||||
override fun onAnimationCancel(view: View) {}
|
||||
|
||||
internal fun startAnimation() {
|
||||
fun startAnimation() {
|
||||
view?.let { view ->
|
||||
if (view.visibility == View.VISIBLE) {
|
||||
// In
|
||||
|
||||
@@ -23,27 +23,14 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_add_white_24dp"
|
||||
android:contentDescription="@string/content_description_add_node"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
app:useCompatPadding="true"
|
||||
app:fabSize="normal"
|
||||
style="@style/KeepassDXStyle.Fab" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/container_add_entry"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/add_button"
|
||||
android:layout_alignEnd="@+id/add_button"
|
||||
android:layout_alignRight="@+id/add_button"
|
||||
android:layout_above="@+id/container_add_group"
|
||||
android:layout_alignEnd="@+id/container_add_group"
|
||||
android:layout_alignRight="@+id/container_add_group"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:visibility="gone">
|
||||
@@ -73,9 +60,9 @@
|
||||
android:id="@+id/container_add_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/container_add_entry"
|
||||
android:layout_alignEnd="@+id/container_add_entry"
|
||||
android:layout_alignRight="@+id/container_add_entry"
|
||||
android:layout_above="@+id/add_button"
|
||||
android:layout_alignEnd="@+id/add_button"
|
||||
android:layout_alignRight="@+id/add_button"
|
||||
android:layout_marginBottom="-12dp"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:visibility="gone">
|
||||
@@ -99,4 +86,17 @@
|
||||
app:useCompatPadding="true" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/add_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_add_white_24dp"
|
||||
android:contentDescription="@string/content_description_add_node"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
app:useCompatPadding="true"
|
||||
app:fabSize="normal"
|
||||
style="@style/KeepassDXStyle.Fab" />
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user