Display note on separate line, omit card id on card list

The card id was of dubious value, because the main screen
is really for selecting the card. The note may have more value,
as it may specify info about the card.
This commit is contained in:
Branden Archer committed 2018-01-31 22:49:31 -05:00
1 parent 41c8b78275
commit 2f6516ffb9
4 files changed
+25 -29

No files matched your search

@@ -32,25 +32,23 @@ class LoyaltyCardCursorAdapter extends CursorAdapter
// Find fields to populate in inflated template
ImageView thumbnail = view.findViewById(R.id.thumbnail);
TextView storeField = (TextView) view.findViewById(R.id.store);
TextView cardIdField = (TextView) view.findViewById(R.id.cardId);
TextView noteField = (TextView) view.findViewById(R.id.note);
// Extract properties from cursor
LoyaltyCard loyaltyCard = LoyaltyCard.toLoyaltyCard(cursor);
// Populate fields with extracted properties
String storeAndNote = loyaltyCard.store;
storeField.setText(loyaltyCard.store);
if(loyaltyCard.note.isEmpty() == false)
{
String storeNameAndNoteFormat = view.getResources().getString(R.string.storeNameAndNoteFormat);
storeAndNote = String.format(storeNameAndNoteFormat, loyaltyCard.store, loyaltyCard.note);
noteField.setVisibility(View.VISIBLE);
noteField.setText(loyaltyCard.note);
}
else
{
noteField.setVisibility(View.GONE);
}
storeField.setText(storeAndNote);
String cardIdFormat = view.getResources().getString(R.string.cardIdFormat);
String cardIdLabel = view.getResources().getString(R.string.cardId);
String cardIdText = String.format(cardIdFormat, cardIdLabel, loyaltyCard.cardId);
cardIdField.setText(cardIdText);
int tileLetterFontSize = context.getResources().getDimensionPixelSize(R.dimen.tileLetterFontSize);
int pixelSize = context.getResources().getDimensionPixelSize(R.dimen.cardThumbnailSize);
@@ -45,12 +45,12 @@
</LinearLayout>
<TextView
android:id="@+id/cardId"
android:id="@+id/note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textSize="18sp"/>
android:textSize="@dimen/noteTextSize"/>
</LinearLayout>
</LinearLayout>
+1
View File
@@ -12,6 +12,7 @@
<dimen name="text_size_large">22sp</dimen>
<dimen name="storeNameTextSize">28sp</dimen>
<dimen name="noteTextSize">14sp</dimen>
<dimen name="inputBorderThickness">2dip</dimen>
<dimen name="inputBorderDividerThickness">4dip</dimen>
@@ -40,13 +40,21 @@ public class LoyaltyCardCursorAdapterTest
return view;
}
private void checkView(final View view, final String store, final String cardId)
private void checkView(final View view, final String store, final String note)
{
final TextView storeField = (TextView) view.findViewById(R.id.store);
assertEquals(store, storeField.getText().toString());
final TextView cardIdField = (TextView) view.findViewById(R.id.cardId);
assertEquals(cardId, cardIdField.getText().toString());
final TextView noteField = view.findViewById(R.id.note);
if(note.isEmpty() == false)
{
assertEquals(View.VISIBLE, noteField.getVisibility());
assertEquals(note, noteField.getText().toString());
}
else
{
assertEquals(View.GONE, noteField.getVisibility());
}
}
@@ -61,11 +69,7 @@ public class LoyaltyCardCursorAdapterTest
View view = createView(cursor);
final String cardIdLabel = activity.getResources().getString(R.string.cardId);
final String cardIdFormat = activity.getResources().getString(R.string.cardIdFormat);
String cardIdText = String.format(cardIdFormat, cardIdLabel, card.cardId);
checkView(view, card.store, cardIdText);
checkView(view, card.store, card.note);
}
@Test
@@ -79,13 +83,6 @@ public class LoyaltyCardCursorAdapterTest
View view = createView(cursor);
final String storeNameAndNoteFormat = activity.getResources().getString(R.string.storeNameAndNoteFormat);
String storeAndNoteText = String.format(storeNameAndNoteFormat, card.store, card.note);
final String cardIdLabel = activity.getResources().getString(R.string.cardId);
final String cardIdFormat = activity.getResources().getString(R.string.cardIdFormat);
String cardIdText = String.format(cardIdFormat, cardIdLabel, card.cardId);
checkView(view, storeAndNoteText, cardIdText);
checkView(view, card.store, card.note);
}
}