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
d9b9a721
Commit
d9b9a721
authored
Jul 10, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes
parent
d3afc836
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
7 deletions
+80
-7
MessagesStorage.java
...j/src/main/java/org/telegram/android/MessagesStorage.java
+32
-0
NotificationsController.java
...in/java/org/telegram/android/NotificationsController.java
+11
-6
DispatchQueue.java
...j/src/main/java/org/telegram/messenger/DispatchQueue.java
+18
-0
PopupNotificationActivity.java
.../main/java/org/telegram/ui/PopupNotificationActivity.java
+19
-1
No files found.
TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
View file @
d9b9a721
...
...
@@ -116,6 +116,7 @@ public class MessagesStorage {
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS date_idx_dialogs ON dialogs(date);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS date_idx_enc_tasks ON enc_tasks(date);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS last_mid_idx_dialogs ON dialogs(last_mid);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS unread_count_idx_dialogs ON dialogs(unread_count);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS uid_mid_idx_media ON media(uid, mid);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS mid_idx_media ON media(mid);"
).
stepThis
().
dispose
();
...
...
@@ -180,6 +181,8 @@ public class MessagesStorage {
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS mid_idx_randoms ON randoms(mid);"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE TABLE IF NOT EXISTS sent_files_v2(uid TEXT, type INTEGER, data BLOB, PRIMARY KEY (uid, type))"
).
stepThis
().
dispose
();
database
.
executeFast
(
"CREATE INDEX IF NOT EXISTS unread_count_idx_dialogs ON dialogs(unread_count);"
).
stepThis
().
dispose
();
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -267,6 +270,35 @@ public class MessagesStorage {
});
}
public
void
loadUnreadMessages
()
{
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
final
HashMap
<
Long
,
Integer
>
pushDialogs
=
new
HashMap
<
Long
,
Integer
>();
int
totalCount
=
0
;
SQLiteCursor
cursor
=
database
.
queryFinalized
(
"SELECT did, unread_count FROM dialogs WHERE unread_count != 0"
);
while
(
cursor
.
next
())
{
long
did
=
cursor
.
longValue
(
0
);
int
count
=
cursor
.
intValue
(
1
);
pushDialogs
.
put
(
did
,
count
);
totalCount
+=
count
;
}
cursor
.
dispose
();
final
int
totalCountFinal
=
totalCount
;
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
NotificationsController
.
getInstance
().
processLoadedUnreadMessages
(
pushDialogs
,
totalCountFinal
);
}
});
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
});
}
public
void
putWallpapers
(
final
ArrayList
<
TLRPC
.
WallPaper
>
wallPapers
)
{
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
...
...
TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java
View file @
d9b9a721
...
...
@@ -318,12 +318,6 @@ public class NotificationsController {
name
=
Utilities
.
formatName
(
user
.
first_name
,
user
.
last_name
);
}
NotificationCompat
.
Builder
mBuilder
=
new
NotificationCompat
.
Builder
(
ApplicationLoader
.
applicationContext
)
.
setContentTitle
(
name
)
.
setSmallIcon
(
R
.
drawable
.
notification
)
.
setAutoCancel
(
true
)
.
setContentIntent
(
contentIntent
);
String
detailText
=
null
;
if
(
pushDialogs
.
size
()
==
1
)
{
detailText
=
LocaleController
.
formatPluralString
(
"NewMessages"
,
pushMessages
.
size
());
...
...
@@ -331,6 +325,13 @@ public class NotificationsController {
detailText
=
String
.
format
(
"%s %s"
,
LocaleController
.
formatPluralString
(
"NewMessages"
,
pushMessages
.
size
()),
LocaleController
.
formatPluralString
(
"FromContacts"
,
pushDialogs
.
size
()));
}
NotificationCompat
.
Builder
mBuilder
=
new
NotificationCompat
.
Builder
(
ApplicationLoader
.
applicationContext
)
.
setContentTitle
(
name
)
.
setSmallIcon
(
R
.
drawable
.
notification
)
.
setAutoCancel
(
true
)
.
setContentText
(
detailText
)
.
setContentIntent
(
contentIntent
);
String
lastMessage
=
null
;
NotificationCompat
.
InboxStyle
inboxStyle
=
new
NotificationCompat
.
InboxStyle
();
inboxStyle
.
setBigContentTitle
(
name
);
...
...
@@ -537,4 +538,8 @@ public class NotificationsController {
}
}
}
public
void
processLoadedUnreadMessages
(
HashMap
<
Long
,
Integer
>
dialogs
,
int
totalCount
)
{
}
}
TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java
View file @
d9b9a721
...
...
@@ -41,6 +41,24 @@ public class DispatchQueue extends Thread {
}
}
public
void
cancelRunnable
(
Runnable
runnable
)
{
if
(
handler
==
null
)
{
synchronized
(
handlerSyncObject
)
{
if
(
handler
==
null
)
{
try
{
handlerSyncObject
.
wait
();
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
}
}
}
}
if
(
handler
!=
null
)
{
handler
.
removeCallbacks
(
runnable
);
}
}
public
void
postRunnable
(
Runnable
runnable
)
{
postRunnable
(
runnable
,
0
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java
View file @
d9b9a721
...
...
@@ -85,6 +85,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
private
float
moveStartX
=
-
1
;
private
boolean
startedMoving
=
false
;
private
Runnable
onAnimationEndRunnable
=
null
;
private
Runnable
wakeLockRunnable
=
null
;
private
class
FrameLayoutTouch
extends
FrameLayout
{
public
FrameLayoutTouch
(
Context
context
)
{
...
...
@@ -650,7 +651,21 @@ public class PopupNotificationActivity extends Activity implements NotificationC
currentMessageNum
=
0
;
}
getNewMessage
();
wakeLock
.
acquire
(
7000
);
wakeLock
.
acquire
();
Utilities
.
stageQueue
.
postRunnable
(
wakeLockRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
wakeLockRunnable
=
null
;
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
}
});
}
},
7000
);
}
private
void
getNewMessage
()
{
...
...
@@ -957,5 +972,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if
(
wakeLock
.
isHeld
())
{
wakeLock
.
release
();
}
if
(
wakeLockRunnable
!=
null
)
{
Utilities
.
stageQueue
.
cancelRunnable
(
wakeLockRunnable
);
}
}
}
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