display store and note on card summary view

Dutch translation provided by PanderMusubi

Related issues:
https://github.com/brarcher/loyalty-card-locker/issues/23
https://github.com/brarcher/loyalty-card-locker/issues/24
This commit is contained in:
Branden Archer
2016-04-09 22:11:20 -04:00
parent f6f749de1c
commit e0a77e9628
6 changed files with 35 additions and 3 deletions

View File

@@ -36,7 +36,14 @@ class LoyaltyCardCursorAdapter extends CursorAdapter
LoyaltyCard loyaltyCard = LoyaltyCard.toLoyaltyCard(cursor);
// Populate fields with extracted properties
storeField.setText(loyaltyCard.store);
String storeAndNote = loyaltyCard.store;
if(loyaltyCard.note.isEmpty() == false)
{
String storeNameAndNoteFormat = view.getResources().getString(R.string.storeNameAndNoteFormat);
storeAndNote = String.format(storeNameAndNoteFormat, loyaltyCard.store, loyaltyCard.note);
}
storeField.setText(storeAndNote);
String cardIdFormat = view.getResources().getString(R.string.cardIdFormat);
String cardIdLabel = view.getResources().getString(R.string.cardId);

View File

@@ -13,7 +13,8 @@
android:id="@+id/store"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"/>
android:layout_weight="1.0"
android:maxLines="1"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"

View File

@@ -25,4 +25,5 @@
<string name="noCardIdError">Nessun codice carta inserito</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="note">Nota</string>
</resources>

View File

@@ -25,4 +25,5 @@
<string name="noCardIdError">Geen kaart-ID toegevoegd</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="note">Notitie</string>
</resources>

View File

@@ -26,4 +26,5 @@
<string name="noCardIdError">No Card ID entered</string>
<string name="cardIdFormat">%1$s: %2$s</string>
<string name="storeNameAndNoteFormat" translatable="false">%1$s - %2$s</string>
</resources>

View File

@@ -51,7 +51,7 @@ public class LoyaltyCardCursorAdapterTest
@Test
public void TestCursorAdapter()
public void TestCursorAdapterEmptyNote()
{
db.insertLoyaltyCard("store", "", "cardId", BarcodeFormat.UPC_A.toString());
LoyaltyCard card = db.getLoyaltyCard(1);
@@ -67,4 +67,25 @@ public class LoyaltyCardCursorAdapterTest
checkView(view, card.store, cardIdText);
}
@Test
public void TestCursorAdapterWithNote()
{
db.insertLoyaltyCard("store", "note", "cardId", BarcodeFormat.UPC_A.toString());
LoyaltyCard card = db.getLoyaltyCard(1);
Cursor cursor = db.getLoyaltyCardCursor();
cursor.moveToFirst();
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);
}
}