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
Hide 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
return
;
}
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
)
{
...
...
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 {
}
final
boolean
dontDelete
=
isLocalFile
;
if
((
exist
=
cacheFileFinal
.
exists
())
&&
!
ignoreCache
)
{
Utilities
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
...
...
@@ -403,7 +403,7 @@ public class FileLoadOperation {
final
boolean
renamed
=
cacheFileTemp
.
renameTo
(
cacheFileFinal
);
if
(
needBitmapCreate
)
{
Utilities
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
cacheOutQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
int
delay
=
20
;
...
...
@@ -520,7 +520,7 @@ public class FileLoadOperation {
int
readed
=
httpConnectionStream
.
read
(
data
);
if
(
readed
>
0
)
{
fileOutputStream
.
write
(
data
,
0
,
readed
);
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
FileLoader
.
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
startDownloadHTTPRequest
();
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
ebe7ab78
...
...
@@ -38,6 +38,9 @@ import java.util.concurrent.ConcurrentHashMap;
public
class
FileLoader
{
public
LruCache
memCache
;
public
static
volatile
DispatchQueue
cacheOutQueue
=
new
DispatchQueue
(
"cacheOutQueue"
);
public
static
volatile
DispatchQueue
fileLoaderQueue
=
new
DispatchQueue
(
"fileUploadQueue"
);
private
String
ignoreRemoval
=
null
;
private
ConcurrentHashMap
<
String
,
CacheImage
>
imageLoading
;
private
HashMap
<
Integer
,
CacheImage
>
imageLoadingByKeys
;
...
...
@@ -50,9 +53,11 @@ public class FileLoader {
private
int
currentUploadOperationsCount
=
0
;
private
Queue
<
FileLoadOperation
>
loadOperationQueue
;
private
Queue
<
FileLoadOperation
>
audioLoadOperationQueue
;
private
Queue
<
FileLoadOperation
>
photoLoadOperationQueue
;
private
ConcurrentHashMap
<
String
,
FileLoadOperation
>
loadOperationPaths
;
private
int
currentLoadOperationsCount
=
0
;
private
int
currentAudioLoadOperationsCount
=
0
;
private
int
currentPhotoLoadOperationsCount
=
0
;
public
static
long
lastCacheOutTime
=
0
;
public
ConcurrentHashMap
<
String
,
Float
>
fileProgresses
=
new
ConcurrentHashMap
<
String
,
Float
>();
private
long
lastProgressUpdateTime
=
0
;
...
...
@@ -108,21 +113,12 @@ public class FileLoader {
try
{
Class
cl
=
Class
.
forName
(
"dalvik.system.VMRuntime"
);
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
});
trackFree
=
cl
.
getMethod
(
"trackExternalFree"
,
new
Class
[]
{
long
.
class
});
success
=
true
;
}
catch
(
ClassNotFoundException
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
)
{
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(!
success
)
{
...
...
@@ -179,7 +175,7 @@ public class FileLoader {
}
}
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
synchronized
(
imageViewArray
)
{
...
...
@@ -316,10 +312,11 @@ public class FileLoader {
loadOperationPaths
=
new
ConcurrentHashMap
<
String
,
FileLoadOperation
>();
loadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
audioLoadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
photoLoadOperationQueue
=
new
LinkedList
<
FileLoadOperation
>();
}
public
void
cancelUploadFile
(
final
String
location
,
final
boolean
enc
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(!
enc
)
{
...
...
@@ -344,7 +341,7 @@ public class FileLoader {
}
public
void
uploadFile
(
final
String
location
,
final
byte
[]
key
,
final
byte
[]
iv
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
key
!=
null
)
{
...
...
@@ -365,7 +362,7 @@ public class FileLoader {
operation
.
delegate
=
new
FileUploadOperation
.
FileUploadOperationDelegate
()
{
@Override
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
public
void
run
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
...
...
@@ -394,7 +391,7 @@ public class FileLoader {
@Override
public
void
didFailedUploadingFile
(
final
FileUploadOperation
operation
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
...
...
@@ -454,7 +451,7 @@ public class FileLoader {
if
(
video
==
null
&&
photo
==
null
&&
document
==
null
&&
audio
==
null
)
{
return
;
}
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
String
fileName
=
null
;
...
...
@@ -474,6 +471,8 @@ public class FileLoader {
if
(
operation
!=
null
)
{
if
(
audio
!=
null
)
{
audioLoadOperationQueue
.
remove
(
operation
);
}
else
if
(
photo
!=
null
)
{
photoLoadOperationQueue
.
remove
(
operation
);
}
else
{
loadOperationQueue
.
remove
(
operation
);
}
...
...
@@ -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
)
{
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
String
fileName
=
null
;
...
...
@@ -540,7 +539,7 @@ public class FileLoader {
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg1
);
}
});
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
loadOperationPaths
.
remove
(
arg1
);
...
...
@@ -553,6 +552,15 @@ public class FileLoader {
operation
.
start
();
}
}
}
else
if
(
photo
!=
null
)
{
currentPhotoLoadOperationsCount
--;
if
(
currentPhotoLoadOperationsCount
<
2
)
{
FileLoadOperation
operation
=
photoLoadOperationQueue
.
poll
();
if
(
operation
!=
null
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
}
}
else
{
currentLoadOperationsCount
--;
if
(
currentLoadOperationsCount
<
2
)
{
...
...
@@ -579,7 +587,7 @@ public class FileLoader {
}
});
}
Utilities
.
fileUpload
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
loadOperationPaths
.
remove
(
arg1
);
...
...
@@ -592,6 +600,15 @@ public class FileLoader {
operation
.
start
();
}
}
}
else
if
(
photo
!=
null
)
{
currentPhotoLoadOperationsCount
--;
if
(
currentPhotoLoadOperationsCount
<
2
)
{
FileLoadOperation
operation
=
photoLoadOperationQueue
.
poll
();
if
(
operation
!=
null
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
}
}
else
{
currentLoadOperationsCount
--;
if
(
currentLoadOperationsCount
<
2
)
{
...
...
@@ -630,6 +647,13 @@ public class FileLoader {
}
else
{
audioLoadOperationQueue
.
add
(
operation
);
}
}
else
if
(
photo
!=
null
)
{
if
(
currentPhotoLoadOperationsCount
<
2
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
else
{
photoLoadOperationQueue
.
add
(
operation
);
}
}
else
{
if
(
currentLoadOperationsCount
<
2
)
{
currentLoadOperationsCount
++;
...
...
@@ -674,7 +698,7 @@ public class FileLoader {
if
(
imageView
==
null
)
{
return
;
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
Integer
TAG
=
getTag
(
imageView
);
...
...
@@ -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
)))
{
return
;
}
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
String
key
;
String
fileName
=
null
;
if
(
httpUrl
!=
null
)
{
key
=
Utilities
.
MD5
(
httpUrl
);
}
else
{
key
=
url
.
volume_id
+
"_"
+
url
.
local_id
;
fileName
=
key
+
".jpg"
;
}
if
(
filter
!=
null
)
{
key
+=
"@"
+
filter
;
...
...
@@ -832,6 +858,7 @@ public class FileLoader {
imageLoading
.
put
(
key
,
img
);
final
String
arg2
=
key
;
final
String
arg3
=
fileName
;
FileLoadOperation
loadOperation
;
if
(
httpUrl
!=
null
)
{
loadOperation
=
new
FileLoadOperation
(
httpUrl
);
...
...
@@ -843,30 +870,43 @@ public class FileLoader {
loadOperation
.
delegate
=
new
FileLoadOperation
.
FileLoadOperationDelegate
()
{
@Override
public
void
didFinishLoadingFile
(
final
FileLoadOperation
operation
)
{
enqueueImageProcessingOperationWithImage
(
operation
.
image
,
filter
,
arg2
,
img
);
if
(
operation
.
totalBytesCount
!=
0
)
{
final
String
arg1
=
operation
.
location
.
volume_id
+
"_"
+
operation
.
location
.
local_id
+
".jpg"
;
fileProgresses
.
remove
(
arg1
);
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileLoadProgressChanged
,
arg1
,
1.0f
);
fileProgresses
.
remove
(
arg3
);
}
fileLoaderQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
arg3
!=
null
)
{
loadOperationPaths
.
remove
(
arg3
);
}
});
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg1
);
for
(
Object
v
:
img
.
imageViewArray
)
{
imageLoadingByKeys
.
remove
(
getTag
(
v
));
}
});
}
checkOperationsAndClear
(
img
.
loadOperation
);
imageLoading
.
remove
(
arg2
);
}
});
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
img
.
callAndClear
(
operation
.
image
);
if
(
operation
.
image
!=
null
&&
memCache
.
get
(
arg2
)
==
null
)
{
memCache
.
put
(
arg2
,
operation
.
image
);
}
NotificationCenter
.
getInstance
().
postNotificationName
(
FileDidLoaded
,
arg3
);
}
});
}
@Override
public
void
didFailedLoadingFile
(
final
FileLoadOperation
operation
)
{
Utilities
.
imageLoad
Queue
.
postRunnable
(
new
Runnable
()
{
fileLoader
Queue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
arg3
!=
null
)
{
loadOperationPaths
.
remove
(
arg3
);
}
for
(
Object
view
:
img
.
imageViewArray
)
{
imageLoadingByKeys
.
remove
(
getTag
(
view
));
imageLoading
.
remove
(
arg2
);
...
...
@@ -921,6 +961,9 @@ public class FileLoader {
}
else
{
operationsQueue
.
add
(
loadOperation
);
}
if
(
fileName
!=
null
)
{
loadOperationPaths
.
put
(
fileName
,
loadOperation
);
}
}
}
});
...
...
@@ -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
)
{
BitmapFactory
.
Options
bmOptions
=
new
BitmapFactory
.
Options
();
bmOptions
.
inJustDecodeBounds
=
true
;
...
...
TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
View file @
ebe7ab78
...
...
@@ -12,9 +12,13 @@ import android.app.Activity;
import
android.content.SharedPreferences
;
import
android.content.res.Configuration
;
import
android.text.format.DateFormat
;
import
android.util.Xml
;
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.Calendar
;
import
java.util.Collections
;
...
...
@@ -66,42 +70,42 @@ public class LocaleController {
}
public
LocaleController
()
{
Locale
Controller
.
LocaleInfo
localeInfo
=
new
LocaleController
.
LocaleInfo
();
Locale
Info
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"English"
;
localeInfo
.
nameEnglish
=
"English"
;
localeInfo
.
shortName
=
"en"
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Italiano"
;
localeInfo
.
nameEnglish
=
"Italian"
;
localeInfo
.
shortName
=
"it"
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Español"
;
localeInfo
.
nameEnglish
=
"Spanish"
;
localeInfo
.
shortName
=
"es"
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Deutsch"
;
localeInfo
.
nameEnglish
=
"German"
;
localeInfo
.
shortName
=
"de"
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"Nederlands"
;
localeInfo
.
nameEnglish
=
"Dutch"
;
localeInfo
.
shortName
=
"nl"
;
sortedLanguages
.
add
(
localeInfo
);
languagesDict
.
put
(
localeInfo
.
shortName
,
localeInfo
);
localeInfo
=
new
Locale
Controller
.
Locale
Info
();
localeInfo
=
new
LocaleInfo
();
localeInfo
.
name
=
"العربية"
;
localeInfo
.
nameEnglish
=
"Arabic"
;
localeInfo
.
shortName
=
"ar"
;
...
...
@@ -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
)
{
if
(
localeInfo
==
null
)
{
return
;
...
...
@@ -196,7 +269,7 @@ public class LocaleController {
}
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
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
ebe7ab78
...
...
@@ -20,9 +20,12 @@ import android.media.audiofx.AutomaticGainControl;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.Vibrator
;
import
android.view.View
;
import
org.telegram.objects.MessageObject
;
import
org.telegram.ui.ApplicationLoader
;
import
org.telegram.ui.Cells.ChatMediaCell
;
import
org.telegram.ui.Views.GifDrawable
;
import
java.io.File
;
import
java.io.FileInputStream
;
...
...
@@ -54,6 +57,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public
void
onFailedDownload
(
String
fileName
);
public
void
onSuccessDownload
(
String
fileName
);
public
void
onProgressDownload
(
String
fileName
,
float
progress
);
public
void
onProgressUpload
(
String
fileName
,
float
progress
,
boolean
isEncrypted
);
public
int
getObserverTag
();
}
...
...
@@ -84,6 +88,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private
ArrayList
<
FileDownloadProgressListener
>
deleteLaterArray
=
new
ArrayList
<
FileDownloadProgressListener
>();
private
int
lastTag
=
0
;
private
GifDrawable
currentGifDrawable
;
private
MessageObject
currentGifMessageObject
;
private
ChatMediaCell
currentMediaCell
;
private
boolean
isPaused
=
false
;
private
MediaPlayer
audioPlayer
=
null
;
private
AudioTrack
audioTrackPlayer
=
null
;
...
...
@@ -226,6 +234,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidFailedLoad
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileDidLoaded
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileLoadProgressChanged
);
NotificationCenter
.
getInstance
().
addObserver
(
this
,
FileLoader
.
FileUploadProgressChanged
);
Timer
progressTimer
=
new
Timer
();
progressTimer
.
schedule
(
new
TimerTask
()
{
...
...
@@ -273,6 +282,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public
void
cleanup
()
{
clenupPlayer
(
false
);
if
(
currentGifDrawable
!=
null
)
{
currentGifDrawable
.
recycle
();
currentGifDrawable
=
null
;
}
currentMediaCell
=
null
;
currentGifMessageObject
=
null
;
}
public
int
generateObserverTag
()
{
...
...
@@ -377,6 +392,22 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
listenerInProgress
=
false
;
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
});
}
}
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
delayedMessage
.
type
=
2
;
delayedMessage
.
obj
=
newMsgObj
;
delayedMessage
.
documentLocation
=
document
;
delayedMessage
.
location
=
document
.
thumb
.
location
;
performSendDelayedMessage
(
delayedMessage
);
}
else
if
(
type
==
8
)
{
reqSend
.
media
=
new
TLRPC
.
TL_inputMediaUploadedAudio
();
...
...
@@ -1976,9 +1977,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
random
.
nextBytes
(
reqSend
.
media
.
iv
);
random
.
nextBytes
(
reqSend
.
media
.
key
);
reqSend
.
media
.
size
=
document
.
size
;
reqSend
.
media
.
thumb
=
new
byte
[
0
];
reqSend
.
media
.
thumb_h
=
0
;
reqSend
.
media
.
thumb_w
=
0
;
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_h
=
0
;
reqSend
.
media
.
thumb_w
=
0
;
}
reqSend
.
media
.
file_name
=
document
.
file_name
;
reqSend
.
media
.
mime_type
=
document
.
mime_type
;
...
...
@@ -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
))
{
String
fileName
=
size2
.
location
.
volume_id
+
"_"
+
size2
.
location
.
local_id
;
String
fileName2
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
;
if
(
fileName
.
equals
(
fileName2
))
{
return
;
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
;
}
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
.
attachPath
=
newMsg
.
attachPath
;
}
sentMessage
.
message
=
newMsg
.
message
;
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
)
{
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
.
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
)
{
...
...
@@ -2071,14 +2090,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
String
fileName
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
String
fileName2
=
sentMessage
.
media
.
audio
.
dc_id
+
"_"
+
sentMessage
.
media
.
audio
.
id
+
".m4a"
;
if
(
fileName
.
equals
(
fileName2
))
{
return
;
if
(!
fileName
.
equals
(
fileName2
))
{
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
newMsg
.
media
.
audio
.
dc_id
=
sentMessage
.
media
.
audio
.
dc_id
;
newMsg
.
media
.
audio
.
id
=
sentMessage
.
media
.
audio
.
id
;
}
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
newMsg
.
media
.
audio
.
dc_id
=
sentMessage
.
media
.
audio
.
dc_id
;
newMsg
.
media
.
audio
.
id
=
sentMessage
.
media
.
audio
.
id
;
}
}
else
if
(
file
!=
null
)
{
if
(
newMsg
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
&&
newMsg
.
media
.
photo
!=
null
)
{
...
...
@@ -2154,12 +2172,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
String
fileName
=
audio
.
dc_id
+
"_"
+
audio
.
id
+
".m4a"
;
String
fileName2
=
newMsg
.
media
.
audio
.
dc_id
+
"_"
+
newMsg
.
media
.
audio
.
id
+
".m4a"
;
if
(
fileName
.
equals
(
fileName2
))
{
return
;
if
(!
fileName
.
equals
(
fileName2
))
{
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
}
File
cacheFile
=
new
File
(
Utilities
.
getCacheDir
(),
fileName
);
File
cacheFile2
=
new
File
(
Utilities
.
getCacheDir
(),
fileName2
);
cacheFile
.
renameTo
(
cacheFile2
);
ArrayList
<
TLRPC
.
Message
>
arr
=
new
ArrayList
<
TLRPC
.
Message
>();
arr
.
add
(
newMsg
);
...
...
@@ -2429,12 +2446,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
}
}
else
if
(
message
.
type
==
2
)
{
String
location
=
message
.
documentLocation
.
path
;
putToDelayedMessages
(
location
,
message
)
;
if
(
message
.
sendRequest
!=
null
)
{
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
{
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
String
location
=
message
.
documentLocation
.
path
;
putToDelayedMessages
(
location
,
message
);
if
(
message
.
sendRequest
!=
null
)
{
FileLoader
.
getInstance
().
uploadFile
(
location
,
null
,
null
);
}
else
{
FileLoader
.
getInstance
().
uploadFile
(
location
,
message
.
sendEncryptedRequest
.
media
.
key
,
message
.
sendEncryptedRequest
.
media
.
iv
);
}
}
}
else
if
(
message
.
type
==
3
)
{
String
location
=
message
.
audioLocation
.
path
;
...
...
@@ -2545,8 +2568,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
}
}
else
if
(
message
.
type
==
2
)
{
message
.
sendRequest
.
media
.
file
=
file
;
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
if
(
message
.
sendRequest
.
media
.
thumb
==
null
&&
message
.
location
!=
null
)
{
message
.
sendRequest
.
media
.
thumb
=
file
;
performSendDelayedMessage
(
message
);
}
else
{
message
.
sendRequest
.
media
.
file
=
file
;
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
}
}
else
if
(
message
.
type
==
3
)
{
message
.
sendRequest
.
media
.
file
=
file
;
performSendMessageRequest
(
message
.
sendRequest
,
message
.
obj
);
...
...
@@ -4692,7 +4720,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage
.
media
.
geo
.
lat
=
decryptedMessage
.
media
.
lat
;
newMessage
.
media
.
geo
.
_long
=
decryptedMessage
.
media
.
_long
;
}
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
;
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaPhoto
();
...
...
@@ -4725,7 +4753,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
big
.
location
.
local_id
=
message
.
file
.
key_fingerprint
;
newMessage
.
media
.
photo
.
sizes
.
add
(
big
);
}
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
;
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaVideo
();
...
...
@@ -4754,7 +4782,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
newMessage
.
media
.
video
.
key
=
decryptedMessage
.
media
.
key
;
newMessage
.
media
.
video
.
iv
=
decryptedMessage
.
media
.
iv
;
}
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
;
}
newMessage
.
media
=
new
TLRPC
.
TL_messageMediaDocument
();
...
...
@@ -4781,7 +4809,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
newMessage
.
media
.
document
.
dc_id
=
message
.
file
.
dc_id
;
}
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
;
}
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 {
public
static
volatile
DispatchQueue
stageQueue
=
new
DispatchQueue
(
"stageQueue"
);
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
[]
arrUsersAvatars
=
{
...
...
TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java
View file @
ebe7ab78
...
...
@@ -35,6 +35,7 @@ public class MessageObject {
public
TLRPC
.
Message
messageOwner
;
public
CharSequence
messageText
;
public
int
type
;
public
int
contentType
;
public
ArrayList
<
PhotoObject
>
photoThumbs
;
public
Bitmap
imagePreview
;
public
PhotoObject
previewPhoto
;
...
...
@@ -244,6 +245,11 @@ public class MessageObject {
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
messageText
=
LocaleController
.
getString
(
"UnsuppotedMedia"
,
R
.
string
.
UnsuppotedMedia
);
}
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
);
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
messageText
=
LocaleController
.
getString
(
"AttachAudio"
,
R
.
string
.
AttachAudio
);
...
...
@@ -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
.
media
==
null
||
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
0
;
}
else
{
type
=
1
;
}
contentType
=
type
=
0
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
2
;
}
else
{
type
=
3
;
}
contentType
=
type
=
1
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaGeo
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
4
;
contentType
=
type
=
4
;
}
else
{
type
=
5
;
contentType
=
type
=
5
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
6
;
contentType
=
type
=
6
;
}
else
{
type
=
7
;
contentType
=
type
=
7
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaContact
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
12
;
contentType
=
type
=
12
;
}
else
{
type
=
13
;
contentType
=
type
=
13
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
0
;
}
else
{
type
=
1
;
}
contentType
=
type
=
0
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
16
;
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"
))
{
contentType
=
1
;
type
=
8
;
}
else
{
type
=
17
;
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
contentType
=
type
=
8
;
}
else
{
contentType
=
type
=
9
;
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
18
;
}
else
{
type
=
19
;
}
contentType
=
type
=
2
;
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
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
)
{
type
=
11
;
contentType
=
type
=
11
;
}
else
{
type
=
10
;
contentType
=
type
=
10
;
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageForwarded
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
type
=
8
;
}
else
{
type
=
9
;
}
contentType
=
type
=
0
;
}
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
private
TLRPC
.
FileLocation
currentPhoto
;
private
String
currentNameString
;
public
ChatAudioCell
(
Context
context
,
boolean
isChat
)
{
super
(
context
,
isChat
);
public
ChatAudioCell
(
Context
context
)
{
super
(
context
,
false
);
TAG
=
MediaController
.
getInstance
().
generateObserverTag
();
avatarImage
=
new
ImageReceiver
();
...
...
@@ -101,6 +101,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
avatarImage
.
clearImage
();
currentPhoto
=
null
;
}
MediaController
.
getInstance
().
removeLoadingFileObserver
(
this
);
}
@Override
...
...
@@ -230,7 +231,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
}
progressView
.
setProgress
(
0
);
}
else
{
MediaController
.
getInstance
().
addLoadingFileObserver
(
currentMessageObject
.
getFileName
()
,
this
);
MediaController
.
getInstance
().
addLoadingFileObserver
(
fileName
,
this
);
if
(!
FileLoader
.
getInstance
().
isLoadingFile
(
fileName
))
{
buttonState
=
2
;
progressView
.
setProgress
(
0
);
...
...
@@ -263,6 +264,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate
();
}
@Override
public
void
onProgressUpload
(
String
fileName
,
float
progress
,
boolean
isEncrypted
)
{
}
@Override
public
int
getObserverTag
()
{
return
TAG
;
...
...
@@ -281,7 +287,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
int
width
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
setMeasuredDimension
(
width
,
Utilities
.
dp
(
68
));
if
(
c
hat
)
{
if
(
isC
hat
)
{
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
102
),
Utilities
.
dp
(
300
));
}
else
{
backgroundWidth
=
Math
.
min
(
width
-
Utilities
.
dp
(
50
),
Utilities
.
dp
(
300
));
...
...
@@ -298,7 +304,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
buttonX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
67
);
timeX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
71
);
}
else
{
if
(
c
hat
)
{
if
(
isC
hat
)
{
avatarImage
.
imageX
=
Utilities
.
dp
(
69
);
seekBarX
=
Utilities
.
dp
(
158
);
buttonX
=
Utilities
.
dp
(
128
);
...
...
@@ -355,10 +361,10 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if
(
messageObject
.
messageOwner
.
out
)
{
seekBar
.
type
=
0
;
progressView
.
type
=
0
;
progressView
.
setProgressColors
(
0xffb4e396
,
0xff6ac453
)
;
}
else
{
seekBar
.
type
=
1
;
progressView
.
type
=
1
;
progressView
.
setProgressColors
(
0xffd9e2eb
,
0xff86c5f8
)
;
}
super
.
setMessageObject
(
messageObject
);
...
...
@@ -405,10 +411,4 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
timeLayout
.
draw
(
canvas
);
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 {
public
static
interface
ChatBaseCellDelegate
{
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
forwardName
=
false
;
protected
boolean
media
=
false
;
private
boolean
isCheckPressed
=
true
;
private
boolean
wasLayout
=
false
;
protected
boolean
isAvatarVisible
=
false
;
protected
MessageObject
currentMessageObject
;
private
static
Drawable
backgroundDrawableIn
;
private
static
Drawable
backgroundDrawableInSelected
;
private
static
Drawable
backgroundDrawableOut
;
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
halfCheckDrawable
;
private
static
Drawable
clockDrawable
;
private
static
Drawable
checkMediaDrawable
;
private
static
Drawable
halfCheckMediaDrawable
;
private
static
Drawable
clockMediaDrawable
;
private
static
Drawable
errorDrawable
;
protected
static
Drawable
mediaBackgroundDrawable
;
private
static
TextPaint
timePaintIn
;
private
static
TextPaint
timePaintOut
;
private
static
TextPaint
timeMediaPaint
;
private
static
TextPaint
namePaint
;
private
static
TextPaint
forwardNamePaint
;
...
...
@@ -95,23 +107,19 @@ public class ChatBaseCell extends BaseCell {
protected
int
namesOffset
=
0
;
public
ChatBaseCell
(
Context
context
,
boolean
is
Chat
)
{
public
ChatBaseCell
(
Context
context
,
boolean
is
Media
)
{
super
(
context
);
init
();
chat
=
isChat
;
if
(
chat
)
{
avatarImage
=
new
ImageReceiver
();
avatarImage
.
parentView
=
new
WeakReference
<
View
>(
this
);
}
media
=
isMedia
;
avatarImage
=
new
ImageReceiver
();
avatarImage
.
parentView
=
new
WeakReference
<
View
>(
this
);
}
@Override
protected
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
if
(
avatarImage
!=
null
)
{
avatarImage
.
clearImage
();
currentPhoto
=
null
;
}
avatarImage
.
clearImage
();
currentPhoto
=
null
;
}
private
void
init
()
{
...
...
@@ -120,10 +128,18 @@ public class ChatBaseCell extends BaseCell {
backgroundDrawableInSelected
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_in_selected
);
backgroundDrawableOut
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_out
);
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
);
halfCheckDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
msg_halfcheck
);
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
);
mediaBackgroundDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
phototime
);
timePaintIn
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
timePaintIn
.
setTextSize
(
Utilities
.
dp
(
12
));
...
...
@@ -133,11 +149,16 @@ public class ChatBaseCell extends BaseCell {
timePaintOut
.
setTextSize
(
Utilities
.
dp
(
12
));
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
.
setTextSize
(
Utilities
.
dp
(
15
));
forwardNamePaint
=
new
TextPaint
(
TextPaint
.
ANTI_ALIAS_FLAG
);
forwardNamePaint
.
setTextSize
(
Utilities
.
dp
(
14
));
}
}
...
...
@@ -160,7 +181,7 @@ public class ChatBaseCell extends BaseCell {
TLRPC
.
User
newUser
=
MessagesController
.
getInstance
().
users
.
get
(
currentMessageObject
.
messageOwner
.
from_id
);
TLRPC
.
FileLocation
newPhoto
=
null
;
if
(
avatarImage
!=
null
&&
newUser
!=
null
&&
newUser
.
photo
!=
null
)
{
if
(
isAvatarVisible
&&
newUser
!=
null
&&
newUser
.
photo
!=
null
)
{
newPhoto
=
newUser
.
photo
.
photo_small
;
}
...
...
@@ -169,7 +190,7 @@ public class ChatBaseCell extends BaseCell {
}
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
);
}
...
...
@@ -198,7 +219,8 @@ public class ChatBaseCell extends BaseCell {
}
currentUser
=
MessagesController
.
getInstance
().
users
.
get
(
messageObject
.
messageOwner
.
from_id
);
if
(
avatarImage
!=
null
)
{
if
(
isChat
&&
!
messageObject
.
messageOwner
.
out
)
{
isAvatarVisible
=
true
;
if
(
currentUser
!=
null
)
{
if
(
currentUser
.
photo
!=
null
)
{
currentPhoto
=
currentUser
.
photo
.
photo_small
;
...
...
@@ -209,10 +231,14 @@ public class ChatBaseCell extends BaseCell {
}
}
if
(
currentMessageObject
.
messageOwner
.
out
)
{
currentTimePaint
=
timePaintOut
;
if
(!
media
)
{
if
(
currentMessageObject
.
messageOwner
.
out
)
{
currentTimePaint
=
timePaintOut
;
}
else
{
currentTimePaint
=
timePaintIn
;
}
}
else
{
currentTimePaint
=
time
PaintIn
;
currentTimePaint
=
time
MediaPaint
;
}
currentTimeString
=
LocaleController
.
formatterDay
.
format
((
long
)
(
currentMessageObject
.
messageOwner
.
date
)
*
1000
);
...
...
@@ -220,7 +246,7 @@ public class ChatBaseCell extends BaseCell {
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
);
nameWidth
=
getMaxNameWidth
();
...
...
@@ -284,7 +310,7 @@ public class ChatBaseCell extends BaseCell {
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
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
;
result
=
true
;
}
else
if
(
drawForwardedName
&&
forwardedNameLayout
!=
null
)
{
...
...
@@ -303,7 +329,7 @@ public class ChatBaseCell extends BaseCell {
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
avatarPressed
=
false
;
}
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
;
}
}
...
...
@@ -338,13 +364,21 @@ public class ChatBaseCell extends BaseCell {
layoutHeight
=
getMeasuredHeight
();
timeLayout
=
new
StaticLayout
(
currentTimeString
,
currentTimePaint
,
timeWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
if
(!
currentMessageObject
.
messageOwner
.
out
)
{
timeX
=
backgroundWidth
-
Utilities
.
dp
(
9
)
-
timeWidth
+
(
chat
?
Utilities
.
dp
(
52
)
:
0
);
if
(!
media
)
{
if
(!
currentMessageObject
.
messageOwner
.
out
)
{
timeX
=
backgroundWidth
-
Utilities
.
dp
(
9
)
-
timeWidth
+
(
isChat
?
Utilities
.
dp
(
52
)
:
0
);
}
else
{
timeX
=
layoutWidth
-
timeWidth
-
Utilities
.
dpf
(
38.5f
);
}
}
else
{
timeX
=
layoutWidth
-
timeWidth
-
Utilities
.
dpf
(
38.5f
);
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
.
imageY
=
layoutHeight
-
Utilities
.
dp
(
45
);
avatarImage
.
imageW
=
Utilities
.
dp
(
42
);
...
...
@@ -355,6 +389,11 @@ public class ChatBaseCell extends BaseCell {
}
}
protected
void
onAfterBackgroundDraw
(
Canvas
canvas
)
{
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
if
(
currentMessageObject
==
null
)
{
...
...
@@ -366,32 +405,50 @@ public class ChatBaseCell extends BaseCell {
return
;
}
if
(
avatarImage
!=
null
)
{
if
(
isAvatarVisible
)
{
avatarImage
.
draw
(
canvas
,
Utilities
.
dp
(
6
),
layoutHeight
-
Utilities
.
dp
(
45
),
Utilities
.
dp
(
42
),
Utilities
.
dp
(
42
));
}
Drawable
currentBackgroundDrawable
=
null
;
if
(
currentMessageObject
.
messageOwner
.
out
)
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
currentBackgroundDrawable
=
backgroundDrawableOutSelected
;
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableOutSelected
;
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableOutSelected
;
}
}
else
{
currentBackgroundDrawable
=
backgroundDrawableOut
;
if
(!
media
)
{
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
{
if
(
isPressed
()
&&
isCheckPressed
||
!
isCheckPressed
&&
isPressed
)
{
currentBackgroundDrawable
=
backgroundDrawableInSelected
;
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableInSelected
;
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableInSelected
;
}
}
else
{
currentBackgroundDrawable
=
backgroundDrawableIn
;
if
(!
media
)
{
currentBackgroundDrawable
=
backgroundDrawableIn
;
}
else
{
currentBackgroundDrawable
=
backgroundMediaDrawableIn
;
}
}
if
(
c
hat
)
{
setDrawableBounds
(
currentBackgroundDrawable
,
Utilities
.
dp
(
52
),
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
if
(
isC
hat
)
{
setDrawableBounds
(
currentBackgroundDrawable
,
Utilities
.
dp
(
52
+
(!
media
?
0
:
9
)
),
Utilities
.
dp
(
1
),
backgroundWidth
,
layoutHeight
-
Utilities
.
dp
(
2
));
}
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
);
onAfterBackgroundDraw
(
canvas
);
if
(
drawName
&&
nameLayout
!=
null
)
{
canvas
.
save
();
canvas
.
translate
(
currentBackgroundDrawable
.
getBounds
().
left
+
Utilities
.
dp
(
19
)
-
nameOffsetX
,
Utilities
.
dp
(
10
));
...
...
@@ -416,10 +473,20 @@ public class ChatBaseCell extends BaseCell {
canvas
.
restore
();
}
canvas
.
save
();
canvas
.
translate
(
timeX
,
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
timeLayout
.
getHeight
());
timeLayout
.
draw
(
canvas
);
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
.
translate
(
timeX
,
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
timeLayout
.
getHeight
());
timeLayout
.
draw
(
canvas
);
canvas
.
restore
();
}
if
(
currentMessageObject
.
messageOwner
.
out
)
{
boolean
drawCheck1
=
false
;
...
...
@@ -450,24 +517,48 @@ public class ChatBaseCell extends BaseCell {
}
if
(
drawClock
)
{
setDrawableBounds
(
clockDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
clockDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
clockDrawable
.
getIntrinsicHeight
());
clockDrawable
.
draw
(
canvas
);
if
(!
media
)
{
setDrawableBounds
(
clockDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
clockDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
clockDrawable
.
getIntrinsicHeight
());
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
(
drawCheck1
)
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
if
(!
media
)
{
if
(
drawCheck1
)
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
22.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
}
else
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
}
checkDrawable
.
draw
(
canvas
);
}
else
{
setDrawableBounds
(
checkDrawable
,
layoutWidth
-
Utilities
.
dpf
(
18.5f
)
-
checkDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
checkDrawable
.
getIntrinsicHeight
());
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
);
}
checkDrawable
.
draw
(
canvas
);
}
if
(
drawCheck1
)
{
setDrawableBounds
(
halfCheckDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
halfCheckDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
halfCheckDrawable
.
getIntrinsicHeight
());
halfCheckDrawable
.
draw
(
canvas
);
if
(!
media
)
{
setDrawableBounds
(
halfCheckDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
halfCheckDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
8.5f
)
-
halfCheckDrawable
.
getIntrinsicHeight
());
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
)
{
setDrawableBounds
(
errorDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
errorDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
errorDrawable
.
getIntrinsicHeight
());
errorDrawable
.
draw
(
canvas
);
if
(!
media
)
{
setDrawableBounds
(
errorDrawable
,
layoutWidth
-
Utilities
.
dp
(
18
)
-
errorDrawable
.
getIntrinsicWidth
(),
layoutHeight
-
Utilities
.
dpf
(
6.5f
)
-
errorDrawable
.
getIntrinsicHeight
());
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 {
private
int
firstVisibleBlockNum
=
0
;
private
int
totalVisibleBlocksCount
=
0
;
public
ChatMessageCell
(
Context
context
,
boolean
isChat
)
{
super
(
context
,
isChat
);
public
ChatMessageCell
(
Context
context
)
{
super
(
context
,
false
);
drawForwardedName
=
true
;
}
...
...
@@ -131,7 +131,7 @@ public class ChatMessageCell extends ChatBaseCell {
}
pressedLink
=
null
;
int
maxWidth
;
if
(
c
hat
)
{
if
(
isC
hat
)
{
maxWidth
=
Utilities
.
displaySize
.
x
-
Utilities
.
dp
(
122
);
drawName
=
true
;
}
else
{
...
...
@@ -180,7 +180,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
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
;
}
}
...
...
@@ -196,7 +196,7 @@ public class ChatMessageCell extends ChatBaseCell {
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
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
;
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
ebe7ab78
...
...
@@ -88,10 +88,12 @@ import org.telegram.messenger.UserConfig;
import
org.telegram.messenger.Utilities
;
import
org.telegram.ui.Cells.ChatAudioCell
;
import
org.telegram.ui.Cells.ChatBaseCell
;
import
org.telegram.ui.Cells.ChatMediaCell
;
import
org.telegram.ui.Cells.ChatMessageCell
;
import
org.telegram.ui.Views.BackupImageView
;
import
org.telegram.ui.Views.BaseFragment
;
import
org.telegram.ui.Views.EmojiView
;
import
org.telegram.ui.Views.GifDrawable
;
import
org.telegram.ui.Views.LayoutListView
;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.OnSwipeTouchListener
;
...
...
@@ -1225,9 +1227,29 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
1
;
}
else
{
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
)
{
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
messageObject
.
getFileName
());
if
(
f
.
exists
())
{
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
());
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
;
}
}
...
...
@@ -1249,12 +1271,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
1
;
}
else
{
if
(!(
messageObject
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
))
{
/*if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
File f = new File(Utilities.getCacheDir(), messageObject.getFileName());
if (f.exists()) {
return 4;
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
());
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
2
;
}
else
{
return
3
;
...
...
@@ -1266,12 +1308,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
void
addToSelectedMessages
(
MessageObject
messageObject
)
{
if
(
selectedMessagesIds
.
containsKey
(
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
);
}
}
else
{
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
);
}
}
...
...
@@ -1576,8 +1618,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
ext
=
documentFilePath
.
substring
(
idx
);
}
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
document
.
id
=
0
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
...
...
@@ -1596,6 +1636,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
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
);
}
...
...
@@ -1707,7 +1768,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
dateObj
.
type
=
10
;
if
(
forwardLoad
)
{
messages
.
add
(
0
,
dateObj
);
}
else
{
...
...
@@ -1730,7 +1791,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
""
;
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
15
;
dateObj
.
contentType
=
dateObj
.
type
=
15
;
boolean
dateAdded
=
true
;
if
(
a
!=
messArr
.
size
()
-
1
)
{
MessageObject
next
=
messArr
.
get
(
a
+
1
);
...
...
@@ -1985,7 +2046,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
dateMsg
.
message
=
LocaleController
.
formatDateChat
(
obj
.
messageOwner
.
date
);
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
dateObj
.
type
=
10
;
messages
.
add
(
0
,
dateObj
);
}
if
(!
obj
.
messageOwner
.
out
&&
obj
.
messageOwner
.
unread
)
{
...
...
@@ -2864,6 +2925,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
type
==
4
)
{
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
)};
}
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
{
if
(
type
==
0
)
{
...
...
@@ -2877,6 +2940,8 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
type
==
4
)
{
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
)};
}
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
String
fileName
=
selectedObject
.
getFileName
();
if
(
selectedObject
.
type
==
6
||
selectedObject
.
type
==
7
)
{
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
);
}
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
);
}
}
else
if
(
i
==
1
)
{
...
...
@@ -2940,6 +3005,47 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
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
private
void
processSelectedOption
(
int
option
)
{
if
(
option
==
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
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
}
else
{
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
)
{
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
)
{
MessagesController
.
getInstance
().
sendMessage
(
selectedObject
,
dialog_id
);
}
else
{
...
...
@@ -2994,11 +3098,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
selectedObject
.
type
==
12
||
selectedObject
.
type
==
13
)
{
TLRPC
.
User
user
=
MessagesController
.
getInstance
().
users
.
get
(
selectedObject
.
messageOwner
.
media
.
user_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
;
document
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
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
;
audio
.
path
=
selectedObject
.
messageOwner
.
attachPath
;
MessagesController
.
getInstance
().
sendMessage
(
audio
,
dialog_id
);
...
...
@@ -3064,8 +3168,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
,
String
name
,
String
ext
,
long
size
)
{
activity
.
finishFragment
();
TLRPC
.
TL_document
document
=
new
TLRPC
.
TL_document
();
document
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
document
.
thumb
.
type
=
"s"
;
document
.
id
=
0
;
document
.
user_id
=
UserConfig
.
clientUserId
;
document
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
...
...
@@ -3084,6 +3186,27 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
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
);
}
...
...
@@ -3322,9 +3445,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
void
updateRowBackground
(
ChatListRowHolderEx
holder
,
boolean
disableSelection
,
boolean
selected
)
{
int
messageType
=
holder
.
message
.
type
;
if
(!
disableSelection
)
{
if
(
messageType
==
2
||
messageType
==
4
||
messageType
==
6
)
{
if
(
messageType
==
4
||
messageType
==
6
)
{
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
);
}
else
if
(
messageType
==
12
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
...
...
@@ -3332,21 +3455,21 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
messageType
==
13
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
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
.
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
.
setPadding
(
Utilities
.
dp
(
18
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
0
);
}
}
else
{
if
(
messageType
==
2
||
messageType
==
4
||
messageType
==
6
)
{
if
(
messageType
==
4
||
messageType
==
6
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo_selected
);
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_photo
);
}
}
else
if
(
messageType
==
3
||
messageType
==
5
||
messageType
==
7
)
{
}
else
if
(
messageType
==
5
||
messageType
==
7
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_photo_selected
);
}
else
{
...
...
@@ -3366,14 +3489,14 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in
);
}
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
15
),
Utilities
.
dp
(
6
),
Utilities
.
dp
(
9
),
0
);
}
else
if
(
messageType
==
16
)
{
}
else
if
(
messageType
==
8
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_selected
);
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out
);
}
holder
.
chatBubbleView
.
setPadding
(
Utilities
.
dp
(
9
),
Utilities
.
dp
(
9
),
Utilities
.
dp
(
18
),
0
);
}
else
if
(
messageType
==
17
)
{
}
else
if
(
messageType
==
9
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_selected
);
}
else
{
...
...
@@ -3453,17 +3576,11 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
int
type
=
message
.
t
ype
;
int
type
=
message
.
contentT
ype
;
if
(
view
==
null
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
if
(
type
==
0
)
{
view
=
new
ChatMessageCell
(
mContext
,
false
);
}
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
);
view
=
new
ChatMessageCell
(
mContext
);
}
else
if
(
type
==
4
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_location_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
5
)
{
...
...
@@ -3472,14 +3589,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_location_layout
,
viewGroup
,
false
);
}
}
else
if
(
type
==
2
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_photo_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
3
)
{
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
==
1
)
{
view
=
new
ChatMediaCell
(
mContext
);
((
ChatMediaCell
)
view
).
downloadPhotos
=
downloadPhotos
;
}
else
if
(
type
==
6
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_video_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
7
)
{
...
...
@@ -3502,36 +3614,19 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
else
if
(
type
==
15
)
{
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
);
}
else
if
(
type
==
17
)
{
}
else
if
(
type
==
9
)
{
if
(
currentChat
!=
null
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_group_incoming_document_layout
,
viewGroup
,
false
);
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_document_layout
,
viewGroup
,
false
);
}
}
else
if
(
type
==
18
)
{
view
=
new
ChatAudioCell
(
mContext
,
false
);
}
else
if
(
type
==
19
)
{
view
=
new
ChatAudioCell
(
mContext
,
currentChat
!=
null
);
}
else
if
(
type
==
2
)
{
view
=
new
ChatAudioCell
(
mContext
);
}
}
if
(
view
instanceof
ChatBaseCell
)
{
((
ChatBaseCell
)
view
).
delegate
=
new
ChatBaseCell
.
ChatBaseCellDelegate
()
{
@Override
public
void
didPressedUserAvatar
(
ChatBaseCell
cell
,
TLRPC
.
User
user
)
{
if
(
user
!=
null
&&
user
.
id
!=
UserConfig
.
clientUserId
)
{
UserProfileActivity
fragment
=
new
UserProfileActivity
();
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
user
.
id
);
fragment
.
setArguments
(
args
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"user_"
+
user
.
id
,
false
);
}
}
};
}
boolean
selected
=
false
;
boolean
disableSelection
=
false
;
if
(
mActionMode
!=
null
)
{
...
...
@@ -3547,15 +3642,49 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
if
(
view
instanceof
ChatBaseCell
)
{
((
ChatBaseCell
)
view
).
delegate
=
new
ChatBaseCell
.
ChatBaseCellDelegate
()
{
@Override
public
void
didPressedUserAvatar
(
ChatBaseCell
cell
,
TLRPC
.
User
user
)
{
if
(
user
!=
null
&&
user
.
id
!=
UserConfig
.
clientUserId
)
{
UserProfileActivity
fragment
=
new
UserProfileActivity
();
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
user
.
id
);
fragment
.
setArguments
(
args
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"user_"
+
user
.
id
,
false
);
}
}
@Override
public
void
didPressedCanceSendButton
(
ChatBaseCell
cell
)
{
MessageObject
message
=
cell
.
getMessageObject
();
if
(
message
.
messageOwner
.
send_state
!=
0
)
{
MessagesController
.
getInstance
().
cancelSendingMessage
(
message
);
}
}
};
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
);
}
};
}
((
ChatBaseCell
)
view
).
isChat
=
currentChat
!=
null
;
((
ChatBaseCell
)
view
).
setMessageObject
(
message
);
((
ChatBaseCell
)
view
).
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
if
(
view
instanceof
ChatAudioCell
&&
downloadAudios
)
{
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
}
else
if
(
view
instanceof
ChatMediaCell
)
{
((
ChatMediaCell
)
view
).
downloadPhotos
=
downloadPhotos
;
}
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
view
.
getTag
();
if
(
holder
==
null
)
{
holder
=
new
ChatListRowHolderEx
(
view
,
type
);
holder
=
new
ChatListRowHolderEx
(
view
,
message
.
type
);
view
.
setTag
(
holder
);
}
holder
.
message
=
message
;
...
...
@@ -3579,12 +3708,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return
14
;
}
MessageObject
message
=
messages
.
get
(
messages
.
size
()
-
i
-
offset
);
return
message
.
t
ype
;
return
message
.
contentT
ype
;
}
@Override
public
int
getViewTypeCount
()
{
return
20
;
return
16
;
}
@Override
...
...
@@ -3620,7 +3749,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
public
ImageView
addContactButton
;
public
View
addContactView
;
public
View
chatBubbleView
;
public
View
photoProgressView
;
public
ProgressBar
actionProgress
;
public
View
actionView
;
...
...
@@ -3649,12 +3777,12 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
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
.
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
height
=
width
+
Utilities
.
dp
(
100
);
if
(
type
==
6
||
type
==
7
)
{
...
...
@@ -3669,11 +3797,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
message
.
photoThumbs
,
width
,
height
);
if
(
type
==
3
)
{
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
}
if
(
photo
!=
null
)
{
float
scale
=
(
float
)
photo
.
photoOwner
.
w
/
(
float
)
width
;
...
...
@@ -3706,17 +3829,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
photo
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
photo
.
image
);
}
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
(
message
.
imagePreview
!=
null
)
{
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
}
else
{
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
;
if
(
document
instanceof
TLRPC
.
TL_document
||
document
instanceof
TLRPC
.
TL_documentEncrypted
)
{
nameTextView
.
setText
(
message
.
messageOwner
.
media
.
document
.
file_name
);
...
...
@@ -3844,7 +3956,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
if
(
document
.
thumb
instanceof
TLRPC
.
TL_photoCachedSize
)
{
}
else
{
if
(
type
==
16
)
{
if
(
type
==
8
)
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
}
else
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
...
...
@@ -3853,7 +3965,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
nameTextView
.
setText
(
"Error"
);
phoneTextView
.
setText
(
"Error"
);
if
(
type
==
16
)
{
if
(
type
==
8
)
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_green
);
}
else
{
contactAvatar
.
setImageResource
(
R
.
drawable
.
doc_blue
);
...
...
@@ -3871,19 +3983,16 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
halfCheckImage
!=
null
)
{
if
(
message
.
messageOwner
.
send_state
==
MessagesController
.
MESSAGE_SEND_STATE_SENDING
)
{
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
if
(
type
==
2
||
type
==
6
||
type
==
4
)
{
if
(
type
==
6
||
type
==
4
)
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock_photo
);
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock
);
}
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
if
(
actionView
!=
null
||
photoProgressView
!=
null
)
{
if
(
actionView
!=
null
)
{
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
VISIBLE
);
}
Float
progress
=
FileLoader
.
getInstance
().
fileProgresses
.
get
(
message
.
messageOwner
.
attachPath
);
if
(
progress
!=
null
)
{
actionProgress
.
setProgress
((
int
)(
progress
*
100
));
...
...
@@ -3905,9 +4014,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
GONE
);
}
...
...
@@ -3915,7 +4021,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(!
message
.
messageOwner
.
unread
)
{
halfCheckImage
.
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
);
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck
);
...
...
@@ -3923,7 +4029,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
else
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
if
(
type
==
2
||
type
==
6
||
type
==
4
)
{
if
(
type
==
6
||
type
==
4
)
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check_w
);
}
else
{
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check
);
...
...
@@ -3932,16 +4038,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
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
();
String
file
=
progressByTag
.
get
(
tag
);
if
(
file
!=
null
)
{
...
...
@@ -3965,37 +4068,31 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
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
));
}
}
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
}
else
{
load
=
true
;
}
}
if
(
load
&&
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
||
!
load
&&
(
message
.
messageOwner
.
attachPath
==
null
||
message
.
messageOwner
.
attachPath
.
length
()
==
0
))
{
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
)
{
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
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
));
}
}
if
(
actionView
!=
null
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
}
load
=
false
;
}
else
{
load
=
true
;
...
...
@@ -4012,47 +4109,32 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
progressByTag
.
put
((
Integer
)
actionProgress
.
getTag
(),
fileName
);
addToLoadingFile
(
fileName
,
actionProgress
);
if
(
actionView
!=
null
)
{
if
((
message
.
type
==
2
||
message
.
type
==
3
)
&&
downloadPhotos
)
{
actionView
.
setVisibility
(
View
.
GONE
);
}
else
{
actionView
.
setVisibility
(
View
.
VISIBLE
);
if
(
photoFileName
!=
null
)
{
actionCancelButton
.
setImageResource
(
R
.
drawable
.
photo_download_cancel_states
);
}
actionView
.
setVisibility
(
View
.
VISIBLE
);
if
(
photoFileName
!=
null
)
{
actionCancelButton
.
setImageResource
(
R
.
drawable
.
photo_download_cancel_states
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
GONE
);
}
}
else
{
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
);
}
}
if
(
photoProgressView
!=
null
)
{
photoProgressView
.
setVisibility
(
View
.
GONE
);
actionView
.
setVisibility
(
View
.
GONE
);
}
if
(
actionAttachButton
!=
null
)
{
actionAttachButton
.
setVisibility
(
View
.
VISIBLE
);
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
));
}
else
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
}
else
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
actionAttachButton
.
setText
(
LocaleController
.
getString
(
"DOWNLOAD"
,
R
.
string
.
DOWNLOAD
));
}
}
}
}
}
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
int
width
;
if
(
currentChat
!=
null
&&
type
!=
16
)
{
if
(
currentChat
!=
null
&&
type
!=
8
)
{
if
(
actionView
.
getVisibility
()
==
View
.
VISIBLE
)
{
width
=
displaySize
.
x
-
Utilities
.
dp
(
290
);
}
else
{
...
...
@@ -4091,7 +4173,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
addContactButton
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
add_contact_button
);
addContactView
=
view
.
findViewById
(
R
.
id
.
add_contact_view
);
chatBubbleView
=
view
.
findViewById
(
R
.
id
.
chat_bubble_layout
);
photoProgressView
=
view
.
findViewById
(
R
.
id
.
photo_progress
);
if
(
messageTextView
!=
null
)
{
messageTextView
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
MessagesController
.
getInstance
().
fontSize
);
}
...
...
@@ -4149,7 +4230,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
contactView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
message
.
type
==
16
||
message
.
type
==
17
)
{
if
(
message
.
type
==
8
||
message
.
type
==
9
)
{
processOnClick
(
view
);
}
else
if
(
message
.
type
==
12
||
message
.
type
==
13
)
{
if
(
mActionMode
!=
null
)
{
...
...
@@ -4230,15 +4311,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
contactAvatar
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
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
if
(
file
!=
null
)
{
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
);
if
(
file
!=
null
)
{
loadingFile
.
remove
(
file
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
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
);
}
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
NotificationCenter
.
getInstance
().
addToMemCache
(
0
,
message
);
LocationActivity
fragment
=
new
LocationActivity
();
((
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
)
{
NotificationCenter
.
getInstance
().
addToMemCache
(
51
,
message
);
Intent
intent
=
new
Intent
(
parentActivity
,
GalleryImageViewer
.
class
);
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
;
String
fileName
=
message
.
getFileName
();
if
(
message
.
messageOwner
.
attachPath
!=
null
&&
message
.
messageOwner
.
attachPath
.
length
()
!=
0
)
{
...
...
@@ -4400,7 +4443,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
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
();
int
idx
=
fileName
.
lastIndexOf
(
"."
);
if
(
idx
!=
-
1
)
{
...
...
@@ -4435,7 +4478,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
addToLoadingFile
(
fileName
,
actionProgress
);
if
(
message
.
type
==
6
||
message
.
type
==
7
)
{
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
);
}
updateVisibleRows
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
View file @
ebe7ab78
...
...
@@ -409,7 +409,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
listView
.
invalidateViews
();
}
}
else
if
(
i
==
languageRow
)
{
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
LanguageSelectActivity
(),
"settings_
wallpapers
"
,
false
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
LanguageSelectActivity
(),
"settings_
lang
"
,
false
);
}
else
if
(
i
==
switchBackendButtonRow
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
parentActivity
);
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.
package
org
.
telegram
.
ui
.
Views
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.ColorFilter
;
import
android.graphics.Paint
;
...
...
@@ -33,9 +34,11 @@ import android.graphics.drawable.Animatable;
import
android.graphics.drawable.Drawable
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.view.View
;
import
android.widget.MediaController
;
import
java.io.File
;
import
java.lang.ref.WeakReference
;
import
java.util.Locale
;
public
class
GifDrawable
extends
Drawable
implements
Animatable
,
MediaController
.
MediaPlayerControl
{
...
...
@@ -68,6 +71,8 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
private
boolean
mApplyTransformation
;
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
int
[]
mColors
;
...
...
@@ -82,7 +87,10 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public
void
run
()
{
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
private
final
Runnable
mInvalidateTask
=
new
Runnable
()
{
@Override
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
}
public
GifDrawable
(
String
filePath
)
throws
Exception
{
if
(
filePath
==
null
)
{
throw
new
NullPointerException
(
"Source is null"
);
}
mInputSourceLength
=
new
File
(
filePath
).
length
();
mGifInfoPtr
=
openFile
(
mMetaData
,
filePath
);
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
}
public
GifDrawable
(
File
file
)
throws
Exception
{
if
(
file
==
null
)
{
throw
new
NullPointerException
(
"Source is null"
);
}
mInputSourceLength
=
file
.
length
();
mGifInfoPtr
=
openFile
(
mMetaData
,
file
.
getPath
());
mColors
=
new
int
[
mMetaData
[
0
]
*
mMetaData
[
1
]];
...
...
@@ -169,6 +173,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public
void
start
()
{
if
(
mIsRunning
)
{
return
;
}
mIsRunning
=
true
;
runOnUiThread
(
mStartTask
);
}
...
...
@@ -240,7 +247,9 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public
void
run
()
{
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
@Override
public
void
run
()
{
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
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
protected
void
onBoundsChange
(
Rect
bounds
)
{
super
.
onBoundsChange
(
bounds
);
...
...
@@ -343,6 +359,7 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
}
else
{
mMetaData
[
4
]
=
-
1
;
}
canvas
.
translate
(
mDstRect
.
left
,
mDstRect
.
top
);
canvas
.
scale
(
mSx
,
mSy
);
canvas
.
drawBitmap
(
mColors
,
0
,
mMetaData
[
0
],
0
f
,
0
f
,
mMetaData
[
0
],
mMetaData
[
1
],
true
,
mPaint
);
if
(
mMetaData
[
4
]
>=
0
&&
mMetaData
[
2
]
>
1
)
{
...
...
@@ -365,13 +382,17 @@ public class GifDrawable extends Drawable implements Animatable, MediaController
@Override
public
void
setFilterBitmap
(
boolean
filter
)
{
mPaint
.
setFilterBitmap
(
filter
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
@Override
public
void
setDither
(
boolean
dither
)
{
mPaint
.
setDither
(
dither
);
invalidateSelf
();
if
(
parentView
!=
null
&&
parentView
.
get
()
!=
null
)
{
parentView
.
get
().
invalidate
();
}
}
@Override
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ImageReceiver.java
View file @
ebe7ab78
...
...
@@ -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
()
{
recycleBitmap
(
null
);
}
@Override
protected
void
finalize
()
throws
Throwable
{
try
{
clearImage
();
}
finally
{
super
.
finalize
();
}
}
private
void
recycleBitmap
(
Bitmap
newBitmap
)
{
if
(
currentImage
==
null
||
isPlaceholder
)
{
return
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ProgressView.java
View file @
ebe7ab78
...
...
@@ -14,50 +14,35 @@ import android.graphics.Paint;
import
org.telegram.messenger.Utilities
;
public
class
ProgressView
{
private
static
Paint
innerPaint1
;
private
static
Paint
outerPaint1
;
private
static
Paint
innerPaint2
;
private
static
Paint
outerPaint2
;
private
Paint
innerPaint
;
private
Paint
outerPaint
;
public
int
type
;
public
int
thumbX
=
0
;
public
float
currentProgress
=
0
;
public
int
width
;
public
int
height
;
public
float
progressHeight
=
Utilities
.
dpf
(
2.0f
);
public
ProgressView
()
{
if
(
innerPaint1
==
null
)
{
innerPaint1
=
new
Paint
();
outerPaint1
=
new
Paint
();
innerPaint2
=
new
Paint
();
outerPaint2
=
new
Paint
();
innerPaint1
.
setColor
(
0xffb4e396
);
outerPaint1
.
setColor
(
0xff6ac453
);
innerPaint2
.
setColor
(
0xffd9e2eb
);
outerPaint2
.
setColor
(
0xff86c5f8
);
}
innerPaint
=
new
Paint
();
outerPaint
=
new
Paint
();
}
public
void
setProgressColors
(
int
innerColor
,
int
outerColor
)
{
innerPaint
.
setColor
(
innerColor
);
outerPaint
.
setColor
(
outerColor
);
}
public
void
setProgress
(
float
progress
)
{
thumbX
=
(
int
)
Math
.
ceil
(
width
*
progress
)
;
if
(
thumbX
<
0
)
{
thumbX
=
0
;
}
else
if
(
thumbX
>
width
)
{
thumbX
=
width
;
currentProgress
=
progress
;
if
(
currentProgress
<
0
)
{
currentProgress
=
0
;
}
else
if
(
currentProgress
>
1
)
{
currentProgress
=
1
;
}
}
public
void
draw
(
Canvas
canvas
)
{
Paint
inner
=
null
;
Paint
outer
=
null
;
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
);
canvas
.
drawRect
(
0
,
height
/
2
-
progressHeight
/
2.0f
,
width
,
height
/
2
+
progressHeight
/
2.0f
,
innerPaint
);
canvas
.
drawRect
(
0
,
height
/
2
-
progressHeight
/
2.0f
,
width
*
currentProgress
,
height
/
2
+
progressHeight
/
2.0f
,
outerPaint
);
}
}
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 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
العربية
</string>
<string
name=
"LanguangeNameInEnglish"
>
Arabic
</string>
<string
name=
"LanguageName"
>
العربية
</string>
<string
name=
"LanguageNameInEnglish"
>
Arabic
</string>
<string
name=
"LanguageCode"
>
ar
</string>
<!--signin view-->
<string
name=
"YourPhone"
>
رقم هاتفك المحمول
</string>
...
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
حذف المجموعة
</string>
<string
name=
"SlideToCancel"
>
قم بالسحب للإلغاء
</string>
<string
name=
"SaveToDownloads"
>
حفظ في الجهاز
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
تطبيق ملف التعريب
</string>
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
تم طلب محادثة سرية
</string>
...
...
TMessagesProj/src/main/res/values-de/strings.xml
View file @
ebe7ab78
...
...
@@ -5,8 +5,9 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Deutsch
</string>
<string
name=
"LanguangeNameInEnglish"
>
German
</string>
<string
name=
"LanguageName"
>
Deutsch
</string>
<string
name=
"LanguageNameInEnglish"
>
German
</string>
<string
name=
"LanguageCode"
>
de
</string>
<!--signin view-->
<string
name=
"YourPhone"
>
Dein Telefon
</string>
...
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Diese Gruppe löschen
</string>
<string
name=
"SlideToCancel"
>
WISCHEN UM ABZUBRECHEN
</string>
<string
name=
"SaveToDownloads"
>
In Ordner Downloads speichern
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
Sprachdatei benutzen
</string>
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Geheimen Chat angefordert
</string>
...
...
TMessagesProj/src/main/res/values-es/strings.xml
View file @
ebe7ab78
...
...
@@ -5,8 +5,9 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Español
</string>
<string
name=
"LanguangeNameInEnglish"
>
Spanish
</string>
<string
name=
"LanguageName"
>
Español
</string>
<string
name=
"LanguageNameInEnglish"
>
Spanish
</string>
<string
name=
"LanguageCode"
>
es
</string>
<!--signin view-->
<string
name=
"YourPhone"
>
Tu teléfono
</string>
...
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Eliminar este grupo
</string>
<string
name=
"SlideToCancel"
>
DESLIZA PARA CANCELAR
</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-->
<string
name=
"EncryptedChatRequested"
>
Chat secreto solicitado
</string>
...
...
TMessagesProj/src/main/res/values-it/strings.xml
View file @
ebe7ab78
...
...
@@ -5,8 +5,9 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Italiano
</string>
<string
name=
"LanguangeNameInEnglish"
>
Italian
</string>
<string
name=
"LanguageName"
>
Italiano
</string>
<string
name=
"LanguageNameInEnglish"
>
Italian
</string>
<string
name=
"LanguageCode"
>
it
</string>
<!--signin view-->
<string
name=
"YourPhone"
>
Il tuo telefono
</string>
...
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Elimina questo gruppo
</string>
<string
name=
"SlideToCancel"
>
TRASCINA PER ANNULLARE
</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-->
<string
name=
"EncryptedChatRequested"
>
Chat segreta richiesta
</string>
...
...
TMessagesProj/src/main/res/values-nl/strings.xml
View file @
ebe7ab78
...
...
@@ -5,8 +5,9 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
Nederlands
</string>
<string
name=
"LanguangeNameInEnglish"
>
Dutch
</string>
<string
name=
"LanguageName"
>
Nederlands
</string>
<string
name=
"LanguageNameInEnglish"
>
Dutch
</string>
<string
name=
"LanguageCode"
>
nl
</string>
<!--signin view-->
<string
name=
"YourPhone"
>
Uw telefoon
</string>
...
...
@@ -110,7 +111,7 @@
<string
name=
"DeleteThisGroup"
>
Deze groep verwijderen
</string>
<string
name=
"SlideToCancel"
>
SLEEP OM TE ANNULEREN
</string>
<string
name=
"SaveToDownloads"
>
Opslaan in downloads
</string>
<string
name=
"ApplyLocalizationFile"
>
Apply localization file
</string>
<string
name=
"ApplyLocalizationFile"
>
Vertaling toepassen
</string>
<!--notification-->
<string
name=
"EncryptedChatRequested"
>
Privégesprek aangevraagd
</string>
...
...
TMessagesProj/src/main/res/values/strings.xml
View file @
ebe7ab78
...
...
@@ -5,8 +5,9 @@
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"LanguangeName"
>
English
</string>
<string
name=
"LanguangeNameInEnglish"
>
English
</string>
<string
name=
"LanguageName"
>
English
</string>
<string
name=
"LanguageNameInEnglish"
>
English
</string>
<string
name=
"LanguageCode"
>
en
</string>
<!--signin view-->
<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