Migrate primate drawable tinting

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-09-13 14:46:46 +02:00 committed by Álvaro Brey
parent 35fb67f0a6
commit 6bf79d5a5f
No known key found for this signature in database
GPG key ID: 2585783189A62105
32 changed files with 144 additions and 155 deletions

View file

@ -355,7 +355,7 @@ dependencies {
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
// TODO change back to tag before merging
implementation 'com.github.nextcloud.android-common:ui:b2103712a1'
implementation 'com.github.nextcloud.android-common:ui:2c8987f0f2'
}
configurations.all {

View file

@ -65,8 +65,7 @@ import com.owncloud.android.utils.BitmapUtils;
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
@ -757,18 +756,15 @@ public final class ThumbnailsCacheManager {
private File mFile;
private String mImageKey;
private final Context mContext;
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
public MediaThumbnailGenerationTask(ImageView imageView,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<>(imageView);
mContext = context;
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
@Override
@ -816,8 +812,7 @@ public final class ThumbnailsCacheManager {
if (mFile != null) {
if (mFile.isDirectory()) {
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(mContext,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
if (MimeTypeUtil.isVideo(mFile)) {
imageView.setImageBitmap(ThumbnailsCacheManager.mDefaultVideo);
@ -825,8 +820,7 @@ public final class ThumbnailsCacheManager {
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null,
mFile.getName(),
mContext,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
}
}
}

View file

@ -116,8 +116,7 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
this,
clientFactory,
false,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
binding.list.setAdapter(adapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);

View file

@ -43,6 +43,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
public abstract class EditorWebView extends ExternalSiteWebView {
protected Snackbar loadingSnackbar;
@ -159,8 +160,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
file.isGroupFolder(),
file.getMountType(),
this,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
// Thumbnail in cache?
@ -184,8 +184,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
file.getFileName(),
user,
getApplicationContext(),
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
binding.thumbnail.setImageDrawable(icon);
}
}

View file

@ -769,8 +769,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
new int[]{R.id.filename},
getStorageManager(),
getUser().get(),
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
binding.list.setAdapter(sa);
}

View file

@ -760,7 +760,7 @@ public class SettingsActivity extends ThemedPreferenceActivity
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
if (this.getResources() != null) {
viewThemeUtils.material.themeActionBar(this,
viewThemeUtils.androidx.themeActionBar(this,
actionBar,
getString(R.string.actionbar_settings),
ResourcesCompat.getDrawable(this.getResources(),

View file

@ -43,6 +43,7 @@ import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
@ -79,15 +80,13 @@ public class ShareActivity extends FileActivity {
file.isGroupFolder(),
file.getMountType(),
this,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
binding.shareFileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
file.getFileName(),
optionalUser.get(),
this,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
if (MimeTypeUtil.isImage(file)) {
String remoteId = String.valueOf(file.getRemoteId());
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(remoteId);

View file

@ -252,7 +252,16 @@ class SyncedFoldersActivity :
private fun setupContent() {
val gridWidth = resources.getInteger(R.integer.media_grid_width)
val lightVersion = resources.getBoolean(R.bool.syncedFolder_light)
adapter = SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion, themeColorUtils, themeDrawableUtils)
adapter = SyncedFolderAdapter(
this,
clock,
gridWidth,
this,
lightVersion,
themeColorUtils,
themeDrawableUtils,
viewThemeUtils
)
syncedFolderProvider = SyncedFolderProvider(contentResolver, preferences, clock)
binding.emptyList.emptyListIcon.setImageResource(R.drawable.nav_synced_folders)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.emptyList.emptyListViewAction)

View file

@ -42,6 +42,7 @@ import com.owncloud.android.ui.interfaces.VersionListInterface;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.util.Collections;
import java.util.Date;
@ -61,16 +62,14 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
ActivityListInterface activityListInterface,
VersionListInterface.View versionListInterface,
ClientFactory clientFactory,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils
ViewThemeUtils viewThemeUtils
) {
super(context,
currentAccountProvider,
activityListInterface,
clientFactory,
true,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
this.versionListInterface = versionListInterface;
}

View file

@ -74,6 +74,7 @@ import com.owncloud.android.utils.svg.SvgBitmapTranscoder;
import com.owncloud.android.utils.svg.SvgDecoder;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.io.InputStream;
import java.util.ArrayList;
@ -100,8 +101,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private ClientFactory clientFactory;
protected List<Object> values;
private boolean isDetailView;
private ThemeColorUtils themeColorUtils;
private ThemeDrawableUtils themeDrawableUtils;
private ViewThemeUtils viewThemeUtils;
public ActivityListAdapter(
Context context,
@ -109,8 +109,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
ActivityListInterface activityListInterface,
ClientFactory clientFactory,
boolean isDetailView,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
this.values = new ArrayList<>();
this.context = context;
this.currentAccountProvider = currentAccountProvider;
@ -118,8 +117,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.clientFactory = clientFactory;
px = getThumbnailDimension();
this.isDetailView = isDetailView;
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
public void setActivityItems(List<Object> activityItems, NextcloudClient client, boolean clear) {
@ -287,14 +285,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} else {
if (MimeTypeUtil.isFolder(previewObject.getMimeType())) {
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(previewObject.getMimeType(),
"",
context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
}
}

View file

@ -51,6 +51,7 @@ import com.owncloud.android.utils.FileStorageUtils
import com.owncloud.android.utils.MimeTypeUtil
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
import me.zhanghai.android.fastscroll.PopupTextProvider
import java.util.Calendar
import java.util.Date
@ -63,7 +64,8 @@ class GalleryAdapter(
preferences: AppPreferences,
transferServiceGetter: ComponentsGetter,
themeColorUtils: ThemeColorUtils,
themeDrawableUtils: ThemeDrawableUtils
themeDrawableUtils: ThemeDrawableUtils,
viewThemeUtils: ViewThemeUtils
) : SectionedRecyclerViewAdapter<SectionedViewHolder>(), CommonOCFileListAdapterInterface, PopupTextProvider {
var files: List<GalleryItems> = mutableListOf()
private val ocFileListDelegate: OCFileListDelegate
@ -84,7 +86,8 @@ class GalleryAdapter(
showMetadata = false,
showShareAvatar = false,
themeColorUtils,
themeDrawableUtils
themeDrawableUtils,
viewThemeUtils
)
}

View file

@ -42,6 +42,7 @@ import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.io.File;
import java.util.ArrayList;
@ -73,8 +74,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
private boolean gridView = false;
private LocalFileListFragmentInterface localFileListFragmentInterface;
private Set<File> checkedFiles;
private ThemeColorUtils themeColorUtils;
private ThemeDrawableUtils themeDrawableUtils;
private ViewThemeUtils viewThemeUtils;
private static final int VIEWTYPE_ITEM = 0;
private static final int VIEWTYPE_FOOTER = 1;
@ -92,8 +92,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
mLocalFolderPicker = localFolderPickerMode;
this.localFileListFragmentInterface = localFileListFragmentInterface;
checkedFiles = new HashSet<>();
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
swapDirectory(directory);
}
@ -181,9 +180,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
if (isCheckedFile(file)) {
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources()
.getColor(R.color.selected_item_background));
gridViewHolder.checkbox.setImageDrawable(
themeDrawableUtils.tintDrawable(R.drawable.ic_checkbox_marked,
themeColorUtils.primaryColor(mContext)));
viewThemeUtils.platform.tintPrimaryDrawable(mContext, R.drawable.ic_checkbox_marked));
} else {
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
@ -193,7 +192,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
}
gridViewHolder.thumbnail.setTag(file.hashCode());
setThumbnail(file, gridViewHolder.thumbnail, mContext, themeColorUtils, themeDrawableUtils);
setThumbnail(file, gridViewHolder.thumbnail, mContext, viewThemeUtils);
gridViewHolder.itemLayout.setOnClickListener(v -> localFileListFragmentInterface
.onItemClicked(finalFile));
@ -231,12 +230,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
public static void setThumbnail(File file,
ImageView thumbnailView,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
if (file.isDirectory()) {
thumbnailView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(context,
themeColorUtils,
themeDrawableUtils));
thumbnailView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(context, viewThemeUtils));
} else {
thumbnailView.setImageResource(R.drawable.file);
@ -282,8 +278,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null,
file.getName(),
context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
}
}
}

View file

@ -182,7 +182,8 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
.getVersion()
.isShareesOnDavSupported(),
themeColorUtils,
themeDrawableUtils);
themeDrawableUtils,
viewThemeUtils);
// initialise thumbnails cache on background thread
new ThumbnailsCacheManager.InitDiskCacheTask().execute();

View file

@ -36,6 +36,7 @@ import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
@Suppress("LongParameterList", "TooManyFunctions")
class OCFileListDelegate(
@ -50,7 +51,8 @@ class OCFileListDelegate(
private val showMetadata: Boolean,
private var showShareAvatar: Boolean,
private var themeColorUtils: ThemeColorUtils,
private var themeDrawableUtils: ThemeDrawableUtils
private var themeDrawableUtils: ThemeDrawableUtils,
private var viewThemeUtils: ViewThemeUtils
) {
private val checkedFiles: MutableSet<OCFile> = HashSet()
private var highlightedItem: OCFile? = null
@ -106,8 +108,7 @@ class OCFileListDelegate(
context,
gridViewHolder.shimmerThumbnail,
preferences,
themeColorUtils,
themeDrawableUtils
viewThemeUtils
)
// item layout + click listeners
bindGridItemLayout(file, gridViewHolder)

View file

@ -42,6 +42,7 @@ import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.io.File;
import java.util.ArrayList;
@ -72,6 +73,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
private boolean hideItems;
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
private final Executor thumbnailThreadPool;
public SyncedFolderAdapter(Context context,
@ -80,7 +82,8 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
ClickListener listener,
boolean light,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ThemeDrawableUtils themeDrawableUtils,
ViewThemeUtils viewThemeUtils) {
this.context = context;
this.clock = clock;
this.gridWidth = gridWidth;
@ -92,6 +95,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
this.hideItems = true;
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
this.thumbnailThreadPool = Executors.newCachedThreadPool();
shouldShowHeadersForEmptySections(true);
@ -348,8 +352,7 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
ThumbnailsCacheManager.MediaThumbnailGenerationTask task =
new ThumbnailsCacheManager.MediaThumbnailGenerationTask(holder.binding.thumbnail,
context,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
ThumbnailsCacheManager.AsyncMediaThumbnailDrawable asyncDrawable =
new ThumbnailsCacheManager.AsyncMediaThumbnailDrawable(

View file

@ -40,7 +40,7 @@ import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.glide.CustomGlideStreamLoader;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.util.ArrayList;
@ -61,8 +61,7 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
private Template selectedTemplate;
private final int colorSelected;
private final int colorUnselected;
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
public TemplateAdapter(
String mimetype,
@ -71,7 +70,7 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
CurrentAccountProvider currentAccountProvider,
ClientFactory clientFactory,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils
ViewThemeUtils viewThemeUtils
) {
this.mimetype = mimetype;
this.clickListener = clickListener;
@ -80,8 +79,7 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
this.clientFactory = clientFactory;
colorSelected = themeColorUtils.primaryColor(context, true);
colorUnselected = context.getResources().getColor(R.color.grey_200);
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
@NonNull
@ -96,7 +94,7 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.setData(new ArrayList<>(templateList.getTemplates().values()).get(position), themeColorUtils, themeDrawableUtils);
holder.setData(new ArrayList<>(templateList.getTemplates().values()).get(position));
}
public void setTemplateList(TemplateList templateList) {
@ -135,15 +133,14 @@ public class TemplateAdapter extends RecyclerView.Adapter<TemplateAdapter.ViewHo
}
}
public void setData(Template template, ThemeColorUtils themeColorUtils, ThemeDrawableUtils themeDrawableUtils) {
public void setData(Template template) {
this.template = template;
Drawable placeholder = MimeTypeUtil.getFileTypeIcon(mimetype,
template.getTitle(),
currentAccountProvider.getUser(),
context,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider.getUser(), clientFactory))
.load(template.getPreview())

View file

@ -42,8 +42,7 @@ import com.owncloud.android.ui.interfaces.TrashbinActivityInterface;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.util.ArrayList;
import java.util.List;
@ -70,8 +69,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final FileDataStorageManager storageManager;
private final AppPreferences preferences;
private final List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks = new ArrayList<>();
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
public TrashbinListAdapter(
TrashbinActivityInterface trashbinActivityInterface,
@ -79,8 +77,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
AppPreferences preferences,
Context context,
User user,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils
ViewThemeUtils viewThemeUtils
) {
this.files = new ArrayList<>();
this.trashbinActivityInterface = trashbinActivityInterface;
@ -88,8 +85,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.storageManager = storageManager;
this.preferences = preferences;
this.context = context;
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
public void setTrashbinFiles(List<Object> trashbinFiles, boolean clear) {
@ -226,8 +222,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private void setThumbnail(TrashbinFile file, ImageView thumbnailView) {
if (file.isFolder()) {
thumbnailView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
// Thumbnail in cache?
@ -273,8 +268,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
file.getFileName(),
user,
context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
}
}
}

View file

@ -44,6 +44,7 @@ import com.owncloud.android.utils.MimeTypeUtil
import com.owncloud.android.utils.glide.CustomGlideStreamLoader
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
@Suppress("LongParameterList")
class UnifiedSearchItemViewHolder(
@ -54,7 +55,7 @@ class UnifiedSearchItemViewHolder(
private val listInterface: UnifiedSearchListInterface,
val context: Context,
private val themeColorUtils: ThemeColorUtils,
private val themeDrawableUtils: ThemeDrawableUtils
private val viewThemeUtils: ViewThemeUtils
) :
SectionedViewHolder(binding.root) {
@ -101,7 +102,7 @@ class UnifiedSearchItemViewHolder(
startsWith("icon-deck") ->
ResourcesCompat.getDrawable(context.resources, R.drawable.ic_deck, null)
else ->
MimeTypeUtil.getFileTypeIcon(mimetype, entry.title, context, themeColorUtils, themeDrawableUtils)
MimeTypeUtil.getFileTypeIcon(mimetype, entry.title, context, viewThemeUtils)
}
}
val color = themeColorUtils.primaryColor(context)

View file

@ -42,6 +42,7 @@ import com.owncloud.android.ui.interfaces.UnifiedSearchListInterface
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchSection
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
/**
* This Adapter populates a SectionedRecyclerView with search results by unified search
@ -54,7 +55,7 @@ class UnifiedSearchListAdapter(
private val clientFactory: ClientFactory,
private val context: Context,
private val themeColorUtils: ThemeColorUtils,
private val themeDrawableUtils: ThemeDrawableUtils
private val viewThemeUtils: ViewThemeUtils
) : SectionedRecyclerViewAdapter<SectionedViewHolder>() {
companion object {
private const val VIEW_TYPE_EMPTY = Int.MAX_VALUE
@ -95,7 +96,7 @@ class UnifiedSearchListAdapter(
listInterface,
context,
themeColorUtils,
themeDrawableUtils
viewThemeUtils
)
}
VIEW_TYPE_EMPTY -> {

View file

@ -493,8 +493,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
fileName,
user,
parentActivity,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
itemViewHolder.binding.thumbnail.setImageDrawable(icon);
}
}

View file

@ -40,6 +40,7 @@ import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.util.HashMap;
import java.util.List;
@ -51,8 +52,7 @@ public class UploaderAdapter extends SimpleAdapter {
private final User user;
private final FileDataStorageManager mStorageManager;
private final LayoutInflater inflater;
private final ThemeColorUtils themeColorUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
public UploaderAdapter(Context context,
List<? extends Map<String, ?>> data,
@ -61,15 +61,13 @@ public class UploaderAdapter extends SimpleAdapter {
int[] to,
FileDataStorageManager storageManager,
User user,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
super(context, data, resource, from, to);
this.user = user;
mStorageManager = storageManager;
mContext = context;
inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.themeColorUtils = themeColorUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
@Override
@ -112,8 +110,7 @@ public class UploaderAdapter extends SimpleAdapter {
user,
file.getMountType(),
mContext,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
fileIcon.setImageDrawable(icon);
} else {
// get Thumbnail if file is image
@ -150,8 +147,7 @@ public class UploaderAdapter extends SimpleAdapter {
file.getFileName(),
user,
mContext,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
fileIcon.setImageDrawable(icon);
}
}

View file

@ -167,7 +167,7 @@ class ChooseTemplateDialogFragment : DialogFragment(), View.OnClickListener, Tem
currentAccount,
clientFactory,
themeColorUtils,
themeDrawableUtils
viewThemeUtils
)
binding.list.adapter = adapter

View file

@ -198,8 +198,7 @@ public class ConflictsResolveDialog extends DialogFragment implements Injectable
LocalFileListAdapter.setThumbnail(newFile,
binding.newThumbnail,
getContext(),
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
// set info for existing file
binding.existingSize.setText(DisplayUtils.bytesToHumanReadable(existingFile.getFileLength()));
@ -217,8 +216,7 @@ public class ConflictsResolveDialog extends DialogFragment implements Injectable
getContext(),
null,
null,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
View.OnClickListener checkBoxClickListener = v ->
positiveButton.setEnabled(binding.newCheckbox.isChecked() || binding.existingCheckbox.isChecked());

View file

@ -240,8 +240,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
this,
this,
clientFactory,
themeColorUtils,
themeDrawableUtils
viewThemeUtils
);
binding.list.setAdapter(adapter);

View file

@ -138,7 +138,8 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
preferences,
mContainerActivity,
themeColorUtils,
themeDrawableUtils);
themeDrawableUtils,
viewThemeUtils);
setRecyclerViewAdapter(mAdapter);

View file

@ -45,6 +45,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import javax.inject.Inject;
@ -62,6 +63,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
private final ThemeColorUtils themeColorUtils;
private final ThemeUtils themeUtils;
private final ThemeDrawableUtils themeDrawableUtils;
private final ViewThemeUtils viewThemeUtils;
public OCFileListBottomSheetDialog(FileActivity fileActivity,
@ -71,7 +73,8 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
OCFile file,
ThemeColorUtils themeColorUtils,
ThemeUtils themeUtils,
ThemeDrawableUtils themeDrawableUtils) {
ThemeDrawableUtils themeDrawableUtils,
ViewThemeUtils viewThemeUtils) {
super(fileActivity);
this.actions = actions;
this.fileActivity = fileActivity;
@ -81,6 +84,7 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
this.themeColorUtils = themeColorUtils;
this.themeUtils = themeUtils;
this.themeDrawableUtils = themeDrawableUtils;
this.viewThemeUtils = viewThemeUtils;
}
@Override
@ -93,11 +97,14 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int primaryColor = themeColorUtils.primaryColor(getContext(), true);
themeDrawableUtils.tintDrawable(binding.menuIconUploadFiles.getDrawable(), primaryColor);
themeDrawableUtils.tintDrawable(binding.menuIconUploadFromApp.getDrawable(), primaryColor);
themeDrawableUtils.tintDrawable(binding.menuIconDirectCameraUpload.getDrawable(), primaryColor);
themeDrawableUtils.tintDrawable(binding.menuIconMkdir.getDrawable(), primaryColor);
viewThemeUtils.platform.themeDialog(binding.getRoot());
viewThemeUtils.platform.colorImageView(binding.menuIconUploadFiles);
viewThemeUtils.platform.colorImageView(binding.menuIconUploadFromApp);
viewThemeUtils.platform.colorImageView(binding.menuIconDirectCameraUpload);
viewThemeUtils.platform.colorImageView(binding.menuIconScanDocUpload);
viewThemeUtils.platform.colorImageView(binding.menuIconMkdir);
viewThemeUtils.platform.colorImageView(binding.menuIconAddFolderInfo);
binding.addToCloud.setText(getContext().getResources().getString(R.string.add_to_cloud,
themeUtils.getDefaultDisplayNameForRootFolder(getContext())));
@ -136,9 +143,8 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog implements In
MimeTypeUtil.getFileTypeIcon(creator.getMimetype(),
creator.getExtension(),
user,
getContext(),
themeColorUtils,
themeDrawableUtils));
creatorViewBinding.creatorThumbnail.getContext(),
viewThemeUtils));
creatorView.setOnClickListener(v -> {
actions.showTemplate(creator, creatorViewBinding.creatorName.getText().toString());

View file

@ -32,6 +32,7 @@ import com.owncloud.android.ui.activity.FileActivity
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.ThemeUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
import javax.inject.Inject
class OCFileListBottomSheetDialogFragment(
@ -51,6 +52,9 @@ class OCFileListBottomSheetDialogFragment(
@Inject
lateinit var themeDrawableUtils: ThemeDrawableUtils
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return OCFileListBottomSheetDialog(
fileActivity,
@ -60,7 +64,8 @@ class OCFileListBottomSheetDialogFragment(
file,
themeColorUtils,
themeUtils,
themeDrawableUtils
themeDrawableUtils,
viewThemeUtils
)
}
}

View file

@ -56,6 +56,7 @@ import com.owncloud.android.ui.unifiedsearch.UnifiedSearchViewModel
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
import javax.inject.Inject
/**
@ -86,6 +87,9 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
@Inject
lateinit var themeColorUtils: ThemeColorUtils
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@Inject
lateinit var themeDrawableUtils: ThemeDrawableUtils
@ -187,7 +191,7 @@ class UnifiedSearchFragment : Fragment(), Injectable, UnifiedSearchListInterface
clientFactory,
requireContext(),
themeColorUtils,
themeDrawableUtils
viewThemeUtils
)
adapter.shouldShowFooters(true)
adapter.setLayoutManager(gridLayoutManager)

View file

@ -144,8 +144,7 @@ public class TrashbinActivity extends DrawerActivity implements
preferences,
this,
getUser().orElse(accountProvider.getUser()),
themeColorUtils,
themeDrawableUtils
viewThemeUtils
);
recyclerView.setAdapter(trashbinListAdapter);
recyclerView.setHasFixedSize(true);

View file

@ -82,6 +82,7 @@ import com.owncloud.android.utils.svg.SvgDecoder;
import com.owncloud.android.utils.svg.SvgDrawableTranscoder;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import org.greenrobot.eventbus.EventBus;
@ -846,8 +847,7 @@ public final class DisplayUtils {
Context context,
LoaderImageView shimmerThumbnail,
AppPreferences preferences,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
if (file.isFolder()) {
stopShimmer(shimmerThumbnail, thumbnailView);
thumbnailView.setImageDrawable(MimeTypeUtil
@ -857,8 +857,7 @@ public final class DisplayUtils {
file.isGroupFolder(),
file.getMountType(),
context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
} else {
if (file.getRemoteId() != null && file.isPreviewAvailable()) {
// Thumbnail in cache?
@ -901,8 +900,7 @@ public final class DisplayUtils {
file.getFileName(),
user,
context,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
if (drawable == null) {
drawable = ResourcesCompat.getDrawable(context.getResources(),
R.drawable.file_image,
@ -954,8 +952,7 @@ public final class DisplayUtils {
file.getFileName(),
user,
context,
themeColorUtils,
themeDrawableUtils));
viewThemeUtils));
}
}
}

View file

@ -28,8 +28,7 @@ import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils;
import java.io.File;
import java.util.ArrayList;
@ -95,9 +94,8 @@ public final class MimeTypeUtil {
public static Drawable getFileTypeIcon(String mimetype,
String filename,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
return getFileTypeIcon(mimetype, filename, null, context, themeColorUtils, themeDrawableUtils);
ViewThemeUtils viewThemeUtils) {
return getFileTypeIcon(mimetype, filename, null, context, viewThemeUtils);
}
/**
@ -113,14 +111,13 @@ public final class MimeTypeUtil {
String filename,
@Nullable User user,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
if (context != null) {
int iconId = MimeTypeUtil.getFileTypeIconId(mimetype, filename);
Drawable icon = ContextCompat.getDrawable(context, iconId);
if (R.drawable.file_zip == iconId) {
themeDrawableUtils.tintDrawable(icon, themeColorUtils.primaryColor(user, true, context));
viewThemeUtils.platform.tintPrimaryDrawable(context, icon);
}
return icon;
@ -160,8 +157,7 @@ public final class MimeTypeUtil {
boolean isGroupfolder,
WebdavEntry.MountType mountType,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
return getFolderTypeIcon(isSharedViaUsers,
isSharedViaLink,
isEncrypted,
@ -169,8 +165,7 @@ public final class MimeTypeUtil {
null,
mountType,
context,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
}
/**
@ -189,8 +184,7 @@ public final class MimeTypeUtil {
@Nullable User user,
WebdavEntry.MountType mountType,
Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
int drawableId;
if (isSharedViaLink) {
@ -207,26 +201,22 @@ public final class MimeTypeUtil {
drawableId = R.drawable.folder;
}
int color = themeColorUtils.primaryColor(user != null ? user.toPlatformAccount() : null,
true,
context);
return themeDrawableUtils.tintDrawable(drawableId, color);
Drawable drawable = ContextCompat.getDrawable(context, drawableId);
viewThemeUtils.platform.tintPrimaryDrawable(context, drawable);
return drawable;
}
public static Drawable getDefaultFolderIcon(Context context,
ThemeColorUtils themeColorUtils,
ThemeDrawableUtils themeDrawableUtils) {
ViewThemeUtils viewThemeUtils) {
return getFolderTypeIcon(false,
false,
false,
false,
WebdavEntry.MountType.INTERNAL,
context,
themeColorUtils,
themeDrawableUtils);
viewThemeUtils);
}
/**
* Returns a single MIME type of all the possible, by inspection of the file extension, and taking
* into account the MIME types known by ownCloud first.

View file

@ -32,6 +32,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
import com.owncloud.android.utils.theme.ThemeColorUtils
import com.owncloud.android.utils.theme.ThemeDrawableUtils
import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
import junit.framework.Assert.assertEquals
import org.junit.After
import org.junit.Before
@ -66,6 +67,9 @@ class GalleryAdapterTest {
@Mock
lateinit var themeDrawableUtils: ThemeDrawableUtils
@Mock
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var mocks: AutoCloseable
@Before
@ -89,7 +93,8 @@ class GalleryAdapterTest {
preferences,
transferServiceGetter,
themeColorUtils,
themeDrawableUtils
themeDrawableUtils,
viewThemeUtils
)
val list = listOf(