Skip to content

Commit d3e0eca

Browse files
committed
Add animations for horizontal rule format button
1 parent 7954e15 commit d3e0eca

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
4040
private lateinit var buttonMore: RippleToggleButton
4141
// TODO: Uncomment when Page Break is to be added back as a feature.
4242
// private lateinit var buttonPage: RippleToggleButton
43-
// TODO: Uncomment once Horizontal Rule format button is merged.
44-
// private lateinit var buttonRule: RippleToggleButton
43+
private lateinit var buttonRule: RippleToggleButton
4544
private lateinit var buttonStrikethrough: RippleToggleButton
4645
private lateinit var buttonUnderline: RippleToggleButton
4746
private lateinit var buttonScaleInHtml: Animation
@@ -53,9 +52,8 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
5352
// TODO: Uncomment when Page Break is to be added back as a feature.
5453
// private lateinit var buttonScaleInPage: Animation
5554
// private lateinit var buttonScaleOutPage: Animation
56-
// TODO: Uncomment once Horizontal Rule format button is merged.
57-
// private lateinit var buttonScaleInRule: Animation
58-
// private lateinit var buttonScaleOutRule: Animation
55+
private lateinit var buttonScaleInRule: Animation
56+
private lateinit var buttonScaleOutRule: Animation
5957
private lateinit var buttonScaleInStrikethrough: Animation
6058
private lateinit var buttonScaleOutStrikethrough: Animation
6159
private lateinit var buttonScaleInUnderline: Animation
@@ -565,7 +563,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
565563
// TODO: Use programmatic or better approach to button animations.
566564

567565
buttonScaleInHtml = AnimationUtils.loadAnimation(context, R.anim.scale_in)
568-
buttonScaleInHtml.startOffset = DELAY_ANIM_IN_BUTTON_4
566+
buttonScaleInHtml.startOffset = DELAY_ANIM_IN_BUTTON_5
569567
buttonScaleInHtml.setAnimationListener(
570568
object : Animation.AnimationListener {
571569
override fun onAnimationEnd(animation: Animation) {
@@ -626,8 +624,39 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
626624
}
627625
)
628626

627+
buttonScaleInRule = AnimationUtils.loadAnimation(context, R.anim.scale_in)
628+
buttonScaleInRule.startOffset = DELAY_ANIM_IN_BUTTON_3
629+
buttonScaleInRule.setAnimationListener(
630+
object : Animation.AnimationListener {
631+
override fun onAnimationEnd(animation: Animation) {
632+
}
633+
634+
override fun onAnimationRepeat(animation: Animation) {
635+
}
636+
637+
override fun onAnimationStart(animation: Animation) {
638+
buttonRule.visibility = View.VISIBLE
639+
}
640+
}
641+
)
642+
643+
buttonScaleOutRule = AnimationUtils.loadAnimation(context, R.anim.scale_out)
644+
buttonScaleOutRule.setAnimationListener(
645+
object : Animation.AnimationListener {
646+
override fun onAnimationEnd(animation: Animation) {
647+
buttonRule.visibility = View.GONE
648+
}
649+
650+
override fun onAnimationRepeat(animation: Animation) {
651+
}
652+
653+
override fun onAnimationStart(animation: Animation) {
654+
}
655+
}
656+
)
657+
629658
buttonScaleInMore = AnimationUtils.loadAnimation(context, R.anim.scale_in)
630-
buttonScaleInMore.startOffset = DELAY_ANIM_IN_BUTTON_3
659+
buttonScaleInMore.startOffset = DELAY_ANIM_IN_BUTTON_4
631660
buttonScaleInMore.setAnimationListener(
632661
object : Animation.AnimationListener {
633662
override fun onAnimationEnd(animation: Animation) {
@@ -734,6 +763,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
734763
buttonLink.startAnimation(buttonScaleOutLink)
735764
buttonUnderline.startAnimation(buttonScaleOutUnderline)
736765
buttonStrikethrough.startAnimation(buttonScaleOutStrikethrough)
766+
buttonRule.startAnimation(buttonScaleOutRule)
737767
buttonMore.startAnimation(buttonScaleOutMore)
738768
buttonHtml.startAnimation(buttonScaleOutHtml)
739769
}
@@ -755,6 +785,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
755785
buttonLink.startAnimation(buttonScaleInLink)
756786
buttonUnderline.startAnimation(buttonScaleInUnderline)
757787
buttonStrikethrough.startAnimation(buttonScaleInStrikethrough)
788+
buttonRule.startAnimation(buttonScaleInRule)
758789
buttonMore.startAnimation(buttonScaleInMore)
759790
buttonHtml.startAnimation(buttonScaleInHtml)
760791
}
@@ -766,8 +797,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
766797
buttonLink = findViewById(R.id.format_bar_button_link) as RippleToggleButton
767798
buttonUnderline = findViewById(R.id.format_bar_button_underline) as RippleToggleButton
768799
buttonStrikethrough = findViewById(R.id.format_bar_button_strikethrough) as RippleToggleButton
769-
// TODO: Uncomment once Horizontal Rule format button is merged.
770-
// buttonRule = findViewById(R.id.format_bar_button_horizontal_rule) as RippleToggleButton
800+
buttonRule = findViewById(R.id.format_bar_button_horizontal_rule) as RippleToggleButton
771801
buttonMore = findViewById(R.id.format_bar_button_more) as RippleToggleButton
772802
// TODO: Uncomment when Page Break is to be added back as a feature.
773803
// buttonPage = findViewById(R.id.format_bar_button_page) as RippleToggleButton
@@ -819,8 +849,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
819849
buttonLink.visibility = View.GONE
820850
buttonUnderline.visibility = View.GONE
821851
buttonStrikethrough.visibility = View.GONE
822-
// TODO: Uncomment once Horizontal Rule format button is merged.
823-
// buttonRule.visibility = View.GONE
852+
buttonRule.visibility = View.GONE
824853
buttonMore.visibility = View.GONE
825854
// TODO: Uncomment when Page Break is to be added back as a feature.
826855
// buttonPage.visibility = View.GONE
@@ -833,8 +862,7 @@ class AztecToolbar : FrameLayout, OnMenuItemClickListener {
833862
buttonLink.visibility = View.VISIBLE
834863
buttonUnderline.visibility = View.VISIBLE
835864
buttonStrikethrough.visibility = View.VISIBLE
836-
// TODO: Uncomment once Horizontal Rule format button is merged.
837-
// buttonRule.visibility = View.VISIBLE
865+
buttonRule.visibility = View.VISIBLE
838866
buttonMore.visibility = View.VISIBLE
839867
// TODO: Uncomment when Page Break is to be added back as a feature.
840868
// buttonPage.visibility = View.VISIBLE

0 commit comments

Comments
 (0)