Simplify approach for animating advanced entry settings

This slightly simplifies the approach we use to animate the advanced
entry settings into view, by defaulting its alpha to 0 and setting it to
VISIBLE before the animation starts. That way, we're not dependent on
"animation ended" callbacks that apparently don't fire in all cases.

The XML diff looks a bit scary, but it basically just removes a
wrapping ``RelativeLayout`` that appears to not be necessary.
This commit is contained in:
Alexander Bakker 2024-07-19 20:57:23 +02:00
parent d1695aa712
commit 94d1cc6608
2 changed files with 116 additions and 126 deletions

View file

@ -127,7 +127,7 @@ public class EditEntryActivity extends AegisActivity {
private KropView _kropView;
private RelativeLayout _advancedSettingsHeader;
private RelativeLayout _advancedSettings;
private LinearLayout _advancedSettingsLayout;
private BackPressHandler _backPressHandler;
private IconBackPressHandler _iconBackPressHandler;
@ -241,7 +241,7 @@ public class EditEntryActivity extends AegisActivity {
_advancedSettingsHeader = findViewById(R.id.accordian_header);
_advancedSettingsHeader.setOnClickListener(v -> openAdvancedSettings());
_advancedSettings = findViewById(R.id.expandableLayout);
_advancedSettingsLayout = findViewById(R.id.layout_advanced);
// fill the fields with values if possible
GlideHelper.loadEntryIcon(Glide.with(this), _origEntry, _iconView);
@ -411,17 +411,13 @@ public class EditEntryActivity extends AegisActivity {
fadeOut.setDuration((long) (220 * AnimationsHelper.Scale.ANIMATOR.getValue(this)));
_advancedSettingsHeader.startAnimation(fadeOut);
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new AccelerateInterpolator());
fadeIn.setDuration((long) (250 * AnimationsHelper.Scale.ANIMATOR.getValue(this)));
fadeOut.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettingsHeader.setVisibility(View.GONE);
_advancedSettings.startAnimation(fadeIn);
}));
fadeIn.setAnimationListener(new SimpleAnimationEndListener((a) -> {
_advancedSettings.setVisibility(View.VISIBLE);
_advancedSettingsLayout.setVisibility(View.VISIBLE);
_advancedSettingsLayout.animate()
.setInterpolator(new AccelerateInterpolator())
.setDuration((long) (250 * AnimationsHelper.Scale.ANIMATOR.getValue(this)))
.alpha(1);
}));
}

View file

@ -251,16 +251,13 @@
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/expandableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<LinearLayout
android:id="@+id/layout_advanced"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:alpha="0"
android:layout_marginHorizontal="10dp">
<LinearLayout
android:id="@+id/layout_type_algo"
@ -392,9 +389,6 @@
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>