Commit 4b4602dc authored by Alan McNatty's avatar Alan McNatty

Resolved issues with camera - if the intent is null just use the imageUri...

Resolved issues with camera - if the intent is null just use the imageUri created when the camera intent was raised (some phones don't populkate correctly so you have to remember it :(...)
parent da814310
......@@ -25,6 +25,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
/*
* The GlobalResources class is taken from the GlobalResources class
* written by Russel Stewart (rnstewart@gmail.com) as part of the Flickr Free
......@@ -43,6 +45,8 @@ public class GlobalResources {
public static int ERROR_DELAY_MS = 1000;
public static Uri TEMP_PHOTO_URI;
public static final int UPLOADER_ID = 100;
public static final int UPLOADING_ID = UPLOADER_ID + 100;
......
......@@ -338,14 +338,14 @@ public class Utils {
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera for MaharaDroid");
//imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
Uri imageUri = context.getContentResolver().insert(
GlobalResources.TEMP_PHOTO_URI = context.getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
if ( VERBOSE ) Log.v(TAG, "imageUri is '" + imageUri.toString() + "'");
if ( VERBOSE ) Log.v(TAG, "imageUri is '" + GlobalResources.TEMP_PHOTO_URI.toString() + "'");
//create new Intent
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
i.putExtra(MediaStore.EXTRA_OUTPUT, GlobalResources.TEMP_PHOTO_URI);
i.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
return i;
}
......
......@@ -209,27 +209,26 @@ public class ArtefactExpandableListAdapterActivity extends Activity implements O
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if ( intent == null ) {
Log.e(TAG, "Empty intent received from request code '" + requestCode + "'");
Toast.makeText(mContext, getString(R.string.capturefailed), Toast.LENGTH_LONG);
return;
}
if (resultCode == Activity.RESULT_OK) {
String imageFile = null;
Intent i = new Intent(this, ArtifactSettingsActivity.class);
Uri uri;
switch (requestCode) {
switch (requestCode) {
case GlobalResources.REQ_CAMERA_RETURN:
uri = (Uri) intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
i.putExtra("uri", new String[] { uri.toString() });
startActivity(i);
if ( intent == null ) {
Log.w(TAG, "Empty intent received from request code '" + requestCode + "'");
imageFile = GlobalResources.TEMP_PHOTO_URI.toString();
} else {
imageFile = ((Uri) intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT)).toString();
}
break;
case GlobalResources.REQ_GALLERY_RETURN:
uri = intent.getData();
i.putExtra("uri", new String[] { uri.toString() });
startActivity(i);
imageFile = intent.getData().toString();
break;
}
i.putExtra("uri", new String[] { imageFile });
startActivity(i);
}
}
......
......@@ -476,38 +476,31 @@ public class ArtifactSettingsActivity extends Activity implements OnClickListene
return true;
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if ( intent == null ) {
Log.e(TAG, "Empty intent received from request code '" + requestCode + "'");
Toast.makeText(mContext, getString(R.string.capturefailed), Toast.LENGTH_LONG);
return;
}
if (resultCode == Activity.RESULT_OK) {
Uri uri;
String imageFile = null;
switch (requestCode) {
case GlobalResources.REQ_CAMERA_RETURN:
if ( ! intent.hasExtra(MediaStore.EXTRA_OUTPUT) )
break;
uri = (Uri) intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
if ( a == null ) {
a = new Artefact(uri.toString());
if ( intent == null ) {
Log.w(TAG, "Empty intent received from request code '" + requestCode + "'");
imageFile = GlobalResources.TEMP_PHOTO_URI.toString();
} else {
if ( intent.hasExtra(MediaStore.EXTRA_OUTPUT) ) {
imageFile = ((Uri) intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT)).toString();
}
}
a.setFilename(uri.toString());
setDefaultTitle(a.getBaseFilename(mContext));
//a.save(mContext); // don't auto save - they might want to cancel
uris = new String[] { uri.toString() };
break;
case GlobalResources.REQ_GALLERY_RETURN:
uri = intent.getData();
if ( a == null ) {
a = new Artefact(uri.toString());
}
a.setFilename(uri.toString());
//a.save(mContext); // don't auto save - they might want to cancel
setDefaultTitle(a.getBaseFilename(mContext));
uris = new String[] { uri.toString() };
imageFile = intent.getData().toString();
break;
}
if ( a == null ) {
a = new Artefact(imageFile);
}
a.setFilename(imageFile);
//a.save(mContext); // don't auto save - they might want to cancel
setDefaultTitle(a.getBaseFilename(mContext));
uris = new String[] { imageFile };
}
}
public class TagChooser implements OnItemSelectedListener {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment