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
75a4e23b
Commit
75a4e23b
authored
Sep 15, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avatar hash now send with presence stanzas.
parent
17112aec
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
+33
-6
AvatarManager.java
...m/xabber/android/data/extension/avatar/AvatarManager.java
+12
-2
VCardManager.java
...com/xabber/android/data/extension/vcard/VCardManager.java
+5
-1
PresenceManager.java
.../java/com/xabber/android/data/roster/PresenceManager.java
+12
-2
VCardUpdate.java
xabber/src/main/java/com/xabber/xmpp/avatar/VCardUpdate.java
+4
-1
No files found.
xabber/src/main/java/com/xabber/android/data/extension/avatar/AvatarManager.java
View file @
75a4e23b
...
...
@@ -23,6 +23,7 @@ import android.graphics.drawable.ColorDrawable;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.LayerDrawable
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
com.xabber.android.R
;
import
com.xabber.android.data.Application
;
...
...
@@ -230,8 +231,8 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
* avatar or avatar doesn't exists.
*/
private
Bitmap
getBitmap
(
String
bareAddress
)
{
String
hash
=
hashes
.
get
(
bareAddress
);
if
(
hash
==
null
||
hash
.
equals
(
EMPTY_HASH
)
)
{
String
hash
=
getHash
(
bareAddress
);
if
(
hash
==
null
)
{
return
null
;
}
Bitmap
bitmap
=
bitmaps
.
get
(
hash
);
...
...
@@ -242,6 +243,15 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
}
}
@Nullable
public
String
getHash
(
String
bareAddress
)
{
String
hash
=
hashes
.
get
(
bareAddress
);
if
(
hash
==
null
||
hash
.
equals
(
EMPTY_HASH
))
{
return
null
;
}
return
hash
;
}
/**
* Sets avatar's value.
*
...
...
xabber/src/main/java/com/xabber/android/data/extension/vcard/VCardManager.java
View file @
75a4e23b
...
...
@@ -18,6 +18,7 @@ import android.database.Cursor;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.data.NetworkException
;
import
com.xabber.android.data.OnLoadListener
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.AccountItem
;
...
...
@@ -30,6 +31,7 @@ import com.xabber.android.data.connection.OnPacketListener;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.roster.OnRosterChangedListener
;
import
com.xabber.android.data.roster.OnRosterReceivedListener
;
import
com.xabber.android.data.roster.PresenceManager
;
import
com.xabber.android.data.roster.RosterContact
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.data.roster.StructuredName
;
...
...
@@ -332,7 +334,9 @@ public class VCardManager implements OnLoadListener, OnPacketListener,
vCardSaveRequests
.
add
(
account
);
try
{
vCardManager
.
saveVCard
(
vCard
);
}
catch
(
SmackException
.
NoResponseException
|
XMPPException
.
XMPPErrorException
|
SmackException
.
NotConnectedException
e
)
{
PresenceManager
.
getInstance
().
sendVCardUpdatePresence
(
account
,
vCard
.
getAvatarHash
());
}
catch
(
SmackException
.
NoResponseException
|
XMPPException
.
XMPPErrorException
|
SmackException
.
NotConnectedException
|
NetworkException
e
)
{
LogManager
.
w
(
this
,
"Error saving vCard: "
+
e
.
getMessage
());
isSuccess
=
false
;
}
...
...
xabber/src/main/java/com/xabber/android/data/roster/PresenceManager.java
View file @
75a4e23b
...
...
@@ -28,9 +28,11 @@ import com.xabber.android.data.connection.OnDisconnectListener;
import
com.xabber.android.data.connection.OnPacketListener
;
import
com.xabber.android.data.entity.NestedMap
;
import
com.xabber.android.data.extension.archive.OnArchiveModificationsReceivedListener
;
import
com.xabber.android.data.extension.avatar.AvatarManager
;
import
com.xabber.android.data.notification.EntityNotificationProvider
;
import
com.xabber.android.data.notification.NotificationManager
;
import
com.xabber.xmpp.address.Jid
;
import
com.xabber.xmpp.avatar.VCardUpdate
;
import
org.jivesoftware.smack.packet.IQ
;
import
org.jivesoftware.smack.packet.Presence
;
...
...
@@ -379,10 +381,18 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
* @throws NetworkException
*/
public
void
resendPresence
(
String
account
)
throws
NetworkException
{
sendVCardUpdatePresence
(
account
,
AvatarManager
.
getInstance
().
getHash
(
Jid
.
getBareAddress
(
account
)));
}
public
void
sendVCardUpdatePresence
(
String
account
,
String
hash
)
throws
NetworkException
{
if
(!
readyAccounts
.
contains
(
account
))
throw
new
NetworkException
(
R
.
string
.
NOT_CONNECTED
);
ConnectionManager
.
getInstance
().
sendStanza
(
account
,
AccountManager
.
getInstance
().
getAccount
(
account
).
getPresence
());
final
Presence
presence
=
AccountManager
.
getInstance
().
getAccount
(
account
).
getPresence
();
final
VCardUpdate
vCardUpdate
=
new
VCardUpdate
();
vCardUpdate
.
setPhotoHash
(
hash
);
presence
.
addExtension
(
vCardUpdate
);
ConnectionManager
.
getInstance
().
sendStanza
(
account
,
presence
);
}
}
xabber/src/main/java/com/xabber/xmpp/avatar/VCardUpdate.java
View file @
75a4e23b
...
...
@@ -93,8 +93,11 @@ public class VCardUpdate extends PacketExtension {
@Override
public
void
serializeContent
(
XmlSerializer
serializer
)
throws
IOException
{
if
(
photoHash
!=
null
)
if
(
photoHash
!=
null
)
{
SerializerUtils
.
addTextTag
(
serializer
,
PHOTO_NAME
,
photoHash
);
}
else
{
SerializerUtils
.
addEmtpyTag
(
serializer
,
PHOTO_NAME
);
}
}
}
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