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
22918f14
Commit
22918f14
authored
Mar 27, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed photo sharing on devices with low memory
parent
0e9d92e8
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
447 additions
and
62 deletions
+447
-62
build.gradle
TMessagesProj/build.gradle
+1
-1
LocaleController.java
...rc/main/java/org/telegram/messenger/LocaleController.java
+4
-1
MediaController.java
...src/main/java/org/telegram/messenger/MediaController.java
+20
-16
MessagesStorage.java
...src/main/java/org/telegram/messenger/MessagesStorage.java
+105
-0
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+92
-12
ChatProfileActivity.java
...oj/src/main/java/org/telegram/ui/ChatProfileActivity.java
+6
-4
GroupCreateActivity.java
...oj/src/main/java/org/telegram/ui/GroupCreateActivity.java
+5
-4
GroupCreateFinalActivity.java
...c/main/java/org/telegram/ui/GroupCreateFinalActivity.java
+71
-4
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+65
-0
SettingsActivity.java
...sProj/src/main/java/org/telegram/ui/SettingsActivity.java
+15
-2
SettingsNotificationsActivity.java
...n/java/org/telegram/ui/SettingsNotificationsActivity.java
+5
-3
SettingsWallpapersActivity.java
...main/java/org/telegram/ui/SettingsWallpapersActivity.java
+20
-6
UserProfileActivity.java
...oj/src/main/java/org/telegram/ui/UserProfileActivity.java
+6
-4
AvatarUpdater.java
...oj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java
+4
-4
BaseFragment.java
...roj/src/main/java/org/telegram/ui/Views/BaseFragment.java
+28
-1
No files found.
TMessagesProj/build.gradle
View file @
22918f14
...
...
@@ -82,7 +82,7 @@ android {
defaultConfig
{
minSdkVersion
8
targetSdkVersion
19
versionCode
21
2
versionCode
21
3
versionName
"1.4.9"
}
}
TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
View file @
22918f14
...
...
@@ -26,6 +26,7 @@ import java.util.Locale;
public
class
LocaleController
{
public
static
boolean
isRTL
=
false
;
private
static
boolean
is24HourFormat
=
false
;
public
static
FastDateFormat
formatterDay
;
public
static
FastDateFormat
formatterWeek
;
public
static
FastDateFormat
formatterMonth
;
...
...
@@ -121,6 +122,7 @@ public class LocaleController {
sortedLanguages
.
add
(
0
,
localeInfo
);
systemDefaultLocale
=
Locale
.
getDefault
();
is24HourFormat
=
DateFormat
.
is24HourFormat
(
ApplicationLoader
.
applicationContext
);
LocaleInfo
currentInfo
=
null
;
boolean
override
=
false
;
...
...
@@ -226,6 +228,7 @@ public class LocaleController {
if
(
changingConfiguration
)
{
return
;
}
is24HourFormat
=
DateFormat
.
is24HourFormat
(
ApplicationLoader
.
applicationContext
);
systemDefaultLocale
=
newConfig
.
locale
;
if
(
languageOverride
!=
null
)
{
LocaleInfo
toSet
=
currentLocaleInfo
;
...
...
@@ -324,7 +327,7 @@ public class LocaleController {
formatterWeek
=
FastDateFormat
.
getInstance
(
"EEE"
,
locale
);
if
(
lang
!=
null
)
{
if
(
DateFormat
.
is24HourFormat
(
ApplicationLoader
.
applicationContext
)
)
{
if
(
is24HourFormat
)
{
formatterDay
=
FastDateFormat
.
getInstance
(
"HH:mm"
,
locale
);
}
else
{
if
(
lang
.
toLowerCase
().
equals
(
"ar"
))
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
View file @
22918f14
...
...
@@ -831,26 +831,30 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
recordDialogId
=
dialog_id
;
fileBuffer
.
rewind
();
/*if (android.os.Build.VERSION.SDK_INT >= 16) { some devices crash with it
AutomaticGainControl agc = null;
try {
if (AutomaticGainControl.isAvailable()) {
agc = AutomaticGainControl.create(audioRecorder.getAudioSessionId());
agc.setEnabled(true);
audioGainObj = agc;
}
} catch (Exception e) {
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
16
)
{
File
f
=
new
File
(
"/vendor/lib/libaudioeffect_jni.so"
);
File
f2
=
new
File
(
"/system/lib/libaudioeffect_jni.so"
);
if
(
f
.
exists
()
||
f2
.
exists
())
{
AutomaticGainControl
agc
=
null
;
try
{
if (agc != null) {
agc.release();
agc = null;
if
(
AutomaticGainControl
.
isAvailable
())
{
agc
=
AutomaticGainControl
.
create
(
audioRecorder
.
getAudioSessionId
());
agc
.
setEnabled
(
true
);
audioGainObj
=
agc
;
}
}
catch
(
Exception
e
)
{
try
{
if
(
agc
!=
null
)
{
agc
.
release
();
agc
=
null
;
}
}
catch
(
Exception
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
FileLog
.
e
(
"tmessages"
,
e
);
}
FileLog.e("tmessages", e);
}
}
*/
}
audioRecorder
.
startRecording
();
}
catch
(
Exception
e
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
View file @
22918f14
...
...
@@ -2825,4 +2825,109 @@ public class MessagesStorage {
}
});
}
public
TLRPC
.
User
getUser
(
final
int
user_id
)
{
TLRPC
.
User
user
=
null
;
try
{
SQLiteCursor
cursor
=
database
.
queryFinalized
(
String
.
format
(
Locale
.
US
,
"SELECT data, status FROM users WHERE uid = %d"
,
user_id
));
if
(
cursor
.
next
())
{
byte
[]
userData
=
cursor
.
byteArrayValue
(
0
);
if
(
userData
!=
null
)
{
SerializedData
data
=
new
SerializedData
(
userData
);
user
=
(
TLRPC
.
User
)
TLClassStore
.
Instance
().
TLdeserialize
(
data
,
data
.
readInt32
());
if
(
user
!=
null
)
{
if
(
user
.
status
!=
null
)
{
user
.
status
.
expires
=
cursor
.
intValue
(
1
);
}
}
}
}
cursor
.
dispose
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
user
;
}
public
ArrayList
<
TLRPC
.
User
>
getUsers
(
final
ArrayList
<
Integer
>
uids
,
final
boolean
[]
error
)
{
ArrayList
<
TLRPC
.
User
>
users
=
new
ArrayList
<
TLRPC
.
User
>();
try
{
String
uidsStr
=
""
;
for
(
Integer
uid
:
uids
)
{
if
(
uidsStr
.
length
()
!=
0
)
{
uidsStr
+=
","
;
}
uidsStr
+=
uid
;
}
SQLiteCursor
cursor
=
database
.
queryFinalized
(
String
.
format
(
Locale
.
US
,
"SELECT data, status FROM users WHERE uid IN (%s)"
,
uidsStr
));
while
(
cursor
.
next
())
{
byte
[]
userData
=
cursor
.
byteArrayValue
(
0
);
if
(
userData
!=
null
)
{
SerializedData
data
=
new
SerializedData
(
userData
);
TLRPC
.
User
user
=
(
TLRPC
.
User
)
TLClassStore
.
Instance
().
TLdeserialize
(
data
,
data
.
readInt32
());
if
(
user
!=
null
)
{
if
(
user
.
status
!=
null
)
{
user
.
status
.
expires
=
cursor
.
intValue
(
1
);
}
users
.
add
(
user
);
}
else
{
error
[
0
]
=
true
;
break
;
}
}
else
{
error
[
0
]
=
true
;
break
;
}
}
cursor
.
dispose
();
}
catch
(
Exception
e
)
{
error
[
0
]
=
true
;
FileLog
.
e
(
"tmessages"
,
e
);
}
return
users
;
}
public
TLRPC
.
Chat
getChat
(
final
int
chat_id
)
{
TLRPC
.
Chat
chat
=
null
;
try
{
SQLiteCursor
cursor
=
database
.
queryFinalized
(
String
.
format
(
Locale
.
US
,
"SELECT data FROM chats WHERE uid = %d"
,
chat_id
));
if
(
cursor
.
next
())
{
byte
[]
chatData
=
cursor
.
byteArrayValue
(
0
);
if
(
chatData
!=
null
)
{
SerializedData
data
=
new
SerializedData
(
chatData
);
chat
=
(
TLRPC
.
Chat
)
TLClassStore
.
Instance
().
TLdeserialize
(
data
,
data
.
readInt32
());
}
}
cursor
.
dispose
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
chat
;
}
public
TLRPC
.
EncryptedChat
getEncryptedChat
(
final
int
chat_id
)
{
TLRPC
.
EncryptedChat
chat
=
null
;
try
{
SQLiteCursor
cursor
=
database
.
queryFinalized
(
String
.
format
(
Locale
.
US
,
"SELECT data, user, g, authkey, ttl FROM enc_chats WHERE uid = %d"
,
chat_id
));
if
(
cursor
.
next
())
{
byte
[]
chatData
=
cursor
.
byteArrayValue
(
0
);
if
(
chatData
!=
null
)
{
SerializedData
data
=
new
SerializedData
(
chatData
);
chat
=
(
TLRPC
.
EncryptedChat
)
TLClassStore
.
Instance
().
TLdeserialize
(
data
,
data
.
readInt32
());
if
(
chat
!=
null
)
{
chat
.
user_id
=
cursor
.
intValue
(
1
);
chat
.
a_or_b
=
cursor
.
byteArrayValue
(
2
);
chat
.
auth_key
=
cursor
.
byteArrayValue
(
3
);
chat
.
ttl
=
cursor
.
intValue
(
4
);
}
}
}
cursor
.
dispose
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
return
chat
;
}
}
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
22918f14
...
...
@@ -104,6 +104,7 @@ import java.util.Collections;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.concurrent.Semaphore
;
public
class
ChatActivity
extends
BaseFragment
implements
SizeNotifierRelativeLayout
.
SizeNotifierRelativeLayoutDelegate
,
NotificationCenter
.
NotificationCenterDelegate
,
MessagesActivity
.
MessagesActivityDelegate
,
DocumentSelectActivity
.
DocumentSelectActivityDelegate
{
private
LayoutListView
chatListView
;
...
...
@@ -288,31 +289,99 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
@Override
public
boolean
onFragmentCreate
()
{
super
.
onFragmentCreate
();
int
chatId
=
getArguments
().
getInt
(
"chat_id"
,
0
);
int
userId
=
getArguments
().
getInt
(
"user_id"
,
0
);
int
encId
=
getArguments
().
getInt
(
"enc_id"
,
0
);
final
int
chatId
=
getArguments
().
getInt
(
"chat_id"
,
0
);
final
int
userId
=
getArguments
().
getInt
(
"user_id"
,
0
);
final
int
encId
=
getArguments
().
getInt
(
"enc_id"
,
0
);
if
(
chatId
!=
0
)
{
currentChat
=
MessagesController
.
getInstance
().
chats
.
get
(
chatId
);
if
(
currentChat
==
null
)
{
return
false
;
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
MessagesStorage
.
getInstance
().
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
currentChat
=
MessagesStorage
.
getInstance
().
getChat
(
chatId
);
semaphore
.
release
();
}
});
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(
currentChat
!=
null
)
{
MessagesController
.
getInstance
().
chats
.
put
(
currentChat
.
id
,
currentChat
);
}
else
{
return
false
;
}
}
MessagesController
.
getInstance
().
loadChatInfo
(
currentChat
.
id
);
dialog_id
=
-
chatId
;
}
else
if
(
userId
!=
0
)
{
currentUser
=
MessagesController
.
getInstance
().
users
.
get
(
userId
);
if
(
currentUser
==
null
)
{
return
false
;
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
MessagesStorage
.
getInstance
().
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
currentUser
=
MessagesStorage
.
getInstance
().
getUser
(
userId
);
semaphore
.
release
();
}
});
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(
currentUser
!=
null
)
{
MessagesController
.
getInstance
().
users
.
putIfAbsent
(
currentUser
.
id
,
currentUser
);
}
else
{
return
false
;
}
}
dialog_id
=
userId
;
}
else
if
(
encId
!=
0
)
{
currentEncryptedChat
=
MessagesController
.
getInstance
().
encryptedChats
.
get
(
encId
);
if
(
currentEncryptedChat
==
null
)
{
return
false
;
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
MessagesStorage
.
getInstance
().
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
currentEncryptedChat
=
MessagesStorage
.
getInstance
().
getEncryptedChat
(
encId
);
semaphore
.
release
();
}
});
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(
currentEncryptedChat
!=
null
)
{
MessagesController
.
getInstance
().
encryptedChats
.
putIfAbsent
(
currentEncryptedChat
.
id
,
currentEncryptedChat
);
}
else
{
return
false
;
}
}
currentUser
=
MessagesController
.
getInstance
().
users
.
get
(
currentEncryptedChat
.
user_id
);
if
(
currentUser
==
null
)
{
return
false
;
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
MessagesStorage
.
getInstance
().
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
currentUser
=
MessagesStorage
.
getInstance
().
getUser
(
currentEncryptedChat
.
user_id
);
semaphore
.
release
();
}
});
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(
currentUser
!=
null
)
{
MessagesController
.
getInstance
().
users
.
putIfAbsent
(
currentUser
.
id
,
currentUser
);
}
else
{
return
false
;
}
}
dialog_id
=
((
long
)
encId
)
<<
32
;
maxMessageId
=
Integer
.
MIN_VALUE
;
...
...
@@ -1400,8 +1469,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
0
)
{
Utilities
.
addMediaToGallery
(
currentPicturePath
);
...
...
@@ -1450,6 +1518,18 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
}
}
@Override
public
void
saveSelfArgs
(
Bundle
args
)
{
if
(
currentPicturePath
!=
null
)
{
args
.
putString
(
"path"
,
currentPicturePath
);
}
}
@Override
public
void
restoreSelfArgs
(
Bundle
args
)
{
currentPicturePath
=
args
.
getString
(
"path"
);
}
public
boolean
processSendingText
(
String
text
)
{
text
=
text
.
replaceAll
(
"\n\n+"
,
"\n\n"
);
text
=
text
.
replaceAll
(
" +"
,
" "
);
...
...
@@ -3104,7 +3184,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
takePictureIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
image
));
currentPicturePath
=
image
.
getAbsolutePath
();
}
startActivityForResult
(
takePictureIntent
,
0
);
parentActivity
.
startActivityForResult
(
takePictureIntent
,
0
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -3114,7 +3194,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"image/*"
);
startActivityForResult
(
photoPickerIntent
,
1
);
parentActivity
.
startActivityForResult
(
photoPickerIntent
,
1
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -3138,7 +3218,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
Intent
chooserIntent
=
Intent
.
createChooser
(
pickIntent
,
""
);
chooserIntent
.
putExtra
(
Intent
.
EXTRA_INITIAL_INTENTS
,
new
Intent
[]
{
takeVideoIntent
});
startActivityForResult
(
chooserIntent
,
2
);
parentActivity
.
startActivityForResult
(
chooserIntent
,
2
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java
View file @
22918f14
...
...
@@ -163,6 +163,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
editor
.
commit
();
listView
.
invalidateViews
();
}
else
if
(
i
==
3
)
{
if
(
parentActivity
==
null
)
{
return
;
}
try
{
Intent
tmpIntent
=
new
Intent
(
RingtoneManager
.
ACTION_RINGTONE_PICKER
);
tmpIntent
.
putExtra
(
RingtoneManager
.
EXTRA_RINGTONE_TYPE
,
RingtoneManager
.
TYPE_NOTIFICATION
);
...
...
@@ -187,7 +190,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
}
tmpIntent
.
putExtra
(
RingtoneManager
.
EXTRA_RINGTONE_EXISTING_URI
,
currentSound
);
startActivityForResult
(
tmpIntent
,
15
);
parentActivity
.
startActivityForResult
(
tmpIntent
,
3
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -247,11 +250,10 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
avatarUpdater
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
15
)
{
if
(
requestCode
==
3
)
{
Uri
ringtone
=
data
.
getParcelableExtra
(
RingtoneManager
.
EXTRA_RINGTONE_PICKED_URI
);
String
name
=
null
;
if
(
ringtone
!=
null
&&
parentActivity
!=
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java
View file @
22918f14
...
...
@@ -431,11 +431,12 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if
(!
selectedContacts
.
isEmpty
())
{
ArrayList
<
Integer
>
result
=
new
ArrayList
<
Integer
>();
result
.
addAll
(
selectedContacts
.
keySet
());
NotificationCenter
.
getInstance
().
addToMemCache
(
2
,
result
);
}
else
{
return
;
Bundle
args
=
new
Bundle
();
args
.
putIntegerArrayList
(
"result"
,
result
);
GroupCreateFinalActivity
fragment
=
new
GroupCreateFinalActivity
();
fragment
.
setArguments
(
args
);
((
LaunchActivity
)
parentActivity
).
presentFragment
(
fragment
,
"group_craate_final"
,
false
);
}
((
LaunchActivity
)
parentActivity
).
presentFragment
(
new
GroupCreateFinalActivity
(),
"group_craate_final"
,
false
);
}
});
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java
View file @
22918f14
...
...
@@ -28,6 +28,7 @@ import android.widget.TextView;
import
org.telegram.messenger.ConnectionsManager
;
import
org.telegram.messenger.LocaleController
;
import
org.telegram.messenger.MessagesStorage
;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.MessagesController
;
...
...
@@ -42,10 +43,11 @@ import org.telegram.ui.Views.PinnedHeaderListView;
import
org.telegram.ui.Views.SectionedBaseAdapter
;
import
java.util.ArrayList
;
import
java.util.concurrent.Semaphore
;
public
class
GroupCreateFinalActivity
extends
BaseFragment
implements
NotificationCenter
.
NotificationCenterDelegate
,
AvatarUpdater
.
AvatarUpdaterDelegate
{
private
PinnedHeaderListView
listView
;
private
TextView
nameTextView
;
private
EditText
nameTextView
;
private
TLRPC
.
FileLocation
avatar
;
private
TLRPC
.
InputFile
uploadedAvatar
;
private
ArrayList
<
Integer
>
selectedContacts
;
...
...
@@ -54,6 +56,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
private
boolean
donePressed
;
private
AvatarUpdater
avatarUpdater
=
new
AvatarUpdater
();
private
ProgressDialog
progressDialog
=
null
;
private
String
nameToSet
=
null
;
@SuppressWarnings
(
"unchecked"
)
@Override
...
...
@@ -64,7 +67,40 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
NotificationCenter
.
getInstance
().
addObserver
(
this
,
MessagesController
.
chatDidFailCreate
);
avatarUpdater
.
parentFragment
=
this
;
avatarUpdater
.
delegate
=
this
;
selectedContacts
=
(
ArrayList
<
Integer
>)
NotificationCenter
.
getInstance
().
getFromMemCache
(
2
);
selectedContacts
=
getArguments
().
getIntegerArrayList
(
"result"
);
final
ArrayList
<
Integer
>
usersToLoad
=
new
ArrayList
<
Integer
>();
for
(
Integer
uid
:
selectedContacts
)
{
if
(
MessagesController
.
getInstance
().
users
.
get
(
uid
)
==
null
)
{
usersToLoad
.
add
(
uid
);
}
}
if
(!
usersToLoad
.
isEmpty
())
{
final
Semaphore
semaphore
=
new
Semaphore
(
0
);
final
ArrayList
<
TLRPC
.
User
>
users
=
new
ArrayList
<
TLRPC
.
User
>();
final
boolean
[]
error
=
new
boolean
[
1
];
MessagesStorage
.
getInstance
().
storageQueue
.
postRunnable
(
new
Runnable
()
{
@Override
public
void
run
()
{
users
.
addAll
(
MessagesStorage
.
getInstance
().
getUsers
(
usersToLoad
,
error
));
semaphore
.
release
();
}
});
try
{
semaphore
.
acquire
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
if
(
error
[
0
])
{
return
false
;
}
if
(!
users
.
isEmpty
())
{
for
(
TLRPC
.
User
user
:
users
)
{
MessagesController
.
getInstance
().
users
.
putIfAbsent
(
user
.
id
,
user
);
}
}
else
{
return
false
;
}
}
return
true
;
}
...
...
@@ -125,6 +161,10 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
nameTextView
=
(
EditText
)
fragmentView
.
findViewById
(
R
.
id
.
bubble_input_text
);
nameTextView
.
setHint
(
LocaleController
.
getString
(
"EnterGroupNamePlaceholder"
,
R
.
string
.
EnterGroupNamePlaceholder
));
if
(
nameToSet
!=
null
)
{
nameTextView
.
setText
(
nameToSet
);
nameToSet
=
null
;
}
listView
=
(
PinnedHeaderListView
)
fragmentView
.
findViewById
(
R
.
id
.
listView
);
listView
.
setAdapter
(
new
ListAdapter
(
parentActivity
));
}
else
{
...
...
@@ -200,11 +240,38 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
avatarUpdater
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
@Override
public
void
saveSelfArgs
(
Bundle
args
)
{
if
(
avatarUpdater
!=
null
&&
avatarUpdater
.
currentPicturePath
!=
null
)
{
args
.
putString
(
"path"
,
avatarUpdater
.
currentPicturePath
);
}
if
(
nameTextView
!=
null
)
{
String
text
=
nameTextView
.
getText
().
toString
();
if
(
text
!=
null
&&
text
.
length
()
!=
0
)
{
args
.
putString
(
"nameTextView"
,
text
);
}
}
}
@Override
public
void
restoreSelfArgs
(
Bundle
args
)
{
if
(
avatarUpdater
!=
null
)
{
avatarUpdater
.
currentPicturePath
=
args
.
getString
(
"path"
);
}
String
text
=
args
.
getString
(
"nameTextView"
);
if
(
text
!=
null
)
{
if
(
nameTextView
!=
null
)
{
nameTextView
.
setText
(
text
);
}
else
{
nameToSet
=
text
;
}
}
}
@Override
public
void
onCreateOptionsMenu
(
Menu
menu
,
MenuInflater
inflater
)
{
inflater
.
inflate
(
R
.
menu
.
group_create_menu
,
menu
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
22918f14
...
...
@@ -140,6 +140,46 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
MessagesActivity
fragment
=
new
MessagesActivity
();
fragment
.
onFragmentCreate
();
ApplicationLoader
.
fragmentsStack
.
add
(
fragment
);
try
{
if
(
savedInstanceState
!=
null
)
{
String
fragmentName
=
savedInstanceState
.
getString
(
"fragment"
);
if
(
fragmentName
!=
null
)
{
Bundle
args
=
savedInstanceState
.
getBundle
(
"args"
);
if
(
fragmentName
.
equals
(
"chat"
))
{
if
(
args
!=
null
)
{
ChatActivity
chat
=
new
ChatActivity
();
chat
.
setArguments
(
args
);
if
(
chat
.
onFragmentCreate
())
{
ApplicationLoader
.
fragmentsStack
.
add
(
chat
);
chat
.
restoreSelfArgs
(
savedInstanceState
);
}
}
}
else
if
(
fragmentName
.
equals
(
"settings"
))
{
SettingsActivity
settings
=
new
SettingsActivity
();
settings
.
onFragmentCreate
();
settings
.
restoreSelfArgs
(
savedInstanceState
);
ApplicationLoader
.
fragmentsStack
.
add
(
settings
);
}
else
if
(
fragmentName
.
equals
(
"group"
))
{
if
(
args
!=
null
)
{
GroupCreateFinalActivity
group
=
new
GroupCreateFinalActivity
();
group
.
setArguments
(
args
);
if
(
group
.
onFragmentCreate
())
{
group
.
restoreSelfArgs
(
savedInstanceState
);
ApplicationLoader
.
fragmentsStack
.
add
(
group
);
}
}
}
else
if
(
fragmentName
.
equals
(
"wallpapers"
))
{
SettingsWallpapersActivity
settings
=
new
SettingsWallpapersActivity
();
settings
.
onFragmentCreate
();
settings
.
restoreSelfArgs
(
savedInstanceState
);
ApplicationLoader
.
fragmentsStack
.
add
(
settings
);
}
}
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
handleIntent
(
getIntent
(),
false
,
savedInstanceState
!=
null
);
...
...
@@ -536,6 +576,15 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
ApplicationLoader
.
fragmentsStack
.
size
()
!=
0
)
{
BaseFragment
fragment
=
ApplicationLoader
.
fragmentsStack
.
get
(
ApplicationLoader
.
fragmentsStack
.
size
()
-
1
);
fragment
.
onActivityResultFragment
(
requestCode
,
resultCode
,
data
);
}
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
...
...
@@ -932,6 +981,22 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
try
{
super
.
onSaveInstanceState
(
outState
);
if
(!
ApplicationLoader
.
fragmentsStack
.
isEmpty
())
{
BaseFragment
lastFragment
=
ApplicationLoader
.
fragmentsStack
.
get
(
ApplicationLoader
.
fragmentsStack
.
size
()
-
1
);
Bundle
args
=
lastFragment
.
getArguments
();
if
(
lastFragment
instanceof
ChatActivity
&&
args
!=
null
)
{
outState
.
putBundle
(
"args"
,
args
);
outState
.
putString
(
"fragment"
,
"chat"
);
}
else
if
(
lastFragment
instanceof
SettingsActivity
)
{
outState
.
putString
(
"fragment"
,
"settings"
);
}
else
if
(
lastFragment
instanceof
GroupCreateFinalActivity
&&
args
!=
null
)
{
outState
.
putBundle
(
"args"
,
args
);
outState
.
putString
(
"fragment"
,
"group"
);
}
else
if
(
lastFragment
instanceof
SettingsWallpapersActivity
)
{
outState
.
putString
(
"fragment"
,
"wallpapers"
);
}
lastFragment
.
saveSelfArgs
(
outState
);
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
View file @
22918f14
...
...
@@ -445,11 +445,24 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
avatarUpdater
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
@Override
public
void
saveSelfArgs
(
Bundle
args
)
{
if
(
avatarUpdater
!=
null
&&
avatarUpdater
.
currentPicturePath
!=
null
)
{
args
.
putString
(
"path"
,
avatarUpdater
.
currentPicturePath
);
}
}
@Override
public
void
restoreSelfArgs
(
Bundle
args
)
{
if
(
avatarUpdater
!=
null
)
{
avatarUpdater
.
currentPicturePath
=
args
.
getString
(
"path"
);
}
}
@Override
public
void
didReceivedNotification
(
int
id
,
Object
...
args
)
{
if
(
id
==
MessagesController
.
updateInterfaces
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsNotificationsActivity.java
View file @
22918f14
...
...
@@ -103,6 +103,9 @@ public class SettingsNotificationsActivity extends BaseFragment {
editor
.
commit
();
listView
.
invalidateViews
();
}
else
if
(
i
==
4
||
i
==
9
)
{
if
(
parentActivity
==
null
)
{
return
;
}
try
{
SharedPreferences
preferences
=
ApplicationLoader
.
applicationContext
.
getSharedPreferences
(
"Notifications"
,
Activity
.
MODE_PRIVATE
);
Intent
tmpIntent
=
new
Intent
(
RingtoneManager
.
ACTION_RINGTONE_PICKER
);
...
...
@@ -137,7 +140,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
}
}
tmpIntent
.
putExtra
(
RingtoneManager
.
EXTRA_RINGTONE_EXISTING_URI
,
currentSound
);
startActivityForResult
(
tmpIntent
,
i
);
parentActivity
.
startActivityForResult
(
tmpIntent
,
i
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -228,8 +231,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
Uri
ringtone
=
data
.
getParcelableExtra
(
RingtoneManager
.
EXTRA_RINGTONE_PICKED_URI
);
String
name
=
null
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java
View file @
22918f14
...
...
@@ -113,6 +113,9 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
builder
.
setItems
(
items
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
if
(
parentActivity
==
null
)
{
return
;
}
if
(
i
==
0
)
{
Intent
takePictureIntent
=
new
Intent
(
MediaStore
.
ACTION_IMAGE_CAPTURE
);
File
image
=
Utilities
.
generatePicturePath
();
...
...
@@ -120,11 +123,11 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
takePictureIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
image
));
currentPicturePath
=
image
.
getAbsolutePath
();
}
startActivityForResult
(
takePictureIntent
,
0
);
parentActivity
.
startActivityForResult
(
takePictureIntent
,
1
0
);
}
else
if
(
i
==
1
)
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"image/*"
);
startActivityForResult
(
photoPickerIntent
,
1
);
parentActivity
.
startActivityForResult
(
photoPickerIntent
,
1
1
);
}
}
});
...
...
@@ -194,10 +197,9 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
0
)
{
if
(
requestCode
==
1
0
)
{
Utilities
.
addMediaToGallery
(
currentPicturePath
);
try
{
Bitmap
bitmap
=
FileLoader
.
loadBitmap
(
currentPicturePath
,
null
,
Utilities
.
dp
(
320
),
Utilities
.
dp
(
480
));
...
...
@@ -211,7 +213,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
FileLog
.
e
(
"tmessages"
,
e
);
}
currentPicturePath
=
null
;
}
else
if
(
requestCode
==
1
)
{
}
else
if
(
requestCode
==
1
1
)
{
Uri
imageUri
=
data
.
getData
();
Cursor
cursor
=
parentActivity
.
getContentResolver
().
query
(
imageUri
,
new
String
[]{
android
.
provider
.
MediaStore
.
Images
.
ImageColumns
.
DATA
},
null
,
null
,
null
);
if
(
cursor
==
null
)
{
...
...
@@ -239,6 +241,18 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
}
}
@Override
public
void
saveSelfArgs
(
Bundle
args
)
{
if
(
currentPicturePath
!=
null
)
{
args
.
putString
(
"path"
,
currentPicturePath
);
}
}
@Override
public
void
restoreSelfArgs
(
Bundle
args
)
{
currentPicturePath
=
args
.
getString
(
"path"
);
}
private
void
processSelectedBackground
()
{
TLRPC
.
WallPaper
wallPaper
=
wallpappersByIds
.
get
(
selectedBackground
);
if
(
selectedBackground
!=
-
1
&&
selectedBackground
!=
1000001
&&
wallPaper
!=
null
&&
wallPaper
instanceof
TLRPC
.
TL_wallPaper
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java
View file @
22918f14
...
...
@@ -144,6 +144,9 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
else
if
(
i
==
5
&&
dialog_id
==
0
||
dialog_id
!=
0
&&
(
i
==
7
&&
currentEncryptedChat
instanceof
TLRPC
.
TL_encryptedChat
||
i
==
5
&&
!(
currentEncryptedChat
instanceof
TLRPC
.
TL_encryptedChat
)))
{
if
(
parentActivity
==
null
)
{
return
;
}
try
{
Intent
tmpIntent
=
new
Intent
(
RingtoneManager
.
ACTION_RINGTONE_PICKER
);
tmpIntent
.
putExtra
(
RingtoneManager
.
EXTRA_RINGTONE_TYPE
,
RingtoneManager
.
TYPE_NOTIFICATION
);
...
...
@@ -168,7 +171,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
tmpIntent
.
putExtra
(
RingtoneManager
.
EXTRA_RINGTONE_EXISTING_URI
,
currentSound
);
startActivityForResult
(
tmpIntent
,
0
);
parentActivity
.
startActivityForResult
(
tmpIntent
,
12
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -256,8 +259,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}
@Override
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
data
==
null
)
{
return
;
...
...
@@ -279,7 +281,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
SharedPreferences
preferences
=
ApplicationLoader
.
applicationContext
.
getSharedPreferences
(
"Notifications"
,
Activity
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
if
(
requestCode
==
0
)
{
if
(
requestCode
==
12
)
{
if
(
name
!=
null
&&
ringtone
!=
null
)
{
editor
.
putString
(
"sound_"
+
user_id
,
name
);
editor
.
putString
(
"sound_path_"
+
user_id
,
ringtone
.
toString
());
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarUpdater.java
View file @
22918f14
...
...
@@ -58,7 +58,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
takePictureIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
Uri
.
fromFile
(
image
));
currentPicturePath
=
image
.
getAbsolutePath
();
}
parentFragment
.
startActivityForResult
(
takePictureIntent
,
0
);
parentFragment
.
parentActivity
.
startActivityForResult
(
takePictureIntent
,
13
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -68,7 +68,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"image/*"
);
parentFragment
.
startActivityForResult
(
photoPickerIntent
,
1
);
parentFragment
.
parentActivity
.
startActivityForResult
(
photoPickerIntent
,
14
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -102,12 +102,12 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
public
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
if
(
requestCode
==
0
)
{
if
(
requestCode
==
13
)
{
Utilities
.
addMediaToGallery
(
currentPicturePath
);
startCrop
(
currentPicturePath
,
null
);
currentPicturePath
=
null
;
}
else
if
(
requestCode
==
1
)
{
}
else
if
(
requestCode
==
1
4
)
{
if
(
data
==
null
||
data
.
getData
()
==
null
)
{
return
;
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/BaseFragment.java
View file @
22918f14
...
...
@@ -8,6 +8,7 @@
package
org
.
telegram
.
ui
.
Views
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.app.ActionBarActivity
;
...
...
@@ -28,6 +29,7 @@ public class BaseFragment extends Fragment {
public
int
classGuid
=
0
;
public
boolean
firstStart
=
true
;
public
boolean
animationInProgress
=
false
;
private
long
currentAnimationDuration
=
0
;
private
boolean
removeParentOnDestroy
=
false
;
private
boolean
removeParentOnAnimationEnd
=
true
;
...
...
@@ -108,6 +110,16 @@ public class BaseFragment extends Fragment {
public
void
onAnimationStart
()
{
animationInProgress
=
true
;
if
(
fragmentView
!=
null
)
{
fragmentView
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
animationInProgress
)
{
onAnimationEnd
();
}
}
},
currentAnimationDuration
);
}
}
public
void
onAnimationEnd
()
{
...
...
@@ -137,6 +149,7 @@ public class BaseFragment extends Fragment {
public
Animation
onCreateAnimation
(
int
transit
,
boolean
enter
,
int
nextAnim
)
{
if
(
nextAnim
!=
0
)
{
Animation
anim
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
nextAnim
);
currentAnimationDuration
=
anim
.
getDuration
();
anim
.
setAnimationListener
(
new
Animation
.
AnimationListener
()
{
...
...
@@ -149,7 +162,9 @@ public class BaseFragment extends Fragment {
}
public
void
onAnimationEnd
(
Animation
animation
)
{
BaseFragment
.
this
.
onAnimationEnd
();
if
(
animationInProgress
)
{
BaseFragment
.
this
.
onAnimationEnd
();
}
}
});
...
...
@@ -166,4 +181,16 @@ public class BaseFragment extends Fragment {
public
void
applySelfActionBar
()
{
}
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
}
public
void
saveSelfArgs
(
Bundle
args
)
{
}
public
void
restoreSelfArgs
(
Bundle
args
)
{
}
}
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