From 2bd02914ea4ed23fc4f7fd9707e0398320a7a02f Mon Sep 17 00:00:00 2001 From: Arun Rajagopalan Date: Wed, 15 May 2019 06:13:12 -0700 Subject: [PATCH] Add bounds to pet/mount share drawables (#1150) * Set bounds on pet/mount share drawable * Variablizing image side lengths --- .../android/habitica/ui/activities/MainActivity.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/MainActivity.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/MainActivity.kt index f603b2dff..ecb75b2be 100755 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/MainActivity.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/activities/MainActivity.kt @@ -523,9 +523,11 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction { .setNeutralButton(R.string.share) { hatchingDialog, _ -> val event1 = ShareEvent() event1.sharedMessage = getString(R.string.share_hatched, potionName, eggName) + " https://habitica.com/social/hatch-pet" - val sharedImage = Bitmap.createBitmap(140, 140, Bitmap.Config.ARGB_8888) + val petImageSideLength = 140 + val sharedImage = Bitmap.createBitmap(petImageSideLength, petImageSideLength, Bitmap.Config.ARGB_8888) val canvas = Canvas(sharedImage) canvas.drawColor(ContextCompat.getColor(this, R.color.brand_300)) + petImageView?.drawable?.setBounds(0, 0, petImageSideLength, petImageSideLength) petImageView?.drawable?.draw(canvas) event1.shareImage = sharedImage EventBus.getDefault().post(event1) @@ -557,9 +559,11 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction { .setNeutralButton(R.string.share) { hatchingDialog, _ -> val event1 = ShareEvent() event1.sharedMessage = getString(R.string.share_raised, pet.text) + " https://habitica.com/social/raise-pet" - val sharedImage = Bitmap.createBitmap(99, 99, Bitmap.Config.ARGB_8888) + val mountImageSideLength = 99 + val sharedImage = Bitmap.createBitmap(mountImageSideLength, mountImageSideLength, Bitmap.Config.ARGB_8888) val canvas = Canvas(sharedImage) canvas.drawColor(ContextCompat.getColor(this, R.color.brand_300)) + mountImageView.drawable.setBounds(0, 0, mountImageSideLength, mountImageSideLength) mountImageView.drawable.draw(canvas) event1.shareImage = sharedImage EventBus.getDefault().post(event1)