diff --git a/app/app.iml b/app/app.iml
index 5a074cf1..f9f7358b 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -70,13 +70,6 @@
-
-
-
-
-
-
-
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 46754a9d..3e9a2678 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -140,11 +140,18 @@
android:resource="@xml/syncadapter" />
+
+
diff --git a/app/src/main/java/com/murrayc/galaxyzoo/app/ClassifyFragment.java b/app/src/main/java/com/murrayc/galaxyzoo/app/ClassifyFragment.java
index a75c77ad..0416f366 100644
--- a/app/src/main/java/com/murrayc/galaxyzoo/app/ClassifyFragment.java
+++ b/app/src/main/java/com/murrayc/galaxyzoo/app/ClassifyFragment.java
@@ -24,7 +24,6 @@
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
diff --git a/app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java b/app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java
index e0823b21..23c7b09b 100644
--- a/app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java
+++ b/app/src/main/java/com/murrayc/galaxyzoo/app/SubjectFragment.java
@@ -19,6 +19,8 @@
package com.murrayc.galaxyzoo.app;
+import android.*;
+import android.Manifest;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
@@ -438,6 +440,11 @@ private void updateShareActionIntent() {
//shareIntent.putExtra(Intent.EXTRA_STREAM, mUriImageStandard);
//shareIntent.setType("image/*");
+ /**
+ * if the image URI is not null, a GetImageBitmapAsyncTask is executed for it, and the returned URI is set as
+ * a stream extra on the intent that will be shared, along with an explicit permission for recieving contexts to
+ * read the content URI, enabling them to access the generated image.
+ */
if (mUriStandardRemote!=null) {
GetImageBitmapAsyncTask getImageBitmapAsyncTask = new GetImageBitmapAsyncTask(){
@Override
@@ -451,18 +458,20 @@ protected void onPostExecute(Uri uri) {
getImageBitmapAsyncTask.execute(mUriStandardRemote);
}
-
- mShareActionProvider.setShareIntent(shareIntent);
}
+ /**
+ *These constants and the verifyStoragePermissions method will gain explicit permission from users to read and write
+ * files on their devices. This will allow us to save an image, that can then be shared to other apps.
+ */
private static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {
- "android.permission.WRITE_EXTERNAL_STORAGE",
- "android.permission.READ_EXTERNAL_STORAGE"
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.READ_EXTERNAL_STORAGE
};
public static void verifyStoragePermissions(Activity activity) {
- int permission = ActivityCompat.checkSelfPermission(activity, "android.permission.WRITE_EXTERNAL_STORAGE");
+ int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
@@ -473,7 +482,13 @@ public static void verifyStoragePermissions(Activity activity) {
}
}
- private class GetImageBitmapAsyncTask extends AsyncTask {
+ /**
+ * This AsyncTask, when executed, takes a String that represents a URI, creates the appropriate Bitmap, saves it to
+ * the external storage area of the app as a jpg, and returns the content Uri of that file as generated by the FileProvider class.
+ * Keeping a single file name ensures that future tasks will write over images previously generated by this task instead
+ * of creating new ones.
+ */
+ private class GetImageBitmapAsyncTask extends AsyncTask {
@Override
protected Uri doInBackground(String... params) {
try {
@@ -481,7 +496,6 @@ protected Uri doInBackground(String... params) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
- //TODO: PROVIDE A MORE DESCRIPTIVE FILENAME HERE IF PLAUSIBLE. Filename will be visible when sharing via certain apps like Gmail etc.
String filename = "galaxy_zoo_image.jpg";
String pathname = Environment.getExternalStorageDirectory() + File.separator + filename;
diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml
new file mode 100644
index 00000000..5aafec20
--- /dev/null
+++ b/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file