mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Add DrawableUtil
Signed-off-by: Alper Ozturk <alperozturk@lions-macbook.local> Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
80cf6f04bd
commit
32b8993331
2 changed files with 18 additions and 9 deletions
|
@ -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>() {
|
||||
|
|
15
app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt
Normal file
15
app/src/main/java/com/owncloud/android/utils/DrawableUtil.kt
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue