-
-
-
- /**
- * Translates a content URI of a content to a physical path on the disk
- *
- * @param uri The URI to resolve
- * @return The path to the content or null if it could not be found
- */
- @TargetApi(Build.VERSION_CODES.KITKAT)
- public String getPath(Uri uri) {
- final boolean isKitKatOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
-
- // DocumentProvider
- if (isKitKatOrLater && DocumentsContract.isDocumentUri(this, uri)) {
- // ExternalStorageProvider
- if (UriUtils.isExternalStorageDocument(uri)) {
- final String docId = DocumentsContract.getDocumentId(uri);
- final String[] split = docId.split(":");
- final String type = split[0];
-
- if ("primary".equalsIgnoreCase(type)) {
- return Environment.getExternalStorageDirectory() + "/" + split[1];
- }
- }
- // DownloadsProvider
- else if (UriUtils.isDownloadsDocument(uri)) {
-
- final String id = DocumentsContract.getDocumentId(uri);
- final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
- Long.valueOf(id));
-
- return UriUtils.getDataColumn(this, contentUri, null, null);
- }
- // MediaProvider
- else if (UriUtils.isMediaDocument(uri)) {
- final String docId = DocumentsContract.getDocumentId(uri);
- final String[] split = docId.split(":");
- final String type = split[0];
-
- Uri contentUri = null;
- if ("image".equals(type)) {
- contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- } else if ("video".equals(type)) {
- contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- } else if ("audio".equals(type)) {
- contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
- }
-
- final String selection = "_id=?";
- final String[] selectionArgs = new String[] { split[1] };
-
- return UriUtils.getDataColumn(this, contentUri, selection, selectionArgs);
- }
- // Documents providers returned as content://...
- else if (UriUtils.isContentDocument(uri)) {
- return uri.toString();
- }
- }
- // MediaStore (and general)
- else if ("content".equalsIgnoreCase(uri.getScheme())) {
-
- // Return the remote address
- if (UriUtils.isGooglePhotosUri(uri))
- return uri.getLastPathSegment();
-
- return UriUtils.getDataColumn(this, uri, null, null);
- }
- // File
- else if ("file".equalsIgnoreCase(uri.getScheme())) {
- return uri.getPath();
- }
- return null;
- }
-
-
-
+
+// public void restart(){
+// Intent i = new Intent(this, FileDisplayActivity.class);
+// i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+// startActivity(i);
+// }
+
+// public void closeDrawer() {
+// mDrawerLayout.closeDrawers();
+// }
+
+// private class DrawerItemClickListener implements ListView.OnItemClickListener {
+// @Override
+// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+// if (mShowAccounts && position > 0){
+// position = position - 1;
+// }
+// switch (position){
+// case 0: // Accounts
+// mShowAccounts = !mShowAccounts;
+// mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
+// mNavigationDrawerAdapter.notifyDataSetChanged();
+// break;
+//
+// case 1: // All Files
+// // TODO Enable when "On Device" is recovered ?
+// //MainApp.showOnlyFilesOnDevice(false);
+// mDrawerLayout.closeDrawers();
+// break;
+//
+// // TODO Enable when "On Device" is recovered ?
+//// case 2:
+//// MainApp.showOnlyFilesOnDevice(true);
+//// mDrawerLayout.closeDrawers();
+//// break;
+//
+// case 2: // Settings
+// Intent settingsIntent = new Intent(getApplicationContext(),
+// Preferences.class);
+// startActivity(settingsIntent);
+// break;
+//
+// case 3: // Logs
+// Intent loggerIntent = new Intent(getApplicationContext(),
+// LogHistoryActivity.class);
+// startActivity(loggerIntent);
+// break;
+// }
+// }
+// }