mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Fixed sharing gif files from gallery
This commit is contained in:
parent
ec533c5fff
commit
05471c4395
4 changed files with 52 additions and 42 deletions
|
@ -82,7 +82,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 220
|
versionCode 221
|
||||||
versionName "1.4.10"
|
versionName "1.4.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,46 +684,49 @@ public class Utilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPath(final Uri uri) {
|
public static String getPath(final Uri uri) {
|
||||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
try {
|
||||||
if (isKitKat && DocumentsContract.isDocumentUri(ApplicationLoader.applicationContext, uri)) {
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
if (isExternalStorageDocument(uri)) {
|
if (isKitKat && DocumentsContract.isDocumentUri(ApplicationLoader.applicationContext, uri)) {
|
||||||
final String docId = DocumentsContract.getDocumentId(uri);
|
if (isExternalStorageDocument(uri)) {
|
||||||
final String[] split = docId.split(":");
|
final String docId = DocumentsContract.getDocumentId(uri);
|
||||||
final String type = split[0];
|
final String[] split = docId.split(":");
|
||||||
if ("primary".equalsIgnoreCase(type)) {
|
final String type = split[0];
|
||||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
if ("primary".equalsIgnoreCase(type)) {
|
||||||
|
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||||
|
}
|
||||||
|
} else if (isDownloadsDocument(uri)) {
|
||||||
|
final String id = DocumentsContract.getDocumentId(uri);
|
||||||
|
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||||
|
return getDataColumn(ApplicationLoader.applicationContext, contentUri, null, null);
|
||||||
|
} else if (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 getDataColumn(ApplicationLoader.applicationContext, contentUri, selection, selectionArgs);
|
||||||
}
|
}
|
||||||
} else if (isDownloadsDocument(uri)) {
|
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
||||||
final String id = DocumentsContract.getDocumentId(uri);
|
return getDataColumn(ApplicationLoader.applicationContext, uri, null, null);
|
||||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
||||||
return getDataColumn(ApplicationLoader.applicationContext, contentUri, null, null);
|
return uri.getPath();
|
||||||
} else if (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 getDataColumn(ApplicationLoader.applicationContext, contentUri, selection, selectionArgs);
|
|
||||||
}
|
}
|
||||||
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
|
} catch (Exception e) {
|
||||||
return getDataColumn(ApplicationLoader.applicationContext, uri, null, null);
|
FileLog.e("tmessages", e);
|
||||||
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
|
|
||||||
return uri.getPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1535,10 +1535,15 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
||||||
processSendingPhoto(currentPicturePath, null);
|
processSendingPhoto(currentPicturePath, null);
|
||||||
currentPicturePath = null;
|
currentPicturePath = null;
|
||||||
} else if (requestCode == 1) {
|
} else if (requestCode == 1) {
|
||||||
if (data == null) {
|
if (data == null || data.getData() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processSendingPhoto(null, data.getData());
|
String tempPath = Utilities.getPath(data.getData());
|
||||||
|
if (tempPath != null && tempPath.endsWith(".gif")) {
|
||||||
|
processSendingDocument(tempPath);
|
||||||
|
} else {
|
||||||
|
processSendingPhoto(null, data.getData());
|
||||||
|
}
|
||||||
} else if (requestCode == 2) {
|
} else if (requestCode == 2) {
|
||||||
String videoPath = null;
|
String videoPath = null;
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
|
@ -329,7 +329,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||||
parcelable = Uri.parse(parcelable.toString());
|
parcelable = Uri.parse(parcelable.toString());
|
||||||
}
|
}
|
||||||
if (parcelable != null && type != null && type.startsWith("image/")) {
|
if (parcelable != null && type != null && type.startsWith("image/")) {
|
||||||
if (type.equals("image/gif")) {
|
String tempPath = Utilities.getPath((Uri)parcelable);
|
||||||
|
if (type.equals("image/gif") || tempPath != null && tempPath.endsWith(".gif")) {
|
||||||
try {
|
try {
|
||||||
documentPath = Utilities.getPath((Uri)parcelable);
|
documentPath = Utilities.getPath((Uri)parcelable);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -371,7 +372,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||||
if (!(parcelable instanceof Uri)) {
|
if (!(parcelable instanceof Uri)) {
|
||||||
parcelable = Uri.parse(parcelable.toString());
|
parcelable = Uri.parse(parcelable.toString());
|
||||||
}
|
}
|
||||||
if (type.equals("image/gif")) {
|
String tempPath = Utilities.getPath((Uri)parcelable);
|
||||||
|
if (type.equals("image/gif") || tempPath != null && tempPath.endsWith(".gif")) {
|
||||||
if (documentsPathArray == null) {
|
if (documentsPathArray == null) {
|
||||||
documentsPathArray = new ArrayList<String>();
|
documentsPathArray = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue