Skip to content

Commit 1270ace

Browse files
committed
Use the maxImageWidth when adding new pictures to the editor
1 parent 22dead9 commit 1270ace

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/src/main/kotlin/org/wordpress/aztec/demo/MainActivity.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import android.widget.PopupMenu
2929
import android.widget.TextView
3030
import android.widget.Toast
3131
import org.wordpress.android.util.AppLog
32+
import org.wordpress.android.util.ImageUtils
3233
import org.wordpress.android.util.PermissionUtils
3334
import org.wordpress.android.util.ToastUtils
3435
import org.wordpress.aztec.*
@@ -183,7 +184,6 @@ class MainActivity : AppCompatActivity(),
183184
val options = BitmapFactory.Options()
184185
options.inDensity = DisplayMetrics.DENSITY_DEFAULT
185186
bitmap = BitmapFactory.decodeFile(mediaPath, options)
186-
187187
insertImageAndSimulateUpload(bitmap, mediaPath)
188188
}
189189
REQUEST_MEDIA_PHOTO -> {
@@ -229,14 +229,16 @@ class MainActivity : AppCompatActivity(),
229229
}
230230

231231
fun insertImageAndSimulateUpload(bitmap: Bitmap?, mediaPath: String) {
232+
val bitmapResized = ImageUtils.getScaledBitmapAtLongestSide(bitmap, aztec.visualEditor.maxImagesWidth)
232233
val (id, attrs) = generateAttributesForMedia(mediaPath, isVideo = false)
233-
aztec.visualEditor.insertImage(BitmapDrawable(resources, bitmap), attrs)
234+
aztec.visualEditor.insertImage(BitmapDrawable(resources, bitmapResized), attrs)
234235
insertMediaAndSimulateUpload(id, attrs)
235236
}
236237

237238
fun insertVideoAndSimulateUpload(bitmap: Bitmap?, mediaPath: String) {
239+
val bitmapResized = ImageUtils.getScaledBitmapAtLongestSide(bitmap, aztec.visualEditor.maxImagesWidth)
238240
val (id, attrs) = generateAttributesForMedia(mediaPath, isVideo = true)
239-
aztec.visualEditor.insertVideo(BitmapDrawable(resources, bitmap), attrs)
241+
aztec.visualEditor.insertVideo(BitmapDrawable(resources, bitmapResized), attrs)
240242
insertMediaAndSimulateUpload(id, attrs)
241243
}
242244

0 commit comments

Comments
 (0)