mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-12 04:49:50 +08:00
android: fixed backward compatibility target folder for android <30. Open: files are sorted by last modified date.
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
// Handle this if you need to gracefully shutsaveDatabasedown/retry
|
// Handle this if you need to gracefully shutdown/retry
|
||||||
// in the event that Tango itself crashes/gets upgraded while running.
|
// in the event that Tango itself crashes/gets upgraded while running.
|
||||||
mToast.makeText(getApplicationContext(),
|
mToast.makeText(getApplicationContext(),
|
||||||
String.format("Tango disconnected!"), mToast.LENGTH_LONG).show();
|
String.format("Tango disconnected!"), mToast.LENGTH_LONG).show();
|
||||||
@@ -504,10 +504,28 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
mTotalLoopClosures = 0;
|
mTotalLoopClosures = 0;
|
||||||
mLastFastMovementNotificationStamp = System.currentTimeMillis()/1000;
|
mLastFastMovementNotificationStamp = System.currentTimeMillis()/1000;
|
||||||
|
|
||||||
|
|
||||||
|
int targetSdkVersion= 0;
|
||||||
|
try {
|
||||||
|
ApplicationInfo app = this.getPackageManager().getApplicationInfo("com.introlab.rtabmap", 0);
|
||||||
|
targetSdkVersion = app.targetSdkVersion;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if(Environment.getExternalStorageState().compareTo(Environment.MEDIA_MOUNTED)==0 &&
|
if(Environment.getExternalStorageState().compareTo(Environment.MEDIA_MOUNTED)==0 &&
|
||||||
getActivity().getExternalFilesDirs(null).length >=1)
|
(targetSdkVersion < 30 || getActivity().getExternalFilesDirs(null).length >=1))
|
||||||
{
|
{
|
||||||
File extStore = getActivity().getExternalFilesDirs(null)[0];
|
File extStore;
|
||||||
|
if(targetSdkVersion < 30)
|
||||||
|
{
|
||||||
|
extStore = Environment.getExternalStorageDirectory();
|
||||||
|
}
|
||||||
|
else // >= android30
|
||||||
|
{
|
||||||
|
extStore = getActivity().getExternalFilesDirs(null)[0];
|
||||||
|
}
|
||||||
|
|
||||||
mWorkingDirectory = extStore.getAbsolutePath() + "/" + getString(R.string.app_name) + "/";
|
mWorkingDirectory = extStore.getAbsolutePath() + "/" + getString(R.string.app_name) + "/";
|
||||||
extStore = new File(mWorkingDirectory);
|
extStore = new File(mWorkingDirectory);
|
||||||
extStore.mkdirs();
|
extStore.mkdirs();
|
||||||
@@ -3660,32 +3678,6 @@ public class RTABMapActivity extends FragmentActivity implements OnClickListener
|
|||||||
final File f = new File(zipOutput);
|
final File f = new File(zipOutput);
|
||||||
final int fileSizeMB = (int)f.length()/(1024 * 1024);
|
final int fileSizeMB = (int)f.length()/(1024 * 1024);
|
||||||
|
|
||||||
// Save to public Documents/RTAB-Map folder
|
|
||||||
/*ContentValues values = new ContentValues();
|
|
||||||
values.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName); //file name
|
|
||||||
values.put(MediaStore.MediaColumns.MIME_TYPE, "application/zip"); //file extension, will automatically add to file
|
|
||||||
values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOCUMENTS + "/RTAB-Map"); //end "/" is not mandatory
|
|
||||||
Uri uri = getContentResolver().insert(MediaStore.Files.getContentUri("external"),values);
|
|
||||||
if (uri != null) {
|
|
||||||
OutputStream out;
|
|
||||||
try {
|
|
||||||
out = getApplicationContext().getContentResolver().openOutputStream(uri);
|
|
||||||
|
|
||||||
InputStream in = new FileInputStream(zipOutput);
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int len;
|
|
||||||
while ((len = in.read(buf)) > 0) {
|
|
||||||
out.write(buf, 0, len);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
f.delete(); // remove private file
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, e.getMessage());
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
// Send to...
|
// Send to...
|
||||||
Intent shareIntent = new Intent();
|
Intent shareIntent = new Intent();
|
||||||
shareIntent.setAction(Intent.ACTION_SEND);
|
shareIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ public class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] loadFileList(String directory, final boolean databasesOnly) {
|
public static String[] loadFileList(final String directory, final boolean databasesOnly) {
|
||||||
File path = new File(directory);
|
File path = new File(directory);
|
||||||
String fileList[];
|
String fileList[];
|
||||||
try {
|
try {
|
||||||
@@ -83,6 +87,25 @@ public class Util {
|
|||||||
};
|
};
|
||||||
fileList = path.list(filter);
|
fileList = path.list(filter);
|
||||||
Arrays.sort(fileList);
|
Arrays.sort(fileList);
|
||||||
|
List<String> fileListt = new ArrayList<String>(Arrays.asList(fileList));
|
||||||
|
Collections.sort(fileListt, new Comparator<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(String filename1, String filename2) {
|
||||||
|
File file1 = new File(directory+"/"+filename1);
|
||||||
|
File file2 = new File(directory+"/"+filename2);
|
||||||
|
long k = file1.lastModified() - file2.lastModified();
|
||||||
|
if(k > 0){
|
||||||
|
return -1;
|
||||||
|
}else if(k == 0){
|
||||||
|
return 0;
|
||||||
|
}else{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fileListt.toArray(fileList);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fileList = new String[0];
|
fileList = new String[0];
|
||||||
|
|||||||
@@ -2858,7 +2858,7 @@ std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > projectCloudToCamera
|
|||||||
UINFO("maxDistance=%f", maxDistance);
|
UINFO("maxDistance=%f", maxDistance);
|
||||||
UINFO("maxAngle=%f", maxAngle);
|
UINFO("maxAngle=%f", maxAngle);
|
||||||
UINFO("distanceToCamPolicy=%s", distanceToCamPolicy?"true":"false");
|
UINFO("distanceToCamPolicy=%s", distanceToCamPolicy?"true":"false");
|
||||||
UINFO("roiRatios=%s", roiRatios.size() == 4?uFormat("%f %f %f %f", roiRatios[0], roiRatios[1], roiRatios[2], roiRatios[3]):"");
|
UINFO("roiRatios=%s", roiRatios.size() == 4?uFormat("%f %f %f %f", roiRatios[0], roiRatios[1], roiRatios[2], roiRatios[3]).c_str():"");
|
||||||
UINFO("projMask=%dx%d", projMask.cols, projMask.rows);
|
UINFO("projMask=%dx%d", projMask.cols, projMask.rows);
|
||||||
std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > pointToPixel;
|
std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > pointToPixel;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user