Only reveal fab once title is entered

pull/996/head
Alex Baker 5 years ago
parent aa04bafcb8
commit 8e9fe10705

@ -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);

@ -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();
}
}
}
Loading…
Cancel
Save