forked from upstream-mirrors/OpenTracks
@@ -60,6 +60,8 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
|
|
||||||
private static final long HIDE_TEXT_DELAY = 4 * UnitConversions.ONE_SECOND_MS;
|
private static final long HIDE_TEXT_DELAY = 4 * UnitConversions.ONE_SECOND_MS;
|
||||||
|
|
||||||
|
private MenuItem shareMarkerImageMenuItem;
|
||||||
|
|
||||||
private ContentProviderUtils contentProviderUtils;
|
private ContentProviderUtils contentProviderUtils;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private ImageView photoView;
|
private ImageView photoView;
|
||||||
@@ -145,6 +147,7 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
// Need to update the waypoint in case returning after an edit
|
// Need to update the waypoint in case returning after an edit
|
||||||
updateWaypoint(true);
|
updateWaypoint(true);
|
||||||
updateUi();
|
updateUi();
|
||||||
|
updateMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,8 +173,14 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.marker_detail, menu);
|
inflater.inflate(R.menu.marker_detail, menu);
|
||||||
|
shareMarkerImageMenuItem = menu.findItem(R.id.marker_detail_share);
|
||||||
updateWaypoint(false);
|
updateWaypoint(false);
|
||||||
|
updateMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMenuItems() {
|
||||||
|
if (shareMarkerImageMenuItem != null)
|
||||||
|
shareMarkerImageMenuItem.setVisible(waypoint.hasPhoto());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -188,6 +197,13 @@ public class MarkerDetailFragment extends Fragment {
|
|||||||
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
|
.putExtra(MarkerEditActivity.EXTRA_MARKER_ID, markerId);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.marker_detail_share:
|
||||||
|
if (waypoint.hasPhoto()) {
|
||||||
|
intent = IntentUtils.newShareImageIntent(getContext(), waypoint.getPhotoURI());
|
||||||
|
intent = Intent.createChooser(intent, null);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
case R.id.marker_detail_delete:
|
case R.id.marker_detail_delete:
|
||||||
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), new long[]{markerId});
|
DeleteMarkerDialogFragment.showDialog(getChildFragmentManager(), new long[]{markerId});
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -107,6 +107,30 @@ public class IntentUtils {
|
|||||||
.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.share_track_share_file_body, trackDescription));
|
.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.share_track_share_file_body, trackDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an intent to share a waypoint image with an app.
|
||||||
|
*
|
||||||
|
* @param context the context.
|
||||||
|
* @param uri uri with the image to share.
|
||||||
|
*/
|
||||||
|
public static Intent newShareImageIntent(Context context, Uri uri) {
|
||||||
|
String mime = context.getContentResolver().getType(uri);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because the #166 bug, when you import KMZ tracks then it creates file:/// from markers with photo.
|
||||||
|
* The photos should be content:/// not file:/// because getType(uri) always returns null for file:///
|
||||||
|
* In .setType, to avoid side effects because the #166 bug described above it checks if mime is null.
|
||||||
|
* If it is then it hardcode "images/*".
|
||||||
|
*/
|
||||||
|
return new Intent(Intent.ACTION_SEND)
|
||||||
|
.setType(mime != null ? mime : "image/*")
|
||||||
|
.setAction(Intent.ACTION_SEND)
|
||||||
|
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
.putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
|
.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_image_subject))
|
||||||
|
.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.share_image_body));
|
||||||
|
}
|
||||||
|
|
||||||
public static void showCoordinateOnMap(Context context, Waypoint waypoint) {
|
public static void showCoordinateOnMap(Context context, Waypoint waypoint) {
|
||||||
showCoordinateOnMap(context, waypoint.getLocation().getLatitude(), waypoint.getLocation().getLongitude(), waypoint.getName());
|
showCoordinateOnMap(context, waypoint.getLocation().getLatitude(), waypoint.getLocation().getLongitude(), waypoint.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ limitations under the License.
|
|||||||
android:icon="@drawable/ic_map_24dp"
|
android:icon="@drawable/ic_map_24dp"
|
||||||
android:title="@string/menu_show_on_map"
|
android:title="@string/menu_show_on_map"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/marker_detail_share"
|
||||||
|
android:icon="@drawable/ic_share_24dp"
|
||||||
|
android:title="@string/menu_share"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/marker_detail_edit"
|
android:id="@+id/marker_detail_edit"
|
||||||
android:icon="@drawable/ic_edit_24dp"
|
android:icon="@drawable/ic_edit_24dp"
|
||||||
|
|||||||
@@ -446,4 +446,7 @@
|
|||||||
<string name="waypoint_type_waterfall">cascada</string>
|
<string name="waypoint_type_waterfall">cascada</string>
|
||||||
<string name="waypoint_type_water_fountain">fuente de agua</string>
|
<string name="waypoint_type_water_fountain">fuente de agua</string>
|
||||||
<string name="waypoint_type_waypoint">punto de referencia</string>
|
<string name="waypoint_type_waypoint">punto de referencia</string>
|
||||||
|
<!-- Share image -->
|
||||||
|
<string name="share_image_subject">Me gustaría compartir una imagen contigo</string>
|
||||||
|
<string name="share_image_body">Creo que esta imagen podría interesarte.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -448,4 +448,7 @@ es vegi el cel. Torneu-ho a provar més tard.</string>
|
|||||||
<string name="waypoint_type_waterfall">salt d\'aigua</string>
|
<string name="waypoint_type_waterfall">salt d\'aigua</string>
|
||||||
<string name="waypoint_type_water_fountain">font d\'aigua</string>
|
<string name="waypoint_type_water_fountain">font d\'aigua</string>
|
||||||
<string name="waypoint_type_waypoint">punt de ruta</string>
|
<string name="waypoint_type_waypoint">punt de ruta</string>
|
||||||
|
<!-- Share image -->
|
||||||
|
<string name="share_image_subject">Vull compartir una imatge amb tu</string>
|
||||||
|
<string name="share_image_body">Crec que aquesta imatge et podria interessar.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -450,4 +450,7 @@
|
|||||||
<string name="waypoint_type_waterfall">cascada</string>
|
<string name="waypoint_type_waterfall">cascada</string>
|
||||||
<string name="waypoint_type_water_fountain">fuente de agua</string>
|
<string name="waypoint_type_water_fountain">fuente de agua</string>
|
||||||
<string name="waypoint_type_waypoint">Punto de ruta</string>
|
<string name="waypoint_type_waypoint">Punto de ruta</string>
|
||||||
|
<!-- Share image -->
|
||||||
|
<string name="share_image_subject">Me gustaría compartir una imagen contigo</string>
|
||||||
|
<string name="share_image_body">Creo que esta imagen te podría interesar.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -595,4 +595,7 @@ limitations under the License.
|
|||||||
<string name="waypoint_type_waterfall">waterfall</string>
|
<string name="waypoint_type_waterfall">waterfall</string>
|
||||||
<string name="waypoint_type_water_fountain">water fountain</string>
|
<string name="waypoint_type_water_fountain">water fountain</string>
|
||||||
<string name="waypoint_type_waypoint">waypoint</string>
|
<string name="waypoint_type_waypoint">waypoint</string>
|
||||||
</resources>
|
<!-- Share image -->
|
||||||
|
<string name="share_image_subject">I would like to share an image with you</string>
|
||||||
|
<string name="share_image_body">I think you might be interested in this image.</string>
|
||||||
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user