-
-
Notifications
You must be signed in to change notification settings - Fork 241
Add option to display card ID in card list #3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this It makes sense and we can keep this, I'm just checking to make sure for copyright reasons that it's just one of the default icons we can freely use. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24" | ||
| android:tint="?attr/colorControlNormal"> | ||
| <path | ||
| android:fillColor="@android:color/white" | ||
| android:pathData="M2,6h2v12L2,18L2,6zM5,6h1v12L5,18L5,6zM7,6h3v12L7,18L7,6zM11,6h1v12h-1L11,6zM13,6h2v12h-2L13,6zM16,6h2v12h-2L16,6zM19,6h1v12h-1L19,6zM21,6h1v12h-1L21,6z"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
|
|
||
| import androidx.appcompat.widget.SearchView; | ||
| import androidx.recyclerview.widget.RecyclerView; | ||
| import androidx.test.core.app.ApplicationProvider; | ||
|
|
||
| import com.google.android.material.tabs.TabLayout; | ||
| import com.google.zxing.BarcodeFormat; | ||
|
|
@@ -116,6 +117,74 @@ public void addOneLoyaltyCard() { | |
| database.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void cardIdHiddenByDefault() { | ||
| ActivityController activityController = Robolectric.buildActivity(MainActivity.class).create(); | ||
|
|
||
| Activity mainActivity = (Activity) activityController.get(); | ||
| activityController.start(); | ||
| activityController.resume(); | ||
| activityController.visible(); | ||
|
|
||
| RecyclerView list = mainActivity.findViewById(R.id.list); | ||
|
|
||
| SQLiteDatabase database = TestHelpers.getEmptyDb(mainActivity).getWritableDatabase(); | ||
| DBHelper.insertLoyaltyCard(database, "store", "", null, null, new BigDecimal("0"), null, "1234567890", null, CatimaBarcode.fromBarcode(BarcodeFormat.UPC_A), StandardCharsets.ISO_8859_1, Color.BLACK, 0, null, 0); | ||
|
|
||
| activityController.pause(); | ||
| activityController.resume(); | ||
| activityController.visible(); | ||
|
|
||
| assertEquals(1, list.getAdapter().getItemCount()); | ||
|
|
||
| list.measure(0, 0); | ||
| list.layout(0, 0, 100, 1000); | ||
|
Comment on lines
+140
to
+141
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is exactly necessary, it's used in the addFourLoyaltyCardsTwoStarred test because those are four cards and the RecyclerView might otherwise not show them, but I think keeping it is also not necessarily an issue. But might be good to also copy the comment from the other test ( |
||
|
|
||
| // Card ID is hidden by default | ||
| TextView cardIdField = list.findViewHolderForAdapterPosition(0).itemView.findViewById(R.id.cardId); | ||
| assertEquals(View.GONE, cardIdField.getVisibility()); | ||
|
|
||
| database.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void showCardIdDisplayOption() { | ||
| // The display option is read in the adapter's constructor (during onCreate), so the | ||
| // preference must be set before the activity is built. | ||
| SharedPreferences cardDetailsPref = ApplicationProvider.getApplicationContext().getSharedPreferences( | ||
| ApplicationProvider.getApplicationContext().getString(R.string.sharedpreference_card_details), | ||
| Activity.MODE_PRIVATE); | ||
| cardDetailsPref.edit().putBoolean( | ||
| ApplicationProvider.getApplicationContext().getString(R.string.sharedpreference_card_details_show_card_id), true).apply(); | ||
|
|
||
| ActivityController activityController = Robolectric.buildActivity(MainActivity.class).create(); | ||
|
|
||
| Activity mainActivity = (Activity) activityController.get(); | ||
| activityController.start(); | ||
| activityController.resume(); | ||
| activityController.visible(); | ||
|
|
||
| RecyclerView list = mainActivity.findViewById(R.id.list); | ||
|
|
||
| SQLiteDatabase database = TestHelpers.getEmptyDb(mainActivity).getWritableDatabase(); | ||
| DBHelper.insertLoyaltyCard(database, "store", "", null, null, new BigDecimal("0"), null, "1234567890", null, CatimaBarcode.fromBarcode(BarcodeFormat.UPC_A), StandardCharsets.ISO_8859_1, Color.BLACK, 0, null, 0); | ||
|
|
||
| activityController.pause(); | ||
| activityController.resume(); | ||
| activityController.visible(); | ||
|
|
||
| assertEquals(1, list.getAdapter().getItemCount()); | ||
|
|
||
| list.measure(0, 0); | ||
| list.layout(0, 0, 100, 1000); | ||
|
Comment on lines
+178
to
+179
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| TextView cardIdField = list.findViewHolderForAdapterPosition(0).itemView.findViewById(R.id.cardId); | ||
| assertEquals(View.VISIBLE, cardIdField.getVisibility()); | ||
| assertEquals("1234567890", cardIdField.getText().toString()); | ||
|
|
||
| database.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void addFourLoyaltyCardsTwoStarred() // Main screen showing starred cards on top correctly | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the card ID should probably be displayed as one of the first options, as for those who will use this feature it is probably something they want to refer to often ("yeah my customer ID is 123456").
I'm not quite sure if before or after the note makes most sense, but I'd say it is probably easiest and most consistent to put it after the note but before everything else.