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
288fceeb
Commit
288fceeb
authored
Oct 15, 2014
by
DrKLO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI improvements
parent
2f23635e
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
906 additions
and
1058 deletions
+906
-1058
MessageObject.java
...roj/src/main/java/org/telegram/android/MessageObject.java
+37
-29
FileLoader.java
...Proj/src/main/java/org/telegram/messenger/FileLoader.java
+24
-12
BaseCell.java
...gesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java
+58
-0
ChatActionCell.java
...j/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
+188
-45
ChatBaseCell.java
...roj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
+12
-56
ChatContactCell.java
.../src/main/java/org/telegram/ui/Cells/ChatContactCell.java
+271
-0
ChatMediaCell.java
...oj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
+5
-1
ChatActivity.java
...sagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+278
-668
LaunchActivity.java
...gesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+5
-6
HorizontalListView.java
...c/main/java/org/telegram/ui/Views/HorizontalListView.java
+4
-4
MessageActionLayout.java
.../main/java/org/telegram/ui/Views/MessageActionLayout.java
+0
-42
TightTextView.java
...oj/src/main/java/org/telegram/ui/Views/TightTextView.java
+0
-118
URLSpanNoUnderline.java
...c/main/java/org/telegram/ui/Views/URLSpanNoUnderline.java
+24
-0
chat_action_change_photo_layout.xml
...j/src/main/res/layout/chat_action_change_photo_layout.xml
+0
-42
chat_action_message_layout.xml
...esProj/src/main/res/layout/chat_action_message_layout.xml
+0
-35
No files found.
TMessagesProj/src/main/java/org/telegram/android/MessageObject.java
View file @
288fceeb
...
...
@@ -12,8 +12,11 @@ import android.graphics.Bitmap;
import
android.graphics.Paint
;
import
android.text.Layout
;
import
android.text.Spannable
;
import
android.text.SpannableStringBuilder
;
import
android.text.Spanned
;
import
android.text.StaticLayout
;
import
android.text.TextPaint
;
import
android.text.TextUtils
;
import
android.text.util.Linkify
;
import
org.telegram.messenger.ConnectionsManager
;
...
...
@@ -22,6 +25,7 @@ import org.telegram.messenger.FileLog;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.R
;
import
org.telegram.messenger.UserConfig
;
import
org.telegram.ui.Views.URLSpanNoUnderline
;
import
java.util.AbstractMap
;
import
java.util.ArrayList
;
...
...
@@ -91,7 +95,7 @@ public class MessageObject {
messageText
=
LocaleController
.
getString
(
"ActionYouCreateGroup"
,
R
.
string
.
ActionYouCreateGroup
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
getString
(
"ActionCreateGroup"
,
R
.
string
.
ActionCreateGroup
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionCreateGroup"
,
R
.
string
.
ActionCreateGroup
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionCreateGroup"
,
R
.
string
.
ActionCreateGroup
).
replace
(
"un1"
,
""
);
}
...
...
@@ -102,26 +106,27 @@ public class MessageObject {
messageText
=
LocaleController
.
getString
(
"ActionYouLeftUser"
,
R
.
string
.
ActionYouLeftUser
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
getString
(
"ActionLeftUser"
,
R
.
string
.
ActionLeftUser
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionLeftUser"
,
R
.
string
.
ActionLeftUser
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionLeftUser"
,
R
.
string
.
ActionLeftUser
).
replace
(
"un1"
,
""
);
}
}
}
else
{
TLRPC
.
User
who
=
null
;
TLRPC
.
User
who
User
=
null
;
if
(
users
!=
null
)
{
who
=
users
.
get
(
message
.
action
.
user_id
);
who
User
=
users
.
get
(
message
.
action
.
user_id
);
}
if
(
who
==
null
)
{
who
=
MessagesController
.
getInstance
().
getUser
(
message
.
action
.
user_id
);
if
(
who
User
==
null
)
{
who
User
=
MessagesController
.
getInstance
().
getUser
(
message
.
action
.
user_id
);
}
if
(
who
!=
null
&&
fromUser
!=
null
)
{
if
(
who
User
!=
null
&&
fromUser
!=
null
)
{
if
(
isFromMe
())
{
messageText
=
LocaleController
.
getString
(
"ActionYouKickUser"
,
R
.
string
.
ActionYouKickUser
).
replace
(
"un2"
,
ContactsController
.
formatName
(
who
.
first_name
,
who
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionYouKickUser"
,
R
.
string
.
ActionYouKickUser
),
"un2"
,
whoUser
);
}
else
if
(
message
.
action
.
user_id
==
UserConfig
.
getClientUserId
())
{
messageText
=
LocaleController
.
getString
(
"ActionKickUserYou"
,
R
.
string
.
ActionKickUserYou
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionKickUserYou"
,
R
.
string
.
ActionKickUserYou
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionKickUser"
,
R
.
string
.
ActionKickUser
).
replace
(
"un2"
,
ContactsController
.
formatName
(
who
.
first_name
,
who
.
last_name
)).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
));
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionKickUser"
,
R
.
string
.
ActionKickUser
),
"un2"
,
whoUser
);
messageText
=
replaceWithLink
(
messageText
,
"un1"
,
fromUser
);
}
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionKickUser"
,
R
.
string
.
ActionKickUser
).
replace
(
"un2"
,
""
).
replace
(
"un1"
,
""
);
...
...
@@ -137,11 +142,12 @@ public class MessageObject {
}
if
(
whoUser
!=
null
&&
fromUser
!=
null
)
{
if
(
isFromMe
())
{
messageText
=
LocaleController
.
getString
(
"ActionYouAddUser"
,
R
.
string
.
ActionYouAddUser
).
replace
(
"un2"
,
ContactsController
.
formatName
(
whoUser
.
first_name
,
whoUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionYouAddUser"
,
R
.
string
.
ActionYouAddUser
),
"un2"
,
whoUser
);
}
else
if
(
message
.
action
.
user_id
==
UserConfig
.
getClientUserId
())
{
messageText
=
LocaleController
.
getString
(
"ActionAddUserYou"
,
R
.
string
.
ActionAddUserYou
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionAddUserYou"
,
R
.
string
.
ActionAddUserYou
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionAddUser"
,
R
.
string
.
ActionAddUser
).
replace
(
"un2"
,
ContactsController
.
formatName
(
whoUser
.
first_name
,
whoUser
.
last_name
)).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
));
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionAddUser"
,
R
.
string
.
ActionAddUser
),
"un2"
,
whoUser
);
messageText
=
replaceWithLink
(
messageText
,
"un1"
,
fromUser
);
}
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionAddUser"
,
R
.
string
.
ActionAddUser
).
replace
(
"un2"
,
""
).
replace
(
"un1"
,
""
);
...
...
@@ -151,7 +157,7 @@ public class MessageObject {
messageText
=
LocaleController
.
getString
(
"ActionYouChangedPhoto"
,
R
.
string
.
ActionYouChangedPhoto
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
getString
(
"ActionChangedPhoto"
,
R
.
string
.
ActionChangedPhoto
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionChangedPhoto"
,
R
.
string
.
ActionChangedPhoto
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionChangedPhoto"
,
R
.
string
.
ActionChangedPhoto
).
replace
(
"un1"
,
""
);
}
...
...
@@ -161,7 +167,7 @@ public class MessageObject {
messageText
=
LocaleController
.
getString
(
"ActionYouChangedTitle"
,
R
.
string
.
ActionYouChangedTitle
).
replace
(
"un2"
,
message
.
action
.
title
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
getString
(
"ActionChangedTitle"
,
R
.
string
.
ActionChangedTitle
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)).
replace
(
"un2"
,
message
.
action
.
title
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionChangedTitle"
,
R
.
string
.
ActionChangedTitle
).
replace
(
"un2"
,
message
.
action
.
title
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionChangedTitle"
,
R
.
string
.
ActionChangedTitle
).
replace
(
"un1"
,
""
).
replace
(
"un2"
,
message
.
action
.
title
);
}
...
...
@@ -171,7 +177,7 @@ public class MessageObject {
messageText
=
LocaleController
.
getString
(
"ActionYouRemovedPhoto"
,
R
.
string
.
ActionYouRemovedPhoto
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
getString
(
"ActionRemovedPhoto"
,
R
.
string
.
ActionRemovedPhoto
).
replace
(
"un1"
,
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
)
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionRemovedPhoto"
,
R
.
string
.
ActionRemovedPhoto
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
getString
(
"ActionRemovedPhoto"
,
R
.
string
.
ActionRemovedPhoto
).
replace
(
"un1"
,
""
);
}
...
...
@@ -232,7 +238,7 @@ public class MessageObject {
messageText
=
LocaleController
.
formatString
(
"ActionTakeScreenshootYou"
,
R
.
string
.
ActionTakeScreenshootYou
);
}
else
{
if
(
fromUser
!=
null
)
{
messageText
=
LocaleController
.
formatString
(
"ActionTakeScreenshoot"
,
R
.
string
.
ActionTakeScreenshoot
).
replace
(
"un1"
,
fromUser
.
first_name
);
messageText
=
replaceWithLink
(
LocaleController
.
getString
(
"ActionTakeScreenshoot"
,
R
.
string
.
ActionTakeScreenshoot
),
"un1"
,
fromUser
);
}
else
{
messageText
=
LocaleController
.
formatString
(
"ActionTakeScreenshoot"
,
R
.
string
.
ActionTakeScreenshoot
).
replace
(
"un1"
,
""
);
}
...
...
@@ -263,7 +269,7 @@ public class MessageObject {
}
messageText
=
Emoji
.
replaceEmoji
(
messageText
,
textPaint
.
getFontMetricsInt
(),
AndroidUtilities
.
dp
(
20
));
if
(
message
instanceof
TLRPC
.
TL_message
||
(
message
instanceof
TLRPC
.
TL_messageForwarded
&&
(
message
.
media
==
null
||
!(
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)))
)
{
if
(
message
instanceof
TLRPC
.
TL_message
||
message
instanceof
TLRPC
.
TL_messageForwarded
)
{
if
(
message
.
media
==
null
||
message
.
media
instanceof
TLRPC
.
TL_messageMediaEmpty
)
{
contentType
=
type
=
0
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaPhoto
)
{
...
...
@@ -275,13 +281,8 @@ public class MessageObject {
contentType
=
1
;
type
=
3
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaContact
)
{
if
(
isFromMe
())
{
contentType
=
3
;
type
=
12
;
}
else
{
contentType
=
4
;
type
=
13
;
}
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaUnsupported
)
{
contentType
=
type
=
0
;
}
else
if
(
message
.
media
!=
null
&&
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
...
...
@@ -298,14 +299,12 @@ public class MessageObject {
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionLoginUnknownLocation
)
{
contentType
=
type
=
0
;
}
else
if
(
message
.
action
instanceof
TLRPC
.
TL_messageActionChatEditPhoto
||
message
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
contentType
=
8
;
contentType
=
4
;
type
=
11
;
}
else
{
contentType
=
7
;
contentType
=
4
;
type
=
10
;
}
}
else
if
(
message
instanceof
TLRPC
.
TL_messageForwarded
)
{
contentType
=
type
=
0
;
}
Calendar
rightNow
=
new
GregorianCalendar
();
...
...
@@ -319,6 +318,15 @@ public class MessageObject {
generateThumbs
(
false
,
preview
);
}
public
CharSequence
replaceWithLink
(
CharSequence
source
,
String
param
,
TLRPC
.
User
user
)
{
String
name
=
ContactsController
.
formatName
(
user
.
first_name
,
user
.
last_name
);
int
start
=
TextUtils
.
indexOf
(
source
,
param
);
URLSpanNoUnderline
span
=
new
URLSpanNoUnderline
(
""
+
user
.
id
);
SpannableStringBuilder
builder
=
new
SpannableStringBuilder
(
TextUtils
.
replace
(
source
,
new
String
[]{
param
},
new
String
[]{
name
}));
builder
.
setSpan
(
span
,
start
,
start
+
name
.
length
(),
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
return
builder
;
}
public
void
generateThumbs
(
boolean
update
,
int
preview
)
{
if
(
messageOwner
instanceof
TLRPC
.
TL_messageService
)
{
if
(
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionChatEditPhoto
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
View file @
288fceeb
...
...
@@ -564,6 +564,17 @@ public class FileLoader {
if
(
message
==
null
)
{
return
new
File
(
""
);
}
if
(
message
instanceof
TLRPC
.
TL_messageService
)
{
if
(
message
.
action
.
photo
!=
null
)
{
ArrayList
<
TLRPC
.
PhotoSize
>
sizes
=
message
.
action
.
photo
.
sizes
;
if
(
sizes
.
size
()
>
0
)
{
TLRPC
.
PhotoSize
sizeFull
=
getClosestPhotoSizeWithSize
(
sizes
,
AndroidUtilities
.
getPhotoSize
());
if
(
sizeFull
!=
null
)
{
return
getPathToAttach
(
sizeFull
);
}
}
}
}
else
{
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaVideo
)
{
return
getPathToAttach
(
message
.
media
.
video
);
}
else
if
(
message
.
media
instanceof
TLRPC
.
TL_messageMediaDocument
)
{
...
...
@@ -579,6 +590,7 @@ public class FileLoader {
}
}
}
}
return
new
File
(
""
);
}
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java
View file @
288fceeb
...
...
@@ -10,10 +10,43 @@ package org.telegram.ui.Cells;
import
android.content.Context
;
import
android.graphics.drawable.Drawable
;
import
android.view.HapticFeedbackConstants
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewConfiguration
;
public
class
BaseCell
extends
View
{
private
final
class
CheckForTap
implements
Runnable
{
public
void
run
()
{
if
(
pendingCheckForLongPress
==
null
)
{
pendingCheckForLongPress
=
new
CheckForLongPress
();
}
pendingCheckForLongPress
.
currentPressCount
=
++
pressCount
;
postDelayed
(
pendingCheckForLongPress
,
ViewConfiguration
.
getLongPressTimeout
()
-
ViewConfiguration
.
getTapTimeout
());
}
}
class
CheckForLongPress
implements
Runnable
{
public
int
currentPressCount
;
public
void
run
()
{
if
(
checkingForLongPress
&&
getParent
()
!=
null
&&
currentPressCount
==
pressCount
)
{
checkingForLongPress
=
false
;
MotionEvent
event
=
MotionEvent
.
obtain
(
0
,
0
,
MotionEvent
.
ACTION_CANCEL
,
0
,
0
,
0
);
onTouchEvent
(
event
);
event
.
recycle
();
performHapticFeedback
(
HapticFeedbackConstants
.
LONG_PRESS
);
onLongPress
();
}
}
}
private
boolean
checkingForLongPress
=
false
;
private
CheckForLongPress
pendingCheckForLongPress
=
null
;
private
int
pressCount
=
0
;
private
CheckForTap
pendingCheckForTap
=
null
;
public
BaseCell
(
Context
context
)
{
super
(
context
);
}
...
...
@@ -25,4 +58,29 @@ public class BaseCell extends View {
protected
void
setDrawableBounds
(
Drawable
drawable
,
int
x
,
int
y
,
int
w
,
int
h
)
{
drawable
.
setBounds
(
x
,
y
,
x
+
w
,
y
+
h
);
}
protected
void
startCheckLongPress
()
{
if
(
checkingForLongPress
)
{
return
;
}
checkingForLongPress
=
true
;
if
(
pendingCheckForTap
==
null
)
{
pendingCheckForTap
=
new
CheckForTap
();
}
postDelayed
(
pendingCheckForTap
,
ViewConfiguration
.
getTapTimeout
());
}
protected
void
cancelCheckLongPress
()
{
checkingForLongPress
=
false
;
if
(
pendingCheckForLongPress
!=
null
)
{
removeCallbacks
(
pendingCheckForLongPress
);
}
if
(
pendingCheckForTap
!=
null
)
{
removeCallbacks
(
pendingCheckForTap
);
}
}
protected
void
onLongPress
()
{
}
}
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
View file @
288fceeb
...
...
@@ -9,36 +9,58 @@
package
org
.
telegram
.
ui
.
Cells
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.drawable.Drawable
;
import
android.text.Layout
;
import
android.text.Spannable
;
import
android.text.StaticLayout
;
import
android.text.TextPaint
;
import
android.text.style.URLSpan
;
import
android.view.MotionEvent
;
import
android.view.SoundEffectConstants
;
import
org.telegram.android.AndroidUtilities
;
import
org.telegram.android.ImageReceiver
;
import
org.telegram.android.MessageObject
;
import
org.telegram.android.MessagesController
;
import
org.telegram.android.PhotoObject
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.messenger.R
;
import
org.telegram.messenger.TLRPC
;
import
org.telegram.messenger.UserConfig
;
import
org.telegram.ui.PhotoViewer
;
public
class
ChatActionCell
extends
BaseCell
{
public
static
interface
ChatActionCellDelegate
{
public
abstract
void
didClickedImage
(
ChatActionCell
cell
);
public
abstract
void
didLongPressed
(
ChatActionCell
cell
);
public
abstract
void
needOpenUserProfile
(
int
uid
);
}
private
static
Drawable
backgroundBlack
;
private
static
Drawable
backgroundBlue
;
private
static
TextPaint
textPaint
;
private
URLSpan
pressedLink
;
private
ImageReceiver
imageReceiver
;
private
StaticLayout
textLayout
;
private
int
textWidth
=
0
;
private
int
textHeight
=
0
;
private
int
textX
=
0
;
private
int
textXLeft
=
0
;
private
int
textY
=
0
;
private
int
textXLeft
=
0
;
private
boolean
useBlackBackground
=
false
;
private
boolean
wasLayout
=
false
;
private
int
previousWidth
=
0
;
private
boolean
imagePressed
=
false
;
private
MessageObject
currentMessageObject
;
private
ChatActionCellDelegate
delegate
;
public
ChatActionCell
(
Context
context
)
{
super
(
context
);
if
(
backgroundBlack
==
null
)
{
...
...
@@ -47,73 +69,194 @@ public class ChatActionCell extends BaseCell {
textPaint
=
new
TextPaint
(
Paint
.
ANTI_ALIAS_FLAG
);
textPaint
.
setColor
(
0xffffffff
);
textPaint
.
linkColor
=
0xffffffff
;
}
imageReceiver
=
new
ImageReceiver
(
this
);
textPaint
.
setTextSize
(
AndroidUtilities
.
dp
(
MessagesController
.
getInstance
().
fontSize
));
}
public
void
setDelegate
(
ChatActionCellDelegate
delegate
)
{
this
.
delegate
=
delegate
;
}
public
void
setMessageObject
(
MessageObject
messageObject
)
{
if
(
currentMessageObject
==
messageObject
)
{
return
;
}
currentMessageObject
=
messageObject
;
int
size
;
if
(
AndroidUtilities
.
isTablet
())
{
size
=
AndroidUtilities
.
getMinTabletSide
();
previousWidth
=
0
;
if
(
currentMessageObject
.
type
==
11
)
{
int
id
=
0
;
if
(
messageObject
.
messageOwner
.
to_id
!=
null
)
{
if
(
messageObject
.
messageOwner
.
to_id
.
chat_id
!=
0
)
{
id
=
messageObject
.
messageOwner
.
to_id
.
chat_id
;
}
else
{
id
=
messageObject
.
messageOwner
.
to_id
.
user_id
;
if
(
id
==
UserConfig
.
getClientUserId
())
{
id
=
messageObject
.
messageOwner
.
from_id
;
}
}
}
if
(
currentMessageObject
.
messageOwner
.
action
instanceof
TLRPC
.
TL_messageActionUserUpdatedPhoto
)
{
imageReceiver
.
setImage
(
currentMessageObject
.
messageOwner
.
action
.
newUserPhoto
.
photo_small
,
"50_50"
,
getResources
().
getDrawable
(
AndroidUtilities
.
getUserAvatarForId
(
id
)),
false
);
}
else
{
PhotoObject
photo
=
PhotoObject
.
getClosestImageWithSize
(
currentMessageObject
.
photoThumbs
,
AndroidUtilities
.
dp
(
64
));
if
(
photo
!=
null
)
{
if
(
photo
.
image
!=
null
)
{
imageReceiver
.
setImageBitmap
(
photo
.
image
);
}
else
{
imageReceiver
.
setImage
(
photo
.
photoOwner
.
location
,
"50_50"
,
getResources
().
getDrawable
(
AndroidUtilities
.
getGroupAvatarForId
(
id
)),
false
);
}
}
else
{
imageReceiver
.
setImageBitmap
(
getResources
().
getDrawable
(
AndroidUtilities
.
getGroupAvatarForId
(
id
)));
}
}
imageReceiver
.
setVisible
(!
PhotoViewer
.
getInstance
().
isShowingImage
(
currentMessageObject
),
false
);
}
else
{
imageReceiver
.
setImageBitmap
((
Bitmap
)
null
);
}
requestLayout
();
}
public
void
setUseBlackBackground
(
boolean
value
)
{
useBlackBackground
=
value
;
}
public
MessageObject
getMessageObject
()
{
return
currentMessageObject
;
}
public
ImageReceiver
getPhotoImage
()
{
return
imageReceiver
;
}
@Override
protected
void
onLongPress
()
{
if
(
delegate
!=
null
)
{
delegate
.
didLongPressed
(
this
);
}
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
boolean
result
=
false
;
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
if
(
delegate
!=
null
)
{
if
(
currentMessageObject
.
type
==
11
&&
imageReceiver
.
isInsideImage
(
x
,
y
))
{
imagePressed
=
true
;
result
=
true
;
}
if
(
result
)
{
startCheckLongPress
();
}
}
}
else
{
if
(
event
.
getAction
()
!=
MotionEvent
.
ACTION_MOVE
)
{
cancelCheckLongPress
();
}
if
(
imagePressed
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
imagePressed
=
false
;
if
(
delegate
!=
null
)
{
delegate
.
didClickedImage
(
this
);
playSoundEffect
(
SoundEffectConstants
.
CLICK
);
}
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_CANCEL
)
{
imagePressed
=
false
;
}
else
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_MOVE
)
{
if
(!
imageReceiver
.
isInsideImage
(
x
,
y
))
{
imagePressed
=
false
;
}
}
}
}
if
(!
result
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
||
pressedLink
!=
null
&&
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
x
>=
textX
&&
y
>=
textY
&&
x
<=
textX
+
textWidth
&&
y
<=
textY
+
textHeight
)
{
y
-=
textY
;
x
-=
textXLeft
;
final
int
line
=
textLayout
.
getLineForVertical
((
int
)
y
);
final
int
off
=
textLayout
.
getOffsetForHorizontal
(
line
,
x
);
final
float
left
=
textLayout
.
getLineLeft
(
line
);
if
(
left
<=
x
&&
left
+
textLayout
.
getLineWidth
(
line
)
>=
x
)
{
Spannable
buffer
=
(
Spannable
)
currentMessageObject
.
messageText
;
URLSpan
[]
link
=
buffer
.
getSpans
(
off
,
off
,
URLSpan
.
class
);
if
(
link
.
length
!=
0
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
pressedLink
=
link
[
0
];
result
=
true
;
}
else
{
if
(
link
[
0
]
==
pressedLink
)
{
if
(
delegate
!=
null
)
{
delegate
.
needOpenUserProfile
(
Integer
.
parseInt
(
link
[
0
].
getURL
()));
}
result
=
true
;
}
}
}
else
{
size
=
Math
.
min
(
AndroidUtilities
.
displaySize
.
x
,
AndroidUtilities
.
displaySize
.
y
);
pressedLink
=
null
;
}
}
else
{
pressedLink
=
null
;
}
}
else
{
pressedLink
=
null
;
}
}
}
textLayout
=
new
StaticLayout
(
currentMessageObject
.
messageText
,
textPaint
,
size
-
AndroidUtilities
.
dp
(
30
),
Layout
.
Alignment
.
ALIGN_CENTER
,
1.0f
,
0.0f
,
false
);
if
(!
result
)
{
result
=
super
.
onTouchEvent
(
event
);
}
return
result
;
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
if
(
currentMessageObject
==
null
)
{
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
textHeight
+
AndroidUtilities
.
dp
(
14
));
return
;
}
int
width
=
MeasureSpec
.
getSize
(
widthMeasureSpec
);
if
(
width
!=
previousWidth
)
{
previousWidth
=
width
;
textLayout
=
new
StaticLayout
(
currentMessageObject
.
messageText
,
textPaint
,
width
-
AndroidUtilities
.
dp
(
30
),
Layout
.
Alignment
.
ALIGN_CENTER
,
1.0f
,
0.0f
,
false
);
textHeight
=
0
;
textWidth
=
0
;
try
{
int
linesCount
=
textLayout
.
getLineCount
();
boolean
hasNonRTL
=
false
;
for
(
int
a
=
0
;
a
<
linesCount
;
a
++)
{
float
lineWidth
=
0
;
float
lineLeft
=
0
;
try
{
lineWidth
=
textLayout
.
getLineWidth
(
a
);
lineLeft
=
textLayout
.
getLineLeft
(
a
);
textHeight
=
(
int
)
Math
.
max
(
textHeight
,
Math
.
ceil
(
textLayout
.
getLineBottom
(
a
)));
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
return
;
}
if
(
lineLeft
==
0
)
{
hasNonRTL
=
true
;
}
textWidth
=
(
int
)
Math
.
max
(
textWidth
,
Math
.
ceil
(
lineWidth
));
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
textY
=
AndroidUtilities
.
dp
(
7
);
wasLayout
=
false
;
requestLayout
();
}
public
void
setUseBlackBackground
(
boolean
value
)
{
useBlackBackground
=
value
;
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
textHeight
+
AndroidUtilities
.
dp
(
14
));
}
textX
=
(
width
-
textWidth
)
/
2
;
textY
=
AndroidUtilities
.
dp
(
7
);
textXLeft
=
(
width
-
textLayout
.
getWidth
())
/
2
;
@Override
protected
void
onLayout
(
boolean
changed
,
int
left
,
int
top
,
int
right
,
int
bottom
)
{
if
(
currentMessageObject
==
null
)
{
super
.
onLayout
(
changed
,
left
,
top
,
right
,
bottom
);
return
;
if
(
currentMessageObject
.
type
==
11
)
{
imageReceiver
.
setImageCoords
((
width
-
AndroidUtilities
.
dp
(
64
))
/
2
,
textHeight
+
AndroidUtilities
.
dp
(
15
),
AndroidUtilities
.
dp
(
64
),
AndroidUtilities
.
dp
(
64
));
}
if
(!
wasLayout
||
changed
)
{
textX
=
(
right
-
left
-
textWidth
)
/
2
;
textXLeft
=
(
right
-
left
-
textLayout
.
getWidth
())
/
2
;
wasLayout
=
true
;
}
setMeasuredDimension
(
width
,
textHeight
+
AndroidUtilities
.
dp
(
14
+
(
currentMessageObject
.
type
==
11
?
70
:
0
)));
}
@Override
...
...
@@ -121,10 +264,6 @@ public class ChatActionCell extends BaseCell {
if
(
currentMessageObject
==
null
)
{
return
;
}
if
(!
wasLayout
)
{
requestLayout
();
return
;
}
Drawable
backgroundDrawable
=
null
;
if
(
useBlackBackground
)
{
...
...
@@ -132,9 +271,13 @@ public class ChatActionCell extends BaseCell {
}
else
{
backgroundDrawable
=
backgroundBlue
;
}
backgroundDrawable
.
setBounds
(
textX
-
AndroidUtilities
.
dp
(
5
),
AndroidUtilities
.
dp
(
5
),
textX
+
textWidth
+
AndroidUtilities
.
dp
(
5
),
getMeasuredHeight
()
-
AndroidUtilities
.
dp
(
5
)
);
backgroundDrawable
.
setBounds
(
textX
-
AndroidUtilities
.
dp
(
5
),
AndroidUtilities
.
dp
(
5
),
textX
+
textWidth
+
AndroidUtilities
.
dp
(
5
),
AndroidUtilities
.
dp
(
9
)
+
textHeight
);
backgroundDrawable
.
draw
(
canvas
);
if
(
currentMessageObject
.
type
==
11
)
{
imageReceiver
.
draw
(
canvas
,
imageReceiver
.
getImageX
(),
imageReceiver
.
getImageY
(),
imageReceiver
.
getImageWidth
(),
imageReceiver
.
getImageHeight
());
}
canvas
.
save
();
canvas
.
translate
(
textXLeft
,
textY
);
textLayout
.
draw
(
canvas
);
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
View file @
288fceeb
...
...
@@ -17,10 +17,8 @@ import android.text.Layout;
import
android.text.StaticLayout
;
import
android.text.TextPaint
;
import
android.text.TextUtils
;
import
android.view.HapticFeedbackConstants
;
import
android.view.MotionEvent
;
import
android.view.SoundEffectConstants
;
import
android.view.ViewConfiguration
;
import
org.telegram.android.AndroidUtilities
;
import
org.telegram.android.ContactsController
;
...
...
@@ -108,45 +106,13 @@ public class ChatBaseCell extends BaseCell {
private
TLRPC
.
User
currentForwardUser
;
private
String
currentForwardNameString
;
p
ublic
ChatBaseCellDelegate
delegate
;
p
rotected
ChatBaseCellDelegate
delegate
;
protected
int
namesOffset
=
0
;
private
boolean
checkingForLongPress
=
false
;
private
int
pressCount
=
0
;
private
CheckForLongPress
pendingCheckForLongPress
=
null
;
private
CheckForTap
pendingCheckForTap
=
null
;
private
int
last_send_state
=
0
;
private
int
last_delete_date
=
0
;
private
final
class
CheckForTap
implements
Runnable
{
public
void
run
()
{
if
(
pendingCheckForLongPress
==
null
)
{
pendingCheckForLongPress
=
new
CheckForLongPress
();
}
pendingCheckForLongPress
.
currentPressCount
=
++
pressCount
;
postDelayed
(
pendingCheckForLongPress
,
ViewConfiguration
.
getLongPressTimeout
()
-
ViewConfiguration
.
getTapTimeout
());
}
}
class
CheckForLongPress
implements
Runnable
{
public
int
currentPressCount
;
public
void
run
()
{
if
(
checkingForLongPress
&&
getParent
()
!=
null
&&
currentPressCount
==
pressCount
)
{
if
(
delegate
!=
null
)
{
checkingForLongPress
=
false
;
MotionEvent
event
=
MotionEvent
.
obtain
(
0
,
0
,
MotionEvent
.
ACTION_CANCEL
,
0
,
0
,
0
);
onTouchEvent
(
event
);
event
.
recycle
();
performHapticFeedback
(
HapticFeedbackConstants
.
LONG_PRESS
);
delegate
.
didLongPressed
(
ChatBaseCell
.
this
);
}
}
}
}
public
ChatBaseCell
(
Context
context
)
{
super
(
context
);
if
(
backgroundDrawableIn
==
null
)
{
...
...
@@ -203,6 +169,10 @@ public class ChatBaseCell extends BaseCell {
invalidate
();
}
public
void
setDelegate
(
ChatBaseCellDelegate
delegate
)
{
this
.
delegate
=
delegate
;
}
public
void
setCheckPressed
(
boolean
value
,
boolean
pressed
)
{
isCheckPressed
=
value
;
isPressed
=
pressed
;
...
...
@@ -345,27 +315,6 @@ public class ChatBaseCell extends BaseCell {
return
backgroundWidth
-
AndroidUtilities
.
dp
(
8
);
}
protected
void
startCheckLongPress
()
{
if
(
checkingForLongPress
)
{
return
;
}
checkingForLongPress
=
true
;
if
(
pendingCheckForTap
==
null
)
{
pendingCheckForTap
=
new
CheckForTap
();
}
postDelayed
(
pendingCheckForTap
,
ViewConfiguration
.
getTapTimeout
());
}
protected
void
cancelCheckLongPress
()
{
checkingForLongPress
=
false
;
if
(
pendingCheckForLongPress
!=
null
)
{
removeCallbacks
(
pendingCheckForLongPress
);
}
if
(
pendingCheckForTap
!=
null
)
{
removeCallbacks
(
pendingCheckForTap
);
}
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
boolean
result
=
false
;
...
...
@@ -462,6 +411,13 @@ public class ChatBaseCell extends BaseCell {
}
@Override
protected
void
onLongPress
()
{
if
(
delegate
!=
null
)
{
delegate
.
didLongPressed
(
this
);
}
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
if
(
currentMessageObject
==
null
)
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java
0 → 100644
View file @
288fceeb
/*
* This is the source code of Telegram for Android v. 1.7.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
.
Cells
;
import
android.content.Context
;
public
class
ChatContactCell
extends
ChatBaseCell
{
public
ChatContactCell
(
Context
context
)
{
super
(
context
);
}
/*
public class ChatListRowHolderEx {
public BackupImageView avatarImageView;
public TextView nameTextView;
public TextView messageTextView;
public TextView timeTextView;
public ImageView halfCheckImage;
public ImageView checkImage;
public MessageObject message;
public TextView phoneTextView;
public BackupImageView contactAvatar;
public View contactView;
public ImageView addContactButton;
public View addContactView;
public View chatBubbleView;
public void update() {
TLRPC.User fromUser = MessagesController.getInstance().getUser(message.messageOwner.from_id);
int type = message.type;
if (timeTextView != null) {
timeTextView.setText(LocaleController.formatterDay.format((long) (message.messageOwner.date) * 1000));
}
if (avatarImageView != null && fromUser != null) {
TLRPC.FileLocation photo = null;
if (fromUser.photo != null) {
photo = fromUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(fromUser.id);
avatarImageView.setImage(photo, "50_50", placeHolderId);
}
if (type != 12 && type != 13 && nameTextView != null && fromUser != null && type != 8 && type != 9) {
nameTextView.setText(ContactsController.formatName(fromUser.first_name, fromUser.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.from_id));
}
if (type == 12 || type == 13) {
TLRPC.User contactUser = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
if (contactUser != null) {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(contactUser.id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (!phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
TLRPC.FileLocation photo = null;
if (contactUser.photo != null) {
photo = contactUser.photo.photo_small;
}
int placeHolderId = AndroidUtilities.getUserAvatarForId(contactUser.id);
contactAvatar.setImage(photo, "50_50", placeHolderId);
if (contactUser.id != UserConfig.getClientUserId() && ContactsController.getInstance().contactsDict.get(contactUser.id) == null) {
addContactView.setVisibility(View.VISIBLE);
} else {
addContactView.setVisibility(View.GONE);
}
} else {
nameTextView.setText(ContactsController.formatName(message.messageOwner.media.first_name, message.messageOwner.media.last_name));
nameTextView.setTextColor(AndroidUtilities.getColorForId(message.messageOwner.media.user_id));
String phone = message.messageOwner.media.phone_number;
if (phone != null && phone.length() != 0) {
if (message.messageOwner.media.user_id != 0 && !phone.startsWith("+")) {
phone = "+" + phone;
}
phoneTextView.setText(PhoneFormat.getInstance().format(phone));
} else {
phoneTextView.setText("Unknown");
}
contactAvatar.setImageResource(AndroidUtilities.getUserAvatarForId(message.messageOwner.media.user_id));
addContactView.setVisibility(View.GONE);
}
} else if (type == 6) {
messageTextView.setTextSize(16);
messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
}
if (message.isFromMe()) {
if (halfCheckImage != null) {
if (message.isSending()) {
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_clock);
halfCheckImage.setVisibility(View.VISIBLE);
} else if (message.isSendError()) {
halfCheckImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_warning);
if (checkImage != null) {
checkImage.setVisibility(View.INVISIBLE);
}
} else if (message.isSent()) {
if (!message.isUnread()) {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.VISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_halfcheck);
} else {
halfCheckImage.setVisibility(View.VISIBLE);
checkImage.setVisibility(View.INVISIBLE);
halfCheckImage.setImageResource(R.drawable.msg_check);
}
}
}
}
}
public ChatListRowHolderEx(View view, int type) {
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_group_avatar_image);
nameTextView = (TextView)view.findViewById(R.id.chat_user_group_name);
timeTextView = (TextView)view.findViewById(R.id.chat_time_text);
halfCheckImage = (ImageView)view.findViewById(R.id.chat_row_halfcheck);
checkImage = (ImageView)view.findViewById(R.id.chat_row_check);
messageTextView = (TextView)view.findViewById(R.id.chat_message_text);
phoneTextView = (TextView)view.findViewById(R.id.phone_text_view);
contactAvatar = (BackupImageView)view.findViewById(R.id.contact_avatar);
contactView = view.findViewById(R.id.shared_layout);
addContactButton = (ImageView)view.findViewById(R.id.add_contact_button);
addContactView = view.findViewById(R.id.add_contact_view);
chatBubbleView = view.findViewById(R.id.chat_bubble_layout);
if (messageTextView != null) {
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
}
if (addContactButton != null) {
addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
args.putString("phone", message.messageOwner.media.phone_number);
presentFragment(new ContactAddActivity(args));
}
});
addContactButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactView != null) {
contactView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (message.type == 12 || message.type == 13) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message.messageOwner.media.user_id != UserConfig.getClientUserId()) {
TLRPC.User user = null;
if (message.messageOwner.media.user_id != 0) {
user = MessagesController.getInstance().getUser(message.messageOwner.media.user_id);
}
if (user != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.media.user_id);
presentFragment(new UserProfileActivity(args));
} else {
if (message.messageOwner.media.phone_number == null || message.messageOwner.media.phone_number.length() == 0) {
return;
}
if (getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 1) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + message.messageOwner.media.phone_number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getParentActivity().startActivity(intent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else if (i == 0) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(message.messageOwner.media.phone_number);
} else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("label", message.messageOwner.media.phone_number);
clipboard.setPrimaryClip(clip);
}
}
}
}
);
showAlertDialog(builder);
}
}
}
}
});
contactView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
createMenu(v, false);
return true;
}
});
}
if (contactAvatar != null) {
contactAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
if (avatarImageView != null) {
avatarImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
return;
}
if (message != null) {
Bundle args = new Bundle();
args.putInt("user_id", message.messageOwner.from_id);
presentFragment(new UserProfileActivity(args));
}
}
});
}
}
private void processOnClick(View view) {
if (actionBarLayer.isActionModeShowed()) {
processRowSelect(view);
}
}
}
*/
}
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
View file @
288fceeb
...
...
@@ -93,7 +93,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
private
int
nameWidth
=
0
;
private
String
currentNameString
;
p
ublic
ChatMediaCellDelegate
mediaDelegate
=
null
;
p
rivate
ChatMediaCellDelegate
mediaDelegate
=
null
;
private
float
currentProgress
=
0
;
private
RectF
progressRect
=
new
RectF
();
...
...
@@ -165,6 +165,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
}
}
public
void
setMediaDelegate
(
ChatMediaCellDelegate
delegate
)
{
this
.
mediaDelegate
=
delegate
;
}
@Override
protected
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
...
...
TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
View file @
288fceeb
...
...
@@ -33,13 +33,11 @@ import android.provider.MediaStore;
import
android.text.Html
;
import
android.text.TextUtils
;
import
android.util.SparseArray
;
import
android.util.TypedValue
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewParent
;
import
android.view.ViewTreeObserver
;
import
android.webkit.MimeTypeMap
;
import
android.widget.AbsListView
;
...
...
@@ -64,7 +62,6 @@ import org.telegram.messenger.TLRPC;
import
org.telegram.android.ContactsController
;
import
org.telegram.messenger.FileLog
;
import
org.telegram.android.MessageObject
;
import
org.telegram.android.PhotoObject
;
import
org.telegram.messenger.ConnectionsManager
;
import
org.telegram.android.MessagesController
;
import
org.telegram.android.NotificationCenter
;
...
...
@@ -75,9 +72,11 @@ import org.telegram.ui.Adapters.BaseFragmentAdapter;
import
org.telegram.ui.Cells.ChatActionCell
;
import
org.telegram.ui.Cells.ChatAudioCell
;
import
org.telegram.ui.Cells.ChatBaseCell
;
import
org.telegram.ui.Cells.ChatContactCell
;
import
org.telegram.ui.Cells.ChatMediaCell
;
import
org.telegram.ui.Cells.ChatMessageCell
;
import
org.telegram.ui.Views.ActionBar.ActionBarLayer
;
import
org.telegram.ui.Views.ActionBar.ActionBarLayout
;
import
org.telegram.ui.Views.ActionBar.ActionBarMenu
;
import
org.telegram.ui.Views.ActionBar.ActionBarMenuItem
;
import
org.telegram.ui.Views.BackupImageView
;
...
...
@@ -85,7 +84,6 @@ import org.telegram.ui.Views.ActionBar.BaseFragment;
import
org.telegram.ui.Views.ChatActivityEnterView
;
import
org.telegram.android.ImageReceiver
;
import
org.telegram.ui.Views.LayoutListView
;
import
org.telegram.ui.Views.MessageActionLayout
;
import
org.telegram.ui.Views.SizeNotifierRelativeLayout
;
import
org.telegram.ui.Views.TimerButton
;
import
org.telegram.ui.Views.TypingDotsDrawable
;
...
...
@@ -97,8 +95,7 @@ import java.util.HashMap;
import
java.util.concurrent.Semaphore
;
public
class
ChatActivity
extends
BaseFragment
implements
NotificationCenter
.
NotificationCenterDelegate
,
MessagesActivity
.
MessagesActivityDelegate
,
DocumentSelectActivity
.
DocumentSelectActivityDelegate
,
PhotoViewer
.
PhotoViewerProvider
,
PhotoPickerActivity
.
PhotoPickerActivityDelegate
,
VideoEditorActivity
.
VideoEditorActivityDelegate
,
LocationActivity
.
LocationActivityDelegate
{
PhotoViewer
.
PhotoViewerProvider
{
private
TLRPC
.
Chat
currentChat
;
private
TLRPC
.
User
currentUser
;
...
...
@@ -470,7 +467,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
else
if
(
id
==
attach_gallery
)
{
PhotoPickerActivity
fragment
=
new
PhotoPickerActivity
();
fragment
.
setDelegate
(
ChatActivity
.
this
);
fragment
.
setDelegate
(
new
PhotoPickerActivity
.
PhotoPickerActivityDelegate
()
{
@Override
public
void
didSelectPhotos
(
ArrayList
<
String
>
photos
)
{
processSendingPhotos
(
photos
,
null
);
}
@Override
public
void
startPhotoSelectActivity
()
{
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"image/*"
);
startActivityForResult
(
photoPickerIntent
,
1
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
});
presentFragment
(
fragment
);
}
else
if
(
id
==
attach_video
)
{
try
{
...
...
@@ -499,11 +512,39 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return
;
}
LocationActivity
fragment
=
new
LocationActivity
();
fragment
.
setDelegate
(
ChatActivity
.
this
);
fragment
.
setDelegate
(
new
LocationActivity
.
LocationActivityDelegate
()
{
@Override
public
void
didSelectLocation
(
double
latitude
,
double
longitude
)
{
SendMessagesHelper
.
getInstance
().
sendMessage
(
latitude
,
longitude
,
dialog_id
);
if
(
chatListView
!=
null
)
{
chatListView
.
setSelectionFromTop
(
messages
.
size
()
-
1
,
-
100000
-
chatListView
.
getPaddingTop
());
}
if
(
paused
)
{
scrollToTopOnResume
=
true
;
}
}
});
presentFragment
(
fragment
);
}
else
if
(
id
==
attach_document
)
{
DocumentSelectActivity
fragment
=
new
DocumentSelectActivity
();
fragment
.
setDelegate
(
ChatActivity
.
this
);
fragment
.
setDelegate
(
new
DocumentSelectActivity
.
DocumentSelectActivityDelegate
()
{
@Override
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
)
{
activity
.
finishFragment
();
processSendingDocument
(
path
,
path
);
}
@Override
public
void
startDocumentSelectActivity
()
{
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"*/*"
);
startActivityForResult
(
photoPickerIntent
,
21
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
});
presentFragment
(
fragment
);
}
else
if
(
id
==
chat_menu_avatar
)
{
if
(
currentUser
!=
null
)
{
...
...
@@ -1292,16 +1333,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private
void
processRowSelect
(
View
view
)
{
View
parentView
=
getRowParentView
(
view
);
if
(
parentView
==
null
)
{
return
;
}
MessageObject
message
=
null
;
if
(
view
instanceof
ChatBaseCell
)
{
message
=
((
ChatBaseCell
)
view
).
getMessageObject
();
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
parentView
.
getTag
();
message
=
holder
.
message
;
}
else
if
(
view
instanceof
ChatActionCell
)
{
message
=
((
ChatActionCell
)
view
).
getMessageObject
();
}
int
type
=
getMessageType
(
message
);
...
...
@@ -1375,6 +1411,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
private
void
setTypingAnimation
(
boolean
start
)
{
if
(
actionBarLayer
==
null
)
{
return
;
}
if
(
start
)
{
try
{
actionBarLayer
.
setSubTitleIcon
(
0
,
typingDotsDrawable
,
AndroidUtilities
.
dp
(
4
));
typingDotsDrawable
.
start
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
else
{
actionBarLayer
.
setSubTitleIcon
(
0
,
null
,
0
);
if
(
typingDotsDrawable
!=
null
)
{
typingDotsDrawable
.
stop
();
}
}
}
private
void
checkAndUpdateAvatar
()
{
TLRPC
.
FileLocation
newPhoto
=
null
;
int
placeHolderId
=
0
;
...
...
@@ -1408,6 +1463,41 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
public
boolean
openVideoEditor
(
String
videoPath
,
boolean
removeLast
,
ActionBarLayout
parentLayout
)
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
"videoPath"
,
videoPath
);
VideoEditorActivity
fragment
=
new
VideoEditorActivity
(
args
);
fragment
.
setDelegate
(
new
VideoEditorActivity
.
VideoEditorActivityDelegate
()
{
@Override
public
void
didFinishEditVideo
(
String
videoPath
,
long
startTime
,
long
endTime
,
int
resultWidth
,
int
resultHeight
,
int
rotationValue
,
int
originalWidth
,
int
originalHeight
,
int
bitrate
,
long
estimatedSize
,
long
estimatedDuration
)
{
TLRPC
.
VideoEditedInfo
videoEditedInfo
=
new
TLRPC
.
VideoEditedInfo
();
videoEditedInfo
.
startTime
=
startTime
;
videoEditedInfo
.
endTime
=
endTime
;
videoEditedInfo
.
rotationValue
=
rotationValue
;
videoEditedInfo
.
originalWidth
=
originalWidth
;
videoEditedInfo
.
originalHeight
=
originalHeight
;
videoEditedInfo
.
bitrate
=
bitrate
;
videoEditedInfo
.
resultWidth
=
resultWidth
;
videoEditedInfo
.
resultHeight
=
resultHeight
;
videoEditedInfo
.
originalPath
=
videoPath
;
processSendingVideo
(
videoPath
,
estimatedSize
,
estimatedDuration
,
resultWidth
,
resultHeight
,
videoEditedInfo
);
}
});
if
(
parentLayout
==
null
||
!
parentLayout
.
presentFragment
(
fragment
,
removeLast
,
true
,
true
))
{
processSendingVideo
(
videoPath
,
0
,
0
,
0
,
0
,
null
);
return
false
;
}
return
true
;
}
private
void
showAttachmentError
()
{
if
(
getParentActivity
()
==
null
)
{
return
;
}
Toast
toast
=
Toast
.
makeText
(
getParentActivity
(),
LocaleController
.
getString
(
"UnsupportedAttachment"
,
R
.
string
.
UnsupportedAttachment
),
Toast
.
LENGTH_SHORT
);
toast
.
show
();
}
@Override
public
void
onActivityResultFragment
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
...
...
@@ -1458,13 +1548,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if
(
paused
)
{
startVideoEdit
=
videoPath
;
}
else
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
"videoPath"
,
videoPath
);
VideoEditorActivity
fragment
=
new
VideoEditorActivity
(
args
);
fragment
.
setDelegate
(
this
);
if
(!
presentFragment
(
fragment
,
false
,
true
))
{
processSendingVideo
(
videoPath
,
0
,
0
,
0
,
0
,
null
);
}
openVideoEditor
(
videoPath
,
false
,
parentLayout
);
}
}
else
{
processSendingVideo
(
videoPath
,
0
,
0
,
0
,
0
,
null
);
...
...
@@ -1489,29 +1573,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
@Override
public
void
didFinishEditVideo
(
String
videoPath
,
long
startTime
,
long
endTime
,
int
resultWidth
,
int
resultHeight
,
int
rotationValue
,
int
originalWidth
,
int
originalHeight
,
int
bitrate
,
long
estimatedSize
,
long
estimatedDuration
)
{
TLRPC
.
VideoEditedInfo
videoEditedInfo
=
new
TLRPC
.
VideoEditedInfo
();
videoEditedInfo
.
startTime
=
startTime
;
videoEditedInfo
.
endTime
=
endTime
;
videoEditedInfo
.
rotationValue
=
rotationValue
;
videoEditedInfo
.
originalWidth
=
originalWidth
;
videoEditedInfo
.
originalHeight
=
originalHeight
;
videoEditedInfo
.
bitrate
=
bitrate
;
videoEditedInfo
.
resultWidth
=
resultWidth
;
videoEditedInfo
.
resultHeight
=
resultHeight
;
videoEditedInfo
.
originalPath
=
videoPath
;
processSendingVideo
(
videoPath
,
estimatedSize
,
estimatedDuration
,
resultWidth
,
resultHeight
,
videoEditedInfo
);
}
private
void
showAttachmentError
()
{
if
(
getParentActivity
()
==
null
)
{
return
;
}
Toast
toast
=
Toast
.
makeText
(
getParentActivity
(),
LocaleController
.
getString
(
"UnsupportedAttachment"
,
R
.
string
.
UnsupportedAttachment
),
Toast
.
LENGTH_SHORT
);
toast
.
show
();
}
@Override
public
void
saveSelfArgs
(
Bundle
args
)
{
if
(
currentPicturePath
!=
null
)
{
...
...
@@ -1524,6 +1585,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
currentPicturePath
=
args
.
getString
(
"path"
);
}
private
void
removeUnreadPlane
(
boolean
reload
)
{
if
(
unreadMessageObject
!=
null
)
{
messages
.
remove
(
unreadMessageObject
);
unread_end_reached
=
true
;
first_unread_id
=
0
;
last_unread_id
=
0
;
unread_to_load
=
0
;
unreadMessageObject
=
null
;
if
(
reload
)
{
chatAdapter
.
notifyDataSetChanged
();
}
}
}
public
boolean
processSendingText
(
String
text
)
{
return
chatActivityEnterView
.
processSendingText
(
text
);
}
...
...
@@ -1855,20 +1930,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}).
start
();
}
private
void
removeUnreadPlane
(
boolean
reload
)
{
if
(
unreadMessageObject
!=
null
)
{
messages
.
remove
(
unreadMessageObject
);
unread_end_reached
=
true
;
first_unread_id
=
0
;
last_unread_id
=
0
;
unread_to_load
=
0
;
unreadMessageObject
=
null
;
if
(
reload
)
{
chatAdapter
.
notifyDataSetChanged
();
}
}
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
didReceivedNotification
(
int
id
,
final
Object
...
args
)
{
...
...
@@ -1948,7 +2009,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
7
;
dateObj
.
contentType
=
4
;
if
(
forwardLoad
)
{
messages
.
add
(
0
,
dateObj
);
}
else
{
...
...
@@ -2209,7 +2270,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
dateMsg
.
id
=
0
;
MessageObject
dateObj
=
new
MessageObject
(
dateMsg
,
null
);
dateObj
.
type
=
10
;
dateObj
.
contentType
=
7
;
dateObj
.
contentType
=
4
;
messages
.
add
(
0
,
dateObj
);
}
if
(!
obj
.
isOut
()
&&
obj
.
isUnread
())
{
...
...
@@ -2655,13 +2716,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AndroidUtilities
.
RunOnUIThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Bundle
args
=
new
Bundle
();
args
.
putString
(
"videoPath"
,
startVideoEdit
);
VideoEditorActivity
fragment
=
new
VideoEditorActivity
(
args
);
fragment
.
setDelegate
(
ChatActivity
.
this
);
if
(!
presentFragment
(
fragment
,
false
,
true
))
{
processSendingVideo
(
startVideoEdit
,
0
,
0
,
0
,
0
,
null
);
}
openVideoEditor
(
startVideoEdit
,
false
,
parentLayout
);
startVideoEdit
=
null
;
}
});
...
...
@@ -2672,58 +2727,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatListView
.
setLongClickable
(
true
);
}
@Override
public
void
didSelectPhotos
(
ArrayList
<
String
>
photos
)
{
processSendingPhotos
(
photos
,
null
);
}
@Override
public
void
didSelectLocation
(
double
latitude
,
double
longitude
)
{
SendMessagesHelper
.
getInstance
().
sendMessage
(
latitude
,
longitude
,
dialog_id
);
if
(
chatListView
!=
null
)
{
chatListView
.
setSelectionFromTop
(
messages
.
size
()
-
1
,
-
100000
-
chatListView
.
getPaddingTop
());
}
if
(
paused
)
{
scrollToTopOnResume
=
true
;
}
}
@Override
public
void
startPhotoSelectActivity
()
{
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"image/*"
);
startActivityForResult
(
photoPickerIntent
,
1
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
@Override
public
void
onBeginSlide
()
{
super
.
onBeginSlide
();
chatActivityEnterView
.
hideEmojiPopup
();
}
private
void
setTypingAnimation
(
boolean
start
)
{
if
(
actionBarLayer
==
null
)
{
return
;
}
if
(
start
)
{
try
{
actionBarLayer
.
setSubTitleIcon
(
0
,
typingDotsDrawable
,
AndroidUtilities
.
dp
(
4
));
typingDotsDrawable
.
start
();
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
else
{
actionBarLayer
.
setSubTitleIcon
(
0
,
null
,
0
);
if
(
typingDotsDrawable
!=
null
)
{
typingDotsDrawable
.
stop
();
}
}
}
@Override
public
void
onPause
()
{
super
.
onPause
();
...
...
@@ -2759,12 +2768,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if
(
view
instanceof
ChatBaseCell
)
{
ChatBaseCell
cell
=
(
ChatBaseCell
)
view
;
object
=
cell
.
getMessageObject
();
}
else
{
Object
tag
=
view
.
getTag
();
if
(
tag
instanceof
ChatListRowHolderEx
)
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
tag
;
object
=
holder
.
message
;
}
}
if
(
object
!=
null
&&
object
.
messageOwner
.
id
<
0
&&
object
.
messageOwner
.
random_id
!=
0
)
{
visibleMessages
.
add
(
object
.
messageOwner
.
random_id
);
...
...
@@ -2817,39 +2820,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
fixLayout
(
false
);
}
private
View
getRowParentView
(
View
v
)
{
if
(
v
instanceof
ChatBaseCell
)
{
return
v
;
}
else
{
while
(!(
v
.
getTag
()
instanceof
ChatListRowHolderEx
))
{
ViewParent
parent
=
v
.
getParent
();
if
(!(
parent
instanceof
View
))
{
return
null
;
}
v
=
(
View
)
v
.
getParent
();
if
(
v
==
null
)
{
return
null
;
}
}
return
v
;
}
}
public
void
createMenu
(
View
v
,
boolean
single
)
{
if
(
actionBarLayer
.
isActionModeShowed
())
{
return
;
}
View
parentView
=
getRowParentView
(
v
);
if
(
parentView
==
null
)
{
return
;
}
MessageObject
message
=
null
;
if
(
v
instanceof
ChatBaseCell
)
{
message
=
((
ChatBaseCell
)
v
).
getMessageObject
();
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
parentView
.
getTag
();
message
=
holder
.
message
;
}
else
if
(
v
instanceof
ChatActionCell
)
{
message
=
((
ChatActionCell
)
v
).
getMessageObject
();
}
final
int
type
=
getMessageType
(
message
);
...
...
@@ -3094,23 +3074,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedObject
=
null
;
}
@Override
public
void
didSelectFile
(
DocumentSelectActivity
activity
,
String
path
)
{
activity
.
finishFragment
();
processSendingDocument
(
path
,
path
);
}
@Override
public
void
startDocumentSelectActivity
()
{
try
{
Intent
photoPickerIntent
=
new
Intent
(
Intent
.
ACTION_PICK
);
photoPickerIntent
.
setType
(
"*/*"
);
startActivityForResult
(
photoPickerIntent
,
21
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
private
void
forwardSelectedMessages
(
long
did
,
boolean
fromMyName
)
{
if
(
forwaringMessage
!=
null
)
{
if
(!
fromMyName
)
{
...
...
@@ -3225,25 +3188,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for
(
int
a
=
0
;
a
<
count
;
a
++)
{
View
view
=
chatListView
.
getChildAt
(
a
);
Object
tag
=
view
.
getTag
();
if
(
tag
instanceof
ChatListRowHolderEx
)
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
tag
;
holder
.
update
();
boolean
disableSelection
=
false
;
boolean
selected
=
false
;
if
(
actionBarLayer
.
isActionModeShowed
())
{
if
(
selectedMessagesIds
.
containsKey
(
holder
.
message
.
messageOwner
.
id
))
{
view
.
setBackgroundColor
(
0x6633b5e5
);
selected
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
disableSelection
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
updateRowBackground
(
holder
,
disableSelection
,
selected
);
}
else
if
(
view
instanceof
ChatBaseCell
)
{
if
(
view
instanceof
ChatBaseCell
)
{
ChatBaseCell
cell
=
(
ChatBaseCell
)
view
;
boolean
disableSelection
=
false
;
...
...
@@ -3267,35 +3212,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
private
void
updateRowBackground
(
ChatListRowHolderEx
holder
,
boolean
disableSelection
,
boolean
selected
)
{
int
messageType
=
holder
.
message
.
type
;
if
(!
disableSelection
)
{
if
(
messageType
==
12
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_outgoing_text_states
);
holder
.
chatBubbleView
.
setPadding
(
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
18
),
0
);
}
else
if
(
messageType
==
13
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
chat_incoming_text_states
);
holder
.
chatBubbleView
.
setPadding
(
AndroidUtilities
.
dp
(
15
),
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
9
),
0
);
}
}
else
{
if
(
messageType
==
12
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out_selected
);
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_out
);
}
holder
.
chatBubbleView
.
setPadding
(
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
18
),
0
);
}
else
if
(
messageType
==
13
)
{
if
(
selected
)
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in_selected
);
}
else
{
holder
.
chatBubbleView
.
setBackgroundResource
(
R
.
drawable
.
msg_in
);
}
holder
.
chatBubbleView
.
setPadding
(
AndroidUtilities
.
dp
(
15
),
AndroidUtilities
.
dp
(
6
),
AndroidUtilities
.
dp
(
9
),
0
);
}
}
}
private
void
alertUserOpenError
(
MessageObject
message
)
{
if
(
getParentActivity
()
==
null
)
{
return
;
...
...
@@ -3329,15 +3245,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messageToOpen
=
message
;
imageReceiver
=
cell
.
getPhotoImage
();
}
}
else
if
(
view
.
getTag
()
!=
null
)
{
Object
tag
=
view
.
getTag
();
if
(
tag
instanceof
ChatListRowHolderEx
)
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
tag
;
if
(
holder
.
message
!=
null
&&
holder
.
message
.
messageOwner
.
id
==
messageObject
.
messageOwner
.
id
)
{
messageToOpen
=
holder
.
message
;
imageReceiver
=
holder
.
photoImage
.
imageReceiver
;
view
=
holder
.
photoImage
;
}
}
else
if
(
view
instanceof
ChatActionCell
)
{
ChatActionCell
cell
=
(
ChatActionCell
)
view
;
MessageObject
message
=
cell
.
getMessageObject
();
if
(
message
!=
null
&&
message
.
messageOwner
.
id
==
messageObject
.
messageOwner
.
id
)
{
messageToOpen
=
message
;
imageReceiver
=
cell
.
getPhotoImage
();
}
}
...
...
@@ -3457,45 +3370,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
view
=
new
ChatMessageCell
(
mContext
);
}
if
(
type
==
1
)
{
view
=
new
ChatMediaCell
(
mContext
);
}
else
if
(
type
==
7
)
{
view
=
new
ChatActionCell
(
mContext
);
}
else
if
(
type
==
8
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
view
=
li
.
inflate
(
R
.
layout
.
chat_action_change_photo_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
2
)
{
view
=
new
ChatAudioCell
(
mContext
);
}
else
if
(
type
==
3
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
view
=
li
.
inflate
(
R
.
layout
.
chat_outgoing_contact_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
4
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
if
(
currentChat
!=
null
)
{
view
=
li
.
inflate
(
R
.
layout
.
chat_group_incoming_contact_layout
,
viewGroup
,
false
);
}
else
{
view
=
li
.
inflate
(
R
.
layout
.
chat_incoming_contact_layout
,
viewGroup
,
false
);
}
view
=
new
ChatContactCell
(
mContext
);
}
else
if
(
type
==
6
)
{
LayoutInflater
li
=
(
LayoutInflater
)
mContext
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
view
=
li
.
inflate
(
R
.
layout
.
chat_unread_layout
,
viewGroup
,
false
);
}
else
if
(
type
==
2
)
{
view
=
new
ChatAudioCell
(
mContext
);
}
}
boolean
selected
=
false
;
boolean
disableSelection
=
false
;
if
(
actionBarLayer
.
isActionModeShowed
())
{
if
(
selectedMessagesIds
.
containsKey
(
message
.
messageOwner
.
id
))
{
view
.
setBackgroundColor
(
0x6633b5e5
);
selected
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
disableSelection
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
else
if
(
type
==
4
)
{
view
=
new
ChatActionCell
(
mContext
);
}
if
(
view
instanceof
ChatBaseCell
)
{
((
ChatBaseCell
)
view
).
delegate
=
new
ChatBaseCell
.
ChatBaseCellDelegate
()
{
((
ChatBaseCell
)
view
).
setDelegate
(
new
ChatBaseCell
.
ChatBaseCellDelegate
()
{
@Override
public
void
didPressedUserAvatar
(
ChatBaseCell
cell
,
TLRPC
.
User
user
)
{
if
(
user
!=
null
&&
user
.
id
!=
UserConfig
.
getClientUserId
())
{
...
...
@@ -3522,9 +3409,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public
boolean
canPerformActions
()
{
return
actionBarLayer
!=
null
&&
!
actionBarLayer
.
isActionModeShowed
();
}
}
;
})
;
if
(
view
instanceof
ChatMediaCell
)
{
((
ChatMediaCell
)
view
).
mediaDelegate
=
new
ChatMediaCell
.
ChatMediaCellDelegate
()
{
((
ChatMediaCell
)
view
).
setMediaDelegate
(
new
ChatMediaCell
.
ChatMediaCellDelegate
()
{
@Override
public
void
didClickedImage
(
ChatMediaCell
cell
)
{
MessageObject
message
=
cell
.
getMessageObject
();
...
...
@@ -3608,27 +3495,64 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public
void
didPressedOther
(
ChatMediaCell
cell
)
{
createMenu
(
cell
,
true
);
}
};
});
}
}
else
if
(
view
instanceof
ChatActionCell
)
{
((
ChatActionCell
)
view
).
setDelegate
(
new
ChatActionCell
.
ChatActionCellDelegate
()
{
@Override
public
void
didClickedImage
(
ChatActionCell
cell
)
{
MessageObject
message
=
cell
.
getMessageObject
();
PhotoViewer
.
getInstance
().
setParentActivity
(
getParentActivity
());
PhotoViewer
.
getInstance
().
openPhoto
(
message
,
ChatActivity
.
this
);
}
@Override
public
void
didLongPressed
(
ChatActionCell
cell
)
{
createMenu
(
cell
,
false
);
}
@Override
public
void
needOpenUserProfile
(
int
uid
)
{
if
(
uid
!=
UserConfig
.
getClientUserId
())
{
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
uid
);
presentFragment
(
new
UserProfileActivity
(
args
));
}
}
});
}
}
boolean
selected
=
false
;
boolean
disableSelection
=
false
;
if
(
actionBarLayer
.
isActionModeShowed
())
{
if
(
selectedMessagesIds
.
containsKey
(
message
.
messageOwner
.
id
))
{
view
.
setBackgroundColor
(
0x6633b5e5
);
selected
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
disableSelection
=
true
;
}
else
{
view
.
setBackgroundColor
(
0
);
}
((
ChatBaseCell
)
view
).
isChat
=
currentChat
!=
null
;
((
ChatBaseCell
)
view
).
setMessageObject
(
message
);
((
ChatBaseCell
)
view
).
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
if
(
view
instanceof
ChatBaseCell
)
{
ChatBaseCell
baseCell
=
(
ChatBaseCell
)
view
;
baseCell
.
isChat
=
currentChat
!=
null
;
baseCell
.
setMessageObject
(
message
);
baseCell
.
setCheckPressed
(!
disableSelection
,
disableSelection
&&
selected
);
if
(
view
instanceof
ChatAudioCell
&&
MediaController
.
getInstance
().
canDownloadMedia
(
MediaController
.
AUTODOWNLOAD_MASK_AUDIO
))
{
((
ChatAudioCell
)
view
).
downloadAudioIfNeed
();
}
}
else
if
(
view
instanceof
ChatActionCell
)
{
((
ChatActionCell
)
view
).
setMessageObject
(
message
);
((
ChatActionCell
)
view
).
setUseBlackBackground
(
isCustomTheme
);
}
else
{
ChatListRowHolderEx
holder
=
(
ChatListRowHolderEx
)
view
.
getTag
();
if
(
holder
==
null
)
{
holder
=
new
ChatListRowHolderEx
(
view
,
message
.
type
);
view
.
setTag
(
holder
);
ChatActionCell
actionCell
=
(
ChatActionCell
)
view
;
actionCell
.
setMessageObject
(
message
);
actionCell
.
setUseBlackBackground
(
isCustomTheme
);
}
holder
.
message
=
message
;
updateRowBackground
(
holder
,
disableSelection
,
selected
);
holder
.
update
(
);
if
(
type
==
6
)
{
TextView
messageTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_message_text
);
messageTextView
.
setText
(
LocaleController
.
formatPluralString
(
"NewMessages"
,
unread_to_load
)
);
}
return
view
;
...
...
@@ -3652,7 +3576,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public
int
getViewTypeCount
()
{
return
9
;
return
7
;
}
@Override
...
...
@@ -3669,318 +3593,4 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return
count
==
0
;
}
}
public
class
ChatListRowHolderEx
{
public
BackupImageView
avatarImageView
;
public
TextView
nameTextView
;
public
TextView
messageTextView
;
public
MessageActionLayout
messageLayoutAction
;
public
TextView
timeTextView
;
public
BackupImageView
photoImage
;
public
ImageView
halfCheckImage
;
public
ImageView
checkImage
;
public
MessageObject
message
;
public
TextView
phoneTextView
;
public
BackupImageView
contactAvatar
;
public
View
contactView
;
public
ImageView
addContactButton
;
public
View
addContactView
;
public
View
chatBubbleView
;
public
void
update
()
{
TLRPC
.
User
fromUser
=
MessagesController
.
getInstance
().
getUser
(
message
.
messageOwner
.
from_id
);
int
type
=
message
.
type
;
if
(
timeTextView
!=
null
)
{
timeTextView
.
setText
(
LocaleController
.
formatterDay
.
format
((
long
)
(
message
.
messageOwner
.
date
)
*
1000
));
}
if
(
avatarImageView
!=
null
&&
fromUser
!=
null
)
{
TLRPC
.
FileLocation
photo
=
null
;
if
(
fromUser
.
photo
!=
null
)
{
photo
=
fromUser
.
photo
.
photo_small
;
}
int
placeHolderId
=
AndroidUtilities
.
getUserAvatarForId
(
fromUser
.
id
);
avatarImageView
.
setImage
(
photo
,
"50_50"
,
placeHolderId
);
}
if
(
type
!=
12
&&
type
!=
13
&&
nameTextView
!=
null
&&
fromUser
!=
null
&&
type
!=
8
&&
type
!=
9
)
{
nameTextView
.
setText
(
ContactsController
.
formatName
(
fromUser
.
first_name
,
fromUser
.
last_name
));
nameTextView
.
setTextColor
(
AndroidUtilities
.
getColorForId
(
message
.
messageOwner
.
from_id
));
}
if
(
type
==
11
||
type
==
10
)
{
int
width
=
0
;
if
(
AndroidUtilities
.
isTablet
())
{
width
=
AndroidUtilities
.
getMinTabletSide
()
-
AndroidUtilities
.
dp
(
30
);
}
else
{
width
=
AndroidUtilities
.
displaySize
.
x
-
AndroidUtilities
.
dp
(
30
);
}
messageTextView
.
setText
(
message
.
messageText
);
messageTextView
.
setMaxWidth
(
width
);
if
(
type
==
11
)
{
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
));
if
(
photo
!=
null
)
{
if
(
photo
.
image
!=
null
)
{
photoImage
.
setImageBitmap
(
photo
.
image
);
}
else
{
photoImage
.
setImage
(
photo
.
photoOwner
.
location
,
"50_50"
,
AndroidUtilities
.
getGroupAvatarForId
(
currentChat
.
id
));
}
}
else
{
photoImage
.
setImageResource
(
AndroidUtilities
.
getGroupAvatarForId
(
currentChat
.
id
));
}
}
photoImage
.
imageReceiver
.
setVisible
(!
PhotoViewer
.
getInstance
().
isShowingImage
(
message
),
false
);
}
}
else
if
(
type
==
12
||
type
==
13
)
{
TLRPC
.
User
contactUser
=
MessagesController
.
getInstance
().
getUser
(
message
.
messageOwner
.
media
.
user_id
);
if
(
contactUser
!=
null
)
{
nameTextView
.
setText
(
ContactsController
.
formatName
(
message
.
messageOwner
.
media
.
first_name
,
message
.
messageOwner
.
media
.
last_name
));
nameTextView
.
setTextColor
(
AndroidUtilities
.
getColorForId
(
contactUser
.
id
));
String
phone
=
message
.
messageOwner
.
media
.
phone_number
;
if
(
phone
!=
null
&&
phone
.
length
()
!=
0
)
{
if
(!
phone
.
startsWith
(
"+"
))
{
phone
=
"+"
+
phone
;
}
phoneTextView
.
setText
(
PhoneFormat
.
getInstance
().
format
(
phone
));
}
else
{
phoneTextView
.
setText
(
"Unknown"
);
}
TLRPC
.
FileLocation
photo
=
null
;
if
(
contactUser
.
photo
!=
null
)
{
photo
=
contactUser
.
photo
.
photo_small
;
}
int
placeHolderId
=
AndroidUtilities
.
getUserAvatarForId
(
contactUser
.
id
);
contactAvatar
.
setImage
(
photo
,
"50_50"
,
placeHolderId
);
if
(
contactUser
.
id
!=
UserConfig
.
getClientUserId
()
&&
ContactsController
.
getInstance
().
contactsDict
.
get
(
contactUser
.
id
)
==
null
)
{
addContactView
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
addContactView
.
setVisibility
(
View
.
GONE
);
}
}
else
{
nameTextView
.
setText
(
ContactsController
.
formatName
(
message
.
messageOwner
.
media
.
first_name
,
message
.
messageOwner
.
media
.
last_name
));
nameTextView
.
setTextColor
(
AndroidUtilities
.
getColorForId
(
message
.
messageOwner
.
media
.
user_id
));
String
phone
=
message
.
messageOwner
.
media
.
phone_number
;
if
(
phone
!=
null
&&
phone
.
length
()
!=
0
)
{
if
(
message
.
messageOwner
.
media
.
user_id
!=
0
&&
!
phone
.
startsWith
(
"+"
))
{
phone
=
"+"
+
phone
;
}
phoneTextView
.
setText
(
PhoneFormat
.
getInstance
().
format
(
phone
));
}
else
{
phoneTextView
.
setText
(
"Unknown"
);
}
contactAvatar
.
setImageResource
(
AndroidUtilities
.
getUserAvatarForId
(
message
.
messageOwner
.
media
.
user_id
));
addContactView
.
setVisibility
(
View
.
GONE
);
}
}
else
if
(
type
==
6
)
{
messageTextView
.
setTextSize
(
16
);
messageTextView
.
setText
(
LocaleController
.
formatPluralString
(
"NewMessages"
,
unread_to_load
));
}
if
(
message
.
isFromMe
())
{
if
(
halfCheckImage
!=
null
)
{
if
(
message
.
isSending
())
{
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_clock
);
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
}
else
if
(
message
.
isSendError
())
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_warning
);
if
(
checkImage
!=
null
)
{
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
}
}
else
if
(
message
.
isSent
())
{
if
(!
message
.
isUnread
())
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
VISIBLE
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_halfcheck
);
}
else
{
halfCheckImage
.
setVisibility
(
View
.
VISIBLE
);
checkImage
.
setVisibility
(
View
.
INVISIBLE
);
halfCheckImage
.
setImageResource
(
R
.
drawable
.
msg_check
);
}
}
}
}
}
public
ChatListRowHolderEx
(
View
view
,
int
type
)
{
avatarImageView
=
(
BackupImageView
)
view
.
findViewById
(
R
.
id
.
chat_group_avatar_image
);
nameTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_user_group_name
);
messageLayoutAction
=
(
MessageActionLayout
)
view
.
findViewById
(
R
.
id
.
message_action_layout
);
timeTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_time_text
);
photoImage
=
(
BackupImageView
)
view
.
findViewById
(
R
.
id
.
chat_photo_image
);
halfCheckImage
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
chat_row_halfcheck
);
checkImage
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
chat_row_check
);
messageTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
chat_message_text
);
phoneTextView
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
phone_text_view
);
contactAvatar
=
(
BackupImageView
)
view
.
findViewById
(
R
.
id
.
contact_avatar
);
contactView
=
view
.
findViewById
(
R
.
id
.
shared_layout
);
addContactButton
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
add_contact_button
);
addContactView
=
view
.
findViewById
(
R
.
id
.
add_contact_view
);
chatBubbleView
=
view
.
findViewById
(
R
.
id
.
chat_bubble_layout
);
if
(
messageTextView
!=
null
)
{
messageTextView
.
setTextSize
(
TypedValue
.
COMPLEX_UNIT_SP
,
MessagesController
.
getInstance
().
fontSize
);
}
if
(
messageLayoutAction
!=
null
)
{
if
(
isCustomTheme
)
{
messageLayoutAction
.
setBackgroundResource
(
R
.
drawable
.
system_black
);
}
else
{
messageLayoutAction
.
setBackgroundResource
(
R
.
drawable
.
system_blue
);
}
}
if
(
addContactButton
!=
null
)
{
addContactButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
actionBarLayer
.
isActionModeShowed
())
{
processRowSelect
(
view
);
return
;
}
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
message
.
messageOwner
.
media
.
user_id
);
args
.
putString
(
"phone"
,
message
.
messageOwner
.
media
.
phone_number
);
presentFragment
(
new
ContactAddActivity
(
args
));
}
});
addContactButton
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
createMenu
(
v
,
false
);
return
true
;
}
});
}
if
(
contactView
!=
null
)
{
contactView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
message
.
type
==
12
||
message
.
type
==
13
)
{
if
(
actionBarLayer
.
isActionModeShowed
())
{
processRowSelect
(
view
);
return
;
}
if
(
message
.
messageOwner
.
media
.
user_id
!=
UserConfig
.
getClientUserId
())
{
TLRPC
.
User
user
=
null
;
if
(
message
.
messageOwner
.
media
.
user_id
!=
0
)
{
user
=
MessagesController
.
getInstance
().
getUser
(
message
.
messageOwner
.
media
.
user_id
);
}
if
(
user
!=
null
)
{
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
message
.
messageOwner
.
media
.
user_id
);
presentFragment
(
new
UserProfileActivity
(
args
));
}
else
{
if
(
message
.
messageOwner
.
media
.
phone_number
==
null
||
message
.
messageOwner
.
media
.
phone_number
.
length
()
==
0
)
{
return
;
}
if
(
getParentActivity
()
==
null
)
{
return
;
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getParentActivity
());
builder
.
setItems
(
new
CharSequence
[]
{
LocaleController
.
getString
(
"Copy"
,
R
.
string
.
Copy
),
LocaleController
.
getString
(
"Call"
,
R
.
string
.
Call
)},
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialogInterface
,
int
i
)
{
if
(
i
==
1
)
{
try
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_DIAL
,
Uri
.
parse
(
"tel:"
+
message
.
messageOwner
.
media
.
phone_number
));
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
getParentActivity
().
startActivity
(
intent
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
}
}
else
if
(
i
==
0
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
HONEYCOMB
)
{
android
.
text
.
ClipboardManager
clipboard
=
(
android
.
text
.
ClipboardManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
clipboard
.
setText
(
message
.
messageOwner
.
media
.
phone_number
);
}
else
{
android
.
content
.
ClipboardManager
clipboard
=
(
android
.
content
.
ClipboardManager
)
ApplicationLoader
.
applicationContext
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
android
.
content
.
ClipData
clip
=
android
.
content
.
ClipData
.
newPlainText
(
"label"
,
message
.
messageOwner
.
media
.
phone_number
);
clipboard
.
setPrimaryClip
(
clip
);
}
}
}
}
);
showAlertDialog
(
builder
);
}
}
}
}
});
contactView
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
createMenu
(
v
,
false
);
return
true
;
}
});
}
if
(
contactAvatar
!=
null
)
{
contactAvatar
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
}
});
}
if
(
avatarImageView
!=
null
)
{
avatarImageView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
if
(
actionBarLayer
.
isActionModeShowed
())
{
processRowSelect
(
view
);
return
;
}
if
(
message
!=
null
)
{
Bundle
args
=
new
Bundle
();
args
.
putInt
(
"user_id"
,
message
.
messageOwner
.
from_id
);
presentFragment
(
new
UserProfileActivity
(
args
));
}
}
});
}
if
(
photoImage
!=
null
)
{
photoImage
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
processOnClick
(
view
);
}
});
photoImage
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
createMenu
(
v
,
false
);
return
true
;
}
});
}
}
private
void
processOnClick
(
View
view
)
{
if
(
actionBarLayer
.
isActionModeShowed
())
{
processRowSelect
(
view
);
return
;
}
if
(
message
!=
null
)
{
if
(
message
.
type
==
11
)
{
PhotoViewer
.
getInstance
().
setParentActivity
(
getParentActivity
());
PhotoViewer
.
getInstance
().
openPhoto
(
message
,
ChatActivity
.
this
);
}
}
}
}
}
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
View file @
288fceeb
...
...
@@ -661,12 +661,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
actionBarLayout
.
presentFragment
(
fragment
,
false
,
true
,
true
);
}
Bundle
args2
=
new
Bundle
();
args2
.
putString
(
"videoPath"
,
videoPath
);
VideoEditorActivity
fragment2
=
new
VideoEditorActivity
(
args2
);
fragment2
.
setDelegate
(
fragment
);
presentFragment
(
fragment2
,
true
,
true
);
if
(!
fragment
.
openVideoEditor
(
videoPath
,
true
,
actionBarLayout
))
{
if
(!
AndroidUtilities
.
isTablet
())
{
actionBarLayout
.
presentFragment
(
fragment
,
true
);
}
}
else
if
(!
AndroidUtilities
.
isTablet
())
{
actionBarLayout
.
addFragmentToStack
(
fragment
,
actionBarLayout
.
fragmentsStack
.
size
()
-
1
);
}
}
else
{
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/HorizontalListView.java
View file @
288fceeb
...
...
@@ -207,7 +207,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
v
=
list
.
poll
();
}
View
child
=
mAdapter
.
getView
(
mRightViewIndex
,
v
,
this
);
child
.
setTag
(
1
,
type
);
child
.
setTag
(
type
);
addAndMeasureChild
(
child
,
-
1
);
rightEdge
+=
child
.
getMeasuredWidth
();
...
...
@@ -234,7 +234,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
v
=
list
.
poll
();
}
View
child
=
mAdapter
.
getView
(
mLeftViewIndex
,
v
,
this
);
child
.
setTag
(
1
,
type
);
child
.
setTag
(
type
);
addAndMeasureChild
(
child
,
0
);
leftEdge
-=
child
.
getMeasuredWidth
();
...
...
@@ -248,7 +248,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
while
(
child
!=
null
&&
child
.
getRight
()
+
dx
<=
0
)
{
mDisplayOffset
+=
child
.
getMeasuredWidth
();
int
type
=
(
Integer
)
child
.
getTag
(
1
);
int
type
=
(
Integer
)
child
.
getTag
();
LinkedList
<
View
>
list
=
mRemovedViewQueue
.
get
(
type
);
if
(
list
==
null
)
{
list
=
new
LinkedList
<
View
>();
...
...
@@ -263,7 +263,7 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
child
=
getChildAt
(
getChildCount
()
-
1
);
while
(
child
!=
null
&&
child
.
getLeft
()
+
dx
>=
getWidth
())
{
int
type
=
(
Integer
)
child
.
getTag
(
1
);
int
type
=
(
Integer
)
child
.
getTag
();
LinkedList
<
View
>
list
=
mRemovedViewQueue
.
get
(
type
);
if
(
list
==
null
)
{
list
=
new
LinkedList
<
View
>();
...
...
TMessagesProj/src/main/java/org/telegram/ui/Views/MessageActionLayout.java
deleted
100644 → 0
View file @
2f23635e
/*
* This is the source code of Telegram for Android v. 1.3.2.
* 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.
*/
package
org
.
telegram
.
ui
.
Views
;
import
android.widget.FrameLayout
;
import
org.telegram.android.AndroidUtilities
;
import
org.telegram.messenger.R
;
public
class
MessageActionLayout
extends
FrameLayout
{
public
TightTextView
messageTextView
;
public
MessageActionLayout
(
android
.
content
.
Context
context
)
{
super
(
context
);
}
public
MessageActionLayout
(
android
.
content
.
Context
context
,
android
.
util
.
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
MessageActionLayout
(
android
.
content
.
Context
context
,
android
.
util
.
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
setMeasuredDimension
(
messageTextView
.
linesMaxWidth
+
AndroidUtilities
.
dp
(
14
),
getMeasuredHeight
());
}
@Override
protected
void
onFinishInflate
()
{
super
.
onFinishInflate
();
messageTextView
=
(
TightTextView
)
findViewById
(
R
.
id
.
chat_message_text
);
}
}
TMessagesProj/src/main/java/org/telegram/ui/Views/TightTextView.java
deleted
100644 → 0
View file @
2f23635e
/*
* This is the source code of Telegram for Android v. 1.3.2.
* 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.
*/
package
org
.
telegram
.
ui
.
Views
;
import
android.content.Context
;
import
android.text.Layout
;
import
android.util.AttributeSet
;
import
android.widget.TextView
;
import
org.telegram.messenger.FileLog
;
public
class
TightTextView
extends
TextView
{
private
boolean
hasMaxWidth
;
public
int
maxWidth
;
public
int
lastLineWidth
=
0
;
public
int
linesMaxWidth
=
0
;
public
int
lines
=
0
;
public
TightTextView
(
Context
context
)
{
this
(
context
,
null
,
0
);
}
public
TightTextView
(
Context
context
,
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
public
TightTextView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
try
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
int
measuredWidth
=
getMeasuredWidth
();
Layout
layout
=
getLayout
();
lines
=
layout
.
getLineCount
();
float
lastLeft
=
layout
.
getLineLeft
(
lines
-
1
);
float
lastLine
=
layout
.
getLineWidth
(
lines
-
1
);
int
lastLineWidthWithLeft
;
int
linesMaxWidthWithLeft
;
boolean
hasNonRTL
=
false
;
linesMaxWidth
=
lastLineWidth
=
(
int
)
Math
.
ceil
(
lastLine
);
linesMaxWidthWithLeft
=
lastLineWidthWithLeft
=
(
int
)
Math
.
ceil
(
lastLine
+
lastLeft
);
if
(
lastLeft
==
0
)
{
hasNonRTL
=
true
;
}
if
(
hasMaxWidth
)
{
int
specModeW
=
MeasureSpec
.
getMode
(
widthMeasureSpec
);
if
(
specModeW
!=
MeasureSpec
.
EXACTLY
)
{
if
(
lines
>
1
)
{
float
textRealMaxWidth
=
0
,
textRealMaxWidthWithLeft
=
0
;
for
(
int
n
=
0
;
n
<
lines
;
++
n
)
{
float
lineWidth
;
float
lineLeft
;
try
{
lineWidth
=
layout
.
getLineWidth
(
n
);
lineLeft
=
layout
.
getLineLeft
(
n
);
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
return
;
}
if
(
lineLeft
==
0
)
{
hasNonRTL
=
true
;
}
textRealMaxWidth
=
Math
.
max
(
textRealMaxWidth
,
lineWidth
);
textRealMaxWidthWithLeft
=
Math
.
max
(
textRealMaxWidthWithLeft
,
lineWidth
+
lineLeft
);
linesMaxWidth
=
Math
.
max
(
linesMaxWidth
,
(
int
)
Math
.
ceil
(
lineWidth
));
linesMaxWidthWithLeft
=
Math
.
max
(
linesMaxWidthWithLeft
,
(
int
)
Math
.
ceil
(
lineWidth
+
lineLeft
));
}
if
(
hasNonRTL
)
{
textRealMaxWidth
=
textRealMaxWidthWithLeft
;
lastLineWidth
=
lastLineWidthWithLeft
;
linesMaxWidth
=
linesMaxWidthWithLeft
;
}
else
{
lastLineWidth
=
linesMaxWidth
;
}
int
w
=
(
int
)
Math
.
ceil
(
textRealMaxWidth
);
if
(
w
<
getMeasuredWidth
())
{
super
.
onMeasure
(
MeasureSpec
.
makeMeasureSpec
(
w
,
MeasureSpec
.
AT_MOST
),
heightMeasureSpec
);
}
}
else
{
super
.
onMeasure
(
MeasureSpec
.
makeMeasureSpec
(
Math
.
min
(
maxWidth
,
linesMaxWidth
),
MeasureSpec
.
AT_MOST
),
heightMeasureSpec
);
}
}
}
}
catch
(
Exception
e
)
{
FileLog
.
e
(
"tmessages"
,
e
);
try
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
}
catch
(
Exception
e2
)
{
setMeasuredDimension
(
MeasureSpec
.
getSize
(
widthMeasureSpec
),
MeasureSpec
.
getSize
(
heightMeasureSpec
));
FileLog
.
e
(
"tmessages"
,
e2
);
}
}
}
@Override
public
void
setMaxWidth
(
int
maxpixels
)
{
super
.
setMaxWidth
(
maxpixels
);
hasMaxWidth
=
true
;
maxWidth
=
maxpixels
;
}
@Override
public
void
setMaxEms
(
int
maxems
)
{
super
.
setMaxEms
(
maxems
);
hasMaxWidth
=
true
;
}
}
TMessagesProj/src/main/java/org/telegram/ui/Views/URLSpanNoUnderline.java
0 → 100644
View file @
288fceeb
/*
* This is the source code of Telegram for Android v. 1.7.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.text.TextPaint
;
import
android.text.style.URLSpan
;
public
class
URLSpanNoUnderline
extends
URLSpan
{
public
URLSpanNoUnderline
(
String
url
)
{
super
(
url
);
}
@Override
public
void
updateDrawState
(
TextPaint
ds
)
{
super
.
updateDrawState
(
ds
);
ds
.
setUnderlineText
(
false
);
}
}
TMessagesProj/src/main/res/layout/chat_action_change_photo_layout.xml
deleted
100644 → 0
View file @
2f23635e
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:paddingBottom=
"5dp"
android:gravity=
"center"
android:layout_gravity=
"top"
>
<org.telegram.ui.Views.MessageActionLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:layout_marginLeft=
"15dp"
android:layout_marginRight=
"15dp"
android:id=
"@+id/message_action_layout"
>
<org.telegram.ui.Views.TightTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"15dp"
android:id=
"@+id/chat_message_text"
android:textColor=
"#ffffff"
android:paddingTop=
"1dp"
android:paddingBottom=
"1dp"
android:ellipsize=
"none"
android:gravity=
"center"
android:maxLines=
"10"
android:maxWidth=
"380dp"
android:layout_gravity=
"center"
/>
</org.telegram.ui.Views.MessageActionLayout>
<org.telegram.ui.Views.BackupImageView
android:layout_width=
"64dp"
android:layout_height=
"64dp"
android:layout_marginTop=
"5dp"
android:id=
"@+id/chat_photo_image"
/>
</LinearLayout>
\ No newline at end of file
TMessagesProj/src/main/res/layout/chat_action_message_layout.xml
deleted
100644 → 0
View file @
2f23635e
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"5dp"
android:gravity=
"center"
android:layout_gravity=
"top"
>
<org.telegram.ui.Views.MessageActionLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:layout_marginLeft=
"15dp"
android:layout_marginRight=
"15dp"
android:id=
"@+id/message_action_layout"
>
<org.telegram.ui.Views.TightTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textSize=
"14dp"
android:id=
"@+id/chat_message_text"
android:textColor=
"#ffffff"
android:paddingTop=
"1dp"
android:paddingBottom=
"1dp"
android:ellipsize=
"none"
android:gravity=
"center"
android:maxLines=
"10"
android:layout_gravity=
"center"
/>
</org.telegram.ui.Views.MessageActionLayout>
</LinearLayout>
\ No newline at end of file
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