Skip to content

Commit

Permalink
initial API-34 support
Browse files Browse the repository at this point in the history
  • Loading branch information
VREMSoftwareDevelopment committed Jan 6, 2024
1 parent 23ca728 commit b732570
Show file tree
Hide file tree
Showing 52 changed files with 60 additions and 99 deletions.
19 changes: 9 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ apply plugin: "kotlin-allopen"
dependencies {
// Compile Build Dependencies
implementation fileTree(include: ["*.jar"], dir: "libs")
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.annotation:annotation:1.6.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.annotation:annotation:1.7.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.collection:collection-ktx:1.2.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.collection:collection-ktx:1.3.0'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
implementation 'androidx.media:media:1.6.0'
implementation 'androidx.media:media:1.7.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.jjoe64:graphview:4.2.2'
Expand All @@ -44,7 +44,7 @@ dependencies {
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.8.0'
testImplementation 'org.robolectric:robolectric:4.10.3'
testImplementation 'org.robolectric:robolectric:4.11.1'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation 'org.slf4j:slf4j-simple:2.0.10'
Expand All @@ -55,17 +55,16 @@ dependencies {

android {
namespace 'com.vrem.wifianalyzer'
compileSdk 33
buildToolsVersion '34.0.0'
compileSdk 34

sourceSets.each {
it.java.srcDirs += "src/$it.name/kotlin"
}

defaultConfig {
applicationId "com.vrem.wifianalyzer"
minSdkVersion 23
targetSdkVersion 33
minSdkVersion 24
targetSdkVersion 34
versionCode
versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
4 changes: 2 additions & 2 deletions app/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Build Properties
#Fri Jan 05 08:55:07 EST 2024
version_build=0
#Sat Jan 06 09:11:07 EST 2024
version_build=1
version_major=3
version_minor=1
version_patch=2
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/kotlin/com/vrem/util/BuildUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ fun buildMinVersionQ(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
fun buildMinVersionP(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P

fun buildVersionP(): Boolean = Build.VERSION.SDK_INT == Build.VERSION_CODES.P

fun buildMinVersionN(): Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
19 changes: 1 addition & 18 deletions app/src/main/kotlin/com/vrem/util/CompatUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,13 @@ import android.net.wifi.ScanResult
import android.os.Build
import java.util.*

fun Context.createContext(newLocale: Locale): Context =
if (buildMinVersionN()) {
createContextAndroidN(newLocale)
} else {
createContextLegacy(newLocale)
}

@TargetApi(Build.VERSION_CODES.N)
private fun Context.createContextAndroidN(newLocale: Locale): Context {
fun Context.createContext(newLocale: Locale): Context {
val resources: Resources = resources
val configuration: Configuration = resources.configuration
configuration.setLocale(newLocale)
return createConfigurationContext(configuration)
}

@Suppress("DEPRECATION")
private fun Context.createContextLegacy(newLocale: Locale): Context {
val resources: Resources = resources
val configuration: Configuration = resources.configuration
configuration.locale = newLocale
resources.updateConfiguration(configuration, resources.displayMetrics)
return this
}

fun Context.packageInfo(): PackageInfo =
if (buildMinVersionT()) {
packageInfoAndroidT()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MainActivity : AppCompatActivity(), NavigationMenuControl, OnSharedPrefere
screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
val mainContext = MainContext.INSTANCE
if (mainReload.shouldReload(mainContext.settings)) {
MainContext.INSTANCE.scannerService.stop()
Expand Down
21 changes: 1 addition & 20 deletions app/src/test/kotlin/com/vrem/util/CompatUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.robolectric.annotation.Config
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class CompatUtilsTest {

private val context: Context = mock()
Expand Down Expand Up @@ -94,25 +94,6 @@ class CompatUtilsTest {
verify(resources).configuration
}

@Test
@Config(sdk = [Build.VERSION_CODES.M])
@Suppress("DEPRECATION")
fun testCreateContextLegacy() {
// setup
whenever(context.resources).thenReturn(resources)
whenever(resources.configuration).thenReturn(configuration)
whenever(resources.displayMetrics).thenReturn(displayMetrics)
// execute
val actual: Context = context.createContext(newLocale)
// validate
assertEquals(context, actual)
assertEquals(newLocale, configuration.locale)
verify(resources).displayMetrics
verify(resources).updateConfiguration(configuration, displayMetrics)
verify(context).resources
verify(resources).configuration
}

@Test
fun testContextPackageInfo() {
// setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class MainActivityBackPressedTest {
private val mainActivity: MainActivity = mock()
private val menuItem: MenuItem = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import org.robolectric.Robolectric
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class MainActivityTest {
private val fixture = Robolectric.buildActivity(MainActivity::class.java).create().resume().get()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.robolectric.annotation.Config
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AboutFragment2Test {
@Suppress("unused")
private val mainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import java.text.SimpleDateFormat
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AboutFragmentTest {
@Suppress("unused")
private val mainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class NavigationGroupTest {
@Test
fun testNavigationGroup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class NavigationMenuControllerTest {
private val mainActivity = RobolectricUtil.INSTANCE.activity
private val fixture = mainActivity.navigationMenuController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class NavigationMenuTest {
@Test
fun testNavigationMenu() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class FilterOnTest {
private val mainActivity: MainActivity = mock()
private val optionMenu: OptionMenu = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class WiFiSwitchOnTest {
private val mainActivity = MainContextHelper.INSTANCE.mainActivity
private val settings = MainContextHelper.INSTANCE.settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class ExportItemTest {
private val export: Export = mock()
private val mainActivity: MainActivity = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class FragmentItemTest {
private val title = "title"
private val fragment: Fragment = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class NavigationItemsTest {
@Test
fun testFragmentItem() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class PortAuthorityItemTest {
private val portAuthority = "com.aaronjwood.portauthority"
private val portAuthorityFree = "$portAuthority.free"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class OptionActionTest {
@Suppress("unused")
private val mainActivity: MainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class ApplicationPermissionTest {
private val activity: Activity = mock()
private val permissionDialog: PermissionDialog = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class LocationPermissionTest {
private val activity: Activity = mock()
private val locationManager: LocationManager = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class PermissionDialogTest {
private val activity = RobolectricUtil.INSTANCE.activity
private val fixture = PermissionDialog(activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.robolectric.annotation.Config
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class CountryPreferenceTest {
private val mainActivity = RobolectricUtil.INSTANCE.activity
private val countries = findAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.robolectric.annotation.Config
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class LanguagePreferenceTest {
private val mainActivity = RobolectricUtil.INSTANCE.activity
private val languages = supportedLanguages()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class SettingsFragmentTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import org.robolectric.annotation.Config
import java.util.*

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class SettingsTest {
private val scanSpeedDefault = 5
private val graphYMultiplier = -10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class VendorAdapterTest {
private val vendorName1 = "N1"
private val vendorName2 = "N2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class VendorFragmentTest {
@Suppress("unused")
private val mainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class VendorServiceTest {
private val vendorName = "CISCO SYSTEMS INC"
private val macAddress = "00:23:AB:8C:DF:10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AccessPointDetailTest {
private val vendorName = "VendorName-VendorName-VendorName-VendorName-VendorName-VendorName"
private val mainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AccessPointPopupTest {
private val mainActivity = RobolectricUtil.INSTANCE.activity
private val fixture = AccessPointPopup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AccessPointsAdapterTest {
private val mainActivity = RobolectricUtil.INSTANCE.activity
private val accessPointsAdapterData: AccessPointsAdapterData = mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config

@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.TIRAMISU])
@Config(sdk = [Build.VERSION_CODES.UPSIDE_DOWN_CAKE])
class AccessPointsFragmentTest {
@Suppress("unused")
private val mainActivity = RobolectricUtil.INSTANCE.activity
Expand Down
Loading

0 comments on commit b732570

Please sign in to comment.