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
2b15ac63
Commit
2b15ac63
authored
Aug 27, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue upload file after app restart, bug fixes
parent
8b73d93d
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
256 additions
and
206 deletions
+256
-206
build.gradle
TMessagesProj/build.gradle
+1
-1
GcmBroadcastReceiver.java
.../main/java/org/telegram/android/GcmBroadcastReceiver.java
+0
-7
ImageLoader.java
...sProj/src/main/java/org/telegram/android/ImageLoader.java
+11
-2
ImageReceiver.java
...roj/src/main/java/org/telegram/android/ImageReceiver.java
+3
-3
MessagesController.java
...rc/main/java/org/telegram/android/MessagesController.java
+8
-29
MessagesStorage.java
...j/src/main/java/org/telegram/android/MessagesStorage.java
+72
-77
NotificationsController.java
...in/java/org/telegram/android/NotificationsController.java
+22
-32
SendMessagesHelper.java
...rc/main/java/org/telegram/android/SendMessagesHelper.java
+7
-4
ConnectionsManager.java
.../main/java/org/telegram/messenger/ConnectionsManager.java
+0
-1
FileUploadOperation.java
...main/java/org/telegram/messenger/FileUploadOperation.java
+122
-49
Utilities.java
...sProj/src/main/java/org/telegram/messenger/Utilities.java
+10
-1
No files found.
TMessagesProj/build.gradle
View file @
2b15ac63
...
...
@@ -80,7 +80,7 @@ android {
defaultConfig
{
minSdkVersion
8
targetSdkVersion
19
versionCode
31
0
versionCode
31
1
versionName
"1.8.0"
}
}
TMessagesProj/src/main/java/org/telegram/android/GcmBroadcastReceiver.java
View file @
2b15ac63
...
...
@@ -53,13 +53,6 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
FileLog
.
e
(
"tmessages"
,
e
);
}
/*SharedPreferences preferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
boolean globalEnabled = preferences.getBoolean("EnableAll", true);
if (!globalEnabled) {
FileLog.d("tmessages", "GCM disabled");
return;
}*/
ConnectionsManager
.
getInstance
().
resumeNetworkMaybe
();
}
});
...
...
TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java
View file @
2b15ac63
...
...
@@ -628,7 +628,7 @@ public class ImageLoader {
}
}
public
BitmapDrawable
getImageFromMemory
(
TLRPC
.
FileLocation
url
,
String
httpUrl
,
String
filter
)
{
public
BitmapDrawable
getImageFromMemory
(
TLRPC
.
FileLocation
url
,
String
httpUrl
,
String
filter
,
ImageReceiver
imageReceiver
)
{
if
(
url
==
null
&&
httpUrl
==
null
)
{
return
null
;
}
...
...
@@ -641,6 +641,15 @@ public class ImageLoader {
if
(
filter
!=
null
)
{
key
+=
"@"
+
filter
;
}
if
(
imageReceiver
!=
null
)
{
Integer
TAG
=
imageReceiver
.
getTag
();
if
(
TAG
!=
null
)
{
CacheImage
alreadyLoadingImage
=
imageLoadingByTag
.
get
(
TAG
);
if
(
alreadyLoadingImage
!=
null
)
{
alreadyLoadingImage
.
removeImageView
(
imageReceiver
);
}
}
}
return
memCache
.
get
(
key
);
}
...
...
@@ -668,8 +677,8 @@ public class ImageLoader {
String
url
;
String
key
;
if
(
httpUrl
!=
null
)
{
url
=
httpUrl
;
key
=
Utilities
.
MD5
(
httpUrl
);
url
=
key
+
".jpg"
;
}
else
{
key
=
fileLocation
.
volume_id
+
"_"
+
fileLocation
.
local_id
;
url
=
key
+
".jpg"
;
...
...
TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java
View file @
2b15ac63
...
...
@@ -88,14 +88,14 @@ public class ImageReceiver {
if
(
currentImage
!=
null
)
{
return
;
}
else
{
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
);
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
,
this
);
}
}
else
{
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
);
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
,
this
);
recycleBitmap
(
img
);
}
}
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
);
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
fileLocation
,
httpUrl
,
filter
,
this
);
currentPath
=
key
;
last_path
=
fileLocation
;
last_httpUrl
=
httpUrl
;
...
...
TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
View file @
2b15ac63
...
...
@@ -963,7 +963,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
NotificationsController
.
getInstance
().
processReadMessages
(
null
,
did
,
0
,
Integer
.
MAX_VALUE
,
false
);
HashMap
<
Long
,
Integer
>
dialogsToUpdate
=
new
HashMap
<
Long
,
Integer
>();
dialogsToUpdate
.
put
(
did
,
0
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
}
});
}
...
...
@@ -1395,7 +1395,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
currentDialog
.
unread_count
=
entry
.
getValue
();
}
}
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
NotificationCenter
.
getInstance
().
postNotificationName
(
NotificationCenter
.
dialogsNeedReload
);
}
});
...
...
@@ -1491,7 +1491,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
dialogsServerOnly
.
add
(
d
);
}
}
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
NotificationCenter
.
getInstance
().
postNotificationName
(
NotificationCenter
.
dialogsNeedReload
);
}
});
...
...
@@ -1711,12 +1711,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
NotificationsController
.
getInstance
().
processReadMessages
(
null
,
dialog_id
,
0
,
max_positive_id
,
false
);
HashMap
<
Long
,
Integer
>
dialogsToUpdate
=
new
HashMap
<
Long
,
Integer
>();
dialogsToUpdate
.
put
(
dialog_id
,
0
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
}
else
{
NotificationsController
.
getInstance
().
processReadMessages
(
null
,
dialog_id
,
0
,
max_positive_id
,
true
);
HashMap
<
Long
,
Integer
>
dialogsToUpdate
=
new
HashMap
<
Long
,
Integer
>();
dialogsToUpdate
.
put
(
dialog_id
,
200000
1
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
false
);
dialogsToUpdate
.
put
(
dialog_id
,
-
1
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
}
}
});
...
...
@@ -1784,7 +1784,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
HashMap
<
Long
,
Integer
>
dialogsToUpdate
=
new
HashMap
<
Long
,
Integer
>();
dialogsToUpdate
.
put
(
dialog_id
,
0
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
}
});
}
...
...
@@ -3417,27 +3417,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return
false
;
}
public
void
dialogsUnreadCountIncr
(
final
HashMap
<
Long
,
Integer
>
values
)
{
AndroidUtilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
HashMap
.
Entry
<
Long
,
Integer
>
entry
:
values
.
entrySet
())
{
TLRPC
.
TL_dialog
dialog
=
dialogs_dict
.
get
(
entry
.
getKey
());
if
(
dialog
!=
null
)
{
int
value
=
entry
.
getValue
();
if
(
value
<
0
)
{
dialog
.
unread_count
=
-
value
;
}
else
{
dialog
.
unread_count
+=
value
;
}
}
}
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
values
,
false
);
NotificationCenter
.
getInstance
().
postNotificationName
(
NotificationCenter
.
dialogsNeedReload
);
}
});
}
protected
void
updateInterfaceWithMessages
(
long
uid
,
ArrayList
<
MessageObject
>
messages
)
{
updateInterfaceWithMessages
(
uid
,
messages
,
false
);
}
...
...
@@ -3718,7 +3697,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
NotificationsController
.
getInstance
().
processReadMessages
(
null
,
did
,
0
,
Integer
.
MAX_VALUE
,
false
);
HashMap
<
Long
,
Integer
>
dialogsToUpdate
=
new
HashMap
<
Long
,
Integer
>();
dialogsToUpdate
.
put
(
did
,
0
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
,
true
);
NotificationsController
.
getInstance
().
processDialogsUpdateRead
(
dialogsToUpdate
);
}
});
}
...
...
TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
View file @
2b15ac63
This diff is collapsed.
Click to expand it.
TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java
View file @
2b15ac63
...
...
@@ -419,7 +419,7 @@ public class NotificationsController {
}
if
(
photoPath
!=
null
)
{
BitmapDrawable
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
photoPath
,
null
,
"50_50"
);
BitmapDrawable
img
=
ImageLoader
.
getInstance
().
getImageFromMemory
(
photoPath
,
null
,
"50_50"
,
null
);
if
(
img
!=
null
)
{
mBuilder
.
setLargeIcon
(
img
.
getBitmap
());
}
...
...
@@ -596,50 +596,40 @@ public class NotificationsController {
}
}
public
void
processDialogsUpdateRead
(
final
HashMap
<
Long
,
Integer
>
dialogsToUpdate
,
boolean
replace
)
{
public
void
processDialogsUpdateRead
(
final
HashMap
<
Long
,
Integer
>
dialogsToUpdate
)
{
int
old_unread_count
=
total_unread_count
;
SharedPreferences
preferences
=
ApplicationLoader
.
applicationContext
.
getSharedPreferences
(
"Notifications"
,
Context
.
MODE_PRIVATE
);
for
(
HashMap
.
Entry
<
Long
,
Integer
>
entry
:
dialogsToUpdate
.
entrySet
())
{
long
dialog_id
=
entry
.
getKey
();
int
notify_override
=
preferences
.
getInt
(
"notify2_"
+
dialog_id
,
0
);
boolean
isChat
=
(
int
)
dialog_id
<
0
;
Integer
currentCount
=
pushDialogs
.
get
(
dialog_id
);
boolean
canAddValue
=
!(
notify_override
==
2
||
(!
preferences
.
getBoolean
(
"EnableAll"
,
true
)
||
isChat
&&
!
preferences
.
getBoolean
(
"EnableGroup"
,
true
))
&&
notify_override
==
0
);
boolean
canAddValue
=
!(
notify_override
==
2
||
(!
preferences
.
getBoolean
(
"EnableAll"
,
true
)
||
((
int
)
dialog_id
<
0
)
&&
!
preferences
.
getBoolean
(
"EnableGroup"
,
true
))
&&
notify_override
==
0
);
Integer
currentCount
=
pushDialogs
.
get
(
dialog_id
);
Integer
newCount
=
entry
.
getValue
();
if
(
replace
||
newCount
<
0
)
{
if
(
newCount
<
0
)
{
newCount
*=
-
1
;
}
if
(
currentCount
!=
null
)
{
total_unread_count
-=
currentCount
;
if
(
newCount
<
0
)
{
if
(
currentCount
==
null
)
{
continue
;
}
if
(
newCount
==
0
)
{
pushDialogs
.
remove
(
dialog_id
);
for
(
int
a
=
0
;
a
<
pushMessages
.
size
();
a
++)
{
MessageObject
messageObject
=
pushMessages
.
get
(
a
);
if
(
messageObject
.
getDialogId
()
==
dialog_id
)
{
pushMessages
.
remove
(
a
);
a
--;
pushMessagesDict
.
remove
(
messageObject
.
messageOwner
.
id
);
popupMessages
.
remove
(
messageObject
);
}
newCount
=
currentCount
+
newCount
;
}
if
(
currentCount
!=
null
)
{
total_unread_count
-=
currentCount
;
}
if
(
newCount
==
0
)
{
pushDialogs
.
remove
(
dialog_id
);
for
(
int
a
=
0
;
a
<
pushMessages
.
size
();
a
++)
{
MessageObject
messageObject
=
pushMessages
.
get
(
a
);
if
(
messageObject
.
getDialogId
()
==
dialog_id
)
{
pushMessages
.
remove
(
a
);
a
--;
pushMessagesDict
.
remove
(
messageObject
.
messageOwner
.
id
);
popupMessages
.
remove
(
messageObject
);
}
}
else
if
(
canAddValue
)
{
total_unread_count
+=
newCount
;
pushDialogs
.
put
(
dialog_id
,
newCount
);
}
}
else
if
(
canAddValue
)
{
if
(
newCount
>
2000000
)
{
newCount
=
2000000
-
newCount
;
}
if
(
currentCount
==
null
)
{
currentCount
=
0
;
}
currentCount
+=
newCount
;
total_unread_count
+=
newCount
;
pushDialogs
.
put
(
dialog_id
,
current
Count
);
pushDialogs
.
put
(
dialog_id
,
new
Count
);
}
}
if
(
old_unread_count
!=
total_unread_count
)
{
...
...
TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java
View file @
2b15ac63
...
...
@@ -147,6 +147,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
for
(
int
a
=
0
;
a
<
arr
.
size
();
a
++)
{
DelayedMessage
obj
=
arr
.
get
(
a
);
if
(
enc
&&
obj
.
sendEncryptedRequest
!=
null
||
!
enc
&&
obj
.
sendRequest
!=
null
)
{
MessagesStorage
.
getInstance
().
markMessageAsSendError
(
obj
.
obj
.
messageOwner
.
id
);
obj
.
obj
.
messageOwner
.
send_state
=
MessageObject
.
MESSAGE_SEND_STATE_SEND_ERROR
;
arr
.
remove
(
a
);
a
--;
...
...
@@ -392,6 +393,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg
.
from_id
=
UserConfig
.
getClientUserId
();
newMsg
.
out
=
true
;
newMsg
.
date
=
ConnectionsManager
.
getInstance
().
getCurrentTime
();
UserConfig
.
saveConfig
(
false
);
}
if
(
newMsg
.
random_id
==
0
)
{
newMsg
.
random_id
=
getNextRandomId
();
...
...
@@ -453,11 +455,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg
.
ttl
=
encryptedChat
.
ttl
;
}
UserConfig
.
saveConfig
(
false
);
final
MessageObject
newMsgObj
=
new
MessageObject
(
newMsg
,
null
,
2
);
MessageObject
newMsgObj
=
new
MessageObject
(
newMsg
,
null
,
2
);
newMsgObj
.
messageOwner
.
send_state
=
MessageObject
.
MESSAGE_SEND_STATE_SENDING
;
final
ArrayList
<
MessageObject
>
objArr
=
new
ArrayList
<
MessageObject
>();
ArrayList
<
MessageObject
>
objArr
=
new
ArrayList
<
MessageObject
>();
objArr
.
add
(
newMsgObj
);
ArrayList
<
TLRPC
.
Message
>
arr
=
new
ArrayList
<
TLRPC
.
Message
>();
arr
.
add
(
newMsg
);
...
...
@@ -553,7 +555,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
delayedMessage
.
obj
=
newMsgObj
;
delayedMessage
.
documentLocation
=
document
;
delayedMessage
.
location
=
document
.
thumb
.
location
;
performSendDelayedMessage
(
delayedMessage
);
}
else
{
TLRPC
.
TL_inputMediaDocument
media
=
new
TLRPC
.
TL_inputMediaDocument
();
media
.
id
=
new
TLRPC
.
TL_inputDocument
();
...
...
@@ -889,6 +890,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
});
}
else
{
MessagesStorage
.
getInstance
().
markMessageAsSendError
(
newMsgObj
.
messageOwner
.
id
);
AndroidUtilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -994,6 +996,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
});
}
else
{
MessagesStorage
.
getInstance
().
markMessageAsSendError
(
newMsgObj
.
messageOwner
.
id
);
AndroidUtilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
View file @
2b15ac63
...
...
@@ -988,7 +988,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
return
true
;
}
return
false
;
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java
View file @
2b15ac63
This diff is collapsed.
Click to expand it.
TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
View file @
2b15ac63
...
...
@@ -166,7 +166,7 @@ public class Utilities {
public
static
String
bytesToHex
(
byte
[]
bytes
)
{
char
[]
hexChars
=
new
char
[
bytes
.
length
*
2
];
int
v
;
for
(
int
j
=
0
;
j
<
bytes
.
length
;
j
++
)
{
for
(
int
j
=
0
;
j
<
bytes
.
length
;
j
++
)
{
v
=
bytes
[
j
]
&
0xFF
;
hexChars
[
j
*
2
]
=
hexArray
[
v
>>>
4
];
hexChars
[
j
*
2
+
1
]
=
hexArray
[
v
&
0x0F
];
...
...
@@ -174,6 +174,15 @@ public class Utilities {
return
new
String
(
hexChars
);
}
public
static
byte
[]
hexToBytes
(
String
hex
)
{
int
len
=
hex
.
length
();
byte
[]
data
=
new
byte
[
len
/
2
];
for
(
int
i
=
0
;
i
<
len
;
i
+=
2
)
{
data
[
i
/
2
]
=
(
byte
)
((
Character
.
digit
(
hex
.
charAt
(
i
),
16
)
<<
4
)
+
Character
.
digit
(
hex
.
charAt
(
i
+
1
),
16
));
}
return
data
;
}
public
static
boolean
isGoodPrime
(
byte
[]
prime
,
int
g
)
{
if
(!(
g
>=
2
&&
g
<=
7
))
{
return
false
;
...
...
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