Do not use the new AttachmentsContentProvider for pulic URLs as used when attaching local files.

This commit is contained in:
B. Petersen
2017-02-23 13:28:31 +01:00
parent 8b78df6a14
commit 1485eeecf6
2 changed files with 11 additions and 30 deletions
@@ -225,19 +225,6 @@ public class AndroidUtilities {
}
}
public static boolean isKeyboardShowed(View view) {
if (view == null) {
return false;
}
try {
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
return inputManager.isActive(view);
} catch (Exception e) {
FileLog.e("messenger", e);
}
return false;
}
public static void hideKeyboard(View view) {
if (view == null) {
return;
@@ -399,19 +386,6 @@ public class AndroidUtilities {
}
}
public static void setProgressBarAnimationDuration(ProgressBar progressBar, int duration) {
if (progressBar == null) {
return;
}
try {
Field mCursorDrawableRes = ProgressBar.class.getDeclaredField("mDuration");
mCursorDrawableRes.setAccessible(true);
mCursorDrawableRes.setInt(progressBar, duration);
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
private static Intent createShortcutIntent(int did, Bitmap bitmap) {
Intent shortcutIntent = new Intent(ApplicationLoader.applicationContext, OpenChatReceiver.class);
@@ -1000,13 +974,20 @@ public class AndroidUtilities {
public static void openForView(MessageObject message, Activity activity) throws Exception
{
String fileName = message.messageOwner.media.document.file_name;
Uri toOpen = Uri.parse("content://" + BuildConfig.APPLICATION_ID + ".attachments/" + fileName);
String path = message.messageOwner.media.document.mr_path;
File file = new File(path);
Uri uri;
if( path.startsWith(MrMailbox.getBlobdir()) ) {
uri = Uri.parse("content://" + BuildConfig.APPLICATION_ID + ".attachments/" + file.getName());
}
else {
uri = Uri.fromFile(file);
}
String mimeType = getMimetypeForView(message);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(toOpen, mimeType);
intent.setDataAndType(uri, mimeType);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.startActivity(intent);
}
@@ -228,7 +228,7 @@ public class MrMsg {
ret.media.document.mime_type = getParam('m', "application/octet-stream");
ret.media.document.file_name = getFilename();
ret.media.document.size = getBytes();
ret.attachPath = path;
ret.media.document.mr_path = path;
}
else {
ret.message = "<file path missing>";