1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-24 05:12:09 +01:00

Update opoc

This commit is contained in:
Gregor Santner 2020-02-09 12:49:26 +01:00
parent a686fea141
commit 0f6b1c3ec3
No known key found for this signature in database
GPG key ID: 7E83A7834AECB009

View file

@ -144,8 +144,10 @@ public class ShareUtil {
* @param chooserText The title text for the chooser, or null for default * @param chooserText The title text for the chooser, or null for default
*/ */
public void showChooser(final Intent intent, final String chooserText) { public void showChooser(final Intent intent, final String chooserText) {
_context.startActivity(Intent.createChooser(intent, try {
chooserText != null ? chooserText : _chooserTitle)); _context.startActivity(Intent.createChooser(intent, chooserText != null ? chooserText : _chooserTitle));
} catch (Exception ignored) {
}
} }
/** /**
@ -445,7 +447,10 @@ public class ShareUtil {
android.content.ClipboardManager cm = ((android.content.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE)); android.content.ClipboardManager cm = ((android.content.ClipboardManager) _context.getSystemService(Context.CLIPBOARD_SERVICE));
if (cm != null) { if (cm != null) {
ClipData clip = ClipData.newPlainText(_context.getPackageName(), text); ClipData clip = ClipData.newPlainText(_context.getPackageName(), text);
cm.setPrimaryClip(clip); try {
cm.setPrimaryClip(clip);
} catch (Exception ignored) {
}
return true; return true;
} }
} }
@ -566,19 +571,13 @@ public class ShareUtil {
} }
} }
// external/ prefix for External storage // prefix for External storage (/storage/emulated/0 /// /sdcard/) --> e.g. "content://com.amaze.filemanager/storage_root/file.txt" = "/sdcard/file.txt"
if (fileStr.startsWith((tmps = "external/"))) { for (String prefix : new String[]{"external/", "media/", "storage_root/"}) {
File f = new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileStr.substring(tmps.length()))); if (fileStr.startsWith((tmps = prefix))) {
if (f.exists()) { File f = new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileStr.substring(tmps.length())));
return f; if (f.exists()) {
} return f;
} }
// media/ prefix for External storage
if (fileStr.startsWith((tmps = "media/"))) {
File f = new File(Uri.decode(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + fileStr.substring(tmps.length())));
if (f.exists()) {
return f;
} }
} }
@ -1096,7 +1095,11 @@ public class ShareUtil {
for (int i = 0; i < parts.length; i++) { for (int i = 0; i < parts.length; i++) {
DocumentFile nextDof = dof.findFile(parts[i]); DocumentFile nextDof = dof.findFile(parts[i]);
if (nextDof == null) { if (nextDof == null) {
nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]); try {
nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]);
} catch (Exception ignored) {
nextDof = null;
}
} }
dof = nextDof; dof = nextDof;
} }