From 9fa545fcd028230eda363768d650986f519d0b39 Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Sat, 15 Oct 2016 18:31:15 -0500 Subject: [PATCH] Image previews essentially finished --- app/build.gradle | 6 ++-- .../FrameWidgetConfigureActivity.java | 32 +++++++++++++++--- .../example_appwidget_preview2.png | Bin 0 -> 16732 bytes .../res/layout/frame_widget_configure.xml | 4 ++- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/drawable-nodpi/example_appwidget_preview2.png diff --git a/app/build.gradle b/app/build.gradle index 0903745..29de673 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion "24.0.3" defaultConfig { applicationId "horse.jaeil.microframe" - minSdkVersion 15 + minSdkVersion 23 targetSdkVersion 23 versionCode 1 versionName "1.0" @@ -17,10 +17,12 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + productFlavors { + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) diff --git a/app/src/main/java/horse/jaeil/microframe/FrameWidgetConfigureActivity.java b/app/src/main/java/horse/jaeil/microframe/FrameWidgetConfigureActivity.java index 90dfe60..0d924e7 100644 --- a/app/src/main/java/horse/jaeil/microframe/FrameWidgetConfigureActivity.java +++ b/app/src/main/java/horse/jaeil/microframe/FrameWidgetConfigureActivity.java @@ -5,11 +5,17 @@ import android.appwidget.AppWidgetManager; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.ImageView; +import java.io.FileNotFoundException; +import java.io.InputStream; + /** * The configuration screen for the {@link FrameWidget FrameWidget} AppWidget. */ @@ -17,6 +23,7 @@ public class FrameWidgetConfigureActivity extends Activity { // private static final String PREFS_NAME = "horse.jaeil.microframe.FrameWidget"; // private static final String PREF_PREFIX_KEY = "appwidget_"; + private static final String TAG = "FrameWidgetConfigure"; private static final int REQUEST_IMAGE_GET = 1; int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; View.OnClickListener mSelectClickListener = new View.OnClickListener() { @@ -30,8 +37,9 @@ public class FrameWidgetConfigureActivity extends Activity { .setType("image/*"); if (intent.resolveActivity(context.getPackageManager()) != null) { startActivityForResult(intent, REQUEST_IMAGE_GET); + Log.d(TAG, "Started selector activity"); } -// + // // When the button is clicked, store the string locally // String widgetText = mAppWidgetText.getText().toString(); // saveTitlePref(context, mAppWidgetId, widgetText); @@ -57,13 +65,29 @@ public class FrameWidgetConfigureActivity extends Activity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { + Log.d(TAG, "Received Activity result"); + if (requestCode == REQUEST_IMAGE_GET && resultCode == RESULT_OK) { - Bitmap thumbnail = data.getParcelableExtra("data"); +// Bitmap thumbnail = data.getParcelableExtra("data"); Uri fullPhotoUri = data.getData(); - // Set the preview image + Log.i(TAG, fullPhotoUri.toString()); + + Drawable drawable; + try { + InputStream inputStream = getContentResolver().openInputStream(fullPhotoUri); + drawable = Drawable.createFromStream(inputStream, fullPhotoUri.toString()); + } catch (FileNotFoundException e) { + Log.e(TAG, "Selected image was not found! Now it's going to crash..."); + drawable = null; + } + ImageView preview = (ImageView) findViewById(R.id.previewImageView); - preview.setImageBitmap(thumbnail); +// Drawable drawable = new BitmapDrawable(getResources(), thumbnail); +// drawable = Drawable.createFromPath(fullPhotoUri.getPath()); + preview.setImageDrawable(drawable); + + Log.d(TAG, "Set preview image"); } } diff --git a/app/src/main/res/drawable-nodpi/example_appwidget_preview2.png b/app/src/main/res/drawable-nodpi/example_appwidget_preview2.png new file mode 100644 index 0000000000000000000000000000000000000000..62b7fc4d80a20f7bd72dfb7ce7253fb3aaeab90e GIT binary patch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