diff --git a/.gitignore b/.gitignore
index f9da0a919..75b262fb7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,11 +59,10 @@ captures/
# IDEA/Android Studio Ignore exceptions
!/.idea/vcs.xml
-!/.idea/fileTemplates/
!/.idea/inspectionProfiles/
!/.idea/scopes/
!/.idea/codeStyles/
!/.idea/encodings.xml
!/.idea/copyright/
-!/.idea/compiler.xml
+!/.idea/kotlinCodeInsightSettings.xml
app/jacoco.exec
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 4ce8cb6cb..9ab52cb68 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -39,7 +39,6 @@
-
diff --git a/.idea/kotlinCodeInsightSettings.xml b/.idea/kotlinCodeInsightSettings.xml
new file mode 100644
index 000000000..71e404da5
--- /dev/null
+++ b/.idea/kotlinCodeInsightSettings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.java b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.java
deleted file mode 100644
index acb18c7e6..000000000
--- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Kiwix Android
- * Copyright (c) 2019 Kiwix
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-package org.kiwix.kiwixmobile.core.utils;
-
-import android.animation.Animator;
-import android.animation.ValueAnimator;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.LinearInterpolator;
-import android.view.animation.RotateAnimation;
-import androidx.annotation.NonNull;
-import androidx.core.content.ContextCompat;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import org.kiwix.kiwixmobile.core.R;
-
-public class AnimationUtils {
- public static void expand(final View v) {
- v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- final int targetHeight = v.getMeasuredHeight();
-
- // Older versions of android (pre API 21) cancel animations for views with a height of 0.
- v.getLayoutParams().height = 1;
- v.setVisibility(View.VISIBLE);
-
- ValueAnimator va = ValueAnimator.ofInt(1, targetHeight);
- va.addUpdateListener(animation -> {
- v.getLayoutParams().height = (Integer) animation.getAnimatedValue();
- v.requestLayout();
- });
- va.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationEnd(Animator animation) {
- v.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
- }
-
- @Override public void onAnimationStart(Animator animation) {}
- @Override public void onAnimationCancel(Animator animation) {}
- @Override public void onAnimationRepeat(Animator animation) {}
- });
- va.setDuration(100);
- va.setInterpolator(new LinearInterpolator());
- va.start();
- }
-
- public static void collapse(final @NonNull View v) {
- final int initialHeight = v.getMeasuredHeight();
-
- ValueAnimator va = ValueAnimator.ofInt(initialHeight, 0);
- va.addUpdateListener(animation -> {
- v.getLayoutParams().height = (Integer) animation.getAnimatedValue();
- v.requestLayout();
- });
- va.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationEnd(Animator animation) {
- v.setVisibility(View.GONE);
- }
-
- @Override public void onAnimationStart(Animator animation) {}
- @Override public void onAnimationCancel(Animator animation) {}
- @Override public void onAnimationRepeat(Animator animation) {}
- });
- va.setDuration(100);
- va.setInterpolator(new LinearInterpolator());
- va.start();
- }
-
-
- //rotate animation for closeAllTabs FAB
- public static void rotate(@NonNull FloatingActionButton v) {
- RotateAnimation wheelRotation =
- new RotateAnimation(0.0f, 360f, v.getWidth() / 2.0f, v.getHeight() / 2.0f);
- wheelRotation.setDuration(200);
- wheelRotation.setRepeatCount(0);
- wheelRotation.setInterpolator(v.getContext(), android.R.interpolator.cycle);
- v.startAnimation(wheelRotation);
- wheelRotation.setAnimationListener(new Animation.AnimationListener() {
-
- public void onAnimationEnd(Animation animation) {
- v.setImageDrawable(
- ContextCompat.getDrawable(v.getContext(), R.drawable.ic_done_white_24dp));
- }
-
- public void onAnimationRepeat(Animation animation) {
- }
-
- public void onAnimationStart(Animation animation) {
- v.setImageDrawable(
- ContextCompat.getDrawable(v.getContext(), R.drawable.ic_close_black_24dp));
- }
- });
- }
-}
diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.kt
new file mode 100644
index 000000000..cfd70c31c
--- /dev/null
+++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/AnimationUtils.kt
@@ -0,0 +1,71 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2019 Kiwix
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package org.kiwix.kiwixmobile.core.utils
+
+import android.animation.ValueAnimator
+import android.view.View
+import android.view.ViewGroup.LayoutParams.MATCH_PARENT
+import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
+import android.view.animation.LinearInterpolator
+import androidx.core.animation.addListener
+import com.google.android.material.floatingactionbutton.FloatingActionButton
+import org.kiwix.kiwixmobile.core.R
+import org.kiwix.kiwixmobile.core.extensions.setImageDrawableCompat
+
+private const val HEIGHT_ANIM_DURATION = 100L
+private const val ROTATE_ANIM_DURATION = 200L
+private const val FULL_ROTATION = 360.0f
+
+object AnimationUtils {
+ @JvmStatic fun View.expand() {
+ measure(MATCH_PARENT, WRAP_CONTENT)
+
+ // Older versions of android (pre API 21) cancel animations for views with a height of 0.
+ layoutParams.height = 1
+ visibility = View.VISIBLE
+
+ animateHeight(1, measuredHeight) {
+ layoutParams.height = WRAP_CONTENT
+ }
+ }
+
+ @JvmStatic fun View.collapse() {
+ animateHeight(measuredHeight, 0) { visibility = View.GONE }
+ }
+
+ private fun View.animateHeight(start: Int, end: Int, onEndAction: () -> Unit) {
+ ValueAnimator.ofInt(start, end).apply {
+ addUpdateListener {
+ layoutParams.height = it.animatedValue as Int
+ requestLayout()
+ }
+ addListener(onEnd = { onEndAction.invoke() })
+ duration = HEIGHT_ANIM_DURATION
+ interpolator = LinearInterpolator()
+ }.start()
+ }
+
+ @JvmStatic fun FloatingActionButton.rotate() {
+ animate().apply {
+ withStartAction { setImageDrawableCompat(R.drawable.ic_close_black_24dp) }
+ withEndAction { setImageDrawableCompat(R.drawable.ic_done_white_24dp) }
+ rotationBy(FULL_ROTATION)
+ duration = ROTATE_ANIM_DURATION
+ }.start()
+ }
+}