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
01103c6e
Commit
01103c6e
authored
Mar 10, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to 1.3.30
parent
8ecb9e97
Changes
30
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
900 additions
and
145 deletions
+900
-145
AndroidManifest.xml
TMessagesProj/src/main/AndroidManifest.xml
+5
-6
ContactsController.java
.../main/java/org/telegram/messenger/ContactsController.java
+58
-28
GcmBroadcastReceiver.java
...ain/java/org/telegram/messenger/GcmBroadcastReceiver.java
+23
-11
MediaController.java
...src/main/java/org/telegram/messenger/MediaController.java
+29
-27
MessageObject.java
...roj/src/main/java/org/telegram/objects/MessageObject.java
+55
-13
ContactsActivitySearchAdapter.java
...g/telegram/ui/Adapters/ContactsActivitySearchAdapter.java
+27
-20
BaseCell.java
...gesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java
+1
-0
ChatMessageCell.java
.../src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+35
-3
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+82
-8
GalleryImageViewer.java
...roj/src/main/java/org/telegram/ui/GalleryImageViewer.java
+4
-1
GroupCreateActivity.java
...oj/src/main/java/org/telegram/ui/GroupCreateActivity.java
+27
-20
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+11
-7
LoginActivity.java
...agesProj/src/main/java/org/telegram/ui/LoginActivity.java
+3
-0
LoginActivityPhoneView.java
...src/main/java/org/telegram/ui/LoginActivityPhoneView.java
+1
-0
SettingsActivity.java
...sProj/src/main/java/org/telegram/ui/SettingsActivity.java
+3
-0
TimerButton.java
...Proj/src/main/java/org/telegram/ui/Views/TimerButton.java
+117
-0
header_timer.png
TMessagesProj/src/main/res/drawable-hdpi/header_timer.png
+0
-0
header_timer2.png
TMessagesProj/src/main/res/drawable-hdpi/header_timer2.png
+0
-0
header_timer.png
TMessagesProj/src/main/res/drawable-ldpi/header_timer.png
+0
-0
header_timer2.png
TMessagesProj/src/main/res/drawable-ldpi/header_timer2.png
+0
-0
header_timer.png
TMessagesProj/src/main/res/drawable-mdpi/header_timer.png
+0
-0
header_timer2.png
TMessagesProj/src/main/res/drawable-mdpi/header_timer2.png
+0
-0
header_timer.png
TMessagesProj/src/main/res/drawable-xhdpi/header_timer.png
+0
-0
header_timer2.png
TMessagesProj/src/main/res/drawable-xhdpi/header_timer2.png
+0
-0
header_timer.png
TMessagesProj/src/main/res/drawable-xxhdpi/header_timer.png
+0
-0
header_timer2.png
TMessagesProj/src/main/res/drawable-xxhdpi/header_timer2.png
+0
-0
chat_header_enc_layout.xml
TMessagesProj/src/main/res/layout/chat_header_enc_layout.xml
+14
-0
chat_enc_menu.xml
TMessagesProj/src/main/res/menu/chat_enc_menu.xml
+50
-0
strings.xml
TMessagesProj/src/main/res/values-de/strings.xml
+1
-1
strings.xml
TMessagesProj/src/main/res/values-nl/strings.xml
+354
-0
No files found.
TMessagesProj/src/main/AndroidManifest.xml
View file @
01103c6e
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"org.telegram.messenger"
package=
"org.telegram.messenger"
android:versionCode=
"1
85
"
android:versionCode=
"1
94
"
android:versionName=
"1.3.
26
"
>
android:versionName=
"1.3.
30
"
>
<supports-screens
android:anyDensity=
"true"
<supports-screens
android:anyDensity=
"true"
android:smallScreens=
"true"
android:smallScreens=
"true"
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<uses-feature
android:name=
"android.hardware.screen.PORTRAIT"
android:required=
"false"
/>
<uses-feature
android:name=
"android.hardware.screen.PORTRAIT"
android:required=
"false"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<
uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/
>
<
!--<uses-permission android:name="android.permission.RECORD_AUDIO" />--
>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_SMS"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_SMS"
/>
...
@@ -50,7 +50,6 @@
...
@@ -50,7 +50,6 @@
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"com.google.android.gallery3d.permission.GALLERY_PROVIDER"
/>
<permission
android:name=
"org.telegram.messenger.permission.MAPS_RECEIVE"
android:protectionLevel=
"signature"
/>
<permission
android:name=
"org.telegram.messenger.permission.MAPS_RECEIVE"
android:protectionLevel=
"signature"
/>
<permission
android:name=
"org.telegram.messenger.permission.C2D_MESSAGE"
android:protectionLevel=
"signature"
/>
<permission
android:name=
"org.telegram.messenger.permission.C2D_MESSAGE"
android:protectionLevel=
"signature"
/>
...
@@ -65,9 +64,9 @@
...
@@ -65,9 +64,9 @@
android:largeHeap=
"true"
>
android:largeHeap=
"true"
>
<!--release-->
<!--release-->
<
!--<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />--
>
<
meta-data
android:name=
"com.google.android.maps.v2.API_KEY"
android:value=
"AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
/
>
<!--debug-->
<!--debug-->
<
meta-data
android:name=
"com.google.android.maps.v2.API_KEY"
android:value=
"AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4"
/
>
<
!--<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4" />--
>
<meta-data
android:name=
"com.google.android.gms.version"
android:value=
"@integer/google_play_services_version"
/>
<meta-data
android:name=
"com.google.android.gms.version"
android:value=
"@integer/google_play_services_version"
/>
<activity
<activity
...
...
TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
View file @
01103c6e
...
@@ -501,16 +501,16 @@ public class ContactsController {
...
@@ -501,16 +501,16 @@ public class ContactsController {
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
//
if (ConnectionsManager.DEBUG_VERSION) {
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
//
FileLog.e("tmessages", "need delete contacts");
FileLog
.
e
(
"tmessages"
,
"need delete contacts"
);
//
for (HashMap.Entry<Integer, Contact> c : contactHashMap.entrySet()) {
for
(
HashMap
.
Entry
<
Integer
,
Contact
>
c
:
contactHashMap
.
entrySet
())
{
//
Contact contact = c.getValue();
Contact
contact
=
c
.
getValue
();
//
FileLog.e("tmessages", "delete contact " + contact.first_name + " " + contact.last_name);
FileLog
.
e
(
"tmessages"
,
"delete contact "
+
contact
.
first_name
+
" "
+
contact
.
last_name
);
//
for (String phone : contact.phones) {
for
(
String
phone
:
contact
.
phones
)
{
//
FileLog.e("tmessages", phone);
FileLog
.
e
(
"tmessages"
,
phone
);
//
}
}
//
}
}
//
}
}
final
ArrayList
<
TLRPC
.
User
>
toDelete
=
new
ArrayList
<
TLRPC
.
User
>();
final
ArrayList
<
TLRPC
.
User
>
toDelete
=
new
ArrayList
<
TLRPC
.
User
>();
if
(
contactHashMap
!=
null
&&
!
contactHashMap
.
isEmpty
())
{
if
(
contactHashMap
!=
null
&&
!
contactHashMap
.
isEmpty
())
{
...
@@ -577,12 +577,12 @@ public class ContactsController {
...
@@ -577,12 +577,12 @@ public class ContactsController {
if
(
request
)
{
if
(
request
)
{
if
(!
toImport
.
isEmpty
())
{
if
(!
toImport
.
isEmpty
())
{
//
if (ConnectionsManager.DEBUG_VERSION) {
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
//
FileLog.e("tmessages", "start import contacts");
FileLog
.
e
(
"tmessages"
,
"start import contacts"
);
//
for (TLRPC.TL_inputPhoneContact contact : toImport) {
for
(
TLRPC
.
TL_inputPhoneContact
contact
:
toImport
)
{
//
FileLog.e("tmessages", "add contact " + contact.first_name + " " + contact.last_name + " " + contact.phone);
FileLog
.
e
(
"tmessages"
,
"add contact "
+
contact
.
first_name
+
" "
+
contact
.
last_name
+
" "
+
contact
.
phone
);
//
}
}
//
}
}
final
int
count
=
(
int
)
Math
.
ceil
(
toImport
.
size
()
/
500.0f
);
final
int
count
=
(
int
)
Math
.
ceil
(
toImport
.
size
()
/
500.0f
);
for
(
int
a
=
0
;
a
<
count
;
a
++)
{
for
(
int
a
=
0
;
a
<
count
;
a
++)
{
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>
finalToImport
=
new
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>();
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>
finalToImport
=
new
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>();
...
@@ -600,6 +600,11 @@ public class ContactsController {
...
@@ -600,6 +600,11 @@ public class ContactsController {
MessagesStorage
.
Instance
.
putCachedPhoneBook
(
contactsMap
);
MessagesStorage
.
Instance
.
putCachedPhoneBook
(
contactsMap
);
}
}
TLRPC
.
TL_contacts_importedContacts
res
=
(
TLRPC
.
TL_contacts_importedContacts
)
response
;
TLRPC
.
TL_contacts_importedContacts
res
=
(
TLRPC
.
TL_contacts_importedContacts
)
response
;
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
for
(
TLRPC
.
User
user
:
res
.
users
)
{
FileLog
.
e
(
"tmessages"
,
"received user "
+
user
.
first_name
+
" "
+
user
.
last_name
+
" "
+
user
.
phone
);
}
}
MessagesStorage
.
Instance
.
putUsersAndChats
(
res
.
users
,
null
,
true
,
true
);
MessagesStorage
.
Instance
.
putUsersAndChats
(
res
.
users
,
null
,
true
,
true
);
ArrayList
<
TLRPC
.
TL_contact
>
cArr
=
new
ArrayList
<
TLRPC
.
TL_contact
>();
ArrayList
<
TLRPC
.
TL_contact
>
cArr
=
new
ArrayList
<
TLRPC
.
TL_contact
>();
for
(
TLRPC
.
TL_importedContact
c
:
res
.
imported
)
{
for
(
TLRPC
.
TL_importedContact
c
:
res
.
imported
)
{
...
@@ -740,6 +745,8 @@ public class ContactsController {
...
@@ -740,6 +745,8 @@ public class ContactsController {
}
}
}
}
final
HashMap
<
Integer
,
TLRPC
.
User
>
usersDict
=
new
HashMap
<
Integer
,
TLRPC
.
User
>();
if
(!
contacts
.
isEmpty
())
{
if
(!
contacts
.
isEmpty
())
{
for
(
int
a
=
0
;
a
<
contactsArr
.
size
();
a
++)
{
for
(
int
a
=
0
;
a
<
contactsArr
.
size
();
a
++)
{
TLRPC
.
TL_contact
contact
=
contactsArr
.
get
(
a
);
TLRPC
.
TL_contact
contact
=
contactsArr
.
get
(
a
);
...
@@ -751,6 +758,17 @@ public class ContactsController {
...
@@ -751,6 +758,17 @@ public class ContactsController {
contactsArr
.
addAll
(
contacts
);
contactsArr
.
addAll
(
contacts
);
}
}
for
(
TLRPC
.
TL_contact
contact
:
contactsArr
)
{
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
);
if
(
user
!=
null
)
{
usersDict
.
put
(
user
.
id
,
user
);
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
FileLog
.
e
(
"tmessages"
,
"loaded user contact "
+
user
.
first_name
+
" "
+
user
.
last_name
+
" "
+
user
.
phone
);
}
}
}
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
stageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -760,15 +778,15 @@ public class ContactsController {
...
@@ -760,15 +778,15 @@ public class ContactsController {
return
;
return
;
}
}
if
(
from
==
1
)
{
for
(
TLRPC
.
TL_contact
contact
:
contactsArr
)
{
for
(
TLRPC
.
TL_contact
contact
:
contactsArr
)
{
if
(
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
)
==
null
&&
contact
.
user_id
!=
UserConfig
.
clientUserId
)
{
if
(
usersDict
.
get
(
contact
.
user_id
)
==
null
&&
contact
.
user_id
!=
UserConfig
.
clientUserId
)
{
loadContacts
(
false
,
true
);
loadContacts
(
false
,
true
);
FileLog
.
e
(
"tmessages"
,
"contacts are broken, load from server"
);
FileLog
.
e
(
"tmessages"
,
"contacts are broken, load from server"
);
return
;
return
;
}
}
}
}
}
else
{
if
(
from
!=
1
)
{
MessagesStorage
.
Instance
.
putUsersAndChats
(
usersArr
,
null
,
true
,
true
);
MessagesStorage
.
Instance
.
putUsersAndChats
(
usersArr
,
null
,
true
,
true
);
MessagesStorage
.
Instance
.
putContacts
(
contactsArr
,
from
!=
2
);
MessagesStorage
.
Instance
.
putContacts
(
contactsArr
,
from
!=
2
);
Collections
.
sort
(
contactsArr
,
new
Comparator
<
TLRPC
.
TL_contact
>()
{
Collections
.
sort
(
contactsArr
,
new
Comparator
<
TLRPC
.
TL_contact
>()
{
...
@@ -796,8 +814,8 @@ public class ContactsController {
...
@@ -796,8 +814,8 @@ public class ContactsController {
Collections
.
sort
(
contactsArr
,
new
Comparator
<
TLRPC
.
TL_contact
>()
{
Collections
.
sort
(
contactsArr
,
new
Comparator
<
TLRPC
.
TL_contact
>()
{
@Override
@Override
public
int
compare
(
TLRPC
.
TL_contact
tl_contact
,
TLRPC
.
TL_contact
tl_contact2
)
{
public
int
compare
(
TLRPC
.
TL_contact
tl_contact
,
TLRPC
.
TL_contact
tl_contact2
)
{
TLRPC
.
User
user1
=
MessagesController
.
Instance
.
users
.
get
(
tl_contact
.
user_id
);
TLRPC
.
User
user1
=
usersDict
.
get
(
tl_contact
.
user_id
);
TLRPC
.
User
user2
=
MessagesController
.
Instance
.
users
.
get
(
tl_contact2
.
user_id
);
TLRPC
.
User
user2
=
usersDict
.
get
(
tl_contact2
.
user_id
);
String
name1
=
user1
.
first_name
;
String
name1
=
user1
.
first_name
;
if
(
name1
==
null
||
name1
.
length
()
==
0
)
{
if
(
name1
==
null
||
name1
.
length
()
==
0
)
{
name1
=
user1
.
last_name
;
name1
=
user1
.
last_name
;
...
@@ -822,7 +840,7 @@ public class ContactsController {
...
@@ -822,7 +840,7 @@ public class ContactsController {
final
HashMap
<
String
,
TLRPC
.
TL_contact
>
contactsByPhonesDictFinal
=
contactsByPhonesDict
;
final
HashMap
<
String
,
TLRPC
.
TL_contact
>
contactsByPhonesDictFinal
=
contactsByPhonesDict
;
for
(
TLRPC
.
TL_contact
value
:
contactsArr
)
{
for
(
TLRPC
.
TL_contact
value
:
contactsArr
)
{
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
value
.
user_id
);
TLRPC
.
User
user
=
usersDict
.
get
(
value
.
user_id
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
continue
;
continue
;
}
}
...
@@ -1350,7 +1368,7 @@ public class ContactsController {
...
@@ -1350,7 +1368,7 @@ public class ContactsController {
}
}
public
void
addContact
(
TLRPC
.
User
user
)
{
public
void
addContact
(
TLRPC
.
User
user
)
{
if
(
user
==
null
)
{
if
(
user
==
null
||
user
.
phone
==
null
)
{
return
;
return
;
}
}
...
@@ -1358,12 +1376,18 @@ public class ContactsController {
...
@@ -1358,12 +1376,18 @@ public class ContactsController {
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>
contactsParams
=
new
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>();
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>
contactsParams
=
new
ArrayList
<
TLRPC
.
TL_inputPhoneContact
>();
TLRPC
.
TL_inputPhoneContact
c
=
new
TLRPC
.
TL_inputPhoneContact
();
TLRPC
.
TL_inputPhoneContact
c
=
new
TLRPC
.
TL_inputPhoneContact
();
c
.
phone
=
user
.
phone
;
c
.
phone
=
user
.
phone
;
if
(!
c
.
phone
.
startsWith
(
"+"
))
{
c
.
phone
=
"+"
+
c
.
phone
;
}
c
.
first_name
=
user
.
first_name
;
c
.
first_name
=
user
.
first_name
;
c
.
last_name
=
user
.
last_name
;
c
.
last_name
=
user
.
last_name
;
c
.
client_id
=
0
;
c
.
client_id
=
0
;
contactsParams
.
add
(
c
);
contactsParams
.
add
(
c
);
req
.
contacts
=
contactsParams
;
req
.
contacts
=
contactsParams
;
req
.
replace
=
false
;
req
.
replace
=
false
;
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
FileLog
.
e
(
"tmessages"
,
"add contact "
+
user
.
first_name
+
" "
+
user
.
last_name
+
" "
+
user
.
phone
);
}
ConnectionsManager
.
Instance
.
performRpc
(
req
,
new
RPCRequest
.
RPCRequestDelegate
()
{
ConnectionsManager
.
Instance
.
performRpc
(
req
,
new
RPCRequest
.
RPCRequestDelegate
()
{
@Override
@Override
public
void
run
(
TLObject
response
,
TLRPC
.
TL_error
error
)
{
public
void
run
(
TLObject
response
,
TLRPC
.
TL_error
error
)
{
...
@@ -1373,6 +1397,12 @@ public class ContactsController {
...
@@ -1373,6 +1397,12 @@ public class ContactsController {
final
TLRPC
.
TL_contacts_importedContacts
res
=
(
TLRPC
.
TL_contacts_importedContacts
)
response
;
final
TLRPC
.
TL_contacts_importedContacts
res
=
(
TLRPC
.
TL_contacts_importedContacts
)
response
;
MessagesStorage
.
Instance
.
putUsersAndChats
(
res
.
users
,
null
,
true
,
true
);
MessagesStorage
.
Instance
.
putUsersAndChats
(
res
.
users
,
null
,
true
,
true
);
if
(
ConnectionsManager
.
DEBUG_VERSION
)
{
for
(
TLRPC
.
User
user
:
res
.
users
)
{
FileLog
.
e
(
"tmessages"
,
"received user "
+
user
.
first_name
+
" "
+
user
.
last_name
+
" "
+
user
.
phone
);
}
}
for
(
final
TLRPC
.
User
u
:
res
.
users
)
{
for
(
final
TLRPC
.
User
u
:
res
.
users
)
{
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
...
...
TMessagesProj/src/main/java/org/telegram/messenger/GcmBroadcastReceiver.java
View file @
01103c6e
...
@@ -17,15 +17,34 @@ import android.os.PowerManager;
...
@@ -17,15 +17,34 @@ import android.os.PowerManager;
public
class
GcmBroadcastReceiver
extends
BroadcastReceiver
{
public
class
GcmBroadcastReceiver
extends
BroadcastReceiver
{
public
static
final
int
NOTIFICATION_ID
=
1
;
public
static
final
int
NOTIFICATION_ID
=
1
;
private
static
PowerManager
.
WakeLock
wakeLock
=
null
;
private
static
final
Integer
sync
=
1
;
@Override
@Override
public
void
onReceive
(
final
Context
context
,
final
Intent
intent
)
{
public
void
onReceive
(
final
Context
context
,
final
Intent
intent
)
{
FileLog
.
d
(
"tmessages"
,
"GCM received intent: "
+
intent
);
FileLog
.
d
(
"tmessages"
,
"GCM received intent: "
+
intent
);
if
(
intent
.
getAction
().
equals
(
"com.google.android.c2dm.intent.RECEIVE"
))
{
if
(
intent
.
getAction
().
equals
(
"com.google.android.c2dm.intent.RECEIVE"
))
{
synchronized
(
sync
)
{
try
{
if
(
wakeLock
==
null
)
{
PowerManager
pm
=
(
PowerManager
)
context
.
getSystemService
(
Context
.
POWER_SERVICE
);
PowerManager
pm
=
(
PowerManager
)
context
.
getSystemService
(
Context
.
POWER_SERVICE
);
final
PowerManager
.
WakeLock
wl
=
pm
.
newWakeLock
(
PowerManager
.
PARTIAL_WAKE_LOCK
,
"lock"
);
wakeLock
=
pm
.
newWakeLock
(
PowerManager
.
PARTIAL_WAKE_LOCK
,
"lock"
);
wl
.
acquire
();
}
if
(!
wakeLock
.
isHeld
())
{
wakeLock
.
acquire
(
5000
);
}
}
catch
(
Exception
e
)
{
try
{
if
(
wakeLock
!=
null
)
{
wakeLock
.
release
();
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
FileLog
.
e
(
"tmessages"
,
e
);
}
}
// SharedPreferences preferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
// SharedPreferences preferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
// boolean globalEnabled = preferences.getBoolean("EnableAll", true);
// boolean globalEnabled = preferences.getBoolean("EnableAll", true);
...
@@ -34,14 +53,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
...
@@ -34,14 +53,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
// return;
// return;
// }
// }
Thread
thread
=
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
ConnectionsManager
.
Instance
.
resumeNetworkMaybe
();
ConnectionsManager
.
Instance
.
resumeNetworkMaybe
();
wl
.
release
();
}
});
thread
.
setPriority
(
Thread
.
MAX_PRIORITY
);
thread
.
start
();
}
else
if
(
intent
.
getAction
().
equals
(
"com.google.android.c2dm.intent.REGISTRATION"
))
{
}
else
if
(
intent
.
getAction
().
equals
(
"com.google.android.c2dm.intent.REGISTRATION"
))
{
String
registration
=
intent
.
getStringExtra
(
"registration_id"
);
String
registration
=
intent
.
getStringExtra
(
"registration_id"
);
if
(
intent
.
getStringExtra
(
"error"
)
!=
null
)
{
if
(
intent
.
getStringExtra
(
"error"
)
!=
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
01103c6e
...
@@ -65,6 +65,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -65,6 +65,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
NotificationCenter
.
Instance
.
addObserver
(
this
,
FileLoader
.
FileDidLoaded
);
NotificationCenter
.
Instance
.
addObserver
(
this
,
FileLoader
.
FileDidLoaded
);
NotificationCenter
.
Instance
.
addObserver
(
this
,
FileLoader
.
FileLoadProgressChanged
);
NotificationCenter
.
Instance
.
addObserver
(
this
,
FileLoader
.
FileLoadProgressChanged
);
if
(
ConnectionsManager
.
enableAudio
)
{
Timer
progressTimer
=
new
Timer
();
Timer
progressTimer
=
new
Timer
();
progressTimer
.
schedule
(
new
TimerTask
()
{
progressTimer
.
schedule
(
new
TimerTask
()
{
@Override
@Override
...
@@ -97,6 +98,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
...
@@ -97,6 +98,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
}
},
100
,
17
);
},
100
,
17
);
}
}
}
public
void
cleanup
()
{
public
void
cleanup
()
{
clenupPlayer
(
false
);
clenupPlayer
(
false
);
...
...
TMessagesProj/src/main/java/org/telegram/objects/MessageObject.java
View file @
01103c6e
...
@@ -16,6 +16,7 @@ import android.text.StaticLayout;
...
@@ -16,6 +16,7 @@ import android.text.StaticLayout;
import
android.text.TextPaint
;
import
android.text.TextPaint
;
import
android.text.util.Linkify
;
import
android.text.util.Linkify
;
import
org.telegram.messenger.ConnectionsManager
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.TLObject
;
import
org.telegram.messenger.TLObject
;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.TLRPC
;
...
@@ -26,6 +27,7 @@ import org.telegram.messenger.UserConfig;
...
@@ -26,6 +27,7 @@ import org.telegram.messenger.UserConfig;
import
org.telegram.messenger.Utilities
;
import
org.telegram.messenger.Utilities
;
import
org.telegram.ui.ApplicationLoader
;
import
org.telegram.ui.ApplicationLoader
;
import
java.io.File
;
import
java.util.AbstractMap
;
import
java.util.AbstractMap
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -298,9 +300,17 @@ public class MessageObject {
...
@@ -298,9 +300,17 @@ public class MessageObject {
}
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaAudio
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
message
.
from_id
==
UserConfig
.
clientUserId
)
{
if
(
ConnectionsManager
.
enableAudio
)
{
type
=
18
;
type
=
18
;
}
else
{
}
else
{
type
=
0
;
}
}
else
{
if
(
ConnectionsManager
.
enableAudio
)
{
type
=
19
;
type
=
19
;
}
else
{
type
=
1
;
}
}
}
}
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
}
else
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
...
@@ -369,7 +379,7 @@ public class MessageObject {
...
@@ -369,7 +379,7 @@ public class MessageObject {
}
}
private
void
generateLayout
()
{
private
void
generateLayout
()
{
if
(
type
!=
0
&&
type
!=
1
&&
type
!=
8
&&
type
!=
9
||
messageOwner
.
to_id
==
null
||
messageText
==
null
||
messageText
.
length
()
==
0
||
!(
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)
&&
!(
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
&&
!(
messageOwner
.
media
==
null
)
)
{
if
(
type
!=
0
&&
type
!=
1
&&
type
!=
8
&&
type
!=
9
||
messageOwner
.
to_id
==
null
||
messageText
==
null
||
messageText
.
length
()
==
0
)
{
return
;
return
;
}
}
...
@@ -392,7 +402,15 @@ public class MessageObject {
...
@@ -392,7 +402,15 @@ public class MessageObject {
maxWidth
=
Math
.
min
(
Utilities
.
displaySize
.
x
,
Utilities
.
displaySize
.
y
)
-
Utilities
.
dp
(
80
);
maxWidth
=
Math
.
min
(
Utilities
.
displaySize
.
x
,
Utilities
.
displaySize
.
y
)
-
Utilities
.
dp
(
80
);
}
}
StaticLayout
textLayout
=
new
StaticLayout
(
messageText
,
textPaint
,
maxWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
StaticLayout
textLayout
=
null
;
try
{
textLayout
=
new
StaticLayout
(
messageText
,
textPaint
,
maxWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
return
;
}
textHeight
=
textLayout
.
getHeight
();
textHeight
=
textLayout
.
getHeight
();
int
linesCount
=
textLayout
.
getLineCount
();
int
linesCount
=
textLayout
.
getLineCount
();
...
@@ -416,18 +434,35 @@ public class MessageObject {
...
@@ -416,18 +434,35 @@ public class MessageObject {
continue
;
continue
;
}
}
block
.
charactersOffset
=
startCharacter
;
block
.
charactersOffset
=
startCharacter
;
try
{
CharSequence
str
=
messageText
.
subSequence
(
startCharacter
,
endCharacter
);
CharSequence
str
=
messageText
.
subSequence
(
startCharacter
,
endCharacter
);
block
.
textLayout
=
new
StaticLayout
(
str
,
textPaint
,
maxWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
block
.
textLayout
=
new
StaticLayout
(
str
,
textPaint
,
maxWidth
,
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
block
.
textYOffset
=
textLayout
.
getLineTop
(
linesOffset
);
block
.
textYOffset
=
textLayout
.
getLineTop
(
linesOffset
);
if
(
a
!=
blocksCount
-
1
)
{
if
(
a
!=
blocksCount
-
1
)
{
blockHeight
=
Math
.
min
(
blockHeight
,
block
.
textLayout
.
getHeight
());
blockHeight
=
Math
.
min
(
blockHeight
,
block
.
textLayout
.
getHeight
());
}
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
continue
;
}
}
}
textLayoutBlocks
.
add
(
block
);
textLayoutBlocks
.
add
(
block
);
float
lastLeft
=
block
.
textXOffset
=
block
.
textLayout
.
getLineLeft
(
currentBlockLinesCount
-
1
);
float
lastLeft
=
block
.
textXOffset
=
0
;
float
lastLine
=
block
.
textLayout
.
getLineWidth
(
currentBlockLinesCount
-
1
);
try
{
lastLeft
=
block
.
textXOffset
=
block
.
textLayout
.
getLineLeft
(
currentBlockLinesCount
-
1
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
float
lastLine
=
0
;
try
{
lastLine
=
block
.
textLayout
.
getLineWidth
(
currentBlockLinesCount
-
1
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
int
linesMaxWidth
;
int
linesMaxWidth
;
int
lastLineWidthWithLeft
;
int
lastLineWidthWithLeft
;
int
linesMaxWidthWithLeft
;
int
linesMaxWidthWithLeft
;
...
@@ -449,13 +484,20 @@ public class MessageObject {
...
@@ -449,13 +484,20 @@ public class MessageObject {
for
(
int
n
=
0
;
n
<
currentBlockLinesCount
;
++
n
)
{
for
(
int
n
=
0
;
n
<
currentBlockLinesCount
;
++
n
)
{
try
{
try
{
lineWidth
=
block
.
textLayout
.
getLineWidth
(
n
);
lineWidth
=
block
.
textLayout
.
getLineWidth
(
n
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
lineWidth
=
0
;
}
try
{
lineLeft
=
block
.
textLayout
.
getLineLeft
(
n
);
lineLeft
=
block
.
textLayout
.
getLineLeft
(
n
);
block
.
textXOffset
=
Math
.
min
(
block
.
textXOffset
,
lineLeft
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
FileLog
.
e
(
"tmessages"
,
e
);
return
;
lineLeft
=
0
;
}
}
block
.
textXOffset
=
Math
.
min
(
block
.
textXOffset
,
lineLeft
);
if
(
lineLeft
==
0
)
{
if
(
lineLeft
==
0
)
{
hasNonRTL
=
true
;
hasNonRTL
=
true
;
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsActivitySearchAdapter.java
View file @
01103c6e
...
@@ -67,6 +67,11 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
...
@@ -67,6 +67,11 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
}
}
private
void
processSearch
(
final
String
query
)
{
private
void
processSearch
(
final
String
query
)
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
final
ArrayList
<
TLRPC
.
TL_contact
>
contactsCopy
=
new
ArrayList
<
TLRPC
.
TL_contact
>();
contactsCopy
.
addAll
(
ContactsController
.
Instance
.
contacts
);
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -79,7 +84,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
...
@@ -79,7 +84,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
ArrayList
<
TLRPC
.
User
>
resultArray
=
new
ArrayList
<
TLRPC
.
User
>();
ArrayList
<
TLRPC
.
User
>
resultArray
=
new
ArrayList
<
TLRPC
.
User
>();
ArrayList
<
CharSequence
>
resultArrayNames
=
new
ArrayList
<
CharSequence
>();
ArrayList
<
CharSequence
>
resultArrayNames
=
new
ArrayList
<
CharSequence
>();
for
(
TLRPC
.
TL_contact
contact
:
ContactsController
.
Instance
.
contacts
)
{
for
(
TLRPC
.
TL_contact
contact
:
contactsCopy
)
{
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
);
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
);
if
(
user
.
first_name
!=
null
&&
user
.
first_name
.
toLowerCase
().
startsWith
(
q
)
||
user
.
last_name
!=
null
&&
user
.
last_name
.
toLowerCase
().
startsWith
(
q
))
{
if
(
user
.
first_name
!=
null
&&
user
.
first_name
.
toLowerCase
().
startsWith
(
q
)
||
user
.
last_name
!=
null
&&
user
.
last_name
.
toLowerCase
().
startsWith
(
q
))
{
if
(
user
.
id
==
UserConfig
.
clientUserId
)
{
if
(
user
.
id
==
UserConfig
.
clientUserId
)
{
...
@@ -94,6 +99,8 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
...
@@ -94,6 +99,8 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
}
}
});
});
}
}
});
}
private
void
updateSearchResults
(
final
ArrayList
<
TLRPC
.
User
>
users
,
final
ArrayList
<
CharSequence
>
names
)
{
private
void
updateSearchResults
(
final
ArrayList
<
TLRPC
.
User
>
users
,
final
ArrayList
<
CharSequence
>
names
)
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java
View file @
01103c6e
...
@@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable;
...
@@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable;
import
android.view.View
;
import
android.view.View
;
public
class
BaseCell
extends
View
{
public
class
BaseCell
extends
View
{
public
BaseCell
(
Context
context
)
{
public
BaseCell
(
Context
context
)
{
super
(
context
);
super
(
context
);
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
View file @
01103c6e
...
@@ -14,6 +14,7 @@ import android.text.Spannable;
...
@@ -14,6 +14,7 @@ import android.text.Spannable;
import
android.text.style.ClickableSpan
;
import
android.text.style.ClickableSpan
;
import
android.view.MotionEvent
;
import
android.view.MotionEvent
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.Utilities
;
import
org.telegram.messenger.Utilities
;
import
org.telegram.objects.MessageObject
;
import
org.telegram.objects.MessageObject
;
...
@@ -34,7 +35,7 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -34,7 +35,7 @@ public class ChatMessageCell extends ChatBaseCell {
@Override
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
if
(
currentMessageObject
!=
null
&&
currentMessageObject
.
messageText
instanceof
Spannable
&&
!
isPressed
)
{
if
(
currentMessageObject
!=
null
&&
currentMessageObject
.
textLayoutBlocks
!=
null
&&
!
currentMessageObject
.
textLayoutBlocks
.
isEmpty
()
&&
currentMessageObject
.
messageText
instanceof
Spannable
&&
!
isPressed
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
||
pressedLink
!=
null
&&
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
||
pressedLink
!=
null
&&
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
int
x
=
(
int
)
event
.
getX
();
int
x
=
(
int
)
event
.
getX
();
int
y
=
(
int
)
event
.
getY
();
int
y
=
(
int
)
event
.
getY
();
...
@@ -59,7 +60,11 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -59,7 +60,11 @@ public class ChatMessageCell extends ChatBaseCell {
return
true
;
return
true
;
}
else
{
}
else
{
if
(
link
[
0
]
==
pressedLink
)
{
if
(
link
[
0
]
==
pressedLink
)
{
try
{
pressedLink
.
onClick
(
this
);
pressedLink
.
onClick
(
this
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
true
;
return
true
;
}
}
}
}
...
@@ -83,6 +88,9 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -83,6 +88,9 @@ public class ChatMessageCell extends ChatBaseCell {
}
}
public
void
setVisiblePart
(
int
position
,
int
height
)
{
public
void
setVisiblePart
(
int
position
,
int
height
)
{
if
(
currentMessageObject
==
null
||
currentMessageObject
.
textLayoutBlocks
==
null
)
{
return
;
}
int
newFirst
=
-
1
,
newLast
=
-
1
,
newCount
=
0
;
int
newFirst
=
-
1
,
newLast
=
-
1
,
newCount
=
0
;
for
(
int
a
=
Math
.
max
(
0
,
(
position
-
textY
)
/
currentMessageObject
.
blockHeight
);
a
<
currentMessageObject
.
textLayoutBlocks
.
size
();
a
++)
{
for
(
int
a
=
Math
.
max
(
0
,
(
position
-
textY
)
/
currentMessageObject
.
blockHeight
);
a
<
currentMessageObject
.
textLayoutBlocks
.
size
();
a
++)
{
...
@@ -117,6 +125,10 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -117,6 +125,10 @@ public class ChatMessageCell extends ChatBaseCell {
@Override
@Override
public
void
setMessageObject
(
MessageObject
messageObject
)
{
public
void
setMessageObject
(
MessageObject
messageObject
)
{
if
(
currentMessageObject
!=
messageObject
||
isUserDataChanged
())
{
if
(
currentMessageObject
!=
messageObject
||
isUserDataChanged
())
{
if
(
currentMessageObject
!=
messageObject
)
{
firstVisibleBlockNum
=
0
;
lastVisibleBlockNum
=
0
;
}
pressedLink
=
null
;
pressedLink
=
null
;
int
maxWidth
;
int
maxWidth
;
if
(
chat
)
{
if
(
chat
)
{
...
@@ -160,6 +172,19 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -160,6 +172,19 @@ public class ChatMessageCell extends ChatBaseCell {
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
totalHeight
);
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
totalHeight
);
}
}
@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
)
{
textX
=
layoutWidth
-
backgroundWidth
+
Utilities
.
dp
(
10
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
else
{
textX
=
Utilities
.
dp
(
19
)
+
(
chat
?
Utilities
.
dp
(
52
)
:
0
);
textY
=
Utilities
.
dp
(
10
)
+
namesOffset
;
}
}
@Override
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
super
.
onDraw
(
canvas
);
...
@@ -176,10 +201,17 @@ public class ChatMessageCell extends ChatBaseCell {
...
@@ -176,10 +201,17 @@ public class ChatMessageCell extends ChatBaseCell {
}
}
for
(
int
a
=
firstVisibleBlockNum
;
a
<=
lastVisibleBlockNum
;
a
++)
{
for
(
int
a
=
firstVisibleBlockNum
;
a
<=
lastVisibleBlockNum
;
a
++)
{
if
(
a
>=
currentMessageObject
.
textLayoutBlocks
.
size
())
{
break
;
}
MessageObject
.
TextLayoutBlock
block
=
currentMessageObject
.
textLayoutBlocks
.
get
(
a
);
MessageObject
.
TextLayoutBlock
block
=
currentMessageObject
.
textLayoutBlocks
.
get
(
a
);
canvas
.
save
();
canvas
.
save
();
canvas
.
translate
(
textX
-
(
int
)
Math
.
ceil
(
block
.
textXOffset
),
textY
+
block
.
textYOffset
);
canvas
.
translate
(
textX
-
(
int
)
Math
.
ceil
(
block
.
textXOffset
),
textY
+
block
.
textYOffset
);
try
{
block
.
textLayout
.
draw
(
canvas
);
block
.
textLayout
.
draw
(
canvas
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
canvas
.
restore
();
canvas
.
restore
();
}
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
01103c6e
...
@@ -68,6 +68,7 @@ import android.widget.TextView;
...
@@ -68,6 +68,7 @@ import android.widget.TextView;
import
org.telegram.PhoneFormat.PhoneFormat
;
import
org.telegram.PhoneFormat.PhoneFormat
;
import
org.telegram.messenger.MediaController
;
import
org.telegram.messenger.MediaController
;
import
org.telegram.messenger.MessagesStorage
;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.ContactsController
;
import
org.telegram.messenger.ContactsController
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.FileLog
;
...
@@ -91,6 +92,7 @@ import org.telegram.ui.Views.LayoutListView;
...
@@ -91,6 +92,7 @@ import org.telegram.ui.Views.LayoutListView;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.OnSwipeTouchListener
;
import
org.telegram.ui.Views.OnSwipeTouchListener
;
import
org.telegram.ui.Views.SizeNotifierRelativeLayout
;
import
org.telegram.ui.Views.SizeNotifierRelativeLayout
;
import
org.telegram.ui.Views.TimerButton
;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -128,6 +130,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -128,6 +130,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
private
MessageObject
selectedObject
;
private
MessageObject
selectedObject
;
private
MessageObject
forwaringMessage
;
private
MessageObject
forwaringMessage
;
private
TextView
secretViewStatusTextView
;
private
TextView
secretViewStatusTextView
;
private
TimerButton
timerButton
;
private
Point
displaySize
=
new
Point
();
private
Point
displaySize
=
new
Point
();
private
boolean
paused
=
true
;
private
boolean
paused
=
true
;
private
boolean
readWhenResume
=
false
;
private
boolean
readWhenResume
=
false
;
...
@@ -777,8 +780,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -777,8 +780,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
private
void
checkSendButton
()
{
private
void
checkSendButton
()
{
// sendButton.setVisibility(View.VISIBLE);
if
(
ConnectionsManager
.
enableAudio
)
{
// audioSendButton.setVisibility(View.INVISIBLE);
if
(
messsageEditText
.
length
()
>
0
)
{
if
(
messsageEditText
.
length
()
>
0
)
{
sendButton
.
setVisibility
(
View
.
VISIBLE
);
sendButton
.
setVisibility
(
View
.
VISIBLE
);
audioSendButton
.
setVisibility
(
View
.
INVISIBLE
);
audioSendButton
.
setVisibility
(
View
.
INVISIBLE
);
...
@@ -786,6 +788,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -786,6 +788,10 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
sendButton
.
setVisibility
(
View
.
INVISIBLE
);
sendButton
.
setVisibility
(
View
.
INVISIBLE
);
audioSendButton
.
setVisibility
(
View
.
VISIBLE
);
audioSendButton
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
else
{
sendButton
.
setVisibility
(
View
.
VISIBLE
);
audioSendButton
.
setVisibility
(
View
.
INVISIBLE
);
}
}
}
private
void
updateAudioRecordIntefrace
()
{
private
void
updateAudioRecordIntefrace
()
{
...
@@ -1172,6 +1178,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1172,6 +1178,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
parentActivity
.
getWindow
().
getDecorView
().
getWindowVisibleDisplayFrame
(
localRect
);
parentActivity
.
getWindow
().
getDecorView
().
getWindowVisibleDisplayFrame
(
localRect
);
WindowManager
manager
=
(
WindowManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Activity
.
WINDOW_SERVICE
);
WindowManager
manager
=
(
WindowManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Activity
.
WINDOW_SERVICE
);
if
(
manager
==
null
||
manager
.
getDefaultDisplay
()
==
null
)
{
return
;
}
int
rotation
=
manager
.
getDefaultDisplay
().
getRotation
();
int
rotation
=
manager
.
getDefaultDisplay
().
getRotation
();
if
(
height
>
Emoji
.
scale
(
50
))
{
if
(
height
>
Emoji
.
scale
(
50
))
{
...
@@ -1638,6 +1647,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1638,6 +1647,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
boolean
currentMarkAsRead
=
false
;
boolean
currentMarkAsRead
=
false
;
for
(
MessageObject
obj
:
arr
)
{
for
(
MessageObject
obj
:
arr
)
{
if
(
currentEncryptedChat
!=
null
&&
obj
.
messageOwner
.
action
!=
null
&&
obj
.
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionTTLChange
&&
timerButton
!=
null
)
{
timerButton
.
setTime
(
obj
.
messageOwner
.
action
.
ttl
);
}
if
(
messagesDict
.
containsKey
(
obj
.
messageOwner
.
id
))
{
if
(
messagesDict
.
containsKey
(
obj
.
messageOwner
.
id
))
{
continue
;
continue
;
}
}
...
@@ -1673,6 +1685,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -1673,6 +1685,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
boolean
markAsRead
=
false
;
boolean
markAsRead
=
false
;
int
oldCount
=
messages
.
size
();
int
oldCount
=
messages
.
size
();
for
(
MessageObject
obj
:
arr
)
{
for
(
MessageObject
obj
:
arr
)
{
if
(
currentEncryptedChat
!=
null
&&
obj
.
messageOwner
.
action
!=
null
&&
obj
.
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionTTLChange
&&
timerButton
!=
null
)
{
timerButton
.
setTime
(
obj
.
messageOwner
.
action
.
ttl
);
}
if
(
messagesDict
.
containsKey
(
obj
.
messageOwner
.
id
))
{
if
(
messagesDict
.
containsKey
(
obj
.
messageOwner
.
id
))
{
continue
;
continue
;
}
}
...
@@ -2356,12 +2371,71 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
...
@@ -2356,12 +2371,71 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
@Override
@Override
public
void
onCreateOptionsMenu
(
Menu
menu
,
MenuInflater
inflater
)
{
public
void
onCreateOptionsMenu
(
Menu
menu
,
MenuInflater
inflater
)
{
menu
.
clear
();
menu
.
clear
();
if
(
currentEncryptedChat
!=
null
)
{
inflater
.
inflate
(
R
.
menu
.
chat_enc_menu
,
menu
);
}
else
{
inflater
.
inflate
(
R
.
menu
.
chat_menu
,
menu
);
inflater
.
inflate
(
R
.
menu
.
chat_menu
,
menu
);
}
SupportMenuItem
timeItem
=
(
SupportMenuItem
)
menu
.
findItem
(
R
.
id
.
chat_enc_timer
);
if
(
currentEncryptedChat
!=
null
&&
!(
currentEncryptedChat
instanceof
TLRPC
.
TL_encryptedChat
)
||
currentChat
!=
null
&&
(
currentChat
instanceof
TLRPC
.
TL_chatForbidden
||
currentChat
.
left
))
{
if
(
currentEncryptedChat
!=
null
&&
!(
currentEncryptedChat
instanceof
TLRPC
.
TL_encryptedChat
)
||
currentChat
!=
null
&&
(
currentChat
instanceof
TLRPC
.
TL_chatForbidden
||
currentChat
.
left
))
{
SupportMenuItem
item
=
(
SupportMenuItem
)
menu
.
findItem
(
R
.
id
.
chat_menu_attach
);
SupportMenuItem
item
=
(
SupportMenuItem
)
menu
.
findItem
(
R
.
id
.
chat_menu_attach
);
if
(
item
!=
null
)
{
item
.
setVisible
(
false
);
item
.
setVisible
(
false
);
}
}
if
(
timeItem
!=
null
)
{
timeItem
.
setVisible
(
false
);
}
}
if
(
timeItem
!=
null
&&
timeItem
.
getActionView
()
!=
null
)
{
timerButton
=
(
TimerButton
)
timeItem
.
getActionView
().
findViewById
(
R
.
id
.
chat_timer
);
timerButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
parentActivity
);
builder
.
setTitle
(
getStringEntry
(
R
.
string
.
MessageLifetime
));
builder
.
setItems
(
new
CharSequence
[]{
getStringEntry
(
R
.
string
.
ShortMessageLifetimeForever
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime2s
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime5s
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime1m
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime1h
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime1d
),
getStringEntry
(
R
.
string
.
ShortMessageLifetime1w
)
},
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
int
oldValue
=
currentEncryptedChat
.
ttl
;
if
(
which
==
0
)
{
currentEncryptedChat
.
ttl
=
0
;
}
else
if
(
which
==
1
)
{
currentEncryptedChat
.
ttl
=
2
;
}
else
if
(
which
==
2
)
{
currentEncryptedChat
.
ttl
=
5
;
}
else
if
(
which
==
3
)
{
currentEncryptedChat
.
ttl
=
60
;
}
else
if
(
which
==
4
)
{
currentEncryptedChat
.
ttl
=
60
*
60
;
}
else
if
(
which
==
5
)
{
currentEncryptedChat
.
ttl
=
60
*
60
*
24
;
}
else
if
(
which
==
6
)
{
currentEncryptedChat
.
ttl
=
60
*
60
*
24
*
7
;
}
if
(
oldValue
!=
currentEncryptedChat
.
ttl
)
{
MessagesController
.
Instance
.
sendTTLMessage
(
currentEncryptedChat
);
MessagesStorage
.
Instance
.
updateEncryptedChat
(
currentEncryptedChat
);
}
}
});
builder
.
setNegativeButton
(
getStringEntry
(
R
.
string
.
Cancel
),
null
);
builder
.
show
().
setCanceledOnTouchOutside
(
true
);
}
});
timerButton
.
setTime
(
currentEncryptedChat
.
ttl
);
}
SupportMenuItem
avatarItem
=
(
SupportMenuItem
)
menu
.
findItem
(
R
.
id
.
chat_menu_avatar
);
SupportMenuItem
avatarItem
=
(
SupportMenuItem
)
menu
.
findItem
(
R
.
id
.
chat_menu_avatar
);
View
avatarLayout
=
avatarItem
.
getActionView
();
View
avatarLayout
=
avatarItem
.
getActionView
();
avatarImageView
=
(
BackupImageView
)
avatarLayout
.
findViewById
(
R
.
id
.
chat_avatar_image
);
avatarImageView
=
(
BackupImageView
)
avatarLayout
.
findViewById
(
R
.
id
.
chat_avatar_image
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/GalleryImageViewer.java
View file @
01103c6e
...
@@ -691,6 +691,9 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
...
@@ -691,6 +691,9 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
break
;
break
;
case
R
.
id
.
gallery_menu_save
:
case
R
.
id
.
gallery_menu_save
:
TLRPC
.
FileLocation
file
=
getCurrentFile
();
TLRPC
.
FileLocation
file
=
getCurrentFile
();
if
(
file
==
null
)
{
return
;
}
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
file
.
volume_id
+
"_"
+
file
.
local_id
+
".jpg"
);
File
f
=
new
File
(
Utilities
.
getCacheDir
(),
file
.
volume_id
+
"_"
+
file
.
local_id
+
".jpg"
);
File
dstFile
=
Utilities
.
generatePicturePath
();
File
dstFile
=
Utilities
.
generatePicturePath
();
try
{
try
{
...
@@ -710,7 +713,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
...
@@ -710,7 +713,7 @@ public class GalleryImageViewer extends AbstractGalleryActivity implements Notif
if
(
fromAll
)
{
if
(
fromAll
)
{
finish
();
finish
();
}
else
{
}
else
{
if
(!
localPagerAdapter
.
imagesArr
.
isEmpty
()
&&
currentDialog
!=
0
)
{
if
(
localPagerAdapter
!=
null
&&
localPagerAdapter
.
imagesArr
!=
null
&&
!
localPagerAdapter
.
imagesArr
.
isEmpty
()
&&
currentDialog
!=
0
)
{
finish
();
finish
();
NotificationCenter
.
Instance
.
postNotificationName
(
needShowAllMedia
,
currentDialog
);
NotificationCenter
.
Instance
.
postNotificationName
(
needShowAllMedia
,
currentDialog
);
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java
View file @
01103c6e
...
@@ -361,6 +361,11 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
...
@@ -361,6 +361,11 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
private
void
processSearch
(
final
String
query
)
{
private
void
processSearch
(
final
String
query
)
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
final
ArrayList
<
TLRPC
.
TL_contact
>
contactsCopy
=
new
ArrayList
<
TLRPC
.
TL_contact
>();
contactsCopy
.
addAll
(
ContactsController
.
Instance
.
contacts
);
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
Utilities
.
globalQueue
.
postRunnable
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
...
@@ -373,7 +378,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
...
@@ -373,7 +378,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
ArrayList
<
CharSequence
>
resultArrayNames
=
new
ArrayList
<
CharSequence
>();
ArrayList
<
CharSequence
>
resultArrayNames
=
new
ArrayList
<
CharSequence
>();
String
q
=
query
.
toLowerCase
();
String
q
=
query
.
toLowerCase
();
for
(
TLRPC
.
TL_contact
contact
:
ContactsController
.
Instance
.
contacts
)
{
for
(
TLRPC
.
TL_contact
contact
:
contactsCopy
)
{
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
);
TLRPC
.
User
user
=
MessagesController
.
Instance
.
users
.
get
(
contact
.
user_id
);
if
(
user
.
first_name
.
toLowerCase
().
startsWith
(
q
)
||
user
.
last_name
.
toLowerCase
().
startsWith
(
q
))
{
if
(
user
.
first_name
.
toLowerCase
().
startsWith
(
q
)
||
user
.
last_name
.
toLowerCase
().
startsWith
(
q
))
{
if
(
user
.
id
==
UserConfig
.
clientUserId
)
{
if
(
user
.
id
==
UserConfig
.
clientUserId
)
{
...
@@ -388,6 +393,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
...
@@ -388,6 +393,8 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
});
});
}
}
});
}
private
void
updateSearchResults
(
final
ArrayList
<
TLRPC
.
User
>
users
,
final
ArrayList
<
CharSequence
>
names
)
{
private
void
updateSearchResults
(
final
ArrayList
<
TLRPC
.
User
>
users
,
final
ArrayList
<
CharSequence
>
names
)
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
01103c6e
...
@@ -132,7 +132,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -132,7 +132,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
ApplicationLoader
.
fragmentsStack
.
add
(
fragment
);
ApplicationLoader
.
fragmentsStack
.
add
(
fragment
);
}
}
handleIntent
(
getIntent
(),
false
);
handleIntent
(
getIntent
(),
false
,
savedInstanceState
!=
null
);
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -164,7 +164,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -164,7 +164,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
getSupportActionBar
().
hide
();
getSupportActionBar
().
hide
();
}
}
private
void
handleIntent
(
Intent
intent
,
boolean
isNew
)
{
private
void
handleIntent
(
Intent
intent
,
boolean
isNew
,
boolean
restore
)
{
boolean
pushOpened
=
false
;
boolean
pushOpened
=
false
;
Integer
push_user_id
=
0
;
Integer
push_user_id
=
0
;
...
@@ -179,7 +179,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -179,7 +179,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
imagesPathArray
=
null
;
imagesPathArray
=
null
;
documentsPathArray
=
null
;
documentsPathArray
=
null
;
if
(
intent
!=
null
&&
intent
.
getAction
()
!=
null
)
{
if
(
intent
!=
null
&&
intent
.
getAction
()
!=
null
&&
!
restore
)
{
if
(
Intent
.
ACTION_SEND
.
equals
(
intent
.
getAction
()))
{
if
(
Intent
.
ACTION_SEND
.
equals
(
intent
.
getAction
()))
{
boolean
error
=
false
;
boolean
error
=
false
;
String
type
=
intent
.
getType
();
String
type
=
intent
.
getType
();
...
@@ -282,7 +282,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -282,7 +282,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
}
}
}
}
if
((
getIntent
().
getFlags
()
&
Intent
.
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
)
==
0
)
{
if
((
getIntent
().
getFlags
()
&
Intent
.
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
)
==
0
&&
!
restore
)
{
int
chatId
=
getIntent
().
getIntExtra
(
"chatId"
,
0
);
int
chatId
=
getIntent
().
getIntExtra
(
"chatId"
,
0
);
int
userId
=
getIntent
().
getIntExtra
(
"userId"
,
0
);
int
userId
=
getIntent
().
getIntExtra
(
"userId"
,
0
);
int
encId
=
getIntent
().
getIntExtra
(
"encId"
,
0
);
int
encId
=
getIntent
().
getIntExtra
(
"encId"
,
0
);
...
@@ -373,7 +373,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -373,7 +373,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
@Override
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
super
.
onNewIntent
(
intent
);
handleIntent
(
intent
,
true
);
handleIntent
(
intent
,
true
,
false
);
}
}
@Override
@Override
...
@@ -750,8 +750,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
...
@@ -750,8 +750,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
fTrans
.
setCustomAnimations
(
R
.
anim
.
scale_in
,
R
.
anim
.
no_anim
);
fTrans
.
setCustomAnimations
(
R
.
anim
.
scale_in
,
R
.
anim
.
no_anim
);
}
}
}
}
try
{
fTrans
.
replace
(
R
.
id
.
container
,
fragment
,
tag
);
fTrans
.
replace
(
R
.
id
.
container
,
fragment
,
tag
);
fTrans
.
commitAllowingStateLoss
();
fTrans
.
commitAllowingStateLoss
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
ApplicationLoader
.
fragmentsStack
.
add
(
fragment
);
ApplicationLoader
.
fragmentsStack
.
add
(
fragment
);
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
View file @
01103c6e
...
@@ -141,6 +141,9 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
...
@@ -141,6 +141,9 @@ public class LoginActivity extends ActionBarActivity implements SlideView.SlideV
@Override
@Override
public
void
needShowAlert
(
String
text
)
{
public
void
needShowAlert
(
String
text
)
{
if
(
text
==
null
)
{
return
;
}
ShowAlertDialog
(
LoginActivity
.
this
,
text
);
ShowAlertDialog
(
LoginActivity
.
this
,
text
);
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/LoginActivityPhoneView.java
View file @
01103c6e
...
@@ -264,6 +264,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
...
@@ -264,6 +264,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
ignoreOnTextChange
=
true
;
ignoreOnTextChange
=
true
;
codeField
.
setText
(
countriesMap
.
get
(
name
));
codeField
.
setText
(
countriesMap
.
get
(
name
));
countryButton
.
setText
(
name
);
countryButton
.
setText
(
name
);
countryState
=
0
;
}
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
View file @
01103c6e
...
@@ -270,6 +270,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
...
@@ -270,6 +270,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
Utilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
parentActivity
==
null
)
{
return
;
}
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putInt
(
"support_id"
,
res
.
user
.
id
);
editor
.
putInt
(
"support_id"
,
res
.
user
.
id
);
SerializedData
data
=
new
SerializedData
();
SerializedData
data
=
new
SerializedData
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/TimerButton.java
0 → 100644
View file @
01103c6e
/*
* This is the source code of Telegram for Android v. 1.3.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
.
Views
;
import
android.content.Context
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.Typeface
;
import
android.graphics.drawable.Drawable
;
import
android.text.Layout
;
import
android.text.StaticLayout
;
import
android.text.TextPaint
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.R
;
import
org.telegram.messenger.Utilities
;
public
class
TimerButton
extends
View
{
private
static
Drawable
emptyTimerDrawable
;
private
static
Drawable
timerDrawable
;
private
static
TextPaint
timePaint
;
private
StaticLayout
timeLayout
;
private
float
timeWidth
=
0
;
private
int
timeHeight
=
0
;
private
int
time
=
0
;
private
void
init
()
{
if
(
emptyTimerDrawable
==
null
)
{
emptyTimerDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
header_timer
);
timerDrawable
=
getResources
().
getDrawable
(
R
.
drawable
.
header_timer2
);
timePaint
=
new
TextPaint
(
Paint
.
ANTI_ALIAS_FLAG
);
timePaint
.
setTextSize
(
Utilities
.
dp
(
10
));
timePaint
.
setColor
(
0xffd7e8f7
);
timePaint
.
setTypeface
(
Typeface
.
DEFAULT_BOLD
);
}
setBackgroundResource
(
R
.
drawable
.
bar_selector
);
}
public
TimerButton
(
Context
context
)
{
super
(
context
);
init
();
}
public
TimerButton
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
();
}
public
TimerButton
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
init
();
}
public
void
setTime
(
int
value
)
{
time
=
value
;
String
timeString
=
null
;
if
(
time
==
2
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime2s
);
}
else
if
(
time
==
5
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime5s
);
}
else
if
(
time
==
60
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime1m
);
}
else
if
(
time
==
60
*
60
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime1h
);
}
else
if
(
time
==
60
*
60
*
24
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime1d
);
}
else
if
(
time
==
60
*
60
*
24
*
7
)
{
timeString
=
getResources
().
getString
(
R
.
string
.
ShortMessageLifetime1w
);
}
else
{
timeString
=
"c"
;
}
timeWidth
=
timePaint
.
measureText
(
timeString
);
try
{
timeLayout
=
new
StaticLayout
(
timeString
,
timePaint
,
(
int
)
Math
.
ceil
(
timeWidth
),
Layout
.
Alignment
.
ALIGN_NORMAL
,
1.0f
,
0.0f
,
false
);
timeHeight
=
timeLayout
.
getHeight
();
}
catch
(
Exception
e
)
{
timeLayout
=
null
;
FileLog
.
e
(
"tmessages"
,
e
);
}
invalidate
();
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
int
width
=
getMeasuredWidth
();
int
height
=
getMeasuredHeight
();
Drawable
drawable
=
null
;
if
(
time
==
0
)
{
drawable
=
timerDrawable
;
}
else
{
drawable
=
emptyTimerDrawable
;
}
int
x
=
(
width
-
drawable
.
getIntrinsicWidth
())
/
2
;
int
y
=
(
height
-
drawable
.
getIntrinsicHeight
())
/
2
;
drawable
.
setBounds
(
x
,
y
,
x
+
drawable
.
getIntrinsicWidth
(),
y
+
drawable
.
getIntrinsicHeight
());
drawable
.
draw
(
canvas
);
if
(
time
!=
0
&&
timeLayout
!=
null
)
{
canvas
.
translate
((
width
-
timeWidth
)
/
2
,
(
height
-
timeHeight
)
/
2
+
Utilities
.
dp
(
1
));
timeLayout
.
draw
(
canvas
);
}
}
}
TMessagesProj/src/main/res/drawable-hdpi/header_timer.png
0 → 100755
View file @
01103c6e
1.01 KB
TMessagesProj/src/main/res/drawable-hdpi/header_timer2.png
0 → 100755
View file @
01103c6e
1.05 KB
TMessagesProj/src/main/res/drawable-ldpi/header_timer.png
0 → 100755
View file @
01103c6e
542 Bytes
TMessagesProj/src/main/res/drawable-ldpi/header_timer2.png
0 → 100755
View file @
01103c6e
558 Bytes
TMessagesProj/src/main/res/drawable-mdpi/header_timer.png
0 → 100755
View file @
01103c6e
698 Bytes
TMessagesProj/src/main/res/drawable-mdpi/header_timer2.png
0 → 100755
View file @
01103c6e
715 Bytes
TMessagesProj/src/main/res/drawable-xhdpi/header_timer.png
0 → 100755
View file @
01103c6e
1.25 KB
TMessagesProj/src/main/res/drawable-xhdpi/header_timer2.png
0 → 100755
View file @
01103c6e
1.3 KB
TMessagesProj/src/main/res/drawable-xxhdpi/header_timer.png
0 → 100755
View file @
01103c6e
1.88 KB
TMessagesProj/src/main/res/drawable-xxhdpi/header_timer2.png
0 → 100755
View file @
01103c6e
1.98 KB
TMessagesProj/src/main/res/layout/chat_header_enc_layout.xml
0 → 100644
View file @
01103c6e
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
>
<org.telegram.ui.Views.TimerButton
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_height=
"fill_parent"
android:layout_width=
"48dp"
android:id=
"@+id/chat_timer"
/>
</RelativeLayout>
\ No newline at end of file
TMessagesProj/src/main/res/menu/chat_enc_menu.xml
0 → 100644
View file @
01103c6e
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:sabd=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/chat_enc_timer"
sabd:showAsAction=
"always"
sabd:actionLayout=
"@layout/chat_header_enc_layout"
/>
<item
android:id=
"@+id/chat_menu_attach"
android:icon=
"@drawable/ic_ab_attach"
android:title=
"@string/Attach"
sabd:showAsAction=
"always"
>
<menu>
<item
android:icon=
"@drawable/ic_attach_photo"
android:title=
"@string/ChatTakePhoto"
android:id=
"@+id/attach_photo"
/>
<item
android:icon=
"@drawable/ic_attach_gallery"
android:title=
"@string/ChatGallery"
android:id=
"@+id/attach_gallery"
/>
<item
android:icon=
"@drawable/ic_attach_video"
android:title=
"@string/ChatVideo"
android:id=
"@+id/attach_video"
/>
<item
android:icon=
"@drawable/ic_ab_doc"
android:title=
"@string/ChatDocument"
android:id=
"@+id/attach_document"
/>
<item
android:icon=
"@drawable/ic_attach_location"
android:title=
"@string/ChatLocation"
android:id=
"@+id/attach_location"
/>
</menu>
</item>
<item
android:id=
"@+id/chat_menu_avatar"
sabd:showAsAction=
"always"
sabd:actionLayout=
"@layout/chat_header_layout"
/>
</menu>
\ No newline at end of file
TMessagesProj/src/main/res/values-de/strings.xml
View file @
01103c6e
...
@@ -240,7 +240,7 @@
...
@@ -240,7 +240,7 @@
<string
name=
"Support"
>
SUPPORT
</string>
<string
name=
"Support"
>
SUPPORT
</string>
<string
name=
"ChatBackground"
>
Chat-Hintergrundbild
</string>
<string
name=
"ChatBackground"
>
Chat-Hintergrundbild
</string>
<string
name=
"MessagesSettings"
>
NACHRICHTEN
</string>
<string
name=
"MessagesSettings"
>
NACHRICHTEN
</string>
<string
name=
"SendByEnter"
>
Mit
<![CDATA[<b>Enter</b>]]>
senden
</string>
<string
name=
"SendByEnter"
>
Mit
Enter
senden
</string>
<string
name=
"TerminateAllSessions"
>
Alle anderen Sitzungen beenden
</string>
<string
name=
"TerminateAllSessions"
>
Alle anderen Sitzungen beenden
</string>
<string
name=
"AutomaticPhotoDownload"
>
AUTOMATISCHER BILDERDOWNLOAD
</string>
<string
name=
"AutomaticPhotoDownload"
>
AUTOMATISCHER BILDERDOWNLOAD
</string>
<string
name=
"AutomaticPhotoDownloadGroups"
>
Gruppen
</string>
<string
name=
"AutomaticPhotoDownloadGroups"
>
Gruppen
</string>
...
...
TMessagesProj/src/main/res/values-nl/strings.xml
0 → 100644
View file @
01103c6e
This diff is collapsed.
Click to expand it.
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