From 3253e1356f8774b0f08000bfc2cd8e4d3ef697a5 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 17 Feb 2021 23:35:51 +0100 Subject: [PATCH] Use dynamic titles Signed-off-by: Andy Scherzinger --- .../ChooseRichDocumentsTemplateDialogFragment.java | 14 +++++++++++++- .../ui/dialog/ChooseTemplateDialogFragment.java | 7 +++++-- .../ui/fragment/OCFileListBottomSheetActions.java | 2 +- .../ui/fragment/OCFileListBottomSheetDialog.java | 2 +- .../android/ui/fragment/OCFileListFragment.java | 4 ++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java index 4deca00979..0f52f1d48b 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java @@ -165,7 +165,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im builder.setView(view) .setPositiveButton(R.string.create, null) .setNeutralButton(R.string.common_cancel, null) - .setTitle(R.string.select_template); + .setTitle(getTitle(type)); Dialog dialog = builder.create(); Window window = dialog.getWindow(); @@ -177,6 +177,18 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im return dialog; } + private int getTitle(Type type) { + if (type == Type.DOCUMENT) { + return R.string.create_new_document; + } else if (type == Type.SPREADSHEET) { + return R.string.create_new_spreadsheet; + } else if (type == Type.PRESENTATION) { + return R.string.create_new_presentation; + } + + return R.string.select_template; + } + @Override public void onDestroyView() { super.onDestroyView(); diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java index 48d305e190..09459ab3c1 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java @@ -81,6 +81,7 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View private static final String ARG_PARENT_FOLDER = "PARENT_FOLDER"; private static final String ARG_CREATOR = "CREATOR"; + private static final String ARG_HEADLINE = "HEADLINE"; private static final String TAG = ChooseTemplateDialogFragment.class.getSimpleName(); private static final String DOT = "."; @@ -99,11 +100,12 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View ChooseTemplateBinding binding; - public static ChooseTemplateDialogFragment newInstance(OCFile parentFolder, Creator creator) { + public static ChooseTemplateDialogFragment newInstance(OCFile parentFolder, Creator creator, String headline) { ChooseTemplateDialogFragment frag = new ChooseTemplateDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_PARENT_FOLDER, parentFolder); args.putParcelable(ARG_CREATOR, creator); + args.putString(ARG_HEADLINE, headline); frag.setArguments(args); return frag; } @@ -139,6 +141,7 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER); creator = arguments.getParcelable(ARG_CREATOR); + String headline = arguments.getString(ARG_HEADLINE, getString(R.string.select_template)); // Inflate the layout for the dialog LayoutInflater inflater = requireActivity().getLayoutInflater(); @@ -187,7 +190,7 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View builder.setView(view) .setPositiveButton(R.string.create, null) .setNeutralButton(R.string.common_cancel, null) - .setTitle(R.string.select_template); + .setTitle(headline); Dialog dialog = builder.create(); Window window = dialog.getWindow(); diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetActions.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetActions.java index 8f35e240e9..769a4c6cca 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetActions.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetActions.java @@ -65,7 +65,7 @@ public interface OCFileListBottomSheetActions { /** * open template selection for creator @link Creator */ - void showTemplate(Creator creator); + void showTemplate(Creator creator, String headline); /** * open editor for rich workspace diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java index da65cca835..d63460f833 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListBottomSheetDialog.java @@ -121,7 +121,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog { getContext())); creatorView.setOnClickListener(v -> { - actions.showTemplate(creator); + actions.showTemplate(creator, creatorViewBinding.creatorName.getText().toString()); dismiss(); }); diff --git a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index aa39c779e0..8b5526293d 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -565,8 +565,8 @@ public class OCFileListFragment extends ExtendedListFragment implements } @Override - public void showTemplate(Creator creator) { - ChooseTemplateDialogFragment.newInstance(mFile, creator).show(requireActivity().getSupportFragmentManager(), + public void showTemplate(Creator creator, String headline) { + ChooseTemplateDialogFragment.newInstance(mFile, creator, headline).show(requireActivity().getSupportFragmentManager(), DIALOG_CREATE_DOCUMENT); }