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
ebe7ab78
Commit
ebe7ab78
authored
Mar 31, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gif support, applying localization files from document messages
parent
5323e87b
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1368 additions
and
854 deletions
+1368
-854
gif.c
TMessagesProj/jni/gif.c
+3
-0
libtmessages.so
TMessagesProj/libs/armeabi-v7a/libtmessages.so
+0
-0
libtmessages.so
TMessagesProj/libs/armeabi/libtmessages.so
+0
-0
libtmessages.so
TMessagesProj/libs/x86/libtmessages.so
+0
-0
FileLoadOperation.java
...c/main/java/org/telegram/messenger/FileLoadOperation.java
+3
-3
FileLoader.java
...Proj/src/main/java/org/telegram/messenger/FileLoader.java
+81
-117
LocaleController.java
...rc/main/java/org/telegram/messenger/LocaleController.java
+80
-7
MediaController.java
...src/main/java/org/telegram/messenger/MediaController.java
+100
-0
MessagesController.java
.../main/java/org/telegram/messenger/MessagesController.java
+62
-34
Utilities.java
...sProj/src/main/java/org/telegram/messenger/Utilities.java
+0
-3
MessageObject.java
...roj/src/main/java/org/telegram/objects/MessageObject.java
+28
-37
ChatAudioCell.java
...oj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java
+13
-13
ChatBaseCell.java
...roj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
+138
-47
ChatMediaCell.java
...oj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
+514
-0
ChatMessageCell.java
.../src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+5
-5
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+229
-186
SettingsActivity.java
...sProj/src/main/java/org/telegram/ui/SettingsActivity.java
+1
-1
GifDrawable.java
...Proj/src/main/java/org/telegram/ui/Views/GifDrawable.java
+33
-12
ImageReceiver.java
...oj/src/main/java/org/telegram/ui/Views/ImageReceiver.java
+37
-0
ProgressView.java
...roj/src/main/java/org/telegram/ui/Views/ProgressView.java
+18
-33
chat_group_incoming_photo_layout.xml
.../src/main/res/layout/chat_group_incoming_photo_layout.xml
+0
-113
chat_incoming_photo_layout.xml
...esProj/src/main/res/layout/chat_incoming_photo_layout.xml
+0
-103
chat_outgoing_photo_layout.xml
...esProj/src/main/res/layout/chat_outgoing_photo_layout.xml
+0
-123
strings.xml
TMessagesProj/src/main/res/values-ar/strings.xml
+4
-3
strings.xml
TMessagesProj/src/main/res/values-de/strings.xml
+4
-3
strings.xml
TMessagesProj/src/main/res/values-es/strings.xml
+4
-3
strings.xml
TMessagesProj/src/main/res/values-it/strings.xml
+4
-3
strings.xml
TMessagesProj/src/main/res/values-nl/strings.xml
+4
-3
strings.xml
TMessagesProj/src/main/res/values/strings.xml
+3
-2
No files found.
TMessagesProj/jni/gif.c
View file @
ebe7ab78
...
@@ -794,6 +794,9 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIE
...
@@ -794,6 +794,9 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIE
return
;
return
;
}
}
info
->
lastFrameReaminder
=
getRealTime
()
-
info
->
nextStartTime
;
info
->
lastFrameReaminder
=
getRealTime
()
-
info
->
nextStartTime
;
if
(
info
->
lastFrameReaminder
>
0
)
{
info
->
lastFrameReaminder
=
0
;
}
}
}
JNIEXPORT
void
JNICALL
Java_org_telegram_ui_Views_GifDrawable_restoreRemainder
(
JNIEnv
*
env
,
jclass
class
,
jobject
gifInfo
)
{
JNIEXPORT
void
JNICALL
Java_org_telegram_ui_Views_GifDrawable_restoreRemainder
(
JNIEnv
*
env
,
jclass
class
,
jobject
gifInfo
)
{
...
...
TMessagesProj/libs/armeabi-v7a/libtmessages.so
View file @
ebe7ab78
No preview for this file type
TMessagesProj/libs/armeabi/libtmessages.so
View file @
ebe7ab78
No preview for this file type
TMessagesProj/libs/x86/libtmessages.so
View file @
ebe7ab78
No preview for this file type
TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java
View file @
ebe7ab78
...
@@ -198,7 +198,7 @@ public class FileLoadOperation {
...
@@ -198,7 +198,7 @@ public class FileLoadOperation {
}
}
final
boolean
dontDelete
=
isLocalFile
;
final
boolean
dontDelete
=
isLocalFile
;
if
((
exist
=
cacheFileFinal
.
exists
())
&&
!
ignoreCache
)
{
if
((
exist
=
cacheFileFinal
.
exists
())
&&
!
ignoreCache
)
{
Utilities
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
try
{
try
{
...
@@ -403,7 +403,7 @@ public class FileLoadOperation {
...
@@ -403,7 +403,7 @@ public class FileLoadOperation {
final
boolean
renamed
=
cacheFileTemp
.
renameTo
(
cacheFileFinal
);
final
boolean
renamed
=
cacheFileTemp
.
renameTo
(
cacheFileFinal
);
if
(
needBitmapCreate
)
{
if
(
needBitmapCreate
)
{
Utilities
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
int
delay
=
20
;
int
delay
=
20
;
...
@@ -520,7 +520,7 @@ public class FileLoadOperation {
...
@@ -520,7 +520,7 @@ public class FileLoadOperation {
int
readed
=
httpConnectionStream
.
read
(
data
);
int
readed
=
httpConnectionStream
.
read
(
data
);
if
(
readed
>
0
)
{
if
(
readed
>
0
)
{
fileOutputStream
.
write
(
data
,
0
,
readed
);
fileOutputStream
.
write
(
data
,
0
,
readed
);
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
startDownloadHTTPRequest
();
startDownloadHTTPRequest
();
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
ebe7ab78
...
@@ -38,6 +38,9 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -38,6 +38,9 @@ import java.util.concurrent.ConcurrentHashMap;
public
class
FileLoader
{
public
class
FileLoader
{
public
LruCache
memCache
;
public
LruCache
memCache
;
public
static
volatile
DispatchQueue
cacheOutQueue
=
new
DispatchQueue
(
"cacheOutQueue"
);
public
static
volatile
DispatchQueue
fileLoaderQueue
=
new
DispatchQueue
(
"fileUploadQueue"
);
private
String
ignoreRemoval
=
null
;
private
String
ignoreRemoval
=
null
;
private
ConcurrentHashMap
<
String
,
CacheImage
>
imageLoading
;
private
ConcurrentHashMap
<
String
,
CacheImage
>
imageLoading
;
private
HashMap
<
Integer
,
CacheImage
>
imageLoadingByKeys
;
private
HashMap
<
Integer
,
CacheImage
>
imageLoadingByKeys
;
...
@@ -50,9 +53,11 @@ public class FileLoader {
...
@@ -50,9 +53,11 @@ public class FileLoader {
private
int
currentUploadOperationsCount
=
0
;
private
int
currentUploadOperationsCount
=
0
;
private
Queue
<
FileLoadOperation
>
loadOperationQueue
;
private
Queue
<
FileLoadOperation
>
loadOperationQueue
;
private
Queue
<
FileLoadOperation
>
audioLoadOperationQueue
;
private
Queue
<
FileLoadOperation
>
audioLoadOperationQueue
;
private
Queue
<
FileLoadOperation
>
photoLoadOperationQueue
;
private
ConcurrentHashMap
<
String
,
FileLoadOperation
>
loadOperationPaths
;
private
ConcurrentHashMap
<
String
,
FileLoadOperation
>
loadOperationPaths
;
private
int
currentLoadOperationsCount
=
0
;
private
int
currentLoadOperationsCount
=
0
;
private
int
currentAudioLoadOperationsCount
=
0
;
private
int
currentAudioLoadOperationsCount
=
0
;
private
int
currentPhotoLoadOperationsCount
=
0
;
public
static
long
lastCacheOutTime
=
0
;
public
static
long
lastCacheOutTime
=
0
;
public
ConcurrentHashMap
<
String
,
Float
>
fileProgresses
=
new
ConcurrentHashMap
<
String
,
Float
>();
public
ConcurrentHashMap
<
String
,
Float
>
fileProgresses
=
new
ConcurrentHashMap
<
String
,
Float
>();
private
long
lastProgressUpdateTime
=
0
;
private
long
lastProgressUpdateTime
=
0
;
...
@@ -108,21 +113,12 @@ public class FileLoader {
...
@@ -108,21 +113,12 @@ public class FileLoader {
try
{
try
{
Class
cl
=
Class
.
forName
(
"dalvik.system.VMRuntime"
);
Class
cl
=
Class
.
forName
(
"dalvik.system.VMRuntime"
);
Method
getRt
=
cl
.
getMethod
(
"getRuntime"
,
new
Class
[
0
]);
Method
getRt
=
cl
.
getMethod
(
"getRuntime"
,
new
Class
[
0
]);
runtime
=
getRt
.
invoke
(
null
,
new
Object
[
0
]);
Object
obj
=
new
Object
[
0
];
runtime
=
getRt
.
invoke
(
null
,
obj
);
trackAllocation
=
cl
.
getMethod
(
"trackExternalAllocation"
,
new
Class
[]
{
long
.
class
});
trackAllocation
=
cl
.
getMethod
(
"trackExternalAllocation"
,
new
Class
[]
{
long
.
class
});
trackFree
=
cl
.
getMethod
(
"trackExternalFree"
,
new
Class
[]
{
long
.
class
});
trackFree
=
cl
.
getMethod
(
"trackExternalFree"
,
new
Class
[]
{
long
.
class
});
success
=
true
;
success
=
true
;
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
catch
(
SecurityException
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
catch
(
NoSuchMethodException
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
catch
(
IllegalArgumentException
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
catch
(
IllegalAccessException
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
catch
(
InvocationTargetException
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
FileLog
.
e
(
"tmessages"
,
e
);
}
}
if
(!
success
)
{
if
(!
success
)
{
...
@@ -179,7 +175,7 @@ public class FileLoader {
...
@@ -179,7 +175,7 @@ public class FileLoader {
}
}
}
}
}
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
synchronized
(
imageViewArray
)
{
synchronized
(
imageViewArray
)
{
...
@@ -316,10 +312,11 @@ public class FileLoader {
...
@@ -316,10 +312,11 @@ public class FileLoader {
loadOperationPaths
=
new
ConcurrentHashMap
<
String
,
FileLoadOperation
>();
loadOperationPaths
=
new
ConcurrentHashMap
<
String
,
FileLoadOperation
>();
loadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
loadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
audioLoadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
audioLoadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
photoLoadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
}
}
public
void
cancelUploadFile
(
final
String
location
,
final
boolean
enc
)
{
public
void
cancelUploadFile
(
final
String
location
,
final
boolean
enc
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(!
enc
)
{
if
(!
enc
)
{
...
@@ -344,7 +341,7 @@ public class FileLoader {
...
@@ -344,7 +341,7 @@ public class FileLoader {
}
}
public
void
uploadFile
(
final
String
location
,
final
byte
[]
key
,
final
byte
[]
iv
)
{
public
void
uploadFile
(
final
String
location
,
final
byte
[]
key
,
final
byte
[]
iv
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
key
!=
null
)
{
if
(
key
!=
null
)
{
...
@@ -365,7 +362,7 @@ public class FileLoader {
...
@@ -365,7 +362,7 @@ public class FileLoader {
operation
.
delegate
=
new
FileUploadOperation
.
FileUploadOperationDelegate
()
{
operation
.
delegate
=
new
FileUploadOperation
.
FileUploadOperationDelegate
()
{
@Override
@Override
public
void
didFinishUploadingFile
(
FileUploadOperation
operation
,
final
TLRPC
.
InputFile
inputFile
,
final
TLRPC
.
InputEncryptedFile
inputEncryptedFile
)
{
public
void
didFinishUploadingFile
(
FileUploadOperation
operation
,
final
TLRPC
.
InputFile
inputFile
,
final
TLRPC
.
InputEncryptedFile
inputEncryptedFile
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
...
@@ -394,7 +391,7 @@ public class FileLoader {
...
@@ -394,7 +391,7 @@ public class FileLoader {
@Override
@Override
public
void
didFailedUploadingFile
(
final
FileUploadOperation
operation
)
{
public
void
didFailedUploadingFile
(
final
FileUploadOperation
operation
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
...
@@ -454,7 +451,7 @@ public class FileLoader {
...
@@ -454,7 +451,7 @@ public class FileLoader {
if
(
video
==
null
&&
photo
==
null
&&
document
==
null
&&
audio
==
null
)
{
if
(
video
==
null
&&
photo
==
null
&&
document
==
null
&&
audio
==
null
)
{
return
;
return
;
}
}
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
String
fileName
=
null
;
String
fileName
=
null
;
...
@@ -474,6 +471,8 @@ public class FileLoader {
...
@@ -474,6 +471,8 @@ public class FileLoader {
if
(
operation
!=
null
)
{
if
(
operation
!=
null
)
{
if
(
audio
!=
null
)
{
if
(
audio
!=
null
)
{
audioLoadOperationQueue
.
remove
(
operation
);
audioLoadOperationQueue
.
remove
(
operation
);
}
else
if
(
photo
!=
null
)
{
photoLoadOperationQueue
.
remove
(
operation
);
}
else
{
}
else
{
loadOperationQueue
.
remove
(
operation
);
loadOperationQueue
.
remove
(
operation
);
}
}
...
@@ -488,7 +487,7 @@ public class FileLoader {
...
@@ -488,7 +487,7 @@ public class FileLoader {
}
}
public
void
loadFile
(
final
TLRPC
.
Video
video
,
final
TLRPC
.
PhotoSize
photo
,
final
TLRPC
.
Document
document
,
final
TLRPC
.
Audio
audio
)
{
public
void
loadFile
(
final
TLRPC
.
Video
video
,
final
TLRPC
.
PhotoSize
photo
,
final
TLRPC
.
Document
document
,
final
TLRPC
.
Audio
audio
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
String
fileName
=
null
;
String
fileName
=
null
;
...
@@ -540,7 +539,7 @@ public class FileLoader {
...
@@ -540,7 +539,7 @@ public class FileLoader {
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg1
);
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg1
);
}
}
});
});
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
loadOperationPaths
.
remove
(
arg1
);
loadOperationPaths
.
remove
(
arg1
);
...
@@ -553,6 +552,15 @@ public class FileLoader {
...
@@ -553,6 +552,15 @@ public class FileLoader {
operation
.
start
();
operation
.
start
();
}
}
}
}
}
else
if
(
photo
!=
null
)
{
currentPhotoLoadOperationsCount
--;
if
(
currentPhotoLoadOperationsCount
<
2
)
{
FileLoadOperation
operation
=
photoLoadOperationQueue
.
poll
();
if
(
operation
!=
null
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
}
}
else
{
}
else
{
currentLoadOperationsCount
--;
currentLoadOperationsCount
--;
if
(
currentLoadOperationsCount
<
2
)
{
if
(
currentLoadOperationsCount
<
2
)
{
...
@@ -579,7 +587,7 @@ public class FileLoader {
...
@@ -579,7 +587,7 @@ public class FileLoader {
}
}
});
});
}
}
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
loadOperationPaths
.
remove
(
arg1
);
loadOperationPaths
.
remove
(
arg1
);
...
@@ -592,6 +600,15 @@ public class FileLoader {
...
@@ -592,6 +600,15 @@ public class FileLoader {
operation
.
start
();
operation
.
start
();
}
}
}
}
}
else
if
(
photo
!=
null
)
{
currentPhotoLoadOperationsCount
--;
if
(
currentPhotoLoadOperationsCount
<
2
)
{
FileLoadOperation
operation
=
photoLoadOperationQueue
.
poll
();
if
(
operation
!=
null
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
}
}
else
{
}
else
{
currentLoadOperationsCount
--;
currentLoadOperationsCount
--;
if
(
currentLoadOperationsCount
<
2
)
{
if
(
currentLoadOperationsCount
<
2
)
{
...
@@ -630,6 +647,13 @@ public class FileLoader {
...
@@ -630,6 +647,13 @@ public class FileLoader {
}
else
{
}
else
{
audioLoadOperationQueue
.
add
(
operation
);
audioLoadOperationQueue
.
add
(
operation
);
}
}
}
else
if
(
photo
!=
null
)
{
if
(
currentPhotoLoadOperationsCount
<
2
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
else
{
photoLoadOperationQueue
.
add
(
operation
);
}
}
else
{
}
else
{
if
(
currentLoadOperationsCount
<
2
)
{
if
(
currentLoadOperationsCount
<
2
)
{
currentLoadOperationsCount
++;
currentLoadOperationsCount
++;
...
@@ -674,7 +698,7 @@ public class FileLoader {
...
@@ -674,7 +698,7 @@ public class FileLoader {
if
(
imageView
==
null
)
{
if
(
imageView
==
null
)
{
return
;
return
;
}
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Integer
TAG
=
getTag
(
imageView
);
Integer
TAG
=
getTag
(
imageView
);
...
@@ -776,14 +800,16 @@ public class FileLoader {
...
@@ -776,14 +800,16 @@ public class FileLoader {
if
((
url
==
null
&&
httpUrl
==
null
)
||
imageView
==
null
||
(
url
!=
null
&&
!(
url
instanceof
TLRPC
.
TL_fileLocation
)
&&
!(
url
instanceof
TLRPC
.
TL_fileEncryptedLocation
)))
{
if
((
url
==
null
&&
httpUrl
==
null
)
||
imageView
==
null
||
(
url
!=
null
&&
!(
url
instanceof
TLRPC
.
TL_fileLocation
)
&&
!(
url
instanceof
TLRPC
.
TL_fileEncryptedLocation
)))
{
return
;
return
;
}
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
String
key
;
String
key
;
String
fileName
=
null
;
if
(
httpUrl
!=
null
)
{
if
(
httpUrl
!=
null
)
{
key
=
Utilities
.
MD5
(
httpUrl
);
key
=
Utilities
.
MD5
(
httpUrl
);
}
else
{
}
else
{
key
=
url
.
volume_id
+
"_"
+
url
.
local_id
;
key
=
url
.
volume_id
+
"_"
+
url
.
local_id
;
fileName
=
key
+
".jpg"
;
}
}
if
(
filter
!=
null
)
{
if
(
filter
!=
null
)
{
key
+=
"@"
+
filter
;
key
+=
"@"
+
filter
;
...
@@ -832,6 +858,7 @@ public class FileLoader {
...
@@ -832,6 +858,7 @@ public class FileLoader {
imageLoading
.
put
(
key
,
img
);
imageLoading
.
put
(
key
,
img
);
final
String
arg2
=
key
;
final
String
arg2
=
key
;
final
String
arg3
=
fileName
;
FileLoadOperation
loadOperation
;
FileLoadOperation
loadOperation
;
if
(
httpUrl
!=
null
)
{
if
(
httpUrl
!=
null
)
{
loadOperation
=
new
FileLoadOperation
(
httpUrl
);
loadOperation
=
new
FileLoadOperation
(
httpUrl
);
...
@@ -843,30 +870,43 @@ public class FileLoader {
...
@@ -843,30 +870,43 @@ public class FileLoader {
loadOperation
.
delegate
=
new
FileLoadOperation
.
FileLoadOperationDelegate
()
{
loadOperation
.
delegate
=
new
FileLoadOperation
.
FileLoadOperationDelegate
()
{
@Override
@Override
public
void
didFinishLoadingFile
(
final
FileLoadOperation
operation
)
{
public
void
didFinishLoadingFile
(
final
FileLoadOperation
operation
)
{
enqueueImageProcessingOperationWithImage
(
operation
.
image
,
filter
,
arg2
,
img
);
if
(
operation
.
totalBytesCount
!=
0
)
{
if
(
operation
.
totalBytesCount
!=
0
)
{
fi
nal
String
arg1
=
operation
.
location
.
volume_id
+
"_"
+
operation
.
location
.
local_id
+
".jpg"
;
fi
leProgresses
.
remove
(
arg3
)
;
fileProgresses
.
remove
(
arg1
);
}
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
fileLoaderQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileLoadProgressChanged
,
arg1
,
1.0f
);
if
(
arg3
!=
null
)
{
loadOperationPaths
.
remove
(
arg3
);
}
for
(
Object
v
:
img
.
imageViewArray
)
{
imageLoadingByKeys
.
remove
(
getTag
(
v
));
}
checkOperationsAndClear
(
img
.
loadOperation
);
imageLoading
.
remove
(
arg2
);
}
}
});
});
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg1
);
img
.
callAndClear
(
operation
.
image
);
if
(
operation
.
image
!=
null
&&
memCache
.
get
(
arg2
)
==
null
)
{
memCache
.
put
(
arg2
,
operation
.
image
);
}
}
}
);
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg3
);
}
}
});
}
}
@Override
@Override
public
void
didFailedLoadingFile
(
final
FileLoadOperation
operation
)
{
public
void
didFailedLoadingFile
(
final
FileLoadOperation
operation
)
{
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
arg3
!=
null
)
{
loadOperationPaths
.
remove
(
arg3
);
}
for
(
Object
view
:
img
.
imageViewArray
)
{
for
(
Object
view
:
img
.
imageViewArray
)
{
imageLoadingByKeys
.
remove
(
getTag
(
view
));
imageLoadingByKeys
.
remove
(
getTag
(
view
));
imageLoading
.
remove
(
arg2
);
imageLoading
.
remove
(
arg2
);
...
@@ -921,6 +961,9 @@ public class FileLoader {
...
@@ -921,6 +961,9 @@ public class FileLoader {
}
else
{
}
else
{
operationsQueue
.
add
(
loadOperation
);
operationsQueue
.
add
(
loadOperation
);
}
}
if
(
fileName
!=
null
)
{
loadOperationPaths
.
put
(
fileName
,
loadOperation
);
}
}
}
}
}
});
});
...
@@ -936,85 +979,6 @@ public class FileLoader {
...
@@ -936,85 +979,6 @@ public class FileLoader {
}
}
}
}
public
void
processImage
(
Bitmap
image
,
Object
imageView
,
String
filter
,
boolean
cancel
)
{
if
(
filter
==
null
||
imageView
==
null
)
{
return
;
}
Integer
TAG
=
getTag
(
imageView
);
if
(
TAG
==
null
)
{
TAG
=
lastImageNum
;
setTag
(
image
,
TAG
);
lastImageNum
++;
if
(
lastImageNum
==
Integer
.
MAX_VALUE
)
lastImageNum
=
0
;
}
boolean
added
=
false
;
boolean
addToByKeys
=
true
;
CacheImage
alreadyLoadingImage
=
imageLoading
.
get
(
filter
);
if
(
cancel
)
{
CacheImage
ei
=
imageLoadingByKeys
.
get
(
TAG
);
if
(
ei
!=
null
)
{
if
(
ei
!=
alreadyLoadingImage
)
{
ei
.
removeImageView
(
imageView
);
if
(
ei
.
imageViewArray
.
size
()
==
0
)
{
checkOperationsAndClear
(
ei
.
loadOperation
);
ei
.
cancelAndClear
();
imageLoading
.
remove
(
ei
.
key
);
}
}
else
{
addToByKeys
=
false
;
added
=
true
;
}
}
}
if
(
alreadyLoadingImage
!=
null
&&
addToByKeys
)
{
alreadyLoadingImage
.
addImageView
(
imageView
);
imageLoadingByKeys
.
put
(
TAG
,
alreadyLoadingImage
);
added
=
true
;
}
if
(!
added
)
{
CacheImage
img
=
new
CacheImage
();
img
.
key
=
filter
;
img
.
addImageView
(
imageView
);
imageLoadingByKeys
.
put
(
TAG
,
img
);
imageLoading
.
put
(
filter
,
img
);
enqueueImageProcessingOperationWithImage
(
image
,
filter
,
filter
,
img
);
}
}
void
enqueueImageProcessingOperationWithImage
(
final
Bitmap
image
,
final
String
filter
,
final
String
key
,
final
CacheImage
img
)
{
if
(
key
==
null
)
{
return
;
}
Utilities
.
imageLoadQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
Object
v
:
img
.
imageViewArray
)
{
imageLoadingByKeys
.
remove
(
getTag
(
v
));
}
checkOperationsAndClear
(
img
.
loadOperation
);
imageLoading
.
remove
(
key
);
}
});
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
img
.
callAndClear
(
image
);
if
(
image
!=
null
&&
memCache
.
get
(
key
)
==
null
)
{
memCache
.
put
(
key
,
image
);
}
}
});
}
public
static
Bitmap
loadBitmap
(
String
path
,
Uri
uri
,
float
maxWidth
,
float
maxHeight
)
{
public
static
Bitmap
loadBitmap
(
String
path
,
Uri
uri
,
float
maxWidth
,
float
maxHeight
)
{
BitmapFactory
.
Options
bmOptions
=
new
BitmapFactory
.
Options
();
BitmapFactory
.
Options
bmOptions
=
new
BitmapFactory
.
Options
();
bmOptions
.
inJustDecodeBounds
=
true
;
bmOptions
.
inJustDecodeBounds
=
true
;
...
...
TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
View file @
ebe7ab78
...
@@ -12,9 +12,13 @@ import android.app.Activity;
...
@@ -12,9 +12,13 @@ import android.app.Activity;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.content.res.Configuration
;
import
android.content.res.Configuration
;
import
android.text.format.DateFormat
;
import
android.text.format.DateFormat
;
import
android.util.Xml
;
import
org.telegram.ui.ApplicationLoader
;
import
org.telegram.ui.ApplicationLoader
;
import
org.xmlpull.v1.XmlPullParser
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -66,42 +70,42 @@ public class LocaleController {
...
@@ -66,42 +70,42 @@ public class LocaleController {
}
}
public
LocaleController
()
{
public
LocaleController
()
{
Locale
Controller
.
LocaleInfo
localeInfo
=
new
LocaleController
.
LocaleInfo
();
Locale
Info
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"English"
;
localeInfo
.
name
=
"English"
;
localeInfo
.
nameEnglish
=
"English"
;
localeInfo
.
nameEnglish
=
"English"
;
localeInfo
.
shortName
=
"en"
;
localeInfo
.
shortName
=
"en"
;
sortedLanguages
.
add
(
localeInfo
);
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Italiano"
;
localeInfo
.
name
=
"Italiano"
;
localeInfo
.
nameEnglish
=
"Italian"
;
localeInfo
.
nameEnglish
=
"Italian"
;
localeInfo
.
shortName
=
"it"
;
localeInfo
.
shortName
=
"it"
;
sortedLanguages
.
add
(
localeInfo
);
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Español"
;
localeInfo
.
name
=
"Español"
;
localeInfo
.
nameEnglish
=
"Spanish"
;
localeInfo
.
nameEnglish
=
"Spanish"
;
localeInfo
.
shortName
=
"es"
;
localeInfo
.
shortName
=
"es"
;
sortedLanguages
.
add
(
localeInfo
);
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Deutsch"
;
localeInfo
.
name
=
"Deutsch"
;
localeInfo
.
nameEnglish
=
"German"
;
localeInfo
.
nameEnglish
=
"German"
;
localeInfo
.
shortName
=
"de"
;
localeInfo
.
shortName
=
"de"
;
sortedLanguages
.
add
(
localeInfo
);
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Nederlands"
;
localeInfo
.
name
=
"Nederlands"
;
localeInfo
.
nameEnglish
=
"Dutch"
;
localeInfo
.
nameEnglish
=
"Dutch"
;
localeInfo
.
shortName
=
"nl"
;
localeInfo
.
shortName
=
"nl"
;
sortedLanguages
.
add
(
localeInfo
);
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"العربية"
;
localeInfo
.
name
=
"العربية"
;
localeInfo
.
nameEnglish
=
"Arabic"
;
localeInfo
.
nameEnglish
=
"Arabic"
;
localeInfo
.
shortName
=
"ar"
;
localeInfo
.
shortName
=
"ar"
;
...
@@ -148,6 +152,75 @@ public class LocaleController {
...
@@ -148,6 +152,75 @@ public class LocaleController {
}
}
}
}
public
boolean
applyLanguageFile
(
File
file
)
{
try
{
HashMap
<
String
,
String
>
stringMap
=
new
HashMap
<
String
,
String
>();
XmlPullParser
parser
=
Xml
.
newPullParser
();
parser
.
setInput
(
new
FileInputStream
(
file
),
"UTF-8"
);
int
eventType
=
parser
.
getEventType
();
String
name
=
null
;
String
value
=
null
;
String
attrName
=
null
;
while
(
eventType
!=
XmlPullParser
.
END_DOCUMENT
)
{
if
(
eventType
==
XmlPullParser
.
START_TAG
)
{
name
=
parser
.
getName
();
int
c
=
parser
.
getAttributeCount
();
if
(
c
>
0
)
{
attrName
=
parser
.
getAttributeValue
(
0
);
}
}
else
if
(
eventType
==
XmlPullParser
.
TEXT
)
{
if
(
attrName
!=
null
)
{
value
=
parser
.
getText
();
}
}
else
if
(
eventType
==
XmlPullParser
.
END_TAG
)
{
value
=
null
;
attrName
=
null
;
name
=
null
;
}
if
(
name
!=
null
&&
name
.
equals
(
"string"
)
&&
value
!=
null
&&
attrName
!=
null
)
{
stringMap
.
put
(
attrName
,
value
);
name
=
null
;
value
=
null
;
attrName
=
null
;
}
eventType
=
parser
.
next
();
}
String
languageName
=
stringMap
.
get
(
"LanguageName"
);
String
languageNameInEnglish
=
stringMap
.
get
(
"LanguageNameInEnglish"
);
String
languageCode
=
stringMap
.
get
(
"LanguageCode"
);
if
(
languageName
!=
null
&&
languageName
.
length
()
>
0
&&
languageNameInEnglish
!=
null
&&
languageNameInEnglish
.
length
()
>
0
&&
languageCode
!=
null
&&
languageCode
.
length
()
>
0
)
{
LocaleInfo
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
languageName
;
localeInfo
.
nameEnglish
=
languageNameInEnglish
;
localeInfo
.
shortName
=
languageCode
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
Collections
.
sort
(
sortedLanguages
,
new
Comparator
<
LocaleInfo
>()
{
@Override
public
int
compare
(
LocaleController
.
LocaleInfo
o
,
LocaleController
.
LocaleInfo
o2
)
{
if
(
o
.
shortName
==
null
)
{
return
-
1
;
}
else
if
(
o2
.
shortName
==
null
)
{
return
1
;
}
return
o
.
name
.
compareTo
(
o2
.
name
);
}
});
applyLanguage
(
localeInfo
,
true
);
localeValues
=
stringMap
;
return
true
;
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
false
;
}
public
void
applyLanguage
(
LocaleInfo
localeInfo
,
boolean
override
)
{
public
void
applyLanguage
(
LocaleInfo
localeInfo
,
boolean
override
)
{
if
(
localeInfo
==
null
)
{
if
(
localeInfo
==
null
)
{
return
;
return
;
...
@@ -196,7 +269,7 @@ public class LocaleController {
...
@@ -196,7 +269,7 @@ public class LocaleController {
}
}
public
static
String
getCurrentLanguageName
()
{
public
static
String
getCurrentLanguageName
()
{
return
getString
(
"Langua
ngeName"
,
R
.
string
.
Languan
geName
);
return
getString
(
"Langua
geName"
,
R
.
string
.
Langua
geName
);
}
}
public
static
String
getString
(
String
key
,
int
res
)
{
public
static
String
getString
(
String
key
,
int
res
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
ebe7ab78
...
@@ -20,9 +20,12 @@ import android.media.audiofx.AutomaticGainControl;
...
@@ -20,9 +20,12 @@ import android.media.audiofx.AutomaticGainControl;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.os.Vibrator
;
import
android.os.Vibrator
;
import
android.view.View
;
import
org.telegram.objects.MessageObject
;
import
org.telegram.objects.MessageObject
;
import
org.telegram.ui.ApplicationLoader
;
import
org.telegram.ui.ApplicationLoader
;
import
org.telegram.ui.Cells.ChatMediaCell
;
import
org.telegram.ui.Views.GifDrawable
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -54,6 +57,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -54,6 +57,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public
void
onFailedDownload
(
String
fileName
);
public
void
onFailedDownload
(
String
fileName
);
public
void
onSuccessDownload
(
String
fileName
);
public
void
onSuccessDownload
(
String
fileName
);
public
void
onProgressDownload
(
String
fileName
,
float
progress
);
public
void
onProgressDownload
(
String
fileName
,
float
progress
);
public
void
onProgressUpload
(
String
fileName
,
float
progress
,
boolean
isEncrypted
);
public
int
getObserverTag
();
public
int
getObserverTag
();
}
}
...
@@ -84,6 +88,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -84,6 +88,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private
ArrayList
<
FileDownloadProgressListener
>
deleteLaterArray
=
new
ArrayList
<
FileDownloadProgressListener
>();
private
ArrayList
<
FileDownloadProgressListener
>
deleteLaterArray
=
new
ArrayList
<
FileDownloadProgressListener
>();
private
int
lastTag
=
0
;
private
int
lastTag
=
0
;
private
GifDrawable
currentGifDrawable
;
private
MessageObject
currentGifMessageObject
;
private
ChatMediaCell
currentMediaCell
;
private
boolean
isPaused
=
false
;
private
boolean
isPaused
=
false
;
private
MediaPlayer
audioPlayer
=
null
;
private
MediaPlayer
audioPlayer
=
null
;
private
AudioTrack
audioTrackPlayer
=
null
;
private
AudioTrack
audioTrackPlayer
=
null
;
...
@@ -226,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -226,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidFailedLoad
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidFailedLoad
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidLoaded
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidLoaded
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileLoadProgressChanged
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileLoadProgressChanged
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileUploadProgressChanged
);
Timer
progressTimer
=
new
Timer
();
Timer
progressTimer
=
new
Timer
();
progressTimer
.
schedule
(
new
TimerTask
()
{
progressTimer
.
schedule
(
new
TimerTask
()
{
...
@@ -273,6 +282,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -273,6 +282,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public
void
cleanup
()
{
public
void
cleanup
()
{
clenupPlayer
(
false
);
clenupPlayer
(
false
);
if
(
currentGifDrawable
!=
null
)
{
currentGifDrawable
.
recycle
();
currentGifDrawable
=
null
;
}
currentMediaCell
=
null
;
currentGifMessageObject
=
null
;
}
}
public
int
generateObserverTag
()
{
public
int
generateObserverTag
()
{
...
@@ -377,6 +392,22 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -377,6 +392,22 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
}
listenerInProgress
=
false
;
listenerInProgress
=
false
;
processLaterArrays
();
processLaterArrays
();
}
else
if
(
id
==
FileLoader
.
FileUploadProgressChanged
)
{
String
location
=
(
String
)
args
[
0
];
listenerInProgress
=
true
;
String
fileName
=
(
String
)
args
[
0
];
ArrayList
<
WeakReference
<
FileDownloadProgressListener
>>
arrayList
=
loadingFileObservers
.
get
(
fileName
);
if
(
arrayList
!=
null
)
{
Float
progress
=
(
Float
)
args
[
1
];
Boolean
enc
=
(
Boolean
)
args
[
2
];
for
(
WeakReference
<
FileDownloadProgressListener
>
reference
:
arrayList
)
{
if
(
reference
.
get
()
!=
null
)
{
reference
.
get
().
onProgressUpload
(
fileName
,
progress
,
enc
);
}
}
}
listenerInProgress
=
false
;
processLaterArrays
();
}
}
}
}
...
@@ -1079,4 +1110,73 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -1079,4 +1110,73 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
});
});
}
}
}
}
public
GifDrawable
getGifDrawable
(
ChatMediaCell
cell
,
boolean
create
)
{
if
(
cell
==
null
)
{
return
null
;
}
MessageObject
messageObject
=
cell
.
getMessageObject
();
if
(
messageObject
==
null
)
{
return
null
;
}
if
(
currentGifMessageObject
!=
null
&&
messageObject
.
messageOwner
.
id
==
currentGifMessageObject
.
messageOwner
.
id
)
{
currentMediaCell
=
cell
;
currentGifDrawable
.
parentView
=
new
WeakReference
<
View
>(
cell
);
return
currentGifDrawable
;
}
if
(
create
)
{
if
(
currentMediaCell
!=
null
)
{
if
(
currentGifDrawable
!=
null
)
{
currentGifDrawable
.
stop
();
currentGifDrawable
.
recycle
();
}
currentMediaCell
.
clearGifImage
();
}
currentGifMessageObject
=
cell
.
getMessageObject
();
currentMediaCell
=
cell
;
File
cacheFile
=
null
;
if
(
currentGifMessageObject
.
messageOwner
.
attachPath
!=
null
&&
currentGifMessageObject
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
File
f
=
new
File
(
currentGifMessageObject
.
messageOwner
.
attachPath
);
if
(
f
.
length
()
>
0
)
{
cacheFile
=
f
;
}
}
else
{
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
}
try
{
currentGifDrawable
=
new
GifDrawable
(
cacheFile
);
currentGifDrawable
.
parentView
=
new
WeakReference
<
View
>(
cell
);
return
currentGifDrawable
;
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
return
null
;
}
public
void
clearGifDrawable
(
ChatMediaCell
cell
)
{
if
(
cell
==
null
)
{
return
;
}
MessageObject
messageObject
=
cell
.
getMessageObject
();
if
(
messageObject
==
null
)
{
return
;
}
if
(
currentGifMessageObject
!=
null
&&
messageObject
.
messageOwner
.
id
==
currentGifMessageObject
.
messageOwner
.
id
)
{
if
(
currentGifDrawable
!=
null
)
{
currentGifDrawable
.
stop
();
currentGifDrawable
.
recycle
();
currentGifDrawable
=
null
;
}
currentMediaCell
=
null
;
currentGifMessageObject
=
null
;
}
}
}
}
TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
View file @
ebe7ab78
...
@@ -1895,6 +1895,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -1895,6 +1895,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
delayedMessage
.
type
=
2
;
delayedMessage
.
type
=
2
;
delayedMessage
.
obj
=
newMsgObj
;
delayedMessage
.
obj
=
newMsgObj
;
delayedMessage
.
documentLocation
=
document
;
delayedMessage
.
documentLocation
=
document
;
delayedMessage
.
location
=
document
.
thumb
.
location
;
performSendDelayedMessage
(
delayedMessage
);
performSendDelayedMessage
(
delayedMessage
);
}
else
if
(
type
==
8
)
{
}
else
if
(
type
==
8
)
{
reqSend
.
media
=
new
TLRPC
.
TL_inputMediaUploadedAudio
();
reqSend
.
media
=
new
TLRPC
.
TL_inputMediaUploadedAudio
();
...
@@ -1976,9 +1977,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -1976,9 +1977,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
random
.
nextBytes
(
reqSend
.
media
.
iv
);
random
.
nextBytes
(
reqSend
.
media
.
iv
);
random
.
nextBytes
(
reqSend
.
media
.
key
);
random
.
nextBytes
(
reqSend
.
media
.
key
);
reqSend
.
media
.
size
=
document
.
size
;
reqSend
.
media
.
size
=
document
.
size
;
if
(!(
document
.
thumb
instanceof
TLRPC
.
TL_photoSizeEmpty
))
{
reqSend
.
media
.
thumb
=
document
.
thumb
.
bytes
;
reqSend
.
media
.
thumb_h
=
document
.
thumb
.
h
;
reqSend
.
media
.
thumb_w
=
document
.
thumb
.
w
;
}
else
{
reqSend
.
media
.
thumb
=
new
byte
[
0
];
reqSend
.
media
.
thumb
=
new
byte
[
0
];
reqSend
.
media
.
thumb_h
=
0
;
reqSend
.
media
.
thumb_h
=
0
;
reqSend
.
media
.
thumb_w
=
0
;
reqSend
.
media
.
thumb_w
=
0
;
}
reqSend
.
media
.
file_name
=
document
.
file_name
;
reqSend
.
media
.
file_name
=
document
.
file_name
;
reqSend
.
media
.
mime_type
=
document
.
mime_type
;
reqSend
.
media
.
mime_type
=
document
.
mime_type
;
...
@@ -2051,18 +2058,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2051,18 +2058,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if
(
size2
.
location
!=
null
&&
size
.
location
!=
null
&&
!(
size
instanceof
TLRPC
.
TL_photoSizeEmpty
)
&&
!(
size2
instanceof
TLRPC
.
TL_photoSizeEmpty
))
{
if
(
size2
.
location
!=
null
&&
size
.
location
!=
null
&&
!(
size
instanceof
TLRPC
.
TL_photoSizeEmpty
)
&&
!(
size2
instanceof
TLRPC
.
TL_photoSizeEmpty
))
{
String
fileName
=
size2
.
location
.
volume_id
+
"_"
+
size2
.
location
.
local_id
;
String
fileName
=
size2
.
location
.
volume_id
+
"_"
+
size2
.
location
.
local_id
;
String
fileName2
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
;
String
fileName2
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
;
if
(
fileName
.
equals
(
fileName2
))
{
if
(!
fileName
.
equals
(
fileName2
))
{
return
;
}
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
+
".jpg"
);
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
+
".jpg"
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
+
".jpg"
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
+
".jpg"
);
boolean
result
=
cacheFile
.
renameTo
(
cacheFile2
);
boolean
result
=
cacheFile
.
renameTo
(
cacheFile2
);
FileLoader
.
getInstance
().
replaceImageInCache
(
fileName
,
fileName2
);
FileLoader
.
getInstance
().
replaceImageInCache
(
fileName
,
fileName2
);
size2
.
location
=
size
.
location
;
size2
.
location
=
size
.
location
;
}
}
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
}
}
else
if
(
sentMessage
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
&&
sentMessage
.
media
.
document
!=
null
&&
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
&&
newMsg
.
media
.
document
!=
null
)
{
}
else
if
(
sentMessage
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
&&
sentMessage
.
media
.
document
!=
null
&&
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
&&
newMsg
.
media
.
document
!=
null
)
{
TLRPC
.
PhotoSize
size2
=
newMsg
.
media
.
document
.
thumb
;
TLRPC
.
PhotoSize
size
=
sentMessage
.
media
.
document
.
thumb
;
if
(
size2
.
location
!=
null
&&
size
.
location
!=
null
&&
!(
size
instanceof
TLRPC
.
TL_photoSizeEmpty
)
&&
!(
size2
instanceof
TLRPC
.
TL_photoSizeEmpty
))
{
String
fileName
=
size2
.
location
.
volume_id
+
"_"
+
size2
.
location
.
local_id
;
String
fileName2
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
;
if
(!
fileName
.
equals
(
fileName2
))
{
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
+
".jpg"
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
+
".jpg"
);
boolean
result
=
cacheFile
.
renameTo
(
cacheFile2
);
FileLoader
.
getInstance
().
replaceImageInCache
(
fileName
,
fileName2
);
size2
.
location
=
size
.
location
;
}
}
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
message
=
newMsg
.
message
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
sentMessage
.
attachPath
=
newMsg
.
attachPath
;
}
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
)
{
...
@@ -2071,15 +2090,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2071,15 +2090,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
String
fileName
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
String
fileName
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
String
fileName2
=
sentMessage
.
media
.
audio
.
dc_id
+
"_"
+
sentMessage
.
media
.
audio
.
id
+
".m4a"
;
String
fileName2
=
sentMessage
.
media
.
audio
.
dc_id
+
"_"
+
sentMessage
.
media
.
audio
.
id
+
".m4a"
;
if
(
fileName
.
equals
(
fileName2
))
{
if
(!
fileName
.
equals
(
fileName2
))
{
return
;
}
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
cacheFile
.
renameTo
(
cacheFile2
);
newMsg
.
media
.
audio
.
dc_id
=
sentMessage
.
media
.
audio
.
dc_id
;
newMsg
.
media
.
audio
.
dc_id
=
sentMessage
.
media
.
audio
.
dc_id
;
newMsg
.
media
.
audio
.
id
=
sentMessage
.
media
.
audio
.
id
;
newMsg
.
media
.
audio
.
id
=
sentMessage
.
media
.
audio
.
id
;
}
}
}
}
else
if
(
file
!=
null
)
{
}
else
if
(
file
!=
null
)
{
if
(
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
&&
newMsg
.
media
.
photo
!=
null
)
{
if
(
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
&&
newMsg
.
media
.
photo
!=
null
)
{
TLRPC
.
PhotoSize
size
=
newMsg
.
media
.
photo
.
sizes
.
get
(
newMsg
.
media
.
photo
.
sizes
.
size
()
-
1
);
TLRPC
.
PhotoSize
size
=
newMsg
.
media
.
photo
.
sizes
.
get
(
newMsg
.
media
.
photo
.
sizes
.
size
()
-
1
);
...
@@ -2154,12 +2172,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2154,12 +2172,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
String
fileName
=
audio
.
dc_id
+
"_"
+
audio
.
id
+
".m4a"
;
String
fileName
=
audio
.
dc_id
+
"_"
+
audio
.
id
+
".m4a"
;
String
fileName2
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
String
fileName2
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
if
(
fileName
.
equals
(
fileName2
))
{
if
(!
fileName
.
equals
(
fileName2
))
{
return
;
}
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
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
);
...
@@ -2429,6 +2446,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2429,6 +2446,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
}
}
}
else
if
(
message
.
type
==
2
)
{
}
else
if
(
message
.
type
==
2
)
{
if
(
message
.
sendRequest
!=
null
&&
message
.
sendRequest
.
media
.
thumb
==
null
&&
message
.
location
!=
null
)
{
String
location
=
Utilities
.
getCacheDir
()
+
"/"
+
message
.
location
.
volume_id
+
"_"
+
message
.
location
.
local_id
+
".jpg"
;
putToDelayedMessages
(
location
,
message
);
FileLoader
.
getInstance
().
uploadFile
(
location
,
null
,
null
);
}
else
{
String
location
=
message
.
documentLocation
.
path
;
String
location
=
message
.
documentLocation
.
path
;
putToDelayedMessages
(
location
,
message
);
putToDelayedMessages
(
location
,
message
);
if
(
message
.
sendRequest
!=
null
)
{
if
(
message
.
sendRequest
!=
null
)
{
...
@@ -2436,6 +2458,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2436,6 +2458,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
else
{
}
else
{
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
}
}
}
}
else
if
(
message
.
type
==
3
)
{
}
else
if
(
message
.
type
==
3
)
{
String
location
=
message
.
audioLocation
.
path
;
String
location
=
message
.
audioLocation
.
path
;
putToDelayedMessages
(
location
,
message
);
putToDelayedMessages
(
location
,
message
);
...
@@ -2545,8 +2568,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -2545,8 +2568,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
}
}
}
else
if
(
message
.
type
==
2
)
{
}
else
if
(
message
.
type
==
2
)
{
if
(
message
.
sendRequest
.
media
.
thumb
==
null
&&
message
.
location
!=
null
)
{
message
.
sendRequest
.
media
.
thumb
=
file
;
performSendDelayedMessage
(
message
);
}
else
{
message
.
sendRequest
.
media
.
file
=
file
;
message
.
sendRequest
.
media
.
file
=
file
;
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
}
}
else
if
(
message
.
type
==
3
)
{
}
else
if
(
message
.
type
==
3
)
{
message
.
sendRequest
.
media
.
file
=
file
;
message
.
sendRequest
.
media
.
file
=
file
;
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
...
@@ -4692,7 +4720,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -4692,7 +4720,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage
.
media
.
geo
.
lat
=
decryptedMessage
.
media
.
lat
;
newMessage
.
media
.
geo
.
lat
=
decryptedMessage
.
media
.
lat
;
newMessage
.
media
.
geo
.
_long
=
decryptedMessage
.
media
.
_long
;
newMessage
.
media
.
geo
.
_long
=
decryptedMessage
.
media
.
_long
;
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaPhoto
)
{
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaPhoto
)
{
if
(
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
if
(
decryptedMessage
.
media
.
key
==
null
||
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
==
null
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
return
null
;
return
null
;
}
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaPhoto
();
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaPhoto
();
...
@@ -4725,7 +4753,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -4725,7 +4753,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
big
.
location
.
local_id
=
message
.
file
.
key_fingerprint
;
big
.
location
.
local_id
=
message
.
file
.
key_fingerprint
;
newMessage
.
media
.
photo
.
sizes
.
add
(
big
);
newMessage
.
media
.
photo
.
sizes
.
add
(
big
);
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaVideo
)
{
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaVideo
)
{
if
(
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
if
(
decryptedMessage
.
media
.
key
==
null
||
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
==
null
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
return
null
;
return
null
;
}
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaVideo
();
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaVideo
();
...
@@ -4754,7 +4782,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -4754,7 +4782,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage
.
media
.
video
.
key
=
decryptedMessage
.
media
.
key
;
newMessage
.
media
.
video
.
key
=
decryptedMessage
.
media
.
key
;
newMessage
.
media
.
video
.
iv
=
decryptedMessage
.
media
.
iv
;
newMessage
.
media
.
video
.
iv
=
decryptedMessage
.
media
.
iv
;
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaDocument
)
{
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaDocument
)
{
if
(
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
if
(
decryptedMessage
.
media
.
key
==
null
||
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
==
null
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
return
null
;
return
null
;
}
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaDocument
();
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaDocument
();
...
@@ -4781,7 +4809,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
...
@@ -4781,7 +4809,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
newMessage
.
media
.
document
.
dc_id
=
message
.
file
.
dc_id
;
newMessage
.
media
.
document
.
dc_id
=
message
.
file
.
dc_id
;
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaAudio
)
{
}
else
if
(
decryptedMessage
.
media
instanceof
TLRPC
.
TL_decryptedMessageMediaAudio
)
{
if
(
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
if
(
decryptedMessage
.
media
.
key
==
null
||
decryptedMessage
.
media
.
key
.
length
!=
32
||
decryptedMessage
.
media
.
iv
==
null
||
decryptedMessage
.
media
.
iv
.
length
!=
32
)
{
return
null
;
return
null
;
}
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaAudio
();
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaAudio
();
...
...
TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
View file @
ebe7ab78
...
@@ -76,9 +76,6 @@ public class Utilities {
...
@@ -76,9 +76,6 @@ public class Utilities {
public
static
volatile
DispatchQueue
stageQueue
=
new
DispatchQueue
(
"stageQueue"
);
public
static
volatile
DispatchQueue
stageQueue
=
new
DispatchQueue
(
"stageQueue"
);
public
static
volatile
DispatchQueue
globalQueue
=
new
DispatchQueue
(
"globalQueue"
);
public
static
volatile
DispatchQueue
globalQueue
=
new
DispatchQueue
(
"globalQueue"
);
public
static
volatile
DispatchQueue
cacheOutQueue
=
new
DispatchQueue
(
"cacheOutQueue"
);
public
static
volatile
DispatchQueue
imageLoadQueue
=
new
DispatchQueue
(
"imageLoadQueue"
);
public
static
volatile
DispatchQueue
fileUploadQueue
=
new
DispatchQueue
(
"fileUploadQueue"
);
public
static
int
[]
arrColors
=
{
0xffee4928
,
0xff41a903
,
0xffe09602
,
0xff0f94ed
,
0xff8f3bf7
,
0xfffc4380
,
0xff00a1c4
,
0xffeb7002
};
public
static
int
[]
arrColors
=
{
0xffee4928
,
0xff41a903
,
0xffe09602
,
0xff0f94ed
,
0xff8f3bf7
,
0xfffc4380
,
0xff00a1c4
,
0xffeb7002
};
public
static
int
[]
arrUsersAvatars
=
{
public
static
int
[]
arrUsersAvatars
=
{
...
...
TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java
View file @
ebe7ab78
...
@@ -35,6 +35,7 @@ public class MessageObject {
...
@@ -35,6 +35,7 @@ public class MessageObject {
public
TLRPC
.
Message
messageOwner
;
public
TLRPC
.
Message
messageOwner
;
public
CharSequence
messageText
;
public
CharSequence
messageText
;
public
int
type
;
public
int
type
;
public
int
contentType
;
public
ArrayList
<
PhotoObject
>
photoThumbs
;
public
ArrayList
<
PhotoObject
>
photoThumbs
;
public
Bitmap
imagePreview
;
public
Bitmap
imagePreview
;
public
PhotoObject
previewPhoto
;
public
PhotoObject
previewPhoto
;
...
@@ -244,6 +245,11 @@ public class MessageObject {
...
@@ -244,6 +245,11 @@ public class MessageObject {
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
messageText
=
LocaleController
.
getString
(
"UnsuppotedMedia"
,
R
.
string
.
UnsuppotedMedia
);
messageText
=
LocaleController
.
getString
(
"UnsuppotedMedia"
,
R
.
string
.
UnsuppotedMedia
);
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
if
(!(
message
.
media
.
document
.
thumb
instanceof
TLRPC
.
TL_photoSizeEmpty
))
{
photoThumbs
=
new
ArrayList
<
PhotoObject
>();
PhotoObject
obj
=
new
PhotoObject
(
message
.
media
.
document
.
thumb
);
photoThumbs
.
add
(
obj
);
}
messageText
=
LocaleController
.
getString
(
"AttachDocument"
,
R
.
string
.
AttachDocument
);
messageText
=
LocaleController
.
getString
(
"AttachDocument"
,
R
.
string
.
AttachDocument
);
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
messageText
=
LocaleController
.
getString
(
"AttachAudio"
,
R
.
string
.
AttachAudio
);
messageText
=
LocaleController
.
getString
(
"AttachAudio"
,
R
.
string
.
AttachAudio
);
...
@@ -255,68 +261,53 @@ public class MessageObject {
...
@@ -255,68 +261,53 @@ public class MessageObject {
if
(
message
instanceof
TLRPC
.
TL_message
||
(
message
instanceof
TLRPC
.
TL_messageForwarded
&&
(
message
.
media
==
null
||
!(
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))))
{
if
(
message
instanceof
TLRPC
.
TL_message
||
(
message
instanceof
TLRPC
.
TL_messageForwarded
&&
(
message
.
media
==
null
||
!(
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))))
{
if
(
message
.
media
==
null
||
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)
{
if
(
message
.
media
==
null
||
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
contentType
=
type
=
0
;
type
=
0
;
}
else
{
type
=
1
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
contentType
=
type
=
1
;
type
=
2
;
}
else
{
type
=
3
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaGeo
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaGeo
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
4
;
contentType
=
type
=
4
;
}
else
{
}
else
{
type
=
5
;
contentType
=
type
=
5
;
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
6
;
contentType
=
type
=
6
;
}
else
{
}
else
{
type
=
7
;
contentType
=
type
=
7
;
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaContact
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaContact
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
12
;
contentType
=
type
=
12
;
}
else
{
}
else
{
type
=
13
;
contentType
=
type
=
13
;
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
contentType
=
type
=
0
;
type
=
0
;
}
else
{
type
=
1
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
media
.
document
.
thumb
!=
null
&&
!(
message
.
media
.
document
.
thumb
instanceof
TLRPC
.
TL_photoSizeEmpty
)
&&
message
.
media
.
document
.
mime_type
!=
null
&&
message
.
media
.
document
.
mime_type
.
equals
(
"image/gif"
))
{
type
=
16
;
contentType
=
1
;
type
=
8
;
}
else
{
}
else
{
type
=
17
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
1
8
;
contentType
=
type
=
8
;
}
else
{
}
else
{
type
=
1
9
;
contentType
=
type
=
9
;
}
}
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
contentType
=
type
=
2
;
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
}
else
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionLoginUnknownLocation
)
{
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionLoginUnknownLocation
)
{
type
=
1
;
contentType
=
type
=
0
;
}
else
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionChatEditPhoto
||
message
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
}
else
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionChatEditPhoto
||
message
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
type
=
11
;
contentType
=
type
=
11
;
}
else
{
}
else
{
type
=
10
;
contentType
=
type
=
10
;
}
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageForwarded
)
{
}
else
if
(
message
instanceof
TLRPC
.
TL_messageForwarded
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
contentType
=
type
=
0
;
type
=
8
;
}
else
{
type
=
9
;
}
}
}
Calendar
rightNow
=
new
GregorianCalendar
();
Calendar
rightNow
=
new
GregorianCalendar
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java
View file @
ebe7ab78
...
@@ -60,8 +60,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -60,8 +60,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
private
TLRPC
.
FileLocation
currentPhoto
;
private
TLRPC
.
FileLocation
currentPhoto
;
private
String
currentNameString
;
private
String
currentNameString
;
public
ChatAudioCell
(
Context
context
,
boolean
isChat
)
{
public
ChatAudioCell
(
Context
context
)
{
super
(
context
,
isChat
);
super
(
context
,
false
);
TAG
=
MediaController
.
getInstance
().
generateObserverTag
();
TAG
=
MediaController
.
getInstance
().
generateObserverTag
();
avatarImage
=
new
ImageReceiver
();
avatarImage
=
new
ImageReceiver
();
...
@@ -101,6 +101,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -101,6 +101,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
avatarImage
.
clearImage
();
avatarImage
.
clearImage
();
currentPhoto
=
null
;
currentPhoto
=
null
;
}
}
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
}
}
@Override
@Override
...
@@ -230,7 +231,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -230,7 +231,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
}
}
progressView
.
setProgress
(
0
);
progressView
.
setProgress
(
0
);
}
else
{
}
else
{
MediaController
.
getInstance
().
addLoadingFileObserver
(
currentMessageObject
.
getFileName
()
,
this
);
MediaController
.
getInstance
().
addLoadingFileObserver
(
fileName
,
this
);
if
(!
FileLoader
.
getInstance
().
isLoadingFile
(
fileName
))
{
if
(!
FileLoader
.
getInstance
().
isLoadingFile
(
fileName
))
{
buttonState
=
2
;
buttonState
=
2
;
progressView
.
setProgress
(
0
);
progressView
.
setProgress
(
0
);
...
@@ -263,6 +264,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -263,6 +264,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate
();
invalidate
();
}
}
@Override
public
void
onProgressUpload
(
String
fileName
,
float
progress
,
boolean
isEncrypted
)
{
}
@Override
@Override
public
int
getObserverTag
()
{
public
int
getObserverTag
()
{
return
TAG
;
return
TAG
;
...
@@ -281,7 +287,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -281,7 +287,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
int
width
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
int
width
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
setMeasuredDimension
(
width
,
Utilities
.
dp
(
68
));
setMeasuredDimension
(
width
,
Utilities
.
dp
(
68
));
if
(
c
hat
)
{
if
(
isC
hat
)
{
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
102
),
Utilities
.
dp
(
300
));
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
102
),
Utilities
.
dp
(
300
));
}
else
{
}
else
{
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
50
),
Utilities
.
dp
(
300
));
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
50
),
Utilities
.
dp
(
300
));
...
@@ -298,7 +304,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -298,7 +304,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
buttonX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
67
);
buttonX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
67
);
timeX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
71
);
timeX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
71
);
}
else
{
}
else
{
if
(
c
hat
)
{
if
(
isC
hat
)
{
avatarImage
.
imageX
=
Utilities
.
dp
(
69
);
avatarImage
.
imageX
=
Utilities
.
dp
(
69
);
seekBarX
=
Utilities
.
dp
(
158
);
seekBarX
=
Utilities
.
dp
(
158
);
buttonX
=
Utilities
.
dp
(
128
);
buttonX
=
Utilities
.
dp
(
128
);
...
@@ -355,10 +361,10 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -355,10 +361,10 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if
(
messageObject
.
messageOwner
.
out
)
{
if
(
messageObject
.
messageOwner
.
out
)
{
seekBar
.
type
=
0
;
seekBar
.
type
=
0
;
progressView
.
type
=
0
;
progressView
.
setProgressColors
(
0xffb4e396
,
0xff6ac453
)
;
}
else
{
}
else
{
seekBar
.
type
=
1
;
seekBar
.
type
=
1
;
progressView
.
type
=
1
;
progressView
.
setProgressColors
(
0xffd9e2eb
,
0xff86c5f8
)
;
}
}
super
.
setMessageObject
(
messageObject
);
super
.
setMessageObject
(
messageObject
);
...
@@ -405,10 +411,4 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
...
@@ -405,10 +411,4 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
timeLayout
.
draw
(
canvas
);
timeLayout
.
draw
(
canvas
);
canvas
.
restore
();
canvas
.
restore
();
}
}
@Override
protected
void
finalize
()
throws
Throwable
{
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
super
.
finalize
();
}
}
}
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
View file @
ebe7ab78
...
@@ -35,25 +35,37 @@ public class ChatBaseCell extends BaseCell {
...
@@ -35,25 +35,37 @@ public class ChatBaseCell extends BaseCell {
public
static
interface
ChatBaseCellDelegate
{
public
static
interface
ChatBaseCellDelegate
{
public
abstract
void
didPressedUserAvatar
(
ChatBaseCell
cell
,
TLRPC
.
User
user
);
public
abstract
void
didPressedUserAvatar
(
ChatBaseCell
cell
,
TLRPC
.
User
user
);
public
abstract
void
didPressedCanceSendButton
(
ChatBaseCell
cell
);
}
}
p
rotected
boolean
chat
;
p
ublic
boolean
isChat
=
false
;
protected
boolean
isPressed
=
false
;
protected
boolean
isPressed
=
false
;
protected
boolean
forwardName
=
false
;
protected
boolean
forwardName
=
false
;
protected
boolean
media
=
false
;
private
boolean
isCheckPressed
=
true
;
private
boolean
isCheckPressed
=
true
;
private
boolean
wasLayout
=
false
;
private
boolean
wasLayout
=
false
;
protected
boolean
isAvatarVisible
=
false
;
protected
MessageObject
currentMessageObject
;
protected
MessageObject
currentMessageObject
;
private
static
Drawable
backgroundDrawableIn
;
private
static
Drawable
backgroundDrawableIn
;
private
static
Drawable
backgroundDrawableInSelected
;
private
static
Drawable
backgroundDrawableInSelected
;
private
static
Drawable
backgroundDrawableOut
;
private
static
Drawable
backgroundDrawableOut
;
private
static
Drawable
backgroundDrawableOutSelected
;
private
static
Drawable
backgroundDrawableOutSelected
;
private
static
Drawable
backgroundMediaDrawableIn
;
private
static
Drawable
backgroundMediaDrawableInSelected
;
private
static
Drawable
backgroundMediaDrawableOut
;
private
static
Drawable
backgroundMediaDrawableOutSelected
;
private
static
Drawable
checkDrawable
;
private
static
Drawable
checkDrawable
;
private
static
Drawable
halfCheckDrawable
;
private
static
Drawable
halfCheckDrawable
;
private
static
Drawable
clockDrawable
;
private
static
Drawable
clockDrawable
;
private
static
Drawable
checkMediaDrawable
;
private
static
Drawable
halfCheckMediaDrawable
;
private
static
Drawable
clockMediaDrawable
;
private
static
Drawable
errorDrawable
;
private
static
Drawable
errorDrawable
;
protected
static
Drawable
mediaBackgroundDrawable
;
private
static
TextPaint
timePaintIn
;
private
static
TextPaint
timePaintIn
;
private
static
TextPaint
timePaintOut
;
private
static
TextPaint
timePaintOut
;
private
static
TextPaint
timeMediaPaint
;
private
static
TextPaint
namePaint
;
private
static
TextPaint
namePaint
;
private
static
TextPaint
forwardNamePaint
;
private
static
TextPaint
forwardNamePaint
;
...
@@ -95,24 +107,20 @@ public class ChatBaseCell extends BaseCell {
...
@@ -95,24 +107,20 @@ public class ChatBaseCell extends BaseCell {
protected
int
namesOffset
=
0
;
protected
int
namesOffset
=
0
;
public
ChatBaseCell
(
Context
context
,
boolean
is
Chat
)
{
public
ChatBaseCell
(
Context
context
,
boolean
is
Media
)
{
super
(
context
);
super
(
context
);
init
();
init
();
chat
=
isChat
;
media
=
isMedia
;
if
(
chat
)
{
avatarImage
=
new
ImageReceiver
();
avatarImage
=
new
ImageReceiver
();
avatarImage
.
parentView
=
new
WeakReference
<
View
>(
this
);
avatarImage
.
parentView
=
new
WeakReference
<
View
>(
this
);
}
}
}
@Override
@Override
protected
void
onDetachedFromWindow
()
{
protected
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
super
.
onDetachedFromWindow
();
if
(
avatarImage
!=
null
)
{
avatarImage
.
clearImage
();
avatarImage
.
clearImage
();
currentPhoto
=
null
;
currentPhoto
=
null
;
}
}
}
private
void
init
()
{
private
void
init
()
{
if
(
backgroundDrawableIn
==
null
)
{
if
(
backgroundDrawableIn
==
null
)
{
...
@@ -120,10 +128,18 @@ public class ChatBaseCell extends BaseCell {
...
@@ -120,10 +128,18 @@ public class ChatBaseCell extends BaseCell {
backgroundDrawableInSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_in_selected
);
backgroundDrawableInSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_in_selected
);
backgroundDrawableOut
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out
);
backgroundDrawableOut
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out
);
backgroundDrawableOutSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out_selected
);
backgroundDrawableOutSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out_selected
);
backgroundMediaDrawableIn
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_in_photo
);
backgroundMediaDrawableInSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_in_photo_selected
);
backgroundMediaDrawableOut
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out_photo
);
backgroundMediaDrawableOutSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out_photo_selected
);
checkDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_check
);
checkDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_check
);
halfCheckDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_halfcheck
);
halfCheckDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_halfcheck
);
clockDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_clock
);
clockDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_clock
);
checkMediaDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_check_w
);
halfCheckMediaDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_halfcheck_w
);
clockMediaDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_clock_photo
);
errorDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_warning
);
errorDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_warning
);
mediaBackgroundDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
phototime
);
timePaintIn
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
timePaintIn
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
timePaintIn
.
setTextSize
(
Utilities
.
dp
(
12
));
timePaintIn
.
setTextSize
(
Utilities
.
dp
(
12
));
...
@@ -133,11 +149,16 @@ public class ChatBaseCell extends BaseCell {
...
@@ -133,11 +149,16 @@ public class ChatBaseCell extends BaseCell {
timePaintOut
.
setTextSize
(
Utilities
.
dp
(
12
));
timePaintOut
.
setTextSize
(
Utilities
.
dp
(
12
));
timePaintOut
.
setColor
(
0xff70b15c
);
timePaintOut
.
setColor
(
0xff70b15c
);
timeMediaPaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
timeMediaPaint
.
setTextSize
(
Utilities
.
dp
(
12
));
timeMediaPaint
.
setColor
(
0xffffffff
);
namePaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
namePaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
namePaint
.
setTextSize
(
Utilities
.
dp
(
15
));
namePaint
.
setTextSize
(
Utilities
.
dp
(
15
));
forwardNamePaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
forwardNamePaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
forwardNamePaint
.
setTextSize
(
Utilities
.
dp
(
14
));
forwardNamePaint
.
setTextSize
(
Utilities
.
dp
(
14
));
}
}
}
}
...
@@ -160,7 +181,7 @@ public class ChatBaseCell extends BaseCell {
...
@@ -160,7 +181,7 @@ public class ChatBaseCell extends BaseCell {
TLRPC
.
User
newUser
=
MessagesController
.
getInstance
().
users
.
get
(
currentMessageObject
.
messageOwner
.
from_id
);
TLRPC
.
User
newUser
=
MessagesController
.
getInstance
().
users
.
get
(
currentMessageObject
.
messageOwner
.
from_id
);
TLRPC
.
FileLocation
newPhoto
=
null
;
TLRPC
.
FileLocation
newPhoto
=
null
;
if
(
avatarImage
!=
null
&&
newUser
!=
null
&&
newUser
.
photo
!=
null
)
{
if
(
isAvatarVisible
&&
newUser
!=
null
&&
newUser
.
photo
!=
null
)
{
newPhoto
=
newUser
.
photo
.
photo_small
;
newPhoto
=
newUser
.
photo
.
photo_small
;
}
}
...
@@ -169,7 +190,7 @@ public class ChatBaseCell extends BaseCell {
...
@@ -169,7 +190,7 @@ public class ChatBaseCell extends BaseCell {
}
}
String
newNameString
=
null
;
String
newNameString
=
null
;
if
(
drawName
&&
c
hat
&&
newUser
!=
null
&&
!
currentMessageObject
.
messageOwner
.
out
)
{
if
(
drawName
&&
isC
hat
&&
newUser
!=
null
&&
!
currentMessageObject
.
messageOwner
.
out
)
{
newNameString
=
Utilities
.
formatName
(
newUser
.
first_name
,
newUser
.
last_name
);
newNameString
=
Utilities
.
formatName
(
newUser
.
first_name
,
newUser
.
last_name
);
}
}
...
@@ -198,7 +219,8 @@ public class ChatBaseCell extends BaseCell {
...
@@ -198,7 +219,8 @@ public class ChatBaseCell extends BaseCell {
}
}
currentUser
=
MessagesController
.
getInstance
().
users
.
get
(
messageObject
.
messageOwner
.
from_id
);
currentUser
=
MessagesController
.
getInstance
().
users
.
get
(
messageObject
.
messageOwner
.
from_id
);
if
(
avatarImage
!=
null
)
{
if
(
isChat
&&
!
messageObject
.
messageOwner
.
out
)
{
isAvatarVisible
=
true
;
if
(
currentUser
!=
null
)
{
if
(
currentUser
!=
null
)
{
if
(
currentUser
.
photo
!=
null
)
{
if
(
currentUser
.
photo
!=
null
)
{
currentPhoto
=
currentUser
.
photo
.
photo_small
;
currentPhoto
=
currentUser
.
photo
.
photo_small
;
...
@@ -209,18 +231,22 @@ public class ChatBaseCell extends BaseCell {
...
@@ -209,18 +231,22 @@ public class ChatBaseCell extends BaseCell {
}
}
}
}
if
(!
media
)
{
if
(
currentMessageObject
.
messageOwner
.
out
)
{
if
(
currentMessageObject
.
messageOwner
.
out
)
{
currentTimePaint
=
timePaintOut
;
currentTimePaint
=
timePaintOut
;
}
else
{
}
else
{
currentTimePaint
=
timePaintIn
;
currentTimePaint
=
timePaintIn
;
}
}
}
else
{
currentTimePaint
=
timeMediaPaint
;
}
currentTimeString
=
LocaleController
.
formatterDay
.
format
((
long
)
(
currentMessageObject
.
messageOwner
.
date
)
*
1000
);
currentTimeString
=
LocaleController
.
formatterDay
.
format
((
long
)
(
currentMessageObject
.
messageOwner
.
date
)
*
1000
);
timeWidth
=
(
int
)
Math
.
ceil
(
currentTimePaint
.
measureText
(
currentTimeString
));
timeWidth
=
(
int
)
Math
.
ceil
(
currentTimePaint
.
measureText
(
currentTimeString
));
namesOffset
=
0
;
namesOffset
=
0
;
if
(
drawName
&&
c
hat
&&
currentUser
!=
null
&&
!
currentMessageObject
.
messageOwner
.
out
)
{
if
(
drawName
&&
isC
hat
&&
currentUser
!=
null
&&
!
currentMessageObject
.
messageOwner
.
out
)
{
currentNameString
=
Utilities
.
formatName
(
currentUser
.
first_name
,
currentUser
.
last_name
);
currentNameString
=
Utilities
.
formatName
(
currentUser
.
first_name
,
currentUser
.
last_name
);
nameWidth
=
getMaxNameWidth
();
nameWidth
=
getMaxNameWidth
();
...
@@ -284,7 +310,7 @@ public class ChatBaseCell extends BaseCell {
...
@@ -284,7 +310,7 @@ public class ChatBaseCell extends BaseCell {
float
x
=
event
.
getX
();
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
float
y
=
event
.
getY
();
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
if
(
avatarImage
!=
null
&&
x
>=
avatarImage
.
imageX
&&
x
<=
avatarImage
.
imageX
+
avatarImage
.
imageW
&&
y
>=
avatarImage
.
imageY
&&
y
<=
avatarImage
.
imageY
+
avatarImage
.
imageH
)
{
if
(
isAvatarVisible
&&
x
>=
avatarImage
.
imageX
&&
x
<=
avatarImage
.
imageX
+
avatarImage
.
imageW
&&
y
>=
avatarImage
.
imageY
&&
y
<=
avatarImage
.
imageY
+
avatarImage
.
imageH
)
{
avatarPressed
=
true
;
avatarPressed
=
true
;
result
=
true
;
result
=
true
;
}
else
if
(
drawForwardedName
&&
forwardedNameLayout
!=
null
)
{
}
else
if
(
drawForwardedName
&&
forwardedNameLayout
!=
null
)
{
...
@@ -303,7 +329,7 @@ public class ChatBaseCell extends BaseCell {
...
@@ -303,7 +329,7 @@ public class ChatBaseCell extends BaseCell {
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
avatarPressed
=
false
;
avatarPressed
=
false
;
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_MOVE
)
{
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_MOVE
)
{
if
(
avatarImage
!=
null
&&
!(
x
>=
avatarImage
.
imageX
&&
x
<=
avatarImage
.
imageX
+
avatarImage
.
imageW
&&
y
>=
avatarImage
.
imageY
&&
y
<=
avatarImage
.
imageY
+
avatarImage
.
imageH
))
{
if
(
isAvatarVisible
&&
!(
x
>=
avatarImage
.
imageX
&&
x
<=
avatarImage
.
imageX
+
avatarImage
.
imageW
&&
y
>=
avatarImage
.
imageY
&&
y
<=
avatarImage
.
imageY
+
avatarImage
.
imageH
))
{
avatarPressed
=
false
;
avatarPressed
=
false
;
}
}
}
}
...
@@ -338,13 +364,21 @@ public class ChatBaseCell extends BaseCell {
...
@@ -338,13 +364,21 @@ public class ChatBaseCell extends BaseCell {
layoutHeight
=
getMeasuredHeight
();
layoutHeight
=
getMeasuredHeight
();
timeLayout
=
new
StaticLayout
(
currentTimeString
,
currentTimePaint
,
timeWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
timeLayout
=
new
StaticLayout
(
currentTimeString
,
currentTimePaint
,
timeWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
if
(!
media
)
{
if
(!
currentMessageObject
.
messageOwner
.
out
)
{
if
(!
currentMessageObject
.
messageOwner
.
out
)
{
timeX
=
backgroundWidth
-
Utilities
.
dp
(
9
)
-
timeWidth
+
(
c
hat
?
Utilities
.
dp
(
52
)
:
0
);
timeX
=
backgroundWidth
-
Utilities
.
dp
(
9
)
-
timeWidth
+
(
isC
hat
?
Utilities
.
dp
(
52
)
:
0
);
}
else
{
}
else
{
timeX
=
layoutWidth
-
timeWidth
-
Utilities
.
dpf
(
38.5f
);
timeX
=
layoutWidth
-
timeWidth
-
Utilities
.
dpf
(
38.5f
);
}
}
}
else
{
if
(!
currentMessageObject
.
messageOwner
.
out
)
{
timeX
=
backgroundWidth
-
Utilities
.
dp
(
4
)
-
timeWidth
+
(
isChat
?
Utilities
.
dp
(
52
)
:
0
);
}
else
{
timeX
=
layoutWidth
-
timeWidth
-
Utilities
.
dpf
(
42.0f
);
}
}
if
(
avatarImage
!=
null
)
{
if
(
isAvatarVisible
)
{
avatarImage
.
imageX
=
Utilities
.
dp
(
6
);
avatarImage
.
imageX
=
Utilities
.
dp
(
6
);
avatarImage
.
imageY
=
layoutHeight
-
Utilities
.
dp
(
45
);
avatarImage
.
imageY
=
layoutHeight
-
Utilities
.
dp
(
45
);
avatarImage
.
imageW
=
Utilities
.
dp
(
42
);
avatarImage
.
imageW
=
Utilities
.
dp
(
42
);
...
@@ -355,6 +389,11 @@ public class ChatBaseCell extends BaseCell {
...
@@ -355,6 +389,11 @@ public class ChatBaseCell extends BaseCell {
}
}
}
}
protected
void
onAfterBackgroundDraw
(
Canvas
canvas
)
{
}
@Override
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
protected
void
onDraw
(
Canvas
canvas
)
{
if
(
currentMessageObject
==
null
)
{
if
(
currentMessageObject
==
null
)
{
...
@@ -366,32 +405,50 @@ public class ChatBaseCell extends BaseCell {
...
@@ -366,32 +405,50 @@ public class ChatBaseCell extends BaseCell {
return
;
return
;
}
}
if
(
avatarImage
!=
null
)
{
if
(
isAvatarVisible
)
{
avatarImage
.
draw
(
canvas
,
Utilities
.
dp
(
6
),
layoutHeight
-
Utilities
.
dp
(
45
),
Utilities
.
dp
(
42
),
Utilities
.
dp
(
42
));
avatarImage
.
draw
(
canvas
,
Utilities
.
dp
(
6
),
layoutHeight
-
Utilities
.
dp
(
45
),
Utilities
.
dp
(
42
),
Utilities
.
dp
(
42
));
}
}
Drawable
currentBackgroundDrawable
=
null
;
Drawable
currentBackgroundDrawable
=
null
;
if
(
currentMessageObject
.
messageOwner
.
out
)
{
if
(
currentMessageObject
.
messageOwner
.
out
)
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableOutSelected
;
currentBackgroundDrawable
=
backgroundDrawableOutSelected
;
}
else
{
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableOutSelected
;
}
}
else
{
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableOut
;
currentBackgroundDrawable
=
backgroundDrawableOut
;
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableOut
;
}
}
}
setDrawableBounds
(
currentBackgroundDrawable
,
layoutWidth
-
backgroundWidth
,
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
setDrawableBounds
(
currentBackgroundDrawable
,
layoutWidth
-
backgroundWidth
-
(!
media
?
0
:
Utilities
.
dp
(
9
))
,
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
}
else
{
}
else
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableInSelected
;
currentBackgroundDrawable
=
backgroundDrawableInSelected
;
}
else
{
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableInSelected
;
}
}
else
{
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableIn
;
currentBackgroundDrawable
=
backgroundDrawableIn
;
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableIn
;
}
}
}
if
(
c
hat
)
{
if
(
isC
hat
)
{
setDrawableBounds
(
currentBackgroundDrawable
,
Utilities
.
dp
(
52
),
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
setDrawableBounds
(
currentBackgroundDrawable
,
Utilities
.
dp
(
52
+
(!
media
?
0
:
9
)
),
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
}
else
{
}
else
{
setDrawableBounds
(
currentBackgroundDrawable
,
0
,
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
setDrawableBounds
(
currentBackgroundDrawable
,
(!
media
?
0
:
Utilities
.
dp
(
9
))
,
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
}
}
}
}
currentBackgroundDrawable
.
draw
(
canvas
);
currentBackgroundDrawable
.
draw
(
canvas
);
onAfterBackgroundDraw
(
canvas
);
if
(
drawName
&&
nameLayout
!=
null
)
{
if
(
drawName
&&
nameLayout
!=
null
)
{
canvas
.
save
();
canvas
.
save
();
canvas
.
translate
(
currentBackgroundDrawable
.
getBounds
().
left
+
Utilities
.
dp
(
19
)
-
nameOffsetX
,
Utilities
.
dp
(
10
));
canvas
.
translate
(
currentBackgroundDrawable
.
getBounds
().
left
+
Utilities
.
dp
(
19
)
-
nameOffsetX
,
Utilities
.
dp
(
10
));
...
@@ -416,10 +473,20 @@ public class ChatBaseCell extends BaseCell {
...
@@ -416,10 +473,20 @@ public class ChatBaseCell extends BaseCell {
canvas
.
restore
();
canvas
.
restore
();
}
}
if
(
media
)
{
setDrawableBounds
(
mediaBackgroundDrawable
,
timeX
-
Utilities
.
dp
(
3
),
layoutHeight
-
Utilities
.
dpf
(
27.5f
),
timeWidth
+
Utilities
.
dp
(
6
+
(
currentMessageObject
.
messageOwner
.
out
?
20
:
0
)),
Utilities
.
dpf
(
16.5f
));
mediaBackgroundDrawable
.
draw
(
canvas
);
canvas
.
save
();
canvas
.
translate
(
timeX
,
layoutHeight
-
Utilities
.
dpf
(
12.0f
)
-
timeLayout
.
getHeight
());
timeLayout
.
draw
(
canvas
);
canvas
.
restore
();
}
else
{
canvas
.
save
();
canvas
.
save
();
canvas
.
translate
(
timeX
,
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
timeLayout
.
getHeight
());
canvas
.
translate
(
timeX
,
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
timeLayout
.
getHeight
());
timeLayout
.
draw
(
canvas
);
timeLayout
.
draw
(
canvas
);
canvas
.
restore
();
canvas
.
restore
();
}
if
(
currentMessageObject
.
messageOwner
.
out
)
{
if
(
currentMessageObject
.
messageOwner
.
out
)
{
boolean
drawCheck1
=
false
;
boolean
drawCheck1
=
false
;
...
@@ -450,24 +517,48 @@ public class ChatBaseCell extends BaseCell {
...
@@ -450,24 +517,48 @@ public class ChatBaseCell extends BaseCell {
}
}
if
(
drawClock
)
{
if
(
drawClock
)
{
if
(!
media
)
{
setDrawableBounds
(
clockDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
clockDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
clockDrawable
.
getIntrinsicHeight
());
setDrawableBounds
(
clockDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
clockDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
clockDrawable
.
getIntrinsicHeight
());
clockDrawable
.
draw
(
canvas
);
clockDrawable
.
draw
(
canvas
);
}
else
{
setDrawableBounds
(
clockMediaDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.0f
)
-
clockMediaDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
13.0f
)
-
clockMediaDrawable
.
getIntrinsicHeight
());
clockMediaDrawable
.
draw
(
canvas
);
}
}
}
if
(
drawCheck2
)
{
if
(
drawCheck2
)
{
if
(!
media
)
{
if
(
drawCheck1
)
{
if
(
drawCheck1
)
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
}
else
{
}
else
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
}
}
checkDrawable
.
draw
(
canvas
);
checkDrawable
.
draw
(
canvas
);
}
else
{
if
(
drawCheck1
)
{
setDrawableBounds
(
checkMediaDrawable
,
layoutWidth
-
Utilities
.
dpf
(
26.0f
)
-
checkMediaDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
13.0f
)
-
checkMediaDrawable
.
getIntrinsicHeight
());
}
else
{
setDrawableBounds
(
checkMediaDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.0f
)
-
checkMediaDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
13.0f
)
-
checkMediaDrawable
.
getIntrinsicHeight
());
}
checkMediaDrawable
.
draw
(
canvas
);
}
}
}
if
(
drawCheck1
)
{
if
(
drawCheck1
)
{
if
(!
media
)
{
setDrawableBounds
(
halfCheckDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
halfCheckDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
halfCheckDrawable
.
getIntrinsicHeight
());
setDrawableBounds
(
halfCheckDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
halfCheckDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
halfCheckDrawable
.
getIntrinsicHeight
());
halfCheckDrawable
.
draw
(
canvas
);
halfCheckDrawable
.
draw
(
canvas
);
}
else
{
setDrawableBounds
(
halfCheckMediaDrawable
,
layoutWidth
-
Utilities
.
dpf
(
20.5f
)
-
halfCheckMediaDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
13.5f
)
-
halfCheckMediaDrawable
.
getIntrinsicHeight
());
halfCheckMediaDrawable
.
draw
(
canvas
);
}
}
}
if
(
drawError
)
{
if
(
drawError
)
{
if
(!
media
)
{
setDrawableBounds
(
errorDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
errorDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
errorDrawable
.
getIntrinsicHeight
());
setDrawableBounds
(
errorDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
errorDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
errorDrawable
.
getIntrinsicHeight
());
errorDrawable
.
draw
(
canvas
);
errorDrawable
.
draw
(
canvas
);
}
else
{
setDrawableBounds
(
errorDrawable
,
layoutWidth
-
Utilities
.
dpf
(
20.5f
)
-
errorDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
12.5f
)
-
errorDrawable
.
getIntrinsicHeight
());
errorDrawable
.
draw
(
canvas
);
}
}
}
}
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
0 → 100644
View file @
ebe7ab78
/*
* This is the source code of Telegram for Android v. 1.4.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package
org
.
telegram
.
ui
.
Cells
;
import
android.content.Context
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.text.Layout
;
import
android.text.StaticLayout
;
import
android.text.TextPaint
;
import
android.view.MotionEvent
;
import
android.view.SoundEffectConstants
;
import
android.view.View
;
import
org.telegram.messenger.FileLoader
;
import
org.telegram.messenger.MediaController
;
import
org.telegram.messenger.MessagesController
;
import
org.telegram.messenger.R
;
import
org.telegram.messenger.Utilities
;
import
org.telegram.objects.MessageObject
;
import
org.telegram.objects.PhotoObject
;
import
org.telegram.ui.Views.GifDrawable
;
import
org.telegram.ui.Views.ImageReceiver
;
import
org.telegram.ui.Views.ProgressView
;
import
java.io.File
;
import
java.lang.ref.WeakReference
;
import
java.util.Locale
;
public
class
ChatMediaCell
extends
ChatBaseCell
implements
MediaController
.
FileDownloadProgressListener
{
public
static
interface
ChatMediaCellDelegate
{
public
abstract
void
didPressedImage
(
ChatBaseCell
cell
);
}
private
static
Drawable
placeholderInDrawable
;
private
static
Drawable
placeholderOutDrawable
;
private
static
Drawable
[][]
buttonStatesDrawables
=
new
Drawable
[
3
][
2
];
private
static
TextPaint
infoPaint
;
private
GifDrawable
gifDrawable
=
null
;
private
int
photoWidth
;
private
int
photoHeight
;
private
PhotoObject
currentPhotoObject
;
private
String
currentPhotoFilter
;
private
ImageReceiver
photoImage
;
private
ProgressView
progressView
;
public
boolean
downloadPhotos
=
true
;
private
boolean
progressVisible
=
false
;
private
int
TAG
;
private
int
buttonState
=
0
;
private
int
buttonPressed
=
0
;
private
boolean
imagePressed
=
false
;
private
int
buttonX
;
private
int
buttonY
;
private
StaticLayout
infoLayout
;
protected
int
infoWidth
;
private
String
currentInfoString
;
public
ChatMediaCellDelegate
mediaDelegate
=
null
;
public
ChatMediaCell
(
Context
context
)
{
super
(
context
,
true
);
if
(
placeholderInDrawable
==
null
)
{
placeholderInDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
photo_placeholder_in
);
placeholderOutDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
photo_placeholder_out
);
buttonStatesDrawables
[
0
][
0
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photoload
);
buttonStatesDrawables
[
0
][
1
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photoload_pressed
);
buttonStatesDrawables
[
1
][
0
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photocancel
);
buttonStatesDrawables
[
1
][
1
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photocancel_pressed
);
buttonStatesDrawables
[
2
][
0
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photogif
);
buttonStatesDrawables
[
2
][
1
]
=
getResources
().
getDrawable
(
R
.
drawable
.
photogif_pressed
);
infoPaint
=
new
TextPaint
(
Paint
.
ANTI_ALIAS_FLAG
);
infoPaint
.
setColor
(
0xffffffff
);
infoPaint
.
setTextSize
(
Utilities
.
dp
(
12
));
}
TAG
=
MediaController
.
getInstance
().
generateObserverTag
();
photoImage
=
new
ImageReceiver
();
photoImage
.
parentView
=
new
WeakReference
<
View
>(
this
);
progressView
=
new
ProgressView
();
progressView
.
setProgressColors
(
0x802a2a2a
,
0xffffffff
);
}
public
void
clearGifImage
()
{
if
(
currentMessageObject
!=
null
&&
currentMessageObject
.
type
==
8
)
{
gifDrawable
=
null
;
buttonState
=
2
;
invalidate
();
}
}
@Override
protected
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
//if (photoImage != null) {
// photoImage.clearImage();
//}
if
(
gifDrawable
!=
null
)
{
MediaController
.
getInstance
().
clearGifDrawable
(
this
);
gifDrawable
=
null
;
}
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
boolean
result
=
false
;
int
side
=
Utilities
.
dp
(
44
);
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
if
(
buttonState
!=
-
1
&&
x
>=
buttonX
&&
x
<=
buttonX
+
side
&&
y
>=
buttonY
&&
y
<=
buttonY
+
side
)
{
buttonPressed
=
1
;
invalidate
();
result
=
true
;
}
else
if
(
x
>=
photoImage
.
imageX
&&
x
<=
photoImage
.
imageX
+
photoImage
.
imageW
&&
y
>=
photoImage
.
imageY
&&
y
<=
photoImage
.
imageY
+
photoImage
.
imageH
)
{
imagePressed
=
true
;
result
=
true
;
}
}
else
if
(
buttonPressed
==
1
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
buttonPressed
=
0
;
playSoundEffect
(
SoundEffectConstants
.
CLICK
);
didPressedButton
();
invalidate
();
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
buttonPressed
=
0
;
invalidate
();
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_MOVE
)
{
if
(!(
x
>=
buttonX
&&
x
<=
buttonX
+
side
&&
y
>=
buttonY
&&
y
<=
buttonY
+
side
))
{
buttonPressed
=
0
;
invalidate
();
}
}
}
else
if
(
imagePressed
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
imagePressed
=
false
;
playSoundEffect
(
SoundEffectConstants
.
CLICK
);
didPressedImage
();
invalidate
();
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
imagePressed
=
false
;
invalidate
();
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_MOVE
)
{
if
(!(
x
>=
photoImage
.
imageX
&&
x
<=
photoImage
.
imageX
+
photoImage
.
imageW
&&
y
>=
photoImage
.
imageY
&&
y
<=
photoImage
.
imageY
+
photoImage
.
imageH
))
{
imagePressed
=
false
;
invalidate
();
}
}
}
if
(!
result
)
{
result
=
super
.
onTouchEvent
(
event
);
}
return
result
;
}
private
void
didPressedImage
()
{
if
(
currentMessageObject
.
type
==
1
)
{
if
(
buttonState
==
-
1
)
{
if
(
currentMessageObject
.
type
==
1
)
{
if
(
mediaDelegate
!=
null
)
{
mediaDelegate
.
didPressedImage
(
this
);
}
}
}
else
if
(
buttonState
==
0
)
{
didPressedButton
();
}
}
else
if
(
currentMessageObject
.
type
==
8
)
{
if
(
buttonState
==
-
1
)
{
buttonState
=
2
;
gifDrawable
.
pause
();
invalidate
();
}
else
if
(
buttonState
==
2
||
buttonState
==
0
)
{
didPressedButton
();
}
}
}
private
void
didPressedButton
()
{
if
(
buttonState
==
0
)
{
if
(
currentMessageObject
.
type
==
1
)
{
if
(
currentMessageObject
.
imagePreview
!=
null
)
{
photoImage
.
setImage
(
currentPhotoObject
.
photoOwner
.
location
,
currentPhotoFilter
,
new
BitmapDrawable
(
currentMessageObject
.
imagePreview
),
currentPhotoObject
.
photoOwner
.
size
);
}
else
{
photoImage
.
setImage
(
currentPhotoObject
.
photoOwner
.
location
,
currentPhotoFilter
,
currentMessageObject
.
messageOwner
.
out
?
placeholderOutDrawable
:
placeholderInDrawable
,
currentPhotoObject
.
photoOwner
.
size
);
}
}
else
if
(
currentMessageObject
.
type
==
8
)
{
FileLoader
.
getInstance
().
loadFile
(
null
,
null
,
currentMessageObject
.
messageOwner
.
media
.
document
,
null
);
}
progressVisible
=
true
;
buttonState
=
1
;
invalidate
();
}
else
if
(
buttonState
==
1
)
{
if
(
currentMessageObject
.
messageOwner
.
out
&&
currentMessageObject
.
messageOwner
.
send_state
==
MessagesController
.
MESSAGE_SEND_STATE_SENDING
)
{
if
(
delegate
!=
null
)
{
delegate
.
didPressedCanceSendButton
(
this
);
}
}
else
{
if
(
currentMessageObject
.
type
==
1
)
{
FileLoader
.
getInstance
().
cancelLoadingForImageView
(
photoImage
);
}
else
if
(
currentMessageObject
.
type
==
8
)
{
FileLoader
.
getInstance
().
cancelLoadFile
(
null
,
null
,
currentMessageObject
.
messageOwner
.
media
.
document
,
null
);
}
progressVisible
=
false
;
buttonState
=
0
;
invalidate
();
}
}
else
if
(
buttonState
==
2
)
{
if
(
gifDrawable
==
null
)
{
gifDrawable
=
MediaController
.
getInstance
().
getGifDrawable
(
this
,
true
);
}
if
(
gifDrawable
!=
null
)
{
gifDrawable
.
start
();
gifDrawable
.
invalidateSelf
();
buttonState
=
-
1
;
invalidate
();
}
}
}
@Override
public
void
setMessageObject
(
MessageObject
messageObject
)
{
super
.
setMessageObject
(
messageObject
);
progressVisible
=
false
;
buttonState
=
-
1
;
gifDrawable
=
null
;
if
(
messageObject
.
type
==
8
)
{
gifDrawable
=
MediaController
.
getInstance
().
getGifDrawable
(
this
,
false
);
String
str
=
Utilities
.
formatFileSize
(
messageObject
.
messageOwner
.
media
.
document
.
size
);
if
(
currentInfoString
==
null
||
!
currentInfoString
.
equals
(
str
))
{
currentInfoString
=
str
;
infoWidth
=
(
int
)
Math
.
ceil
(
infoPaint
.
measureText
(
currentInfoString
));
infoLayout
=
new
StaticLayout
(
currentInfoString
,
infoPaint
,
infoWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
}
}
else
{
currentInfoString
=
null
;
infoLayout
=
null
;
}
photoWidth
=
(
int
)
(
Math
.
min
(
Utilities
.
displaySize
.
x
,
Utilities
.
displaySize
.
y
)
*
0.7f
);
photoHeight
=
photoWidth
+
Utilities
.
dp
(
100
);
if
(
messageObject
.
type
==
6
||
messageObject
.
type
==
7
)
{
photoWidth
=
(
int
)
(
Math
.
min
(
Utilities
.
displaySize
.
x
,
Utilities
.
displaySize
.
y
)
/
2.5f
);
photoHeight
=
photoWidth
+
100
;
}
if
(
photoWidth
>
800
)
{
photoWidth
=
800
;
}
if
(
photoHeight
>
800
)
{
photoHeight
=
800
;
}
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
photoWidth
,
photoHeight
);
if
(
currentPhotoObject
!=
null
)
{
float
scale
=
(
float
)
currentPhotoObject
.
photoOwner
.
w
/
(
float
)
photoWidth
;
int
w
=
(
int
)
(
currentPhotoObject
.
photoOwner
.
w
/
scale
);
int
h
=
(
int
)
(
currentPhotoObject
.
photoOwner
.
h
/
scale
);
if
(
h
>
photoHeight
)
{
float
scale2
=
h
;
h
=
photoHeight
;
scale2
/=
h
;
w
=
(
int
)
(
w
/
scale2
);
}
else
if
(
h
<
Utilities
.
dp
(
120
))
{
h
=
Utilities
.
dp
(
120
);
float
hScale
=
(
float
)
currentPhotoObject
.
photoOwner
.
h
/
h
;
if
(
currentPhotoObject
.
photoOwner
.
w
/
hScale
<
photoWidth
)
{
w
=
(
int
)
(
currentPhotoObject
.
photoOwner
.
w
/
hScale
);
}
}
photoWidth
=
w
;
photoHeight
=
h
;
backgroundWidth
=
w
+
Utilities
.
dp
(
12
);
currentPhotoFilter
=
String
.
format
(
Locale
.
US
,
"%d_%d"
,
(
int
)
(
w
/
Utilities
.
density
),
(
int
)
(
h
/
Utilities
.
density
));
if
(
currentPhotoObject
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
currentPhotoObject
.
image
);
}
else
{
boolean
photoExist
=
true
;
String
fileName
=
MessageObject
.
getAttachFileName
(
currentPhotoObject
.
photoOwner
);
if
(
messageObject
.
type
==
1
)
{
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
if
(!
cacheFile
.
exists
())
{
photoExist
=
false
;
}
else
{
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
}
}
if
(
photoExist
||
downloadPhotos
)
{
if
(
messageObject
.
imagePreview
!=
null
)
{
photoImage
.
setImage
(
currentPhotoObject
.
photoOwner
.
location
,
currentPhotoFilter
,
new
BitmapDrawable
(
messageObject
.
imagePreview
),
currentPhotoObject
.
photoOwner
.
size
);
}
else
{
photoImage
.
setImage
(
currentPhotoObject
.
photoOwner
.
location
,
currentPhotoFilter
,
messageObject
.
messageOwner
.
out
?
placeholderOutDrawable
:
placeholderInDrawable
,
currentPhotoObject
.
photoOwner
.
size
);
}
}
else
{
if
(
messageObject
.
imagePreview
!=
null
)
{
photoImage
.
setImageBitmap
(
messageObject
.
imagePreview
);
}
else
{
photoImage
.
setImageBitmap
(
messageObject
.
messageOwner
.
out
?
placeholderOutDrawable
:
placeholderInDrawable
);
}
}
}
}
else
{
photoImage
.
setImageBitmap
(
messageObject
.
messageOwner
.
out
?
placeholderOutDrawable
:
placeholderInDrawable
);
}
/*if ((type == 6 || type == 7) && videoTimeText != null) {
int duration = message.messageOwner.media.video.duration;
int minutes = duration / 60;
int seconds = duration - minutes * 60;
videoTimeText.setText(String.format("%d:%02d", minutes, seconds));
}*/
updateButtonState
();
invalidate
();
}
public
void
updateButtonState
()
{
String
fileName
=
null
;
File
cacheFile
=
null
;
if
(
currentMessageObject
.
type
==
1
)
{
fileName
=
MessageObject
.
getAttachFileName
(
currentPhotoObject
.
photoOwner
);
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
}
else
if
(
currentMessageObject
.
type
==
8
)
{
if
(
currentMessageObject
.
messageOwner
.
attachPath
!=
null
&&
currentMessageObject
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
File
f
=
new
File
(
currentMessageObject
.
messageOwner
.
attachPath
);
if
(
f
.
exists
())
{
fileName
=
currentMessageObject
.
messageOwner
.
attachPath
;
cacheFile
=
f
;
}
}
else
{
fileName
=
currentMessageObject
.
getFileName
();
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
}
}
if
(
fileName
==
null
)
{
return
;
}
if
(
currentMessageObject
.
messageOwner
.
out
&&
currentMessageObject
.
messageOwner
.
send_state
==
MessagesController
.
MESSAGE_SEND_STATE_SENDING
)
{
if
(
currentMessageObject
.
messageOwner
.
attachPath
!=
null
)
{
MediaController
.
getInstance
().
addLoadingFileObserver
(
currentMessageObject
.
messageOwner
.
attachPath
,
this
);
progressVisible
=
true
;
buttonState
=
1
;
Float
progress
=
FileLoader
.
getInstance
().
fileProgresses
.
get
(
currentMessageObject
.
messageOwner
.
attachPath
);
if
(
progress
!=
null
)
{
progressView
.
setProgress
(
progress
);
}
else
{
progressView
.
setProgress
(
0
);
}
}
}
else
{
if
(
currentMessageObject
.
messageOwner
.
attachPath
!=
null
)
{
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
}
if
(
cacheFile
.
exists
()
&&
cacheFile
.
length
()
==
0
)
{
cacheFile
.
delete
();
}
if
(!
cacheFile
.
exists
())
{
MediaController
.
getInstance
().
addLoadingFileObserver
(
fileName
,
this
);
if
(!
FileLoader
.
getInstance
().
isLoadingFile
(
fileName
))
{
if
(
currentMessageObject
.
type
!=
1
||
!
downloadPhotos
)
{
buttonState
=
0
;
progressVisible
=
false
;
}
else
{
buttonState
=
-
1
;
progressVisible
=
true
;
}
progressView
.
setProgress
(
0
);
}
else
{
if
(
currentMessageObject
.
type
!=
1
||
!
downloadPhotos
)
{
buttonState
=
1
;
}
else
{
buttonState
=
-
1
;
}
progressVisible
=
true
;
Float
progress
=
FileLoader
.
getInstance
().
fileProgresses
.
get
(
fileName
);
if
(
progress
!=
null
)
{
progressView
.
setProgress
(
progress
);
}
else
{
progressView
.
setProgress
(
0
);
}
}
}
else
{
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
progressVisible
=
false
;
if
(
currentMessageObject
.
type
==
8
&&
gifDrawable
==
null
)
{
buttonState
=
2
;
}
else
{
buttonState
=
-
1
;
}
invalidate
();
}
}
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
photoHeight
+
Utilities
.
dp
(
14
));
}
@Override
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
if
(
currentMessageObject
.
messageOwner
.
out
)
{
photoImage
.
imageX
=
layoutWidth
-
backgroundWidth
-
Utilities
.
dp
(
3
);
}
else
{
if
(
isChat
)
{
photoImage
.
imageX
=
Utilities
.
dp
(
67
);
}
else
{
photoImage
.
imageX
=
Utilities
.
dp
(
15
);
}
}
photoImage
.
imageY
=
Utilities
.
dp
(
7
);
photoImage
.
imageW
=
photoWidth
;
photoImage
.
imageH
=
photoHeight
;
progressView
.
width
=
timeX
-
photoImage
.
imageX
-
Utilities
.
dpf
(
23.0f
);
progressView
.
height
=
Utilities
.
dp
(
3
);
progressView
.
progressHeight
=
Utilities
.
dp
(
3
);
int
size
=
Utilities
.
dp
(
44
);
buttonX
=
(
int
)(
photoImage
.
imageX
+
(
photoWidth
-
size
)
/
2.0f
);
buttonY
=
(
int
)(
photoImage
.
imageY
+
(
photoHeight
-
size
)
/
2.0f
);
}
@Override
protected
void
onAfterBackgroundDraw
(
Canvas
canvas
)
{
if
(
gifDrawable
!=
null
)
{
canvas
.
save
();
gifDrawable
.
setBounds
(
photoImage
.
imageX
,
photoImage
.
imageY
,
photoImage
.
imageX
+
photoWidth
,
photoImage
.
imageY
+
photoHeight
);
gifDrawable
.
draw
(
canvas
);
canvas
.
restore
();
}
else
{
photoImage
.
draw
(
canvas
,
photoImage
.
imageX
,
photoImage
.
imageY
,
photoWidth
,
photoHeight
);
}
if
(
progressVisible
)
{
setDrawableBounds
(
mediaBackgroundDrawable
,
photoImage
.
imageX
+
Utilities
.
dp
(
4
),
layoutHeight
-
Utilities
.
dpf
(
27.5f
),
progressView
.
width
+
Utilities
.
dp
(
12
),
Utilities
.
dpf
(
16.5f
));
mediaBackgroundDrawable
.
draw
(
canvas
);
canvas
.
save
();
canvas
.
translate
(
photoImage
.
imageX
+
Utilities
.
dp
(
10
),
layoutHeight
-
Utilities
.
dpf
(
21.0f
));
progressView
.
draw
(
canvas
);
canvas
.
restore
();
}
if
(
buttonState
>=
0
&&
buttonState
<
3
)
{
Drawable
currentButtonDrawable
=
buttonStatesDrawables
[
buttonState
][
buttonPressed
];
setDrawableBounds
(
currentButtonDrawable
,
buttonX
,
buttonY
);
currentButtonDrawable
.
draw
(
canvas
);
}
if
(
infoLayout
!=
null
&&
(
buttonState
==
1
||
buttonState
==
0
))
{
setDrawableBounds
(
mediaBackgroundDrawable
,
photoImage
.
imageX
+
Utilities
.
dp
(
4
),
photoImage
.
imageY
+
Utilities
.
dp
(
4
),
infoWidth
+
Utilities
.
dp
(
8
),
Utilities
.
dpf
(
16.5f
));
mediaBackgroundDrawable
.
draw
(
canvas
);
canvas
.
save
();
canvas
.
translate
(
photoImage
.
imageX
+
Utilities
.
dp
(
8
),
photoImage
.
imageY
+
Utilities
.
dpf
(
5.5f
));
infoLayout
.
draw
(
canvas
);
canvas
.
restore
();
}
}
@Override
public
void
onFailedDownload
(
String
fileName
)
{
updateButtonState
();
}
@Override
public
void
onSuccessDownload
(
String
fileName
)
{
updateButtonState
();
}
@Override
public
void
onProgressDownload
(
String
fileName
,
float
progress
)
{
progressVisible
=
true
;
progressView
.
setProgress
(
progress
);
invalidate
();
}
@Override
public
void
onProgressUpload
(
String
fileName
,
float
progress
,
boolean
isEncrypted
)
{
progressView
.
setProgress
(
progress
);
invalidate
();
}
@Override
public
int
getObserverTag
()
{
return
TAG
;
}
}
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
View file @
ebe7ab78
...
@@ -28,8 +28,8 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -28,8 +28,8 @@ public class ChatMessageCell extends ChatBaseCell {
private
int
firstVisibleBlockNum
=
0
;
private
int
firstVisibleBlockNum
=
0
;
private
int
totalVisibleBlocksCount
=
0
;
private
int
totalVisibleBlocksCount
=
0
;
public
ChatMessageCell
(
Context
context
,
boolean
isChat
)
{
public
ChatMessageCell
(
Context
context
)
{
super
(
context
,
isChat
);
super
(
context
,
false
);
drawForwardedName
=
true
;
drawForwardedName
=
true
;
}
}
...
@@ -131,7 +131,7 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -131,7 +131,7 @@ public class ChatMessageCell extends ChatBaseCell {
}
}
pressedLink
=
null
;
pressedLink
=
null
;
int
maxWidth
;
int
maxWidth
;
if
(
c
hat
)
{
if
(
isC
hat
)
{
maxWidth
=
Utilities
.
displaySize
.
x
-
Utilities
.
dp
(
122
);
maxWidth
=
Utilities
.
displaySize
.
x
-
Utilities
.
dp
(
122
);
drawName
=
true
;
drawName
=
true
;
}
else
{
}
else
{
...
@@ -180,7 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -180,7 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
else
{
}
else
{
textX
=
Utilities
.
dp
(
19
)
+
(
c
hat
?
Utilities
.
dp
(
52
)
:
0
);
textX
=
Utilities
.
dp
(
19
)
+
(
isC
hat
?
Utilities
.
dp
(
52
)
:
0
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
}
}
}
...
@@ -196,7 +196,7 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -196,7 +196,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
else
{
}
else
{
textX
=
Utilities
.
dp
(
19
)
+
(
c
hat
?
Utilities
.
dp
(
52
)
:
0
);
textX
=
Utilities
.
dp
(
19
)
+
(
isC
hat
?
Utilities
.
dp
(
52
)
:
0
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
ebe7ab78
...
@@ -88,10 +88,12 @@ import org.telegram.messenger.UserConfig;
...
@@ -88,10 +88,12 @@ import org.telegram.messenger.UserConfig;
import
org.telegram.messenger.Utilities
;
import
org.telegram.messenger.Utilities
;
import
org.telegram.ui.Cells.ChatAudioCell
;
import
org.telegram.ui.Cells.ChatAudioCell
;
import
org.telegram.ui.Cells.ChatBaseCell
;
import
org.telegram.ui.Cells.ChatBaseCell
;
import
org.telegram.ui.Cells.ChatMediaCell
;
import
org.telegram.ui.Cells.ChatMessageCell
;
import
org.telegram.ui.Cells.ChatMessageCell
;
import
org.telegram.ui.Views.BackupImageView
;
import
org.telegram.ui.Views.BackupImageView
;
import
org.telegram.ui.Views.BaseFragment
;
import
org.telegram.ui.Views.BaseFragment
;
import
org.telegram.ui.Views.EmojiView
;
import
org.telegram.ui.Views.EmojiView
;
import
org.telegram.ui.Views.GifDrawable
;
import
org.telegram.ui.Views.LayoutListView
;
import
org.telegram.ui.Views.LayoutListView
;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.OnSwipeTouchListener
;
import
org.telegram.ui.Views.OnSwipeTouchListener
;
...
@@ -1225,9 +1227,29 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1225,9 +1227,29 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
1
;
return
1
;
}
else
{
}
else
{
if
(!(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))
{
if
(!(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))
{
if
(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
if
(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
boolean
canSave
=
false
;
if
(
messageObject
.
messageOwner
.
attachPath
!=
null
&&
messageObject
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
File
f
=
new
File
(
messageObject
.
messageOwner
.
attachPath
);
if
(
f
.
exists
())
{
canSave
=
true
;
}
}
if
(!
canSave
)
{
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
if
(
f
.
exists
())
{
if
(
f
.
exists
())
{
canSave
=
true
;
}
}
if
(
canSave
)
{
if
(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
String
mime
=
messageObject
.
messageOwner
.
media
.
document
.
mime_type
;
if
(
mime
!=
null
&&
mime
.
equals
(
"text/xml"
))
{
return
5
;
}
}
return
4
;
return
4
;
}
}
}
}
...
@@ -1249,12 +1271,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1249,12 +1271,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
1
;
return
1
;
}
else
{
}
else
{
if
(!(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))
{
if
(!(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))
{
/*if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
if
(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
||
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
boolean
canSave
=
false
;
if
(
messageObject
.
messageOwner
.
attachPath
!=
null
&&
messageObject
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
File
f
=
new
File
(
messageObject
.
messageOwner
.
attachPath
);
if
(
f
.
exists
())
{
canSave
=
true
;
}
}
if
(!
canSave
)
{
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
if
(
f
.
exists
())
{
if
(
f
.
exists
())
{
return 4;
canSave
=
true
;
}
}
if
(
canSave
)
{
if
(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
String
mime
=
messageObject
.
messageOwner
.
media
.
document
.
mime_type
;
if
(
mime
!=
null
&&
mime
.
equals
(
"text/xml"
))
{
return
5
;
}
}
//return 4;
}
}
}
}*/
return
2
;
return
2
;
}
else
{
}
else
{
return
3
;
return
3
;
...
@@ -1266,12 +1308,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1266,12 +1308,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
void
addToSelectedMessages
(
MessageObject
messageObject
)
{
private
void
addToSelectedMessages
(
MessageObject
messageObject
)
{
if
(
selectedMessagesIds
.
containsKey
(
messageObject
.
messageOwner
.
id
))
{
if
(
selectedMessagesIds
.
containsKey
(
messageObject
.
messageOwner
.
id
))
{
selectedMessagesIds
.
remove
(
messageObject
.
messageOwner
.
id
);
selectedMessagesIds
.
remove
(
messageObject
.
messageOwner
.
id
);
if
(
messageObject
.
type
==
0
||
messageObject
.
type
==
1
||
messageObject
.
type
==
8
||
messageObject
.
type
==
9
)
{
if
(
messageObject
.
type
==
0
)
{
selectedMessagesCanCopyIds
.
remove
(
messageObject
.
messageOwner
.
id
);
selectedMessagesCanCopyIds
.
remove
(
messageObject
.
messageOwner
.
id
);
}
}
}
else
{
}
else
{
selectedMessagesIds
.
put
(
messageObject
.
messageOwner
.
id
,
messageObject
);
selectedMessagesIds
.
put
(
messageObject
.
messageOwner
.
id
,
messageObject
);
if
(
messageObject
.
type
==
0
||
messageObject
.
type
==
1
||
messageObject
.
type
==
8
||
messageObject
.
type
==
9
)
{
if
(
messageObject
.
type
==
0
)
{
selectedMessagesCanCopyIds
.
put
(
messageObject
.
messageOwner
.
id
,
messageObject
);
selectedMessagesCanCopyIds
.
put
(
messageObject
.
messageOwner
.
id
,
messageObject
);
}
}
}
}
...
@@ -1576,8 +1618,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1576,8 +1618,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ext
=
documentFilePath
.
substring
(
idx
);
ext
=
documentFilePath
.
substring
(
idx
);
}
}
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
document
.
id
=
0
;
document
.
id
=
0
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
...
@@ -1596,6 +1636,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1596,6 +1636,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
document
.
mime_type
=
"application/octet-stream"
;
document
.
mime_type
=
"application/octet-stream"
;
}
}
if
(
document
.
mime_type
.
equals
(
"image/gif"
))
{
GifDrawable
gifDrawable
=
null
;
try
{
gifDrawable
=
new
GifDrawable
(
f
);
Bitmap
bitmap
=
gifDrawable
.
getBitmap
();
if
(
bitmap
!=
null
)
{
document
.
thumb
=
FileLoader
.
scaleAndSaveImage
(
bitmap
,
90
,
90
,
55
,
currentEncryptedChat
!=
null
);
document
.
thumb
.
type
=
"s"
;
}
gifDrawable
.
recycle
();
}
catch
(
Exception
e
)
{
if
(
gifDrawable
!=
null
)
{
gifDrawable
.
recycle
();
}
FileLog
.
e
(
"tmessages"
,
e
);
}
}
if
(
document
.
thumb
==
null
)
{
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
}
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
}
}
...
@@ -1707,7 +1768,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1707,7 +1768,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
id
=
0
;
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
dateObj
.
type
=
10
;
if
(
forwardLoad
)
{
if
(
forwardLoad
)
{
messages
.
add
(
0
,
dateObj
);
messages
.
add
(
0
,
dateObj
);
}
else
{
}
else
{
...
@@ -1730,7 +1791,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1730,7 +1791,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
""
;
dateMsg
.
message
=
""
;
dateMsg
.
id
=
0
;
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
15
;
dateObj
.
contentType
=
dateObj
.
type
=
15
;
boolean
dateAdded
=
true
;
boolean
dateAdded
=
true
;
if
(
a
!=
messArr
.
size
()
-
1
)
{
if
(
a
!=
messArr
.
size
()
-
1
)
{
MessageObject
next
=
messArr
.
get
(
a
+
1
);
MessageObject
next
=
messArr
.
get
(
a
+
1
);
...
@@ -1985,7 +2046,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1985,7 +2046,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
id
=
0
;
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
dateObj
.
type
=
10
;
messages
.
add
(
0
,
dateObj
);
messages
.
add
(
0
,
dateObj
);
}
}
if
(!
obj
.
messageOwner
.
out
&&
obj
.
messageOwner
.
unread
)
{
if
(!
obj
.
messageOwner
.
out
&&
obj
.
messageOwner
.
unread
)
{
...
@@ -2864,6 +2925,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2864,6 +2925,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
type
==
4
)
{
}
else
if
(
type
==
4
)
{
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
"SaveToDownloads"
:
"SaveToGallery"
,
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
"SaveToDownloads"
:
"SaveToGallery"
,
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
R
.
string
.
SaveToDownloads
:
R
.
string
.
SaveToGallery
),
LocaleController
.
getString
(
"Forward"
,
R
.
string
.
Forward
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
R
.
string
.
SaveToDownloads
:
R
.
string
.
SaveToGallery
),
LocaleController
.
getString
(
"Forward"
,
R
.
string
.
Forward
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
}
else
if
(
type
==
5
)
{
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
"ApplyLocalizationFile"
,
R
.
string
.
ApplyLocalizationFile
),
LocaleController
.
getString
(
"SaveToDownloads"
,
R
.
string
.
SaveToDownloads
),
LocaleController
.
getString
(
"Forward"
,
R
.
string
.
Forward
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
}
}
}
else
{
}
else
{
if
(
type
==
0
)
{
if
(
type
==
0
)
{
...
@@ -2877,6 +2940,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2877,6 +2940,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
type
==
4
)
{
}
else
if
(
type
==
4
)
{
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
"SaveToDownloads"
:
"SaveToGallery"
,
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
"SaveToDownloads"
:
"SaveToGallery"
,
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
R
.
string
.
SaveToDownloads
:
R
.
string
.
SaveToGallery
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
selectedObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
?
R
.
string
.
SaveToDownloads
:
R
.
string
.
SaveToGallery
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
}
else
if
(
type
==
5
)
{
items
=
new
CharSequence
[]
{
LocaleController
.
getString
(
"ApplyLocalizationFile"
,
R
.
string
.
ApplyLocalizationFile
),
LocaleController
.
getString
(
"Delete"
,
R
.
string
.
Delete
)};
}
}
}
}
...
@@ -2923,9 +2988,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2923,9 +2988,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
String
fileName
=
selectedObject
.
getFileName
();
String
fileName
=
selectedObject
.
getFileName
();
if
(
selectedObject
.
type
==
6
||
selectedObject
.
type
==
7
)
{
if
(
selectedObject
.
type
==
6
||
selectedObject
.
type
==
7
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
1
,
null
);
MediaController
.
saveFile
(
fileName
,
parentActivity
,
1
,
null
);
}
else
if
(
selectedObject
.
type
==
2
||
selectedObject
.
type
==
3
)
{
}
else
if
(
selectedObject
.
type
==
1
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
0
,
null
);
MediaController
.
saveFile
(
fileName
,
parentActivity
,
0
,
null
);
}
else
if
(
selectedObject
.
type
==
16
||
selectedObject
.
type
==
17
)
{
}
else
if
(
selectedObject
.
type
==
8
||
selectedObject
.
type
==
9
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
2
,
selectedObject
.
messageOwner
.
media
.
document
.
file_name
);
MediaController
.
saveFile
(
fileName
,
parentActivity
,
2
,
selectedObject
.
messageOwner
.
media
.
document
.
file_name
);
}
}
}
else
if
(
i
==
1
)
{
}
else
if
(
i
==
1
)
{
...
@@ -2940,6 +3005,47 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2940,6 +3005,47 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
processSelectedOption
(
1
);
processSelectedOption
(
1
);
}
}
}
}
}
else
if
(
type
==
5
)
{
if
(
currentEncryptedChat
==
null
)
{
if
(
i
==
1
)
{
String
fileName
=
selectedObject
.
getFileName
();
if
(
selectedObject
.
type
==
6
||
selectedObject
.
type
==
7
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
1
,
null
);
}
else
if
(
selectedObject
.
type
==
1
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
0
,
null
);
}
else
if
(
selectedObject
.
type
==
8
||
selectedObject
.
type
==
9
)
{
MediaController
.
saveFile
(
fileName
,
parentActivity
,
2
,
selectedObject
.
messageOwner
.
media
.
document
.
file_name
);
}
}
else
if
(
i
==
2
)
{
processSelectedOption
(
2
);
}
else
if
(
i
==
3
)
{
processSelectedOption
(
1
);
}
}
else
{
if
(
i
==
1
)
{
processSelectedOption
(
1
);
}
}
if
(
i
==
0
)
{
File
locFile
=
null
;
if
(
selectedObject
.
messageOwner
.
attachPath
!=
null
&&
selectedObject
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
File
f
=
new
File
(
selectedObject
.
messageOwner
.
attachPath
);
if
(
f
.
exists
())
{
locFile
=
f
;
}
}
if
(
locFile
==
null
)
{
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
selectedObject
.
getFileName
());
if
(
f
.
exists
())
{
locFile
=
f
;
}
}
if
(
locFile
!=
null
)
{
if
(
LocaleController
.
getInstance
().
applyLanguageFile
(
locFile
))
{
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
LanguageSelectActivity
(),
"settings_lang"
,
false
);
}
}
}
}
}
}
}
});
});
...
@@ -2966,17 +3072,15 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2966,17 +3072,15 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
void
processSelectedOption
(
int
option
)
{
private
void
processSelectedOption
(
int
option
)
{
if
(
option
==
0
)
{
if
(
option
==
0
)
{
if
(
selectedObject
!=
null
&&
selectedObject
.
messageOwner
.
id
<
0
)
{
if
(
selectedObject
!=
null
&&
selectedObject
.
messageOwner
.
id
<
0
)
{
if
(
selectedObject
.
type
==
0
||
selectedObject
.
type
==
1
)
{
if
(
selectedObject
.
type
==
0
)
{
if
(
selectedObject
.
messageOwner
instanceof
TLRPC
.
TL_messageForwarded
)
{
if
(
selectedObject
.
messageOwner
instanceof
TLRPC
.
TL_messageForwarded
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
}
else
{
}
else
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
.
messageOwner
.
message
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
.
messageOwner
.
message
,
dialog_id
);
}
}
}
else
if
(
selectedObject
.
type
==
8
||
selectedObject
.
type
==
9
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
}
else
if
(
selectedObject
.
type
==
4
||
selectedObject
.
type
==
5
)
{
}
else
if
(
selectedObject
.
type
==
4
||
selectedObject
.
type
==
5
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
.
messageOwner
.
media
.
geo
.
lat
,
selectedObject
.
messageOwner
.
media
.
geo
.
_long
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
.
messageOwner
.
media
.
geo
.
lat
,
selectedObject
.
messageOwner
.
media
.
geo
.
_long
,
dialog_id
);
}
else
if
(
selectedObject
.
type
==
2
||
selectedObject
.
type
==
3
)
{
}
else
if
(
selectedObject
.
type
==
1
)
{
if
(
selectedObject
.
messageOwner
instanceof
TLRPC
.
TL_messageForwarded
)
{
if
(
selectedObject
.
messageOwner
instanceof
TLRPC
.
TL_messageForwarded
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
}
else
{
}
else
{
...
@@ -2994,11 +3098,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2994,11 +3098,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
selectedObject
.
type
==
12
||
selectedObject
.
type
==
13
)
{
}
else
if
(
selectedObject
.
type
==
12
||
selectedObject
.
type
==
13
)
{
TLRPC
.
User
user
=
MessagesController
.
getInstance
().
users
.
get
(
selectedObject
.
messageOwner
.
media
.
user_id
);
TLRPC
.
User
user
=
MessagesController
.
getInstance
().
users
.
get
(
selectedObject
.
messageOwner
.
media
.
user_id
);
MessagesController
.
getInstance
().
sendMessage
(
user
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
user
,
dialog_id
);
}
else
if
(
selectedObject
.
type
==
16
||
selectedObject
.
type
==
17
)
{
}
else
if
(
selectedObject
.
type
==
8
||
selectedObject
.
type
==
9
)
{
TLRPC
.
TL_document
document
=
(
TLRPC
.
TL_document
)
selectedObject
.
messageOwner
.
media
.
document
;
TLRPC
.
TL_document
document
=
(
TLRPC
.
TL_document
)
selectedObject
.
messageOwner
.
media
.
document
;
document
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
document
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
}
else
if
(
selectedObject
.
type
==
18
||
selectedObject
.
type
==
19
)
{
}
else
if
(
selectedObject
.
type
==
2
)
{
TLRPC
.
TL_audio
audio
=
(
TLRPC
.
TL_audio
)
selectedObject
.
messageOwner
.
media
.
audio
;
TLRPC
.
TL_audio
audio
=
(
TLRPC
.
TL_audio
)
selectedObject
.
messageOwner
.
media
.
audio
;
audio
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
audio
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
MessagesController
.
getInstance
().
sendMessage
(
audio
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
audio
,
dialog_id
);
...
@@ -3064,8 +3168,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3064,8 +3168,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
,
String
name
,
String
ext
,
long
size
)
{
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
,
String
name
,
String
ext
,
long
size
)
{
activity
.
finishFragment
();
activity
.
finishFragment
();
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
document
.
id
=
0
;
document
.
id
=
0
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
...
@@ -3084,6 +3186,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3084,6 +3186,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
document
.
mime_type
=
"application/octet-stream"
;
document
.
mime_type
=
"application/octet-stream"
;
}
}
if
(
document
.
mime_type
.
equals
(
"image/gif"
))
{
GifDrawable
gifDrawable
=
null
;
try
{
gifDrawable
=
new
GifDrawable
(
path
);
Bitmap
bitmap
=
gifDrawable
.
getBitmap
();
if
(
bitmap
!=
null
)
{
document
.
thumb
=
FileLoader
.
scaleAndSaveImage
(
bitmap
,
90
,
90
,
55
,
currentEncryptedChat
!=
null
);
document
.
thumb
.
type
=
"s"
;
}
gifDrawable
.
recycle
();
}
catch
(
Exception
e
)
{
if
(
gifDrawable
!=
null
)
{
gifDrawable
.
recycle
();
}
FileLog
.
e
(
"tmessages"
,
e
);
}
}
if
(
document
.
thumb
==
null
)
{
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
}
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
MessagesController
.
getInstance
().
sendMessage
(
document
,
dialog_id
);
}
}
...
@@ -3322,9 +3445,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3322,9 +3445,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
void
updateRowBackground
(
ChatListRowHolderEx
holder
,
boolean
disableSelection
,
boolean
selected
)
{
private
void
updateRowBackground
(
ChatListRowHolderEx
holder
,
boolean
disableSelection
,
boolean
selected
)
{
int
messageType
=
holder
.
message
.
type
;
int
messageType
=
holder
.
message
.
type
;
if
(!
disableSelection
)
{
if
(!
disableSelection
)
{
if
(
messageType
==
2
||
messageType
==
4
||
messageType
==
6
)
{
if
(
messageType
==
4
||
messageType
==
6
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_photo_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_photo_states
);
}
else
if
(
messageType
==
3
||
messageType
==
5
||
messageType
==
7
)
{
}
else
if
(
messageType
==
5
||
messageType
==
7
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_photo_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_photo_states
);
}
else
if
(
messageType
==
12
)
{
}
else
if
(
messageType
==
12
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
...
@@ -3332,21 +3455,21 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3332,21 +3455,21 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
messageType
==
13
)
{
}
else
if
(
messageType
==
13
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
15
),
Utilities
.
dp
(
6
),
Utilities
.
dp
(
9
),
0
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
15
),
Utilities
.
dp
(
6
),
Utilities
.
dp
(
9
),
0
);
}
else
if
(
messageType
==
16
)
{
}
else
if
(
messageType
==
8
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
18
),
0
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
18
),
0
);
}
else
if
(
messageType
==
17
)
{
}
else
if
(
messageType
==
9
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
18
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
0
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
18
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
0
);
}
}
}
else
{
}
else
{
if
(
messageType
==
2
||
messageType
==
4
||
messageType
==
6
)
{
if
(
messageType
==
4
||
messageType
==
6
)
{
if
(
selected
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo_selected
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo_selected
);
}
else
{
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo
);
}
}
}
else
if
(
messageType
==
3
||
messageType
==
5
||
messageType
==
7
)
{
}
else
if
(
messageType
==
5
||
messageType
==
7
)
{
if
(
selected
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_photo_selected
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_photo_selected
);
}
else
{
}
else
{
...
@@ -3366,14 +3489,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3366,14 +3489,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in
);
}
}
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
15
),
Utilities
.
dp
(
6
),
Utilities
.
dp
(
9
),
0
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
15
),
Utilities
.
dp
(
6
),
Utilities
.
dp
(
9
),
0
);
}
else
if
(
messageType
==
16
)
{
}
else
if
(
messageType
==
8
)
{
if
(
selected
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_selected
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_selected
);
}
else
{
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out
);
}
}
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
18
),
0
);
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
18
),
0
);
}
else
if
(
messageType
==
17
)
{
}
else
if
(
messageType
==
9
)
{
if
(
selected
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_selected
);
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_selected
);
}
else
{
}
else
{
...
@@ -3453,17 +3576,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3453,17 +3576,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
}
}
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
int
type
=
message
.
t
ype
;
int
type
=
message
.
contentT
ype
;
if
(
view
==
null
)
{
if
(
view
==
null
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
if
(
type
==
0
)
{
if
(
type
==
0
)
{
view
=
new
ChatMessageCell
(
mContext
,
false
);
view
=
new
ChatMessageCell
(
mContext
);
}
else
if
(
type
==
1
)
{
view
=
new
ChatMessageCell
(
mContext
,
currentChat
!=
null
);
}
else
if
(
type
==
8
)
{
view
=
new
ChatMessageCell
(
mContext
,
false
);
}
else
if
(
type
==
9
)
{
view
=
new
ChatMessageCell
(
mContext
,
currentChat
!=
null
);
}
else
if
(
type
==
4
)
{
}
else
if
(
type
==
4
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_location_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_location_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
5
)
{
}
else
if
(
type
==
5
)
{
...
@@ -3472,14 +3589,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3472,14 +3589,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_location_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_location_layout
,
viewGroup
,
false
);
}
}
}
else
if
(
type
==
2
)
{
}
else
if
(
type
==
1
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_photo_layout
,
viewGroup
,
false
);
view
=
new
ChatMediaCell
(
mContext
);
}
else
if
(
type
==
3
)
{
((
ChatMediaCell
)
view
).
downloadPhotos
=
downloadPhotos
;
if
(
currentChat
!=
null
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_group_incoming_photo_layout
,
viewGroup
,
false
);
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_photo_layout
,
viewGroup
,
false
);
}
}
else
if
(
type
==
6
)
{
}
else
if
(
type
==
6
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_video_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_video_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
7
)
{
}
else
if
(
type
==
7
)
{
...
@@ -3502,19 +3614,31 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3502,19 +3614,31 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
}
else
if
(
type
==
15
)
{
}
else
if
(
type
==
15
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_unread_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_unread_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
16
)
{
}
else
if
(
type
==
8
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_document_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_document_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
17
)
{
}
else
if
(
type
==
9
)
{
if
(
currentChat
!=
null
)
{
if
(
currentChat
!=
null
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_group_incoming_document_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_group_incoming_document_layout
,
viewGroup
,
false
);
}
else
{
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_document_layout
,
viewGroup
,
false
);
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_document_layout
,
viewGroup
,
false
);
}
}
}
else
if
(
type
==
18
)
{
}
else
if
(
type
==
2
)
{
view
=
new
ChatAudioCell
(
mContext
,
false
);
view
=
new
ChatAudioCell
(
mContext
);
}
else
if
(
type
==
19
)
{
}
view
=
new
ChatAudioCell
(
mContext
,
currentChat
!=
null
);
}
boolean
selected
=
false
;
boolean
disableSelection
=
false
;
if
(
mActionMode
!=
null
)
{
if
(
selectedMessagesIds
.
containsKey
(
message
.
messageOwner
.
id
))
{
view
.
setBackgroundColor
(
0x6633b5e5
);
selected
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
}
disableSelection
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
}
if
(
view
instanceof
ChatBaseCell
)
{
if
(
view
instanceof
ChatBaseCell
)
{
...
@@ -3529,33 +3653,38 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3529,33 +3653,38 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"user_"
+
user
.
id
,
false
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"user_"
+
user
.
id
,
false
);
}
}
}
}
};
}
boolean
selected
=
false
;
@Override
boolean
disableSelection
=
false
;
public
void
didPressedCanceSendButton
(
ChatBaseCell
cell
)
{
if
(
mActionMode
!=
null
)
{
MessageObject
message
=
cell
.
getMessageObject
();
if
(
selectedMessagesIds
.
containsKey
(
message
.
messageOwner
.
id
))
{
if
(
message
.
messageOwner
.
send_state
!=
0
)
{
view
.
setBackgroundColor
(
0x6633b5e5
);
MessagesController
.
getInstance
().
cancelSendingMessage
(
message
);
selected
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
}
disableSelection
=
true
;
}
}
else
{
};
view
.
setBackgroundColor
(
0
);
if
(
view
instanceof
ChatMediaCell
)
{
((
ChatMediaCell
)
view
).
mediaDelegate
=
new
ChatMediaCell
.
ChatMediaCellDelegate
()
{
@Override
public
void
didPressedImage
(
ChatBaseCell
cell
)
{
NotificationCenter
.
getInstance
().
addToMemCache
(
51
,
cell
.
getMessageObject
());
Intent
intent
=
new
Intent
(
parentActivity
,
GalleryImageViewer
.
class
);
startActivity
(
intent
);
}
};
}
}
if
(
view
instanceof
ChatBaseCell
)
{
((
ChatBaseCell
)
view
).
isChat
=
currentChat
!=
null
;
((
ChatBaseCell
)
view
).
setMessageObject
(
message
);
((
ChatBaseCell
)
view
).
setMessageObject
(
message
);
((
ChatBaseCell
)
view
).
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
((
ChatBaseCell
)
view
).
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
if
(
view
instanceof
ChatAudioCell
&&
downloadAudios
)
{
if
(
view
instanceof
ChatAudioCell
&&
downloadAudios
)
{
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
}
else
if
(
view
instanceof
ChatMediaCell
)
{
((
ChatMediaCell
)
view
).
downloadPhotos
=
downloadPhotos
;
}
}
}
else
{
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
view
.
getTag
();
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
view
.
getTag
();
if
(
holder
==
null
)
{
if
(
holder
==
null
)
{
holder
=
new
ChatListRowHolderEx
(
view
,
type
);
holder
=
new
ChatListRowHolderEx
(
view
,
message
.
type
);
view
.
setTag
(
holder
);
view
.
setTag
(
holder
);
}
}
holder
.
message
=
message
;
holder
.
message
=
message
;
...
@@ -3579,12 +3708,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3579,12 +3708,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
14
;
return
14
;
}
}
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
return
message
.
t
ype
;
return
message
.
contentT
ype
;
}
}
@Override
@Override
public
int
getViewTypeCount
()
{
public
int
getViewTypeCount
()
{
return
20
;
return
16
;
}
}
@Override
@Override
...
@@ -3620,7 +3749,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3620,7 +3749,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public
ImageView
addContactButton
;
public
ImageView
addContactButton
;
public
View
addContactView
;
public
View
addContactView
;
public
View
chatBubbleView
;
public
View
chatBubbleView
;
public
View
photoProgressView
;
public
ProgressBar
actionProgress
;
public
ProgressBar
actionProgress
;
public
View
actionView
;
public
View
actionView
;
...
@@ -3649,12 +3777,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3649,12 +3777,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
avatarImageView
.
setImage
(
photo
,
"50_50"
,
placeHolderId
);
avatarImageView
.
setImage
(
photo
,
"50_50"
,
placeHolderId
);
}
}
if
(
type
!=
12
&&
type
!=
13
&&
nameTextView
!=
null
&&
fromUser
!=
null
&&
type
!=
16
&&
type
!=
17
)
{
if
(
type
!=
12
&&
type
!=
13
&&
nameTextView
!=
null
&&
fromUser
!=
null
&&
type
!=
8
&&
type
!=
9
)
{
nameTextView
.
setText
(
Utilities
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
));
nameTextView
.
setText
(
Utilities
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
));
nameTextView
.
setTextColor
(
Utilities
.
getColorForId
(
message
.
messageOwner
.
from_id
));
nameTextView
.
setTextColor
(
Utilities
.
getColorForId
(
message
.
messageOwner
.
from_id
));
}
}
if
(
type
==
2
||
type
==
3
||
type
==
6
||
type
==
7
)
{
if
(
type
==
6
||
type
==
7
)
{
int
width
=
(
int
)(
Math
.
min
(
displaySize
.
x
,
displaySize
.
y
)
*
0.7f
);
int
width
=
(
int
)(
Math
.
min
(
displaySize
.
x
,
displaySize
.
y
)
*
0.7f
);
int
height
=
width
+
Utilities
.
dp
(
100
);
int
height
=
width
+
Utilities
.
dp
(
100
);
if
(
type
==
6
||
type
==
7
)
{
if
(
type
==
6
||
type
==
7
)
{
...
@@ -3669,11 +3797,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3669,11 +3797,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
message
.
photoThumbs
,
width
,
height
);
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
message
.
photoThumbs
,
width
,
height
);
if
(
type
==
3
)
{
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photo
!=
null
)
{
if
(
photo
!=
null
)
{
float
scale
=
(
float
)
photo
.
photoOwner
.
w
/
(
float
)
width
;
float
scale
=
(
float
)
photo
.
photoOwner
.
w
/
(
float
)
width
;
...
@@ -3706,17 +3829,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3706,17 +3829,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
photo
.
image
!=
null
)
{
if
(
photo
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
photo
.
image
);
photoImage
.
setImageBitmap
(
photo
.
image
);
}
else
{
}
else
{
if
(
type
==
2
||
type
==
3
)
{
String
fileName
=
MessageObject
.
getAttachFileName
(
photo
.
photoOwner
);
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
if
(!
cacheFile
.
exists
())
{
photoFileName
=
fileName
;
photoFile
=
cacheFile
;
}
else
{
photoFileName
=
null
;
photoFile
=
null
;
}
}
if
(
photoFileName
==
null
)
{
if
(
photoFileName
==
null
)
{
if
(
message
.
imagePreview
!=
null
)
{
if
(
message
.
imagePreview
!=
null
)
{
photoImage
.
setImage
(
photo
.
photoOwner
.
location
,
String
.
format
(
Locale
.
US
,
"%d_%d"
,
(
int
)(
w
/
Utilities
.
density
),
(
int
)(
h
/
Utilities
.
density
)),
message
.
imagePreview
);
photoImage
.
setImage
(
photo
.
photoOwner
.
location
,
String
.
format
(
Locale
.
US
,
"%d_%d"
,
(
int
)(
w
/
Utilities
.
density
),
(
int
)(
h
/
Utilities
.
density
)),
message
.
imagePreview
);
...
@@ -3817,7 +3929,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3817,7 +3929,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
messageTextView
.
setText
(
LocaleController
.
formatString
(
"FewNewMessages"
,
R
.
string
.
FewNewMessages
,
unread_to_load
));
messageTextView
.
setText
(
LocaleController
.
formatString
(
"FewNewMessages"
,
R
.
string
.
FewNewMessages
,
unread_to_load
));
}
}
}
else
if
(
type
==
16
||
type
==
17
)
{
}
else
if
(
type
==
8
||
type
==
9
)
{
TLRPC
.
Document
document
=
message
.
messageOwner
.
media
.
document
;
TLRPC
.
Document
document
=
message
.
messageOwner
.
media
.
document
;
if
(
document
instanceof
TLRPC
.
TL_document
||
document
instanceof
TLRPC
.
TL_documentEncrypted
)
{
if
(
document
instanceof
TLRPC
.
TL_document
||
document
instanceof
TLRPC
.
TL_documentEncrypted
)
{
nameTextView
.
setText
(
message
.
messageOwner
.
media
.
document
.
file_name
);
nameTextView
.
setText
(
message
.
messageOwner
.
media
.
document
.
file_name
);
...
@@ -3844,7 +3956,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3844,7 +3956,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
document
.
thumb
instanceof
TLRPC
.
TL_photoCachedSize
)
{
}
else
if
(
document
.
thumb
instanceof
TLRPC
.
TL_photoCachedSize
)
{
}
else
{
}
else
{
if
(
type
==
16
)
{
if
(
type
==
8
)
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
}
else
{
}
else
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
...
@@ -3853,7 +3965,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3853,7 +3965,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
nameTextView
.
setText
(
"Error"
);
nameTextView
.
setText
(
"Error"
);
phoneTextView
.
setText
(
"Error"
);
phoneTextView
.
setText
(
"Error"
);
if
(
type
==
16
)
{
if
(
type
==
8
)
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
}
else
{
}
else
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
...
@@ -3871,19 +3983,16 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3871,19 +3983,16 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
halfCheckImage
!=
null
)
{
if
(
halfCheckImage
!=
null
)
{
if
(
message
.
messageOwner
.
send_state
==
MessagesController
.
MESSAGE_SEND_STATE_SENDING
)
{
if
(
message
.
messageOwner
.
send_state
==
MessagesController
.
MESSAGE_SEND_STATE_SENDING
)
{
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
if
(
type
==
2
||
type
==
6
||
type
==
4
)
{
if
(
type
==
6
||
type
==
4
)
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock_photo
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock_photo
);
}
else
{
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock
);
}
}
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
if
(
actionView
!=
null
||
photoProgressView
!=
null
)
{
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
VISIBLE
);
actionView
.
setVisibility
(
View
.
VISIBLE
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
VISIBLE
);
}
Float
progress
=
FileLoader
.
getInstance
().
fileProgresses
.
get
(
message
.
messageOwner
.
attachPath
);
Float
progress
=
FileLoader
.
getInstance
().
fileProgresses
.
get
(
message
.
messageOwner
.
attachPath
);
if
(
progress
!=
null
)
{
if
(
progress
!=
null
)
{
actionProgress
.
setProgress
((
int
)(
progress
*
100
));
actionProgress
.
setProgress
((
int
)(
progress
*
100
));
...
@@ -3905,9 +4014,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3905,9 +4014,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
GONE
);
actionAttachButton
.
setVisibility
(
View
.
GONE
);
}
}
...
@@ -3915,7 +4021,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3915,7 +4021,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(!
message
.
messageOwner
.
unread
)
{
if
(!
message
.
messageOwner
.
unread
)
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
VISIBLE
);
if
(
type
==
2
||
type
==
6
||
type
==
4
)
{
if
(
type
==
6
||
type
==
4
)
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck_w
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck_w
);
}
else
{
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck
);
...
@@ -3923,7 +4029,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3923,7 +4029,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
}
else
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
if
(
type
==
2
||
type
==
6
||
type
==
4
)
{
if
(
type
==
6
||
type
==
4
)
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check_w
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check_w
);
}
else
{
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check
);
...
@@ -3932,16 +4038,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3932,16 +4038,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
}
}
}
}
}
if
(
message
.
type
==
2
||
message
.
type
==
3
||
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
16
||
message
.
type
==
17
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
8
||
message
.
type
==
9
)
{
Integer
tag
=
(
Integer
)
actionProgress
.
getTag
();
Integer
tag
=
(
Integer
)
actionProgress
.
getTag
();
String
file
=
progressByTag
.
get
(
tag
);
String
file
=
progressByTag
.
get
(
tag
);
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
...
@@ -3965,37 +4068,31 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -3965,37 +4068,31 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"ViewVideo"
,
R
.
string
.
ViewVideo
));
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"ViewVideo"
,
R
.
string
.
ViewVideo
));
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"Open"
,
R
.
string
.
Open
));
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"Open"
,
R
.
string
.
Open
));
}
}
}
}
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
}
else
{
}
else
{
load
=
true
;
load
=
true
;
}
}
}
}
if
(
load
&&
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
||
!
load
&&
(
message
.
messageOwner
.
attachPath
==
null
||
message
.
messageOwner
.
attachPath
.
length
()
==
0
))
{
if
(
load
&&
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
||
!
load
&&
(
message
.
messageOwner
.
attachPath
==
null
||
message
.
messageOwner
.
attachPath
.
length
()
==
0
))
{
File
cacheFile
=
null
;
File
cacheFile
=
null
;
if
((
(
message
.
type
==
2
||
message
.
type
==
3
)
&&
photoFileName
==
null
)
||
(
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
)).
exists
())
{
if
((
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
)).
exists
())
{
if
(
actionAttachButton
!=
null
)
{
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"ViewVideo"
,
R
.
string
.
ViewVideo
));
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"ViewVideo"
,
R
.
string
.
ViewVideo
));
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"Open"
,
R
.
string
.
Open
));
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"Open"
,
R
.
string
.
Open
));
}
}
}
}
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
load
=
false
;
load
=
false
;
}
else
{
}
else
{
load
=
true
;
load
=
true
;
...
@@ -4012,47 +4109,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4012,47 +4109,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
progressByTag
.
put
((
Integer
)
actionProgress
.
getTag
(),
fileName
);
progressByTag
.
put
((
Integer
)
actionProgress
.
getTag
(),
fileName
);
addToLoadingFile
(
fileName
,
actionProgress
);
addToLoadingFile
(
fileName
,
actionProgress
);
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
if
((
message
.
type
==
2
||
message
.
type
==
3
)
&&
downloadPhotos
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
else
{
actionView
.
setVisibility
(
View
.
VISIBLE
);
actionView
.
setVisibility
(
View
.
VISIBLE
);
if
(
photoFileName
!=
null
)
{
if
(
photoFileName
!=
null
)
{
actionCancelButton
.
setImageResource
(
R
.
drawable
.
photo_download_cancel_states
);
actionCancelButton
.
setImageResource
(
R
.
drawable
.
photo_download_cancel_states
);
}
}
}
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
actionAttachButton
!=
null
)
{
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
GONE
);
actionAttachButton
.
setVisibility
(
View
.
GONE
);
}
}
}
else
{
}
else
{
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
if
((
message
.
type
==
2
||
message
.
type
==
3
)
&&
!
downloadPhotos
)
{
actionView
.
setVisibility
(
View
.
VISIBLE
);
actionCancelButton
.
setImageResource
(
R
.
drawable
.
photo_download_states
);
}
else
{
actionView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
actionAttachButton
.
setText
(
String
.
format
(
"%s %.1f MB"
,
LocaleController
.
getString
(
"DOWNLOAD"
,
R
.
string
.
DOWNLOAD
),
message
.
messageOwner
.
media
.
video
.
size
/
1024.0f
/
1024.0f
));
actionAttachButton
.
setText
(
String
.
format
(
"%s %.1f MB"
,
LocaleController
.
getString
(
"DOWNLOAD"
,
R
.
string
.
DOWNLOAD
),
message
.
messageOwner
.
media
.
video
.
size
/
1024.0f
/
1024.0f
));
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"DOWNLOAD"
,
R
.
string
.
DOWNLOAD
));
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"DOWNLOAD"
,
R
.
string
.
DOWNLOAD
));
}
}
}
}
}
}
}
}
}
}
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
int
width
;
int
width
;
if
(
currentChat
!=
null
&&
type
!=
16
)
{
if
(
currentChat
!=
null
&&
type
!=
8
)
{
if
(
actionView
.
getVisibility
()
==
View
.
VISIBLE
)
{
if
(
actionView
.
getVisibility
()
==
View
.
VISIBLE
)
{
width
=
displaySize
.
x
-
Utilities
.
dp
(
290
);
width
=
displaySize
.
x
-
Utilities
.
dp
(
290
);
}
else
{
}
else
{
...
@@ -4091,7 +4173,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4091,7 +4173,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
addContactButton
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
add_contact_button
);
addContactButton
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
add_contact_button
);
addContactView
=
view
.
findViewById
(
R
.
id
.
add_contact_view
);
addContactView
=
view
.
findViewById
(
R
.
id
.
add_contact_view
);
chatBubbleView
=
view
.
findViewById
(
R
.
id
.
chat_bubble_layout
);
chatBubbleView
=
view
.
findViewById
(
R
.
id
.
chat_bubble_layout
);
photoProgressView
=
view
.
findViewById
(
R
.
id
.
photo_progress
);
if
(
messageTextView
!=
null
)
{
if
(
messageTextView
!=
null
)
{
messageTextView
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
MessagesController
.
getInstance
().
fontSize
);
messageTextView
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
MessagesController
.
getInstance
().
fontSize
);
}
}
...
@@ -4149,7 +4230,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4149,7 +4230,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
contactView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
contactView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
processOnClick
(
view
);
processOnClick
(
view
);
}
else
if
(
message
.
type
==
12
||
message
.
type
==
13
)
{
}
else
if
(
message
.
type
==
12
||
message
.
type
==
13
)
{
if
(
mActionMode
!=
null
)
{
if
(
mActionMode
!=
null
)
{
...
@@ -4230,15 +4311,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4230,15 +4311,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
contactAvatar
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
contactAvatar
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
if
(
message
.
type
==
18
||
message
.
type
==
19
)
{
if
(
message
.
messageOwner
.
media
.
audio
.
user_id
!=
UserConfig
.
clientUserId
&&
message
.
messageOwner
.
media
.
audio
.
user_id
!=
0
)
{
UserProfileActivity
fragment
=
new
UserProfileActivity
();
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
message
.
messageOwner
.
media
.
audio
.
user_id
);
fragment
.
setArguments
(
args
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"user_"
+
message
.
messageOwner
.
media
.
audio
.
user_id
,
false
);
}
}
}
}
});
});
}
}
...
@@ -4283,33 +4356,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4283,33 +4356,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
progressBarMap
.
remove
(
file
);
progressBarMap
.
remove
(
file
);
}
}
}
else
if
(
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
8
||
message
.
type
==
9
)
{
String
file
=
progressByTag
.
get
(
tag
);
String
file
=
progressByTag
.
get
(
tag
);
if
(
file
!=
null
)
{
if
(
file
!=
null
)
{
loadingFile
.
remove
(
file
);
loadingFile
.
remove
(
file
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
FileLoader
.
getInstance
().
cancelLoadFile
(
message
.
messageOwner
.
media
.
video
,
null
,
null
,
null
);
FileLoader
.
getInstance
().
cancelLoadFile
(
message
.
messageOwner
.
media
.
video
,
null
,
null
,
null
);
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
FileLoader
.
getInstance
().
cancelLoadFile
(
null
,
null
,
message
.
messageOwner
.
media
.
document
,
null
);
FileLoader
.
getInstance
().
cancelLoadFile
(
null
,
null
,
message
.
messageOwner
.
media
.
document
,
null
);
}
}
updateVisibleRows
();
updateVisibleRows
();
}
}
}
else
if
(
message
.
type
==
2
||
message
.
type
==
3
)
{
if
(
photoFile
!=
null
&&
!
photoFile
.
exists
()
&&
photoObjectToSet
!=
null
)
{
if
(
loadingFile
.
containsKey
(
photoFileName
))
{
loadingFile
.
remove
(
photoFileName
);
FileLoader
.
getInstance
().
cancelLoadingForImageView
(
photoImage
);
updateVisibleRows
();
}
else
{
addToLoadingFile
(
photoFileName
,
actionProgress
);
if
(
message
.
imagePreview
!=
null
)
{
photoImage
.
setImage
(
photoObjectToSet
.
photoOwner
.
location
,
photoFilter
,
message
.
imagePreview
,
photoObjectToSet
.
photoOwner
.
size
);
}
else
{
photoImage
.
setImage
(
photoObjectToSet
.
photoOwner
.
location
,
photoFilter
,
message
.
messageOwner
.
out
?
R
.
drawable
.
photo_placeholder_out
:
R
.
drawable
.
photo_placeholder_in
,
photoObjectToSet
.
photoOwner
.
size
);
}
updateVisibleRows
();
}
}
}
}
}
}
}
}
...
@@ -4367,25 +4424,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4367,25 +4424,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
NotificationCenter
.
getInstance
().
addToMemCache
(
0
,
message
);
NotificationCenter
.
getInstance
().
addToMemCache
(
0
,
message
);
LocationActivity
fragment
=
new
LocationActivity
();
LocationActivity
fragment
=
new
LocationActivity
();
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"location_view"
,
false
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"location_view"
,
false
);
}
else
if
(
message
.
type
==
2
||
message
.
type
==
3
)
{
if
(
photoFile
==
null
||
photoObjectToSet
==
null
||
photoFile
!=
null
&&
photoFile
.
exists
())
{
NotificationCenter
.
getInstance
().
addToMemCache
(
51
,
message
);
Intent
intent
=
new
Intent
(
parentActivity
,
GalleryImageViewer
.
class
);
startActivity
(
intent
);
}
else
{
addToLoadingFile
(
photoFileName
,
actionProgress
);
if
(
message
.
imagePreview
!=
null
)
{
photoImage
.
setImage
(
photoObjectToSet
.
photoOwner
.
location
,
photoFilter
,
message
.
imagePreview
,
photoObjectToSet
.
photoOwner
.
size
);
}
else
{
photoImage
.
setImage
(
photoObjectToSet
.
photoOwner
.
location
,
photoFilter
,
message
.
messageOwner
.
out
?
R
.
drawable
.
photo_placeholder_out
:
R
.
drawable
.
photo_placeholder_in
,
photoObjectToSet
.
photoOwner
.
size
);
}
updateVisibleRows
();
}
}
else
if
(
message
.
type
==
11
)
{
}
else
if
(
message
.
type
==
11
)
{
NotificationCenter
.
getInstance
().
addToMemCache
(
51
,
message
);
NotificationCenter
.
getInstance
().
addToMemCache
(
51
,
message
);
Intent
intent
=
new
Intent
(
parentActivity
,
GalleryImageViewer
.
class
);
Intent
intent
=
new
Intent
(
parentActivity
,
GalleryImageViewer
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
}
else
if
(
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
6
||
message
.
type
==
7
||
message
.
type
==
8
||
message
.
type
==
9
)
{
File
f
=
null
;
File
f
=
null
;
String
fileName
=
message
.
getFileName
();
String
fileName
=
message
.
getFileName
();
if
(
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
if
(
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
...
@@ -4400,7 +4443,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4400,7 +4443,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
f
),
"video/mp4"
);
intent
.
setDataAndType
(
Uri
.
fromFile
(
f
),
"video/mp4"
);
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
MimeTypeMap
myMime
=
MimeTypeMap
.
getSingleton
();
MimeTypeMap
myMime
=
MimeTypeMap
.
getSingleton
();
int
idx
=
fileName
.
lastIndexOf
(
"."
);
int
idx
=
fileName
.
lastIndexOf
(
"."
);
if
(
idx
!=
-
1
)
{
if
(
idx
!=
-
1
)
{
...
@@ -4435,7 +4478,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -4435,7 +4478,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
addToLoadingFile
(
fileName
,
actionProgress
);
addToLoadingFile
(
fileName
,
actionProgress
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
FileLoader
.
getInstance
().
loadFile
(
message
.
messageOwner
.
media
.
video
,
null
,
null
,
null
);
FileLoader
.
getInstance
().
loadFile
(
message
.
messageOwner
.
media
.
video
,
null
,
null
,
null
);
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
FileLoader
.
getInstance
().
loadFile
(
null
,
null
,
message
.
messageOwner
.
media
.
document
,
null
);
FileLoader
.
getInstance
().
loadFile
(
null
,
null
,
message
.
messageOwner
.
media
.
document
,
null
);
}
}
updateVisibleRows
();
updateVisibleRows
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
View file @
ebe7ab78
...
@@ -409,7 +409,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
...
@@ -409,7 +409,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView
.
invalidateViews
();
listView
.
invalidateViews
();
}
}
}
else
if
(
i
==
languageRow
)
{
}
else
if
(
i
==
languageRow
)
{
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
LanguageSelectActivity
(),
"settings_
wallpapers
"
,
false
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
LanguageSelectActivity
(),
"settings_
lang
"
,
false
);
}
else
if
(
i
==
switchBackendButtonRow
)
{
}
else
if
(
i
==
switchBackendButtonRow
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
parentActivity
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
parentActivity
);
builder
.
setMessage
(
LocaleController
.
getString
(
"AreYouSure"
,
R
.
string
.
AreYouSure
));
builder
.
setMessage
(
LocaleController
.
getString
(
"AreYouSure"
,
R
.
string
.
AreYouSure
));
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/GifDrawable.java
View file @
ebe7ab78
...
@@ -24,6 +24,7 @@ THE SOFTWARE.
...
@@ -24,6 +24,7 @@ THE SOFTWARE.
package
org
.
telegram
.
ui
.
Views
;
package
org
.
telegram
.
ui
.
Views
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.Canvas
;
import
android.graphics.ColorFilter
;
import
android.graphics.ColorFilter
;
import
android.graphics.Paint
;
import
android.graphics.Paint
;
...
@@ -33,9 +34,11 @@ import android.graphics.drawable.Animatable;
...
@@ -33,9 +34,11 @@ import android.graphics.drawable.Animatable;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.Looper
;
import
android.view.View
;
import
android.widget.MediaController
;
import
android.widget.MediaController
;
import
java.io.File
;
import
java.io.File
;
import
java.lang.ref.WeakReference
;
import
java.util.Locale
;
import
java.util.Locale
;
public
class
GifDrawable
extends
Drawable
implements
Animatable
,
MediaController
.
MediaPlayerControl
{
public
class
GifDrawable
extends
Drawable
implements
Animatable
,
MediaController
.
MediaPlayerControl
{
...
@@ -68,6 +71,8 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -68,6 +71,8 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private
boolean
mApplyTransformation
;
private
boolean
mApplyTransformation
;
private
final
Rect
mDstRect
=
new
Rect
();
private
final
Rect
mDstRect
=
new
Rect
();
public
WeakReference
<
View
>
parentView
=
null
;
protected
final
Paint
mPaint
=
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
|
Paint
.
DITHER_FLAG
);
protected
final
Paint
mPaint
=
new
Paint
(
Paint
.
FILTER_BITMAP_FLAG
|
Paint
.
DITHER_FLAG
);
protected
final
int
[]
mColors
;
protected
final
int
[]
mColors
;
...
@@ -82,7 +87,10 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -82,7 +87,10 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
@Override
public
void
run
()
{
public
void
run
()
{
restoreRemainder
(
mGifInfoPtr
);
restoreRemainder
(
mGifInfoPtr
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
mMetaData
[
4
]
=
0
;
}
}
};
};
...
@@ -96,7 +104,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -96,7 +104,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private
final
Runnable
mInvalidateTask
=
new
Runnable
()
{
private
final
Runnable
mInvalidateTask
=
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
}
};
};
...
@@ -109,18 +119,12 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -109,18 +119,12 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
}
}
public
GifDrawable
(
String
filePath
)
throws
Exception
{
public
GifDrawable
(
String
filePath
)
throws
Exception
{
if
(
filePath
==
null
)
{
throw
new
NullPointerException
(
"Source is null"
);
}
mInputSourceLength
=
new
File
(
filePath
).
length
();
mInputSourceLength
=
new
File
(
filePath
).
length
();
mGifInfoPtr
=
openFile
(
mMetaData
,
filePath
);
mGifInfoPtr
=
openFile
(
mMetaData
,
filePath
);
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
}
}
public
GifDrawable
(
File
file
)
throws
Exception
{
public
GifDrawable
(
File
file
)
throws
Exception
{
if
(
file
==
null
)
{
throw
new
NullPointerException
(
"Source is null"
);
}
mInputSourceLength
=
file
.
length
();
mInputSourceLength
=
file
.
length
();
mGifInfoPtr
=
openFile
(
mMetaData
,
file
.
getPath
());
mGifInfoPtr
=
openFile
(
mMetaData
,
file
.
getPath
());
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
...
@@ -169,6 +173,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -169,6 +173,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
@Override
public
void
start
()
{
public
void
start
()
{
if
(
mIsRunning
)
{
return
;
}
mIsRunning
=
true
;
mIsRunning
=
true
;
runOnUiThread
(
mStartTask
);
runOnUiThread
(
mStartTask
);
}
}
...
@@ -240,7 +247,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -240,7 +247,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
@Override
public
void
run
()
{
public
void
run
()
{
seekToTime
(
mGifInfoPtr
,
position
,
mColors
);
seekToTime
(
mGifInfoPtr
,
position
,
mColors
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
}
});
});
}
}
...
@@ -253,7 +262,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -253,7 +262,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
@Override
public
void
run
()
{
public
void
run
()
{
seekToFrame
(
mGifInfoPtr
,
frameIndex
,
mColors
);
seekToFrame
(
mGifInfoPtr
,
frameIndex
,
mColors
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
}
});
});
}
}
...
@@ -323,6 +334,11 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -323,6 +334,11 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
return
mColors
[
mMetaData
[
1
]
*
y
+
x
];
return
mColors
[
mMetaData
[
1
]
*
y
+
x
];
}
}
public
Bitmap
getBitmap
()
{
seekToFrame
(
mGifInfoPtr
,
0
,
mColors
);
return
Bitmap
.
createBitmap
(
mColors
,
0
,
mMetaData
[
0
],
mMetaData
[
0
],
mMetaData
[
1
],
Bitmap
.
Config
.
ARGB_8888
);
}
@Override
@Override
protected
void
onBoundsChange
(
Rect
bounds
)
{
protected
void
onBoundsChange
(
Rect
bounds
)
{
super
.
onBoundsChange
(
bounds
);
super
.
onBoundsChange
(
bounds
);
...
@@ -343,6 +359,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -343,6 +359,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
}
else
{
}
else
{
mMetaData
[
4
]
=
-
1
;
mMetaData
[
4
]
=
-
1
;
}
}
canvas
.
translate
(
mDstRect
.
left
,
mDstRect
.
top
);
canvas
.
scale
(
mSx
,
mSy
);
canvas
.
scale
(
mSx
,
mSy
);
canvas
.
drawBitmap
(
mColors
,
0
,
mMetaData
[
0
],
0
f
,
0
f
,
mMetaData
[
0
],
mMetaData
[
1
],
true
,
mPaint
);
canvas
.
drawBitmap
(
mColors
,
0
,
mMetaData
[
0
],
0
f
,
0
f
,
mMetaData
[
0
],
mMetaData
[
1
],
true
,
mPaint
);
if
(
mMetaData
[
4
]
>=
0
&&
mMetaData
[
2
]
>
1
)
{
if
(
mMetaData
[
4
]
>=
0
&&
mMetaData
[
2
]
>
1
)
{
...
@@ -365,13 +382,17 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
...
@@ -365,13 +382,17 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
@Override
public
void
setFilterBitmap
(
boolean
filter
)
{
public
void
setFilterBitmap
(
boolean
filter
)
{
mPaint
.
setFilterBitmap
(
filter
);
mPaint
.
setFilterBitmap
(
filter
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
}
@Override
@Override
public
void
setDither
(
boolean
dither
)
{
public
void
setDither
(
boolean
dither
)
{
mPaint
.
setDither
(
dither
);
mPaint
.
setDither
(
dither
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
}
@Override
@Override
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java
View file @
ebe7ab78
...
@@ -111,10 +111,47 @@ public class ImageReceiver {
...
@@ -111,10 +111,47 @@ public class ImageReceiver {
}
}
}
}
public
void
setImageBitmap
(
Bitmap
bitmap
)
{
currentPath
=
null
;
last_path
=
null
;
last_httpUrl
=
null
;
last_filter
=
null
;
last_placeholder
=
null
;
last_size
=
0
;
FileLoader
.
getInstance
().
cancelLoadingForImageView
(
this
);
if
(
bitmap
!=
null
)
{
recycleBitmap
(
null
);
currentImage
=
new
BitmapDrawable
(
null
,
bitmap
);
}
}
public
void
setImageBitmap
(
Drawable
bitmap
)
{
currentPath
=
null
;
last_path
=
null
;
last_httpUrl
=
null
;
last_filter
=
null
;
last_placeholder
=
null
;
last_size
=
0
;
FileLoader
.
getInstance
().
cancelLoadingForImageView
(
this
);
if
(
bitmap
!=
null
)
{
recycleBitmap
(
null
);
currentImage
=
bitmap
;
}
}
public
void
clearImage
()
{
public
void
clearImage
()
{
recycleBitmap
(
null
);
recycleBitmap
(
null
);
}
}
@Override
protected
void
finalize
()
throws
Throwable
{
try
{
clearImage
();
}
finally
{
super
.
finalize
();
}
}
private
void
recycleBitmap
(
Bitmap
newBitmap
)
{
private
void
recycleBitmap
(
Bitmap
newBitmap
)
{
if
(
currentImage
==
null
||
isPlaceholder
)
{
if
(
currentImage
==
null
||
isPlaceholder
)
{
return
;
return
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java
View file @
ebe7ab78
...
@@ -14,50 +14,35 @@ import android.graphics.Paint;
...
@@ -14,50 +14,35 @@ import android.graphics.Paint;
import
org.telegram.messenger.Utilities
;
import
org.telegram.messenger.Utilities
;
public
class
ProgressView
{
public
class
ProgressView
{
private
static
Paint
innerPaint1
;
private
Paint
innerPaint
;
private
static
Paint
outerPaint1
;
private
Paint
outerPaint
;
private
static
Paint
innerPaint2
;
private
static
Paint
outerPaint2
;
public
int
type
;
public
float
currentProgress
=
0
;
public
int
thumbX
=
0
;
public
int
width
;
public
int
width
;
public
int
height
;
public
int
height
;
public
float
progressHeight
=
Utilities
.
dpf
(
2.0f
);
public
ProgressView
()
{
public
ProgressView
()
{
if
(
innerPaint1
==
null
)
{
innerPaint
=
new
Paint
();
innerPaint1
=
new
Paint
();
outerPaint
=
new
Paint
();
outerPaint1
=
new
Paint
();
innerPaint2
=
new
Paint
();
outerPaint2
=
new
Paint
();
innerPaint1
.
setColor
(
0xffb4e396
);
outerPaint1
.
setColor
(
0xff6ac453
);
innerPaint2
.
setColor
(
0xffd9e2eb
);
outerPaint2
.
setColor
(
0xff86c5f8
);
}
}
public
void
setProgressColors
(
int
innerColor
,
int
outerColor
)
{
innerPaint
.
setColor
(
innerColor
);
outerPaint
.
setColor
(
outerColor
);
}
}
public
void
setProgress
(
float
progress
)
{
public
void
setProgress
(
float
progress
)
{
thumbX
=
(
int
)
Math
.
ceil
(
width
*
progress
)
;
currentProgress
=
progress
;
if
(
thumbX
<
0
)
{
if
(
currentProgress
<
0
)
{
thumbX
=
0
;
currentProgress
=
0
;
}
else
if
(
thumbX
>
width
)
{
}
else
if
(
currentProgress
>
1
)
{
thumbX
=
width
;
currentProgress
=
1
;
}
}
}
}
public
void
draw
(
Canvas
canvas
)
{
public
void
draw
(
Canvas
canvas
)
{
Paint
inner
=
null
;
canvas
.
drawRect
(
0
,
height
/
2
-
progressHeight
/
2.0f
,
width
,
height
/
2
+
progressHeight
/
2.0f
,
innerPaint
);
Paint
outer
=
null
;
canvas
.
drawRect
(
0
,
height
/
2
-
progressHeight
/
2.0f
,
width
*
currentProgress
,
height
/
2
+
progressHeight
/
2.0f
,
outerPaint
);
if
(
type
==
0
)
{
inner
=
innerPaint1
;
outer
=
outerPaint1
;
}
else
if
(
type
==
1
)
{
inner
=
innerPaint2
;
outer
=
outerPaint2
;
}
canvas
.
drawRect
(
0
,
height
/
2
-
Utilities
.
dp
(
1
),
width
,
height
/
2
+
Utilities
.
dp
(
1
),
inner
);
canvas
.
drawRect
(
0
,
height
/
2
-
Utilities
.
dp
(
1
),
thumbX
,
height
/
2
+
Utilities
.
dp
(
1
),
outer
);
}
}
}
}
TMessagesProj/src/main/res/layout/chat_group_incoming_photo_layout.xml
deleted
100644 → 0
View file @
5323e87b
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"1dp"
android:paddingTop=
"1dp"
android:layout_gravity=
"top"
>
<org.telegram.ui.Views.BackupImageView
android:layout_width=
"42dp"
android:layout_height=
"42dp"
android:layout_marginLeft=
"6dp"
android:id=
"@+id/chat_group_avatar_image"
android:scaleType=
"fitCenter"
android:layout_marginBottom=
"2dp"
android:layout_gravity=
"bottom"
/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"13dp"
android:layout_gravity=
"top"
android:id=
"@+id/chat_bubble_layout"
android:addStatesFromChildren=
"true"
>
<org.telegram.ui.Views.BackupImageView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_margin=
"6dp"
android:layout_gravity=
"top"
android:scaleType=
"centerCrop"
android:minHeight=
"100dp"
android:minWidth=
"100dp"
android:id=
"@+id/chat_photo_image"
/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height=
"44dp"
android:layout_width=
"44dp"
android:id=
"@+id/chat_view_action_layout"
android:layout_gravity=
"center"
android:visibility=
"visible"
>
<ImageView
android:layout_width=
"44dp"
android:layout_height=
"44dp"
android:scaleType=
"centerInside"
android:id=
"@+id/chat_view_action_cancel_button"
android:src=
"@drawable/photo_download_states"
android:layout_gravity=
"center"
android:clickable=
"true"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"16dp"
android:orientation=
"horizontal"
android:layout_marginLeft=
"10dp"
android:layout_marginBottom=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_gravity=
"right|bottom"
android:gravity=
"right"
>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"0dp"
android:layout_height=
"16dp"
android:paddingLeft=
"6dp"
android:paddingRight=
"6dp"
android:paddingTop=
"1dp"
android:layout_marginRight=
"4dp"
android:background=
"@drawable/phototime"
android:id=
"@+id/photo_progress"
android:layout_weight=
"1"
>
<ProgressBar
android:layout_width=
"fill_parent"
android:layout_height=
"3dp"
android:layout_gravity=
"right|center_vertical"
android:progressDrawable=
"@drawable/photo_progress_chat"
style=
"?android:attr/progressBarStyleHorizontal"
android:progress=
"50"
android:id=
"@+id/chat_view_action_progress"
android:max=
"100"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:id=
"@+id/chat_time_layout"
android:paddingLeft=
"3dp"
android:paddingRight=
"3dp"
android:background=
"@drawable/phototime"
>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:textColor=
"#ffffff"
android:textSize=
"12dp"
android:layout_gravity=
"bottom"
android:layout_marginBottom=
"1dp"
android:id=
"@+id/chat_time_text"
/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
TMessagesProj/src/main/res/layout/chat_incoming_photo_layout.xml
deleted
100644 → 0
View file @
5323e87b
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"1dp"
android:paddingTop=
"1dp"
android:layout_gravity=
"top"
>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"9dp"
android:id=
"@+id/chat_bubble_layout"
android:layout_gravity=
"top"
android:addStatesFromChildren=
"true"
>
<org.telegram.ui.Views.BackupImageView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_margin=
"6dp"
android:layout_gravity=
"top"
android:scaleType=
"centerCrop"
android:minHeight=
"100dp"
android:minWidth=
"100dp"
android:id=
"@+id/chat_photo_image"
/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height=
"44dp"
android:layout_width=
"44dp"
android:id=
"@+id/chat_view_action_layout"
android:layout_gravity=
"center"
android:visibility=
"visible"
>
<ImageView
android:layout_width=
"44dp"
android:layout_height=
"44dp"
android:scaleType=
"centerInside"
android:id=
"@+id/chat_view_action_cancel_button"
android:src=
"@drawable/photo_download_states"
android:layout_gravity=
"center"
android:clickable=
"true"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"16dp"
android:orientation=
"horizontal"
android:layout_marginLeft=
"10dp"
android:layout_marginBottom=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_gravity=
"right|bottom"
android:gravity=
"right"
>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"0dp"
android:layout_height=
"16dp"
android:paddingLeft=
"6dp"
android:paddingRight=
"6dp"
android:paddingTop=
"1dp"
android:layout_marginRight=
"4dp"
android:background=
"@drawable/phototime"
android:id=
"@+id/photo_progress"
android:layout_weight=
"1"
>
<ProgressBar
android:layout_width=
"fill_parent"
android:layout_height=
"3dp"
android:layout_gravity=
"right|center_vertical"
android:progressDrawable=
"@drawable/photo_progress_chat"
style=
"?android:attr/progressBarStyleHorizontal"
android:progress=
"50"
android:id=
"@+id/chat_view_action_progress"
android:max=
"100"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:id=
"@+id/chat_time_layout"
android:paddingLeft=
"3dp"
android:paddingRight=
"3dp"
android:background=
"@drawable/phototime"
>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:textColor=
"#ffffff"
android:textSize=
"12dp"
android:layout_gravity=
"bottom"
android:layout_marginBottom=
"1dp"
android:id=
"@+id/chat_time_text"
/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
TMessagesProj/src/main/res/layout/chat_outgoing_photo_layout.xml
deleted
100644 → 0
View file @
5323e87b
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"right"
android:paddingBottom=
"1dp"
android:paddingTop=
"1dp"
>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"9dp"
android:id=
"@+id/chat_bubble_layout"
android:addStatesFromChildren=
"true"
>
<org.telegram.ui.Views.BackupImageView
android:layout_height=
"100dp"
android:layout_width=
"100dp"
android:layout_margin=
"6dp"
android:layout_gravity=
"top|left"
android:scaleType=
"centerCrop"
android:minHeight=
"100dp"
android:minWidth=
"100dp"
android:id=
"@+id/chat_photo_image"
/>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_height=
"44dp"
android:layout_width=
"44dp"
android:id=
"@+id/chat_view_action_layout"
android:layout_gravity=
"center"
android:visibility=
"visible"
>
<ImageView
android:layout_width=
"44dp"
android:layout_height=
"44dp"
android:scaleType=
"centerInside"
android:id=
"@+id/chat_view_action_cancel_button"
android:src=
"@drawable/photo_download_cancel_states"
android:layout_gravity=
"center"
android:clickable=
"true"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"16dp"
android:orientation=
"horizontal"
android:layout_marginLeft=
"10dp"
android:layout_marginBottom=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_gravity=
"right|bottom"
android:gravity=
"right"
>
<org.telegram.ui.Views.FrameLayoutFixed
android:layout_width=
"0dp"
android:layout_height=
"16dp"
android:paddingLeft=
"6dp"
android:paddingRight=
"6dp"
android:paddingTop=
"1dp"
android:layout_marginRight=
"4dp"
android:background=
"@drawable/phototime"
android:id=
"@+id/photo_progress"
android:layout_weight=
"1"
>
<ProgressBar
android:layout_width=
"fill_parent"
android:layout_height=
"3dp"
android:layout_gravity=
"right|center_vertical"
android:progressDrawable=
"@drawable/photo_progress_chat"
style=
"?android:attr/progressBarStyleHorizontal"
android:progress=
"50"
android:id=
"@+id/chat_view_action_progress"
android:max=
"100"
/>
</org.telegram.ui.Views.FrameLayoutFixed>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"16dp"
android:id=
"@+id/chat_time_layout"
android:paddingLeft=
"3dp"
android:paddingRight=
"3dp"
android:background=
"@drawable/phototime"
>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:textColor=
"#ffffff"
android:textSize=
"12dp"
android:layout_gravity=
"bottom"
android:layout_marginBottom=
"1dp"
android:id=
"@+id/chat_time_text"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/msg_check_w"
android:layout_marginTop=
"2dp"
android:layout_marginLeft=
"3dp"
android:layout_marginRight=
"-8dp"
android:id=
"@+id/chat_row_check"
android:visibility=
"visible"
android:layout_gravity=
"top"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"2dp"
android:id=
"@+id/chat_row_halfcheck"
android:visibility=
"visible"
android:src=
"@drawable/msg_halfcheck_w"
android:layout_gravity=
"top"
/>
</LinearLayout>
</LinearLayout>
</org.telegram.ui.Views.FrameLayoutFixed>
</LinearLayout>
\ No newline at end of file
TMessagesProj/src/main/res/values-ar/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
العربية
</string>
<string
name=
"LanguageName"
>
العربية
</string>
<string
name=
"LanguangeNameInEnglish"
>
Arabic
</string>
<string
name=
"LanguageNameInEnglish"
>
Arabic
</string>
<string
name=
"LanguageCode"
>
ar
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
رقم هاتفك المحمول
</string>
<string
name=
"YourPhone"
>
رقم هاتفك المحمول
</string>
...
@@ -110,7 +111,7 @@
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
حذف المجموعة
</string>
<string
name=
"DeleteThisGroup"
>
حذف المجموعة
</string>
<string
name=
"SlideToCancel"
>
قم بالسحب للإلغاء
</string>
<string
name=
"SlideToCancel"
>
قم بالسحب للإلغاء
</string>
<string
name=
"SaveToDownloads"
>
حفظ في الجهاز
</string>
<string
name=
"SaveToDownloads"
>
حفظ في الجهاز
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
تطبيق ملف التعريب
</string>
<!--notification-->
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
تم طلب محادثة سرية
</string>
<string
name=
"EncryptedChatRequested"
>
تم طلب محادثة سرية
</string>
...
...
TMessagesProj/src/main/res/values-de/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Deutsch
</string>
<string
name=
"LanguageName"
>
Deutsch
</string>
<string
name=
"LanguangeNameInEnglish"
>
German
</string>
<string
name=
"LanguageNameInEnglish"
>
German
</string>
<string
name=
"LanguageCode"
>
de
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
Dein Telefon
</string>
<string
name=
"YourPhone"
>
Dein Telefon
</string>
...
@@ -110,7 +111,7 @@
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Diese Gruppe löschen
</string>
<string
name=
"DeleteThisGroup"
>
Diese Gruppe löschen
</string>
<string
name=
"SlideToCancel"
>
WISCHEN UM ABZUBRECHEN
</string>
<string
name=
"SlideToCancel"
>
WISCHEN UM ABZUBRECHEN
</string>
<string
name=
"SaveToDownloads"
>
In Ordner Downloads speichern
</string>
<string
name=
"SaveToDownloads"
>
In Ordner Downloads speichern
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
Sprachdatei benutzen
</string>
<!--notification-->
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Geheimen Chat angefordert
</string>
<string
name=
"EncryptedChatRequested"
>
Geheimen Chat angefordert
</string>
...
...
TMessagesProj/src/main/res/values-es/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Español
</string>
<string
name=
"LanguageName"
>
Español
</string>
<string
name=
"LanguangeNameInEnglish"
>
Spanish
</string>
<string
name=
"LanguageNameInEnglish"
>
Spanish
</string>
<string
name=
"LanguageCode"
>
es
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
Tu teléfono
</string>
<string
name=
"YourPhone"
>
Tu teléfono
</string>
...
@@ -110,7 +111,7 @@
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Eliminar este grupo
</string>
<string
name=
"DeleteThisGroup"
>
Eliminar este grupo
</string>
<string
name=
"SlideToCancel"
>
DESLIZA PARA CANCELAR
</string>
<string
name=
"SlideToCancel"
>
DESLIZA PARA CANCELAR
</string>
<string
name=
"SaveToDownloads"
>
Guardar en descargas
</string>
<string
name=
"SaveToDownloads"
>
Guardar en descargas
</string>
<string
name=
"ApplyLocalizationFile"
>
Ap
ply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
Ap
licar fichero de localización
</string>
<!--notification-->
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Chat secreto solicitado
</string>
<string
name=
"EncryptedChatRequested"
>
Chat secreto solicitado
</string>
...
...
TMessagesProj/src/main/res/values-it/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Italiano
</string>
<string
name=
"LanguageName"
>
Italiano
</string>
<string
name=
"LanguangeNameInEnglish"
>
Italian
</string>
<string
name=
"LanguageNameInEnglish"
>
Italian
</string>
<string
name=
"LanguageCode"
>
it
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
Il tuo telefono
</string>
<string
name=
"YourPhone"
>
Il tuo telefono
</string>
...
@@ -110,7 +111,7 @@
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Elimina questo gruppo
</string>
<string
name=
"DeleteThisGroup"
>
Elimina questo gruppo
</string>
<string
name=
"SlideToCancel"
>
TRASCINA PER ANNULLARE
</string>
<string
name=
"SlideToCancel"
>
TRASCINA PER ANNULLARE
</string>
<string
name=
"SaveToDownloads"
>
Salva in download
</string>
<string
name=
"SaveToDownloads"
>
Salva in download
</string>
<string
name=
"ApplyLocalizationFile"
>
Appl
y localization fil
e
</string>
<string
name=
"ApplyLocalizationFile"
>
Appl
ica file di localizzazion
e
</string>
<!--notification-->
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Chat segreta richiesta
</string>
<string
name=
"EncryptedChatRequested"
>
Chat segreta richiesta
</string>
...
...
TMessagesProj/src/main/res/values-nl/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Nederlands
</string>
<string
name=
"LanguageName"
>
Nederlands
</string>
<string
name=
"LanguangeNameInEnglish"
>
Dutch
</string>
<string
name=
"LanguageNameInEnglish"
>
Dutch
</string>
<string
name=
"LanguageCode"
>
nl
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
Uw telefoon
</string>
<string
name=
"YourPhone"
>
Uw telefoon
</string>
...
@@ -110,7 +111,7 @@
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Deze groep verwijderen
</string>
<string
name=
"DeleteThisGroup"
>
Deze groep verwijderen
</string>
<string
name=
"SlideToCancel"
>
SLEEP OM TE ANNULEREN
</string>
<string
name=
"SlideToCancel"
>
SLEEP OM TE ANNULEREN
</string>
<string
name=
"SaveToDownloads"
>
Opslaan in downloads
</string>
<string
name=
"SaveToDownloads"
>
Opslaan in downloads
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
Vertaling toepassen
</string>
<!--notification-->
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Privégesprek aangevraagd
</string>
<string
name=
"EncryptedChatRequested"
>
Privégesprek aangevraagd
</string>
...
...
TMessagesProj/src/main/res/values/strings.xml
View file @
ebe7ab78
...
@@ -5,8 +5,9 @@
...
@@ -5,8 +5,9 @@
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
English
</string>
<string
name=
"LanguageName"
>
English
</string>
<string
name=
"LanguangeNameInEnglish"
>
English
</string>
<string
name=
"LanguageNameInEnglish"
>
English
</string>
<string
name=
"LanguageCode"
>
en
</string>
<!--signin view-->
<!--signin view-->
<string
name=
"YourPhone"
>
Your phone
</string>
<string
name=
"YourPhone"
>
Your phone
</string>
...
...
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