Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 240 warnings</span>
<span class="mdl-layout-title">Lint Report: 232 warnings</span>
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void directCameraUpload() {
}

@Override
public void showTemplate(Creator creator) {
public void showTemplate(Creator creator, String headline) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@
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;
import java.util.List;

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
Expand All @@ -57,6 +55,9 @@ public class RichDocumentsTemplateAdapter extends RecyclerView.Adapter<RichDocum
private ChooseRichDocumentsTemplateDialogFragment.Type type;
private CurrentAccountProvider currentAccountProvider;
private ClientFactory clientFactory;
private Template selectedTemplate;
private final int colorSelected;
private final int colorUnselected;

public RichDocumentsTemplateAdapter(
ChooseRichDocumentsTemplateDialogFragment.Type type,
Expand All @@ -70,13 +71,19 @@ public RichDocumentsTemplateAdapter(
this.context = context;
this.currentAccountProvider = currentAccountProvider;
this.clientFactory = clientFactory;
colorSelected = ThemeUtils.primaryColor(context, true);
colorUnselected = context.getResources().getColor(R.color.grey_200);
}

@NonNull
@Override
@NextcloudServer(max = 18) // remove entire class
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.template_button, parent, false));
return new RichDocumentsTemplateAdapter.ViewHolder(
TemplateButtonBinding.inflate(LayoutInflater.from(parent.getContext()),
parent,
false)
);
}

@Override
Expand All @@ -88,24 +95,28 @@ public void setTemplateList(List<Template> templateList) {
this.templateList = templateList;
}

public void setTemplateAsActive(Template template) {
selectedTemplate = template;
notifyDataSetChanged();
}

public Template getSelectedTemplate() {
return selectedTemplate;
}

@Override
public int getItemCount() {
return templateList.size();
}

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

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

Expand Down
52 changes: 35 additions & 17 deletions src/main/java/com/owncloud/android/ui/adapter/TemplateAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,6 +55,9 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
private CurrentAccountProvider currentAccountProvider;
private ClientFactory clientFactory;
private String mimetype;
private Template selectedTemplate;
private final int colorSelected;
private final int colorUnselected;

public TemplateAdapter(
String mimetype,
Expand All @@ -70,12 +71,18 @@ public TemplateAdapter(
this.context = context;
this.currentAccountProvider = currentAccountProvider;
this.clientFactory = clientFactory;
colorSelected = ThemeUtils.primaryColor(context, true);
colorUnselected = context.getResources().getColor(R.color.grey_200);
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.template_button, parent, false));
return new TemplateAdapter.ViewHolder(
TemplateButtonBinding.inflate(LayoutInflater.from(parent.getContext()),
parent,
false)
);
}

@Override
Expand All @@ -87,23 +94,28 @@ public void setTemplateList(TemplateList templateList) {
this.templateList = templateList;
}

public void setTemplateAsActive(Template template) {
selectedTemplate = template;
notifyDataSetChanged();
}

public Template getSelectedTemplate() {
return selectedTemplate;
}

@Override
public int getItemCount() {
return templateList.getTemplateList().size();
}

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

Expand All @@ -124,11 +136,17 @@ public void setData(Template template) {

Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
.load(template.getPreview())
.placeholder(placeholder)
.error(placeholder)
.into(thumbnail);
.placeholder(placeholder)
.error(placeholder)
.into(binding.template);

binding.templateName.setText(template.getTitle());

name.setText(template.getTitle());
if (template == selectedTemplate) {
binding.templateContainer.setStrokeColor(colorSelected);
} else {
binding.templateContainer.setStrokeColor(colorUnselected);
}
}
}

Expand Down
Loading