Skip to content

Commit bd921f1

Browse files
authored
Merge pull request #93 from st235/feature/update_build_scripts
Update build scripts and dependencies
2 parents 5fe0e27 + b0d03d2 commit bd921f1

12 files changed

Lines changed: 75 additions & 87 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
working_directory: ~/code
55
docker:
66
# Android the primary container
7-
- image: circleci/android:api-25
7+
- image: cimg/android:2023.08
88
environment:
99
JVM_OPTS: -Xmx1024m
1010
steps:

app/build.gradle

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,43 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33

44
android {
5-
compileSdkVersion 33
5+
namespace 'github.com.st235.expandablebottombar'
6+
67
defaultConfig {
7-
applicationId "github.com.st235.expandablebottonbar"
8+
applicationId 'github.com.st235.expandablebottombar'
89
minSdkVersion 21
9-
targetSdkVersion 33
10+
targetSdkVersion 34
11+
compileSdk 34
1012
versionCode 1
1113
}
1214

15+
lint {
16+
baseline = file('lint-baseline.txt')
17+
}
18+
1319
buildTypes {
1420
release {
1521
minifyEnabled false
1622
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
1723
}
1824
}
1925
compileOptions {
20-
sourceCompatibility JavaVersion.VERSION_11
21-
targetCompatibility JavaVersion.VERSION_11
26+
sourceCompatibility JavaVersion.VERSION_17
27+
targetCompatibility JavaVersion.VERSION_17
2228
}
2329
}
2430

2531
dependencies {
2632
implementation project(':lib-expandablebottombar')
2733

28-
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10'
34+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22'
2935

30-
implementation 'androidx.appcompat:appcompat:1.5.1'
31-
implementation 'com.google.android.material:material:1.6.1'
36+
implementation 'androidx.appcompat:appcompat:1.6.1'
37+
implementation 'com.google.android.material:material:1.9.0'
3238
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
3339

34-
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
35-
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
40+
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.0'
41+
implementation 'androidx.navigation:navigation-ui-ktx:2.7.0'
3642

3743
implementation 'com.squareup.picasso:picasso:2.8'
3844
}

app/lint-baseline.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<issues format="6" by="lint 8.1.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.0)" variant="all" version="8.1.0">
3+
4+
<issue
5+
id="NotificationPermission"
6+
message="When targeting Android 13 or higher, posting a permission requires holding the `POST_NOTIFICATIONS` permission (usage from com.squareup.picasso.RemoteViewsAction.NotificationAction)">
7+
<location
8+
file="src/main/AndroidManifest.xml"/>
9+
</issue>
10+
11+
</issues>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.2.2'
9-
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
8+
classpath 'com.android.tools.build:gradle:8.1.0'
9+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22'
1010
}
1111
}
1212

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ android.useAndroidX=true
44

55
GROUP=com.github.st235
66

7-
VERSION_CODE=164
8-
VERSION_NAME=1.5.2
7+
VERSION_CODE=165
8+
VERSION_NAME=1.5.3
99

1010
POM_DESCRIPTION=A new way to improve navigation in your app.
1111
POM_URL=https://github.com/st235/ExpandableBottomBar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Jul 29 08:51:49 BST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

lib-expandablebottombar/build.gradle

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ apply plugin: 'kotlin-parcelize'
44
apply from: './maven.gradle'
55

66
android {
7-
compileSdkVersion 33
7+
namespace 'github.com.st235.lib_expandablebottombar'
88

99
defaultConfig {
1010
minSdkVersion 19
11-
targetSdkVersion 33
11+
targetSdkVersion 34
12+
compileSdk 34
1213
versionCode project.property('VERSION_CODE') as int
1314
versionName project.property('VERSION_NAME')
1415

15-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1617

1718
}
1819

@@ -33,22 +34,25 @@ android {
3334
}
3435
}
3536

37+
compileOptions {
38+
sourceCompatibility JavaVersion.VERSION_17
39+
targetCompatibility JavaVersion.VERSION_17
40+
}
3641
}
3742

