Tango: Optional sharing to other apps after saving on device

This commit is contained in:
matlabbe
2017-08-31 11:10:46 -04:00
parent 964a052be1
commit 9eac47f7e8

View File

@@ -2346,10 +2346,9 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
exportDir.mkdirs(); exportDir.mkdirs();
final String pathHuman = mWorkingDirectoryHuman + RTABMAP_EXPORT_DIR + fileName + ".zip"; final String pathHuman = mWorkingDirectoryHuman + RTABMAP_EXPORT_DIR + fileName + ".zip";
final String zipOutput = mWorkingDirectory+RTABMAP_EXPORT_DIR+fileName+".zip";
if(RTABMapLib.writeExportedMesh(mWorkingDirectory + RTABMAP_TMP_DIR, RTABMAP_TMP_FILENAME)) if(RTABMapLib.writeExportedMesh(mWorkingDirectory + RTABMAP_TMP_DIR, RTABMAP_TMP_FILENAME))
{ {
final String zipOutput = mWorkingDirectory+RTABMAP_EXPORT_DIR+fileName+".zip";
fileNames = Util.loadFileList(mWorkingDirectory + RTABMAP_TMP_DIR, false); fileNames = Util.loadFileList(mWorkingDirectory + RTABMAP_TMP_DIR, false);
if(fileNames.length > 0) if(fileNames.length > 0)
{ {
@@ -2384,24 +2383,13 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
mProgressDialog.dismiss(); mProgressDialog.dismiss();
mToast.makeText(getActivity(), String.format("Mesh \"%s\" successfully exported!", pathHuman), mToast.LENGTH_LONG).show();
Intent intent = new Intent(getActivity(), RTABMapActivity.class);
// use System.currentTimeMillis() to have a unique ID for the pending intent
PendingIntent pIntent = PendingIntent.getActivity(getActivity(), (int) System.currentTimeMillis(), intent, 0);
// build notification // Send to...
// the addAction re-use the same intent to keep the example short Intent shareIntent = new Intent();
Notification n = new Notification.Builder(getActivity()) shareIntent.setAction(Intent.ACTION_SEND);
.setContentTitle(getString(R.string.app_name)) shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(zipOutput)));
.setContentText(pathHuman + " exported!") shareIntent.setType("application/zip");
.setSmallIcon(R.drawable.ic_launcher) startActivity(Intent.createChooser(shareIntent, String.format("Mesh \"%s\" successfully exported! Share it?", pathHuman)));
.setContentIntent(pIntent)
.setAutoCancel(true).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
resetNoTouchTimer(true); resetNoTouchTimer(true);
} }