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
33074dd2
Commit
33074dd2
authored
Mar 19, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ContactViewerFragment: jabber name can be edited in toolbar. RosterManager: setName method added.
parent
8c8c65d1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
10 deletions
+75
-10
RosterManager.java
...in/java/com/xabber/android/data/roster/RosterManager.java
+18
-1
ContactViewer.java
app/src/main/java/com/xabber/android/ui/ContactViewer.java
+6
-3
ContactViewerFragment.java
...ain/java/com/xabber/android/ui/ContactViewerFragment.java
+35
-5
expandable_contact_title_activity.xml
...src/main/res/layout/expandable_contact_title_activity.xml
+16
-1
No files found.
app/src/main/java/com/xabber/android/data/roster/RosterManager.java
View file @
33074dd2
...
...
@@ -348,11 +348,28 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
return
;
}
}
updateRosterContact
(
account
,
bareAddress
,
name
,
groups
);
}
public
void
setName
(
String
account
,
String
bareAddress
,
String
name
)
throws
NetworkException
{
RosterContact
contact
=
getRosterContact
(
account
,
bareAddress
);
if
(
contact
==
null
)
throw
new
NetworkException
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
if
(
contact
.
getRealName
().
equals
(
name
))
{
return
;
}
updateRosterContact
(
account
,
bareAddress
,
name
,
contact
.
getGroupNames
());
}
private
void
updateRosterContact
(
String
account
,
String
bareAddress
,
String
name
,
Collection
<
String
>
groups
)
throws
NetworkException
{
RosterPacket
packet
=
new
RosterPacket
();
packet
.
setType
(
IQ
.
Type
.
SET
);
RosterPacket
.
Item
item
=
new
RosterPacket
.
Item
(
bareAddress
,
name
);
for
(
String
group
:
groups
)
for
(
String
group
:
groups
)
{
item
.
addGroupName
(
group
);
}
packet
.
addRosterItem
(
item
);
ConnectionManager
.
getInstance
().
sendPacket
(
account
,
packet
);
}
...
...
app/src/main/java/com/xabber/android/ui/ContactViewer.java
View file @
33074dd2
...
...
@@ -200,9 +200,6 @@ public class ContactViewer extends ManagedActivity implements
contactTitleExpandableToolbarInflater
=
new
ContactTitleExpandableToolbarInflater
(
this
);
AbstractContact
bestContact
=
RosterManager
.
getInstance
().
getBestContact
(
account
,
bareAddress
);
contactTitleExpandableToolbarInflater
.
onCreate
(
bestContact
);
findViewById
(
R
.
id
.
status_icon
).
setVisibility
(
View
.
GONE
);
findViewById
(
R
.
id
.
status_text
).
setVisibility
(
View
.
GONE
);
}
@Override
...
...
@@ -333,4 +330,10 @@ public class ContactViewer extends ManagedActivity implements
public
static
Map
<
EmailType
,
Integer
>
getEmailTypeMap
()
{
return
EMAIL_TYPE_MAP
;
}
public
View
getContactTitleView
()
{
return
findViewById
(
R
.
id
.
expandable_contact_title
);
}
}
app/src/main/java/com/xabber/android/ui/ContactViewerFragment.java
View file @
33074dd2
...
...
@@ -7,10 +7,13 @@ import android.support.annotation.Nullable;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.extension.capability.CapabilitiesManager
;
import
com.xabber.android.data.extension.capability.ClientInfo
;
import
com.xabber.android.data.roster.PresenceManager
;
...
...
@@ -37,6 +40,10 @@ public class ContactViewerFragment extends Fragment {
private
LinearLayout
xmppItems
;
private
LinearLayout
contactInfoItems
;
String
account
;
String
bareAddress
;
private
EditText
contactNameEditText
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -52,9 +59,29 @@ public class ContactViewerFragment extends Fragment {
xmppItems
=
(
LinearLayout
)
view
.
findViewById
(
R
.
id
.
xmpp_items
);
contactInfoItems
=
(
LinearLayout
)
view
.
findViewById
(
R
.
id
.
contact_info_items
);
View
contactTitleView
=
((
ContactViewer
)
getActivity
()).
getContactTitleView
();
contactTitleView
.
findViewById
(
R
.
id
.
status_icon
).
setVisibility
(
View
.
GONE
);
contactTitleView
.
findViewById
(
R
.
id
.
status_text
).
setVisibility
(
View
.
GONE
);
contactTitleView
.
findViewById
(
R
.
id
.
name
).
setVisibility
(
View
.
GONE
);
contactNameEditText
=
(
EditText
)
contactTitleView
.
findViewById
(
R
.
id
.
contact_name_edit
);
contactNameEditText
.
setVisibility
(
View
.
VISIBLE
);
return
view
;
}
@Override
public
void
onPause
()
{
super
.
onPause
();
try
{
String
name
=
contactNameEditText
.
getText
().
toString
();
RosterManager
.
getInstance
().
setName
(
account
,
bareAddress
,
name
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
}
/**
* @param source
* @param value
...
...
@@ -70,13 +97,17 @@ public class ContactViewerFragment extends Fragment {
}
public
void
updateContact
(
String
account
,
String
bareAddress
)
{
this
.
account
=
account
;
this
.
bareAddress
=
bareAddress
;
xmppItems
.
removeAllViews
();
addXmppItem
(
getString
(
R
.
string
.
contact_viewer_jid
),
bareAddress
,
R
.
drawable
.
ic_xmpp_24dp
);
RosterContact
rosterContact
=
RosterManager
.
getInstance
().
getRosterContact
(
account
,
bareAddress
);
addXmppItem
(
getString
(
R
.
string
.
contact_viewer_name
),
rosterContact
==
null
?
null
:
rosterContact
.
getRealName
(),
null
);
if
(
rosterContact
==
null
||
!
rosterContact
.
isConnected
())
{
contactNameEditText
.
setText
(
rosterContact
.
getName
());
if
(!
rosterContact
.
isConnected
())
{
return
;
}
...
...
@@ -288,8 +319,8 @@ public class ContactViewerFragment extends Fragment {
}
}
private
void
addItem
(
List
<
View
>
nameList
,
LinearLayout
contactInfoItems
,
String
label
,
String
value
)
{
View
itemView
=
createItemView
(
contactInfoItems
,
label
,
value
,
null
);
private
void
addItem
(
List
<
View
>
nameList
,
ViewGroup
rootView
,
String
label
,
String
value
)
{
View
itemView
=
createItemView
(
rootView
,
label
,
value
,
null
);
if
(
itemView
!=
null
)
{
nameList
.
add
(
itemView
);
}
...
...
@@ -307,7 +338,6 @@ public class ContactViewerFragment extends Fragment {
}
}
private
View
createItemView
(
ViewGroup
rootView
,
String
label
,
String
value
,
Integer
iconResource
)
{
if
(
value
==
null
||
value
.
isEmpty
()
)
{
return
null
;
...
...
app/src/main/res/layout/expandable_contact_title_activity.xml
View file @
33074dd2
...
...
@@ -3,7 +3,8 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:descendantFocusability=
"beforeDescendants"
android:focusableInTouchMode=
"true"
>
<com.github.ksoichiro.android.observablescrollview.ObservableScrollView
android:id=
"@+id/scroll"
...
...
@@ -71,6 +72,20 @@
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
<EditText
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textPersonName"
android:textColor=
"@color/primary_text_default_material_dark"
android:text=
"Name"
android:singleLine=
"true"
android:ems=
"10"
android:id=
"@+id/contact_name_edit"
android:gravity=
"center_vertical"
android:visibility=
"gone"
android:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
/>
<TextView
android:id=
"@+id/status_text"
android:layout_width=
"wrap_content"
...
...
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