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
23e3e407
Commit
23e3e407
authored
May 28, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate contact list, account toggler and intent methods.
parent
68a6c838
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
78 deletions
+95
-78
ContactList.java
src/com/xabber/android/ui/ContactList.java
+90
-74
ContactListAdapter.java
src/com/xabber/android/ui/adapter/ContactListAdapter.java
+5
-4
No files found.
src/com/xabber/android/ui/ContactList.java
View file @
23e3e407
...
...
@@ -162,7 +162,7 @@ public class ContactList extends ManagedListActivity implements
listView
.
setItemsCanFocus
(
true
);
registerForContextMenu
(
listView
);
contactListAdapter
=
new
ContactListAdapter
(
this
);
contactListAdapter
=
new
ContactListAdapter
(
this
,
listView
);
setListAdapter
(
contactListAdapter
);
accountToggleAdapter
=
new
AccountToggleAdapter
(
this
,
this
,
(
LinearLayout
)
findViewById
(
R
.
id
.
account_list
));
...
...
@@ -498,38 +498,53 @@ public class ContactList extends ManagedListActivity implements
String
account
=
accountToggleAdapter
.
getItemForView
(
view
);
if
(
account
==
null
)
// Check for tap on account in the title
break
;
ListView
listView
=
getListView
();
if
(!
SettingsManager
.
contactsShowAccounts
())
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
{
if
(
AccountManager
.
getInstance
().
getAccounts
().
size
()
<
2
)
scrollUp
();
}
else
{
if
(
account
.
equals
(
AccountManager
.
getInstance
()
.
getSelectedAccount
()))
SettingsManager
.
setContactsSelectedAccount
(
""
);
else
SettingsManager
.
setContactsSelectedAccount
(
account
);
rebuildAccountToggler
();
contactListAdapter
.
onChange
();
stopMovement
();
}
}
else
{
long
count
=
listView
.
getCount
();
for
(
int
position
=
0
;
position
<
(
int
)
count
;
position
++)
{
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
.
getItemAtPosition
(
position
);
if
(
baseEntity
!=
null
&&
baseEntity
instanceof
AccountConfiguration
&&
baseEntity
.
getAccount
().
equals
(
account
))
{
listView
.
setSelection
(
position
);
stopMovement
();
break
;
}
}
}
else
setSelectedAccount
(
account
);
}
else
scrollTo
(
account
);
break
;
}
}
/**
* Scroll contact list to specified account.
*
* @param account
*/
private
void
scrollTo
(
String
account
)
{
ListView
listView
=
getListView
();
long
count
=
listView
.
getCount
();
for
(
int
position
=
0
;
position
<
(
int
)
count
;
position
++)
{
BaseEntity
baseEntity
=
(
BaseEntity
)
listView
.
getItemAtPosition
(
position
);
if
(
baseEntity
!=
null
&&
baseEntity
instanceof
AccountConfiguration
&&
baseEntity
.
getAccount
().
equals
(
account
))
{
listView
.
setSelection
(
position
);
stopMovement
();
break
;
}
}
}
/**
* Filter out contact list for selected account.
*
* @param account
*/
private
void
setSelectedAccount
(
String
account
)
{
if
(
account
.
equals
(
AccountManager
.
getInstance
().
getSelectedAccount
()))
SettingsManager
.
setContactsSelectedAccount
(
""
);
else
SettingsManager
.
setContactsSelectedAccount
(
account
);
rebuildAccountToggler
();
contactListAdapter
.
onChange
();
stopMovement
();
}
/**
* Stop fling scrolling.
*/
...
...
@@ -567,53 +582,7 @@ public class ContactList extends ManagedListActivity implements
if
(
object
==
null
)
{
// Account toggler
}
else
if
(
object
instanceof
AbstractContact
)
{
AbstractContact
abstractContact
=
(
AbstractContact
)
object
;
if
(
ACTION_ROOM_INVITE
.
equals
(
action
))
{
action
=
null
;
Intent
intent
=
getIntent
();
String
account
=
getRoomInviteAccount
(
intent
);
String
user
=
getRoomInviteUser
(
intent
);
if
(
account
!=
null
&&
user
!=
null
)
try
{
MUCManager
.
getInstance
().
invite
(
account
,
user
,
abstractContact
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
finish
();
}
else
if
(
Intent
.
ACTION_SEND
.
equals
(
action
))
{
action
=
null
;
startActivity
(
ChatViewer
.
createSendIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
(),
sendText
));
finish
();
}
else
if
(
Intent
.
ACTION_CREATE_SHORTCUT
.
equals
(
action
))
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_INTENT
,
ChatViewer
.
createClearTopIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_NAME
,
abstractContact
.
getName
());
Bitmap
bitmap
;
if
(
MUCManager
.
getInstance
()
.
hasRoom
(
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()))
bitmap
=
AvatarManager
.
getInstance
().
getRoomBitmap
(
abstractContact
.
getUser
());
else
bitmap
=
AvatarManager
.
getInstance
().
getUserBitmap
(
abstractContact
.
getUser
());
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_ICON
,
AvatarManager
.
getInstance
().
createShortcutBitmap
(
bitmap
));
setResult
(
RESULT_OK
,
intent
);
finish
();
}
else
{
startActivity
(
ChatViewer
.
createIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
}
onContactClick
((
AbstractContact
)
object
);
}
else
if
(
object
instanceof
GroupConfiguration
)
{
GroupConfiguration
groupConfiguration
=
(
GroupConfiguration
)
object
;
contactListAdapter
.
setExpanded
(
groupConfiguration
.
getAccount
(),
...
...
@@ -622,6 +591,53 @@ public class ContactList extends ManagedListActivity implements
}
}
private
void
onContactClick
(
AbstractContact
abstractContact
)
{
if
(
ACTION_ROOM_INVITE
.
equals
(
action
))
{
action
=
null
;
Intent
intent
=
getIntent
();
String
account
=
getRoomInviteAccount
(
intent
);
String
user
=
getRoomInviteUser
(
intent
);
if
(
account
!=
null
&&
user
!=
null
)
try
{
MUCManager
.
getInstance
().
invite
(
account
,
user
,
abstractContact
.
getUser
());
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
finish
();
}
else
if
(
Intent
.
ACTION_SEND
.
equals
(
action
))
{
action
=
null
;
startActivity
(
ChatViewer
.
createSendIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
(),
sendText
));
finish
();
}
else
if
(
Intent
.
ACTION_CREATE_SHORTCUT
.
equals
(
action
))
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_INTENT
,
ChatViewer
.
createClearTopIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_NAME
,
abstractContact
.
getName
());
Bitmap
bitmap
;
if
(
MUCManager
.
getInstance
().
hasRoom
(
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()))
bitmap
=
AvatarManager
.
getInstance
().
getRoomBitmap
(
abstractContact
.
getUser
());
else
bitmap
=
AvatarManager
.
getInstance
().
getUserBitmap
(
abstractContact
.
getUser
());
intent
.
putExtra
(
Intent
.
EXTRA_SHORTCUT_ICON
,
AvatarManager
.
getInstance
().
createShortcutBitmap
(
bitmap
));
setResult
(
RESULT_OK
,
intent
);
finish
();
}
else
{
startActivity
(
ChatViewer
.
createIntent
(
this
,
abstractContact
.
getAccount
(),
abstractContact
.
getUser
()));
}
}
@Override
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
addresses
)
{
contactListAdapter
.
refreshRequest
();
...
...
src/com/xabber/android/ui/adapter/ContactListAdapter.java
View file @
23e3e407
...
...
@@ -22,12 +22,14 @@ import java.util.Date;
import
java.util.Map.Entry
;
import
java.util.TreeMap
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.animation.Animation
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Button
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
com.xabber.android.data.SettingsManager
;
...
...
@@ -47,7 +49,6 @@ import com.xabber.android.data.roster.RosterManager;
import
com.xabber.android.ui.AccountAdd
;
import
com.xabber.android.ui.AccountList
;
import
com.xabber.android.ui.ContactAdd
;
import
com.xabber.android.ui.helper.ManagedListActivity
;
import
com.xabber.androiddev.R
;
/**
...
...
@@ -120,9 +121,9 @@ public class ContactListAdapter extends
*/
private
Date
nextRefresh
;
public
ContactListAdapter
(
ManagedListActivity
activity
)
{
super
(
activity
,
activity
.
getListView
(),
new
ChatContactInflater
(
activity
),
GroupManager
.
getInstance
());
public
ContactListAdapter
(
Activity
activity
,
ListView
listView
)
{
super
(
activity
,
listView
,
new
ChatContactInflater
(
activity
),
GroupManager
.
getInstance
());
infoView
=
activity
.
findViewById
(
R
.
id
.
info
);
if
(
infoView
!=
null
)
{
connectedView
=
infoView
.
findViewById
(
R
.
id
.
connected
);
...
...
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