3843
dependencies {
39-
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10'
44+
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22'
4045

41-
implementation 'androidx.appcompat:appcompat:1.5.1'
42-
implementation 'com.google.android.material:material:1.6.1'
46+
implementation 'androidx.appcompat:appcompat:1.6.1'
47+
implementation 'com.google.android.material:material:1.9.0'
4348
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
44-
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.2'
49+
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.0'
4550

4651
testImplementation 'junit:junit:4.13.2'
47-
testImplementation 'org.mockito:mockito-core:4.6.1'
48-
testImplementation 'org.mockito:mockito-inline:4.6.1'
52+
testImplementation 'org.mockito:mockito-core:5.3.1'
4953
testImplementation 'org.hamcrest:hamcrest-library:2.2'
50-
testImplementation 'androidx.test:core:1.4.0'
51-
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
54+
testImplementation 'androidx.test:core:1.5.0'
55+
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.1.0'
5256
testImplementation 'org.robolectric:robolectric:4.8.1'
5357

5458
}

lib-expandablebottombar/src/main/java/github/com/st235/lib_expandablebottombar/components/notifications/ExpandableBottomBarNotificationBadgeView.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ internal class ExpandableBottomBarNotificationBadgeView @JvmOverloads constructo
6464
viewBounds.set(0F, 0F, w.toFloat(), h.toFloat())
6565
}
6666

