Commit bcbb1c98 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'feature/notifications' into develop

parents fcbb6053 ef08f374
...@@ -8,8 +8,8 @@ android { ...@@ -8,8 +8,8 @@ android {
applicationId "com.xabber.androiddev" applicationId "com.xabber.androiddev"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 21 targetSdkVersion 21
versionCode 88 versionCode 107
versionName '0.10.3' versionName '0.10.10'
} }
buildTypes { buildTypes {
...@@ -18,6 +18,10 @@ android { ...@@ -18,6 +18,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
} }
dependencies { dependencies {
......
...@@ -123,7 +123,14 @@ ...@@ -123,7 +123,14 @@
<activity <activity
android:label="@string/occupant_list" android:label="@string/occupant_list"
android:name="com.xabber.android.ui.OccupantList" android:name="com.xabber.android.ui.OccupantList"
/> android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.ChatViewer" />
</activity>
<activity <activity
android:label="@string/chat_viewer" android:label="@string/chat_viewer"
android:name="com.xabber.android.ui.ChatViewer" android:name="com.xabber.android.ui.ChatViewer"
......
...@@ -14,18 +14,6 @@ ...@@ -14,18 +14,6 @@
*/ */
package com.xabber.android.data.account; package com.xabber.android.data.account;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.jivesoftware.smack.util.StringUtils;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.database.Cursor; import android.database.Cursor;
import android.os.Build; import android.os.Build;
...@@ -46,6 +34,18 @@ import com.xabber.android.data.roster.RosterManager; ...@@ -46,6 +34,18 @@ import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
import org.jivesoftware.smack.util.StringUtils;
import java.security.KeyPair;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/** /**
* This class manage all operations with accounts. * This class manage all operations with accounts.
* <p/> * <p/>
...@@ -117,9 +117,9 @@ public class AccountManager implements OnLoadListener, OnWipeListener { ...@@ -117,9 +117,9 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
enabledAccounts = new HashSet<String>(); enabledAccounts = new HashSet<String>();
savedStatuses = new ArrayList<SavedStatus>(); savedStatuses = new ArrayList<SavedStatus>();
authorizationErrorProvider = new BaseAccountNotificationProvider<AccountAuthorizationError>( authorizationErrorProvider = new BaseAccountNotificationProvider<AccountAuthorizationError>(
R.drawable.ic_stat_auth_failed); R.drawable.ic_stat_error);
passwordRequestProvider = new BaseAccountNotificationProvider<PasswordRequest>( passwordRequestProvider = new BaseAccountNotificationProvider<PasswordRequest>(
R.drawable.ic_stat_request); R.drawable.ic_stat_ic_add_circle);
TypedArray accountAvatars = application.getResources() TypedArray accountAvatars = application.getResources()
.obtainTypedArray(R.array.account_avatars); .obtainTypedArray(R.array.account_avatars);
......
...@@ -14,6 +14,19 @@ ...@@ -14,6 +14,19 @@
*/ */
package com.xabber.android.data.connection; package com.xabber.android.data.connection;
import android.content.res.AssetManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.OnClearListener;
import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.notification.BaseNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.CertificateListener;
import org.jivesoftware.smack.util.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -34,19 +47,6 @@ import java.util.HashMap; ...@@ -34,19 +47,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.CertificateListener;
import org.jivesoftware.smack.util.StringUtils;
import android.content.res.AssetManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.OnClearListener;
import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.notification.BaseNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R;
/** /**
* Manage certificate exceptions. * Manage certificate exceptions.
* <p/> * <p/>
...@@ -94,7 +94,7 @@ public class CertificateManager implements OnLoadListener, OnClearListener { ...@@ -94,7 +94,7 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
private final Map<CertificateInvalidReason, KeyStore> defaultStores; private final Map<CertificateInvalidReason, KeyStore> defaultStores;
private final BaseNotificationProvider<PendingCertificate> pendingCertificateProvider = new BaseNotificationProvider<PendingCertificate>( private final BaseNotificationProvider<PendingCertificate> pendingCertificateProvider = new BaseNotificationProvider<PendingCertificate>(
R.drawable.ic_stat_auth_failed) { R.drawable.ic_stat_error) {
@Override @Override
public void clearNotifications() { public void clearNotifications() {
......
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
*/ */
package com.xabber.android.data.extension.archive; package com.xabber.android.data.extension.archive;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager; import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
...@@ -68,6 +58,16 @@ import com.xabber.xmpp.archive.Session; ...@@ -68,6 +58,16 @@ import com.xabber.xmpp.archive.Session;
import com.xabber.xmpp.archive.SessionRemove; import com.xabber.xmpp.archive.SessionRemove;
import com.xabber.xmpp.rsm.Set; import com.xabber.xmpp.rsm.Set;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
/** /**
* Manage server side archive. Replicate it with memory storage. * Manage server side archive. Replicate it with memory storage.
* <p/> * <p/>
...@@ -164,7 +164,7 @@ public class MessageArchiveManager implements OnPacketListener, ...@@ -164,7 +164,7 @@ public class MessageArchiveManager implements OnPacketListener,
modificationRequests = new NestedMap<Boolean>(); modificationRequests = new NestedMap<Boolean>();
chatStorages = new NestedNestedMaps<String, ChatStorage>(); chatStorages = new NestedNestedMaps<String, ChatStorage>();
availableArchiveRequestProvider = new BaseAccountNotificationProvider<AvailableArchiveRequest>( availableArchiveRequestProvider = new BaseAccountNotificationProvider<AvailableArchiveRequest>(
R.drawable.ic_stat_request); R.drawable.ic_stat_ic_help_black);
} }
@Override @Override
......
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
*/ */
package com.xabber.android.data.extension.attention; package com.xabber.android.data.extension.attention;
import java.util.Iterator;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
...@@ -51,6 +41,16 @@ import com.xabber.androiddev.R; ...@@ -51,6 +41,16 @@ import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.attention.Attention; import com.xabber.xmpp.attention.Attention;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import java.util.Iterator;
/** /**
* XEP-0224: Attention. * XEP-0224: Attention.
* *
...@@ -86,7 +86,7 @@ public class AttentionManager implements OnPacketListener, OnLoadListener { ...@@ -86,7 +86,7 @@ public class AttentionManager implements OnPacketListener, OnLoadListener {
} }
private final EntityNotificationProvider<AttentionRequest> attentionRequestProvider = new EntityNotificationProvider<AttentionRequest>( private final EntityNotificationProvider<AttentionRequest> attentionRequestProvider = new EntityNotificationProvider<AttentionRequest>(
R.drawable.ic_stat_attention) { R.drawable.ic_stat_error) {
@Override @Override
public Uri getSound() { public Uri getSound() {
......
...@@ -14,17 +14,6 @@ ...@@ -14,17 +14,6 @@
*/ */
package com.xabber.android.data.extension.muc; package com.xabber.android.data.extension.muc;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.packet.MUCUser;
import android.database.Cursor; import android.database.Cursor;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
...@@ -46,6 +35,17 @@ import com.xabber.android.data.roster.RosterManager; ...@@ -46,6 +35,17 @@ import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.muc.MUC; import com.xabber.xmpp.muc.MUC;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.packet.MUCUser;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/** /**
* Manage multi user chats. * Manage multi user chats.
* <p/> * <p/>
...@@ -72,9 +72,9 @@ public class MUCManager implements OnLoadListener, OnPacketListener { ...@@ -72,9 +72,9 @@ public class MUCManager implements OnLoadListener, OnPacketListener {
private MUCManager() { private MUCManager() {
inviteProvider = new EntityNotificationProvider<RoomInvite>( inviteProvider = new EntityNotificationProvider<RoomInvite>(
R.drawable.ic_stat_subscribe); R.drawable.ic_stat_ic_add_circle);
authorizationErrorProvider = new EntityNotificationProvider<RoomAuthorizationError>( authorizationErrorProvider = new EntityNotificationProvider<RoomAuthorizationError>(
R.drawable.ic_stat_auth_failed); R.drawable.ic_stat_error);
} }
@Override @Override
......
...@@ -14,29 +14,6 @@ ...@@ -14,29 +14,6 @@
*/ */
package com.xabber.android.data.extension.otr; package com.xabber.android.data.extension.otr;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import net.java.otr4j.OtrEngineHost;
import net.java.otr4j.OtrEngineListener;
import net.java.otr4j.OtrException;
import net.java.otr4j.OtrPolicy;
import net.java.otr4j.OtrPolicyImpl;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException;
import net.java.otr4j.io.SerializationUtils;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
import android.database.Cursor; import android.database.Cursor;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
...@@ -66,6 +43,29 @@ import com.xabber.androiddev.R; ...@@ -66,6 +43,29 @@ import com.xabber.androiddev.R;
import com.xabber.xmpp.archive.OtrMode; import com.xabber.xmpp.archive.OtrMode;
import com.xabber.xmpp.archive.SaveMode; import com.xabber.xmpp.archive.SaveMode;
import net.java.otr4j.OtrEngineHost;
import net.java.otr4j.OtrEngineListener;
import net.java.otr4j.OtrException;
import net.java.otr4j.OtrPolicy;
import net.java.otr4j.OtrPolicyImpl;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException;
import net.java.otr4j.io.SerializationUtils;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionID;
import net.java.otr4j.session.SessionImpl;
import net.java.otr4j.session.SessionStatus;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
/** /**
* Manage off-the-record encryption. * Manage off-the-record encryption.
* <p/> * <p/>
...@@ -134,9 +134,9 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener, ...@@ -134,9 +134,9 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
private OTRManager() { private OTRManager() {
smRequestProvider = new EntityNotificationProvider<SMRequest>( smRequestProvider = new EntityNotificationProvider<SMRequest>(
R.drawable.ic_stat_request); R.drawable.ic_stat_ic_help_black);
smProgressProvider = new EntityNotificationProvider<SMProgress>( smProgressProvider = new EntityNotificationProvider<SMProgress>(
R.drawable.ic_stat_play); R.drawable.ic_stat_ic_play_circle_fill);
smProgressProvider.setCanClearNotifications(false); smProgressProvider.setCanClearNotifications(false);
fingerprints = new NestedNestedMaps<String, Boolean>(); fingerprints = new NestedNestedMaps<String, Boolean>();
actives = new NestedMap<String>(); actives = new NestedMap<String>();
......
package com.xabber.android.data.notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.media.AudioManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ChatViewer;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.util.List;
public class MessageNotificationCreator {
private final Application application;
private List<MessageNotification> messageNotifications;
private NotificationCompat.Builder notificationBuilder;
public MessageNotificationCreator() {
application = Application.getInstance();
}
public android.app.Notification notifyMessageNotification(List<MessageNotification> messageNotifications,
MessageItem messageItem) {
this.messageNotifications = messageNotifications;
if (messageNotifications.isEmpty()) {
return null;
}
int messageCount = 0;
for (MessageNotification messageNotification : messageNotifications) {
messageCount += messageNotification.getCount();
}
MessageNotification message = messageNotifications.get(messageNotifications.size() - 1);
boolean showText = ChatManager.getInstance().isShowText(message.getAccount(), message.getUser());
notificationBuilder = new NotificationCompat.Builder(application);
notificationBuilder.setContentTitle(getTitle(message, messageCount));
notificationBuilder.setContentText(getText(message, showText));
notificationBuilder.setSubText(message.getAccount());
notificationBuilder.setTicker(getText(message, showText));
notificationBuilder.setSmallIcon(getSmallIcon());
notificationBuilder.setLargeIcon(getLargeIcon(message));
notificationBuilder.setWhen(message.getTimestamp().getTime());
notificationBuilder.setColor(NotificationManager.COLOR_MATERIAL_RED_500);
notificationBuilder.setStyle(getStyle(message, messageCount, showText));
notificationBuilder.setContentIntent(getIntent(message));
notificationBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE);
notificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
addEffects(messageItem);
return notificationBuilder.build();
}
private CharSequence getTitle(MessageNotification message, int messageCount) {
if (isFromOneContact()) {
return getSingleContactTitle(message, messageCount);
} else {
return getMultiContactTitle(messageCount);
}
}
private CharSequence getSingleContactTitle(MessageNotification message, int messageCount) {
if (messageCount > 1) {
return application.getString(R.string.chat_messages_from_contact,
messageCount, getTextForMessages(messageCount), getContactName(message));
} else {
return getContactName(message);
}
}
private String getContactName(MessageNotification message) {
return RosterManager.getInstance().getName(message.getAccount(), message.getUser());
}
private CharSequence getMultiContactTitle(int messageCount) {
String messageText = getTextForMessages(messageCount);
String contactText = StringUtils.getQuantityString(application.getResources(),
R.array.chat_contact_quantity, messageNotifications.size());
return application.getString(R.string.chat_status,
messageCount, messageText, messageNotifications.size(), contactText);
}
private String getTextForMessages(int messageCount) {
return StringUtils.getQuantityString(
application.getResources(), R.array.chat_message_quantity, messageCount);
}
private CharSequence getText(MessageNotification message, boolean showText) {
if (isFromOneContact()) {
if (showText) {
return message.getText();
} else {
return null;
}
} else {
return getContactNameAndMessage(message, showText);
}
}
private int getSmallIcon() {
return R.drawable.ic_stat_chat;
}
private android.graphics.Bitmap getLargeIcon(MessageNotification message) {
if (isFromOneContact()) {
if (MUCManager.getInstance().hasRoom(message.getAccount(), message.getUser())) {
return AvatarManager.getInstance().getRoomBitmap(message.getUser());
} else {
return AvatarManager.getInstance().getUserBitmap(message.getUser());
}
}
return null;
}
private boolean isFromOneContact() {
return messageNotifications.size() == 1;
}
private NotificationCompat.Style getStyle(MessageNotification message, int messageCount, boolean showText) {
if (isFromOneContact()) {
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(getSingleContactTitle(message, messageCount));
if (showText) {
bigTextStyle.bigText(message.getText());
}
bigTextStyle.setSummaryText(message.getAccount());
return bigTextStyle;
} else {
return getInboxStyle(messageCount, message.getAccount());
}
}
private NotificationCompat.Style getInboxStyle(int messageCount, String accountName) {
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(getMultiContactTitle(messageCount));
for (int i = 1; i <= messageNotifications.size(); i++) {
MessageNotification messageNotification = messageNotifications.get(messageNotifications.size() - i);
boolean showTextForThisContact
= ChatManager.getInstance().isShowText(messageNotification.getAccount(), messageNotification.getUser());
inboxStyle.addLine(getContactNameAndMessage(messageNotification, showTextForThisContact));
}
inboxStyle.setSummaryText(accountName);
return inboxStyle;
}
private Spannable getContactNameAndMessage(MessageNotification messageNotification, boolean showText) {
String userName = getContactName(messageNotification);
Spannable spannableString;
if (showText) {
String contactAndMessage = application.getString(
R.string.chat_contact_and_message, userName, messageNotification.getText());
spannableString = new SpannableString(contactAndMessage);
} else {
spannableString = new SpannableString(userName);
}
spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, userName.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannableString;
}
private PendingIntent getIntent(MessageNotification message) {
Intent chatIntent
= ChatViewer.createClearTopIntent(application, message.getAccount(), message.getUser());
return PendingIntent.getActivity(application, 0, chatIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}
private void addEffects(MessageItem messageItem) {
if (messageItem == null) {
return;
}
if (messageItem.getChat().getFirstNotification() || !SettingsManager.eventsFirstOnly()) {
Uri sound = PhraseManager.getInstance().getSound(messageItem.getChat().getAccount(),
messageItem.getChat().getUser(), messageItem.getText());
boolean makeVibration = ChatManager.getInstance().isMakeVibro(messageItem.getChat().getAccount(),
messageItem.getChat().getUser());
NotificationManager.getInstance().setNotificationDefaults(notificationBuilder,
makeVibration, sound, AudioManager.STREAM_NOTIFICATION);
}
}
}
...@@ -14,20 +14,6 @@ ...@@ -14,20 +14,6 @@
*/ */
package com.xabber.android.data.roster; package com.xabber.android.data.roster;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import org.jivesoftware.smack.util.StringUtils;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
import com.xabber.android.data.OnLoadListener; import com.xabber.android.data.OnLoadListener;
...@@ -46,6 +32,20 @@ import com.xabber.android.data.notification.NotificationManager; ...@@ -46,6 +32,20 @@ import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import org.jivesoftware.smack.util.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
/** /**
* Process contact's presence information. * Process contact's presence information.
* *
...@@ -86,7 +86,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener, ...@@ -86,7 +86,7 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
private PresenceManager() { private PresenceManager() {
subscriptionRequestProvider = new EntityNotificationProvider<SubscriptionRequest>( subscriptionRequestProvider = new EntityNotificationProvider<SubscriptionRequest>(
R.drawable.ic_stat_subscribe); R.drawable.ic_stat_ic_add_circle);
requestedSubscriptions = new HashMap<String, HashSet<String>>(); requestedSubscriptions = new HashMap<String, HashSet<String>>();
presenceContainers = new NestedMap<ResourceContainer>(); presenceContainers = new NestedMap<ResourceContainer>();
readyAccounts = new ArrayList<String>(); readyAccounts = new ArrayList<String>();
......
...@@ -61,6 +61,8 @@ public class OccupantList extends ManagedListActivity implements ...@@ -61,6 +61,8 @@ public class OccupantList extends ManagedListActivity implements
setContentView(R.layout.list); setContentView(R.layout.list);
listAdapter = new OccupantListAdapter(this, account, room); listAdapter = new OccupantListAdapter(this, account, room);
setListAdapter(listAdapter); setListAdapter(listAdapter);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="@dimen/notification_large_icon_width"
android:layout_height="@dimen/notification_large_icon_height"
android:background="@drawable/notify_panel_notification_icon_bg_tile"
android:gravity="center"
>
<ImageView
android:id="@+id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:src="@drawable/avatar_1_1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:paddingLeft="12dp"
android:paddingRight="12dp"
>
<LinearLayout
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView android:id="@+id/title"
android:textAppearance="@style/NotificationTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:layout_weight="1"
/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:singleLine="true"
android:gravity="center"
android:paddingLeft="8dp"
android:text="22:11:00"
android:textAppearance="@style/NotificationText"
/>
</LinearLayout>
<TextView android:id="@+id/text2"
android:textAppearance="@style/NotificationText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-2dp"
android:layout_marginBottom="-2dp"
android:singleLine="true"
android:fadingEdge="horizontal"
android:ellipsize="marquee"
/>
<LinearLayout
android:id="@+id/line3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView android:id="@+id/text"
android:textAppearance="@style/NotificationText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp">
<ImageView
android:id="@+id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_marginRight="6dip"
android:layout_centerVertical="true"
android:src="@drawable/avatar_1_1"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:singleLine="true"
android:gravity="bottom"
android:layout_toRightOf="@id/icon"
android:text="name"
style="@style/NotificationTitle"
/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
android:layout_toRightOf="@id/icon"
android:layout_below="@id/title"
android:layout_marginRight="10dip"
android:text="22:11:00"
style="@style/NotificationText"
/>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:layout_below="@id/title"
android:layout_toRightOf="@id/time"
android:ellipsize="marquee"
android:text="text text text text text text text text text text text"
style="@style/NotificationText"
/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:layout_below="@id/time"
android:layout_toRightOf="@id/icon"
android:text="1 message from 1 contact"
style="@style/NotificationText"
/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"> <resources>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
<string name="account_quantity_1">учетной записи</string> <string name="account_quantity_1">учетной записи</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
<string name="chat_message_quantity_5">сообщений</string> <string name="chat_message_quantity_5">сообщений</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_message.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_message.png -->
<string name="chat_status">%1$d %2$s от %3$d %4$s</string> <string name="chat_status">%1$d %2$s от %3$d %4$s</string>
<string name="chat_messages_from_contact">%1$d %2$s от %3$s</string>
<string name="chat_contact_and_message">%1$s: %2$s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
<string name="connection_state_connected_1">%1$d из %2$d %3$s подключена </string> <string name="connection_state_connected_1">%1$d из %2$d %3$s подключена </string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"> <resources>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
<string name="account_quantity_1">account</string> <string name="account_quantity_1">account</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
...@@ -28,6 +28,10 @@ ...@@ -28,6 +28,10 @@
<string name="chat_message_quantity_5">-</string> <string name="chat_message_quantity_5">-</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_message.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_message.png -->
<string name="chat_status">%1$d %2$s from %3$d %4$s</string> <string name="chat_status">%1$d %2$s from %3$d %4$s</string>
<string name="chat_messages_from_contact">%1$d %2$s from %3$s</string>
<string name="chat_contact_and_message">%1$s: %2$s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
<string name="connection_state_connected_1">%1$d of %2$d %3$s online</string> <string name="connection_state_connected_1">%1$d of %2$d %3$s online</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/notification_bar_connected.png -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment