Initial widget work

Co-authored-by: Sylvia van Os <sylvia@hackerchick.me>
This commit is contained in:
realwk
2025-07-30 21:21:55 +02:00
committed by Sylvia van Os
parent e217e99864
commit 9a0149def8
11 changed files with 280 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -1176,4 +1177,40 @@ public class Utils {
return ImageView.ScaleType.FIT_CENTER;
}
public static DBHelper.LoyaltyCardOrder getLoyaltyCardOrder(Context context) {
SharedPreferences sortPref = context.getSharedPreferences(
"sharedpreference_sort",
Context.MODE_PRIVATE
);
String orderString = sortPref.getString("sharedpreference_sort_order", null);
if (orderString != null) {
try {
return DBHelper.LoyaltyCardOrder.valueOf(orderString);
} catch (IllegalArgumentException ignored) {
}
}
return DBHelper.LoyaltyCardOrder.Alpha;
}
public static DBHelper.LoyaltyCardOrderDirection getLoyaltyCardOrderDirection(Context context) {
SharedPreferences sortPref = context.getSharedPreferences(
"sharedpreference_sort",
Context.MODE_PRIVATE
);
String orderDirectionString = sortPref.getString("sharedpreference_sort_direction", null);
if (orderDirectionString != null) {
try {
return DBHelper.LoyaltyCardOrderDirection.valueOf(orderDirectionString);
} catch (IllegalArgumentException ignored) {
}
}
return DBHelper.LoyaltyCardOrderDirection.Ascending;
}
}