Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
4beb03dd
Commit
4beb03dd
authored
Apr 05, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed sharing gif files from picasa and G+ albums
parent
c4e113dc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
147 additions
and
22 deletions
+147
-22
build.gradle
TMessagesProj/build.gradle
+2
-2
MediaController.java
...src/main/java/org/telegram/messenger/MediaController.java
+79
-0
MessagesController.java
.../main/java/org/telegram/messenger/MessagesController.java
+23
-2
NativeLoader.java
...oj/src/main/java/org/telegram/messenger/NativeLoader.java
+1
-1
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+11
-0
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+31
-17
No files found.
TMessagesProj/build.gradle
View file @
4beb03dd
...
@@ -82,7 +82,7 @@ android {
...
@@ -82,7 +82,7 @@ android {
defaultConfig
{
defaultConfig
{
minSdkVersion
8
minSdkVersion
8
targetSdkVersion
19
targetSdkVersion
19
versionCode
2
29
versionCode
2
30
versionName
"1.4.1
2
"
versionName
"1.4.1
3
"
}
}
}
}
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
4beb03dd
...
@@ -21,6 +21,7 @@ import android.media.MediaRecorder;
...
@@ -21,6 +21,7 @@ import android.media.MediaRecorder;
import
android.media.audiofx.AutomaticGainControl
;
import
android.media.audiofx.AutomaticGainControl
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.os.ParcelFileDescriptor
;
import
android.os.Vibrator
;
import
android.os.Vibrator
;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
android.view.View
;
import
android.view.View
;
...
@@ -38,6 +39,7 @@ import java.nio.ByteBuffer;
...
@@ -38,6 +39,7 @@ import java.nio.ByteBuffer;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.TimerTask
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.Semaphore
;
...
@@ -1424,4 +1426,81 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -1424,4 +1426,81 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
currentGifMessageObject
=
null
;
currentGifMessageObject
=
null
;
}
}
}
}
public
static
boolean
isGif
(
Uri
uri
)
{
ParcelFileDescriptor
parcelFD
=
null
;
FileInputStream
input
=
null
;
try
{
parcelFD
=
ApplicationLoader
.
applicationContext
.
getContentResolver
().
openFileDescriptor
(
uri
,
"r"
);
input
=
new
FileInputStream
(
parcelFD
.
getFileDescriptor
());
if
(
input
.
getChannel
().
size
()
>
3
)
{
byte
[]
header
=
new
byte
[
3
];
input
.
read
(
header
,
0
,
3
);
String
str
=
new
String
(
header
);
if
(
str
!=
null
&&
str
.
equalsIgnoreCase
(
"gif"
))
{
return
true
;
}
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
try
{
if
(
parcelFD
!=
null
)
{
parcelFD
.
close
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
try
{
if
(
input
!=
null
)
{
input
.
close
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
}
return
false
;
}
public
static
String
copyDocumentToCache
(
Uri
uri
)
{
ParcelFileDescriptor
parcelFD
=
null
;
FileInputStream
input
=
null
;
FileOutputStream
output
=
null
;
try
{
int
id
=
UserConfig
.
lastLocalId
;
UserConfig
.
lastLocalId
--;
parcelFD
=
ApplicationLoader
.
applicationContext
.
getContentResolver
().
openFileDescriptor
(
uri
,
"r"
);
input
=
new
FileInputStream
(
parcelFD
.
getFileDescriptor
());
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
String
.
format
(
Locale
.
US
,
"%d.gif"
,
id
));
output
=
new
FileOutputStream
(
f
);
input
.
getChannel
().
transferTo
(
0
,
input
.
getChannel
().
size
(),
output
.
getChannel
());
UserConfig
.
saveConfig
(
false
);
return
f
.
getAbsolutePath
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
try
{
if
(
parcelFD
!=
null
)
{
parcelFD
.
close
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
try
{
if
(
input
!=
null
)
{
input
.
close
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
try
{
if
(
output
!=
null
)
{
output
.
close
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
}
return
null
;
}
}
}
TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
View file @
4beb03dd
...
@@ -2134,8 +2134,22 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2134,8 +2134,22 @@ public class MessagesController implements NotificationCenter.NotificationCenter
size2
.
location
=
size
.
location
;
size2
.
location
=
size
.
location
;
}
}
}
}
sentMessage
.
message
=
newMsg
.
message
;
if
(
newMsg
.
attachPath
!=
null
&&
newMsg
.
attachPath
.
startsWith
(
Utilities
.
getCacheDir
().
getAbsolutePath
()))
{
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
File
cacheFile
=
new
File
(
newMsg
.
attachPath
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
MessageObject
.
getAttachFileName
(
sentMessage
.
media
.
document
));
boolean
result
=
cacheFile
.
renameTo
(
cacheFile2
);
if
(
result
)
{
newMsg
.
attachPath
=
null
;
newMsg
.
media
.
document
.
dc_id
=
sentMessage
.
media
.
document
.
dc_id
;
newMsg
.
media
.
document
.
id
=
sentMessage
.
media
.
document
.
id
;
}
else
{
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
sentMessage
.
message
=
newMsg
.
message
;
}
}
else
{
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
sentMessage
.
message
=
newMsg
.
message
;
}
}
else
if
(
sentMessage
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
&&
sentMessage
.
media
.
audio
!=
null
&&
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
&&
newMsg
.
media
.
audio
!=
null
)
{
}
else
if
(
sentMessage
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
&&
sentMessage
.
media
.
audio
!=
null
&&
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
&&
newMsg
.
media
.
audio
!=
null
)
{
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
...
@@ -2205,6 +2219,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2205,6 +2219,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMsg
.
media
.
document
.
path
=
document
.
path
;
newMsg
.
media
.
document
.
path
=
document
.
path
;
newMsg
.
media
.
document
.
thumb
=
document
.
thumb
;
newMsg
.
media
.
document
.
thumb
=
document
.
thumb
;
newMsg
.
media
.
document
.
dc_id
=
file
.
dc_id
;
newMsg
.
media
.
document
.
dc_id
=
file
.
dc_id
;
if
(
document
.
path
!=
null
&&
document
.
path
.
startsWith
(
Utilities
.
getCacheDir
().
getAbsolutePath
()))
{
File
cacheFile
=
new
File
(
document
.
path
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
MessageObject
.
getAttachFileName
(
newMsg
.
media
.
document
));
cacheFile
.
renameTo
(
cacheFile2
);
}
ArrayList
<
TLRPC
.
Message
>
arr
=
new
ArrayList
<
TLRPC
.
Message
>();
ArrayList
<
TLRPC
.
Message
>
arr
=
new
ArrayList
<
TLRPC
.
Message
>();
arr
.
add
(
newMsg
);
arr
.
add
(
newMsg
);
MessagesStorage
.
getInstance
().
putMessages
(
arr
,
false
,
true
);
MessagesStorage
.
getInstance
().
putMessages
(
arr
,
false
,
true
);
...
...
TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java
View file @
4beb03dd
...
@@ -34,7 +34,7 @@ public class NativeLoader {
...
@@ -34,7 +34,7 @@ public class NativeLoader {
File
f
=
null
;
File
f
=
null
;
if
(
context
!=
null
)
{
if
(
context
!=
null
)
{
try
{
try
{
f
=
(
File
)
ApplicationInfo
.
class
.
getField
(
"nativeLibraryDir"
).
get
(
context
.
getApplicationInfo
(
));
f
=
new
File
((
String
)
ApplicationInfo
.
class
.
getField
(
"nativeLibraryDir"
).
get
(
context
.
getApplicationInfo
()
));
}
catch
(
Throwable
th
)
{
}
catch
(
Throwable
th
)
{
th
.
printStackTrace
();
th
.
printStackTrace
();
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
4beb03dd
...
@@ -1556,7 +1556,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1556,7 +1556,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
;
return
;
}
}
String
tempPath
=
Utilities
.
getPath
(
data
.
getData
());
String
tempPath
=
Utilities
.
getPath
(
data
.
getData
());
boolean
isGif
=
false
;
if
(
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
if
(
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
isGif
=
true
;
}
else
if
(
tempPath
==
null
)
{
isGif
=
MediaController
.
isGif
(
data
.
getData
());
if
(
isGif
)
{
tempPath
=
MediaController
.
copyDocumentToCache
(
data
.
getData
());
}
}
if
(
tempPath
!=
null
&&
isGif
)
{
processSendingDocument
(
tempPath
);
processSendingDocument
(
tempPath
);
}
else
{
}
else
{
processSendingPhoto
(
null
,
data
.
getData
());
processSendingPhoto
(
null
,
data
.
getData
());
...
...
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
4beb03dd
...
@@ -38,6 +38,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
...
@@ -38,6 +38,7 @@ import org.telegram.PhoneFormat.PhoneFormat;
import
org.telegram.messenger.BuildVars
;
import
org.telegram.messenger.BuildVars
;
import
org.telegram.messenger.ConnectionsManager
;
import
org.telegram.messenger.ConnectionsManager
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.MediaController
;
import
org.telegram.messenger.MessagesController
;
import
org.telegram.messenger.MessagesController
;
import
org.telegram.messenger.NotificationCenter
;
import
org.telegram.messenger.NotificationCenter
;
import
org.telegram.messenger.R
;
import
org.telegram.messenger.R
;
...
@@ -336,22 +337,24 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -336,22 +337,24 @@ 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
(
parcelable
!=
null
&&
type
!=
null
&&
type
.
startsWith
(
"image/"
))
{
Uri
uri
=
(
Uri
)
parcelable
;
String
tempPath
=
Utilities
.
getPath
((
Uri
)
parcelable
);
if
(
uri
!=
null
&&
type
!=
null
&&
type
.
startsWith
(
"image/"
))
{
if
(
type
.
equals
(
"image/gif"
)
||
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
String
tempPath
=
Utilities
.
getPath
(
uri
);
try
{
boolean
isGif
=
false
;
documentPath
=
Utilities
.
getPath
((
Uri
)
parcelable
);
if
(
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
}
catch
(
Exception
e
)
{
isGif
=
true
;
FileLog
.
e
(
"tmessages"
,
e
);
documentPath
=
tempPath
;
}
else
if
(
tempPath
==
null
)
{
isGif
=
MediaController
.
isGif
(
uri
);
if
(
isGif
)
{
documentPath
=
MediaController
.
copyDocumentToCache
(
uri
);
}
}
if
(
documentPath
==
null
)
{
}
photoPath
=
(
Uri
)
parcelable
;
if
(!
isGif
||
documentPath
==
null
)
{
}
photoPath
=
uri
;
}
else
{
photoPath
=
(
Uri
)
parcelable
;
}
}
}
else
{
}
else
{
path
=
Utilities
.
getPath
(
(
Uri
)
parcelable
);
path
=
Utilities
.
getPath
(
uri
);
if
(
path
!=
null
)
{
if
(
path
!=
null
)
{
if
(
path
.
startsWith
(
"file:"
))
{
if
(
path
.
startsWith
(
"file:"
))
{
path
=
path
.
replace
(
"file://"
,
""
);
path
=
path
.
replace
(
"file://"
,
""
);
...
@@ -380,13 +383,24 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -380,13 +383,24 @@ 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
());
}
}
String
tempPath
=
Utilities
.
getPath
((
Uri
)
parcelable
);
Uri
uri
=
(
Uri
)
parcelable
;
if
(
type
.
equals
(
"image/gif"
)
||
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
String
tempPath
=
Utilities
.
getPath
(
uri
);
boolean
isGif
=
false
;
if
(
tempPath
!=
null
&&
tempPath
.
endsWith
(
".gif"
))
{
isGif
=
true
;
}
else
if
(
tempPath
==
null
)
{
isGif
=
MediaController
.
isGif
(
uri
);
if
(
isGif
)
{
tempPath
=
MediaController
.
copyDocumentToCache
(
uri
);
}
}
if
(
isGif
&&
tempPath
!=
null
)
{
if
(
documentsPathArray
==
null
)
{
if
(
documentsPathArray
==
null
)
{
documentsPathArray
=
new
ArrayList
<
String
>();
documentsPathArray
=
new
ArrayList
<
String
>();
}
}
try
{
try
{
documentsPathArray
.
add
(
Utilities
.
getPath
((
Uri
)
parcelable
)
);
documentsPathArray
.
add
(
tempPath
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
FileLog
.
e
(
"tmessages"
,
e
);
}
}
...
@@ -394,7 +408,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -394,7 +408,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
if
(
imagesPathArray
==
null
)
{
if
(
imagesPathArray
==
null
)
{
imagesPathArray
=
new
ArrayList
<
Uri
>();
imagesPathArray
=
new
ArrayList
<
Uri
>();
}
}
imagesPathArray
.
add
(
(
Uri
)
parcelable
);
imagesPathArray
.
add
(
uri
);
}
}
}
}
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment