Use dynamic titles

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-02-17 23:35:51 +01:00
parent cdc611a71e
commit 3253e1356f
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
5 changed files with 22 additions and 7 deletions

View file

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

View file

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

View file

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

View file

@ -121,7 +121,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
getContext()));
creatorView.setOnClickListener(v -> {
actions.showTemplate(creator);
actions.showTemplate(creator, creatorViewBinding.creatorName.getText().toString());
dismiss();
});

View file

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