Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
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
xabber-android
Commits
b852d27b
Commit
b852d27b
authored
May 29, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup message context menu callbacks while menu creation.
parent
4cf5f2db
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
47 deletions
+46
-47
ChatViewer.java
src/com/xabber/android/ui/ChatViewer.java
+46
-47
No files found.
src/com/xabber/android/ui/ChatViewer.java
View file @
b852d27b
...
@@ -120,18 +120,12 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -120,18 +120,12 @@ public class ChatViewer extends ManagedActivity implements
private
static
final
int
OPTION_MENU_VERIFY_SECRET_ID
=
0x24
;
private
static
final
int
OPTION_MENU_VERIFY_SECRET_ID
=
0x24
;
private
static
final
int
OPTION_MENU_REFRESH_OTR_ID
=
0x25
;
private
static
final
int
OPTION_MENU_REFRESH_OTR_ID
=
0x25
;
private
static
final
int
CONTEXT_MENU_QUOTE_ID
=
0x100
;
private
static
final
int
CONTEXT_MENU_REPEAT_ID
=
0x101
;
private
static
final
int
CONTEXT_MENU_COPY_ID
=
0x102
;
private
static
final
int
CONTEXT_MENU_REMOVE_ID
=
0x103
;
private
ChatViewerAdapter
chatViewerAdapter
;
private
ChatViewerAdapter
chatViewerAdapter
;
private
PageSwitcher
pageSwitcher
;
private
PageSwitcher
pageSwitcher
;
private
String
actionWithAccount
;
private
String
actionWithAccount
;
private
String
actionWithUser
;
private
String
actionWithUser
;
private
View
actionWithView
;
private
View
actionWithView
;
private
MessageItem
actionWithMessage
;
private
boolean
exitOnSend
;
private
boolean
exitOnSend
;
...
@@ -159,7 +153,6 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -159,7 +153,6 @@ public class ChatViewer extends ManagedActivity implements
actionWithAccount
=
null
;
actionWithAccount
=
null
;
actionWithUser
=
null
;
actionWithUser
=
null
;
actionWithView
=
null
;
actionWithView
=
null
;
actionWithMessage
=
null
;
setContentView
(
R
.
layout
.
chat_viewer
);
setContentView
(
R
.
layout
.
chat_viewer
);
chatViewerAdapter
=
new
ChatViewerAdapter
(
this
,
account
,
user
);
chatViewerAdapter
=
new
ChatViewerAdapter
(
this
,
account
,
user
);
...
@@ -468,22 +461,54 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -468,22 +461,54 @@ public class ChatViewer extends ManagedActivity implements
ListView
listView
=
(
ListView
)
actionWithView
ListView
listView
=
(
ListView
)
actionWithView
.
findViewById
(
android
.
R
.
id
.
list
);
.
findViewById
(
android
.
R
.
id
.
list
);
actionWithMessage
=
(
MessageItem
)
listView
.
getAdapter
().
getItem
(
final
MessageItem
message
=
(
MessageItem
)
listView
.
getAdapter
()
info
.
position
);
.
getItem
(
info
.
position
);
if
(
actionWithMessage
!=
null
&&
actionWithMessage
.
getAction
()
!=
null
)
if
(
message
!=
null
&&
message
.
getAction
()
!=
null
)
actionWithMessage
=
null
;
// Skip action message
if
(
actionWithMessage
==
null
)
return
;
return
;
if
(
actionWithMessage
.
isError
())
{
if
(
message
.
isError
())
{
menu
.
add
(
0
,
CONTEXT_MENU_REPEAT_ID
,
0
,
menu
.
add
(
R
.
string
.
message_repeat
).
setOnMenuItemClickListener
(
getResources
().
getText
(
R
.
string
.
message_repeat
));
new
MenuItem
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
sendMessage
(
message
.
getText
());
return
true
;
}
});
}
menu
.
add
(
R
.
string
.
message_quote
).
setOnMenuItemClickListener
(
new
MenuItem
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
insertText
(
"> "
+
message
.
getText
()
+
"\n"
);
return
true
;
}
});
menu
.
add
(
R
.
string
.
message_copy
).
setOnMenuItemClickListener
(
new
MenuItem
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
((
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
))
.
setText
(
message
.
getSpannable
());
return
true
;
}
});
menu
.
add
(
R
.
string
.
message_remove
).
setOnMenuItemClickListener
(
new
MenuItem
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
MessageManager
.
getInstance
().
removeMessage
(
message
);
chatViewerAdapter
.
onChatChange
(
actionWithView
,
false
);
return
true
;
}
}
menu
.
add
(
0
,
CONTEXT_MENU_QUOTE_ID
,
0
,
getResources
().
getText
(
R
.
string
.
message_quote
));
});
menu
.
add
(
0
,
CONTEXT_MENU_COPY_ID
,
0
,
getResources
().
getText
(
R
.
string
.
message_copy
));
menu
.
add
(
0
,
CONTEXT_MENU_REMOVE_ID
,
0
,
getResources
().
getText
(
R
.
string
.
message_remove
));
}
}
/**
/**
...
@@ -508,30 +533,6 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -508,30 +533,6 @@ public class ChatViewer extends ManagedActivity implements
editView
.
setSelection
(
selection
+
additional
.
length
());
editView
.
setSelection
(
selection
+
additional
.
length
());
}
}
@Override
public
boolean
onContextItemSelected
(
MenuItem
item
)
{
if
(
actionWithMessage
==
null
)
return
false
;
super
.
onContextItemSelected
(
item
);
switch
(
item
.
getItemId
())
{
case
CONTEXT_MENU_QUOTE_ID:
insertText
(
"> "
+
actionWithMessage
.
getText
()
+
"\n"
);
return
true
;
case
CONTEXT_MENU_REPEAT_ID:
sendMessage
(
actionWithMessage
.
getText
());
return
true
;
case
CONTEXT_MENU_COPY_ID:
((
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
))
.
setText
(
actionWithMessage
.
getSpannable
());
return
true
;
case
CONTEXT_MENU_REMOVE_ID:
MessageManager
.
getInstance
().
removeMessage
(
actionWithMessage
);
chatViewerAdapter
.
onChatChange
(
actionWithView
,
false
);
return
true
;
}
return
false
;
}
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
switch
(
view
.
getId
())
{
...
@@ -594,7 +595,6 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -594,7 +595,6 @@ public class ChatViewer extends ManagedActivity implements
LogManager
.
i
(
this
,
"onSelect: "
+
actionWithAccount
+
":"
LogManager
.
i
(
this
,
"onSelect: "
+
actionWithAccount
+
":"
+
actionWithUser
);
+
actionWithUser
);
actionWithView
=
pageSwitcher
.
getSelectedView
();
actionWithView
=
pageSwitcher
.
getSelectedView
();
actionWithMessage
=
null
;
if
(
isVisible
)
if
(
isVisible
)
MessageManager
.
getInstance
().
setVisibleChat
(
actionWithAccount
,
MessageManager
.
getInstance
().
setVisibleChat
(
actionWithAccount
,
actionWithUser
);
actionWithUser
);
...
@@ -614,7 +614,6 @@ public class ChatViewer extends ManagedActivity implements
...
@@ -614,7 +614,6 @@ public class ChatViewer extends ManagedActivity implements
actionWithAccount
=
null
;
actionWithAccount
=
null
;
actionWithUser
=
null
;
actionWithUser
=
null
;
actionWithView
=
null
;
actionWithView
=
null
;
actionWithMessage
=
null
;
if
(
PageSwitcher
.
LOG
)
if
(
PageSwitcher
.
LOG
)
LogManager
.
i
(
this
,
"onUnselect"
);
LogManager
.
i
(
this
,
"onUnselect"
);
}
}
...
...
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