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 {
SEARCH_RESULT,
CONTRIBUTOR,
LICENCES,
CONTACT,
CONTACT_WITH_USERNAME,
}
}
\ No newline at end of file
......@@ -52,7 +52,13 @@ public class CardPresenterSelector extends PresenterSelector {
presenter = new AboutCardPresenter(mContext);
break;
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;
default:
presenter = new ContactCardPresenter(mContext, R.style.DefaultCardTheme);
......
......@@ -25,6 +25,7 @@ import cx.ring.tv.cards.Card;
public class ContactCard extends Card {
CallContact mCallContact = null;
private byte[] mPhoto = null;
public ContactCard(CallContact pCallContact, Type type) {
mCallContact = pCallContact;
setId(pCallContact.getId());
......@@ -37,7 +38,18 @@ public class ContactCard extends Card {
}
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() {
......
......@@ -92,10 +92,9 @@ public class MainPresenter extends RootPresenter<MainView> implements Observer<S
switch (event.getEventType()) {
case CONVERSATIONS_CHANGED:
reloadConversations();
break;
case ACCOUNTS_CHANGED:
case NAME_REGISTRATION_ENDED:
reloadConversations();
reloadAccountInfos();
break;
}
......
......@@ -128,6 +128,14 @@
<item name="lbImageCardViewType">Title</item>
</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">
<item name="android:layout_width">96dp</item>
<item name="android:layout_height">96dp</item>
......@@ -147,8 +155,8 @@
<item name="layout_viewType">main</item>
</style>
<!-- A Searcht card style. Used in cards example. -->
<style name="SearchtCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<!-- A Search card style. Used in cards example. -->
<style name="SearchCardImageStyle" parent="Widget.Leanback.ImageCardView.ImageStyle">
<item name="android:layout_width">@dimen/search_image_card_width</item>
<item name="android:layout_height">@dimen/search_image_card_height</item>
</style>
......@@ -157,11 +165,18 @@
<item name="cardBackground">@null</item>
<item name="android:layout_width">96dp</item>
<item name="android:layout_height">96dp</item>
<item name="lbImageCardViewType">Title</item>
</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="imageCardViewImageStyle">@style/SearchtCardImageStyle</item>
<item name="imageCardViewImageStyle">@style/SearchCardImageStyle</item>
</style>
<!-- Theme corresponding to the IconCardStyle -->
<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