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
21273f82
Commit
21273f82
authored
Aug 23, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes
parent
fc46daa5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
13 deletions
+104
-13
build.gradle
TMessagesProj/build.gradle
+1
-1
MediaController.java
...j/src/main/java/org/telegram/android/MediaController.java
+3
-1
MessagesController.java
...rc/main/java/org/telegram/android/MessagesController.java
+19
-3
FileLoader.java
...Proj/src/main/java/org/telegram/messenger/FileLoader.java
+16
-4
FileUploadOperation.java
...main/java/org/telegram/messenger/FileUploadOperation.java
+63
-1
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+2
-3
No files found.
TMessagesProj/build.gradle
View file @
21273f82
...
...
@@ -80,7 +80,7 @@ android {
defaultConfig
{
minSdkVersion
8
targetSdkVersion
19
versionCode
30
8
versionCode
30
9
versionName
"1.8.0"
}
}
TMessagesProj/src/main/java/org/telegram/android/MediaController.java
View file @
21273f82
...
...
@@ -382,8 +382,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
IntentFilter
filter
=
new
IntentFilter
(
ConnectivityManager
.
CONNECTIVITY_ACTION
);
ApplicationLoader
.
applicationContext
.
registerReceiver
(
networkStateReceiver
,
filter
);
if
(
UserConfig
.
isClientActivated
())
{
checkAutodownloadSettings
();
}
}
private
void
startProgressTimer
()
{
synchronized
(
progressTimerSync
)
{
...
...
TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
View file @
21273f82
...
...
@@ -55,6 +55,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public
HashMap
<
Integer
,
MessageObject
>
dialogMessage
=
new
HashMap
<
Integer
,
MessageObject
>();
public
ConcurrentHashMap
<
Long
,
ArrayList
<
PrintingUser
>>
printingUsers
=
new
ConcurrentHashMap
<
Long
,
ArrayList
<
PrintingUser
>>(
100
,
1.0f
,
2
);
public
HashMap
<
Long
,
CharSequence
>
printingStrings
=
new
HashMap
<
Long
,
CharSequence
>();
public
HashMap
<
Long
,
Boolean
>
sendingTypings
=
new
HashMap
<
Long
,
Boolean
>();
private
int
lastPrintingStringCount
=
0
;
public
boolean
loadingBlockedUsers
=
false
;
...
...
@@ -308,6 +309,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
pendingEncMessagesToDelete
.
clear
();
delayedEncryptedChatUpdates
.
clear
();
blockedUsers
.
clear
();
sendingTypings
.
clear
();
updatesStartWaitTime
=
0
;
currentDeletingTaskTime
=
0
;
...
...
@@ -1192,10 +1194,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
});
}
public
void
sendTyping
(
long
dialog_id
,
int
classGuid
)
{
public
void
cancelTyping
(
long
dialog_id
)
{
sendingTypings
.
remove
(
dialog_id
);
}
public
void
sendTyping
(
final
long
dialog_id
,
int
classGuid
)
{
if
(
dialog_id
==
0
)
{
return
;
}
if
(
sendingTypings
.
get
(
dialog_id
)
!=
null
)
{
return
;
}
int
lower_part
=
(
int
)
dialog_id
;
int
high_id
=
(
int
)(
dialog_id
>>
32
);
if
(
lower_part
!=
0
)
{
...
...
@@ -1223,10 +1232,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
req
.
typing
=
true
;
sendingTypings
.
put
(
dialog_id
,
true
);
long
reqId
=
ConnectionsManager
.
getInstance
().
performRpc
(
req
,
new
RPCRequest
.
RPCRequestDelegate
()
{
@Override
public
void
run
(
TLObject
response
,
TLRPC
.
TL_error
error
)
{
AndroidUtilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
sendingTypings
.
remove
(
dialog_id
);
}
});
}
},
true
,
RPCRequest
.
RPCRequestClassGeneric
|
RPCRequest
.
RPCRequestClassFailOnServerErrors
);
ConnectionsManager
.
getInstance
().
bindRequestToGuid
(
reqId
,
classGuid
);
...
...
@@ -1238,10 +1253,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req
.
peer
.
chat_id
=
chat
.
id
;
req
.
peer
.
access_hash
=
chat
.
access_hash
;
req
.
typing
=
true
;
sendingTypings
.
put
(
dialog_id
,
true
);
long
reqId
=
ConnectionsManager
.
getInstance
().
performRpc
(
req
,
new
RPCRequest
.
RPCRequestDelegate
()
{
@Override
public
void
run
(
TLObject
response
,
TLRPC
.
TL_error
error
)
{
sendingTypings
.
remove
(
dialog_id
);
}
},
true
,
RPCRequest
.
RPCRequestClassGeneric
|
RPCRequest
.
RPCRequestClassFailOnServerErrors
);
ConnectionsManager
.
getInstance
().
bindRequestToGuid
(
reqId
,
classGuid
);
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
21273f82
...
...
@@ -276,7 +276,7 @@ public class FileLoader {
}
public
void
loadFile
(
TLRPC
.
FileLocation
location
,
int
size
)
{
loadFile
(
null
,
null
,
null
,
location
,
size
,
fals
e
);
loadFile
(
null
,
null
,
null
,
location
,
size
,
tru
e
);
}
private
void
loadFile
(
final
TLRPC
.
Video
video
,
final
TLRPC
.
Document
document
,
final
TLRPC
.
Audio
audio
,
final
TLRPC
.
FileLocation
location
,
final
int
locationSize
,
final
boolean
force
)
{
...
...
@@ -409,25 +409,37 @@ public class FileLoader {
if
(
currentAudioLoadOperationsCount
<
2
)
{
currentAudioLoadOperationsCount
++;
operation
.
start
();
}
else
{
if
(
force
)
{
audioLoadOperationQueue
.
add
(
0
,
operation
);
}
else
{
audioLoadOperationQueue
.
add
(
operation
);
}
}
}
else
if
(
location
!=
null
)
{
if
(
currentPhotoLoadOperationsCount
<
2
)
{
currentPhotoLoadOperationsCount
++;
operation
.
start
();
}
else
{
if
(
force
)
{
photoLoadOperationQueue
.
add
(
0
,
operation
);
}
else
{
photoLoadOperationQueue
.
add
(
operation
);
}
}
}
else
{
if
(
currentLoadOperationsCount
<
2
)
{
currentLoadOperationsCount
++;
operation
.
start
();
}
else
{
if
(
force
)
{
loadOperationQueue
.
add
(
0
,
operation
);
}
else
{
loadOperationQueue
.
add
(
operation
);
}
}
}
}
});
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java
View file @
21273f82
...
...
@@ -8,6 +8,11 @@
package
org
.
telegram
.
messenger
;
import
android.app.Activity
;
import
android.content.SharedPreferences
;
import
org.telegram.ui.ApplicationLoader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.math.BigInteger
;
...
...
@@ -28,11 +33,13 @@ public class FileUploadOperation {
private
long
totalFileSize
=
0
;
private
int
totalPartsCount
=
0
;
private
long
currentUploaded
=
0
;
private
int
saveInfoTimes
=
0
;
private
byte
[]
key
;
private
byte
[]
iv
;
private
byte
[]
ivChange
;
private
int
fingerprint
=
0
;
private
boolean
isBigFile
=
false
;
private
String
fileKey
;
FileInputStream
stream
;
MessageDigest
mdEnc
=
null
;
...
...
@@ -89,6 +96,12 @@ public class FileUploadOperation {
ConnectionsManager
.
getInstance
().
cancelRpc
(
requestToken
,
true
);
}
delegate
.
didFailedUploadingFile
(
this
);
cleanup
();
}
private
void
cleanup
()
{
SharedPreferences
preferences
=
ApplicationLoader
.
applicationContext
.
getSharedPreferences
(
"uploadinfo"
,
Activity
.
MODE_PRIVATE
);
preferences
.
edit
().
remove
(
fileKey
+
"_time"
).
remove
(
fileKey
+
"_size"
).
remove
(
fileKey
+
"_uploaded"
).
commit
();
}
private
void
startUploadRequest
()
{
...
...
@@ -104,7 +117,6 @@ public class FileUploadOperation {
stream
=
new
FileInputStream
(
cacheFile
);
totalFileSize
=
cacheFile
.
length
();
if
(
totalFileSize
>
10
*
1024
*
1024
)
{
FileLog
.
e
(
"tmessages"
,
"file is big!"
);
isBigFile
=
true
;
}
...
...
@@ -120,6 +132,51 @@ public class FileUploadOperation {
uploadChunkSize
*=
1024
;
totalPartsCount
=
(
int
)
Math
.
ceil
((
float
)
totalFileSize
/
(
float
)
uploadChunkSize
);
readBuffer
=
new
byte
[
uploadChunkSize
];
fileKey
=
Utilities
.
MD5
(
uploadingFilePath
);
/*SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE); TODO
long fileSize = preferences.getLong(fileKey + "_size", 0);
int currentTime = (int)(System.currentTimeMillis() / 1000);
boolean rewrite = false;
if (fileSize == totalFileSize) {
int date = preferences.getInt(fileKey + "_time", 0);
long uploadedSize = preferences.getLong(fileKey + "_uploaded", 0);
if (date != 0) {
if (isBigFile && date < currentTime - 60 * 60 * 24) {
date = 0;
} else if (!isBigFile && date < currentTime - 60 * 60 * 1.5f) {
date = 0;
}
if (date != 0) {
if (isBigFile) {
uploadedSize = uploadedSize / (1024 * 1024) * (1024 * 1024);
}
if (uploadedSize > 0) {
currentUploaded = uploadedSize;
stream.skip(uploadedSize);
currentPartNum = (int) (uploadedSize / uploadChunkSize);
} else {
rewrite = true;
}
}
} else {
rewrite = true;
}
} else {
rewrite = true;
}
if (rewrite) {
preferences.edit().putInt(fileKey + "_time", currentTime).putLong(fileKey + "_size", totalFileSize).commit();
}*/
}
else
{
/*if (saveInfoTimes >= 4) {
saveInfoTimes = 0;
}
if (saveInfoTimes == 0) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE);
preferences.edit().putLong(fileKey + "_uploaded", currentUploaded).commit();
}
saveInfoTimes++;*/
}
int
readed
=
stream
.
read
(
readBuffer
);
...
...
@@ -160,6 +217,7 @@ public class FileUploadOperation {
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
delegate
.
didFailedUploadingFile
(
this
);
cleanup
();
return
;
}
requestToken
=
ConnectionsManager
.
getInstance
().
performRpc
(
finalRequest
,
new
RPCRequest
.
RPCRequestDelegate
()
{
...
...
@@ -184,6 +242,7 @@ public class FileUploadOperation {
result
.
id
=
currentFileId
;
result
.
name
=
uploadingFilePath
.
substring
(
uploadingFilePath
.
lastIndexOf
(
"/"
)
+
1
);
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
result
,
null
);
cleanup
();
}
else
{
TLRPC
.
InputEncryptedFile
result
;
if
(
isBigFile
)
{
...
...
@@ -198,15 +257,18 @@ public class FileUploadOperation {
result
.
iv
=
iv
;
result
.
key
=
key
;
delegate
.
didFinishUploadingFile
(
FileUploadOperation
.
this
,
null
,
result
);
cleanup
();
}
}
else
{
startUploadRequest
();
}
}
else
{
delegate
.
didFailedUploadingFile
(
FileUploadOperation
.
this
);
cleanup
();
}
}
else
{
delegate
.
didFailedUploadingFile
(
FileUploadOperation
.
this
);
cleanup
();
}
}
},
null
,
true
,
RPCRequest
.
RPCRequestClassUploadMedia
,
ConnectionsManager
.
DEFAULT_DATACENTER_ID
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
21273f82
...
...
@@ -354,8 +354,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
loading
=
true
;
MessagesController
.
getInstance
().
loadMessages
(
dialog_id
,
30
,
0
,
true
,
0
,
classGuid
,
true
,
false
);
SharedPreferences
preferences
=
ApplicationLoader
.
applicationContext
.
getSharedPreferences
(
"mainconfig"
,
Activity
.
MODE_PRIVATE
);
if
(
currentUser
!=
null
)
{
userBlocked
=
MessagesController
.
getInstance
().
blockedUsers
.
contains
(
currentUser
.
id
);
}
...
...
@@ -2572,6 +2570,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
chatActivityEnterView
.
setFieldFocused
(
false
);
MessagesController
.
getInstance
().
cancelTyping
(
dialog_id
);
/*if (currentEncryptedChat != null) { disabled
chatLeaveTime = System.currentTimeMillis();
...
...
@@ -3393,7 +3392,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
((
ChatBaseCell
)
view
).
setMessageObject
(
message
);
((
ChatBaseCell
)
view
).
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
if
(
view
instanceof
ChatAudioCell
&&
MediaController
.
getInstance
().
canDownloadMedia
(
MediaController
.
AUTODOWNLOAD_MASK_AUDIO
))
{
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
//TODO
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
}
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
view
.
getTag
();
...
...
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