From 8e9fe10705940d1e0e035f443f2634da7333b19a Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 30 Mar 2020 12:47:50 -0500 Subject: [PATCH] Only reveal fab once title is entered --- .../astrid/activity/TaskEditFragment.java | 16 ++++++---- .../main/java/org/tasks/ui/AnimationUtil.java | 29 +++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/org/tasks/ui/AnimationUtil.java diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index 8f734f628..4421e0b23 100755 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -65,6 +65,7 @@ import org.tasks.injection.InjectingFragment; import org.tasks.notifications.NotificationManager; import org.tasks.preferences.Preferences; import org.tasks.themes.ThemeColor; +import org.tasks.ui.AnimationUtil; import org.tasks.ui.SubtaskControlSet; import org.tasks.ui.TaskEditControlFragment; @@ -199,6 +200,9 @@ public final class TaskEditFragment extends InjectingFragment if (verticalOffset == 0) { title.setVisibility(View.VISIBLE); binding.collapsingtoolbarlayout.setTitleEnabled(false); + if (!getTitle().isEmpty()) { + AnimationUtil.circularReveal(binding.fab); + } } else if (Math.abs(verticalOffset) < appBarLayout.getTotalScrollRange()) { title.setVisibility(View.INVISIBLE); binding.collapsingtoolbarlayout.setTitle(title.getText()); @@ -206,12 +210,14 @@ public final class TaskEditFragment extends InjectingFragment } }); - if (preferences.getBoolean(R.string.p_linkify_task_edit, false)) { - linkify.linkify(title); - } - - if (!model.isNew()) { + if (model.isNew()) { + binding.fab.setVisibility(View.INVISIBLE); + } else { notificationManager.cancel(model.getId()); + + if (preferences.getBoolean(R.string.p_linkify_task_edit, false)) { + linkify.linkify(title); + } } commentsController.initialize(model, binding.comments); diff --git a/app/src/main/java/org/tasks/ui/AnimationUtil.java b/app/src/main/java/org/tasks/ui/AnimationUtil.java new file mode 100644 index 000000000..683f7c625 --- /dev/null +++ b/app/src/main/java/org/tasks/ui/AnimationUtil.java @@ -0,0 +1,29 @@ +package org.tasks.ui; + +import static com.todoroo.andlib.utility.AndroidUtilities.preLollipop; + +import android.animation.Animator; +import android.annotation.SuppressLint; +import android.view.View; +import android.view.ViewAnimationUtils; + +public class AnimationUtil { + + @SuppressLint("NewApi") + public static void circularReveal(View v) { + if (v.getVisibility() == View.VISIBLE) { + return; + } + if (preLollipop()) { + v.setVisibility(View.VISIBLE); + } else { + int cx = v.getMeasuredWidth() / 2; + int cy = v.getMeasuredHeight() / 2; + int finalRadius = Math.max(v.getWidth(), v.getHeight()) / 2; + + Animator anim = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); + v.setVisibility(View.VISIBLE); + anim.start(); + } + } +}