diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/AppItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/AppItem.java deleted file mode 100644 index 6c2bce104..000000000 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/AppItem.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.adapters.items; - -import android.graphics.drawable.Drawable; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.ForegroundColorSpan; -import android.view.View; - -import com.nextcloud.talk.R; -import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.databinding.RvItemAppBinding; - -import java.util.List; - -import androidx.annotation.Nullable; -import eu.davidea.flexibleadapter.FlexibleAdapter; -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; -import eu.davidea.flexibleadapter.items.IFlexible; -import eu.davidea.viewholders.FlexibleViewHolder; - -public class AppItem extends AbstractFlexibleItem { - private final String title; - private final String packageName; - private final String name; - @Nullable - private final Drawable drawable; - - public AppItem(String title, String packageName, String name, @Nullable Drawable drawable) { - this.title = title; - this.packageName = packageName; - this.name = name; - this.drawable = drawable; - } - - @Override - public boolean equals(Object o) { - if (o instanceof AppItem) { - AppItem inItem = (AppItem) o; - return title.equals(inItem.getTitle()) && packageName.equals(inItem.getPackageName()) && name.equals(inItem - .getName()); - } - - return false; - } - - public String getTitle() { - return title; - } - - public String getPackageName() { - return packageName; - } - - public String getName() { - return name; - } - - @Override - public int getLayoutRes() { - return R.layout.rv_item_app; - } - - @Override - public void bindViewHolder(FlexibleAdapter adapter, AppItemViewHolder holder, int position, List payloads) { - if (drawable != null) { - holder.binding.iconImageView.setVisibility(View.VISIBLE); - holder.binding.iconImageView.setImageDrawable(drawable); - } else { - holder.binding.iconImageView.setVisibility(View.GONE); - } - - if (position == 0) { - Spannable spannableString = new SpannableString(title); - spannableString.setSpan(new ForegroundColorSpan(NextcloudTalkApplication.Companion.getSharedApplication() - .getResources().getColor(R.color.grey_600)), 0, - spannableString.length(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - holder.binding.appTitleTextView.setText(spannableString); - } else { - holder.binding.appTitleTextView.setText(title); - } - } - - @Override - public AppItem.AppItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) { - return new AppItemViewHolder(view, adapter); - } - - static class AppItemViewHolder extends FlexibleViewHolder { - - RvItemAppBinding binding; - - /** - * Default constructor. - */ - AppItemViewHolder(View view, FlexibleAdapter adapter) { - super(view, adapter); - binding = RvItemAppBinding.bind(view); - } - } -} diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/MenuItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/MenuItem.java deleted file mode 100644 index ea7324385..000000000 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/MenuItem.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2017 Mario Danic - * Copyright (C) 2018 Andy Scherzinger - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.adapters.items; - -import android.graphics.drawable.Drawable; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.ForegroundColorSpan; -import android.view.View; - -import com.nextcloud.talk.R; -import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.databinding.RvItemMenuBinding; -import com.nextcloud.talk.utils.DisplayUtils; - -import java.util.List; - -import eu.davidea.flexibleadapter.FlexibleAdapter; -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; -import eu.davidea.viewholders.FlexibleViewHolder; - -public class MenuItem extends AbstractFlexibleItem { - private final String title; - private final Drawable icon; - private final int tag; - private final int padding; - - public MenuItem(String title, int tag, Drawable icon) { - this.title = title; - this.tag = tag; - this.icon = icon; - padding = (int) DisplayUtils.convertDpToPixel(32, - NextcloudTalkApplication - .Companion - .getSharedApplication() - .getApplicationContext()); - } - - @Override - public boolean equals(Object o) { - if (o instanceof MenuItem) { - MenuItem inItem = (MenuItem) o; - return tag == inItem.tag; - } - return false; - } - - public int getTag() { - return tag; - } - - @Override - public int getLayoutRes() { - return R.layout.rv_item_menu; - } - - @Override - public MenuItem.MenuItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) { - return new MenuItemViewHolder(view, adapter); - } - - @Override - public void bindViewHolder(FlexibleAdapter adapter, MenuItem.MenuItemViewHolder holder, int position, List payloads) { - if (position == 0) { - Spannable spannableString = new SpannableString(title); - spannableString.setSpan( - new ForegroundColorSpan( - NextcloudTalkApplication - .Companion - .getSharedApplication() - .getResources() - .getColor(R.color.grey_600)), - 0, - spannableString.length(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - holder.binding.menuText.setText(spannableString); - } else { - holder.binding.menuText.setText(title); - holder.binding.menuText.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); - holder.binding.menuText.setCompoundDrawablePadding(padding); - } - } - - static class MenuItemViewHolder extends FlexibleViewHolder { - - RvItemMenuBinding binding; - - /** - * Default constructor. - */ - MenuItemViewHolder(View view, FlexibleAdapter adapter) { - super(view, adapter); - binding = RvItemMenuBinding.bind(view); - } - } -} diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ProgressItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/ProgressItem.java deleted file mode 100644 index 6455e0c87..000000000 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ProgressItem.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2018 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Heavily copied from and influenced by - * https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-On-Load-More#automatic-load-more. - * Author: David Steduto under Apache2 licence - */ - -package com.nextcloud.talk.adapters.items; - -import android.animation.Animator; -import android.content.Context; -import android.view.View; - -import com.nextcloud.talk.R; -import com.nextcloud.talk.databinding.RvItemProgressBinding; - -import java.util.List; - -import androidx.annotation.NonNull; -import eu.davidea.flexibleadapter.FlexibleAdapter; -import eu.davidea.flexibleadapter.Payload; -import eu.davidea.flexibleadapter.helpers.AnimatorHelper; -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; -import eu.davidea.flexibleadapter.items.IFlexible; -import eu.davidea.viewholders.FlexibleViewHolder; - -/** - * @author Davide Steduto - * @since 22/04/2016 - */ -public class ProgressItem extends AbstractFlexibleItem { - - private StatusEnum status = StatusEnum.MORE_TO_LOAD; - - @Override - public boolean equals(Object o) { - return this == o;//The default implementation - } - - public StatusEnum getStatus() { - return status; - } - - public void setStatus(StatusEnum status) { - this.status = status; - } - - @Override - public int getLayoutRes() { - return R.layout.rv_item_progress; - } - - @Override - public void bindViewHolder(FlexibleAdapter adapter, ProgressViewHolder holder, int position, List payloads) { - Context context = holder.itemView.getContext(); - holder.binding.progressBar.setVisibility(View.GONE); - holder.binding.progressMessage.setVisibility(View.VISIBLE); - - if (!adapter.isEndlessScrollEnabled()) { - setStatus(StatusEnum.DISABLE_ENDLESS); - } else if (payloads.contains(Payload.NO_MORE_LOAD)) { - setStatus(StatusEnum.NO_MORE_LOAD); - } - - switch (this.status) { - case NO_MORE_LOAD: - holder.binding.progressMessage.setText( - context.getString(R.string.nc_no_more_load_retry)); - // Reset to default status for next binding - setStatus(StatusEnum.MORE_TO_LOAD); - break; - case DISABLE_ENDLESS: - holder.binding.progressMessage.setText(context.getString(R.string.nc_endless_disabled)); - break; - case ON_CANCEL: - holder.binding.progressMessage.setText(context.getString(R.string.nc_endless_cancel)); - // Reset to default status for next binding - setStatus(StatusEnum.MORE_TO_LOAD); - break; - case ON_ERROR: - holder.binding.progressMessage.setText(context.getString(R.string.nc_endless_error)); - // Reset to default status for next binding - setStatus(StatusEnum.MORE_TO_LOAD); - break; - default: - holder.binding.progressBar.setVisibility(View.VISIBLE); - holder.binding.progressMessage.setVisibility(View.GONE); - break; - } - } - - @Override - public ProgressViewHolder createViewHolder(View view, FlexibleAdapter adapter) { - return new ProgressViewHolder(view, adapter); - } - - - public enum StatusEnum { - MORE_TO_LOAD, //Default = should have an empty Payload - DISABLE_ENDLESS, //Endless is disabled because user has set limits - NO_MORE_LOAD, //Non-empty Payload = Payload.NO_MORE_LOAD - ON_CANCEL, - ON_ERROR - } - - static class ProgressViewHolder extends FlexibleViewHolder { - - RvItemProgressBinding binding; - - ProgressViewHolder(View view, FlexibleAdapter adapter) { - super(view, adapter); - binding = RvItemProgressBinding.bind(view); - } - - @Override - public void scrollAnimators(@NonNull List animators, int position, boolean isForward) { - AnimatorHelper.scaleAnimator(animators, itemView, 0f); - } - } - -}