From a7d9742e86d0c60fcc2e46fdd4af3fd8272b12b3 Mon Sep 17 00:00:00 2001 From: Mattia Date: Tue, 21 Mar 2017 15:49:39 +0100 Subject: [PATCH] =?UTF-8?q?Aggiunta=20possibilit=C3=A0=20di=20modificare?= =?UTF-8?q?=20dimensioni=20immagine=20scattata/scelta=20da=20galleria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- androidbase-account/build.gradle | 2 +- androidbase-adapter/build.gradle | 2 +- .../androidbase/activity/PickerActivity.java | 27 ++++++++++++++++--- androidbase-gallery/build.gradle | 4 +-- androidbase-tutorial/build.gradle | 2 +- androidbase-webservice/build.gradle | 2 +- androidbase/build.gradle | 14 +++++----- 7 files changed, 37 insertions(+), 16 deletions(-) diff --git a/androidbase-account/build.gradle b/androidbase-account/build.gradle index 1964f78..990089f 100644 --- a/androidbase-account/build.gradle +++ b/androidbase-account/build.gradle @@ -28,6 +28,6 @@ dependencies { }) compile 'com.facebook.android:facebook-android-sdk:4.18.0' compile 'com.google.android.gms:play-services-auth:10.2.0' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' testCompile 'junit:junit:4.12' } diff --git a/androidbase-adapter/build.gradle b/androidbase-adapter/build.gradle index cf67840..a6e88f3 100644 --- a/androidbase-adapter/build.gradle +++ b/androidbase-adapter/build.gradle @@ -26,6 +26,6 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' testCompile 'junit:junit:4.12' } diff --git a/androidbase-core/src/main/java/com/mr_apps/androidbase/activity/PickerActivity.java b/androidbase-core/src/main/java/com/mr_apps/androidbase/activity/PickerActivity.java index 9ff9a68..961eaf2 100644 --- a/androidbase-core/src/main/java/com/mr_apps/androidbase/activity/PickerActivity.java +++ b/androidbase-core/src/main/java/com/mr_apps/androidbase/activity/PickerActivity.java @@ -37,6 +37,7 @@ */ public abstract class PickerActivity extends LocationActivity { + private static final int COMPRESSION_QUALITY = 80; private static final int COMPRESSION_WIDTH = 1280; private static final int COMPRESSION_HEIGHT = 1280; @@ -60,7 +61,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { private static final int actionPickAudio = 5000; private static final int actionRecordAudio = 6000; - private int qualityImage = 80; + private int qualityImage = COMPRESSION_QUALITY; + private int imageWidth = COMPRESSION_WIDTH; + private int imageHeight = COMPRESSION_HEIGHT; /** * Sets the quality of the image taken or chosen from gallery @@ -71,6 +74,24 @@ public void setQualityImage(int qualityImage) { this.qualityImage = qualityImage; } + /** + * Sets the width of the image taken or chosen from gallery + * + * @param imageWidth the width of the image + */ + public void setImageWidth(int imageWidth) { + this.imageWidth = imageWidth; + } + + /** + * Sets the height of the image taken or chosen from gallery + * + * @param imageHeight the height of the image + */ + public void setImageHeight(int imageHeight) { + this.imageHeight = imageHeight; + } + private boolean saveInInternalStorage = false; /** @@ -444,7 +465,7 @@ private void onImageSelected(Bitmap bitmap) { try { - Bitmap resizedBitmap = BitmapUtils.scaleBitmap(bitmap, COMPRESSION_WIDTH, COMPRESSION_HEIGHT); + Bitmap resizedBitmap = BitmapUtils.scaleBitmap(bitmap, imageWidth, imageHeight); OutputStream os = new BufferedOutputStream(new FileOutputStream(file)); resizedBitmap.compress(Bitmap.CompressFormat.JPEG, qualityImage, os); @@ -517,7 +538,7 @@ private void handleTempUri(Uri tempUri) { ExifInterface exif = new ExifInterface(tempUri.getPath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); - Bitmap resizedBitmap = BitmapUtils.scaleBitmap(bitmap, COMPRESSION_WIDTH, COMPRESSION_HEIGHT); + Bitmap resizedBitmap = BitmapUtils.scaleBitmap(bitmap, imageWidth, imageHeight); Bitmap bitmap1 = BitmapUtils.rotateBitmap(resizedBitmap, orientation); diff --git a/androidbase-gallery/build.gradle b/androidbase-gallery/build.gradle index e546c3b..32eb59d 100644 --- a/androidbase-gallery/build.gradle +++ b/androidbase-gallery/build.gradle @@ -28,7 +28,7 @@ dependencies { }) compile 'com.github.chrisbanes:PhotoView:1.2.6' compile 'com.github.bumptech.glide:glide:3.7.0' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-share:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-share:1.1.3beta' testCompile 'junit:junit:4.12' } diff --git a/androidbase-tutorial/build.gradle b/androidbase-tutorial/build.gradle index 6e140b3..d1fd0df 100644 --- a/androidbase-tutorial/build.gradle +++ b/androidbase-tutorial/build.gradle @@ -27,6 +27,6 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.viewpagerindicator:library:2.4.1' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' testCompile 'junit:junit:4.12' } diff --git a/androidbase-webservice/build.gradle b/androidbase-webservice/build.gradle index cf67840..a6e88f3 100644 --- a/androidbase-webservice/build.gradle +++ b/androidbase-webservice/build.gradle @@ -26,6 +26,6 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' testCompile 'junit:junit:4.12' } diff --git a/androidbase/build.gradle b/androidbase/build.gradle index 1a48e77..019c7b7 100644 --- a/androidbase/build.gradle +++ b/androidbase/build.gradle @@ -48,11 +48,11 @@ artifacts { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-account:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-gallery:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-share:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-tutorial:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-webservice:1.1.2' - compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-adapter:1.1.2' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-core:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-account:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-gallery:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-share:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-tutorial:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-webservice:1.1.3beta' + compile 'com.github.MrAPPs-RSM.MrAppsAndroidBase:androidbase-adapter:1.1.3beta' }