Skip to content

Commit b01e6b5

Browse files
Merge pull request #2917 from CatimaLoyalty/minSdk23
Remove Android 5 support
2 parents 68d5dcd + 2345785 commit b01e6b5

File tree

10 files changed

+16
-71
lines changed

10 files changed

+16
-71
lines changed

.github/workflows/android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5151
sudo udevadm control --reload-rules
5252
sudo udevadm trigger --name-match=kvm
53-
- name: Run instrumented tests (API 21)
53+
- name: Run instrumented tests (API 23)
5454
uses: ReactiveCircus/android-emulator-runner@v2
5555
with:
56-
api-level: 21
56+
api-level: 23
5757
arch: x86_64
5858
script: ./gradlew connected${{ matrix.flavor }}DebugAndroidTest
5959
- name: Run instrumented tests (API 35)

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ android {
1717

1818
defaultConfig {
1919
applicationId = "me.hackerchick.catima"
20-
minSdk = 21
20+
minSdk = 23
2121
targetSdk = 36
2222
versionCode = 158
2323
versionName = "2.41.1"

app/src/main/java/protect/card_locker/CatimaAppCompatActivity.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,10 @@ protected void onPostCreate(@Nullable Bundle savedInstanceState) {
3838
Window window = getWindow();
3939
if (window != null) {
4040
boolean darkMode = Utils.isDarkModeEnabled(this);
41-
if (Build.VERSION.SDK_INT >= 23) {
42-
View decorView = window.getDecorView();
43-
WindowInsetsControllerCompat wic = new WindowInsetsControllerCompat(window, decorView);
44-
wic.setAppearanceLightStatusBars(!darkMode);
45-
window.setStatusBarColor(Color.TRANSPARENT);
46-
} else {
47-
// icons are always white back then
48-
window.setStatusBarColor(darkMode ? Color.TRANSPARENT : Color.argb(127, 0, 0, 0));
49-
}
41+
View decorView = window.getDecorView();
42+
WindowInsetsControllerCompat wic = new WindowInsetsControllerCompat(window, decorView);
43+
wic.setAppearanceLightStatusBars(!darkMode);
44+
window.setStatusBarColor(Color.TRANSPARENT);
5045
}
5146
// XXX android 9 and below has a nasty rendering bug if the theme was patched earlier
5247
Utils.postPatchColors(this);
@@ -66,7 +61,4 @@ protected void enableToolbarBackButton() {
6661
actionBar.setDisplayHomeAsUpEnabled(true);
6762
}
6863
}
69-
70-
public void onMockedRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
71-
}
7264
}

