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
33543423
Commit
33543423
authored
Oct 01, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes
parent
53ddefb8
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
268 additions
and
174 deletions
+268
-174
build.gradle
TMessagesProj/build.gradle
+2
-2
AndroidUtilities.java
.../src/main/java/org/telegram/android/AndroidUtilities.java
+9
-1
ImageLoader.java
...sProj/src/main/java/org/telegram/android/ImageLoader.java
+67
-9
ImageReceiver.java
...roj/src/main/java/org/telegram/android/ImageReceiver.java
+40
-9
LruCache.java
...agesProj/src/main/java/org/telegram/android/LruCache.java
+26
-72
MediaController.java
...j/src/main/java/org/telegram/android/MediaController.java
+4
-0
MessageObject.java
...roj/src/main/java/org/telegram/android/MessageObject.java
+1
-1
MessagesController.java
...rc/main/java/org/telegram/android/MessagesController.java
+2
-4
MessagesStorage.java
...j/src/main/java/org/telegram/android/MessagesStorage.java
+1
-1
PhotoObject.java
...sProj/src/main/java/org/telegram/android/PhotoObject.java
+6
-8
SendMessagesHelper.java
...rc/main/java/org/telegram/android/SendMessagesHelper.java
+3
-6
ConnectionsManager.java
.../main/java/org/telegram/messenger/ConnectionsManager.java
+3
-3
FileLoader.java
...Proj/src/main/java/org/telegram/messenger/FileLoader.java
+6
-9
Utilities.java
...sProj/src/main/java/org/telegram/messenger/Utilities.java
+4
-6
ChatMediaCell.java
...oj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
+2
-2
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+43
-24
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+17
-0
MediaActivity.java
...agesProj/src/main/java/org/telegram/ui/MediaActivity.java
+1
-1
PhotoViewer.java
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
+6
-6
PopupNotificationActivity.java
.../main/java/org/telegram/ui/PopupNotificationActivity.java
+1
-1
SettingsActivity.java
...sProj/src/main/java/org/telegram/ui/SettingsActivity.java
+2
-2
SettingsWallpapersActivity.java
...main/java/org/telegram/ui/SettingsWallpapersActivity.java
+3
-3
ActionBarLayer.java
.../java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java
+2
-2
ActionBarMenuItem.java
...va/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java
+11
-0
ChatActivityEnterView.java
...ain/java/org/telegram/ui/Views/ChatActivityEnterView.java
+6
-2
No files found.
TMessagesProj/build.gradle
View file @
33543423
...
...
@@ -80,7 +80,7 @@ android {
defaultConfig
{
minSdkVersion
8
targetSdkVersion
19
versionCode
34
3
versionName
"1.9.
1
"
versionCode
34
4
versionName
"1.9.
2
"
}
}
TMessagesProj/src/main/java/org/telegram/android/AndroidUtilities.java
View file @
33543423
...
...
@@ -266,7 +266,15 @@ public class AndroidUtilities {
}
public
static
void
RunOnUIThread
(
Runnable
runnable
)
{
ApplicationLoader
.
applicationHandler
.
post
(
runnable
);
RunOnUIThread
(
runnable
,
0
);
}
public
static
void
RunOnUIThread
(
Runnable
runnable
,
long
delay
)
{
if
(
delay
==
0
)
{
ApplicationLoader
.
applicationHandler
.
post
(
runnable
);
}
else
{
ApplicationLoader
.
applicationHandler
.
postDelayed
(
runnable
,
delay
);
}
}
public
static
boolean
isTablet
()
{
...
...
TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java
View file @
33543423
...
...
@@ -9,7 +9,10 @@
package
org
.
telegram
.
android
;
import
android.app.ActivityManager
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.Matrix
;
...
...
@@ -589,6 +592,36 @@ public class ImageLoader {
}
});
BroadcastReceiver
receiver
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
arg0
,
Intent
intent
)
{
FileLog
.
e
(
"tmessages"
,
"file system changed"
);
Runnable
r
=
new
Runnable
()
{
public
void
run
()
{
FileLoader
.
getInstance
().
setMediaDirs
(
createMediaPaths
());
}
};
if
(
Intent
.
ACTION_MEDIA_UNMOUNTED
.
equals
(
intent
.
getAction
()))
{
AndroidUtilities
.
RunOnUIThread
(
r
,
1000
);
}
else
{
r
.
run
();
}
}
};
IntentFilter
filter
=
new
IntentFilter
();
filter
.
addAction
(
Intent
.
ACTION_MEDIA_BAD_REMOVAL
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_CHECKING
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_EJECT
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_MOUNTED
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_NOFS
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_REMOVED
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_SHARED
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_UNMOUNTABLE
);
filter
.
addAction
(
Intent
.
ACTION_MEDIA_UNMOUNTED
);
filter
.
addDataScheme
(
"file"
);
ApplicationLoader
.
applicationContext
.
registerReceiver
(
receiver
,
filter
);
FileLoader
.
getInstance
().
setMediaDirs
(
createMediaPaths
());
}
...
...
@@ -603,6 +636,7 @@ public class ImageLoader {
}
}
mediaDirs
.
put
(
FileLoader
.
MEDIA_DIR_CACHE
,
cachePath
);
FileLog
.
e
(
"tmessages"
,
"cache path = "
+
cachePath
);
try
{
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
()))
{
...
...
@@ -613,8 +647,8 @@ public class ImageLoader {
File
imagePath
=
new
File
(
telegramPath
,
LocaleController
.
getString
(
"AppName"
,
R
.
string
.
AppName
)
+
" Images"
);
imagePath
.
mkdir
();
if
(
imagePath
.
isDirectory
())
{
//new File(imagePath, ".nomedia").delete();
mediaDirs
.
put
(
FileLoader
.
MEDIA_DIR_IMAGE
,
imagePath
);
FileLog
.
e
(
"tmessages"
,
"image path = "
+
imagePath
);
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -625,6 +659,7 @@ public class ImageLoader {
videoPath
.
mkdir
();
if
(
videoPath
.
isDirectory
())
{
mediaDirs
.
put
(
FileLoader
.
MEDIA_DIR_VIDEO
,
videoPath
);
FileLog
.
e
(
"tmessages"
,
"video path = "
+
videoPath
);
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -636,6 +671,7 @@ public class ImageLoader {
if
(
audioPath
.
isDirectory
())
{
new
File
(
audioPath
,
".nomedia"
).
createNewFile
();
mediaDirs
.
put
(
FileLoader
.
MEDIA_DIR_AUDIO
,
audioPath
);
FileLog
.
e
(
"tmessages"
,
"audio path = "
+
audioPath
);
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -647,12 +683,14 @@ public class ImageLoader {
if
(
documentPath
.
isDirectory
())
{
new
File
(
documentPath
,
".nomedia"
).
createNewFile
();
mediaDirs
.
put
(
FileLoader
.
MEDIA_DIR_DOCUMENT
,
documentPath
);
FileLog
.
e
(
"tmessages"
,
"documents path = "
+
documentPath
);
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
}
MediaController
.
getInstance
().
checkSaveToGalleryFiles
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -1020,11 +1058,15 @@ public class ImageLoader {
}
catch
(
Throwable
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
ImageLoader
.
getInstance
().
clearMemory
();
if
(
b
==
null
)
{
b
=
BitmapFactory
.
decodeFile
(
path
,
bmOptions
);
}
if
(
b
!=
null
)
{
b
=
Bitmap
.
createBitmap
(
b
,
0
,
0
,
b
.
getWidth
(),
b
.
getHeight
(),
matrix
,
true
);
try
{
if
(
b
==
null
)
{
b
=
BitmapFactory
.
decodeFile
(
path
,
bmOptions
);
}
if
(
b
!=
null
)
{
b
=
Bitmap
.
createBitmap
(
b
,
0
,
0
,
b
.
getWidth
(),
b
.
getHeight
(),
matrix
,
true
);
}
}
catch
(
Throwable
e2
)
{
FileLog
.
e
(
"tmessages"
,
e2
);
}
}
}
else
if
(
uri
!=
null
)
{
...
...
@@ -1050,7 +1092,12 @@ public class ImageLoader {
}
private
static
TLRPC
.
PhotoSize
scaleAndSaveImageInternal
(
Bitmap
bitmap
,
int
w
,
int
h
,
float
photoW
,
float
photoH
,
float
scaleFactor
,
int
quality
,
boolean
cache
)
throws
Exception
{
Bitmap
scaledBitmap
=
Bitmap
.
createScaledBitmap
(
bitmap
,
w
,
h
,
true
);
Bitmap
scaledBitmap
=
null
;
if
(
scaleFactor
>
1
)
{
scaledBitmap
=
Bitmap
.
createScaledBitmap
(
bitmap
,
w
,
h
,
true
);
}
else
{
scaledBitmap
=
bitmap
;
}
TLRPC
.
TL_fileLocation
location
=
new
TLRPC
.
TL_fileLocation
();
location
.
volume_id
=
Integer
.
MIN_VALUE
;
...
...
@@ -1064,8 +1111,19 @@ public class ImageLoader {
size
=
new
TLRPC
.
TL_photoCachedSize
();
}
size
.
location
=
location
;
size
.
w
=
(
int
)(
photoW
/
scaleFactor
);
size
.
h
=
(
int
)(
photoH
/
scaleFactor
);
size
.
w
=
scaledBitmap
.
getWidth
();
size
.
h
=
scaledBitmap
.
getHeight
();
if
(
size
.
w
<=
100
&&
size
.
h
<=
100
)
{
size
.
type
=
"s"
;
}
else
if
(
size
.
w
<=
320
&&
size
.
h
<=
320
)
{
size
.
type
=
"m"
;
}
else
if
(
size
.
w
<=
800
&&
size
.
h
<=
800
)
{
size
.
type
=
"x"
;
}
else
if
(
size
.
w
<=
1280
&&
size
.
h
<=
1280
)
{
size
.
type
=
"y"
;
}
else
{
size
.
type
=
"w"
;
}
if
(!
cache
)
{
String
fileName
=
location
.
volume_id
+
"_"
+
location
.
local_id
+
".jpg"
;
...
...
TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java
View file @
33543423
...
...
@@ -206,7 +206,16 @@ public class ImageReceiver {
bitmapH
/=
scale
;
drawRegion
.
set
(
x
+
(
w
-
bitmapW
)
/
2
,
y
+
(
h
-
bitmapH
)
/
2
,
x
+
(
w
+
bitmapW
)
/
2
,
y
+
(
h
+
bitmapH
)
/
2
);
bitmapDrawable
.
setBounds
(
drawRegion
);
bitmapDrawable
.
draw
(
canvas
);
try
{
bitmapDrawable
.
draw
(
canvas
);
}
catch
(
Exception
e
)
{
if
(
currentPath
!=
null
)
{
ImageLoader
.
getInstance
().
removeImage
(
currentPath
);
currentPath
=
null
;
}
setImage
(
last_path
,
last_httpUrl
,
last_filter
,
last_placeholder
,
last_size
);
FileLog
.
e
(
"tmessages"
,
e
);
}
canvas
.
restore
();
}
else
{
if
(
Math
.
abs
(
scaleW
-
scaleH
)
>
0.00001f
)
{
...
...
@@ -222,7 +231,16 @@ public class ImageReceiver {
}
bitmapDrawable
.
setBounds
(
drawRegion
);
if
(
isVisible
)
{
bitmapDrawable
.
draw
(
canvas
);
try
{
bitmapDrawable
.
draw
(
canvas
);
}
catch
(
Exception
e
)
{
if
(
currentPath
!=
null
)
{
ImageLoader
.
getInstance
().
removeImage
(
currentPath
);
currentPath
=
null
;
}
setImage
(
last_path
,
last_httpUrl
,
last_filter
,
last_placeholder
,
last_size
);
FileLog
.
e
(
"tmessages"
,
e
);
}
}
canvas
.
restore
();
...
...
@@ -230,7 +248,16 @@ public class ImageReceiver {
drawRegion
.
set
(
x
,
y
,
x
+
w
,
y
+
h
);
bitmapDrawable
.
setBounds
(
drawRegion
);
if
(
isVisible
)
{
bitmapDrawable
.
draw
(
canvas
);
try
{
bitmapDrawable
.
draw
(
canvas
);
}
catch
(
Exception
e
)
{
if
(
currentPath
!=
null
)
{
ImageLoader
.
getInstance
().
removeImage
(
currentPath
);
currentPath
=
null
;
}
setImage
(
last_path
,
last_httpUrl
,
last_filter
,
last_placeholder
,
last_size
);
FileLog
.
e
(
"tmessages"
,
e
);
}
}
}
}
...
...
@@ -239,16 +266,20 @@ public class ImageReceiver {
drawRegion
.
set
(
x
,
y
,
x
+
w
,
y
+
h
);
last_placeholder
.
setBounds
(
drawRegion
);
if
(
isVisible
)
{
last_placeholder
.
draw
(
canvas
);
try
{
last_placeholder
.
draw
(
canvas
);
}
catch
(
Exception
e
)
{
if
(
currentPath
!=
null
)
{
ImageLoader
.
getInstance
().
removeImage
(
currentPath
);
currentPath
=
null
;
}
setImage
(
last_path
,
last_httpUrl
,
last_filter
,
last_placeholder
,
last_size
);
FileLog
.
e
(
"tmessages"
,
e
);
}
}
return
true
;
}
}
catch
(
Exception
e
)
{
if
(
currentPath
!=
null
)
{
ImageLoader
.
getInstance
().
removeImage
(
currentPath
);
currentPath
=
null
;
}
setImage
(
last_path
,
last_httpUrl
,
last_filter
,
last_placeholder
,
last_size
);
FileLog
.
e
(
"tmessages"
,
e
);
}
return
false
;
...
...
TMessagesProj/src/main/java/org/telegram/android/LruCache.java
View file @
33543423
...
...
@@ -11,6 +11,8 @@ package org.telegram.android;
import
android.graphics.drawable.BitmapDrawable
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -29,11 +31,6 @@ public class LruCache {
private
int
size
;
private
int
maxSize
;
private
int
putCount
;
private
int
evictionCount
;
private
int
hitCount
;
private
int
missCount
;
/**
* @param maxSize for caches that do not override {@link #sizeOf}, this is
* the maximum number of entries in the cache. For all other caches,
...
...
@@ -63,10 +60,8 @@ public class LruCache {
synchronized
(
this
)
{
mapValue
=
map
.
get
(
key
);
if
(
mapValue
!=
null
)
{
hitCount
++;
return
mapValue
;
}
missCount
++;
}
return
null
;
}
...
...
@@ -92,7 +87,6 @@ public class LruCache {
BitmapDrawable
previous
;
synchronized
(
this
)
{
putCount
++;
size
+=
safeSizeOf
(
key
,
value
);
previous
=
map
.
put
(
key
,
value
);
if
(
previous
!=
null
)
{
...
...
@@ -114,7 +108,7 @@ public class LruCache {
entryRemoved
(
false
,
key
,
previous
,
value
);
}
trimToSize
(
maxSize
);
trimToSize
(
maxSize
,
key
);
return
previous
;
}
...
...
@@ -122,40 +116,36 @@ public class LruCache {
* @param maxSize the maximum size of the cache before returning. May be -1
* to evict even 0-sized elements.
*/
private
void
trimToSize
(
int
maxSize
)
{
while
(
true
)
{
String
key
;
BitmapDrawable
value
;
synchronized
(
this
)
{
if
(
size
<
0
||
(
map
.
isEmpty
()
&&
size
!=
0
))
{
throw
new
IllegalStateException
(
getClass
().
getName
()
+
".sizeOf() is reporting inconsistent results!"
);
}
private
void
trimToSize
(
int
maxSize
,
String
justAdded
)
{
synchronized
(
this
)
{
Iterator
<
HashMap
.
Entry
<
String
,
BitmapDrawable
>>
iterator
=
map
.
entrySet
().
iterator
();
while
(
iterator
.
hasNext
())
{
if
(
size
<=
maxSize
||
map
.
isEmpty
())
{
break
;
}
HashMap
.
Entry
<
String
,
BitmapDrawable
>
entry
=
iterator
.
next
();
Map
.
Entry
<
String
,
BitmapDrawable
>
toEvict
=
map
.
entrySet
().
iterator
().
next
();
key
=
toEvict
.
getKey
();
value
=
toEvict
.
getValue
();
map
.
remove
(
key
);
String
key
=
entry
.
getKey
();
if
(
justAdded
!=
null
&&
justAdded
.
equals
(
key
))
{
continue
;
}
BitmapDrawable
value
=
entry
.
getValue
();
size
-=
safeSizeOf
(
key
,
value
);
evictionCount
++
;
}
String
[]
args
=
key
.
split
(
"@"
);
if
(
args
.
length
>
1
)
{
ArrayList
<
String
>
arr
=
mapFilters
.
get
(
args
[
0
]);
if
(
arr
!=
null
)
{
arr
.
remove
(
key
);
if
(
arr
.
isEmpty
())
{
mapFilters
.
remove
(
args
[
1
]);
iterator
.
remove
()
;
String
[]
args
=
key
.
split
(
"@"
);
if
(
args
.
length
>
1
)
{
ArrayList
<
String
>
arr
=
mapFilters
.
get
(
args
[
0
]);
if
(
arr
!=
null
)
{
arr
.
remove
(
key
);
if
(
arr
.
isEmpty
())
{
mapFilters
.
remove
(
args
[
1
]);
}
}
}
}
entryRemoved
(
true
,
key
,
value
,
null
);
entryRemoved
(
true
,
key
,
value
,
null
);
}
}
}
...
...
@@ -239,7 +229,7 @@ public class LruCache {
* Clear the cache, calling {@link #entryRemoved} on each removed entry.
*/
public
final
void
evictAll
()
{
trimToSize
(-
1
);
// -1 will evict 0-sized elements
trimToSize
(-
1
,
null
);
// -1 will evict 0-sized elements
}
/**
...
...
@@ -259,40 +249,4 @@ public class LruCache {
public
synchronized
final
int
maxSize
()
{
return
maxSize
;
}
/**
* Returns the number of times {@link #get} returned a value.
*/
public
synchronized
final
int
hitCount
()
{
return
hitCount
;
}
/**
* Returns the number of times {@link #get} returned null or required a new
* value to be created.
*/
public
synchronized
final
int
missCount
()
{
return
missCount
;
}
/**
* Returns the number of times {@link #put} was called.
*/
public
synchronized
final
int
putCount
()
{
return
putCount
;
}
/**
* Returns the number of values that have been evicted.
*/
public
synchronized
final
int
evictionCount
()
{
return
evictionCount
;
}
@Override
public
synchronized
final
String
toString
()
{
int
accesses
=
hitCount
+
missCount
;
int
hitPercent
=
accesses
!=
0
?
(
100
*
hitCount
/
accesses
)
:
0
;
return
String
.
format
(
"LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]"
,
maxSize
,
hitCount
,
missCount
,
hitPercent
);
}
}
TMessagesProj/src/main/java/org/telegram/android/MediaController.java
View file @
33543423
...
...
@@ -1794,6 +1794,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putBoolean
(
"save_gallery"
,
saveToGallery
);
editor
.
commit
();
checkSaveToGalleryFiles
();
}
public
void
checkSaveToGalleryFiles
()
{
try
{
File
telegramPath
=
new
File
(
Environment
.
getExternalStorageDirectory
(),
LocaleController
.
getString
(
"AppName"
,
R
.
string
.
AppName
));
File
imagePath
=
new
File
(
telegramPath
,
LocaleController
.
getString
(
"AppName"
,
R
.
string
.
AppName
)
+
" Images"
);
...
...
TMessagesProj/src/main/java/org/telegram/android/MessageObject.java
View file @
33543423
...
...
@@ -417,7 +417,7 @@ public class MessageObject {
}
else
if
(
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
messageOwner
.
media
.
photo
.
sizes
;
if
(
sizes
.
size
()
>
0
)
{
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
return
FileLoader
.
getAttachFileName
(
sizeFull
);
}
...
...
TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
View file @
33543423
...
...
@@ -15,8 +15,6 @@ import android.content.Context;
import
android.content.DialogInterface
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageInfo
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.text.Html
;
...
...
@@ -228,8 +226,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
TLRPC
.
TL_photos_photo
photo
=
(
TLRPC
.
TL_photos_photo
)
response
;
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
photo
.
photo
.
sizes
;
TLRPC
.
PhotoSize
smallSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
100
,
100
);
TLRPC
.
PhotoSize
bigSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
1000
,
1000
);
TLRPC
.
PhotoSize
smallSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
100
);
TLRPC
.
PhotoSize
bigSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
1000
);
user
.
photo
=
new
TLRPC
.
TL_userProfilePhoto
();
user
.
photo
.
photo_id
=
photo
.
photo
.
id
;
if
(
smallSize
!=
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
View file @
33543423
...
...
@@ -2600,7 +2600,7 @@ public class MessagesStorage {
}
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
if
((
downloadMask
&
MediaController
.
AUTODOWNLOAD_MASK_PHOTO
)
!=
0
)
{
TLRPC
.
PhotoSize
photoSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
photoSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
photoSize
!=
null
)
{
id
=
message
.
media
.
photo
.
id
;
type
=
MediaController
.
AUTODOWNLOAD_MASK_PHOTO
;
...
...
TMessagesProj/src/main/java/org/telegram/android/PhotoObject.java
View file @
33543423
...
...
@@ -46,23 +46,21 @@ public class PhotoObject {
}
}
public
static
PhotoObject
getClosestImageWithSize
(
ArrayList
<
PhotoObject
>
arr
,
int
width
,
int
height
)
{
public
static
PhotoObject
getClosestImageWithSize
(
ArrayList
<
PhotoObject
>
arr
,
int
side
)
{
if
(
arr
==
null
)
{
return
null
;
}
int
closestWidth
=
9999
;
int
closestHeight
=
9999
;
int
lastSide
=
0
;
PhotoObject
closestObject
=
null
;
for
(
PhotoObject
obj
:
arr
)
{
if
(
obj
==
null
||
obj
.
photoOwner
==
null
)
{
continue
;
}
int
diffW
=
Math
.
abs
(
obj
.
photoOwner
.
w
-
width
);
int
diffH
=
Math
.
abs
(
obj
.
photoOwner
.
h
-
height
);
if
(
closestObject
==
null
||
closestWidth
>
diffW
||
closestHeight
>
diffH
||
closestObject
.
photoOwner
instanceof
TLRPC
.
TL_photoCachedSize
)
{
int
currentSide
=
obj
.
photoOwner
.
w
>=
obj
.
photoOwner
.
h
?
obj
.
photoOwner
.
w
:
obj
.
photoOwner
.
h
;
if
(
closestObject
==
null
||
closestObject
.
photoOwner
instanceof
TLRPC
.
TL_photoCachedSize
||
currentSide
<=
side
&&
lastSide
<
currentSide
)
{
closestObject
=
obj
;
closestWidth
=
diffW
;
closestHeight
=
diffH
;
lastSide
=
currentSide
;
}
}
return
closestObject
;
...
...
TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java
View file @
33543423
...
...
@@ -1555,19 +1555,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
public
TLRPC
.
TL_photo
generatePhotoSizes
(
String
path
,
Uri
imageUri
)
{
long
time
=
System
.
currentTimeMillis
();
Bitmap
bitmap
=
ImageLoader
.
loadBitmap
(
path
,
imageUri
,
AndroidUtilities
.
getPhotoSize
(),
AndroidUtilities
.
getPhotoSize
());
if
(
bitmap
==
null
&&
AndroidUtilities
.
getPhotoSize
()
!=
800
)
{
bitmap
=
ImageLoader
.
loadBitmap
(
path
,
imageUri
,
800
,
800
);
}
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
new
ArrayList
<
TLRPC
.
PhotoSize
>();
TLRPC
.
PhotoSize
size
=
ImageLoader
.
scaleAndSaveImage
(
bitmap
,
90
,
90
,
55
,
true
);
if
(
size
!=
null
)
{
size
.
type
=
"s"
;
sizes
.
add
(
size
);
}
size
=
ImageLoader
.
scaleAndSaveImage
(
bitmap
,
AndroidUtilities
.
getPhotoSize
(),
AndroidUtilities
.
getPhotoSize
(),
80
,
false
);
if
(
size
!=
null
)
{
if
(
AndroidUtilities
.
getPhotoSize
()
==
800
)
{
size
.
type
=
"x"
;
}
else
{
size
.
type
=
"y"
;
}
sizes
.
add
(
size
);
}
if
(
bitmap
!=
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
View file @
33543423
...
...
@@ -946,17 +946,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
try
{
ConnectivityManager
cm
=
(
ConnectivityManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
NetworkInfo
netInfo
=
cm
.
getActiveNetworkInfo
();
if
(
netInfo
!=
null
&&
(
netInfo
.
isConnectedOrConnecting
()
||
netInfo
.
is
Roaming
()
||
netInfo
.
is
Available
()))
{
if
(
netInfo
!=
null
&&
(
netInfo
.
isConnectedOrConnecting
()
||
netInfo
.
isAvailable
()))
{
return
true
;
}
netInfo
=
cm
.
getNetworkInfo
(
ConnectivityManager
.
TYPE_MOBILE
);
if
(
netInfo
!=
null
&&
(
netInfo
.
isConnectedOrConnecting
()
||
netInfo
.
isRoaming
()
))
{
if
(
netInfo
!=
null
&&
netInfo
.
isConnectedOrConnecting
(
))
{
return
true
;
}
else
{
netInfo
=
cm
.
getNetworkInfo
(
ConnectivityManager
.
TYPE_WIFI
);
if
(
netInfo
!=
null
&&
(
netInfo
.
isConnectedOrConnecting
()
||
netInfo
.
isRoaming
()
))
{
if
(
netInfo
!=
null
&&
netInfo
.
isConnectedOrConnecting
(
))
{
return
true
;
}
}
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
33543423
...
...
@@ -573,7 +573,7 @@ public class FileLoader {
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
message
.
media
.
photo
.
sizes
;
if
(
sizes
.
size
()
>
0
)
{
TLRPC
.
PhotoSize
sizeFull
=
getClosestPhotoSizeWithSize
(
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
getClosestPhotoSizeWithSize
(
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
return
getPathToAttach
(
sizeFull
);
}
...
...
@@ -636,23 +636,20 @@ public class FileLoader {
return
new
File
(
dir
,
getAttachFileName
(
attach
));
}
public
static
TLRPC
.
PhotoSize
getClosestPhotoSizeWithSize
(
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
,
int
width
,
int
height
)
{
public
static
TLRPC
.
PhotoSize
getClosestPhotoSizeWithSize
(
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
,
int
side
)
{
if
(
sizes
==
null
)
{
return
null
;
}
int
closestWidth
=
9999
;
int
closestHeight
=
9999
;
int
lastSide
=
0
;
TLRPC
.
PhotoSize
closestObject
=
null
;
for
(
TLRPC
.
PhotoSize
obj
:
sizes
)
{
if
(
obj
==
null
)
{
continue
;
}
int
diffW
=
Math
.
abs
(
obj
.
w
-
width
);
int
diffH
=
Math
.
abs
(
obj
.
h
-
height
);
if
(
closestObject
==
null
||
closestObject
instanceof
TLRPC
.
TL_photoCachedSize
||
closestWidth
>
diffW
||
closestHeight
>
diffH
)
{
int
currentSide
=
obj
.
w
>=
obj
.
h
?
obj
.
w
:
obj
.
h
;
if
(
closestObject
==
null
||
closestObject
instanceof
TLRPC
.
TL_photoCachedSize
||
currentSide
<=
side
&&
lastSide
<
currentSide
)
{
closestObject
=
obj
;
closestWidth
=
diffW
;
closestHeight
=
diffH
;
lastSide
=
currentSide
;
}
}
return
closestObject
;
...
...
TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
View file @
33543423
...
...
@@ -532,8 +532,8 @@ public class Utilities {
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
()))
{
storageDir
=
new
File
(
Environment
.
getExternalStoragePublicDirectory
(
Environment
.
DIRECTORY_PICTURES
),
LocaleController
.
getString
(
"AppName"
,
R
.
string
.
AppName
));
if
(
storageDir
!=
null
)
{
if
(!
storageDir
.
mkdirs
())
{
if
(!
storageDir
.
exists
()){
if
(!
storageDir
.
mkdirs
())
{
if
(!
storageDir
.
exists
()){
FileLog
.
d
(
"tmessages"
,
"failed to create directory"
);
return
null
;
}
...
...
@@ -633,8 +633,7 @@ public class Utilities {
try
{
File
storageDir
=
getAlbumDir
();
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
String
imageFileName
=
"IMG_"
+
timeStamp
+
"_"
;
return
File
.
createTempFile
(
imageFileName
,
".jpg"
,
storageDir
);
return
new
File
(
storageDir
,
"IMG_"
+
timeStamp
+
".jpg"
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
@@ -683,8 +682,7 @@ public class Utilities {
try
{
File
storageDir
=
getAlbumDir
();
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
String
imageFileName
=
"VID_"
+
timeStamp
+
"_"
;
return
File
.
createTempFile
(
imageFileName
,
".mp4"
,
storageDir
);
return
new
File
(
storageDir
,
"VID_"
+
timeStamp
+
".mp4"
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
View file @
33543423
...
...
@@ -472,7 +472,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoWidth
=
AndroidUtilities
.
dp
(
86
);
photoHeight
=
AndroidUtilities
.
dp
(
86
);
backgroundWidth
=
photoWidth
+
Math
.
max
(
nameWidth
,
infoWidth
)
+
AndroidUtilities
.
dp
(
68
);
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
());
if
(
currentPhotoObject
!=
null
)
{
if
(
currentPhotoObject
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
currentPhotoObject
.
image
);
...
...
@@ -507,7 +507,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
photoHeight
=
AndroidUtilities
.
getPhotoSize
();
}
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
());
if
(
currentPhotoObject
!=
null
)
{
boolean
noSize
=
false
;
if
(
currentMessageObject
.
type
==
3
||
currentMessageObject
.
type
==
8
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
33543423
...
...
@@ -1599,7 +1599,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Bitmap
bitmap
=
ImageLoader
.
loadBitmap
(
f
.
getAbsolutePath
(),
null
,
90
,
90
);
if
(
bitmap
!=
null
)
{
document
.
thumb
=
ImageLoader
.
scaleAndSaveImage
(
bitmap
,
90
,
90
,
55
,
currentEncryptedChat
!=
null
);
document
.
thumb
.
type
=
"s"
;
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
...
...
@@ -1674,6 +1673,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
video
.
thumb
=
size
;
if
(
video
.
thumb
==
null
)
{
video
.
thumb
=
new
TLRPC
.
TL_photoSizeEmpty
();
video
.
thumb
.
type
=
"s"
;
}
else
{
video
.
thumb
.
type
=
"s"
;
}
...
...
@@ -1702,31 +1702,50 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if
(
temp
!=
null
&&
temp
.
exists
())
{
video
.
size
=
(
int
)
temp
.
length
();
}
boolean
infoObtained
=
false
;
if
(
Build
.
VERSION
.
SDK_INT
>=
14
)
{
MediaMetadataRetriever
mediaMetadataRetriever
=
new
MediaMetadataRetriever
();
mediaMetadataRetriever
.
setDataSource
(
videoPath
);
String
width
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_VIDEO_WIDTH
);
if
(
width
!=
null
)
{
video
.
w
=
Integer
.
parseInt
(
width
);
}
String
height
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_VIDEO_HEIGHT
);
if
(
height
!=
null
)
{
video
.
h
=
Integer
.
parseInt
(
height
);
}
String
duration
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_DURATION
);
if
(
duration
!=
null
)
{
video
.
duration
=
(
int
)
Math
.
ceil
(
Long
.
parseLong
(
duration
)
/
1000.0f
);
MediaMetadataRetriever
mediaMetadataRetriever
=
null
;
try
{
mediaMetadataRetriever
=
new
MediaMetadataRetriever
();
mediaMetadataRetriever
.
setDataSource
(
videoPath
);
String
width
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_VIDEO_WIDTH
);
if
(
width
!=
null
)
{
video
.
w
=
Integer
.
parseInt
(
width
);
}
String
height
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_VIDEO_HEIGHT
);
if
(
height
!=
null
)
{
video
.
h
=
Integer
.
parseInt
(
height
);
}
String
duration
=
mediaMetadataRetriever
.
extractMetadata
(
MediaMetadataRetriever
.
METADATA_KEY_DURATION
);
if
(
duration
!=
null
)
{
video
.
duration
=
(
int
)
Math
.
ceil
(
Long
.
parseLong
(
duration
)
/
1000.0f
);
}
infoObtained
=
true
;
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
finally
{
try
{
if
(
mediaMetadataRetriever
!=
null
)
{
mediaMetadataRetriever
.
release
();
mediaMetadataRetriever
=
null
;
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
mediaMetadataRetriever
.
release
();
}
else
{
MediaPlayer
mp
=
MediaPlayer
.
create
(
ApplicationLoader
.
applicationContext
,
Uri
.
fromFile
(
new
File
(
videoPath
)));
if
(
mp
==
null
)
{
return
;
}
if
(!
infoObtained
)
{
try
{
MediaPlayer
mp
=
MediaPlayer
.
create
(
ApplicationLoader
.
applicationContext
,
Uri
.
fromFile
(
new
File
(
videoPath
)));
if
(
mp
!=
null
)
{
video
.
duration
=
(
int
)
Math
.
ceil
(
mp
.
getDuration
()
/
1000.0f
);
video
.
w
=
mp
.
getVideoWidth
();
video
.
h
=
mp
.
getVideoHeight
();
mp
.
release
();
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
video
.
duration
=
(
int
)
Math
.
ceil
(
mp
.
getDuration
()
/
1000.0f
);
video
.
w
=
mp
.
getVideoWidth
();
video
.
h
=
mp
.
getVideoHeight
();
mp
.
release
();
}
}
}
...
...
@@ -3572,7 +3591,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if
(
message
.
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
photoImage
.
setImage
(
message
.
messageOwner
.
action
.
newUserPhoto
.
photo_small
,
"50_50"
,
AndroidUtilities
.
getUserAvatarForId
(
currentUser
.
id
));
}
else
{
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
message
.
photoThumbs
,
AndroidUtilities
.
dp
(
64
)
,
AndroidUtilities
.
dp
(
64
)
);
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
message
.
photoThumbs
,
AndroidUtilities
.
dp
(
64
));
if
(
photo
!=
null
)
{
if
(
photo
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
photo
.
image
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
33543423
...
...
@@ -20,6 +20,7 @@ import android.os.Bundle;
import
android.os.Parcelable
;
import
android.provider.ContactsContract
;
import
android.view.ActionMode
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -1013,6 +1014,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
if
(
AndroidUtilities
.
isTablet
())
{
if
(
layersActionBarLayout
.
getVisibility
()
==
View
.
VISIBLE
&&
!
layersActionBarLayout
.
fragmentsStack
.
isEmpty
())
{
layersActionBarLayout
.
onKeyUp
(
keyCode
,
event
);
}
else
if
(
rightActionBarLayout
.
getVisibility
()
==
View
.
VISIBLE
&&
!
rightActionBarLayout
.
fragmentsStack
.
isEmpty
())
{
rightActionBarLayout
.
onKeyUp
(
keyCode
,
event
);
}
else
{
actionBarLayout
.
onKeyUp
(
keyCode
,
event
);
}
}
else
{
actionBarLayout
.
onKeyUp
(
keyCode
,
event
);
}
return
super
.
onKeyUp
(
keyCode
,
event
);
}
@Override
public
boolean
needPresentFragment
(
BaseFragment
fragment
,
boolean
removeLast
,
boolean
forceWithoutAnimation
,
ActionBarLayout
layout
)
{
if
(
AndroidUtilities
.
isTablet
())
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java
View file @
33543423
...
...
@@ -413,7 +413,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
if
(
message
.
imagePreview
!=
null
)
{
imageView
.
setImageBitmap
(
message
.
imagePreview
);
}
else
{
TLRPC
.
PhotoSize
photoSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
80
,
80
);
TLRPC
.
PhotoSize
photoSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
80
);
imageView
.
setImage
(
photoSize
.
location
,
null
,
R
.
drawable
.
photo_placeholder_in
);
}
}
else
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java
View file @
33543423
...
...
@@ -335,7 +335,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if
(
photo
instanceof
TLRPC
.
TL_photoEmpty
||
photo
.
sizes
==
null
)
{
continue
;
}
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
photo
.
sizes
,
640
,
640
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
photo
.
sizes
,
640
);
if
(
sizeFull
!=
null
)
{
if
(
currentFileLocation
!=
null
)
{
for
(
TLRPC
.
PhotoSize
size
:
photo
.
sizes
)
{
...
...
@@ -682,7 +682,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if
(
current
)
{
MessagesController
.
getInstance
().
deleteUserPhoto
(
null
);
closePhoto
(
false
);
}
else
{
}
else
if
(
photo
!=
null
)
{
TLRPC
.
TL_inputPhoto
inputPhoto
=
new
TLRPC
.
TL_inputPhoto
();
inputPhoto
.
id
=
photo
.
id
;
inputPhoto
.
access_hash
=
photo
.
access_hash
;
...
...
@@ -951,7 +951,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if
(
message
.
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
return
message
.
messageOwner
.
action
.
newUserPhoto
.
photo_big
;
}
else
{
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
action
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
action
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
size
[
0
]
=
sizeFull
.
size
;
if
(
size
[
0
]
==
0
)
{
...
...
@@ -963,7 +963,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
}
else
if
(
message
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
&&
message
.
messageOwner
.
media
.
photo
!=
null
)
{
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
size
[
0
]
=
sizeFull
.
size
;
if
(
size
[
0
]
==
0
)
{
...
...
@@ -1014,7 +1014,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
location
.
secret
=
sizeFull
.
secret
;
return
location
;
}
else
{
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
action
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
action
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
TLRPC
.
TL_inputFileLocation
location
=
new
TLRPC
.
TL_inputFileLocation
();
location
.
local_id
=
sizeFull
.
location
.
local_id
;
...
...
@@ -1025,7 +1025,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
}
else
if
(
message
.
messageOwner
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
TLRPC
.
PhotoSize
sizeFull
=
FileLoader
.
getClosestPhotoSizeWithSize
(
message
.
messageOwner
.
media
.
photo
.
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
TLRPC
.
TL_inputFileLocation
location
=
new
TLRPC
.
TL_inputFileLocation
();
location
.
local_id
=
sizeFull
.
location
.
local_id
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java
View file @
33543423
...
...
@@ -445,7 +445,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
TextView
messageText
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
message_text
);
BackupImageView
imageView
=
(
BackupImageView
)
view
.
findViewById
(
R
.
id
.
message_image
);
imageView
.
imageReceiver
.
setAspectFit
(
true
);
PhotoObject
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
()
,
AndroidUtilities
.
getPhotoSize
()
);
PhotoObject
currentPhotoObject
=
PhotoObject
.
getClosestImageWithSize
(
messageObject
.
photoThumbs
,
AndroidUtilities
.
getPhotoSize
());
boolean
photoSet
=
false
;
if
(
currentPhotoObject
!=
null
)
{
boolean
photoExist
=
true
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
View file @
33543423
...
...
@@ -143,8 +143,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
}
TLRPC
.
TL_photos_photo
photo
=
(
TLRPC
.
TL_photos_photo
)
response
;
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
photo
.
photo
.
sizes
;
TLRPC
.
PhotoSize
smallSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
100
,
100
);
TLRPC
.
PhotoSize
bigSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
1000
,
1000
);
TLRPC
.
PhotoSize
smallSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
100
);
TLRPC
.
PhotoSize
bigSize
=
FileLoader
.
getClosestPhotoSizeWithSize
(
sizes
,
1000
);
user
.
photo
=
new
TLRPC
.
TL_userProfilePhoto
();
user
.
photo
.
photo_id
=
photo
.
photo
.
id
;
if
(
smallSize
!=
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/SettingsWallpapersActivity.java
View file @
33543423
...
...
@@ -119,7 +119,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
width
=
height
;
height
=
temp
;
}
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
width
,
height
);
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
Math
.
min
(
width
,
height
)
);
String
fileName
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
+
".jpg"
;
File
f
=
new
File
(
FileLoader
.
getInstance
().
getDirectory
(
FileLoader
.
MEDIA_DIR_CACHE
),
fileName
);
File
toFile
=
new
File
(
ApplicationLoader
.
applicationContext
.
getFilesDir
(),
"wallpaper.jpg"
);
...
...
@@ -273,7 +273,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
width
=
height
;
height
=
temp
;
}
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
width
,
height
);
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
Math
.
min
(
width
,
height
)
);
String
fileName
=
size
.
location
.
volume_id
+
"_"
+
size
.
location
.
local_id
+
".jpg"
;
File
f
=
new
File
(
FileLoader
.
getInstance
().
getDirectory
(
FileLoader
.
MEDIA_DIR_CACHE
),
fileName
);
if
(!
f
.
exists
())
{
...
...
@@ -532,7 +532,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
BackupImageView
image
=
(
BackupImageView
)
view
.
findViewById
(
R
.
id
.
image
);
View
selection
=
view
.
findViewById
(
R
.
id
.
selection
);
TLRPC
.
WallPaper
wallPaper
=
wallPapers
.
get
(
i
-
1
);
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
AndroidUtilities
.
dp
(
100
)
,
AndroidUtilities
.
dp
(
100
)
);
TLRPC
.
PhotoSize
size
=
FileLoader
.
getClosestPhotoSizeWithSize
(
wallPaper
.
sizes
,
AndroidUtilities
.
dp
(
100
));
if
(
size
!=
null
&&
size
.
location
!=
null
)
{
image
.
setImage
(
size
.
location
,
"100_100"
,
0
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarLayer.java
View file @
33543423
...
...
@@ -110,7 +110,7 @@ public class ActionBarLayer extends FrameLayout {
}
private
void
positionLogoImage
(
int
height
)
{
if
(
logoImageView
!=
null
)
{
if
(
logoImageView
!=
null
&&
logoImageView
.
getDrawable
()
!=
null
)
{
LayoutParams
layoutParams
=
(
LayoutParams
)
logoImageView
.
getLayoutParams
();
if
(!
AndroidUtilities
.
isTablet
()
&&
getResources
().
getConfiguration
().
orientation
==
Configuration
.
ORIENTATION_LANDSCAPE
)
{
layoutParams
.
width
=
(
int
)(
logoImageView
.
getDrawable
().
getIntrinsicWidth
()
/
1.3f
);
...
...
@@ -482,7 +482,7 @@ public class ActionBarLayer extends FrameLayout {
}
public
void
setBackOverlayVisible
(
boolean
visible
)
{
if
(
actionOverlay
==
null
)
{
if
(
actionOverlay
==
null
||
parentFragment
==
null
||
parentFragment
.
parentLayout
==
null
)
{
return
;
}
isBackOverlayVisible
=
visible
;
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ActionBar/ActionBarMenuItem.java
View file @
33543423
...
...
@@ -218,6 +218,17 @@ public class ActionBarMenuItem extends ImageView {
popupWindow
.
setInputMethodMode
(
ActionBarPopupWindow
.
INPUT_METHOD_NOT_NEEDED
);
popupWindow
.
setSoftInputMode
(
WindowManager
.
LayoutParams
.
SOFT_INPUT_STATE_UNSPECIFIED
);
popupLayout
.
measure
(
MeasureSpec
.
makeMeasureSpec
(
AndroidUtilities
.
dp
(
1000
),
MeasureSpec
.
AT_MOST
),
MeasureSpec
.
makeMeasureSpec
(
AndroidUtilities
.
dp
(
1000
),
MeasureSpec
.
AT_MOST
));
popupWindow
.
getContentView
().
setFocusableInTouchMode
(
true
);
popupWindow
.
getContentView
().
setOnKeyListener
(
new
OnKeyListener
()
{
@Override
public
boolean
onKey
(
View
v
,
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_MENU
&&
event
.
getRepeatCount
()
==
0
&&
event
.
getAction
()
==
KeyEvent
.
ACTION_UP
&&
popupWindow
!=
null
&&
popupWindow
.
isShowing
())
{
popupWindow
.
dismiss
();
return
true
;
}
return
false
;
}
});
}
popupWindow
.
setFocusable
(
true
);
if
(
popupLayout
.
getMeasuredWidth
()
==
0
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java
View file @
33543423
...
...
@@ -510,7 +510,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
});
emojiPopup
=
new
PopupWindow
(
emojiView
);
/*
U
try {
/*try {
Method method = emojiPopup.getClass().getMethod("setWindowLayoutType", int.class);
if (method != null) {
method.invoke(emojiPopup, WindowManager.LayoutParams.LAST_SUB_WINDOW);
...
...
@@ -545,7 +545,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
@Override
public
void
run
()
{
if
(
messsageEditText
!=
null
)
{
messsageEditText
.
requestFocus
();
try
{
messsageEditText
.
requestFocus
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
}
},
600
);
...
...
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