Skip to content
Snippets Groups Projects
Commit 74f6cc94 authored by Loïc Siret's avatar Loïc Siret
Browse files

androidtv: rework Card Styles

This patches remove duplicate information on cards. if the title and
description are the same, we display one one line card.

Change-Id: I5794710a34010275edb25c053d8a3595dc1993b4
parent c689c346
No related branches found
No related tags found
No related merge requests found
...@@ -125,6 +125,8 @@ public class Card { ...@@ -125,6 +125,8 @@ public class Card {
SEARCH_RESULT, SEARCH_RESULT,
CONTRIBUTOR, CONTRIBUTOR,
LICENCES, LICENCES,
CONTACT,
CONTACT_WITH_USERNAME,
} }
} }
\ No newline at end of file
...@@ -52,7 +52,13 @@ public class CardPresenterSelector extends PresenterSelector { ...@@ -52,7 +52,13 @@ public class CardPresenterSelector extends PresenterSelector {
presenter = new AboutCardPresenter(mContext); presenter = new AboutCardPresenter(mContext);
break; break;
case SEARCH_RESULT: case SEARCH_RESULT:
presenter = new ContactCardPresenter(mContext,R.style.SearchtCardTheme); presenter = new ContactCardPresenter(mContext,R.style.SearchCardTheme);
break;
case CONTACT:
presenter = new ContactCardPresenter(mContext,R.style.ContactCardTheme);
break;
case CONTACT_WITH_USERNAME:
presenter = new ContactCardPresenter(mContext,R.style.ContactCompleteCardTheme);
break; break;
default: default:
presenter = new ContactCardPresenter(mContext, R.style.DefaultCardTheme); presenter = new ContactCardPresenter(mContext, R.style.DefaultCardTheme);
......
...@@ -25,6 +25,7 @@ import cx.ring.tv.cards.Card; ...@@ -25,6 +25,7 @@ import cx.ring.tv.cards.Card;
public class ContactCard extends Card { public class ContactCard extends Card {
CallContact mCallContact = null; CallContact mCallContact = null;
private byte[] mPhoto = null; private byte[] mPhoto = null;
public ContactCard(CallContact pCallContact, Type type) { public ContactCard(CallContact pCallContact, Type type) {
mCallContact = pCallContact; mCallContact = pCallContact;
setId(pCallContact.getId()); setId(pCallContact.getId());
...@@ -37,7 +38,18 @@ public class ContactCard extends Card { ...@@ -37,7 +38,18 @@ public class ContactCard extends Card {
} }
public ContactCard(CallContact pCallContact) { public ContactCard(CallContact pCallContact) {
this(pCallContact, Type.DEFAULT); mCallContact = pCallContact;
setId(pCallContact.getId());
setTitle(pCallContact.getDisplayName());
setDescription(pCallContact.getRingUsername());
if (pCallContact.getPhoto() != null) {
mPhoto = pCallContact.getPhoto();
}
if (pCallContact.getDisplayName().equals(pCallContact.getRingUsername())) {
setType(Type.CONTACT);
} else {
setType(Type.CONTACT_WITH_USERNAME);
}
} }
public CallContact getCallContact() { public CallContact getCallContact() {
......
...@@ -92,10 +92,9 @@ public class MainPresenter extends RootPresenter<MainView> implements Observer<S ...@@ -92,10 +92,9 @@ public class MainPresenter extends RootPresenter<MainView> implements Observer<S
switch (event.getEventType()) { switch (event.getEventType()) {
case CONVERSATIONS_CHANGED: case CONVERSATIONS_CHANGED:
reloadConversations();
break;
case ACCOUNTS_CHANGED: case ACCOUNTS_CHANGED:
case NAME_REGISTRATION_ENDED: case NAME_REGISTRATION_ENDED:
reloadConversations();
reloadAccountInfos(); reloadAccountInfos();
break; break;
} }
......
...@@ -128,6 +128,14 @@ ...@@ -128,6 +128,14 @@
<item name="lbImageCardViewType">Title</item> <item name="lbImageCardViewType">Title</item>
</style> </style>
<style name="ContactTitleViewStyle" parent="DefaultCardStyle">
<item name="lbImageCardViewType">Title</item>
</style>
<style name="ContactCompleteCardViewStyle" parent="DefaultCardStyle">
<item name="lbImageCardViewType">Title|Content</item>
</style>
<style name="IconCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle"> <style name="IconCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">96dp</item> <item name="android:layout_width">96dp</item>
<item name="android:layout_height">96dp</item> <item name="android:layout_height">96dp</item>
...@@ -147,8 +155,8 @@ ...@@ -147,8 +155,8 @@
<item name="layout_viewType">main</item> <item name="layout_viewType">main</item>
</style> </style>
<!-- A Searcht card style. Used in cards example. --> <!-- A Search card style. Used in cards example. -->
<style name="SearchtCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle"> <style name="SearchCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/search_image_card_width</item> <item name="android:layout_width">@dimen/search_image_card_width</item>
<item name="android:layout_height">@dimen/search_image_card_height</item> <item name="android:layout_height">@dimen/search_image_card_height</item>
</style> </style>
...@@ -157,11 +165,18 @@ ...@@ -157,11 +165,18 @@
<item name="cardBackground">@null</item> <item name="cardBackground">@null</item>
<item name="android:layout_width">96dp</item> <item name="android:layout_width">96dp</item>
<item name="android:layout_height">96dp</item> <item name="android:layout_height">96dp</item>
<item name="lbImageCardViewType">Title</item>
</style> </style>
<style name="SearchtCardTheme" parent="Theme.Leanback"> <style name="ContactCardTheme" parent="DefaultCardTheme">
<item name="imageCardViewStyle">@style/ContactTitleViewStyle</item>
</style>
<style name="ContactCompleteCardTheme" parent="DefaultCardTheme">
<item name="imageCardViewStyle">@style/ContactCompleteCardViewStyle</item>
</style>
<style name="SearchCardTheme" parent="Theme.Leanback">
<item name="imageCardViewStyle">@style/SearchCardStyle</item> <item name="imageCardViewStyle">@style/SearchCardStyle</item>
<item name="imageCardViewImageStyle">@style/SearchtCardImageStyle</item> <item name="imageCardViewImageStyle">@style/SearchCardImageStyle</item>
</style> </style>
<!-- Theme corresponding to the IconCardStyle --> <!-- Theme corresponding to the IconCardStyle -->
<style name="IconCardTheme" parent="Theme.Leanback"> <style name="IconCardTheme" parent="Theme.Leanback">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment