From d2ebe80bf64beb3d958b5c244352d52c318a84d6 Mon Sep 17 00:00:00 2001 From: Mikhail Lopatkin Date: Mon, 6 Apr 2020 18:47:43 +0300 Subject: [PATCH] Bring back titles for Create/Edit filter dialogs Titles got lost during transition to MVP. --- .../filters/MainFilterController.java | 2 +- .../ui/filterdialog/FilterDialogFactory.java | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/org/bitbucket/mlopatkin/android/logviewer/filters/MainFilterController.java b/src/org/bitbucket/mlopatkin/android/logviewer/filters/MainFilterController.java index d1f6e884..780712c1 100644 --- a/src/org/bitbucket/mlopatkin/android/logviewer/filters/MainFilterController.java +++ b/src/org/bitbucket/mlopatkin/android/logviewer/filters/MainFilterController.java @@ -135,7 +135,7 @@ public void addFilter(FilterFromDialog filter) { @Override public void createFilterWithDialog(FilterFromDialog baseData) { - dialogFactory.startEditFilterDialog(baseData) + dialogFactory.startCreateFilterDialogWithInitialData(baseData) .thenAccept(result -> result.ifPresent(this::addFilter)) .exceptionally(Threads::uncaughtException); } diff --git a/src/org/bitbucket/mlopatkin/android/logviewer/ui/filterdialog/FilterDialogFactory.java b/src/org/bitbucket/mlopatkin/android/logviewer/ui/filterdialog/FilterDialogFactory.java index 5e2a966a..7bfb5f0b 100644 --- a/src/org/bitbucket/mlopatkin/android/logviewer/ui/filterdialog/FilterDialogFactory.java +++ b/src/org/bitbucket/mlopatkin/android/logviewer/ui/filterdialog/FilterDialogFactory.java @@ -23,18 +23,31 @@ import javax.inject.Provider; public class FilterDialogFactory { - private final Provider filterDialogFactory; + private static final String NEW_FILTER_DIALOG_TITLE = "Create new filter"; + private static final String EDIT_FILTER_DIALOG_TITLE = "Edit filter"; + + private final Provider filterDialogViewFactory; @Inject - public FilterDialogFactory(Provider filterDialogFactory) { - this.filterDialogFactory = filterDialogFactory; + public FilterDialogFactory(Provider filterDialogViewFactory) { + this.filterDialogViewFactory = filterDialogViewFactory; } public CompletionStage> startCreateFilterDialog() { - return FilterDialogPresenter.create(filterDialogFactory.get()).show(); + FilterDialog dialogView = filterDialogViewFactory.get(); + dialogView.setTitle(NEW_FILTER_DIALOG_TITLE); + return FilterDialogPresenter.create(dialogView).show(); + } + + public CompletionStage> startCreateFilterDialogWithInitialData(FilterFromDialog filter) { + FilterDialog dialogView = filterDialogViewFactory.get(); + dialogView.setTitle(NEW_FILTER_DIALOG_TITLE); + return FilterDialogPresenter.create(dialogView, filter).show(); } public CompletionStage> startEditFilterDialog(FilterFromDialog filter) { - return FilterDialogPresenter.create(filterDialogFactory.get(), filter).show(); + FilterDialog dialogView = filterDialogViewFactory.get(); + dialogView.setTitle(EDIT_FILTER_DIALOG_TITLE); + return FilterDialogPresenter.create(dialogView, filter).show(); } }