From 0eadf445173eeaabd8d39e333047012c799ba9b2 Mon Sep 17 00:00:00 2001 From: Federico Iosue Date: Sat, 28 Oct 2023 22:28:33 +0200 Subject: [PATCH] Fixed some tests --- .../helpers/DocumentFileHelperTest.kt | 2 +- .../GeocodeProviderBaseFactoryTest.java | 49 ------------------- .../helpers/GeocodeProviderBaseFactoryTest.kt | 41 ++++++++++++++++ .../testutils/BaseAndroidTestCase.java | 7 ++- .../feio/android/omninotes/ListFragment.java | 3 +- .../feio/android/omninotes/MainActivity.java | 2 +- .../it/feio/android/omninotes/OmniNotes.java | 5 +- .../async/AlarmRestoreOnRebootService.java | 4 +- .../{BuildVersionHelper.kt => BuildHelper.kt} | 8 ++- .../helpers/GeocodeProviderBaseFactory.java | 2 +- .../omninotes/helpers/IntentHelper.java | 4 +- .../omninotes/helpers/LanguageHelper.java | 2 +- .../omninotes/helpers/PermissionsHelper.java | 3 +- .../notifications/NotificationsHelper.java | 13 ++--- .../omninotes/intro/IntroActivity.java | 4 +- .../omninotes/utils/ShortcutHelper.java | 6 +-- .../omninotes/helpers/NotesHelperTest.java | 4 +- 17 files changed, 79 insertions(+), 80 deletions(-) delete mode 100644 omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.java create mode 100644 omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.kt rename omniNotes/src/main/java/it/feio/android/omninotes/helpers/{BuildVersionHelper.kt => BuildHelper.kt} (87%) diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/DocumentFileHelperTest.kt b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/DocumentFileHelperTest.kt index b0f1c543c..7f862d74d 100644 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/DocumentFileHelperTest.kt +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/DocumentFileHelperTest.kt @@ -78,7 +78,7 @@ class DocumentFileHelperTest : BaseAndroidTestCase() { } @Test - @Ignore("runned manually") + @Ignore("run manually") fun copyFileTo_performance() { for (i in 1..50) copyFileTo() diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.java deleted file mode 100644 index e90f56c22..000000000 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013-2023 Federico Iosue (federico@iosue.it) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package it.feio.android.omninotes.helpers; - - -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -import io.nlopez.smartlocation.location.LocationProvider; -import it.feio.android.omninotes.testutils.BaseAndroidTestCase; -import org.junit.Test; - -public class GeocodeProviderBaseFactoryTest extends BaseAndroidTestCase { - - @Test - public void checkUtilityClassWellDefined() throws Exception { - assertUtilityClassWellDefined(GeocodeProviderBaseFactory.class, true, true); - } - - @Test - public void getProvider() { - LocationProvider locationProvider = GeocodeProviderBaseFactory.getProvider(testContext); - assertNotEquals(null, locationProvider); - } - - @Test - public void checkHighAccuracyLocationProvider() { - boolean highAccuracyLocationProviderEnabled = GeocodeProviderBaseFactory - .checkHighAccuracyLocationProvider( - testContext); - assertTrue(highAccuracyLocationProviderEnabled); - } - -} diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.kt b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.kt new file mode 100644 index 000000000..677e66444 --- /dev/null +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactoryTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013-2023 Federico Iosue (federico@iosue.it) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package it.feio.android.omninotes.helpers + +import it.feio.android.omninotes.testutils.BaseAndroidTestCase +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertTrue +import org.junit.Test + +class GeocodeProviderBaseFactoryTest : BaseAndroidTestCase() { + + @Test + @Throws(Exception::class) + fun checkUtilityClassWellDefined() { + assertUtilityClassWellDefined(GeocodeProviderBaseFactory::class.java, true, true) + } + + @Test + fun provider() { + assertNotNull(GeocodeProviderBaseFactory.getProvider(testContext)) + } + + @Test + fun checkHighAccuracyLocationProvider() { + assertTrue(GeocodeProviderBaseFactory.checkHighAccuracyLocationProvider(testContext)) + } +} \ No newline at end of file diff --git a/omniNotes/src/androidTest/java/it/feio/android/omninotes/testutils/BaseAndroidTestCase.java b/omniNotes/src/androidTest/java/it/feio/android/omninotes/testutils/BaseAndroidTestCase.java index b4a261171..0c6acd26c 100644 --- a/omniNotes/src/androidTest/java/it/feio/android/omninotes/testutils/BaseAndroidTestCase.java +++ b/omniNotes/src/androidTest/java/it/feio/android/omninotes/testutils/BaseAndroidTestCase.java @@ -44,7 +44,7 @@ import it.feio.android.omninotes.async.bus.NotesUpdatedEvent; import it.feio.android.omninotes.db.DbHelper; import it.feio.android.omninotes.exceptions.TestException; -import it.feio.android.omninotes.helpers.BuildVersionHelper; +import it.feio.android.omninotes.helpers.BuildHelper; import it.feio.android.omninotes.models.Attachment; import it.feio.android.omninotes.models.Category; import it.feio.android.omninotes.models.Note; @@ -98,9 +98,12 @@ public void tearDown() { private static void grantPermissions() { GrantPermissionRule.grant(ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION, READ_EXTERNAL_STORAGE, RECORD_AUDIO); - if (BuildVersionHelper.isBelowOrEqual(VERSION_CODES.Q)) { + if (BuildHelper.isBelowOrEqual(VERSION_CODES.Q)) { GrantPermissionRule.grant(WRITE_EXTERNAL_STORAGE); } + if (BuildHelper.isAboveOrEqual(VERSION_CODES.TIRAMISU)) { + GrantPermissionRule.grant(POST_NOTIFICATIONS); + } } private void preparePreferences() { diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java b/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java index b1fed044f..d07f59de4 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java @@ -19,6 +19,7 @@ import static android.text.Html.fromHtml; import static android.text.TextUtils.isEmpty; import static androidx.core.view.ViewCompat.animate; +import static it.feio.android.omninotes.helpers.BuildHelper.isDebugBuild; import static it.feio.android.omninotes.utils.ConstantsBase.ACTION_FAB_TAKE_PHOTO; import static it.feio.android.omninotes.utils.ConstantsBase.ACTION_MERGE; import static it.feio.android.omninotes.utils.ConstantsBase.ACTION_POSTPONE; @@ -1260,7 +1261,7 @@ public void onEvent(PasswordRemovedEvent passwordRemovedEvent) { } private void animateListView() { - if (!OmniNotes.isDebugBuild()) { + if (!isDebugBuild()) { animate(binding.progressWheel) .setDuration(getResources().getInteger(R.integer.list_view_fade_anim)).alpha(0); animate(binding.list).setDuration(getResources().getInteger(R.integer.list_view_fade_anim)) diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/MainActivity.java b/omniNotes/src/main/java/it/feio/android/omninotes/MainActivity.java index e71c6afc1..5e940b7bd 100755 --- a/omniNotes/src/main/java/it/feio/android/omninotes/MainActivity.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/MainActivity.java @@ -17,9 +17,9 @@ package it.feio.android.omninotes; -import static it.feio.android.omninotes.OmniNotes.isDebugBuild; import static it.feio.android.omninotes.helpers.AppVersionHelper.isAppUpdated; import static it.feio.android.omninotes.helpers.AppVersionHelper.updateAppVersionInPreferences; +import static it.feio.android.omninotes.helpers.BuildHelper.isDebugBuild; import static it.feio.android.omninotes.helpers.ChangelogHelper.showChangelog; import static it.feio.android.omninotes.utils.ConstantsBase.ACTION_NOTIFICATION_CLICK; import static it.feio.android.omninotes.utils.ConstantsBase.ACTION_RESTART_APP; diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/OmniNotes.java b/omniNotes/src/main/java/it/feio/android/omninotes/OmniNotes.java index 9b8d89e1b..d842aca9e 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/OmniNotes.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/OmniNotes.java @@ -17,6 +17,7 @@ package it.feio.android.omninotes; +import static it.feio.android.omninotes.helpers.BuildHelper.isDebugBuild; import static it.feio.android.omninotes.utils.Constants.PACKAGE; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_LANG; @@ -39,10 +40,6 @@ public class OmniNotes extends MultiDexApplication { private static Context mContext; - public static boolean isDebugBuild() { - return BuildConfig.BUILD_TYPE.equals("debug"); - } - public static Context getAppContext() { return OmniNotes.mContext; } diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/async/AlarmRestoreOnRebootService.java b/omniNotes/src/main/java/it/feio/android/omninotes/async/AlarmRestoreOnRebootService.java index d65dc7fa3..6ab2dec9e 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/async/AlarmRestoreOnRebootService.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/async/AlarmRestoreOnRebootService.java @@ -25,7 +25,7 @@ import it.feio.android.omninotes.BaseActivity; import it.feio.android.omninotes.OmniNotes; import it.feio.android.omninotes.db.DbHelper; -import it.feio.android.omninotes.helpers.BuildVersionHelper; +import it.feio.android.omninotes.helpers.BuildHelper; import it.feio.android.omninotes.helpers.LogDelegate; import it.feio.android.omninotes.models.Note; import it.feio.android.omninotes.utils.ReminderHelper; @@ -39,7 +39,7 @@ public class AlarmRestoreOnRebootService extends JobIntentService { public static final int JOB_ID = 0x01; public static void enqueueWork(Context context, Intent work) { - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.O)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.O)) { enqueueWork(context, AlarmRestoreOnRebootService.class, JOB_ID, work); } else { Intent jobIntent = new Intent(context, AlarmRestoreOnRebootService.class); diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildVersionHelper.kt b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildHelper.kt similarity index 87% rename from omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildVersionHelper.kt rename to omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildHelper.kt index 0ef91ee4f..a79c9b1a7 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildVersionHelper.kt +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/BuildHelper.kt @@ -18,8 +18,9 @@ package it.feio.android.omninotes.helpers import android.os.Build +import it.feio.android.omninotes.BuildConfig -class BuildVersionHelper { +class BuildHelper { companion object { @JvmStatic @@ -41,5 +42,10 @@ class BuildVersionHelper { fun isBelow(sdk: Int): Boolean { return Build.VERSION.SDK_INT < sdk } + + @JvmStatic + fun isDebugBuild(): Boolean { + return BuildConfig.BUILD_TYPE == "debug" + } } } \ No newline at end of file diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactory.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactory.java index a62312e98..a771f05fe 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactory.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/GeocodeProviderBaseFactory.java @@ -35,7 +35,7 @@ protected GeocodeProviderBaseFactory() { } public static LocationProvider getProvider(Context context) { - if (BuildVersionHelper.isBelow(VERSION_CODES.P) && checkHighAccuracyLocationProvider(context)) { + if (BuildHelper.isBelow(VERSION_CODES.P) && checkHighAccuracyLocationProvider(context)) { Toast.makeText(context, R.string.location_set_high_accuracy, Toast.LENGTH_SHORT).show(); context.startActivity((new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))); } diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/IntentHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/IntentHelper.java index 6af547307..6a4c9ffaf 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/IntentHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/IntentHelper.java @@ -60,7 +60,7 @@ public static PendingIntent getNotePendingIntent(@NonNull Context context, @NonN public static int immutablePendingIntentFlag(final int flag) { int pIntentFlags = flag; - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.M)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.M)) { pIntentFlags = pIntentFlags | FLAG_IMMUTABLE; } return pIntentFlags; @@ -68,7 +68,7 @@ public static int immutablePendingIntentFlag(final int flag) { public static int mutablePendingIntentFlag(final int flag) { int pIntentFlags = flag; - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.S)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.S)) { pIntentFlags = pIntentFlags | FLAG_MUTABLE; } return pIntentFlags; diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/LanguageHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/LanguageHelper.java index 342f6babf..b57577a21 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/LanguageHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/LanguageHelper.java @@ -97,7 +97,7 @@ public static String getCurrentLocaleAsString(Context context) { } public static Locale getCurrentLocale(Context context) { - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.N)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.N)) { return context.getResources().getConfiguration().getLocales().get(0); } else { return context.getResources().getConfiguration().locale; diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/PermissionsHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/PermissionsHelper.java index 15b36fa3f..499f9e20f 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/PermissionsHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/PermissionsHelper.java @@ -23,7 +23,6 @@ import android.app.Activity; import android.content.pm.PackageManager; -import android.os.Build; import android.os.Build.VERSION_CODES; import android.view.View; import androidx.core.app.ActivityCompat; @@ -65,7 +64,7 @@ public static void requestPermission(Activity activity, String permission, } private static boolean skipPermissionRequest(String permission) { - return BuildVersionHelper.isAbove(VERSION_CODES.Q) && permission.equals(WRITE_EXTERNAL_STORAGE); + return BuildHelper.isAbove(VERSION_CODES.Q) && permission.equals(WRITE_EXTERNAL_STORAGE); } private static void requestPermissionExecute(Activity activity, String permission, diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/notifications/NotificationsHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/notifications/NotificationsHelper.java index fc7fa88e2..d0c8f5736 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/helpers/notifications/NotificationsHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/helpers/notifications/NotificationsHelper.java @@ -47,7 +47,7 @@ import it.feio.android.omninotes.MainActivity; import it.feio.android.omninotes.R; import it.feio.android.omninotes.async.bus.NotificationsGrantedEvent; -import it.feio.android.omninotes.helpers.BuildVersionHelper; +import it.feio.android.omninotes.helpers.BuildHelper; import lombok.NonNull; @@ -71,7 +71,7 @@ public NotificationsHelper(Context mContext) { */ @TargetApi(VERSION_CODES.O) public void initNotificationChannels() { - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.O)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.O)) { String soundFromPrefs = Prefs.getString("settings_notification_ringtone", null); Uri sound = soundFromPrefs != null ? Uri.parse(soundFromPrefs) @@ -97,7 +97,7 @@ public void initNotificationChannels() { @TargetApi(Build.VERSION_CODES.O) public void updateNotificationChannelsSound() { - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.O)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.O)) { Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Settings.EXTRA_APP_PACKAGE, mContext.getPackageName()); @@ -148,7 +148,7 @@ public NotificationsHelper setLargeIcon(int largeIconResource) { } public NotificationsHelper setRingtone(String ringtone) { - if (ringtone != null && BuildVersionHelper.isBelow(VERSION_CODES.O)) { + if (ringtone != null && BuildHelper.isBelow(VERSION_CODES.O)) { mBuilder.setSound(Uri.parse(ringtone)); } return this; @@ -242,13 +242,14 @@ public void cancel(int id) { } public boolean checkNotificationsEnabled(Context context) { - return BuildVersionHelper.isBelow(VERSION_CODES.TIRAMISU) + return BuildHelper.isBelow(VERSION_CODES.TIRAMISU) + || BuildHelper.isDebugBuild() || ContextCompat.checkSelfPermission(context, permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED; } public void askToEnableNotifications(ComponentActivity activity) { - if (BuildVersionHelper.isAboveOrEqual(VERSION_CODES.TIRAMISU)) { + if (BuildHelper.isAboveOrEqual(VERSION_CODES.TIRAMISU)) { if (!checkNotificationsEnabled(activity)) { activity.registerForActivityResult(new RequestPermission(), isGranted -> EventBus.getDefault().post(new NotificationsGrantedEvent(isGranted))) diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/intro/IntroActivity.java b/omniNotes/src/main/java/it/feio/android/omninotes/intro/IntroActivity.java index cfcb765ef..7e41e04c2 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/intro/IntroActivity.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/intro/IntroActivity.java @@ -17,12 +17,12 @@ package it.feio.android.omninotes.intro; +import static it.feio.android.omninotes.helpers.BuildHelper.isDebugBuild; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_TOUR_COMPLETE; import android.os.Bundle; import com.github.paolorotolo.appintro.AppIntro2; import com.pixplicity.easyprefs.library.Prefs; -import it.feio.android.omninotes.OmniNotes; public class IntroActivity extends AppIntro2 { @@ -44,7 +44,7 @@ public void onDonePressed() { } public static boolean mustRun() { - return !OmniNotes.isDebugBuild() && !Prefs.getBoolean(PREF_TOUR_COMPLETE, false); + return !isDebugBuild() && !Prefs.getBoolean(PREF_TOUR_COMPLETE, false); } @Override diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/utils/ShortcutHelper.java b/omniNotes/src/main/java/it/feio/android/omninotes/utils/ShortcutHelper.java index 26145732f..d6f5214c1 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/utils/ShortcutHelper.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/utils/ShortcutHelper.java @@ -35,7 +35,7 @@ import com.pixplicity.easyprefs.library.Prefs; import it.feio.android.omninotes.MainActivity; import it.feio.android.omninotes.R; -import it.feio.android.omninotes.helpers.BuildVersionHelper; +import it.feio.android.omninotes.helpers.BuildHelper; import it.feio.android.omninotes.helpers.date.DateHelper; import it.feio.android.omninotes.models.Note; import lombok.SneakyThrows; @@ -54,7 +54,7 @@ public static void addShortcut(Context context, Note note) { .getCreation(), Prefs.getBoolean(PREF_PRETTIFIED_DATES, true)); - if (BuildVersionHelper.isBelow(VERSION_CODES.O)) { + if (BuildHelper.isBelow(VERSION_CODES.O)) { createShortcutPreOreo(context, note, shortcutTitle); } else { createShortcutPostOreo(context, note, shortcutTitle); @@ -118,7 +118,7 @@ private static void createShortcutPreOreo(Context context, Note note, String sho * Removes note shortcut from home launcher */ public static void removeShortcut(Context context, Note note) { - if (BuildVersionHelper.isBelow(VERSION_CODES.O)) { + if (BuildHelper.isBelow(VERSION_CODES.O)) { removeShortcutPreOreo(context, note); } else { removeShortcutPostOreo(context, note); diff --git a/omniNotes/src/test/java/it/feio/android/omninotes/helpers/NotesHelperTest.java b/omniNotes/src/test/java/it/feio/android/omninotes/helpers/NotesHelperTest.java index 5ecfc7cce..ecec07c3b 100644 --- a/omniNotes/src/test/java/it/feio/android/omninotes/helpers/NotesHelperTest.java +++ b/omniNotes/src/test/java/it/feio/android/omninotes/helpers/NotesHelperTest.java @@ -92,10 +92,10 @@ public void getNoteInfo() { var contextMock = getContextMock(); try ( MockedStatic omniNotes = mockStatic(OmniNotes.class); - MockedStatic buildVersionHelper = mockStatic(BuildVersionHelper.class); + MockedStatic buildVersionHelper = mockStatic(BuildHelper.class); ) { omniNotes.when(OmniNotes::getAppContext).thenReturn(contextMock); - buildVersionHelper.when(() -> BuildVersionHelper.isAboveOrEqual(VERSION_CODES.N)).thenReturn(true); + buildVersionHelper.when(() -> BuildHelper.isAboveOrEqual(VERSION_CODES.N)).thenReturn(true); var info = NotesHelper.getNoteInfo(new Note());