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