diff --git a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java index 26db7fa08..292c4cfc1 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java +++ b/app/src/main/java/com/todoroo/astrid/activity/MainActivity.java @@ -421,7 +421,7 @@ public class MainActivity extends InjectingAppCompatActivity } else { taskEditFragment.discardButtonClick(); } - } else { + } else if (!getTaskListFragment().collapseSearchView()) { finish(); } } diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 240b7a5a3..b8003ae74 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -149,6 +149,7 @@ public final class TaskListFragment extends InjectingFragment private PublishSubject searchSubject = PublishSubject.create(); private Disposable searchDisposable; protected CompositeDisposable disposables; + private MenuItem search; /* * ====================================================================== @@ -282,7 +283,7 @@ public final class TaskListFragment extends InjectingFragment MenuItem voice = menu.findItem(R.id.menu_voice_add); voice.setVisible(device.voiceInputAvailable()); - MenuItem search = + search = menu.findItem(R.id.menu_search) .setOnActionExpandListener( new MenuItem.OnActionExpandListener() { @@ -505,6 +506,10 @@ public final class TaskListFragment extends InjectingFragment } } + boolean collapseSearchView() { + return search.collapseActionView(); + } + /** * Called by the RefreshReceiver when the task list receives a refresh broadcast. Subclasses * should override this.