Tango: set third person camera by default, scan media file on SD-card when saving database (fixed issue of database just saved not seen with MTP when connected by USB)

This commit is contained in:
matlabbe
2018-10-17 14:05:22 -04:00
parent 4c7b565391
commit 5fc9f859ce
3 changed files with 33 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
<!-- BEGIN_INCLUDE(manifest) --> <!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.introlab.rtabmap" package="com.introlab.rtabmap"
android:versionCode="70" android:versionCode="71"
android:versionName="@RTABMAP_VERSION@"> android:versionName="@RTABMAP_VERSION@">
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />

View File

@@ -102,7 +102,7 @@ Scene::Scene() :
{ {
gesture_camera_ = new tango_gl::GestureCamera(); gesture_camera_ = new tango_gl::GestureCamera();
gesture_camera_->SetCameraType( gesture_camera_->SetCameraType(
tango_gl::GestureCamera::kFirstPerson); tango_gl::GestureCamera::kThirdPersonFollow);
} }
Scene::~Scene() { Scene::~Scene() {

View File

@@ -155,6 +155,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
private boolean mHudVisible = true; private boolean mHudVisible = true;
private int mSavedRenderingType = 0; private int mSavedRenderingType = 0;
private boolean mMenuOpened = false; private boolean mMenuOpened = false;
private long mSavedStamp = 0;
// UI states // UI states
private static enum State { private static enum State {
@@ -535,6 +536,8 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
setCamera(1);
DISABLE_LOG = !( 0 != ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) ); DISABLE_LOG = !( 0 != ( getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE ) );
} }
@@ -2223,6 +2226,19 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
File from = new File(mWorkingDirectory, files[position]); File from = new File(mWorkingDirectory, files[position]);
File to = new File(mWorkingDirectory, fileName + ".db"); File to = new File(mWorkingDirectory, fileName + ".db");
from.renameTo(to); from.renameTo(to);
long stamp = System.currentTimeMillis();
if(stamp-mSavedStamp < 10000)
{
try {
Thread.sleep(10000 - (stamp-mSavedStamp));
}
catch(InterruptedException e){}
}
refreshSystemMediaScanDataBase(getActivity(), files[position]);
refreshSystemMediaScanDataBase(getActivity(), to.getAbsolutePath());
ad.dismiss(); ad.dismiss();
resetNoTouchTimer(true); resetNoTouchTimer(true);
} }
@@ -2245,6 +2261,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
Log.e(TAG, String.format("Yes delete %s!", files[position])); Log.e(TAG, String.format("Yes delete %s!", files[position]));
(new File(mWorkingDirectory+files[position])).delete(); (new File(mWorkingDirectory+files[position])).delete();
refreshSystemMediaScanDataBase(getActivity(), mWorkingDirectory+files[position]);
ad.dismiss(); ad.dismiss();
resetNoTouchTimer(true); resetNoTouchTimer(true);
break; break;
@@ -2461,6 +2478,18 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
exportThread.start(); exportThread.start();
} }
/**
@param context : it is the reference where this method get called
@param docPath : absolute path of file for which broadcast will be send to refresh media database
@see https://stackoverflow.com/a/36051318/6163336
**/
public static void refreshSystemMediaScanDataBase(Context context, String docPath){
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.fromFile(new File(docPath));
mediaScanIntent.setData(contentUri);
context.sendBroadcast(mediaScanIntent);
}
private void saveDatabase(String fileName) private void saveDatabase(String fileName)
{ {
final String newDatabasePath = mWorkingDirectory + fileName + ".db"; final String newDatabasePath = mWorkingDirectory + fileName + ".db";
@@ -2489,6 +2518,8 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
} }
else else
{ {
refreshSystemMediaScanDataBase(getActivity(), newDatabasePath);
mSavedStamp = System.currentTimeMillis();
msg = String.format("Database saved to \"%s\".", newDatabasePathHuman); msg = String.format("Database saved to \"%s\".", newDatabasePathHuman);
} }