Add DrawableUtil

Signed-off-by: Alper Ozturk <alperozturk@lions-macbook.local>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
Alper Ozturk 2023-10-03 14:23:17 +02:00 committed by alperozturk
parent 80cf6f04bd
commit 32b8993331
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
2 changed files with 18 additions and 9 deletions

View file

@ -41,6 +41,7 @@ import com.owncloud.android.lib.resources.files.model.GeoLocation;
import com.owncloud.android.lib.resources.files.model.ImageDimension;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.lib.resources.shares.ShareeUser;
import com.owncloud.android.utils.DrawableUtil;
import com.owncloud.android.utils.MimeType;
import com.owncloud.android.utils.theme.ViewThemeUtils;
@ -670,15 +671,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
}
Drawable overlayDrawable = ContextCompat.getDrawable(context, overlayIconId);
return addDrawableAsOverlay(folderDrawable, overlayDrawable);
}
private LayerDrawable addDrawableAsOverlay(Drawable backgroundDrawable, Drawable overlayDrawable) {
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { backgroundDrawable, overlayDrawable } );
layerDrawable.setLayerGravity(1, Gravity.CENTER);
layerDrawable.setLayerInsetTop(1, 6);
return layerDrawable;
DrawableUtil drawableUtil = new DrawableUtil();
return drawableUtil.addDrawableAsOverlay(folderDrawable, overlayDrawable, 6);
}
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {

View file

@ -0,0 +1,15 @@
package com.owncloud.android.utils
import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable
import android.view.Gravity
class DrawableUtil {
fun addDrawableAsOverlay(backgroundDrawable: Drawable, overlayDrawable: Drawable, topMargin: Int = 6): LayerDrawable {
val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, overlayDrawable))
layerDrawable.setLayerGravity(1, Gravity.CENTER)
layerDrawable.setLayerInsetTop(1, topMargin)
return layerDrawable
}
}