diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete.png
index 94649f8737d0..512624b5ab8d 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_blue.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_blue.png
index dcbd74a183f1..e02f1a068aab 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_blue.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_blue.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_white.png
index 545ac06699e7..bf346d3780ef 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_dark_white.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_light_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_light_white.png
index fc13882a3061..118f9ccb7b5b 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_light_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_delete_light_white.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request.png
index 5feb32d103ef..ea90e61440f4 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_blue.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_blue.png
index f7c0f0c638e3..833f1d214cc9 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_blue.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_blue.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_white.png
index eb1464ca0629..b12891f531dd 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_dark_white.png differ
diff --git a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_light_white.png b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_light_white.png
index d72fa40896dc..96fb3fcd5232 100644
Binary files a/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_light_white.png and b/screenshots/gplay/debug/com.owncloud.android.ui.activity.PassCodeActivityIT_request_light_white.png differ
diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt
index 1cc9be59d585..8fcd69aefd92 100644
--- a/scripts/analysis/lint-results.txt
+++ b/scripts/analysis/lint-results.txt
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
- Lint Report: 240 warnings
+ Lint Report: 232 warnings
diff --git a/src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java b/src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java
index 2327604ac0fb..f79c71384dcd 100644
--- a/src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java
+++ b/src/androidTest/java/com/owncloud/android/ui/dialog/DialogFragmentIT.java
@@ -278,7 +278,7 @@ public void directCameraUpload() {
}
@Override
- public void showTemplate(Creator creator) {
+ public void showTemplate(Creator creator, String headline) {
}
diff --git a/src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java b/src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java
index 27545c1640a4..c48467e3e078 100644
--- a/src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java
+++ b/src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java
@@ -93,7 +93,7 @@ protected void onCreate(Bundle savedInstanceState) {
int elementColor = ThemeUtils.primaryColor(this, true);
- ThemeUtils.themeDialogActionButton(binding.cancel);
+ ThemeUtils.themeBorderlessButton(binding.cancel, ThemeUtils.primaryColor(this, true));
passCodeEditTexts[0] = binding.txt0;
ThemeUtils.colorEditText(passCodeEditTexts[0], elementColor);
diff --git a/src/main/java/com/owncloud/android/ui/adapter/RichDocumentsTemplateAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/RichDocumentsTemplateAdapter.java
index 353e3a153087..bc86430eec53 100644
--- a/src/main/java/com/owncloud/android/ui/adapter/RichDocumentsTemplateAdapter.java
+++ b/src/main/java/com/owncloud/android/ui/adapter/RichDocumentsTemplateAdapter.java
@@ -26,16 +26,16 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.R;
+import com.owncloud.android.databinding.TemplateButtonBinding;
import com.owncloud.android.datamodel.Template;
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
import com.owncloud.android.utils.NextcloudServer;
+import com.owncloud.android.utils.ThemeUtils;
import com.owncloud.android.utils.glide.CustomGlideStreamLoader;
import java.util.ArrayList;
@@ -43,8 +43,6 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
/**
* Adapter for handling Templates, used to create files out of it via RichDocuments app
@@ -57,6 +55,9 @@ public class RichDocumentsTemplateAdapter extends RecyclerView.Adapter templateList) {
this.templateList = templateList;
}
+ public void setTemplateAsActive(Template template) {
+ selectedTemplate = template;
+ notifyDataSetChanged();
+ }
+
+ public Template getSelectedTemplate() {
+ return selectedTemplate;
+ }
+
@Override
public int getItemCount() {
return templateList.size();
@@ -95,17 +111,12 @@ public int getItemCount() {
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
- @BindView(R.id.name)
- public TextView name;
-
- @BindView(R.id.thumbnail)
- public ImageView thumbnail;
-
+ private final TemplateButtonBinding binding;
private Template template;
- public ViewHolder(View itemView) {
- super(itemView);
- ButterKnife.bind(this, itemView);
+ public ViewHolder(@NonNull TemplateButtonBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
itemView.setOnClickListener(this);
}
@@ -143,9 +154,15 @@ public void setData(Template template) {
load(template.getThumbnailLink())
.placeholder(placeholder)
.error(placeholder)
- .into(thumbnail);
+ .into(binding.template);
- name.setText(template.getName());
+ binding.templateName.setText(template.getName());
+
+ if (template == selectedTemplate) {
+ binding.templateContainer.setStrokeColor(colorSelected);
+ } else {
+ binding.templateContainer.setStrokeColor(colorUnselected);
+ }
}
}
diff --git a/src/main/java/com/owncloud/android/ui/adapter/TemplateAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/TemplateAdapter.java
index 8fe502f60e63..2b777fca383b 100644
--- a/src/main/java/com/owncloud/android/ui/adapter/TemplateAdapter.java
+++ b/src/main/java/com/owncloud/android/ui/adapter/TemplateAdapter.java
@@ -29,22 +29,20 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.R;
+import com.owncloud.android.databinding.TemplateButtonBinding;
import com.owncloud.android.lib.common.Template;
import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.utils.MimeTypeUtil;
+import com.owncloud.android.utils.ThemeUtils;
import com.owncloud.android.utils.glide.CustomGlideStreamLoader;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
/**
* Adapter for handling Templates, used to create files out of it via RichDocuments app
@@ -57,6 +55,9 @@ public class TemplateAdapter extends RecyclerView.Adapter templateList) {
}
@Override
- public void onClick(Template template) {
- String name = fileName.getText().toString();
+ public void onClick(View v) {
+ String name = binding.filename.getText().toString();
String path = parentFolder.getRemotePath() + name;
- if (name.isEmpty() || name.equalsIgnoreCase(DOT + template.getExtension())) {
- DisplayUtils.showSnackMessage(listView, R.string.enter_filename);
- } else if (!name.endsWith(template.getExtension())) {
- createFromTemplate(template, path + DOT + template.getExtension());
+ Template selectedTemplate = adapter.getSelectedTemplate();
+
+ if (selectedTemplate == null) {
+ DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template);
+ } else if (name.isEmpty() || name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())) {
+ DisplayUtils.showSnackMessage(binding.list, R.string.enter_filename);
+ } else if (!name.endsWith(selectedTemplate.getExtension())) {
+ createFromTemplate(selectedTemplate, path + DOT + selectedTemplate.getExtension());
} else {
- createFromTemplate(template, path);
+ createFromTemplate(selectedTemplate, path);
}
}
@Override
- public void onClick(DialogInterface dialog, int which) {
- // cancel is handled by dialog itself, no other button available
+ public void onClick(Template template) {
+ onTemplateChosen(template);
+ }
+
+ private void onTemplateChosen(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.name, template.extension));
+ }
+ binding.filename.setSelection(binding.filename.getText().toString().lastIndexOf('.'));
+ }
+
+ private void checkEnablingCreateButton() {
+ Template selectedTemplate = adapter.getSelectedTemplate();
+ String name = binding.filename.getText().toString();
+
+ positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
+ !name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
}
private static class CreateFileFromTemplateTask extends AsyncTask {
@@ -268,7 +309,7 @@ protected void onPostExecute(String url) {
if (fragment != null && fragment.isAdded()) {
if (url.isEmpty()) {
- DisplayUtils.showSnackMessage(fragment.listView, "Error creating file from template");
+ DisplayUtils.showSnackMessage(fragment.binding.list, "Error creating file from template");
} else {
Intent collaboraWebViewIntent = new Intent(MainApp.getAppContext(), RichDocumentsEditorWebView.class);
collaboraWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Collabora");
@@ -319,12 +360,18 @@ protected void onPostExecute(List templateList) {
if (fragment != null) {
if (templateList.isEmpty()) {
- DisplayUtils.showSnackMessage(fragment.listView, R.string.error_retrieving_templates);
+ DisplayUtils.showSnackMessage(fragment.binding.list, R.string.error_retrieving_templates);
} else {
- fragment.setTemplateList(templateList);
+ if (templateList.size() == SINGLE_TEMPLATE) {
+ fragment.onTemplateChosen(templateList.get(0));
+ fragment.binding.list.setVisibility(View.GONE);
+ } else {
+ String name = DOT + templateList.get(0).getExtension();
+ fragment.binding.filename.setText(name);
+ fragment.binding.helperText.setVisibility(View.VISIBLE);
+ }
- String name = DOT + templateList.get(0).getExtension();
- fragment.fileName.setText(name);
+ fragment.setTemplateList(templateList);
}
} else {
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
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 802804126ee3..f9249cce04de 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java
@@ -24,20 +24,19 @@
package com.owncloud.android.ui.dialog;
-import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
-import android.graphics.PorterDuff;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
-import android.widget.EditText;
+import android.widget.Button;
import com.nextcloud.android.lib.resources.directediting.DirectEditingCreateFileRemoteOperation;
import com.nextcloud.android.lib.resources.directediting.DirectEditingObtainListOfTemplatesRemoteOperation;
@@ -47,6 +46,7 @@
import com.nextcloud.client.network.ClientFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
+import com.owncloud.android.databinding.ChooseTemplateBinding;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.Creator;
@@ -72,26 +72,27 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.GridLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
/**
* Dialog to show templates for new documents/spreadsheets/presentations.
*/
-public class ChooseTemplateDialogFragment extends DialogFragment implements DialogInterface.OnClickListener,
+public class ChooseTemplateDialogFragment extends DialogFragment implements View.OnClickListener,
TemplateAdapter.ClickListener, Injectable {
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 = ".";
+ public static final int SINGLE_TEMPLATE = 1;
private TemplateAdapter adapter;
private OCFile parentFolder;
+ private String title;
@Inject ClientFactory clientFactory;
private Creator creator;
@Inject CurrentAccountProvider currentAccount;
+ private Button positiveButton;
public enum Type {
DOCUMENT,
@@ -99,20 +100,16 @@ public enum Type {
PRESENTATION
}
- @BindView(R.id.list)
- RecyclerView listView;
+ ChooseTemplateBinding binding;
- @BindView(R.id.filename)
- EditText fileName;
-
- 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;
-
}
@Override
@@ -123,8 +120,14 @@ public void onStart() {
AlertDialog alertDialog = (AlertDialog) getDialog();
- alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
- alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
+ positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
+ ThemeUtils.themeBorderlessButton(positiveButton, color);
+ positiveButton.setOnClickListener(this);
+ positiveButton.setEnabled(false);
+
+ ThemeUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL), color);
+
+ checkEnablingCreateButton();
}
@NonNull
@@ -140,18 +143,45 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
throw new IllegalArgumentException("Activity may not be null");
}
- int accentColor = ThemeUtils.primaryAccentColor(getContext());
-
parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER);
creator = arguments.getParcelable(ARG_CREATOR);
+ title = arguments.getString(ARG_HEADLINE, getString(R.string.select_template));
+
+ if (savedInstanceState == null) {
+ title = arguments.getString(ARG_HEADLINE);
+ } else {
+ title = savedInstanceState.getString(ARG_HEADLINE);
+ }
// Inflate the layout for the dialog
- LayoutInflater inflater = activity.getLayoutInflater();
- @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.choose_template, null);
- ButterKnife.bind(this, view);
+ LayoutInflater inflater = requireActivity().getLayoutInflater();
+ binding = ChooseTemplateBinding.inflate(inflater, null, false);
+ View view = binding.getRoot();
+
+ binding.filename.requestFocus();
+ ThemeUtils.colorTextInput(binding.filenameContainer, binding.filename, ThemeUtils.primaryColor(getContext()));
+
+ binding.filename.setOnKeyListener((v, keyCode, event) -> {
+ checkEnablingCreateButton();
+ return false;
+ });
+
+ binding.filename.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ // generated method stub
+ }
- fileName.requestFocus();
- fileName.getBackground().setColorFilter(accentColor, PorterDuff.Mode.SRC_ATOP);
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ // generated method stub
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ checkEnablingCreateButton();
+ }
+ });
try {
User user = currentAccount.getUser();
@@ -160,16 +190,17 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
Log_OC.e(TAG, "Loading stream url not possible: " + e);
}
- listView.setHasFixedSize(true);
- listView.setLayoutManager(new GridLayoutManager(activity, 2));
+ binding.list.setHasFixedSize(true);
+ binding.list.setLayoutManager(new GridLayoutManager(activity, 2));
adapter = new TemplateAdapter(creator.getMimetype(), this, getContext(), currentAccount, clientFactory);
- listView.setAdapter(adapter);
+ binding.list.setAdapter(adapter);
// Build the dialog
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setView(view)
- .setNegativeButton(R.string.common_cancel, this)
- .setTitle(R.string.select_template);
+ .setPositiveButton(R.string.create, null)
+ .setNeutralButton(R.string.common_cancel, null)
+ .setTitle(title);
Dialog dialog = builder.create();
Window window = dialog.getWindow();
@@ -181,6 +212,18 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
return dialog;
}
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ binding = null;
+ }
+
+ @Override
+ public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
+ super.onSaveInstanceState(savedInstanceState);
+ savedInstanceState.putString(ARG_HEADLINE, title);
+ }
+
private void createFromTemplate(Template template, String path) {
new CreateFileFromTemplateTask(this, clientFactory, currentAccount.getUser(), template, path, creator).execute();
}
@@ -192,21 +235,47 @@ public void setTemplateList(TemplateList templateList) {
@Override
public void onClick(Template template) {
- String name = fileName.getText().toString();
- String path = parentFolder.getRemotePath() + name;
+ onTemplateChosen(template);
+ }
+
+ private void onTemplateChosen(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())) {
- DisplayUtils.showSnackMessage(listView, R.string.enter_filename);
- } else if (!name.endsWith(template.getExtension())) {
- createFromTemplate(template, path + DOT + template.getExtension());
- } else {
- createFromTemplate(template, path);
+ binding.filename.setText(String.format("%s.%s", template.title, template.extension));
}
+ binding.filename.setSelection(binding.filename.getText().toString().lastIndexOf('.'));
}
@Override
- public void onClick(DialogInterface dialog, int which) {
- // cancel is handled by dialog itself, no other button available
+ public void onClick(View v) {
+ String name = binding.filename.getText().toString();
+ String path = parentFolder.getRemotePath() + name;
+
+ Template selectedTemplate = adapter.getSelectedTemplate();
+
+ if (selectedTemplate == null) {
+ DisplayUtils.showSnackMessage(binding.list, R.string.select_one_template);
+ } else if (name.isEmpty() || name.equalsIgnoreCase(DOT + selectedTemplate.getExtension())) {
+ DisplayUtils.showSnackMessage(binding.list, R.string.enter_filename);
+ } else if (!name.endsWith(selectedTemplate.getExtension())) {
+ createFromTemplate(selectedTemplate, path + DOT + selectedTemplate.getExtension());
+ } else {
+ createFromTemplate(selectedTemplate, path);
+ }
+ }
+
+ private void checkEnablingCreateButton() {
+ Template selectedTemplate = adapter.getSelectedTemplate();
+ String name = binding.filename.getText().toString();
+
+ positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
+ !name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
}
private static class CreateFileFromTemplateTask extends AsyncTask {
@@ -284,7 +353,7 @@ protected void onPostExecute(String url) {
if (fragment != null && fragment.isAdded()) {
if (url.isEmpty()) {
- DisplayUtils.showSnackMessage(fragment.listView, "Error creating file from template");
+ DisplayUtils.showSnackMessage(fragment.binding.list, "Error creating file from template");
} else {
Intent editorWebView = new Intent(MainApp.getAppContext(), TextEditorWebView.class);
editorWebView.putExtra(ExternalSiteWebView.EXTRA_TITLE, "Text");
@@ -345,12 +414,18 @@ protected void onPostExecute(TemplateList templateList) {
if (fragment != null && fragment.isAdded()) {
if (templateList.templates.isEmpty()) {
- DisplayUtils.showSnackMessage(fragment.listView, R.string.error_retrieving_templates);
+ DisplayUtils.showSnackMessage(fragment.binding.list, R.string.error_retrieving_templates);
} else {
- fragment.setTemplateList(templateList);
+ if (templateList.templates.size() == SINGLE_TEMPLATE) {
+ fragment.onTemplateChosen(templateList.templates.values().iterator().next());
+ fragment.binding.list.setVisibility(View.GONE);
+ } else {
+ String name = DOT + templateList.templates.values().iterator().next().getExtension();
+ fragment.binding.filename.setText(name);
+ fragment.binding.helperText.setVisibility(View.VISIBLE);
+ }
- String name = DOT + templateList.templates.values().iterator().next().getExtension();
- fragment.fileName.setText(name);
+ fragment.setTemplateList(templateList);
}
} else {
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
diff --git a/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java
index 3610ecc4648d..69f6465d200e 100644
--- a/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java
+++ b/src/main/java/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java
@@ -202,10 +202,10 @@ private void setupDialogElements(View view) {
mNameCollisionPolicySummary = view.findViewById(R.id.setting_instant_name_collision_policy_summary);
mCancel = view.findViewById(R.id.cancel);
- ThemeUtils.themeDialogActionButton(mCancel);
+ ThemeUtils.themeBorderlessButton(mCancel, accentColor);
mSave = view.findViewById(R.id.save);
- ThemeUtils.themeDialogActionButton(mSave);
+ ThemeUtils.themeBorderlessButton(mSave, accentColor);
// Set values
setEnabled(mSyncedFolder.isEnabled());
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 8f35e240e916..769a4c6cca44 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 da65cca835b6..d63460f8333e 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 @@ protected void onCreate(Bundle savedInstanceState) {
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 aa39c779e07f..8b5526293df4 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 void onHeaderClicked() {
}
@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);
}
diff --git a/src/main/java/com/owncloud/android/utils/ThemeUtils.java b/src/main/java/com/owncloud/android/utils/ThemeUtils.java
index 44f6b13159f9..f110fc6e582c 100644
--- a/src/main/java/com/owncloud/android/utils/ThemeUtils.java
+++ b/src/main/java/com/owncloud/android/utils/ThemeUtils.java
@@ -45,7 +45,6 @@
import android.widget.ProgressBar;
import android.widget.SeekBar;
-import com.google.android.material.button.MaterialButton;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.tabs.TabLayout;
@@ -569,13 +568,12 @@ private static void colorTextInputLayout(TextInputLayout textInputLayout, int co
));
}
- public static void themeDialogActionButton(MaterialButton button) {
+ public static void themeBorderlessButton(Button button, int primaryColor) {
if (button == null) {
return;
}
Context context = button.getContext();
- int accentColor = ThemeUtils.primaryAccentColor(button.getContext());
int disabledColor = ContextCompat.getColor(context, R.color.disabled_text);
button.setTextColor(new ColorStateList(
new int[][]{
@@ -583,7 +581,7 @@ public static void themeDialogActionButton(MaterialButton button) {
new int[]{-android.R.attr.state_enabled}, // disabled
},
new int[]{
- accentColor,
+ primaryColor,
disabledColor
}
));
diff --git a/src/main/res/layout/choose_template.xml b/src/main/res/layout/choose_template.xml
index a6d185716f4b..b8599fb389c1 100644
--- a/src/main/res/layout/choose_template.xml
+++ b/src/main/res/layout/choose_template.xml
@@ -3,6 +3,8 @@
Nextcloud Android client application
@author Tobias Kaminsky
+ @author Andy Scherzinger
+ Copyright (C) 2020 Andy Scherzinger
Copyright (C) 2018 Tobias Kaminsky
Copyright (C) 2018 Nextcloud GmbH.
@@ -20,11 +22,22 @@
along with this program. If not, see .
-->
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="clip_horizontal"
+ android:orientation="vertical"
+ android:paddingStart="@dimen/standard_padding"
+ android:paddingEnd="@dimen/standard_padding">
+
+
-
+ android:paddingTop="@dimen/standard_padding">
+
+
+
+
+
+
diff --git a/src/main/res/layout/template_button.xml b/src/main/res/layout/template_button.xml
index d5c0c2a8635b..cebe72ab07d0 100644
--- a/src/main/res/layout/template_button.xml
+++ b/src/main/res/layout/template_button.xml
@@ -3,6 +3,8 @@
Nextcloud Android client application
@author Tobias Kaminsky
+ @author Andy Scherzinger
+ Copyright (C) 2020 Andy Scherzinger
Copyright (C) 2018 Tobias Kaminsky
Copyright (C) 2018 Nextcloud GmbH.
@@ -19,25 +21,35 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
-->
-
-
-
+
+
+ app:cardElevation="0dp"
+ app:strokeColor="@color/grey_200"
+ app:strokeWidth="2dp">
+
+
+
+
+ tools:text="Template" />
diff --git a/src/main/res/values-night/colors.xml b/src/main/res/values-night/colors.xml
index 17686893e498..58336c603e2c 100644
--- a/src/main/res/values-night/colors.xml
+++ b/src/main/res/values-night/colors.xml
@@ -22,6 +22,7 @@
#E3E3E3
#000000
+ #ff6F6F6F
#A5A5A5
#222222
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 278159c77ef6..bcc7b915bbbf 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -954,4 +954,7 @@
Login via direct link failed!
The link to your %1$s web interface when you open it in the browser.
Delayed due to too many wrong attempts
+ Create
+ Please select one template
+ Please choose a template and enter a file name.