mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 05:35:39 +03:00
images: slightly rounded corners
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
ae6251bf6f
commit
ef0b0fe9ee
4 changed files with 35 additions and 3 deletions
|
@ -508,7 +508,12 @@ public final class ThumbnailsCacheManager {
|
|||
tagId = String.valueOf(((TrashbinFile) mFile).getRemoteId());
|
||||
}
|
||||
if (String.valueOf(imageView.getTag()).equals(tagId)) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
Resources resources = MainApp.getAppContext().getResources();
|
||||
|
||||
BitmapUtils.setRoundedBitmap(resources,
|
||||
bitmap,
|
||||
resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
|
||||
imageView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
|||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
@ -602,7 +603,13 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail);
|
||||
thumbnailView.setImageBitmap(withOverlay);
|
||||
} else {
|
||||
thumbnailView.setImageBitmap(thumbnail);
|
||||
Resources resources = MainApp.getAppContext().getResources();
|
||||
|
||||
BitmapUtils.setRoundedBitmap(resources,
|
||||
thumbnail,
|
||||
resources.getDimension(R.dimen.file_icon_rounded_corner_radius),
|
||||
thumbnailView);
|
||||
|
||||
}
|
||||
} else {
|
||||
// generate new thumbnail
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
|
@ -376,16 +377,34 @@ public final class BitmapUtils {
|
|||
* @param bitmap the original bitmap
|
||||
* @return the circular bitmap
|
||||
*/
|
||||
public static RoundedBitmapDrawable bitmapToCircularBitmapDrawable(Resources resources, Bitmap bitmap) {
|
||||
public static RoundedBitmapDrawable bitmapToCircularBitmapDrawable(Resources resources,
|
||||
Bitmap bitmap,
|
||||
float radius) {
|
||||
if (bitmap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory.create(resources, bitmap);
|
||||
roundedBitmap.setCircular(true);
|
||||
|
||||
if (radius != -1) {
|
||||
roundedBitmap.setCornerRadius(20);
|
||||
}
|
||||
|
||||
return roundedBitmap;
|
||||
}
|
||||
|
||||
public static RoundedBitmapDrawable bitmapToCircularBitmapDrawable(Resources resources, Bitmap bitmap) {
|
||||
return bitmapToCircularBitmapDrawable(resources, bitmap, -1);
|
||||
}
|
||||
|
||||
public static void setRoundedBitmap(Resources resources, Bitmap bitmap, float radius, ImageView imageView) {
|
||||
|
||||
imageView.setImageDrawable(BitmapUtils.bitmapToCircularBitmapDrawable(resources,
|
||||
bitmap,
|
||||
radius));
|
||||
}
|
||||
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<dimen name="list_item_avatar_icon_radius">20dp</dimen>
|
||||
<dimen name="file_icon_size">40dp</dimen>
|
||||
<dimen name="file_icon_size_grid">128dp</dimen>
|
||||
<dimen name="file_icon_rounded_corner_radius">20dp</dimen>
|
||||
<dimen name="file_avatar_size">128dp</dimen>
|
||||
<dimen name="standard_padding">16dp</dimen>
|
||||
<dimen name="standard_double_padding">32dp</dimen>
|
||||
|
|
Loading…
Reference in a new issue