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
362aa208
Commit
362aa208
authored
May 27, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set account context menu actions while ContextMenu creation.
parent
7e258b6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
60 deletions
+54
-60
ContactList.java
src/com/xabber/android/ui/ContactList.java
+53
-59
AccountToggleAdapter.java
src/com/xabber/android/ui/adapter/AccountToggleAdapter.java
+1
-1
No files found.
src/com/xabber/android/ui/ContactList.java
View file @
362aa208
...
@@ -141,12 +141,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -141,12 +141,6 @@ public class ContactList extends ManagedListActivity implements
private
static
final
int
CONTEXT_MENU_GROUP_RENAME_ID
=
0x31
;
private
static
final
int
CONTEXT_MENU_GROUP_RENAME_ID
=
0x31
;
private
static
final
int
CONTEXT_MENU_GROUP_DELETE_ID
=
0x32
;
private
static
final
int
CONTEXT_MENU_GROUP_DELETE_ID
=
0x32
;
private
static
final
int
CONTEXT_MENU_ACCOUNT_EDITOR_ID
=
0x33
;
private
static
final
int
CONTEXT_MENU_ACCOUNT_STATUS_ID
=
0x34
;
private
static
final
int
CONTEXT_MENU_ACCOUNT_ADD_CONTACT_ID
=
0x35
;
private
static
final
int
CONTEXT_MENU_ACCOUNT_RECONNECT_ID
=
0x39
;
private
static
final
int
CONTEXT_MENU_ACCOUNT_VCARD_ID
=
0x3A
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_GROUP_ID
=
0x40
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_GROUP_ID
=
0x40
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_ALWAYS_ID
=
0x41
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_ALWAYS_ID
=
0x41
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_NORMAL_ID
=
0x42
;
private
static
final
int
CONTEXT_MENU_SHOW_OFFLINE_NORMAL_ID
=
0x42
;
...
@@ -497,8 +491,8 @@ public class ContactList extends ManagedListActivity implements
...
@@ -497,8 +491,8 @@ public class ContactList extends ManagedListActivity implements
}
}
}
else
{
}
else
{
// Account panel
// Account panel
createAccountContextMenu
(
createAccountContextMenu
(
accountToggleAdapter
.
getItemForView
(
view
),
(
String
)
accountToggleAdapter
.
getItemForView
(
view
),
menu
);
menu
);
}
}
}
}
...
@@ -568,29 +562,56 @@ public class ContactList extends ManagedListActivity implements
...
@@ -568,29 +562,56 @@ public class ContactList extends ManagedListActivity implements
createOfflineModeContextMenu
(
menu
);
createOfflineModeContextMenu
(
menu
);
}
}
private
void
createAccountContextMenu
(
String
account
,
ContextMenu
menu
)
{
private
void
createAccountContextMenu
(
final
String
account
,
ContextMenu
menu
)
{
actionWithAccount
=
account
;
actionWithAccount
=
account
;
actionWithGroup
=
null
;
actionWithGroup
=
null
;
actionWithUser
=
null
;
actionWithUser
=
null
;
menu
.
setHeaderTitle
(
AccountManager
.
getInstance
().
getVerboseName
(
menu
.
setHeaderTitle
(
AccountManager
.
getInstance
()
actionWithAccount
));
.
getVerboseName
(
account
));
AccountItem
accountItem
=
AccountManager
.
getInstance
().
getAccount
(
AccountItem
accountItem
=
AccountManager
.
getInstance
().
getAccount
(
actionWithAccount
);
account
);
ConnectionState
state
=
accountItem
.
getState
();
ConnectionState
state
=
accountItem
.
getState
();
if
(
state
==
ConnectionState
.
waiting
)
if
(
state
==
ConnectionState
.
waiting
)
menu
.
add
(
0
,
CONTEXT_MENU_ACCOUNT_RECONNECT_ID
,
0
,
menu
.
add
(
R
.
string
.
account_reconnect
).
setOnMenuItemClickListener
(
getText
(
R
.
string
.
account_reconnect
));
new
MenuItem
.
OnMenuItemClickListener
()
{
menu
.
add
(
0
,
CONTEXT_MENU_ACCOUNT_STATUS_ID
,
0
,
getText
(
R
.
string
.
status_editor
));
@Override
menu
.
add
(
0
,
CONTEXT_MENU_ACCOUNT_EDITOR_ID
,
0
,
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
getText
(
R
.
string
.
account_editor
));
if
(
AccountManager
.
getInstance
()
if
(
state
.
isConnected
())
{
.
getAccount
(
account
).
updateConnection
(
true
))
menu
.
add
(
0
,
CONTEXT_MENU_ACCOUNT_VCARD_ID
,
0
,
AccountManager
.
getInstance
().
onAccountChanged
(
getText
(
R
.
string
.
contact_viewer
));
account
);
menu
.
add
(
0
,
CONTEXT_MENU_ACCOUNT_ADD_CONTACT_ID
,
0
,
return
true
;
getText
(
R
.
string
.
contact_add
));
}
}
createOfflineModeContextMenu
(
menu
);
});
menu
.
add
(
R
.
string
.
status_editor
).
setIntent
(
StatusEditor
.
createIntent
(
this
,
account
));
menu
.
add
(
R
.
string
.
account_editor
).
setIntent
(
AccountEditor
.
createIntent
(
this
,
account
));
if
(
state
.
isConnected
())
{
menu
.
add
(
R
.
string
.
contact_viewer
).
setOnMenuItemClickListener
(
new
MenuItem
.
OnMenuItemClickListener
()
{
@Override
public
boolean
onMenuItemClick
(
MenuItem
item
)
{
String
user
=
AccountManager
.
getInstance
()
.
getAccount
(
account
).
getRealJid
();
if
(
user
==
null
)
Application
.
getInstance
().
onError
(
R
.
string
.
NOT_CONNECTED
);
else
{
startActivity
(
ContactViewer
.
createIntent
(
ContactList
.
this
,
account
,
user
));
}
return
true
;
}
});
menu
.
add
(
R
.
string
.
contact_add
).
setIntent
(
ContactAdd
.
createIntent
(
this
,
account
));
}
createOfflineModeContextMenu
(
menu
);
}
}
private
void
createOfflineModeContextMenu
(
ContextMenu
menu
)
{
private
void
createOfflineModeContextMenu
(
ContextMenu
menu
)
{
...
@@ -717,33 +738,6 @@ public class ContactList extends ManagedListActivity implements
...
@@ -717,33 +738,6 @@ public class ContactList extends ManagedListActivity implements
getSupportFragmentManager
(),
"GROUP_DELETE"
);
getSupportFragmentManager
(),
"GROUP_DELETE"
);
return
true
;
return
true
;
// Account
case
CONTEXT_MENU_ACCOUNT_RECONNECT_ID:
if
(
AccountManager
.
getInstance
().
getAccount
(
actionWithAccount
)
.
updateConnection
(
true
))
AccountManager
.
getInstance
()
.
onAccountChanged
(
actionWithAccount
);
return
true
;
case
CONTEXT_MENU_ACCOUNT_VCARD_ID:
String
user
=
AccountManager
.
getInstance
()
.
getAccount
(
actionWithAccount
).
getRealJid
();
if
(
user
==
null
)
Application
.
getInstance
().
onError
(
R
.
string
.
NOT_CONNECTED
);
else
{
startActivity
(
ContactViewer
.
createIntent
(
this
,
actionWithAccount
,
user
));
}
return
true
;
case
CONTEXT_MENU_ACCOUNT_EDITOR_ID:
startActivity
(
AccountEditor
.
createIntent
(
this
,
actionWithAccount
));
return
true
;
case
CONTEXT_MENU_ACCOUNT_STATUS_ID:
startActivity
(
StatusEditor
.
createIntent
(
this
,
actionWithAccount
));
return
true
;
case
CONTEXT_MENU_ACCOUNT_ADD_CONTACT_ID:
startActivity
(
ContactAdd
.
createIntent
(
this
,
actionWithAccount
));
return
true
;
// Groups or account
// Groups or account
case
CONTEXT_MENU_SHOW_OFFLINE_ALWAYS_ID:
case
CONTEXT_MENU_SHOW_OFFLINE_ALWAYS_ID:
GroupManager
.
getInstance
().
setShowOfflineMode
(
GroupManager
.
getInstance
().
setShowOfflineMode
(
...
@@ -840,7 +834,7 @@ public class ContactList extends ManagedListActivity implements
...
@@ -840,7 +834,7 @@ public class ContactList extends ManagedListActivity implements
scrollUp
();
scrollUp
();
break
;
break
;
default
:
default
:
String
account
=
(
String
)
accountToggleAdapter
.
getItemForView
(
view
);
String
account
=
accountToggleAdapter
.
getItemForView
(
view
);
if
(
account
==
null
)
// Check for tap on account in the title
if
(
account
==
null
)
// Check for tap on account in the title
break
;
break
;
ListView
listView
=
getListView
();
ListView
listView
=
getListView
();
...
...
src/com/xabber/android/ui/adapter/AccountToggleAdapter.java
View file @
362aa208
...
@@ -138,7 +138,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
...
@@ -138,7 +138,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
* child.
* child.
* @return The data for the specified view.
* @return The data for the specified view.
*/
*/
public
Object
getItemForView
(
View
view
)
{
public
String
getItemForView
(
View
view
)
{
if
(
view
.
getId
()
==
R
.
id
.
status_mode
)
if
(
view
.
getId
()
==
R
.
id
.
status_mode
)
view
=
(
View
)
view
.
getParent
();
view
=
(
View
)
view
.
getParent
();
for
(
int
index
=
0
;
index
<
linearLayout
.
getChildCount
();
index
++)
for
(
int
index
=
0
;
index
<
linearLayout
.
getChildCount
();
index
++)
...
...
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