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
7d17df87
Commit
7d17df87
authored
Mar 17, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactViewerFragment: separate views for xmpp data and vcard info.
parent
20fa4b61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
14 deletions
+47
-14
ContactViewerFragment.java
...ain/java/com/xabber/android/ui/ContactViewerFragment.java
+29
-13
contact_viewer_fragment.xml
app/src/main/res/layout/contact_viewer_fragment.xml
+18
-1
No files found.
app/src/main/java/com/xabber/android/ui/ContactViewerFragment.java
View file @
7d17df87
...
...
@@ -11,7 +11,6 @@ import android.widget.ImageView;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.extension.capability.CapabilitiesManager
;
import
com.xabber.android.data.extension.capability.ClientInfo
;
import
com.xabber.android.data.roster.PresenceManager
;
...
...
@@ -34,6 +33,7 @@ import com.xabber.xmpp.vcard.VCardProperty;
import
java.util.List
;
public
class
ContactViewerFragment
extends
Fragment
{
private
LinearLayout
xmppItems
;
private
LinearLayout
contactInfoItems
;
@Override
...
...
@@ -48,6 +48,7 @@ public class ContactViewerFragment extends Fragment {
View
view
=
inflater
.
inflate
(
R
.
layout
.
contact_viewer_fragment
,
container
,
false
);
xmppItems
=
(
LinearLayout
)
view
.
findViewById
(
R
.
id
.
xmpp_items
);
contactInfoItems
=
(
LinearLayout
)
view
.
findViewById
(
R
.
id
.
contact_info_items
);
return
view
;
...
...
@@ -68,9 +69,11 @@ public class ContactViewerFragment extends Fragment {
}
public
void
updateContact
(
String
account
,
String
bareAddress
)
{
addContactInfoItem
(
R
.
string
.
contact_viewer_jid
,
bareAddress
);
xmppItems
.
removeAllViews
();
addXmppItem
(
getString
(
R
.
string
.
contact_viewer_jid
),
bareAddress
,
null
);
RosterContact
rosterContact
=
RosterManager
.
getInstance
().
getRosterContact
(
account
,
bareAddress
);
add
ContactInfoItem
(
R
.
string
.
contact_viewer_name
,
rosterContact
==
null
?
null
:
rosterContact
.
getRealName
()
);
add
XmppItem
(
getString
(
R
.
string
.
contact_viewer_name
),
rosterContact
==
null
?
null
:
rosterContact
.
getRealName
(),
null
);
if
(
rosterContact
!=
null
&&
rosterContact
.
isConnected
())
for
(
ResourceItem
resourceItem
...
...
@@ -109,16 +112,17 @@ public class ContactViewerFragment extends Fragment {
label
=
label
+
", "
+
client
;
}
add
ContactInfo
Item
(
label
,
resourceItem
.
getVerbose
(),
R
.
drawable
.
ic_xmpp_24dp
);
add
Xmpp
Item
(
label
,
resourceItem
.
getVerbose
(),
R
.
drawable
.
ic_xmpp_24dp
);
}
}
public
void
updateVCard
(
VCard
vCard
)
{
LogManager
.
i
(
this
,
"updateVCard."
);
if
(
vCard
==
null
)
{
return
;
}
contactInfoItems
.
removeAllViews
();
addContactInfoItem
(
R
.
string
.
vcard_nick_name
,
vCard
.
getField
(
VCardProperty
.
NICKNAME
));
addContactInfoItem
(
getString
(
R
.
string
.
vcard_formatted_name
),
vCard
.
getFormattedName
(),
R
.
drawable
.
ic_contact_info_24dp
);
addContactInfoItem
(
R
.
string
.
vcard_prefix_name
,
vCard
.
getField
(
NameProperty
.
PREFIX
));
...
...
@@ -195,15 +199,28 @@ public class ContactViewerFragment extends Fragment {
}
private
void
addContactInfoItem
(
String
label
,
String
value
,
Integer
iconResource
)
{
LogManager
.
i
(
this
,
label
+
": "
+
value
);
View
contactInfoItem
=
createItemView
(
contactInfoItems
,
label
,
value
,
iconResource
);
if
(
contactInfoItem
!=
null
)
{
contactInfoItems
.
addView
(
contactInfoItem
);
}
}
private
void
addXmppItem
(
String
label
,
String
value
,
Integer
iconResource
)
{
View
contactInfoItem
=
createItemView
(
xmppItems
,
label
,
value
,
iconResource
);
if
(
contactInfoItem
!=
null
)
{
xmppItems
.
addView
(
contactInfoItem
);
}
}
private
View
createItemView
(
ViewGroup
rootView
,
String
label
,
String
value
,
Integer
iconResource
)
{
if
(
value
==
null
||
value
.
isEmpty
()
)
{
return
;
return
null
;
}
final
LayoutInflater
inflater
=
(
LayoutInflater
)
getActivity
().
getSystemService
(
Activity
.
LAYOUT_INFLATER_SERVICE
);
View
contactInfoItem
=
inflater
.
inflate
(
R
.
layout
.
contact_info_item
,
contactInfoItems
,
false
);
LayoutInflater
inflater
=
(
LayoutInflater
)
getActivity
().
getSystemService
(
Activity
.
LAYOUT_INFLATER_SERVICE
);
View
contactInfoItem
=
inflater
.
inflate
(
R
.
layout
.
contact_info_item
,
rootView
,
false
);
((
TextView
)
contactInfoItem
.
findViewById
(
R
.
id
.
contact_info_item_name
)).
setText
(
label
);
((
TextView
)
contactInfoItem
.
findViewById
(
R
.
id
.
contact_info_item_value
)).
setText
(
value
);
...
...
@@ -211,8 +228,7 @@ public class ContactViewerFragment extends Fragment {
if
(
iconResource
!=
null
)
{
((
ImageView
)
contactInfoItem
.
findViewById
(
R
.
id
.
contact_info_group_icon
)).
setImageResource
(
iconResource
);
}
contactInfoItems
.
addView
(
contactInfoItem
);
return
contactInfoItem
;
}
}
app/src/main/res/layout/contact_viewer_fragment.xml
View file @
7d17df87
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/contact_info_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/xmpp_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
/>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/contact_info_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
/>
</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