app/src/main/java/protect/card_locker/ListWidget.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ class ListWidget : AppWidgetProvider() {
100100
val foreground = if (Utils.needsDarkForeground(headerColor)) Color.BLACK else Color.WHITE
101101
setInt(R.id.item_container_foreground, "setBackgroundColor", headerColor)
102102
val icon = loyaltyCard.getImageThumbnail(context)
103-
// setImageViewIcon is not supported on Android 5, so force Android 5 down the text path
104-
// FIXME: The icon flow causes a crash up to Android 12L, so SDK_INT is forced up from 23 to 33
103+
// FIXME: The icon flow causes a crash up to Android 12L, so force anything below 33 down this path
105104
if (icon != null && Build.VERSION.SDK_INT >= 32) {
106105
setInt(R.id.item_container_foreground, "setBackgroundColor", foreground)
107106
setImageViewIcon(R.id.item_image, Icon.createWithBitmap(icon))

app/src/main/java/protect/card_locker/PermissionUtils.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ private static boolean needsStorageReadPermission(Activity activity) {
3434
* @return
3535
*/
3636
public static boolean needsCameraPermission(Activity activity) {
37-
// Android only introduced the runtime permission system in Marshmallow (Android 6.0)
38-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
39-
return false;
40-
}
41-
4237
return ContextCompat.checkSelfPermission(activity, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED;
4338
}
4439

@@ -49,21 +44,14 @@ public static boolean needsCameraPermission(Activity activity) {
4944
* @param activity
5045
* @param requestCode
5146
*/
52-
public static void requestStorageReadPermission(CatimaAppCompatActivity activity, int requestCode) {
47+
public static void requestStorageReadPermission(Activity activity, int requestCode) {
5348
String[] permissions = new String[]{ android.Manifest.permission.READ_EXTERNAL_STORAGE };
5449
int[] mockedResults = new int[]{ PackageManager.PERMISSION_GRANTED };
5550

5651
if (needsStorageReadPermission(activity)) {
5752
ActivityCompat.requestPermissions(activity, permissions, requestCode);
5853
} else {
59-
// FIXME: This points to onMockedRequestPermissionResult instead of to
60-
// onRequestPermissionResult because onRequestPermissionResult was only introduced in
61-
// Android 6.0 (SDK 23) and we and to support Android 5.0 (SDK 21) too.
62-
//
63-
// When minSdk becomes 23, this should point to onRequestPermissionResult directly and
64-
// the activity input variable should be changed from CatimaAppCompatActivity to
65-
// Activity.
66-
activity.onMockedRequestPermissionsResult(requestCode, permissions, mockedResults);
54+
activity.onRequestPermissionsResult(requestCode, permissions, mockedResults);
6755
}
6856
}
6957

@@ -74,21 +62,14 @@ public static void requestStorageReadPermission(CatimaAppCompatActivity activity
7462
* @param activity
7563
* @param requestCode
7664
*/
77-
public static void requestCameraPermission(CatimaAppCompatActivity activity, int requestCode) {
65+
public static void requestCameraPermission(Activity activity, int requestCode) {
7866
String[] permissions = new String[]{ Manifest.permission.CAMERA };
7967
int[] mockedResults = new int[]{ PackageManager.PERMISSION_GRANTED };
8068

8169
if (needsCameraPermission(activity)) {
8270
ActivityCompat.requestPermissions(activity, permissions, requestCode);
8371
} else {
84-
// FIXME: This points to onMockedRequestPermissionResult instead of to
85-
// onRequestPermissionResult because onRequestPermissionResult was only introduced in
86-
// Android 6.0 (SDK 23) and we and to support Android 5.0 (SDK 21) too.
87-
//
88-
// When minSdk becomes 23, this should point to onRequestPermissionResult directly and
89-
// the activity input variable should be changed from CatimaAppCompatActivity to
90-
// Activity.
91-
activity.onMockedRequestPermissionsResult(requestCode, permissions, mockedResults);
72+
activity.onRequestPermissionsResult(requestCode, permissions, mockedResults);
9273
}
9374
}
9475
}

app/src/main/java/protect/card_locker/ScanActivity.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,14 +543,6 @@ class ScanActivity : CatimaAppCompatActivity() {
543543
) {
544544
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
545545

546-
onMockedRequestPermissionsResult(requestCode, permissions, grantResults)
547-
}
548-
549-
override fun onMockedRequestPermissionsResult(
550-
requestCode: Int,
551-
permissions: Array<String>,
552-
grantResults: IntArray
553-
) {
554546
val granted =
555547
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED
556548

app/src/main/java/protect/card_locker/UCropWrapper.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,9 @@ class UCropWrapper : UCropActivity() {
4040
return
4141
}
4242

43-
if (Build.VERSION.SDK_INT >= 23) {
44-
val decorView = window.decorView
45-
val wic = WindowInsetsControllerCompat(window, decorView)
46-
wic.isAppearanceLightStatusBars = !darkMode
47-
} else if (!darkMode) {
48-
window.statusBarColor = ColorUtils.compositeColors(
49-
Color.argb(127, 0, 0, 0),
50-
window.statusBarColor
51-
)
52-
}
43+
val decorView = window.decorView
44+
val wic = WindowInsetsControllerCompat(window, decorView)
45+
wic.isAppearanceLightStatusBars = !darkMode
5346
}
5447

5548
private fun checkViews(darkMode: Boolean) {

app/src/main/java/protect/card_locker/contentprovider/CardsContentProvider.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ public Cursor query(@NonNull final Uri uri,
7777
@Nullable final String selection,
7878
@Nullable final String[] selectionArgs,
7979
@Nullable final String sortOrder) {
80-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
81-
// Disable the content provider on SDK < 23 since it grants dangerous
82-
// permissions at install-time
83-
Log.w(TAG, "Content provider read is only available for SDK >= 23");
84-
return null;
85-
}
86-
8780
final Settings settings = new Settings(getContext());
8881
if (!settings.getAllowContentProviderRead()) {
8982
Log.w(TAG, "Content provider read is disabled");

app/src/main/java/protect/card_locker/importexport/CatimaImporter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ private LoyaltyCard importLoyaltyCard(CSVRecord record) throws FormatException {
459459
barcodeType = CatimaBarcode.fromName(unparsedBarcodeType);
460460
}
461461

462+
// This field did not exist in version 2.40.0 and before
462463
Charset barcodeEncoding = null;
463464
String unparsedBarcodeEncoding = CSVHelpers.extractString(DBHelper.LoyaltyCardDbIds.BARCODE_ENCODING, record, "");
464465
if (!unparsedBarcodeEncoding.isEmpty()) {

app/src/main/java/protect/card_locker/preferences/SettingsActivity.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,6 @@ class SettingsActivity : CatimaAppCompatActivity() {
157157
true
158158
}
159159

160-
// Disable content provider on SDK < 23 since dangerous permissions
161-
// are granted at install-time
162-
val contentProviderReadPreference = findPreference<Preference>(getString(R.string.settings_key_allow_content_provider_read))
163-
contentProviderReadPreference!!.isVisible =
164-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
165-
166160
// Hide crash reporter settings on builds it's not enabled on
167161
val crashReporterPreference = findPreference<Preference>("acra.enable")
168162
crashReporterPreference!!.isVisible = BuildConfig.useAcraCrashReporter

0 commit comments

Comments
 (0)