diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b237bb4..1269f9c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -9,52 +9,55 @@ on: jobs: lint: name: Spotless check - runs-on: ubuntu-18.04 + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v2 - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 11 + distribution: 'zulu' + java-version: 17 - name: spotless run: ./gradlew spotlessCheck api_check: name: API check - runs-on: ubuntu-18.04 + runs-on: macos-latest steps: - name: Check out code uses: actions/checkout@v2 - name: Set up JDK uses: actions/setup-java@v1 with: - java-version: 11 + distribution: 'zulu' + java-version: 17 - name: API check run: ./gradlew apiCheck build: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - - uses: actions/checkout@v2 - - - name: set up JDK - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Cache Gradle and wrapper - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Make Gradle executable - run: chmod +x ./gradlew - - - name: Build with Gradle - run: ./gradlew build + - uses: actions/checkout@v2 + + - name: set up JDK + uses: actions/setup-java@v1 + with: + distribution: 'zulu' + java-version: 17 + + - name: Cache Gradle and wrapper + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Make Gradle executable + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml deleted file mode 100644 index 75d6b46..0000000 --- a/.github/workflows/publish-snapshot.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish Snapshot builds - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - publish: - name: Snapshot build and publish - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 11 - - name: Release build - run: ./gradlew assemble --scan - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar --scan - - name: Publish to MavenCentral - run: ./gradlew publishReleasePublicationToSonatypeRepository --scan - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SNAPSHOT: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 96f97a1..ea6928e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,30 +2,35 @@ name: Publish on: release: - types: [released] + types: [ released ] + workflow_dispatch: jobs: publish: - name: Release build and publish - runs-on: ubuntu-latest + name: Snapshot build and publish + runs-on: macos-latest steps: - name: Check out code - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v3.1.0 + + - name: Set up JDK 17 + uses: actions/setup-java@v3.5.1 with: - distribution: adopt - java-version: 11 + distribution: 'zulu' + java-version: 17 + + - name: Grant Permission to Execute Gradle + run: chmod +x gradlew + - name: Release build run: ./gradlew assemble --scan - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar --scan + - name: Publish to MavenCentral - run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository --scan + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index e4d7549..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -///* -// * Designed and developed by 2021 skydoves (Jaewoong Eum) -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ - -import com.skydoves.bindables.Configuration -import com.skydoves.bindables.Dependencies - -plugins { - id "com.android.application" - id "org.jetbrains.kotlin.android" - id "kotlin-kapt" - id "kotlin-parcelize" - id "dagger.hilt.android.plugin" -} - -android { - compileSdkVersion Configuration.compileSdk - defaultConfig { - applicationId "com.skydoves.bindablesdemo" - minSdkVersion Configuration.minSdk - targetSdkVersion Configuration.targetSdk - versionCode Configuration.versionCode - versionName Configuration.versionName - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } - - buildFeatures { - dataBinding true - } -} - -dependencies { - implementation project(":bindables") - - implementation Dependencies.material - implementation Dependencies.fragment - implementation Dependencies.glide - implementation Dependencies.hilt - kapt Dependencies.hiltCompiler - implementation Dependencies.whatIf -} - -apply from: "$rootDir/spotless/spotless.gradle" \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..85308a6 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,66 @@ +///* +// * Designed and developed by 2021 skydoves (Jaewoong Eum) +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ + +import com.skydoves.bindables.Configuration + +plugins { + id(libs.plugins.android.application.get().pluginId) + id(libs.plugins.kotlin.android.get().pluginId) + id(libs.plugins.kotlin.parcelize.get().pluginId) + id(libs.plugins.kotlin.kapt.get().pluginId) + id(libs.plugins.ksp.get().pluginId) + id(libs.plugins.hilt.plugin.get().pluginId) +} + +android { + namespace = "com.skydoves.bindablesdemo" + compileSdk = Configuration.compileSdk + defaultConfig { + applicationId = "com.skydoves.bindablesdemo" + minSdk = Configuration.minSdk + targetSdk = Configuration.targetSdk + versionCode = Configuration.versionCode + versionName = Configuration.versionName + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = "11" + } + + buildFeatures { + dataBinding = true + } +} + +dependencies { + implementation(project(":bindables")) + + implementation(libs.hilt.android) + implementation(libs.androidx.appcompat) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + ksp(libs.hilt.compiler) + + implementation(libs.androidx.material) + implementation(libs.androidx.fragment) + implementation(libs.glide) + implementation(libs.whatif) +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3e03013..fa889d7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,21 +1,20 @@ - + + + android:exported="true" + android:theme="@style/AppTheme"> diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/MainActivity.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/MainActivity.kt index 23a0145..82b6271 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/MainActivity.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/MainActivity.kt @@ -43,17 +43,17 @@ class MainActivity : BindingActivity(R.layout.activity_main override fun onPageScrolled( position: Int, positionOffset: Float, - positionOffsetPixels: Int + positionOffsetPixels: Int, ) = Unit override fun onPageSelected(position: Int) { binding.mainBottomNavigation.menu.getItem(position).isChecked = true } - } + }, ) } - binding.mainBottomNavigation.setOnNavigationItemSelectedListener { + binding.mainBottomNavigation.setOnItemSelectedListener { when (it.itemId) { R.id.action_one -> binding.mainViewpager.currentItem = 0 R.id.action_two -> binding.mainViewpager.currentItem = 1 diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/MockUtil.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/MockUtil.kt index a3e481f..4a57b4e 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/MockUtil.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/MockUtil.kt @@ -26,58 +26,187 @@ object MockUtil { "Frozen II", "2019", "1 h 43 min", - "Frozen II, also known as Frozen 2, is a 2019 American 3D computer-animated musical fantasy film produced by Walt Disney Animation Studios. The 58th animated film produced by the studio, it is the sequel to the 2013 film Frozen and features the return of directors Chris Buck and Jennifer Lee, producer Peter Del Vecho, songwriters Kristen Anderson-Lopez and Robert Lopez, and composer Christophe Beck. Lee also returns as screenwriter, penning the screenplay from a story by her, Buck, Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron Howard executive-produced the film.[a][1] Veteran voice cast Kristen Bell, Idina Menzel, Josh Gad, Jonathan Groff, and Ciarán Hinds return as their previous characters, and they are joined by newcomers Sterling K. Brown, Evan Rachel Wood, Alfred Molina, Martha Plimpton, Jason Ritter, Rachel Matthews, and Jeremy Sisto.", - "https://user-images.githubusercontent.com/24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg" + "Frozen II, also known as Frozen 2, is a 2019 American 3D computer-animated " + + "musical fantasy film produced by Walt Disney Animation Studios. " + + "The 58th animated film produced by the studio, it is the sequel to the 2013 film " + + "Frozen " + + "and features the return of directors Chris Buck and Jennifer Lee, producer Peter Del " + + "Vecho, songwriters Kristen Anderson-Lopez and Robert Lopez, and composer Christophe " + + "Beck. Lee also returns as screenwriter, penning the screenplay from a story by her, " + + "Buck, Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron Howard " + + "executive-produced " + + "the film.[a][1] Veteran voice cast Kristen Bell, Idina Menzel, Josh Gad, " + + "Jonathan Groff, " + + "and Ciarán Hinds return as their previous characters, and they are joined by" + + " newcomers " + + "Sterling K. Brown, Evan Rachel Wood, Alfred Molina, Martha Plimpton, Jason Ritter, " + + "Rachel Matthews, and Jeremy Sisto.", + "https://user-images.githubusercontent.com/" + + "24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg", + "https://media2.giphy.com/media/aQYR1p8saOQla/" + + "giphy.gif?cid=ecf05e4701sln9u63lr3z17lh5f3n3h3owrk54zh1183hqmi&rid=giphy.gif&ct=g", ), Poster( "Toy Story 4", "2019", "1 h 40 min", - "Toy Story 4 is a 2019 American computer-animated comedy film produced by Pixar Animation Studios for Walt Disney Pictures. It is the fourth installment in Pixar's Toy Story series and the sequel to Toy Story 3 (2010). It was directed by Josh Cooley (in his feature directorial debut) from a screenplay by Andrew Stanton and Stephany Folsom; the three also conceived the story alongside John Lasseter, Rashida Jones, Will McCormack, Valerie LaPointe, and Martin Hynes.[2] Tom Hanks, Tim Allen, Annie Potts, Joan Cusack, Wallace Shawn, John Ratzenberger, Estelle Harris, Blake Clark, Bonnie Hunt, Jeff Garlin, Kristen Schaal and Timothy Dalton reprise their character roles from the first three films. They are joined by Tony Hale, Keegan-Michael Key, Jordan Peele, Christina Hendricks, Keanu Reeves, and Ally Maki, who voice the new characters. The film also posthumously features Don Rickles, who appears through use of archived voice recordings.", - "https://user-images.githubusercontent.com/24237865/75087934-5a53dc00-553e-11ea-94f1-494c1c68a574.jpg" + "Toy Story 4 is a 2019 American computer-animated comedy film " + + "produced by Pixar" + + " Animation Studios for Walt Disney Pictures. It is the fourth installment" + + " in Pixar's Toy" + + " Story series and the sequel to Toy Story 3 (2010). It was directed by Josh " + + "Cooley (in " + + "his feature directorial debut) from a screenplay by Andrew Stanton and Stephany " + + "Folsom;" + + " the three also conceived the story alongside John Lasseter, Rashida Jones, Will " + + "McCormack, Valerie LaPointe, and Martin Hynes.[2] Tom Hanks, Tim Allen, Annie Potts, " + + "Joan Cusack, Wallace Shawn, John Ratzenberger, Estelle Harris, Blake Clark," + + " Bonnie Hunt," + + " Jeff Garlin, Kristen Schaal and Timothy Dalton reprise their character roles " + + "from the" + + " first three films. They are joined by Tony Hale, Keegan-Michael Key, " + + "Jordan Peele, " + + "Christina Hendricks, Keanu Reeves, and Ally Maki, who voice the new characters. " + + "The film also posthumously features Don Rickles, who appears through use of " + + "archived voice recordings.", + "https://user-images.githubusercontent.com/24237865/" + + "75087934-5a53dc00-553e-11ea-94f1-494c1c68a574.jpg", + "https://media0.giphy.com/media/sgswHaZw5yklq/" + + "giphy.gif?cid=ecf05e473wd424bhp29tw5i4clg60djlvz4aridyzgxua96q&rid=giphy.gif&ct=g", ), Poster( "Zootopia", "2016", "1 h 50 min", - "Zootopia (titled Zootropolis in the UK and Ireland)[6] is a 2016 American 3D computer-animated comedy film[7] produced by Walt Disney Animation Studios and released by Walt Disney Pictures. It is the 55th Disney animated feature film, directed by Byron Howard and Rich Moore, co-directed by Jared Bush, and stars the voices of Ginnifer Goodwin, Jason Bateman, Idris Elba, Jenny Slate, Nate Torrence, Bonnie Hunt, Don Lake, Tommy Chong, J. K. Simmons, Octavia Spencer, Alan Tudyk, and Shakira. It details the unlikely partnership between a rabbit police officer and a red fox con artist, as they uncover a criminal conspiracy involving the disappearance of predators.", - "https://user-images.githubusercontent.com/24237865/75087937-5c1d9f80-553e-11ea-8fc9-a7e520addde0.jpg" + "Zootopia (titled Zootropolis in the UK and Ireland)[6] is a 2016 American 3D " + + "computer-animated comedy film[7] produced by Walt Disney Animation Studios" + + " and released" + + " by Walt Disney Pictures. It is the 55th Disney animated feature film, directed " + + "by Byron " + + "Howard and Rich Moore, co-directed by Jared Bush, and stars the voices of Ginnifer " + + "Goodwin, Jason Bateman, Idris Elba, Jenny Slate, Nate Torrence, Bonnie Hunt, " + + "Don Lake," + + " Tommy Chong, J. K. Simmons, Octavia Spencer, Alan Tudyk, and Shakira. It details " + + "the" + + " unlikely partnership between a rabbit police officer and a red fox con artist, " + + "as they uncover a criminal conspiracy involving the disappearance of predators.", + "https://user-images.githubusercontent.com/" + + "24237865/75087937-5c1d9f80-553e-11ea-8fc9-a7e520addde0.jpg", + "https://media0.giphy.com/media/mHcEcam5FtKQE/" + + "giphy.gif?cid=ecf05e473an8u0cwv7mao8mm6hxb8hsf62l34p0zblcfmmwp&rid=giphy.gif&ct=g", ), Poster( "Finding Dory", "2016", "1 h 45 min", - "Finding Dory is a 2016 American 3D computer-animated adventure film produced by Pixar Animation Studios and released by Walt Disney Pictures. Directed by Andrew Stanton with co-direction by Angus MacLane,[5][6] the screenplay was written by Stanton and Victoria Strouse.[7] The film is a sequel/spinoff[8][9] to 2003's Finding Nemo and features the returning voices of Ellen DeGeneres and Albert Brooks, with Hayden Rolence (replacing Alexander Gould), Ed O'Neill, Kaitlin Olson, Ty Burrell, Diane Keaton, and Eugene Levy joining the cast. The film focuses on the amnesiac fish Dory, who journeys to be reunited with her parents.[10]", - "https://user-images.githubusercontent.com/24237865/75088201-0ba84100-5542-11ea-8587-0c2823b05351.jpg" + "Finding Dory is a 2016 American 3D computer-animated adventure film" + + " produced by" + + " Pixar Animation Studios and released by Walt Disney Pictures. Directed by" + + " Andrew Stanton" + + " with co-direction by Angus MacLane,[5][6] the screenplay was written by Stanton and " + + "Victoria Strouse.[7] The film is a sequel/spinoff[8][9] to 2003's Finding Nemo and " + + "features the returning voices of Ellen DeGeneres and Albert Brooks, with" + + " Hayden Rolence " + + "(replacing Alexander Gould), Ed O'Neill, Kaitlin Olson, Ty Burrell, Diane Keaton, " + + "and Eugene Levy joining the cast. The film focuses on the amnesiac fish Dory, who" + + " journeys to be reunited with her parents.[10]", + "https://user-images.githubusercontent.com/" + + "24237865/75088201-0ba84100-5542-11ea-8587-0c2823b05351.jpg", + "https://media1.giphy.com/media/yUt0xuAPgFpSM/" + + "giphy.gif?cid=ecf05e47xl77vojzdfyfsq05jj6lok315g8vdhbwpedj1ja6&rid=giphy.gif&ct=g", ), Poster( - "Frozen II", + "Bambi", "2019", "1 h 43 min", - "Frozen II, also known as Frozen 2, is a 2019 American 3D computer-animated musical fantasy film produced by Walt Disney Animation Studios. The 58th animated film produced by the studio, it is the sequel to the 2013 film Frozen and features the return of directors Chris Buck and Jennifer Lee, producer Peter Del Vecho, songwriters Kristen Anderson-Lopez and Robert Lopez, and composer Christophe Beck. Lee also returns as screenwriter, penning the screenplay from a story by her, Buck, Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron Howard executive-produced the film.[a][1] Veteran voice cast Kristen Bell, Idina Menzel, Josh Gad, Jonathan Groff, and Ciarán Hinds return as their previous characters, and they are joined by newcomers Sterling K. Brown, Evan Rachel Wood, Alfred Molina, Martha Plimpton, Jason Ritter, Rachel Matthews, and Jeremy Sisto.", - "https://user-images.githubusercontent.com/24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg" + "Frozen II, also known as Frozen 2, is a 2019 American 3D computer-animated " + + "musical fantasy film produced by Walt Disney Animation Studios. The 58th animated " + + "film produced by the studio, it is the sequel to the 2013 film Frozen and features " + + "the return of directors Chris Buck and Jennifer Lee, producer Peter Del Vecho, " + + "songwriters Kristen Anderson-Lopez and Robert Lopez, and composer Christophe Beck. " + + "Lee also returns as screenwriter, penning the screenplay from a story by her, Buck, " + + "Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron Howard executive-produced " + + "the film.[a][1] Veteran voice cast Kristen Bell, Idina Menzel, Josh Gad, " + + "Jonathan Groff," + + " and Ciarán Hinds return as their previous characters, and they are joined by" + + " newcomers " + + "Sterling K. Brown, Evan Rachel Wood, Alfred Molina, Martha Plimpton, Jason Ritter, " + + "Rachel Matthews, and Jeremy Sisto.", + "https://user-images.githubusercontent.com/24237865/" + + "75087801-a56cef80-553c-11ea-9ae5-cf203c6ea8c2.jpg", + "https://media3.giphy.com/media/52SvdzXWPjdOo/" + + "giphy.gif?cid=ecf05e47uuv6gjcgscfqe3ec5bc6edasuv2e36278j870i4n&rid=giphy.gif&ct=g", ), Poster( - "Toy Story 4", + "Coco", "2019", "1 h 40 min", - "Toy Story 4 is a 2019 American computer-animated comedy film produced by Pixar Animation Studios for Walt Disney Pictures. It is the fourth installment in Pixar's Toy Story series and the sequel to Toy Story 3 (2010). It was directed by Josh Cooley (in his feature directorial debut) from a screenplay by Andrew Stanton and Stephany Folsom; the three also conceived the story alongside John Lasseter, Rashida Jones, Will McCormack, Valerie LaPointe, and Martin Hynes.[2] Tom Hanks, Tim Allen, Annie Potts, Joan Cusack, Wallace Shawn, John Ratzenberger, Estelle Harris, Blake Clark, Bonnie Hunt, Jeff Garlin, Kristen Schaal and Timothy Dalton reprise their character roles from the first three films. They are joined by Tony Hale, Keegan-Michael Key, Jordan Peele, Christina Hendricks, Keanu Reeves, and Ally Maki, who voice the new characters. The film also posthumously features Don Rickles, who appears through use of archived voice recordings.", - "https://user-images.githubusercontent.com/24237865/75087934-5a53dc00-553e-11ea-94f1-494c1c68a574.jpg" + "Toy Story 4 is a 2019 American computer-animated comedy film produced" + + " by Pixar" + + " Animation Studios for Walt Disney Pictures. It is the fourth installment" + + "in Pixar's " + + "Toy Story series and the sequel to Toy Story 3 (2010). It was directed by " + + "Josh Cooley " + + "(in his feature directorial debut) from a screenplay by Andrew Stanton and " + + "Stephany " + + "Folsom; the three also conceived the story alongside John Lasseter, Rashida" + + " Jones, " + + "Will McCormack, Valerie LaPointe, and Martin Hynes.[2] Tom Hanks, Tim Allen, " + + "Annie Potts," + + " Joan Cusack, Wallace Shawn, John Ratzenberger, Estelle Harris, Blake Clark, " + + "Bonnie Hunt, " + + "Jeff Garlin, Kristen Schaal and Timothy Dalton reprise their character roles " + + "from the" + + " first three films. They are joined by Tony Hale, Keegan-Michael Key, Jordan " + + "Peele, " + + "Christina Hendricks, Keanu Reeves, and Ally Maki, who voice the new characters. " + + "The film also posthumously features Don Rickles, who appears through use of archived " + + "voice recordings.", + "https://user-images.githubusercontent.com/" + + "24237865/75088277-dea85e00-5542-11ea-961b-7f0942cd8f47.jpg", + "https://media3.giphy.com/media/KFcACgXTXkzKAGDZ05/" + + "giphy.gif?cid=ecf05e47ku475ue16rb920a6ykl6roi9l0odvqo00flmikvs&rid=giphy.gif&ct=g", ), Poster( - "Zootopia", + "Alice Through the Looking Glass", "2016", - "1 h 50 min", - "Zootopia (titled Zootropolis in the UK and Ireland)[6] is a 2016 American 3D computer-animated comedy film[7] produced by Walt Disney Animation Studios and released by Walt Disney Pictures. It is the 55th Disney animated feature film, directed by Byron Howard and Rich Moore, co-directed by Jared Bush, and stars the voices of Ginnifer Goodwin, Jason Bateman, Idris Elba, Jenny Slate, Nate Torrence, Bonnie Hunt, Don Lake, Tommy Chong, J. K. Simmons, Octavia Spencer, Alan Tudyk, and Shakira. It details the unlikely partnership between a rabbit police officer and a red fox con artist, as they uncover a criminal conspiracy involving the disappearance of predators.", - "https://user-images.githubusercontent.com/24237865/75087937-5c1d9f80-553e-11ea-8fc9-a7e520addde0.jpg" + "1 h 45 min", + "Finding Dory is a 2016 American 3D computer-animated adventure film " + + "produced" + + " by Pixar Animation Studios and released by Walt Disney Pictures. Directed by " + + "Andrew " + + "Stanton with co-direction by Angus MacLane,[5][6] the screenplay was written by " + + "Stanton" + + " and Victoria Strouse.[7] The film is a sequel/spinoff[8][9] to 2003's Finding" + + " Nemo and " + + "features the returning voices of Ellen DeGeneres and Albert Brooks, with Hayden" + + " Rolence " + + "(replacing Alexander Gould), Ed O'Neill, Kaitlin Olson, Ty Burrell, Diane Keaton, " + + "and Eugene Levy joining the cast. The film focuses on the amnesiac fish Dory, " + + "who journeys to be reunited with her parents.[10]", + "https://user-images.githubusercontent.com/24237865/" + + "75088202-0d720480-5542-11ea-85f3-8726e69a9a26.jpg", + "https://media3.giphy.com/media/Y713FQ3mfWDWU/" + + "giphy.gif?cid=ecf05e47ksc6l561mp74ljpctaox6u0hkzv0pzap9kt9653g&rid=giphy.gif&ct=g", ), Poster( - "Finding Dory", + "The Lion King", "2016", - "1 h 45 min", - "Finding Dory is a 2016 American 3D computer-animated adventure film produced by Pixar Animation Studios and released by Walt Disney Pictures. Directed by Andrew Stanton with co-direction by Angus MacLane,[5][6] the screenplay was written by Stanton and Victoria Strouse.[7] The film is a sequel/spinoff[8][9] to 2003's Finding Nemo and features the returning voices of Ellen DeGeneres and Albert Brooks, with Hayden Rolence (replacing Alexander Gould), Ed O'Neill, Kaitlin Olson, Ty Burrell, Diane Keaton, and Eugene Levy joining the cast. The film focuses on the amnesiac fish Dory, who journeys to be reunited with her parents.[10]", - "https://user-images.githubusercontent.com/24237865/75088201-0ba84100-5542-11ea-8587-0c2823b05351.jpg" - ) + "1 h 50 min", + "Zootopia (titled Zootropolis in the UK and Ireland)[6] is a 2016 American " + + "3D computer-animated comedy film[7] produced by Walt Disney Animation Studios and " + + "released by Walt Disney Pictures. It is the 55th Disney animated feature film, " + + "directed by Byron Howard and Rich Moore, co-directed by Jared Bush, and stars the " + + "voices of Ginnifer Goodwin, Jason Bateman, Idris Elba, Jenny Slate, Nate Torrence," + + " Bonnie Hunt, Don Lake, Tommy Chong, J. K. Simmons, Octavia Spencer, Alan Tudyk, " + + "and Shakira. It details the unlikely partnership between a rabbit police officer" + + " and a red fox con artist, as they uncover a criminal conspiracy involving the" + + " disappearance of predators.", + "https://user-images.githubusercontent.com/24237865/" + + "75087937-5c1d9f80-553e-11ea-8fc9-a7e520addde0.jpg", + "https://media3.giphy.com/media/26tPpStnC0XthM19u/" + + "giphy.gif?cid=ecf05e471xnhh2e78pvhmgegmc1y27f06qcfvbg326p98gup&rid=giphy.gif&ct=g", + ), ) } @@ -86,8 +215,22 @@ object MockUtil { "Frozen II", "2019", "1 h 43 min", - "Frozen II, also known as Frozen 2, is a 2019 American 3D computer-animated musical fantasy film produced by Walt Disney Animation Studios. The 58th animated film produced by the studio, it is the sequel to the 2013 film Frozen and features the return of directors Chris Buck and Jennifer Lee, producer Peter Del Vecho, songwriters Kristen Anderson-Lopez and Robert Lopez, and composer Christophe Beck. Lee also returns as screenwriter, penning the screenplay from a story by her, Buck, Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron Howard executive-produced the film.[a][1] Veteran voice cast Kristen Bell, Idina Menzel, Josh Gad, Jonathan Groff, and Ciarán Hinds return as their previous characters, and they are joined by newcomers Sterling K. Brown, Evan Rachel Wood, Alfred Molina, Martha Plimpton, Jason Ritter, Rachel Matthews, and Jeremy Sisto.", - "https://user-images.githubusercontent.com/24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg" + "Frozen II, also known as Frozen 2, is a 2019 American" + + " 3D computer-animated musical fantasy film produced by Walt Disney Animation Studios." + + " The 58th animated film produced by the studio, it is the sequel to the 2013 film" + + " Frozen and features the return of directors Chris Buck and Jennifer Lee, producer " + + "Peter Del Vecho, songwriters Kristen Anderson-Lopez and Robert Lopez, and composer " + + "Christophe Beck. Lee also returns as screenwriter, penning the screenplay from a " + + "story by her, Buck, Marc E. Smith, Anderson-Lopez, and Lopez,[2] while Byron " + + "Howard executive-produced the film.[a][1] Veteran voice cast Kristen Bell," + + " Idina Menzel, Josh Gad, Jonathan Groff, and Ciarán Hinds return as their previous" + + " characters, and they are joined by newcomers Sterling K. Brown, Evan Rachel Wood, " + + "Alfred Molina, Martha Plimpton, Jason Ritter, Rachel Matthews, and Jeremy Sisto.", + "https://user-images.githubusercontent.com/24237865/" + + "75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg", + "https://media2.giphy.com/media/" + + "aQYR1p8saOQla/" + + "giphy.gif?cid=ecf05e4701sln9u63lr3z17lh5f3n3h3owrk54zh1183hqmi&rid=giphy.gif&ct=g", ) } } diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/HomeFragment.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/HomeFragment.kt index 337c9aa..2f1da1e 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/HomeFragment.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/HomeFragment.kt @@ -34,7 +34,7 @@ class HomeFragment : BindingFragment(R.layout.fragment_home override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { super.onCreateView(inflater, container, savedInstanceState) return binding { diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/LibraryFragment.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/LibraryFragment.kt index 4af1319..50dc24c 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/LibraryFragment.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/LibraryFragment.kt @@ -34,7 +34,7 @@ class LibraryFragment : BindingFragment(R.layout.fragmen override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { super.onCreateView(inflater, container, savedInstanceState) return binding { diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/RadioFragment.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/RadioFragment.kt index 5972d18..35fac03 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/RadioFragment.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/fragments/RadioFragment.kt @@ -34,7 +34,7 @@ class RadioFragment : BindingFragment(R.layout.fragment_ra override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { super.onCreateView(inflater, container, savedInstanceState) return binding { diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/Poster.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/Poster.kt index 6ccb26b..0036873 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/Poster.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/Poster.kt @@ -25,5 +25,6 @@ data class Poster( val release: String, val playtime: String, val description: String, - val poster: String + val poster: String, + val gif: String, ) : Parcelable diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterCircleAdapter.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterCircleAdapter.kt index 67d4adb..5371243 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterCircleAdapter.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterCircleAdapter.kt @@ -23,7 +23,9 @@ import com.skydoves.bindables.binding import com.skydoves.bindablesdemo.R import com.skydoves.bindablesdemo.databinding.ItemPosterCircleBinding -class PosterCircleAdapter : BindingListAdapter(PosterDiffUtil()) { +class PosterCircleAdapter : BindingListAdapter( + PosterDiffUtil(), +) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PosterViewHolder { val binding = parent.binding(R.layout.item_poster_circle) diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterDiffUtil.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterDiffUtil.kt index 6096a46..eb61b3d 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterDiffUtil.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterDiffUtil.kt @@ -16,13 +16,17 @@ package com.skydoves.bindablesdemo.recycler +import android.annotation.SuppressLint import androidx.recyclerview.widget.DiffUtil class PosterDiffUtil : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: T, newItem: T): Boolean = - oldItem.hashCode() == newItem.hashCode() + override fun areItemsTheSame(oldItem: T & Any, newItem: T & Any): Boolean { + return oldItem.hashCode() == newItem.hashCode() + } - override fun areContentsTheSame(oldItem: T, newItem: T): Boolean = - oldItem.hashCode() == newItem.hashCode() + @SuppressLint("DiffUtilEquals") + override fun areContentsTheSame(oldItem: T & Any, newItem: T & Any): Boolean { + return oldItem == newItem + } } diff --git a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterLineAdapter.kt b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterLineAdapter.kt index 0b638c6..7741d3b 100644 --- a/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterLineAdapter.kt +++ b/app/src/main/kotlin/com/skydoves/bindablesdemo/recycler/PosterLineAdapter.kt @@ -23,7 +23,9 @@ import com.skydoves.bindables.binding import com.skydoves.bindablesdemo.R import com.skydoves.bindablesdemo.databinding.ItemPosterLineBinding -class PosterLineAdapter : BindingListAdapter(PosterDiffUtil()) { +class PosterLineAdapter : BindingListAdapter( + PosterDiffUtil(), +) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PosterViewHolder { val binding = parent.binding(R.layout.item_poster_line) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b23a301..c19ccf4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ - BindablesDemo - Home - Library - Radio - Description - There are no posters. 😅 + BindablesDemo + Home + Library + Radio + Description + There are no posters. 😅 \ No newline at end of file diff --git a/bindables/build.gradle b/bindables/build.gradle deleted file mode 100644 index 098c21a..0000000 --- a/bindables/build.gradle +++ /dev/null @@ -1,78 +0,0 @@ -///* -// * Designed and developed by 2021 skydoves (Jaewoong Eum) -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ - -import com.skydoves.bindables.Configuration -import com.skydoves.bindables.Dependencies - -plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-kapt' - id 'org.jetbrains.dokka' - id 'binary-compatibility-validator' -} - -ext { - PUBLISH_GROUP_ID = Configuration.artifactGroup - PUBLISH_ARTIFACT_ID = 'bindables' - PUBLISH_VERSION = rootVersionName -} - -apply from: "${rootDir}/scripts/publish-module.gradle" - -android { - compileSdkVersion Configuration.compileSdk - defaultConfig { - minSdkVersion Configuration.minSdk - targetSdkVersion Configuration.targetSdk - versionCode Configuration.versionCode - versionName Configuration.versionName - consumerProguardFiles "consumer-rules.pro" - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - dataBinding true - } -} - -apiValidation { - ignoredPackages += [ - "com/skydoves/bindables/databinding", - ] - nonPublicMarkers += [ - "kotlin.PublishedApi", - ] -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { - kotlinOptions.freeCompilerArgs += ["-Xexplicit-api=strict"] -} - -dependencies { - implementation Dependencies.kotlinReflect - implementation Dependencies.material - implementation Dependencies.appcompat - api Dependencies.viewModelKtx - api Dependencies.viewModelSavedState -} - -apply from: "$rootDir/spotless/spotless.gradle" \ No newline at end of file diff --git a/bindables/build.gradle.kts b/bindables/build.gradle.kts new file mode 100644 index 0000000..0849f23 --- /dev/null +++ b/bindables/build.gradle.kts @@ -0,0 +1,78 @@ +///* +// * Designed and developed by 2021 skydoves (Jaewoong Eum) +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ + +import com.skydoves.bindables.Configuration + +plugins { + id(libs.plugins.android.library.get().pluginId) + id(libs.plugins.kotlin.android.get().pluginId) + id(libs.plugins.kotlin.kapt.get().pluginId) + id(libs.plugins.kotlin.parcelize.get().pluginId) + id(libs.plugins.kotlin.binary.compatibility.get().pluginId) + id(libs.plugins.nexus.plugin.get().pluginId) +} + +apply(from = "${rootDir}/scripts/publish-module.gradle.kts") + +mavenPublishing { + val artifactId = "bindables" + coordinates( + Configuration.artifactGroup, + artifactId, + rootProject.extra.get("libVersion").toString() + ) + + pom { + name.set(artifactId) + description.set("Android DataBinding kit for notifying data changes to UI layers with MVVM architecture.") + } +} + +android { + compileSdk = Configuration.compileSdk + namespace = "com.skydoves.bindables" + defaultConfig { + minSdk = Configuration.minSdk + //consumerProguardFiles("consumer-rules.pro") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = "11" + freeCompilerArgs += listOf("-Xexplicit-api=strict") + } + + buildFeatures { + dataBinding = true + } +} + +apiValidation { + ignoredPackages.add("com/skydoves/bindables/databinding") + nonPublicMarkers.add("kotlin.PublishedApi") +} + +dependencies { + implementation(libs.kotlin.reflect) + implementation(libs.androidx.material) + + api(libs.androidx.lifecycle.viewmodel.ktx) + api(libs.androidx.lifecycle.viewmodel.savedstate) +} \ No newline at end of file diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingActivity.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingActivity.kt index a773dc3..d69d89c 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingActivity.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingActivity.kt @@ -33,7 +33,7 @@ import androidx.databinding.ViewDataBinding * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingActivity constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : AppCompatActivity() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingBottomSheetDialogFragment.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingBottomSheetDialogFragment.kt index 53abc49..9def286 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingBottomSheetDialogFragment.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingBottomSheetDialogFragment.kt @@ -37,7 +37,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingBottomSheetDialogFragment constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : BottomSheetDialogFragment() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ @@ -53,7 +53,8 @@ public abstract class BindingBottomSheetDialogFragment cons @BindingOnly protected val binding: T get() = checkNotNull(_binding) { - "BottomSheetDialogFragment $this binding cannot be accessed before onCreateView() or after onDestroyView()" + "BottomSheetDialogFragment $this binding cannot be accessed before " + + "onCreateView() or after onDestroyView()" } /** @@ -73,10 +74,12 @@ public abstract class BindingBottomSheetDialogFragment cons override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { _binding = - DataBindingUtil.inflate(inflater, contentLayoutId, container, false, bindingComponent) + DataBindingUtil.inflate( + inflater, contentLayoutId, container, false, bindingComponent, + ) return binding.root } diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingComponentActivity.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingComponentActivity.kt index 0fc6541..994ab23 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingComponentActivity.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingComponentActivity.kt @@ -33,7 +33,7 @@ import androidx.databinding.ViewDataBinding * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingComponentActivity constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : ComponentActivity() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingDialogFragment.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingDialogFragment.kt index 527fe70..af6f84e 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingDialogFragment.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingDialogFragment.kt @@ -37,7 +37,7 @@ import androidx.fragment.app.DialogFragment * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingDialogFragment constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : DialogFragment() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ @@ -53,7 +53,8 @@ public abstract class BindingDialogFragment constructor( @BindingOnly protected val binding: T get() = checkNotNull(_binding) { - "DialogFragment $this binding cannot be accessed before onCreateView() or after onDestroyView()" + "DialogFragment $this binding cannot be accessed before " + + "onCreateView() or after onDestroyView()" } /** @@ -73,10 +74,12 @@ public abstract class BindingDialogFragment constructor( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { _binding = - DataBindingUtil.inflate(inflater, contentLayoutId, container, false, bindingComponent) + DataBindingUtil.inflate( + inflater, contentLayoutId, container, false, bindingComponent, + ) return binding.root } diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingExtensions.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingExtensions.kt index 00b02c7..7dc5b69 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingExtensions.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingExtensions.kt @@ -37,10 +37,13 @@ import kotlin.reflect.KProperty @BindingOnly public fun ViewGroup.binding( @LayoutRes layoutRes: Int, - attachToParent: Boolean = false + attachToParent: Boolean = false, ): T { return DataBindingUtil.inflate( - LayoutInflater.from(context), layoutRes, this, attachToParent + LayoutInflater.from(context), + layoutRes, + this, + attachToParent, ) } @@ -59,7 +62,7 @@ public fun ViewGroup.binding( public inline fun ViewGroup.binding( @LayoutRes layoutRes: Int, attachToParent: Boolean = false, - block: T.() -> Unit + block: T.() -> Unit, ): T { return binding(layoutRes, attachToParent).apply(block) } diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragment.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragment.kt index fa8c83e..e6fd288 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragment.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragment.kt @@ -37,7 +37,7 @@ import androidx.fragment.app.Fragment * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingFragment constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : Fragment() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ @@ -73,7 +73,7 @@ public abstract class BindingFragment constructor( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { _binding = DataBindingUtil.inflate(inflater, contentLayoutId, container, false, bindingComponent) diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragmentActivity.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragmentActivity.kt index fe4c891..0133834 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragmentActivity.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingFragmentActivity.kt @@ -33,7 +33,7 @@ import androidx.fragment.app.FragmentActivity * @property contentLayoutId A content layout Id for inflating as a content view. */ public abstract class BindingFragmentActivity constructor( - @LayoutRes private val contentLayoutId: Int + @LayoutRes private val contentLayoutId: Int, ) : FragmentActivity() { /** This interface is generated during compilation to contain getters for all used instance `BindingAdapters`. */ diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingInitProvider.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingInitProvider.kt index 5f1077f..464fae0 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingInitProvider.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingInitProvider.kt @@ -43,8 +43,19 @@ public class BindingInitProvider : ContentProvider() { override fun getType(uri: Uri): String? = null override fun insert(uri: Uri, values: ContentValues?): Uri? = null override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int = 0 - override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array?): Int = 0 - override fun query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?): Cursor? = null + override fun update( + uri: Uri, + values: ContentValues?, + selection: String?, + selectionArgs: Array?, + ): Int = 0 + override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String?, + ): Cursor? = null internal companion object { private const val TAG = "BindingInitProvider" diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingListAdapter.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingListAdapter.kt index 0abf678..c37b3f5 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingListAdapter.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingListAdapter.kt @@ -33,7 +33,7 @@ import kotlin.reflect.KProperty * [bindingProperty] delegates. The getter for an observable property should be annotated with [androidx.databinding.Bindable]. */ public abstract class BindingListAdapter constructor( - public val callback: DiffUtil.ItemCallback + public val callback: DiffUtil.ItemCallback, ) : ListAdapter(callback), BindingObservable { /** Synchronization registry lock. */ diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingManager.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingManager.kt index 8297e00..36ac4a3 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingManager.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingManager.kt @@ -72,7 +72,10 @@ public object BindingManager { val bindingProperty = property.takeIf { it.getter.hasAnnotation() } - ?: throw IllegalArgumentException("KProperty: ${property.name} must be annotated with the `@Bindable` annotation on the getter.") + ?: throw IllegalArgumentException( + "KProperty: ${property.name} must be annotated " + + "with the `@Bindable` annotation on the getter.", + ) val propertyName = bindingProperty.name.replaceFirstChar { it.lowercase(Locale.ENGLISH) } val bindingPropertyName = propertyName .takeIf { it.startsWith(JAVA_BEANS_BOOLEAN) } @@ -90,22 +93,28 @@ public object BindingManager { val bindingFunction = function.takeIf { it.hasAnnotation() } - ?: throw IllegalArgumentException("KFunction: ${function.name} must be annotated with the `@Bindable` annotation.") + ?: throw IllegalArgumentException( + "KFunction: ${function.name} must be annotated " + + "with the `@Bindable` annotation.", + ) val functionName = bindingFunction.name.replaceFirstChar { it.lowercase(Locale.ENGLISH) } val bindingFunctionName = when { functionName.startsWith(JAVA_BEANS_GETTER) -> functionName.replaceFirst( JAVA_BEANS_GETTER, - String() + String(), ) functionName.startsWith(JAVA_BEANS_SETTER) -> functionName.replaceFirst( JAVA_BEANS_SETTER, - String() + String(), ) functionName.startsWith(JAVA_BEANS_BOOLEAN) -> functionName.replaceFirst( JAVA_BEANS_BOOLEAN, - String() + String(), + ) + else -> throw IllegalArgumentException( + "@Bindable associated with method " + + "must follow JavaBeans convention $functionName", ) - else -> throw IllegalArgumentException("@Bindable associated with method must follow JavaBeans convention $functionName") }.replaceFirstChar { it.lowercase(Locale.ENGLISH) } return bindingFieldsMap[bindingFunctionName] ?: BR._all } diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingOnly.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingOnly.kt index 1627cf7..833faf1 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingOnly.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingOnly.kt @@ -25,7 +25,7 @@ package com.skydoves.bindables AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, - AnnotationTarget.PROPERTY_SETTER + AnnotationTarget.PROPERTY_SETTER, ) @DslMarker @Retention(AnnotationRetention.BINARY) diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingProperty.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingProperty.kt index 8d4b15c..345705c 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingProperty.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingProperty.kt @@ -42,11 +42,18 @@ public fun bindingProperty(defaultValue: T): BindingPropertyIdWithDefaultVal * @param value A default value should be initialized. */ public class BindingPropertyIdWithDefaultValue( - private var value: T + private var value: T, ) { - public operator fun getValue(bindingObservable: BindingObservable, property: KProperty<*>): T = value + public operator fun getValue( + bindingObservable: BindingObservable, + property: KProperty<*>, + ): T = value - public operator fun setValue(bindingObservable: BindingObservable, property: KProperty<*>, value: T) { + public operator fun setValue( + bindingObservable: BindingObservable, + property: KProperty<*>, + value: T, + ) { if (this.value != value) { this.value = value bindingObservable.notifyPropertyChanged(property.bindingId) @@ -80,12 +87,17 @@ public fun SavedStateHandle.asBindingProperty(key: String): SavedStateHandle */ public class SavedStateHandleBindingProperty( private val savedStateHandle: SavedStateHandle, - private var key: String + private var key: String, ) { - public operator fun getValue(bindingObservable: BindingObservable, property: KProperty<*>): T? = savedStateHandle.get(key) + public operator fun getValue(bindingObservable: BindingObservable, property: KProperty<*>): T? = + savedStateHandle[key] - public operator fun setValue(bindingObservable: BindingObservable, property: KProperty<*>, value: T?) { - savedStateHandle.set(key, value) + public operator fun setValue( + bindingObservable: BindingObservable, + property: KProperty<*>, + value: T?, + ) { + savedStateHandle[key] = value bindingObservable.notifyPropertyChanged(property.bindingId) } } diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/BindingPropertyDelegate.kt b/bindables/src/main/kotlin/com/skydoves/bindables/BindingPropertyDelegate.kt index 7ce80ca..2e56693 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/BindingPropertyDelegate.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/BindingPropertyDelegate.kt @@ -25,7 +25,7 @@ package com.skydoves.bindables AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, - AnnotationTarget.PROPERTY_SETTER + AnnotationTarget.PROPERTY_SETTER, ) @DslMarker @Retention(AnnotationRetention.BINARY) diff --git a/bindables/src/main/kotlin/com/skydoves/bindables/FlowBindingProperty.kt b/bindables/src/main/kotlin/com/skydoves/bindables/FlowBindingProperty.kt index dd2737c..f860360 100644 --- a/bindables/src/main/kotlin/com/skydoves/bindables/FlowBindingProperty.kt +++ b/bindables/src/main/kotlin/com/skydoves/bindables/FlowBindingProperty.kt @@ -40,7 +40,9 @@ import kotlin.reflect.KProperty * @return A flow delegation property [FlowBindingPropertyIdWithDefaultValue]. */ @BindingPropertyDelegate -public fun Flow.asBindingProperty(defaultValue: T): FlowBindingPropertyIdWithDefaultValue = +public fun Flow.asBindingProperty( + defaultValue: T, +): FlowBindingPropertyIdWithDefaultValue = FlowBindingPropertyIdWithDefaultValue(this, defaultValue) /** @@ -53,9 +55,12 @@ public fun Flow.asBindingProperty(defaultValue: T): FlowBindingPropertyId */ public class FlowBindingPropertyIdWithDefaultValue constructor( private val flow: Flow, - private val defaultValue: T + private val defaultValue: T, ) { - public operator fun provideDelegate(bindingViewModel: BindingViewModel, property: KProperty<*>): Delegate { + public operator fun provideDelegate( + bindingViewModel: BindingViewModel, + property: KProperty<*>, + ): Delegate { val bindingId = BindingManager.getBindingIdByProperty(property) val delegate = Delegate(defaultValue, bindingId) delegate.collect(flow, bindingViewModel) @@ -91,7 +96,10 @@ public class FlowBindingPropertyIdWithDefaultValue constructor( * @return A flow delegation property [FlowBindingPropertyIdWithDefaultValue]. */ @BindingPropertyDelegate -public fun Flow.asBindingProperty(coroutineScope: CoroutineScope, defaultValue: T): FlowBindingPropertyIdWithDefaultValueOnScope = +public fun Flow.asBindingProperty( + coroutineScope: CoroutineScope, + defaultValue: T, +): FlowBindingPropertyIdWithDefaultValueOnScope = FlowBindingPropertyIdWithDefaultValueOnScope(this, coroutineScope, defaultValue) /** @@ -106,9 +114,12 @@ public fun Flow.asBindingProperty(coroutineScope: CoroutineScope, default public class FlowBindingPropertyIdWithDefaultValueOnScope constructor( private val flow: Flow, private val coroutineScope: CoroutineScope, - private val defaultValue: T + private val defaultValue: T, ) { - public operator fun provideDelegate(bindingObservable: BindingObservable, property: KProperty<*>): Delegate { + public operator fun provideDelegate( + bindingObservable: BindingObservable, + property: KProperty<*>, + ): Delegate { val bindingId = BindingManager.getBindingIdByProperty(property) val delegate = Delegate(defaultValue, coroutineScope, bindingId) delegate.collect(flow, bindingObservable) @@ -118,7 +129,7 @@ public class FlowBindingPropertyIdWithDefaultValueOnScope constructor( public class Delegate( private var value: T, private val coroutineScope: CoroutineScope, - private val bindingId: Int + private val bindingId: Int, ) { public fun collect(flow: Flow, bindingObservable: BindingObservable) { coroutineScope.launch { @@ -159,7 +170,10 @@ public class StateFlowBindingPropertyId constructor( private val stateFlow: StateFlow, ) { - public operator fun provideDelegate(bindingViewModel: BindingViewModel, property: KProperty<*>): Delegate { + public operator fun provideDelegate( + bindingViewModel: BindingViewModel, + property: KProperty<*>, + ): Delegate { val delegate = Delegate(stateFlow, property.bindingId) delegate.collect(bindingViewModel) return delegate @@ -192,7 +206,9 @@ public class StateFlowBindingPropertyId constructor( * @return A flow delegation property [StateFlowBindingPropertyId]. */ @BindingPropertyDelegate -public fun StateFlow.asBindingProperty(coroutineScope: CoroutineScope): StateFlowBindingPropertyIdOnScope = +public fun StateFlow.asBindingProperty( + coroutineScope: CoroutineScope, +): StateFlowBindingPropertyIdOnScope = StateFlowBindingPropertyIdOnScope(coroutineScope, this) /** @@ -208,7 +224,10 @@ public class StateFlowBindingPropertyIdOnScope constructor( private val stateFlow: StateFlow, ) { - public operator fun provideDelegate(bindingObservable: BindingObservable, property: KProperty<*>): Delegate { + public operator fun provideDelegate( + bindingObservable: BindingObservable, + property: KProperty<*>, + ): Delegate { val delegate = Delegate(stateFlow, coroutineScope, property.bindingId) delegate.collect(bindingObservable) return delegate @@ -217,7 +236,7 @@ public class StateFlowBindingPropertyIdOnScope constructor( public class Delegate( private val stateFlow: StateFlow, private val coroutineScope: CoroutineScope, - private val bindingId: Int + private val bindingId: Int, ) { public fun collect(bindingObservable: BindingObservable) { coroutineScope.launch { diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 1e41163..0000000 --- a/build.gradle +++ /dev/null @@ -1,43 +0,0 @@ -///* -// * Designed and developed by 2021 skydoves (Jaewoong Eum) -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ - -import com.skydoves.bindables.Dependencies - -apply plugin: "io.github.gradle-nexus.publish-plugin" -apply plugin: "org.jetbrains.dokka" - -buildscript { - repositories { - google() - mavenCentral() - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath Dependencies.androidGradlePlugin - classpath Dependencies.kotlinGradlePlugin - classpath Dependencies.spotlessGradlePlugin - classpath Dependencies.gradleNexusPublishPlugin - classpath Dependencies.dokka - classpath Dependencies.hiltPlugin - classpath Dependencies.kotlinBinaryValidator - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} - -apply from: "${rootDir}/scripts/publish-root.gradle" \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..956555a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,65 @@ +///* +// * Designed and developed by 2021 skydoves (Jaewoong Eum) +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ + +@Suppress("DSL_SCOPE_VIOLATION") +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ksp) apply false + alias(libs.plugins.kotlin.binary.compatibility) apply false + alias(libs.plugins.hilt.plugin) apply false + alias(libs.plugins.nexus.plugin) apply false + alias(libs.plugins.kotlin.kapt) apply false + alias(libs.plugins.spotless) + alias(libs.plugins.dokka) +} + +subprojects { + if (name != "app") { + tasks.withType { + kotlinOptions.jvmTarget = libs.versions.jvmTarget.get() + kotlinOptions.freeCompilerArgs += listOf( + "-Xexplicit-api=strict", + "-Xopt-in=kotlin.contracts.ExperimentalContracts" + ) + } + } + + apply(plugin = rootProject.libs.plugins.spotless.get().pluginId) + configure { + kotlin { + target("**/*.kt") + targetExclude("$buildDir/**/*.kt") + ktlint().editorConfigOverride( + mapOf( + "indent_size" to "2", + "continuation_indent_size" to "2" + ) + ) + licenseHeaderFile(rootProject.file("spotless/spotless.license.kt")) + trimTrailingWhitespace() + endWithNewline() + } + format("kts") { + target("**/*.kts") + targetExclude("$buildDir/**/*.kts") + licenseHeaderFile(rootProject.file("spotless/spotless.license.kt"), "(^(?![\\/ ]\\*).*$)") + trimTrailingWhitespace() + endWithNewline() + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt b/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt index cc51d40..d6627ef 100644 --- a/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt +++ b/buildSrc/src/main/kotlin/com/skydoves/bindables/Configuration.kt @@ -17,8 +17,8 @@ package com.skydoves.bindables object Configuration { - const val compileSdk = 32 - const val targetSdk = 32 + const val compileSdk = 35 + const val targetSdk = 35 const val minSdk = 21 const val majorVersion = 1 const val minorVersion = 1 diff --git a/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt b/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt deleted file mode 100644 index b07bbfc..0000000 --- a/buildSrc/src/main/kotlin/com/skydoves/bindables/Dependencies.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.skydoves.bindables - -object Versions { - internal const val ANDROID_GRADLE_PLUGIN = "7.2.1" - internal const val ANDROID_GRADLE_SPOTLESS = "6.3.0" - internal const val GRADLE_NEXUS_PUBLISH_PLUGIN = "1.1.0" - internal const val KOTLIN = "1.7.0" - internal const val KOTLIN_GRADLE_DOKKA = "1.6.21" - internal const val KOTLIN_BINARY_VALIDATOR = "0.10.1" - - internal const val APPCOMPAT = "1.4.1" - internal const val MATERIAL = "1.6.0" - internal const val LIFECYCLE = "2.4.1" - - internal const val FRAGMENT = "1.2.5" - internal const val HILT = "2.42" - internal const val GLIDE = "4.13.0" - internal const val WHATIF = "1.1.1" -} - -object Dependencies { - const val androidGradlePlugin = - "com.android.tools.build:gradle:${Versions.ANDROID_GRADLE_PLUGIN}" - const val gradleNexusPublishPlugin = - "io.github.gradle-nexus:publish-plugin:${Versions.GRADLE_NEXUS_PUBLISH_PLUGIN}" - const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN}" - const val spotlessGradlePlugin = - "com.diffplug.spotless:spotless-plugin-gradle:${Versions.ANDROID_GRADLE_SPOTLESS}" - const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.KOTLIN_GRADLE_DOKKA}" - const val kotlinBinaryValidator = - "org.jetbrains.kotlinx:binary-compatibility-validator:${Versions.KOTLIN_BINARY_VALIDATOR}" - - const val appcompat = "androidx.appcompat:appcompat:${Versions.APPCOMPAT}" - const val material = "com.google.android.material:material:${Versions.MATERIAL}" - const val lifecycle = "androidx.lifecycle:lifecycle-common-java8:${Versions.LIFECYCLE}" - const val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.KOTLIN}" - const val viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LIFECYCLE}" - const val viewModelSavedState = "androidx.lifecycle:lifecycle-viewmodel-savedstate:${Versions.LIFECYCLE}" - - const val fragment = "androidx.fragment:fragment-ktx:${Versions.FRAGMENT}" - const val hilt = "com.google.dagger:hilt-android:${Versions.HILT}" - const val hiltCompiler = "com.google.dagger:hilt-compiler:${Versions.HILT}" - const val hiltPlugin = "com.google.dagger:hilt-android-gradle-plugin:${Versions.HILT}" - const val glide = "com.github.bumptech.glide:glide:${Versions.GLIDE}" - const val whatIf = "com.github.skydoves:whatif:${Versions.WHATIF}" -} diff --git a/gradle.properties b/gradle.properties index f443776..69ea3ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,4 +42,29 @@ android.defaults.buildfeatures.shaders=false # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library # https://developer.android.com/studio/releases/gradle-plugin#4.1-nontransitive-r-class -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +## Maven Central Publication ## +# Required to publish to Nexus (see https://github.com/gradle/gradle/issues/11308) +systemProp.org.gradle.internal.publish.checksums.insecure=true + +# Increase timeout when pushing to Sonatype (otherwise we get timeouts) +systemProp.org.gradle.internal.http.socketTimeout=120000 + +POM_URL=https://github.com/skydoves/bindables/ +POM_SCM_URL=https://github.com/skydoves/bindables/ +POM_SCM_CONNECTION=scm:git:git://github.com/skydoves/bindables.git +POM_SCM_DEV_CONNECTION=scm:git:git://github.com/skydoves/bindables.git + +POM_LICENCE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_DEVELOPER_ID=skydoves +POM_DEVELOPER_NAME=Jaewoong Eum +POM_DEVELOPER_URL=https://github.com/skydoves/ +POM_DEVELOPER_EMAIL=skydoves2@gmail.com + +SONATYPE_HOST=DEFAULT +RELEASE_SIGNING_ENABLED=true +SONATYPE_AUTOMATIC_RELEASE=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..2998075 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,62 @@ +[versions] +agp = "8.7.2" +dokka = "1.9.20" +glide = "4.16.0" +kotlin = "2.0.21" +kotlinReflect = "2.0.21" +ksp = "2.0.21-1.0.26" +kotlinBinaryCompatibility = "0.16.3" +jvmTarget = "11" +nexusPlugin = "0.30.0" +androidxMaterial = "1.12.0" +androidxAppcompat = "1.7.0" +androidxActivity = "1.9.3" +androidxFragment = "1.8.5" +androidxLifecycle = "2.8.7" +androidxAnnotation = "1.9.1" +androidxMacroBenchmark = "1.3.3" +androidxTest = "1.6.2" +hilt = "2.52" +whatif = "1.2.1" +baselineProfiles = "1.4.1" +uiAutomator = "2.3.0" +spotless = "6.21.0" +activity = "1.9.3" +constraintlayout = "2.2.0" + +[libraries] +androidx-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "androidxLifecycle" } +androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidxLifecycle" } +androidx-material = { module = "com.google.android.material:material", version.ref = "androidxMaterial" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppcompat" } +androidx-fragment = { module = "androidx.fragment:fragment-ktx", version.ref = "androidxFragment" } +androidx-lifecycle = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidxLifecycle" } +androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidxAnnotation" } +glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } +hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } +hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" } +kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlinReflect" } +whatif = { module = "com.github.skydoves:whatif", version.ref = "whatif" } + +# unit test +androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidxTest" } +androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "baselineProfiles" } +androidx-benchmark-macro = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidxMacroBenchmark" } +androidx-test-uiautomator = { module = "androidx.test.uiautomator:uiautomator", version.ref = "uiAutomator" } +androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +android-library = { id = "com.android.library", version.ref = "agp" } +android-test = { id = "com.android.test", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +baseline-profile = { id = "androidx.baselineprofile", version.ref = "androidxMacroBenchmark" } +kotlin-binary-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "kotlinBinaryCompatibility" } +kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +hilt-plugin = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b5..2fa91c5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index ea8ce59..0000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,87 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'org.jetbrains.dokka' - -task androidSourcesJar(type: Jar) { - archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs - } else { - from sourceSets.main.java.srcDirs - from sourceSets.main.kotlin.srcDirs - } -} - -tasks.withType(dokkaHtmlPartial.getClass()).configureEach { - pluginsMapConfiguration.set( - ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""] - ) -} - -task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { - archiveClassifier.set('javadoc') - from dokkaJavadoc.outputDirectory -} - -artifacts { - archives androidSourcesJar - archives javadocJar -} - -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId PUBLISH_GROUP_ID - artifactId PUBLISH_ARTIFACT_ID - version PUBLISH_VERSION - if (project.plugins.findPlugin("com.android.library")) { - from components.release - } else { - from components.java - } - - artifact androidSourcesJar - artifact javadocJar - - pom { - name = PUBLISH_ARTIFACT_ID - description = 'Android DataBinding kit for notifying data changes to UI layers.' - url = 'https://github.com/skydoves/bindables' - licenses { - license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - developers { - developer { - id = 'skydoves' - name = 'Jaewoong Eum' - email = "skydoves2@gmail.com" - url = "https://github.com/skydoves" - } - } - scm { - connection = 'scm:git:github.com/skydoves/bindables.git' - developerConnection = 'scm:git:ssh://github.com/skydoves/bindables.git' - url = 'https://github.com/skydoves/bindables/tree/main' - } - } - } - } - } -} - -signing { - useInMemoryPgpKeys( - rootProject.ext["signing.keyId"], - rootProject.ext["signing.key"], - rootProject.ext["signing.password"], - ) - sign publishing.publications -} diff --git a/scripts/publish-module.gradle.kts b/scripts/publish-module.gradle.kts new file mode 100644 index 0000000..9671a66 --- /dev/null +++ b/scripts/publish-module.gradle.kts @@ -0,0 +1,13 @@ +import com.skydoves.bindables.Configuration + +apply(plugin = "com.vanniktech.maven.publish") + +rootProject.extra.apply { + val snapshot = System.getenv("SNAPSHOT").toBoolean() + val libVersion = if (snapshot) { + Configuration.snapshotVersionName + } else { + Configuration.versionName + } + set("libVersion", libVersion) +} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 84ef429..0000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,45 +0,0 @@ -import com.skydoves.bindables.Configuration - -// Create variables with empty default values -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.key"] = '' -ext["snapshot"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') - ext["signing.key"] = System.getenv('SIGNING_KEY') - ext["snapshot"] = System.getenv('SNAPSHOT') -} - -if (snapshot) { - ext["rootVersionName"] = Configuration.snapshotVersionName -} else { - ext["rootVersionName"] = Configuration.versionName -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - version = rootVersionName - } - } -} diff --git a/spotless/.DS_Store b/spotless/.DS_Store index 6966dc1..1fc8d37 100644 Binary files a/spotless/.DS_Store and b/spotless/.DS_Store differ diff --git a/spotless/spotless.gradle b/spotless/spotless.gradle deleted file mode 100644 index db2d1dd..0000000 --- a/spotless/spotless.gradle +++ /dev/null @@ -1,26 +0,0 @@ -// Designed and developed by 2021 skydoves (Jaewoong Eum) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -apply plugin: "com.diffplug.spotless" - -spotless { - kotlin { - target "**/*.kt" - targetExclude "**/build/**/*.kt" - ktlint().userData(['indent_size': '2', 'continuation_indent_size': '2']) - licenseHeaderFile "$rootDir/spotless/spotless.license.kt" - trimTrailingWhitespace() - endWithNewline() - } -} \ No newline at end of file