Skip to content

Commit

Permalink
improve: search view animations order
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza417 committed Dec 29, 2024
1 parent 39e423f commit fc9ef8e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 14 deletions.
7 changes: 6 additions & 1 deletion app/src/main/assets/html/changelogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ <h4>Bug Fixes</h4>
<h4>Improvements</h4>

<ul>
<li>APK Parser is now compatible with <b>Dex v41</b> or at least can parse XML files from these
<li>APK Parser is compatible with <b>Dex v41</b> or at least can parse XML files from these
APK
files now.
</li>
<li>Improved <b>Search View</b> animation flow.
<br>
<small>Animation should be played in order and not in
parallel.</small>
</li>
</ul>

<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,20 @@ private void moreButtonState(boolean state) {
ViewUtils.INSTANCE.gone(more, false);
handler.postDelayed(moreButtonRunnable, MORE_BUTTON_DELAY);
} else {
ViewUtils.INSTANCE.gone(settings, true);
ViewUtils.INSTANCE.gone(refresh, true);
ViewUtils.INSTANCE.gone(filter, true);
ViewUtils.INSTANCE.visible(more, true);
ViewUtils.INSTANCE.gone(refresh, true);
ViewUtils.INSTANCE.gone(settings, true, () -> {
/*
* There is an animation glitch here, since I made the animation in sequential order
* the layout transition stops abruptly when more button becomes visible. The best
* workaround is to make the button visible but with 0 alpha and scale, then animate it.
*
* The best way to learn this behavior is to look into LayoutTransition and how it works.
*/
more.setVisibility(View.VISIBLE);
ViewUtils.INSTANCE.visible(more, true);
return Unit.INSTANCE;
});
}
}

Expand Down
35 changes: 35 additions & 0 deletions app/src/main/java/app/simple/inure/util/ViewUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,41 @@ object ViewUtils {
}
}

fun View.gone(animate: Boolean, onEnd: () -> Unit) {
if (animate) {
this.animate()
.scaleY(0F)
.scaleX(0F)
.alpha(0F)
.setInterpolator(AccelerateInterpolator())
.setDuration(this.resources.getInteger(R.integer.animation_duration).toLong())
.setListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {
/* no-op */
}

override fun onAnimationEnd(animation: Animator) {
this@gone.visibility = View.GONE
clearAnimation()
}

override fun onAnimationCancel(animation: Animator) {
/* no-op */
}

override fun onAnimationRepeat(animation: Animator) {
/* no-op */
}
})
.withEndAction {
onEnd()
}
.start()
} else {
this.visibility = View.GONE
}
}

/**
* Makes the view go away
*
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/res/layout/search_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,6 @@
android:layout_marginHorizontal="5dp"
android:layout_marginVertical="@dimen/popup_padding" />

<app.simple.inure.decorations.ripple.DynamicRippleImageButton
android:id="@+id/more_button"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_marginEnd="@dimen/popup_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/menus"
android:src="@drawable/ic_more_horiz"
app:buttonTintType="regular" />

<app.simple.inure.decorations.ripple.DynamicRippleImageButton
android:id="@+id/refresh_button"
android:layout_width="@dimen/button_size"
Expand Down Expand Up @@ -119,4 +109,14 @@
android:visibility="gone"
app:buttonTintType="regular" />

<app.simple.inure.decorations.ripple.DynamicRippleImageButton
android:id="@+id/more_button"
android:layout_width="@dimen/button_size"
android:layout_height="@dimen/button_size"
android:layout_marginEnd="@dimen/popup_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/menus"
android:src="@drawable/ic_more_horiz"
app:buttonTintType="regular" />

</merge>

0 comments on commit fc9ef8e

Please sign in to comment.