aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2019-11-10 14:52:00 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2019-11-10 14:55:53 +0100
commit904cc18ec20e2fa1841b76f688dbffd4e9c861d0 (patch)
tree247ea49a9a4740dd3b98b22447c58fd3c5f51ce8 /src
parent189ca534ac477b96f5c71a622b0791aa8880f650 (diff)
show overlay to set avatar at the right bottom corner
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java16
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/AvatarWorkerTask.java2
2 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 17e139c59..a074eca4f 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -49,6 +49,7 @@ import java.net.URL;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.security.acl.LastOwnerException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -683,12 +684,23 @@ public class FileBackend {
}
public void drawOverlay(final Bitmap bitmap, final int resource, final float factor) {
+ drawOverlay(bitmap, resource, factor, false);
+ }
+
+ public void drawOverlay(final Bitmap bitmap, final int resource, final float factor, final boolean corner) {
Bitmap overlay = BitmapFactory.decodeResource(mXmppConnectionService.getResources(), resource);
Canvas canvas = new Canvas(bitmap);
float targetSize = Math.min(canvas.getWidth(), canvas.getHeight()) * factor;
Log.d(Config.LOGTAG, "target size overlay: " + targetSize + " overlay bitmap size was " + overlay.getHeight());
- float left = (canvas.getWidth() - targetSize) / 2.0f;
- float top = (canvas.getHeight() - targetSize) / 2.0f;
+ float left;
+ float top;
+ if (corner) {
+ left = canvas.getWidth() - targetSize;
+ top = canvas.getHeight() - targetSize;
+ } else {
+ left = (canvas.getWidth() - targetSize) / 2.0f;
+ top = (canvas.getHeight() - targetSize) / 2.0f;
+ }
RectF dst = new RectF(left, top, left + targetSize - 1, top + targetSize - 1);
canvas.drawBitmap(overlay, null, dst, createAntiAliasingPaint());
}
diff --git a/src/main/java/de/pixart/messenger/ui/util/AvatarWorkerTask.java b/src/main/java/de/pixart/messenger/ui/util/AvatarWorkerTask.java
index 738f387de..4898cf327 100644
--- a/src/main/java/de/pixart/messenger/ui/util/AvatarWorkerTask.java
+++ b/src/main/java/de/pixart/messenger/ui/util/AvatarWorkerTask.java
@@ -87,7 +87,7 @@ public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void,
if (bm != null) {
cancelPotentialWork(avatarable, imageView);
if (overlay) {
- activity.xmppConnectionService.fileBackend.drawOverlay(bm, R.drawable.pencil_overlay, 1.0f);
+ activity.xmppConnectionService.fileBackend.drawOverlay(bm, R.drawable.pencil_overlay, 0.35f, true);
imageView.setImageBitmap(bm);
} else {
imageView.setImageBitmap(bm);