forked from upstream-mirrors/OpenTracks
Bugfix: prevent crash when creating a marker (no camera or gallery application present).
Fixes #1561.
This commit is contained in:
@@ -12,6 +12,8 @@ public class UintUtilsTest {
|
|||||||
assertEquals(1, UintUtils.diff(2, 1, UintUtils.UINT16_MAX));
|
assertEquals(1, UintUtils.diff(2, 1, UintUtils.UINT16_MAX));
|
||||||
assertEquals(3, UintUtils.diff(5, 2, UintUtils.UINT16_MAX));
|
assertEquals(3, UintUtils.diff(5, 2, UintUtils.UINT16_MAX));
|
||||||
assertEquals(65534, UintUtils.diff(1, 2, UintUtils.UINT16_MAX));
|
assertEquals(65534, UintUtils.diff(1, 2, UintUtils.UINT16_MAX));
|
||||||
|
// assertEquals(65535, UintUtils.diff(0, 1, UintUtils.UINT16_MAX));
|
||||||
|
assertEquals(65535, UintUtils.UINT16_MAX);
|
||||||
|
|
||||||
assertEquals(65530, UintUtils.diff(UintUtils.UINT16_MAX, 5, UintUtils.UINT16_MAX));
|
assertEquals(65530, UintUtils.diff(UintUtils.UINT16_MAX, 5, UintUtils.UINT16_MAX));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package de.dennisguse.opentracks.ui.markers;
|
package de.dennisguse.opentracks.ui.markers;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -244,7 +245,12 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
private void createMarkerWithPicture() {
|
private void createMarkerWithPicture() {
|
||||||
Pair<Intent, Uri> intentAndPhotoUri = MarkerUtils.createTakePictureIntent(this, getTrackId());
|
Pair<Intent, Uri> intentAndPhotoUri = MarkerUtils.createTakePictureIntent(this, getTrackId());
|
||||||
cameraPhotoUri = intentAndPhotoUri.second;
|
cameraPhotoUri = intentAndPhotoUri.second;
|
||||||
takePictureFromCamera.launch(intentAndPhotoUri.first);
|
|
||||||
|
try {
|
||||||
|
takePictureFromCamera.launch(intentAndPhotoUri.first);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_compatible_camera_installed, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMarkerWithGalleryImage() {
|
private void createMarkerWithGalleryImage() {
|
||||||
@@ -256,6 +262,10 @@ public class MarkerEditActivity extends AbstractActivity {
|
|||||||
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
}
|
}
|
||||||
intent.setType("image/*");
|
intent.setType("image/*");
|
||||||
takePictureFromGallery.launch(intent);
|
try {
|
||||||
|
takePictureFromGallery.launch(intent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_compatible_gallery_installed, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -664,6 +664,8 @@ limitations under the License.
|
|||||||
<string name="field_set_secondary">Secondary</string>
|
<string name="field_set_secondary">Secondary</string>
|
||||||
<string name="field_remove_from_layout">Remove</string>
|
<string name="field_remove_from_layout">Remove</string>
|
||||||
<string name="no_compatible_file_manager_installed">No compatible file manager installed</string>
|
<string name="no_compatible_file_manager_installed">No compatible file manager installed</string>
|
||||||
|
<string name="no_compatible_camera_installed">No compatible camera application installed</string>
|
||||||
|
<string name="no_compatible_gallery_installed">No compatible image gallery application installed</string>
|
||||||
<string name="error_crash_title">%1$s crashed</string>
|
<string name="error_crash_title">%1$s crashed</string>
|
||||||
<string name="share_crash_report">Share crash report</string>
|
<string name="share_crash_report">Share crash report</string>
|
||||||
<string name="report_bug">Report bug</string>
|
<string name="report_bug">Report bug</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user