Bugfix: creating waypoint from camera works now.

Introduced in commit 677b691ef1
This commit is contained in:
Dennis Guse
2019-08-26 22:57:00 +02:00
parent 22b7962940
commit 6e410e049d
2 changed files with 12 additions and 4 deletions
@@ -24,6 +24,7 @@ import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Pair;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -321,7 +322,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE);
return false;
}
startActivityForResult(IntentUtils.createTakePictureIntent(this, trackId), CAMERA_REQUEST_CODE);
createWaypointWithPicture();
return true;
case R.id.track_detail_menu_show_on_map:
IntentUtils.showTrackOnMap(this, new long[]{trackId});
@@ -362,7 +363,7 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
Toast.makeText(this, R.string.external_storage_not_writable, Toast.LENGTH_LONG).show();
} else {
startActivityForResult(IntentUtils.createTakePictureIntent(this, trackId), CAMERA_REQUEST_CODE);
createWaypointWithPicture();
}
return;
}
@@ -451,6 +452,12 @@ public class TrackDetailActivity extends AbstractListActivity implements ChooseA
setTitle(title);
}
private void createWaypointWithPicture() {
Pair<Intent, Uri> intentAndPhotoUri = IntentUtils.createTakePictureIntent(this, trackId);
photoUri = intentAndPhotoUri.second;
startActivityForResult(intentAndPhotoUri.first, CAMERA_REQUEST_CODE);
}
public void chooseActivityType(String category) {
ChooseActivityTypeDialogFragment.newInstance(category).show(getSupportFragmentManager(), ChooseActivityTypeDialogFragment.CHOOSE_ACTIVITY_TYPE_DIALOG_TAG);
}
@@ -136,7 +136,7 @@ public class IntentUtils {
* @param context the context
* @param trackId the track id
*/
public static Intent createTakePictureIntent(Context context, long trackId) {
public static Pair<Intent, Uri> createTakePictureIntent(Context context, long trackId) {
File dir = FileUtils.getPhotoDir(trackId);
FileUtils.ensureDirectoryExists(dir);
@@ -145,7 +145,8 @@ public class IntentUtils {
Uri photoUri = FileProvider.getUriForFile(context, FileUtils.FILEPROVIDER, file);
Log.d(TAG, "Taking photo to URI: " + photoUri);
return new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
return new Pair<>(intent, photoUri);
}
}