Skip to content
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

Sort by usage #1212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 59 additions & 14 deletions app/src/main/java/protect/card_locker/DBHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static class LoyaltyCardDbIds {
public static final String LAST_USED = "lastused";
public static final String ZOOM_LEVEL = "zoomlevel";
public static final String ARCHIVE_STATUS = "archive";
public static final String USAGE_NUMBER = "usagenumber";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd much prefer this to be named USAGE_COUNT and usagecount. To me that is more logical.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

}

public static class LoyaltyCardDbIdsGroups {
Expand All @@ -65,7 +66,9 @@ public static class LoyaltyCardDbFTS {
public enum LoyaltyCardOrder {
Alpha,
LastUsed,
Expiry
Expiry,

UsageNumber
Comment on lines +70 to +71
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UsageNumber
UsageCount

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done !

}

public enum LoyaltyCardOrderDirection {
Expand Down Expand Up @@ -103,6 +106,7 @@ public void onCreate(SQLiteDatabase db) {
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," +
LoyaltyCardDbIds.CARD_ID + " TEXT not null," +
LoyaltyCardDbIds.BARCODE_ID + " TEXT," +
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " +
LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," +
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0'," +
LoyaltyCardDbIds.LAST_USED + " INTEGER DEFAULT '0', " +
Expand Down Expand Up @@ -189,6 +193,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," +
LoyaltyCardDbIds.CARD_ID + " TEXT not null," +
LoyaltyCardDbIds.BARCODE_ID + " TEXT," +
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, this will only be executed when users are on database version 9. So existing installations won't get the usage column. This should be removed (there should be an extra upgrade at the end and the DATABASE_VERSION variable needs to be increased).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in progress..

LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," +
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0' )");

Expand All @@ -202,6 +207,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LoyaltyCardDbIds.HEADER_COLOR + " ," +
LoyaltyCardDbIds.CARD_ID + " ," +
LoyaltyCardDbIds.BARCODE_ID + " ," +
LoyaltyCardDbIds.USAGE_NUMBER + " , " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

LoyaltyCardDbIds.BARCODE_TYPE + " ," +
LoyaltyCardDbIds.STAR_STATUS + ")" +
" SELECT " +
Expand All @@ -214,6 +220,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LoyaltyCardDbIds.HEADER_COLOR + " ," +
LoyaltyCardDbIds.CARD_ID + " ," +
LoyaltyCardDbIds.BARCODE_ID + " ," +
LoyaltyCardDbIds.USAGE_NUMBER + " , " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

" NULLIF(" + LoyaltyCardDbIds.BARCODE_TYPE + ",'') ," +
LoyaltyCardDbIds.STAR_STATUS +
" FROM " + LoyaltyCardDbIds.TABLE);
Expand All @@ -230,6 +237,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LoyaltyCardDbIds.HEADER_COLOR + " INTEGER," +
LoyaltyCardDbIds.CARD_ID + " TEXT not null," +
LoyaltyCardDbIds.BARCODE_ID + " TEXT," +
LoyaltyCardDbIds.USAGE_NUMBER + " INTEGER DEFAULT '0', " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," +
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0' )");

Expand All @@ -243,6 +251,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
LoyaltyCardDbIds.HEADER_COLOR + " ," +
LoyaltyCardDbIds.CARD_ID + " ," +
LoyaltyCardDbIds.BARCODE_ID + " ," +
LoyaltyCardDbIds.USAGE_NUMBER + " , " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

LoyaltyCardDbIds.BARCODE_TYPE + " ," +
LoyaltyCardDbIds.STAR_STATUS + ")" +
" SELECT " +
Expand Down Expand Up @@ -416,6 +425,7 @@ public static long insertLoyaltyCard(
contentValues.put(LoyaltyCardDbIds.BALANCE_TYPE, balanceType != null ? balanceType.getCurrencyCode() : null);
contentValues.put(LoyaltyCardDbIds.CARD_ID, cardId);
contentValues.put(LoyaltyCardDbIds.BARCODE_ID, barcodeId);
contentValues.put(LoyaltyCardDbIds.USAGE_NUMBER, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is below ARCHIVE_STATUS on top, please keep the order consistent everywhere.

contentValues.put(LoyaltyCardDbIds.BARCODE_TYPE, barcodeType != null ? barcodeType.name() : null);
contentValues.put(LoyaltyCardDbIds.HEADER_COLOR, headerColor);
contentValues.put(LoyaltyCardDbIds.STAR_STATUS, starStatus);
Expand All @@ -437,7 +447,7 @@ public static boolean updateLoyaltyCard(
final Date validFrom, final Date expiry, final BigDecimal balance,
final Currency balanceType, final String cardId, final String barcodeId,
final CatimaBarcode barcodeType, final Integer headerColor, final int starStatus,
final Long lastUsed, final int archiveStatus) {
final Long lastUsed, final int archiveStatus ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whitespace change is unnecessary.

Suggested change
final Long lastUsed, final int archiveStatus ) {
final Long lastUsed, final int archiveStatus) {

database.beginTransaction();

// Card
Expand Down Expand Up @@ -477,6 +487,24 @@ public static boolean updateLoyaltyCardArchiveStatus(SQLiteDatabase database, fi
return (rowsUpdated == 1);
}

public static boolean updateLoyaltyCardUsageNumber(SQLiteDatabase database, final int id) {

LoyaltyCard to_update_card = getLoyaltyCard(database,id);
int usage_number = to_update_card.usage_number + 1;

ContentValues contentValues = new ContentValues();

contentValues.put(LoyaltyCardDbIds.USAGE_NUMBER, usage_number);
Log.d("updateLoyaltyCardULevel", "Card Id = " + id + " usage number = " + usage_number);
int rowsUpdated = database.update(LoyaltyCardDbIds.TABLE, contentValues,
whereAttrs(LoyaltyCardDbIds.ID),
withArgs(to_update_card.id));
Log.d("updateLoyaltyCardZLevel", "Rows changed = " + rowsUpdated);

return (rowsUpdated == 1);

}

Comment on lines +490 to +507
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this makes sense but I am actually going to consider this pull request blocked because we have way too many functions that just edit one field right now and it is just getting uglier every time something is added here. And it is really time I clean this up.

public static boolean updateLoyaltyCardStarStatus(SQLiteDatabase database, final int id, final int starStatus) {
ContentValues contentValues = new ContentValues();
contentValues.put(LoyaltyCardDbIds.STAR_STATUS, starStatus);
Expand Down Expand Up @@ -687,18 +715,31 @@ public static Cursor getLoyaltyCardCursor(SQLiteDatabase database, String filter

String orderField = getFieldForOrder(order);

return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE +
" JOIN " + LoyaltyCardDbFTS.TABLE +
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID +
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") +
groupFilter.toString() +
archiveFilterString +
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ARCHIVE_STATUS + " ASC, " +
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STAR_STATUS + " DESC, " +
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " +
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " +
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " +
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null);
if(order != LoyaltyCardOrder.UsageNumber)
return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE +
" JOIN " + LoyaltyCardDbFTS.TABLE +
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID +
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") +
groupFilter.toString() +
archiveFilterString +
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ARCHIVE_STATUS + " ASC, " +
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STAR_STATUS + " DESC, " +
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " +
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " +
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " +
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null);
else
return database.rawQuery("SELECT " + LoyaltyCardDbIds.TABLE + ".* FROM " + LoyaltyCardDbIds.TABLE +
" JOIN " + LoyaltyCardDbFTS.TABLE +
" ON " + LoyaltyCardDbFTS.TABLE + "." + LoyaltyCardDbFTS.ID + " = " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.ID +
(filter.trim().isEmpty() ? " " : " AND " + LoyaltyCardDbFTS.TABLE + " MATCH ? ") +
groupFilter.toString() +
archiveFilterString +
" ORDER BY " + LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.USAGE_NUMBER + " DESC, "+
" (CASE WHEN " + LoyaltyCardDbIds.TABLE + "." + orderField + " IS NULL THEN 1 ELSE 0 END), " +
LoyaltyCardDbIds.TABLE + "." + orderField + " COLLATE NOCASE " + getDbDirection(order, direction) + ", " +
LoyaltyCardDbIds.TABLE + "." + LoyaltyCardDbIds.STORE + " COLLATE NOCASE ASC " +
limitString, filter.trim().isEmpty() ? null : new String[]{TextUtils.join("* ", filter.split(" ")) + '*'}, null);
Comment on lines +718 to +742
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other ordering features just work with getDbDirection, can't that be extended this time too?

}

/**
Expand Down Expand Up @@ -900,6 +941,10 @@ private static String getFieldForOrder(LoyaltyCardOrder order) {
return LoyaltyCardDbIds.EXPIRY;
}

if (order == LoyaltyCardOrder.UsageNumber) {
return LoyaltyCardDbIds.USAGE_NUMBER;
}

throw new IllegalArgumentException("Unknown order " + order);
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/protect/card_locker/GroupCursorAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public void onBindViewHolder(GroupListItemViewHolder inputHolder, Cursor inputCu
int groupCardCount = DBHelper.getGroupCardCount(mDatabase, group._id);
int archivedCardCount = DBHelper.getArchivedCardsCount(mDatabase, group._id);

System.out.println("Try to find 1");

Comment on lines +56 to +57
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary debug statement.

Suggested change
System.out.println("Try to find 1");

Resources resources = mContext.getResources();

String cardCountText;
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/protect/card_locker/ImportURIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class ImportURIHelper {
private static final String BARCODE_TYPE = DBHelper.LoyaltyCardDbIds.BARCODE_TYPE;
private static final String HEADER_COLOR = DBHelper.LoyaltyCardDbIds.HEADER_COLOR;

private static final String USAGE_NUMBER = DBHelper.LoyaltyCardDbIds.USAGE_NUMBER;

Comment on lines +30 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to add this to ImportURIHelper. I don't think that someone else using a card a lot should affect how often it is considered used in your installation.

private final Context context;
private final String[] hosts = new String[3];
private final String[] paths = new String[3];
Expand Down Expand Up @@ -92,6 +94,7 @@ public LoyaltyCard parse(Uri uri) throws InvalidObjectException {
String note = kv.get(NOTE);
String cardId = kv.get(CARD_ID);
String barcodeId = kv.get(BARCODE_ID);
int usage_number = Integer.parseInt(kv.get(USAGE_NUMBER));
if (store == null || note == null || cardId == null)
throw new InvalidObjectException("Not a valid import URI: " + uri.toString());

Expand Down Expand Up @@ -122,7 +125,7 @@ public LoyaltyCard parse(Uri uri) throws InvalidObjectException {
headerColor = Integer.parseInt(unparsedHeaderColor);
}

return new LoyaltyCard(-1, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, 0, Utils.getUnixTime(), 100, 0);
return new LoyaltyCard(-1, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, 0, Utils.getUnixTime(), 100, 0, usage_number);
} catch (NullPointerException | NumberFormatException | UnsupportedEncodingException | ArrayIndexOutOfBoundsException ex) {
throw new InvalidObjectException("Not a valid import URI");
}
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/java/protect/card_locker/LoyaltyCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public class LoyaltyCard implements Parcelable {
public final long lastUsed;
public int zoomLevel;

public int usage_number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be final like the rest?

Also, please use camel-case like everywhere else.


public LoyaltyCard(final int id, final String store, final String note, final Date validFrom,
final Date expiry, final BigDecimal balance, final Currency balanceType,
final String cardId, @Nullable final String barcodeId,
@Nullable final CatimaBarcode barcodeType,
final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType,
@Nullable final Integer headerColor, final int starStatus,
final long lastUsed, final int zoomLevel, final int archiveStatus) {
final long lastUsed, final int zoomLevel, final int archiveStatus,
int usage_number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be final like the rest?

Also, please use camel-case like everywhere else.

this.id = id;
this.store = store;
this.note = note;
Expand All @@ -55,6 +57,7 @@ public LoyaltyCard(final int id, final String store, final String note, final Da
this.lastUsed = lastUsed;
this.zoomLevel = zoomLevel;
this.archiveStatus = archiveStatus;
this.usage_number = usage_number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camel-case like everywhere else.

}

protected LoyaltyCard(Parcel in) {
Expand Down Expand Up @@ -110,6 +113,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) {
int starred = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.STAR_STATUS));
long lastUsed = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.LAST_USED));
int zoomLevel = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ZOOM_LEVEL));
int usage_number = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.USAGE_NUMBER));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camel-case like everywhere else.

int archived = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ARCHIVE_STATUS));

int barcodeTypeColumn = cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.BARCODE_TYPE);
Expand Down Expand Up @@ -142,7 +146,7 @@ public static LoyaltyCard toLoyaltyCard(Cursor cursor) {
headerColor = cursor.getInt(headerColorColumn);
}

return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, starred, lastUsed, zoomLevel, archived);
return new LoyaltyCard(id, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId ,barcodeType, headerColor, starred, lastUsed, zoomLevel, archived, usage_number);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camel-case like everywhere else.

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package protect.card_locker;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
Expand Down Expand Up @@ -73,7 +72,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.Toolbar;
Expand Down Expand Up @@ -222,7 +220,8 @@ private static LoyaltyCard updateTempState(LoyaltyCard loyaltyCard, LoyaltyCardF
(int) (fieldName == LoyaltyCardField.starStatus ? value : loyaltyCard.starStatus),
0, // Unimportant, always set to null in doSave so the DB updates it to the current timestamp
100, // Unimportant, not updated in doSave, defaults to 100 for new cards
(int) (fieldName == LoyaltyCardField.archiveStatus ? value : loyaltyCard.archiveStatus)
(int) (fieldName == LoyaltyCardField.archiveStatus ? value : loyaltyCard.archiveStatus),
(int) (fieldName == LoyaltyCardField.usage_number ? value : 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the variable, I think otherwise the usage will be reset to 0 every time you edit the card.

Also, please use camel-case like everywhere else.

);
}

Expand Down Expand Up @@ -755,7 +754,7 @@ public void onResume() {
}
} else {
// New card, use default values
tempLoyaltyCard = new LoyaltyCard(-1, "", "", null, null, new BigDecimal("0"), null, "", null, null, null, 0, Utils.getUnixTime(), 100,0);
tempLoyaltyCard = new LoyaltyCard(-1, "", "", null, null, new BigDecimal("0"), null, "", null, null, null, 0, Utils.getUnixTime(), 100,0, 0);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum LoyaltyCardField {
cardId,
barcodeId,
barcodeType,
usage_number,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camel-case like everywhere else. And please keep the same order as in the database class (so, below archiveStatus)

headerColor,
starStatus,
archiveStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ private void setCenterGuideline(int zoomLevel) {

@Override
protected void onCreate(Bundle savedInstanceState) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace change.

Suggested change

if (savedInstanceState == null) {
Bundle incomingIntentExtras = getIntent().getExtras();

Expand Down Expand Up @@ -428,6 +429,8 @@ public void onStopTrackingTouch(SeekBar seekBar) {
maximizeButton.setOnClickListener(v -> setFullscreen(true));
minimizeButton.setOnClickListener(v -> setFullscreen(false));

DBHelper.updateLoyaltyCardUsageNumber(database, loyaltyCardId);

Comment on lines +432 to +433
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to put this either near the top or all the way at the bottom for clarity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, i don't know where to put this function, i think it going to be null :/

editButton = binding.fabEdit;
editButton.setOnClickListener(v -> {
Intent intent = new Intent(getApplicationContext(), LoyaltyCardEditActivity.class);
Expand Down Expand Up @@ -466,7 +469,10 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int
iconImage.setClipBounds(new Rect(left, top, right, bottom));
}
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary whitespace change.

Suggested change

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//this.database

Comment on lines +474 to +475
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary debug comment.

Suggested change
//this.database

}

private SpannableStringBuilder padSpannableString(SpannableStringBuilder spannableStringBuilder) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/protect/card_locker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class MainActivity extends CatimaAppCompatActivity implements LoyaltyCard
private int mLoyaltyCardCount = 0;
protected String mFilter = "";
protected Object mGroup = null;
protected DBHelper.LoyaltyCardOrder mOrder = DBHelper.LoyaltyCardOrder.Alpha;
protected DBHelper.LoyaltyCardOrder mOrder = DBHelper.LoyaltyCardOrder.UsageNumber;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the default sorting style.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

protected DBHelper.LoyaltyCardOrderDirection mOrderDirection = DBHelper.LoyaltyCardOrderDirection.Ascending;
protected int selectedTab = 0;
private RecyclerView mCardList;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<item>@string/sort_by_name</item>
<item>@string/sort_by_most_recently_used</item>
<item>@string/sort_by_expiry</item>
<item>@string/sort_by_usage</item>
</string-array>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
<string name="sort_by_balance">Balance</string>
<!-- \"Reversed order\" is also OK. This is an option in the card sorting list -->
<string name="reverse">…in reversed order</string>
<string name="sort_by_usage">Usage</string>
<string name="sort_by">Sort by</string>
<string name="version_history">Version History</string>
<string name="arrow" translatable="false"><![CDATA[>]]></string>
Expand Down