67-
override fun onDraw(canvas: Canvas?) {
67+
override fun onDraw(canvas: Canvas) {
6868
super.onDraw(canvas)
6969

70-
if (canvas != null) {
71-
badgeDrawer?.draw(paint, viewBounds, canvas)
72-
}
70+
badgeDrawer?.draw(paint, viewBounds, canvas)
7371
}
7472

7573
fun getState() = stateController.store(onSaveInstanceState())

lib-expandablebottombar/src/test/java/github/com/st235/expandablebottombar/MenuItemDescriptorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package github.com.st235.expandablebottombar
22

33
import android.content.Context
4-
import com.nhaarman.mockitokotlin2.mock
54
import github.com.st235.lib_expandablebottombar.MenuItemDescriptor
65
import org.junit.Test
76
import org.junit.runner.RunWith
87
import org.junit.runners.JUnit4
8+
import org.mockito.kotlin.mock
99

1010
@RunWith(JUnit4::class)
1111
class MenuItemDescriptorTest {
Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
package github.com.st235.expandablebottombar
22

33
import android.content.Context
4-
import android.content.res.ColorStateList
5-
import android.graphics.drawable.ColorStateListDrawable
64
import android.view.View
75
import androidx.test.core.app.ApplicationProvider
8-
import com.nhaarman.mockitokotlin2.anyOrNull
9-
import github.com.st235.lib_expandablebottombar.test.R
10-
import com.nhaarman.mockitokotlin2.mock
11-
import com.nhaarman.mockitokotlin2.whenever
126
import github.com.st235.lib_expandablebottombar.ExpandableBottomBar
137
import github.com.st235.lib_expandablebottombar.MenuItem
148
import github.com.st235.lib_expandablebottombar.MenuItemDescriptor
159
import github.com.st235.lib_expandablebottombar.MenuItemFactory
1610
import github.com.st235.lib_expandablebottombar.components.MenuItemView
17-
import github.com.st235.lib_expandablebottombar.utils.DrawableHelper
11+
import github.com.st235.lib_expandablebottombar.test.R
1812
import github.com.st235.lib_expandablebottombar.utils.StyleController
1913
import org.junit.Before
2014
import org.junit.Test
2115
import org.junit.runner.RunWith
22-
import org.mockito.Mockito.*
16+
import org.mockito.kotlin.anyOrNull
17+
import org.mockito.kotlin.eq
18+
import org.mockito.kotlin.mock
19+
import org.mockito.kotlin.times
20+
import org.mockito.kotlin.verify
21+
import org.mockito.kotlin.whenever
2322
import org.robolectric.RobolectricTestRunner
24-
import java.lang.reflect.Field
25-
import java.lang.reflect.Modifier
2623

2724
@RunWith(RobolectricTestRunner::class)
2825
class MenuItemFactoryTest {
@@ -31,8 +28,6 @@ class MenuItemFactoryTest {
3128
private val rootView = mock<ExpandableBottomBar>()
3229
private val styleController = mock<StyleController>()
3330
private val onItemClick = mock<(MenuItem, View) -> Unit>()
34-
private val colorStateList = mock<ColorStateList>()
35-
private val drawableHelper = mockObject(DrawableHelper::class.java)
3631

3732
private val itemVerticalPadding: Int = 54
3833
private val itemHorizontalPadding: Int = 61
@@ -80,7 +75,6 @@ class MenuItemFactoryTest {
8075
@Before
8176
fun setUp() {
8277
whenever(rootView.context).thenReturn(ApplicationProvider.getApplicationContext())
83-
doAnswer{ colorStateList }.whenever(drawableHelper).createSelectedUnselectedStateList(anyInt(), anyInt())
8478
}
8579

8680
@Test
@@ -89,8 +83,8 @@ class MenuItemFactoryTest {
8983

9084
verify(itemView, times(1)).id = menuItemDescriptorWithoutNotificationInfo.itemId
9185
verify(itemView, times(1)).setPadding(itemHorizontalPadding, itemVerticalPadding, itemHorizontalPadding, itemVerticalPadding)
92-
verify(itemView, times(1)).setIcon(menuItemDescriptorWithoutNotificationInfo.iconId, colorStateList)
93-
verify(itemView, times(1)).setText(menuItemDescriptorWithoutNotificationInfo.text, colorStateList)
86+
verify(itemView, times(1)).setIcon(eq(menuItemDescriptorWithoutNotificationInfo.iconId), anyOrNull())
87+
verify(itemView, times(1)).setText(eq(menuItemDescriptorWithoutNotificationInfo.text), anyOrNull())
9488
verify(itemView, times(1)).notificationBadgeBackgroundColor = globalNotificationBadgeColor
9589
verify(itemView, times(1)).notificationBadgeTextColor = globalNotificationBadgeTextColor
9690
}
@@ -101,41 +95,9 @@ class MenuItemFactoryTest {
10195

10296
verify(itemView, times(1)).id = menuItemDescriptorWithNotificationInfo.itemId
10397
verify(itemView, times(1)).setPadding(itemHorizontalPadding, itemVerticalPadding, itemHorizontalPadding, itemVerticalPadding)
104-
verify(itemView, times(1)).setIcon(menuItemDescriptorWithNotificationInfo.iconId, colorStateList)
105-
verify(itemView, times(1)).setText(menuItemDescriptorWithNotificationInfo.text, colorStateList)
98+
verify(itemView, times(1)).setIcon(eq(menuItemDescriptorWithNotificationInfo.iconId), anyOrNull())
99+
verify(itemView, times(1)).setText(eq(menuItemDescriptorWithNotificationInfo.text), anyOrNull())
106100
verify(itemView, times(1)).notificationBadgeBackgroundColor = menuItemDescriptorWithNotificationInfo.badgeBackgroundColor!!
107101
verify(itemView, times(1)).notificationBadgeTextColor = menuItemDescriptorWithNotificationInfo.badgeTextColor!!
108102
}
109-
110-
private fun <T> mockObject(clazz: Class<T>): T {
111-
val constructor = clazz.declaredConstructors.find { it.parameterCount == 0 }
112-
?: throw InstantiationException("class ${clazz.canonicalName} has no empty constructor, " +
113-
"is it really a Kotlin \"object\"?")
114-
115-
constructor.isAccessible = true
116-
117-
val mockedInstance = spy(constructor.newInstance() as T)
118-
119-
return replaceObjectInstance(clazz, mockedInstance)
120-
}
121-
122-
private fun <T> replaceObjectInstance(clazz: Class<T>, newInstance: T): T {
123-
124-
if (!clazz.declaredFields.any {
125-
it.name == "INSTANCE" && it.type == clazz && Modifier.isStatic(it.modifiers)
126-
}) {
127-
throw InstantiationException("clazz ${clazz.canonicalName} does not have a static " +
128-
"INSTANCE field, is it really a Kotlin \"object\"?")
129-
}
130-
131-
val instanceField = clazz.getDeclaredField("INSTANCE")
132-
val modifiersField = Field::class.java.getDeclaredField("modifiers")
133-
modifiersField.isAccessible = true
134-
modifiersField.setInt(instanceField, instanceField.modifiers and Modifier.FINAL.inv())
135-
136-
instanceField.isAccessible = true
137-
val originalInstance = instanceField.get(null) as T
138-
instanceField.set(null, newInstance)
139-
return newInstance
140-
}
141103
}

0 commit comments

Comments
 (0)