add auto pre-filling of file name upon template chosen

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-02-17 17:21:39 +01:00
parent 299248766c
commit 64ad49163f
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -217,9 +217,18 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View
@Override
public void onClick(Template template) {
adapter.setTemplateAsActive(template);
prefillFilenameIfEmpty(template);
checkEnablingCreateButton();
}
private void prefillFilenameIfEmpty(Template template) {
String name = binding.filename.getText().toString();
if (name.isEmpty() || name.equalsIgnoreCase(DOT + template.getExtension())) {
binding.filename.setText(String.format("%s.%s", template.title, template.extension));
}
binding.filename.setSelection(binding.filename.getText().toString().lastIndexOf('.'));
}
@Override
public void onClick(View v) {
String name = binding.filename.getText().toString();