From a7f401cb14b2e54a2f36781a081e064f1ca19ae0 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Thu, 6 Jun 2019 18:49:28 +0200 Subject: [PATCH] remove fab library --- Habitica/build.gradle | 4 +- Habitica/res/layout/floating_menu_tasks.xml | 88 ----------- Habitica/res/layout/widget_add_task.xml | 6 +- .../res/layout/widget_configure_add_task.xml | 28 ++-- .../ui/fragments/tasks/TasksFragment.kt | 3 - .../helpers/FloatingActionMenuBehavior.java | 146 ------------------ .../HabiticaBottomNavigationView.kt | 10 ++ fastlane/changelog.txt | 1 - 8 files changed, 30 insertions(+), 256 deletions(-) delete mode 100644 Habitica/res/layout/floating_menu_tasks.xml delete mode 100644 Habitica/src/main/java/com/habitrpg/android/habitica/ui/helpers/FloatingActionMenuBehavior.java diff --git a/Habitica/build.gradle b/Habitica/build.gradle index 5c6057a92..d8c043992 100644 --- a/Habitica/build.gradle +++ b/Habitica/build.gradle @@ -75,8 +75,6 @@ dependencies { implementation('com.mikepenz:aboutlibraries:5.9.4@aar') { transitive = true } - // a better fab alternative - implementation 'com.github.clans:fab:1.6.4' //Eventbus implementation 'org.greenrobot:eventbus:3.1.1' // IAP Handling / Verification @@ -150,7 +148,7 @@ android { buildConfigField "String", "TESTING_LEVEL", "\"production\"" multiDexEnabled true - versionCode 2146 + versionCode 2149 versionName "1.10" } diff --git a/Habitica/res/layout/floating_menu_tasks.xml b/Habitica/res/layout/floating_menu_tasks.xml deleted file mode 100644 index 9eeecb7ee..000000000 --- a/Habitica/res/layout/floating_menu_tasks.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - diff --git a/Habitica/res/layout/widget_add_task.xml b/Habitica/res/layout/widget_add_task.xml index 677b10b35..b3488eaeb 100644 --- a/Habitica/res/layout/widget_add_task.xml +++ b/Habitica/res/layout/widget_add_task.xml @@ -5,9 +5,9 @@ android:gravity="center_horizontal"> ? = WeakHashMap() private var displayingTaskForm: Boolean = false @@ -310,7 +308,6 @@ class TasksFragment : BaseMainFragment() { } TASK_UPDATED_RESULT -> this.displayingTaskForm = false } - floatingMenu?.close(true) } private fun onTaskCreatedResult(resultCode: Int, data: Intent?) { diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/helpers/FloatingActionMenuBehavior.java b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/helpers/FloatingActionMenuBehavior.java deleted file mode 100644 index 97998db3d..000000000 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/helpers/FloatingActionMenuBehavior.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.habitrpg.android.habitica.ui.helpers; - -// https://gist.github.com/lodlock/e3cd12130bad70a098db - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.Nullable; -import androidx.coordinatorlayout.widget.CoordinatorLayout; -import androidx.core.view.ViewCompat; - -import com.github.clans.fab.FloatingActionMenu; -import com.google.android.material.snackbar.Snackbar; -import com.habitrpg.android.habitica.R; - -import java.util.List; - -public class FloatingActionMenuBehavior extends CoordinatorLayout.Behavior { - - private final int FAB_ANIMATION_DURATION = 500; - - private float mTranslationY; - - private Context context; - private boolean isAnimating; - private boolean isOffScreen; - @Nullable - private FloatingActionMenu fab; - - public FloatingActionMenuBehavior(Context context, AttributeSet attrs) { - super(); - this.context = context; - isAnimating = false; - isOffScreen = false; - } - - @Override - public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) { - return dependency instanceof Snackbar.SnackbarLayout; - } - - @Override - public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { - if (child instanceof FloatingActionMenu && dependency instanceof Snackbar.SnackbarLayout) { - this.updateTranslation(parent, child, dependency); - } - - return false; - } - - private void updateTranslation(CoordinatorLayout parent, View child, View dependency) { - float translationY = this.getTranslationY(parent, child); - if (translationY != this.mTranslationY) { - ViewCompat.animate(child) - .cancel(); - if (Math.abs(translationY - this.mTranslationY) == (float) dependency.getHeight()) { - ViewCompat.animate(child) - .translationY(translationY) - .setListener(null); - } else { - child.setTranslationY(translationY); - } - - this.mTranslationY = translationY; - } - - } - - private float getTranslationY(CoordinatorLayout parent, View child) { - float minOffset = 0.0F; - List dependencies = parent.getDependencies(child); - int i = 0; - - for (int z = dependencies.size(); i < z; ++i) { - View view = (View) dependencies.get(i); - if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) { - minOffset = Math.min(minOffset, view.getTranslationY() - (float) view.getHeight()); - } - } - - return minOffset; - } - - @Override - public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { - ViewGroup fabContainer = child.findViewById(R.id.snackbar_container); - if (fabContainer.getChildCount() > 0) { - if (fabContainer.getChildAt(0).getClass().equals(FloatingActionMenu.class)) { - fab = (FloatingActionMenu) fabContainer.getChildAt(0); - } - } - return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || - super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes); - } - - @Override - public void onNestedScroll(CoordinatorLayout coordinatorLayout, final View child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { - super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); - - if (fab == null) { - return; - } - - /* - Logic: - - If we're scrolling downwards or we're at the bottom of the screen - AND if we're not animating and not on screen > HIDE - */ - if ((dyConsumed > 20 || (dyConsumed == 0 && dyUnconsumed > 0)) && !isAnimating && !isOffScreen) { - isAnimating = true; - slideFabOffScreen(fab); - resetAnimatingStatusWithDelay(fab); - isOffScreen = true; - - /* - Logic: - - If we're not on screen - AND we're scrolling upwards and not animating OR we're at the top of the screen > SHOW - */ - } else if (isOffScreen && ((dyConsumed < -10 && !isAnimating) || dyUnconsumed < 0)) { - isAnimating = true; - slideFabOnScreen(fab); - resetAnimatingStatusWithDelay(fab); - isOffScreen = false; - } - } - - private void resetAnimatingStatusWithDelay(final FloatingActionMenu child) { - child.postDelayed(() -> { - isAnimating = false; - if (isOffScreen && fab != null) { - child.hideMenu(false); - } - }, FAB_ANIMATION_DURATION); - } - - private void slideFabOffScreen(FloatingActionMenu view) { - view.hideMenu(true); - } - - private void slideFabOnScreen(FloatingActionMenu view) { - view.showMenu(true); - } -} \ No newline at end of file diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/navigation/HabiticaBottomNavigationView.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/navigation/HabiticaBottomNavigationView.kt index 93a374a52..7f9110168 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/navigation/HabiticaBottomNavigationView.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/navigation/HabiticaBottomNavigationView.kt @@ -2,6 +2,9 @@ package com.habitrpg.android.habitica.ui.views.navigation import android.content.Context import android.util.AttributeSet +import android.view.animation.Animation +import android.view.animation.LinearInterpolator +import android.view.animation.RotateAnimation import android.widget.ImageButton import android.widget.LinearLayout import android.widget.RelativeLayout @@ -81,6 +84,13 @@ class HabiticaBottomNavigationView @JvmOverloads constructor( private fun showSubmenu() { isShowingSubmenu = true + + val rotate = RotateAnimation(0f, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f) + rotate.duration = 300 + rotate.interpolator = LinearInterpolator() + rotate.fillAfter = true + addButton.startAnimation(rotate) + var pos = 4 submenuWrapper.removeAllViews() for (taskType in listOf(Task.TYPE_HABIT, Task.TYPE_DAILY, Task.TYPE_TODO, Task.TYPE_REWARD)) { diff --git a/fastlane/changelog.txt b/fastlane/changelog.txt index b668b4e30..ac4be0893 100644 --- a/fastlane/changelog.txt +++ b/fastlane/changelog.txt @@ -1,5 +1,4 @@ This beta update stores the apps authentication credentials more securely. The app should automatically update to the new storage method without you having to log in again. If you experience any issues with this, please report them through the in-app-reporting option or to admin@habitica.com We updated the app with a new modal design - Be sure to download this update now for a better Habitica experience!