Set default room icon based on user-count
If a room doesn't have a set icon (and it isn't a one-on-one chat, for which the icon'll come from the other user's avatar), the default icon is now determined based on user count. If there's X users, an icon with X people will be displayed, up to four. After that, a "+" is overlayed on the icon. Not really necessary… but I think it's cute. :-)
This commit is contained in:
parent
9309562cfb
commit
8855464d02
|
@ -25,7 +25,11 @@ enum {
|
|||
kReplicantMessageReceived = 1402,
|
||||
|
||||
kPersonIcon = 1500,
|
||||
kChatIcon = 1501
|
||||
kOnePersonIcon = 1501,
|
||||
kTwoPeopleIcon = 1502,
|
||||
kThreePeopleIcon = 1503,
|
||||
kFourPeopleIcon = 1504,
|
||||
kMorePeopleIcon = 1505
|
||||
};
|
||||
|
||||
#endif // _APP_RESOURCES_H
|
||||
|
|
|
@ -37,7 +37,7 @@ Conversation::Conversation(BString id, BMessenger msgn)
|
|||
fMessenger(msgn),
|
||||
fChatView(NULL),
|
||||
fLooper(NULL),
|
||||
fIcon(ImageCache::Get()->GetImage("kChatIcon")),
|
||||
fIcon(ImageCache::Get()->GetImage("kOnePersonIcon")),
|
||||
fDateFormatter(),
|
||||
fRoomFlags(0),
|
||||
fDisallowedFlags(0),
|
||||
|
@ -431,6 +431,7 @@ Conversation::RemoveUser(User* user)
|
|||
user->UnregisterObserver(this);
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
_SortConversationList();
|
||||
_UpdateIcon();
|
||||
}
|
||||
|
||||
|
||||
|
@ -589,8 +590,7 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
fUsers.AddItem(id, serverUser);
|
||||
user = serverUser;
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
|
||||
_AdoptUserIcon(user);
|
||||
_UpdateIcon(user);
|
||||
}
|
||||
// Not anywhere; create user
|
||||
else if (user == NULL) {
|
||||
|
@ -600,8 +600,7 @@ Conversation::_EnsureUser(BMessage* msg)
|
|||
fLooper->AddUser(user);
|
||||
fUsers.AddItem(id, user);
|
||||
GetView()->UpdateUserList(fUsers);
|
||||
|
||||
_AdoptUserIcon(user);
|
||||
_UpdateIcon(user);
|
||||
}
|
||||
|
||||
if (name.IsEmpty() == false) {
|
||||
|
@ -631,19 +630,52 @@ Conversation::_GetRole(BMessage* msg)
|
|||
|
||||
|
||||
void
|
||||
Conversation::_AdoptUserIcon(User* user)
|
||||
Conversation::_UpdateIcon(User* user)
|
||||
{
|
||||
// If it's a one-on-one chat without custom icon, steal a user's
|
||||
if ((fUsers.CountItems() <= 2 && user->GetId() != GetOwnContact()->GetId())
|
||||
&& (fIcon == ImageCache::Get()->GetImage("kChatIcon")
|
||||
|| fIcon == NULL))
|
||||
fUserIcon = SetIconBitmap(user->AvatarBitmap());
|
||||
if (_IsDefaultIcon(fIcon) == false && fUserIcon == false)
|
||||
return;
|
||||
|
||||
// If it's no longer one-on-one, revert
|
||||
if (fUsers.CountItems() > 2 && fUserIcon == true) {
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kChatIcon"));
|
||||
// If it's a one-on-one chat, try to use the other user's icon
|
||||
if (user != NULL && fUsers.CountItems() == 2
|
||||
&& user->GetId() != GetOwnContact()->GetId()
|
||||
&& _IsDefaultIcon(user->AvatarBitmap()) == false) {
|
||||
fUserIcon = SetIconBitmap(user->AvatarBitmap());
|
||||
return;
|
||||
}
|
||||
|
||||
switch (fUsers.CountItems())
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kOnePersonIcon"));
|
||||
break;
|
||||
case 2:
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kTwoPeopleIcon"));
|
||||
break;
|
||||
case 3:
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kThreePeopleIcon"));
|
||||
break;
|
||||
case 4:
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kFourPeopleIcon"));
|
||||
break;
|
||||
default:
|
||||
SetIconBitmap(ImageCache::Get()->GetImage("kMorePeopleIcon"));
|
||||
break;
|
||||
}
|
||||
fUserIcon = false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Conversation::_IsDefaultIcon(BBitmap* icon)
|
||||
{
|
||||
return (icon == NULL
|
||||
|| icon == ImageCache::Get()->GetImage("kPersonIcon")
|
||||
|| icon == ImageCache::Get()->GetImage("kOnePersonIcon")
|
||||
|| icon == ImageCache::Get()->GetImage("kTwoPeopleIcon")
|
||||
|| icon == ImageCache::Get()->GetImage("kThreePeopleIcon")
|
||||
|| icon == ImageCache::Get()->GetImage("kFourPeopleIcon")
|
||||
|| icon == ImageCache::Get()->GetImage("kMorePeopleIcon"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ private:
|
|||
User* _EnsureUser(BMessage* msg);
|
||||
Role* _GetRole(BMessage* msg);
|
||||
|
||||
void _AdoptUserIcon(User* user);
|
||||
void _UpdateIcon(User* user = NULL);
|
||||
bool _IsDefaultIcon(BBitmap* icon);
|
||||
|
||||
void _SortConversationList();
|
||||
|
||||
|
|
|
@ -27,7 +27,11 @@ ImageCache* ImageCache::fInstance = NULL;
|
|||
ImageCache::ImageCache()
|
||||
{
|
||||
_LoadResource(kPersonIcon, "kPersonIcon");
|
||||
_LoadResource(kChatIcon, "kChatIcon");
|
||||
_LoadResource(kOnePersonIcon, "kOnePersonIcon");
|
||||
_LoadResource(kTwoPeopleIcon, "kTwoPeopleIcon");
|
||||
_LoadResource(kThreePeopleIcon, "kThreePeopleIcon");
|
||||
_LoadResource(kFourPeopleIcon, "kFourPeopleIcon");
|
||||
_LoadResource(kMorePeopleIcon, "kMorePeopleIcon");
|
||||
|
||||
_LoadResource(kAwayReplicant, "kAwayReplicant");
|
||||
_LoadResource(kBusyReplicant, "kBusyReplicant");
|
||||
|
|
|
@ -100,7 +100,11 @@ RDEFS = Cardie.rdef \
|
|||
data/icons/replicant/MessageReceived.rdef \
|
||||
data/icons/replicant/Offline.rdef \
|
||||
data/icons/replicant/Online.rdef \
|
||||
data/icons/misc/Chat.rdef \
|
||||
data/icons/misc/People-1.rdef \
|
||||
data/icons/misc/People-2.rdef \
|
||||
data/icons/misc/People-3.rdef \
|
||||
data/icons/misc/People-4.rdef \
|
||||
data/icons/misc/People-4+.rdef \
|
||||
data/icons/misc/Person.rdef \
|
||||
data/icons/misc/Search.rdef \
|
||||
data/icons/misc/Tool.rdef
|
||||
|
|
Binary file not shown.
|
@ -1,9 +0,0 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kChatIcon) #'VICN' array {
|
||||
$"6E63696604052803010100020106023E80000000000000003D800048C0004940"
|
||||
$"0000F8E278FFFAECA9020106023E80000000000000003D800048000049000000"
|
||||
$"FFFFFFFFF3E6AA010606BF0F3C30C36F30B8E030244024BC3A24C3453C50B8E0"
|
||||
$"503C584858C160C5C14458C512C4DF544054C28454BC3A040A00010030282401"
|
||||
$"158802040A0201002028240A01010030201401158802040A030100202014"
|
||||
};
|
Binary file not shown.
|
@ -0,0 +1,27 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kOnePersonIcon) #'VICN' array {
|
||||
$"6E636966120500020006023CADF43D104EBF02CA3EA2224BB02046648D00FFDB"
|
||||
$"97FFFCAF29020006023CADF43D104EBF02CA3EA2224BB02046648D00D5DCFFFF"
|
||||
$"9D9BD5020006023B804A3C0065BF02CA3EA2224BE70846C45D00EE9BB0FFCC58"
|
||||
$"76020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFF7EAFEFDD17B02"
|
||||
$"0006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFFFFFFEA4A3D7020006"
|
||||
$"023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFE3EAFEF0A8BB020006023A"
|
||||
$"B3673751B2BC59783FD2D74AF3F147385900C85805FFF06306020006023AB367"
|
||||
$"3751B2BC59783FD2D74B03F147385900373583FF6967C0020006023AB3673751"
|
||||
$"B2BC59783FD2D74B13F147785900A02646FFD53961020106033ABB7400000000"
|
||||
$"00003AB5E049D1B1471E5B00F2F2F2AB7D7A7AFFBCA18404016C03A329040325"
|
||||
$"23820371152D02000602388A280000000000004000004A3000C2000000C85804"
|
||||
$"FFDC952F02000602388A280000000000004000004A4000C200000033318CFFA4"
|
||||
$"A3D702000602388A280000000000004000004A4000C3000000AB123AFFDD718D"
|
||||
$"0A0A0D36353646384838593C5B3E5B3E5C425E4858484A4A484A373D310A0B36"
|
||||
$"353645384838593C5B3E5B3E5C425E424D444D443B0A063635443B4A374036C1"
|
||||
$"57BAF73D310A08444D424D425E4858484A4A484A37443B0204402843283D283A"
|
||||
$"2E3A2B3A3140343D344334462E4631462B02043F2AC0592ABE5B2A3A2F3AB7FB"
|
||||
$"3AB9F93F34BE5B34C05934442F44B9F944B7FB0607FE1B3A5F445F3F5F495FC7"
|
||||
$"38CAF4C569CAE4CB5ACB1BCA0FC8AACC99C976C888C82F4E5552574C54425458"
|
||||
$"0A04424D4253484A444D0A0340364A3744340A043C5B3E5B3E4D3C4C0A0A0B01"
|
||||
$"06023FDBA60000000000003FC3C34069E943C3C30A0001001001178400040A02"
|
||||
$"0101000A050102000A080103000A0D0107000A100108000A0001041001178400"
|
||||
$"040A0A0104000A0801090815FF"
|
||||
};
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kTwoPeopleIcon) #'VICN' array {
|
||||
$"6E6369660D0500020006023CADF43D104EBF02CA3EA2224BB02046648D00FFDB"
|
||||
$"97FFFCAF29020006023CADF43D104EBF02CA3EA2224BB02046648D00D5DCFFFF"
|
||||
$"9D9BD5020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFF7EAFEFDD1"
|
||||
$"7B020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFFFFFFEA4A3D702"
|
||||
$"0006023AB3673751B2BC59783FD2D74AF3F147385900C85805FFF06306020006"
|
||||
$"023AB3673751B2BC59783FD2D74B03F147385900373583FF6967C0020106033A"
|
||||
$"BB740000000000003AB5E049D1B1471E5B00F2F2F2AB7D7A7AFFBCA18404016C"
|
||||
$"03A329040325238202000602388A280000000000004000004A3000C2000000C8"
|
||||
$"5804FFDC952F02000602388A280000000000004000004A4000C200000033318C"
|
||||
$"FFA4A3D70A0A0D36353646384838593C5B3E5B3E5C425E4858484A4A484A373D"
|
||||
$"310A0B36353645384838593C5B3E5B3E5C425E424D444D443B0A063635443B4A"
|
||||
$"374036C157BAF73D310A08444D424D425E4858484A4A484A37443B0204402843"
|
||||
$"283D283A2E3A2B3A3140343D344334462E4631462B02043F2AC0592ABE5B2A3A"
|
||||
$"2F3AB7FB3AB9F93F34BE5B34C05934442F44B9F944B7FB0607FE2B42604D6048"
|
||||
$"605260585E535FCC70CB135C585F5AC98AC8665D53CBEDC8915C51544F3C4E0A"
|
||||
$"04424D4253484A444D0A0340364A3744340A043C5B3E5B3E4D3C4C130A080106"
|
||||
$"000A00010030101A01178400040A01010120101A0A03010220101A0A05010320"
|
||||
$"101A0A09010720101A0A0B010820101A0A00010530101A01178400040A070105"
|
||||
$"20101A0A05010928101A15FF0A0001001001178400040A020101000A04010200"
|
||||
$"0A060103000A0A0107000A0C0108000A0001041001178400040A070104000A06"
|
||||
$"01090815FF"
|
||||
};
|
Binary file not shown.
|
@ -0,0 +1,31 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kThreePeopleIcon) #'VICN' array {
|
||||
$"6E636966120500020006023CADF43D104EBF02CA3EA2224BB02046648D00FFDB"
|
||||
$"97FFFCAF29020006023CADF43D104EBF02CA3EA2224BB02046648D00D5DCFFFF"
|
||||
$"9D9BD5020006023B804A3C0065BF02CA3EA2224BE70846C45D00EE9BB0FFCC58"
|
||||
$"76020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFF7EAFEFDD17B02"
|
||||
$"0006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFFFFFFEA4A3D7020006"
|
||||
$"023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFE3EAFEF0A8BB020006023A"
|
||||
$"B3673751B2BC59783FD2D74AF3F147385900C85805FFF06306020006023AB367"
|
||||
$"3751B2BC59783FD2D74B03F147385900373583FF6967C0020006023AB3673751"
|
||||
$"B2BC59783FD2D74B13F147785900A02646FFD53961020106033ABB7400000000"
|
||||
$"00003AB5E049D1B1471E5B00F2F2F2AB7D7A7AFFBCA18404016C03A329040325"
|
||||
$"23820371152D02000602388A280000000000004000004A3000C2000000C85804"
|
||||
$"FFDC952F02000602388A280000000000004000004A4000C200000033318CFFA4"
|
||||
$"A3D702000602388A280000000000004000004A4000C3000000AB123AFFDD718D"
|
||||
$"0A0A0D36353646384838593C5B3E5B3E5C425E4858484A4A484A373D310A0B36"
|
||||
$"353645384838593C5B3E5B3E5C425E424D444D443B0A063635443B4A374036C1"
|
||||
$"57BAF73D310A08444D424D425E4858484A4A484A37443B0204402843283D283A"
|
||||
$"2E3A2B3A3140343D344334462E4631462B02043F2AC0592ABE5B2A3A2F3AB7FB"
|
||||
$"3AB9F93F34BE5B34C05934442F44B9F944B7FB0607FE2B42604D604860526058"
|
||||
$"5E535FCC70CB135C585F5AC98AC8665D53CBEDC8915C51544F4A580A04424D42"
|
||||
$"53484A444D0A0340364A3744340A043C5B3E5B3E4D3C4C1B0A0B0106000A0001"
|
||||
$"00302A1A01178400040A030101202A1A0A060102202A1A0A090103202A1A0A0E"
|
||||
$"0107202A1A0A110108202A1A0A000105302C1A01178400040A0A0105202C1A0A"
|
||||
$"00010030101A01178400040A01010120101A0A04010220101A0A07010320101A"
|
||||
$"0A0C010720101A0A0F010820101A0A00010530101A01178400040A0A01052010"
|
||||
$"1A0A07010928101A15FF0A0001001001178400040A020101000A050102000A08"
|
||||
$"0103000A0D0107000A100108000A0001041001178400040A0A0104000A080109"
|
||||
$"0815FF"
|
||||
};
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,36 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kMorePeopleIcon) #'VICN' array {
|
||||
$"6E636966150500020006023CADF43D104EBF02CA3EA2224BB02046648D00FFDB"
|
||||
$"97FFFCAF29020006023CADF43D104EBF02CA3EA2224BB02046648D00D5DCFFFF"
|
||||
$"9D9BD5020006023B804A3C0065BF02CA3EA2224BE70846C45D00EE9BB0FFCC58"
|
||||
$"76020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFF7EAFEFDD17B02"
|
||||
$"0006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFFFFFFEA4A3D7020006"
|
||||
$"023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFE3EAFEF0A8BB020006023A"
|
||||
$"B3673751B2BC59783FD2D74AF3F147385900C85805FFF06306020006023AB367"
|
||||
$"3751B2BC59783FD2D74B03F147385900373583FF6967C0020006023AB3673751"
|
||||
$"B2BC59783FD2D74B13F147785900A02646FFD53961020106033ABB7400000000"
|
||||
$"00003AB5E049D1B1471E5B00F2F2F2AB7D7A7AFFBCA18404016C03A329040325"
|
||||
$"23820371152D02000602388A280000000000004000004A3000C2000000C85804"
|
||||
$"FFDC952F02000602388A280000000000004000004A4000C200000033318CFFA4"
|
||||
$"A3D702000602388A280000000000004000004A4000C3000000AB123AFFDD718D"
|
||||
$"0400660501020006020000003C6000C000000000004C000048A0000000AAFFFC"
|
||||
$"00FFAA0B0A0D36353646384838593C5B3E5B3E5C425E4858484A4A484A373D31"
|
||||
$"0A0B36353645384838593C5B3E5B3E5C425E424D444D443B0A063635443B4A37"
|
||||
$"4036C157BAF73D310A08444D424D425E4858484A4A484A37443B020440284328"
|
||||
$"3D283A2E3A2B3A3140343D344334462E4631462B02043F2AC0592ABE5B2A3A2F"
|
||||
$"3AB7FB3AB9F93F34BE5B34C05934442F44B9F944B7FB0607FE2B42604D604860"
|
||||
$"5260585E535FCC70CB135C585F5AC98AC8665D53CBEDC8915C51544F4A580A04"
|
||||
$"424D4253484A444D0A0340364A3744340A043C5B3E5B3E4D3C4C0A0C3A223022"
|
||||
$"30302230223A303A30483A483A3A483A48303A30220A0B0106000A0501022019"
|
||||
$"170A1101082019170A000105301B1701178400040A0A0105201B170A00010030"
|
||||
$"2A1A01178400040A030101202A1A0A060102202A1A0A090103202A1A0A0E0107"
|
||||
$"202A1A0A110108202A1A0A000105302C1A01178400040A0A0105202C1A0A0001"
|
||||
$"0030101A01178400040A01010120101A0A04010220101A0A07010320101A0A0C"
|
||||
$"010720101A0A0F010820101A0A00010530101A01178400040A0A010520101A0A"
|
||||
$"07010928101A15FF0A0001001001178400040A020101000A050102000A080103"
|
||||
$"000A0D0107000A100108000A0001041001178400040A0A0104000A0801090815"
|
||||
$"FF0A12010A123E00000000000000003DD1744A70004A8F4501178322040A1301"
|
||||
$"0A123E00000000000000003DD1744A60004A800001178322040A14010A023E00"
|
||||
$"000000000000003DD1744A60004A8000"
|
||||
};
|
|
@ -0,0 +1,32 @@
|
|||
#include "application/AppResources.h"
|
||||
|
||||
resource(kFourPeopleIcon) #'VICN' array {
|
||||
$"6E636966120500020006023CADF43D104EBF02CA3EA2224BB02046648D00FFDB"
|
||||
$"97FFFCAF29020006023CADF43D104EBF02CA3EA2224BB02046648D00D5DCFFFF"
|
||||
$"9D9BD5020006023B804A3C0065BF02CA3EA2224BE70846C45D00EE9BB0FFCC58"
|
||||
$"76020006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFF7EAFEFDD17B02"
|
||||
$"0006023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFFFFFFEA4A3D7020006"
|
||||
$"023A6496BA3F153EBCDD3EEA9147D96A4458AB00FFE3EAFEF0A8BB020006023A"
|
||||
$"B3673751B2BC59783FD2D74AF3F147385900C85805FFF06306020006023AB367"
|
||||
$"3751B2BC59783FD2D74B03F147385900373583FF6967C0020006023AB3673751"
|
||||
$"B2BC59783FD2D74B13F147785900A02646FFD53961020106033ABB7400000000"
|
||||
$"00003AB5E049D1B1471E5B00F2F2F2AB7D7A7AFFBCA18404016C03A329040325"
|
||||
$"23820371152D02000602388A280000000000004000004A3000C2000000C85804"
|
||||
$"FFDC952F02000602388A280000000000004000004A4000C200000033318CFFA4"
|
||||
$"A3D702000602388A280000000000004000004A4000C3000000AB123AFFDD718D"
|
||||
$"0A0A0D36353646384838593C5B3E5B3E5C425E4858484A4A484A373D310A0B36"
|
||||
$"353645384838593C5B3E5B3E5C425E424D444D443B0A063635443B4A374036C1"
|
||||
$"57BAF73D310A08444D424D425E4858484A4A484A37443B0204402843283D283A"
|
||||
$"2E3A2B3A3140343D344334462E4631462B02043F2AC0592ABE5B2A3A2F3AB7FB"
|
||||
$"3AB9F93F34BE5B34C05934442F44B9F944B7FB0607FE2B42604D604860526058"
|
||||
$"5E535FCC70CB135C585F5AC98AC8665D53CBEDC8915C51544F4A580A04424D42"
|
||||
$"53484A444D0A0340364A3744340A043C5B3E5B3E4D3C4C1F0A0B0106000A0501"
|
||||
$"022019170A1101082019170A000105301B1701178400040A0A0105201B170A00"
|
||||
$"0100302A1A01178400040A030101202A1A0A060102202A1A0A090103202A1A0A"
|
||||
$"0E0107202A1A0A110108202A1A0A000105302C1A01178400040A0A0105202C1A"
|
||||
$"0A00010030101A01178400040A01010120101A0A04010220101A0A0701032010"
|
||||
$"1A0A0C010720101A0A0F010820101A0A00010530101A01178400040A0A010520"
|
||||
$"101A0A07010928101A15FF0A0001001001178400040A020101000A050102000A"
|
||||
$"080103000A0D0107000A100108000A0001041001178400040A0A0104000A0801"
|
||||
$"090815FF"
|
||||
};
|
Ŝarĝante…
Reference in New Issue