Compare commits

...
85 Commits
Author SHA1 Message Date
Harsh Shandilya b728103b13 feat(release): bump version 2022-11-14 19:00:39 +05:30
Harsh ShandilyaandGitHub abe8ec77cc fix(github): use a PAT for the release workflow 2022-11-14 17:24:49 +05:30
Harsh Shandilya fa62d871f8 fix(ci): disable configuration cache 2022-11-14 15:24:13 +05:30
Harsh Shandilya aaf67de8d4 chore(deps): remove unused napt plugin declaration 2022-11-14 14:55:13 +05:30
Harsh Shandilya 4ac8882bec chore: update changelog 2022-11-14 14:54:10 +05:30
Harsh Shandilya 6a8893a5aa fix(gradle): change checkouts directory 2022-11-14 14:30:40 +05:30
Harsh Shandilya 839773e48e refactor(gradle): configure Lint for all modules 2022-11-14 13:56:56 +05:30
Harsh Shandilya aa2a109587 fix: prevent warnings in CI 2022-11-14 12:59:01 +05:30
Harsh Shandilya 0232a4179a refactor(di): replace Tangle with Whetstone 2022-11-14 12:59:01 +05:30
Harsh Shandilya 4a87682b68 refactor(di): migrate to Whetstone ApplicationScope 2022-11-14 12:59:01 +05:30
Harsh Shandilya 52562afbd1 feat(deps): configure Whetstone dependencies 2022-11-14 12:59:01 +05:30
Harsh Shandilya 15abd31b03 fix(core): reduce HTTP logging level 2022-11-13 21:15:03 +05:30
Harsh Shandilya 157fe2c221 refactor(di): move out Coil configuration to an AppPlugin 2022-11-13 21:10:57 +05:30
Harsh Shandilya 93db17e6d7 refactor(android): turn off StrictMode 2022-11-13 21:01:00 +05:30
Harsh Shandilya c75d1959a6 feat(android): integrate AppPlugin 2022-11-13 20:35:18 +05:30
Harsh Shandilya 72acf9c850 feat(android): add a WorkManager plugin 2022-11-13 20:35:18 +05:30
Harsh Shandilya 77af00229f feat(core): add a Napier plugin 2022-11-13 20:35:18 +05:30
Harsh Shandilya 0390336d50 feat(core): introduce the AppPlugin interface 2022-11-13 20:35:18 +05:30
Harsh Shandilya 0bf60812e0 refactor(di): workaround unstable IntoSet ordering
EitherNet's ApiResultConverterFactory needs to go before any other
(de)serialization factories, but multibindings do not have ordering
guarantees. To fix this, I've changed the module to handle the EitherNet
configuration within api and let core continue supplying everything else.
2022-11-13 18:11:50 +05:30
Harsh Shandilya 8a4fee5f7c chore(deps): remove unused dependencies from android module 2022-11-13 17:17:01 +05:30
Harsh Shandilya 005dc9ab83 refactor(di): move ApiModule to core and api 2022-11-13 17:17:01 +05:30
Harsh Shandilya 9d41b7e819 refactor(di): migrate OkHttp module to core 2022-11-13 16:27:33 +05:30
Harsh Shandilya b8965902ba chore: cleanup Hilt remnant 2022-11-13 15:15:01 +05:30
Harsh Shandilya ef5242f115 chore: fix Detekt build 2022-11-13 15:07:30 +05:30
Harsh Shandilya 0dd2a3be6f fix(benchmark): remove outdated annotation 2022-11-13 13:52:50 +05:30
Harsh Shandilya 10eecce01c fix(deps): re-align androidx.test versioning 2022-11-13 13:49:24 +05:30
Harsh Shandilya 4fe7c64e42 refactor(android): migrate to Anvil
Fixes #261
2022-11-13 13:15:53 +05:30
Harsh Shandilya 6d88335e13 refactor(metadata-extractor): break Hilt dependency 2022-11-13 13:14:55 +05:30
Harsh Shandilya e3e14edb5d refactor(coroutine-utils): break Hilt dependency 2022-11-13 13:14:44 +05:30
Harsh Shandilya 56d47d1f32 refactor(di): move database injection to its module 2022-11-13 13:13:59 +05:30
Harsh Shandilya ce37903ea0 feat(di): kick off Anvil infra 2022-11-13 13:13:03 +05:30
Harsh Shandilya 3c0a8dd392 feat(gradle): add Anvil and Tangle deps 2022-11-13 13:12:32 +05:30
Harsh Shandilya e7228d35df Revert "feat(build-logic): remove kapt plugin"
This reverts commit e0f68d05e9.
2022-11-13 13:11:35 +05:30
Harsh Shandilya 28c6f62b81 refactor(android): simplify SavedPostUpdaterWorker 2022-11-13 12:32:09 +05:30
Harsh Shandilya 4a48a2ba4c fix(deps): bump Compose Compiler to 1.4.0-alpha02 2022-11-13 01:31:12 +05:30
renovate[bot]andGitHub 18ed012154 fix(deps): update kotlin to v1.7.21 2022-11-12 19:57:41 +00:00
Harsh Shandilya 653787c946 fix(renovate): reformat config with Boop 2022-11-13 01:23:50 +05:30
Harsh Shandilya e90c2f5a7d feat(renovate): configure repositories for Compose Compiler 2022-11-13 01:23:04 +05:30
Harsh Shandilya 5a175c162c feat(renovate): add a regex manager for Compose Compiler 2022-11-13 01:07:45 +05:30
Harsh Shandilya 1373198df0 feat(renovate): enable and batch Kotlin + Compose Compiler updates 2022-11-13 01:03:29 +05:30
renovate[bot]andGitHub 0ab452f943 chore(deps): update dependency com.twitter.compose.rules:detekt to v0.0.24 2022-11-12 10:36:00 +00:00
renovate[bot]andGitHub 07e0de1b0d fix(deps): update dependency com.github.ben-manes:gradle-versions-plugin to v0.44.0 2022-11-12 09:05:32 +00:00
renovate[bot]andGitHub f92fb48752 chore(deps): update dagger to v2.44.1 2022-11-11 18:02:02 +00:00
Harsh Shandilya dc7ef55461 fix(release): add GITHUB_TOKEN env variable for gh CLI 2022-11-10 22:24:44 +05:30
Harsh Shandilya 6581e56c31 refactor(scripts): remove now unused release script 2022-11-10 22:17:19 +05:30
Harsh Shandilya da40cf3892 feat(release): start next development iteration 2022-11-10 22:15:16 +05:30
Harsh Shandilya 2eb0a6a31c feat(release): bump version 2022-11-10 22:12:04 +05:30
Harsh Shandilya 2d44ad2055 feat(github): make release workflow self-contained 2022-11-10 22:09:16 +05:30
Harsh Shandilya 8af4bddfe1 feat(release): add changelog entry for Compose bump 2022-11-10 21:20:17 +05:30
renovate[bot]andGitHub 0be0952e04 fix(deps): update dependency androidx.work:work-runtime-ktx to v2.8.0-beta02 2022-11-10 10:06:12 +00:00
renovate[bot]andGitHub 8b2ba790bc fix(deps): update dependency androidx.test:runner to v1.5.1 2022-11-10 08:07:26 +00:00
Harsh Shandilya 6ed377af94 fix(github): adjust when cache is written to 2022-11-10 13:30:49 +05:30
renovate[bot]andGitHub cfc479a9ee fix(deps): update dependency androidx.compose:compose-bom to v2022.11.00 2022-11-10 05:31:33 +00:00
renovate[bot]andGitHub 7552fb1c36 fix(deps): update dependency androidx.profileinstaller:profileinstaller to v1.3.0-alpha02 2022-11-10 02:24:42 +00:00
renovate[bot]andGitHub bcd8a412b5 fix(deps): update dependency androidx.navigation:navigation-compose to v2.6.0-alpha04 2022-11-09 23:38:19 +00:00
renovate[bot]andGitHub defe4914df fix(deps): update dependency androidx.benchmark:benchmark-macro-junit4 to v1.2.0-alpha07 2022-11-09 20:43:05 +00:00
renovate[bot]andGitHub 621e93939b chore(deps): update plugin napt to v1.18 2022-11-09 17:50:41 +00:00
renovate[bot]andGitHub 247949f92e chore(deps): update dependency com.twitter.compose.rules:detekt to v0.0.23 2022-11-09 14:36:56 +00:00
renovate[bot]andGitHub 5700b2150e fix(deps): update dependency androidx.test.ext:junit to v1.1.4 2022-11-09 03:13:19 +00:00
renovate[bot]andGitHub 530ad44b27 fix(deps): update dependency androidx.test.espresso:espresso-core to v3.5.0 2022-11-08 23:46:03 +00:00
renovate[bot]andGitHub 51c7306cfa fix(deps): update dependency androidx.test:runner to v1.5.0 2022-11-08 20:15:58 +00:00
renovate[bot]andGitHub 79778466b9 chore(deps): update agp to v8.0.0-alpha08 2022-11-07 19:09:52 +00:00
renovate[bot]andHarsh Shandilya 7d7989d5c0 chore(deps): pin dependencies 2022-11-05 16:45:25 +05:30
Harsh Shandilya 923361ee1b fix(renovate): pin actions via SHA 2022-11-05 16:45:14 +05:30
renovate[bot]andGitHub 6adf339e08 chore(deps): update agp to v8.0.0-alpha07 2022-11-02 17:55:42 +00:00
Harsh Shandilya 9e37246810 fix(release): add status parameter explicitly 2022-11-02 14:45:27 +05:30
Harsh Shandilya 7be1157f22 Revert "fix(release): rework Play Store release workflow"
This reverts commit cd7d82d378.
2022-11-02 14:44:48 +05:30
Harsh Shandilya cd7d82d378 fix(release): rework Play Store release workflow 2022-11-02 14:37:26 +05:30
Harsh Shandilya b30425d97d feat(release): start next development iteration 2022-11-02 14:17:58 +05:30
Harsh Shandilya c89589adcb feat(release): bump version
Release to Google Play / publish-google-play-release (push) Canceled after 0s
2022-11-02 14:17:05 +05:30
Harsh Shandilya 6523b85f07 fix(deps): reformat catalog 2022-11-02 12:57:56 +05:30
Harsh Shandilya 33f8b73938 chore: fill out changelog 2022-11-02 12:25:13 +05:30
Harsh Shandilya bb47119c84 fix: remove inaccurate copyright header
Same reasoning as this change https://github.com/rust-lang/rust/commit/2a8807e889a43c6b89eb6f2736907afa87ae592f
2022-11-02 12:23:09 +05:30
Harsh Shandilya 6adb45ff7c fix(metadata-extractor): migrate away from removed APIs 2022-11-01 19:06:27 +05:30
renovate[bot]andGitHub a87b1cf38c fix(deps): update dependency com.chimbori.crux:crux to v3.11.0 2022-11-01 10:50:53 +00:00
renovate[bot]andGitHub b112585533 fix(deps): update material_motion to v0.10.3 2022-10-30 09:52:46 +00:00
renovate[bot]andGitHub 5750bbebd3 fix(deps): update dependency androidx.test.ext:junit to v1.1.4-rc01 2022-10-27 05:20:30 +00:00
renovate[bot]andGitHub 067b762a31 fix(deps): update dependency androidx.test.espresso:espresso-core to v3.5.0-rc01 2022-10-27 02:48:26 +00:00
renovate[bot]andGitHub 658a2f36fd fix(deps): update androidx.test to v1.5.0-rc01 2022-10-26 23:46:41 +00:00
Harsh Shandilya 6a4d0c2d3a refactor: add license headers across the board 2022-10-26 01:55:50 +05:30
Harsh Shandilya 5319669a8e feat: configure Spotless license headers 2022-10-26 01:54:38 +05:30
Harsh Shandilya 720f946f41 fix(gradle): only allow Spotless plugin to be applied to the root project 2022-10-26 01:30:33 +05:30
renovate[bot]andGitHub a1390a0f05 fix(deps): update accompanist to v0.27.0 2022-10-25 03:32:37 +00:00
Harsh Shandilya 655b20e496 fix(github): bump r0adkll/upload-google-play
The new maintainer has not been bumping the v1 tag
2022-10-24 23:20:39 +05:30
Harsh Shandilya 8508a8646f feat(release): start next development iteration 2022-10-24 23:11:30 +05:30
134 changed files with 1193 additions and 347 deletions
+30 -1
View File
@@ -2,18 +2,37 @@
"extends": [
"config:base",
":dependencyDashboard",
"helpers:pinGitHubActionDigests",
"github>msfjarvis/shared-workflows//renovate/automerge"
],
"packageRules": [
{
"matchPackagePatterns": [
"^kotlin",
"^org.jetbrains.kotlin",
"^androidx.compose.compiler"
],
"groupName": "kotlin"
},
{
"managers": [
"gradle"
],
"packagePatterns": [
"^org.jetbrains.kotlin",
"^com.squareup.okhttp3"
],
"enabled": false
},
{
"matchDatasources": [
"maven"
],
"matchPackageNames": [
"androidx.compose.compiler:compiler"
],
"registryUrls": [
"https://maven.google.com/"
]
}
],
"regexManagers": [
@@ -36,6 +55,16 @@
],
"datasourceTemplate": "maven",
"depNameTemplate": "com.twitter.compose.rules:detekt"
},
{
"fileMatch": [
"gradle/libs.versions.toml"
],
"matchStrings": [
"composeCompiler = \"(?<currentValue>.*)\""
],
"datasourceTemplate": "maven",
"depNameTemplate": "androidx.compose.compiler:compiler"
}
]
}
+14 -11
View File
@@ -15,29 +15,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
- name: Set up JDK
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3.6.0
with:
distribution: temurin
java-version: 18
- name: Run unit tests
uses: gradle/gradle-build-action@v2.3.3
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2.3.3
with:
arguments: check -PslimTests
arguments: --no-configuration-cache check -PslimTests
gradle-home-cache-cleanup: true
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Run Detekt
uses: gradle/gradle-build-action@v2.3.3
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2.3.3
with:
arguments: detektMain
arguments: --no-configuration-cache detektMain
gradle-home-cache-cleanup: true
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: (Fail-only) Upload test report
if: failure()
uses: actions/upload-artifact@v3.1.1
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3.1.1
with:
name: Test report
path: android/build/reports
@@ -48,10 +50,10 @@ jobs:
needs: [ "check" ]
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
- name: Set up JDK
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3.6.0
with:
distribution: temurin
java-version: 18
@@ -62,10 +64,11 @@ jobs:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
- name: Build release app
uses: gradle/gradle-build-action@v2.3.3
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2.3.3
with:
arguments: collectReleaseApks
arguments: --no-configuration-cache collectReleaseApks
gradle-home-cache-cleanup: true
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Clean secrets
run: scripts/signing-cleanup.sh
+57 -19
View File
@@ -1,42 +1,80 @@
name: Release to Google Play
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
jobs:
publish-google-play-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0
with:
depth: 0
- name: Set up JDK
uses: actions/setup-java@v3.6.0
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # tag=v3.6.0
with:
distribution: temurin
java-version: 18
- name: Set up Git author
shell: bash
run: |
git config user.name "GitHub Actions"
git config user.email noreply@github.com
- name: Setup Gradle caching
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef # tag=v2.3.3
with:
gradle-home-cache-cleanup: true
cache-read-only: true
- name: Decrypt secrets
run: scripts/signing-setup.sh "$ENCRYPT_KEY"
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
- name: Build release bundle
uses: gradle/gradle-build-action@v2.3.3
with:
arguments: collectReleaseBundle
gradle-home-cache-cleanup: true
- name: Prepare release assets
shell: bash
run: |
# Remove the `-SNAPSHOT` suffix
./gradlew -q --no-configuration-cache clearPreRelease
git commit -am 'feat(release): bump version'
- name: Publish bundle to Google Play
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: dev.msfjarvis.claw.android
releaseFiles: android/bundle/*.aab
track: production
whatsNewDirectory: distribution/whatsnew
mappingFile: android/bundle/mapping.txt
# Build the release assets
./gradlew --no-configuration-cache collectReleaseApks collectReleaseBundle
- name: Clean secrets
run: scripts/signing-cleanup.sh
- name: Publish bundle to Google Play
uses: r0adkll/upload-google-play@78c9e796b1035c94169c101d8e46cb880194bfc3 # tag=v1.0.19
with:
mappingFile: android/bundle/mapping.txt
packageName: dev.msfjarvis.claw.android
releaseFiles: android/bundle/*.aab
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
status: completed
track: production
whatsNewDirectory: distribution/whatsnew
- name: Post-release work
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.POST_RELEASE_GH_TOKEN }}
run: |
# Tag the current version
VERSION="$(tail -n1 android/version.properties | cut -d = -f 2)"
git tag "v${VERSION}" -F distribution/whatsnew/whatsnew-en-GB
# Push everything to GitHub
git push origin --all
# Create a GitHub release
gh release create "v${VERSION}" -F distribution/whatsnew/whatsnew-en-GB --title "v${VERSION}" ./android/apk/*.apk ./android/bundle/*.aab
# Start the next development iteration
./gradlew -q --no-configuration-cache bumpSnapshot
truncate -s 0 distribution/whatsnew/whatsnew-en-GB # Clear changelog
git commit -am 'feat(release): start next development iteration'
git push origin main
+3
View File
@@ -242,3 +242,6 @@ hs_err_pid*
!/gradle/wrapper/gradle-wrapper.jar
# End of https://www.toptal.com/developers/gitignore/api/androidstudio,gradle,intellij+all
# Directory for checkouts of projects built by includegit-gradle-plugin
/checkouts/
+23
View File
@@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
+1 -27
View File
@@ -16,30 +16,4 @@ Snapshots from the development branch can be obtained [here](https://github.com/
## License
```
Copyright (c) 2021 Harsh Shandilya
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
```
See [LICENSE](LICENSE)
+18 -20
View File
@@ -1,18 +1,27 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
import dagger.hilt.android.plugin.HiltExtension
plugins {
id("dev.msfjarvis.claw.android-application")
id("dev.msfjarvis.claw.rename-artifacts")
id("dev.msfjarvis.claw.kotlin-android")
id("dev.msfjarvis.claw.kotlin-kapt")
id("dev.msfjarvis.claw.versioning-plugin")
alias(libs.plugins.hilt)
alias(libs.plugins.napt)
alias(libs.plugins.anvil)
alias(libs.plugins.whetstone)
}
// Hilt's aggregating task fails with NAPT
extensions.getByType<HiltExtension>().enableAggregatingTask = false
whetstone {
addOns {
compose.set(true)
workManager.set(true)
}
}
android {
namespace = "dev.msfjarvis.claw.android"
@@ -29,21 +38,15 @@ android {
isDebuggable = false
}
}
lint {
abortOnError = false
checkReleaseBuilds = false
warningsAsErrors = false
disable.add("DialogFragmentCallbacksDetector")
baseline = file("lint-baseline.xml")
}
}
dependencies {
kapt(libs.dagger.compiler)
implementation(platform(libs.androidx.compose.bom))
annotationProcessor(libs.androidx.hilt.compiler)
annotationProcessor(libs.dagger.hilt.compiler)
implementation(libs.dagger)
implementation(projects.api)
implementation(projects.common)
implementation(projects.core)
implementation(projects.coroutineUtils)
implementation(projects.database)
implementation(projects.metadataExtractor)
@@ -53,19 +56,14 @@ dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.hilt.work)
implementation(libs.androidx.lifecycle.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.paging.compose)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.coil)
implementation(libs.copydown)
implementation(libs.dagger.hilt.android)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.material.motion.core)
implementation(libs.material.motion.navigation)
implementation(libs.okhttp.loggingInterceptor)
implementation(libs.retrofit.kotlinxSerializationConverter)
implementation(libs.sqldelight.extensions.coroutines)
}
@@ -1,53 +1,29 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android
import android.app.Application
import android.os.StrictMode
import android.util.Log
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.disk.DiskCache
import coil.memory.MemoryCache
import dagger.hilt.android.HiltAndroidApp
import io.github.aakira.napier.DebugAntilog
import io.github.aakira.napier.Napier
import com.deliveryhero.whetstone.Whetstone
import com.deliveryhero.whetstone.app.ApplicationComponentOwner
import com.deliveryhero.whetstone.app.ContributesAppInjector
import dev.msfjarvis.claw.core.injection.AppPlugin
import javax.inject.Inject
@HiltAndroidApp
class ClawApplication : Application(), Configuration.Provider, ImageLoaderFactory {
@Inject lateinit var workerFactory: HiltWorkerFactory
@ContributesAppInjector(generateAppComponent = true)
class ClawApplication : Application(), ApplicationComponentOwner {
override val applicationComponent by
lazy(LazyThreadSafetyMode.NONE) { GeneratedApplicationComponent.create(this) }
@Inject lateinit var plugins: Set<@JvmSuppressWildcards AppPlugin>
override fun onCreate() {
Whetstone.inject(this)
super.onCreate()
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build())
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build())
Napier.base(DebugAntilog())
}
override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setMinimumLoggingLevel(Log.DEBUG)
.setWorkerFactory(workerFactory)
.build()
}
override fun newImageLoader(): ImageLoader {
return ImageLoader.Builder(this)
.memoryCache { MemoryCache.Builder(this).maxSizePercent(MEMORY_CACHE_RATIO).build() }
.diskCache {
DiskCache.Builder()
.directory(cacheDir.resolve("image_cache"))
.maxSizeBytes(DISK_CACHE_MAX_SIZE)
.build()
}
// Show a short crossfade when loading images asynchronously.
.crossfade(true)
.build()
}
private companion object {
private const val MEMORY_CACHE_RATIO = 0.25
private const val DISK_CACHE_MAX_SIZE = 25L * 1024 * 1024 // 25 MB
plugins.forEach { plugin -> plugin.apply(this) }
}
}
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android
import android.app.assist.AssistContent
@@ -11,7 +17,8 @@ import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import dagger.hilt.android.AndroidEntryPoint
import com.deliveryhero.whetstone.Whetstone
import com.deliveryhero.whetstone.activity.ContributesActivityInjector
import dev.msfjarvis.claw.android.ui.LobstersApp
import dev.msfjarvis.claw.android.work.SavedPostUpdaterWorker
import dev.msfjarvis.claw.common.comments.HTMLConverter
@@ -19,7 +26,7 @@ import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
import java.util.concurrent.TimeUnit
import javax.inject.Inject
@AndroidEntryPoint
@ContributesActivityInjector
class MainActivity : ComponentActivity() {
@Inject lateinit var urlLauncher: UrlLauncher
@@ -29,6 +36,7 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
Whetstone.inject(this)
setContent {
LobstersApp(
urlLauncher = urlLauncher,
@@ -1,16 +1,22 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import com.deliveryhero.whetstone.app.ApplicationScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.claw.util.coroutines.DefaultDispatcherProvider
import dev.msfjarvis.claw.util.coroutines.DispatcherProvider
import kotlinx.coroutines.CoroutineDispatcher
@Module
@InstallIn(SingletonComponent::class)
@ContributesTo(ApplicationScope::class)
interface CoroutineDispatcherModule {
@Binds fun DefaultDispatcherProvider.bind(): DispatcherProvider
@@ -1,20 +0,0 @@
package dev.msfjarvis.claw.android.injection
import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.claw.database.LobstersDatabase
import dev.msfjarvis.claw.database.local.createDatabase
@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
@Provides
fun provideDatabase(@ApplicationContext context: Context): LobstersDatabase {
return createDatabase(context)
}
}
@@ -1,14 +1,20 @@
/*
* Copyright © 2021 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import com.deliveryhero.whetstone.app.ApplicationScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.claw.common.comments.HTMLConverter
import io.github.furstenheim.CopyDown
@Module
@InstallIn(SingletonComponent::class)
@ContributesTo(ApplicationScope::class)
object HTMLConverterModule {
@Provides
@@ -1,14 +1,20 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import com.chimbori.crux.Crux
import com.deliveryhero.whetstone.app.ApplicationScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
@Module
@InstallIn(SingletonComponent::class)
@ContributesTo(ApplicationScope::class)
object MetadataExtractorModule {
@Provides
fun provideCrux(
@@ -1,18 +1,24 @@
/*
* Copyright © 2021 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import android.content.Context
import com.deliveryhero.whetstone.ForScope
import com.deliveryhero.whetstone.activity.ActivityScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.qualifiers.ActivityContext
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
@Module
@InstallIn(ActivityComponent::class)
@ContributesTo(ActivityScope::class)
object UrlLauncherModule {
@Provides
fun provideUrlLauncher(@ActivityContext context: Context): UrlLauncher {
fun provideUrlLauncher(@ForScope(ActivityScope::class) context: Context): UrlLauncher {
return UrlLauncher(context)
}
}
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import javax.inject.Qualifier
@@ -1,19 +0,0 @@
package dev.msfjarvis.claw.android.network
import dev.msfjarvis.claw.android.BuildConfig
import javax.inject.Inject
import okhttp3.Interceptor
import okhttp3.Response
/** An OkHttp [Interceptor] that adds a recognizable User-Agent header to all network requests. */
class UserAgentInterceptor @Inject constructor() : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
return chain.proceed(
chain
.request()
.newBuilder()
.header("User-Agent", "Claw-Android/${BuildConfig.VERSION_NAME}/msfjarvis")
.build()
)
}
}
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.paging
import androidx.paging.PagingSource
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.paging
import com.slack.eithernet.ApiResult
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui
import androidx.compose.animation.ExperimentalAnimationApi
@@ -21,12 +27,12 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavType
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.paging.compose.collectAsLazyPagingItems
import com.deliveryhero.whetstone.compose.injectedViewModel
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import dev.msfjarvis.claw.android.R
import dev.msfjarvis.claw.android.ui.decorations.ClawNavigationBar
@@ -56,7 +62,7 @@ fun LobstersApp(
urlLauncher: UrlLauncher,
htmlConverter: HTMLConverter,
setWebUri: (String?) -> Unit,
viewModel: ClawViewModel = viewModel(),
viewModel: ClawViewModel = injectedViewModel(),
) {
val systemUiController = rememberSystemUiController()
val hottestListState = rememberLazyListState()
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.decorations
import androidx.compose.animation.AnimatedVisibility
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui
import android.content.Context
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.lists
import androidx.compose.foundation.ExperimentalFoundationApi
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.lists
import androidx.compose.runtime.Composable
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.lists
import androidx.compose.foundation.layout.Box
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.navigation
sealed class Destinations {
@@ -1,12 +1,18 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.viewmodel
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import com.deliveryhero.whetstone.viewmodel.ContributesViewModel
import com.slack.eithernet.ApiResult.Failure
import com.slack.eithernet.ApiResult.Success
import dagger.hilt.android.lifecycle.HiltViewModel
import dev.msfjarvis.claw.android.injection.IODispatcher
import dev.msfjarvis.claw.android.paging.LobstersPagingSource
import dev.msfjarvis.claw.android.ui.toLocalDateTime
@@ -21,7 +27,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@HiltViewModel
@ContributesViewModel
class ClawViewModel
@Inject
constructor(
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.viewmodel
import dev.msfjarvis.claw.metadata.MetadataExtractor
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.viewmodel
import app.cash.sqldelight.coroutines.asFlow
@@ -1,20 +1,26 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.work
import android.content.Context
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.deliveryhero.whetstone.ForScope
import com.deliveryhero.whetstone.worker.ContributesWorker
import com.deliveryhero.whetstone.worker.WorkerScope
import com.slack.eithernet.ApiResult
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import dev.msfjarvis.claw.android.viewmodel.SavedPostsRepository
import dev.msfjarvis.claw.api.LobstersApi
import dev.msfjarvis.claw.common.posts.toDbModel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import javax.inject.Inject
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.supervisorScope
/**
* WorkManager-backed [CoroutineWorker] that gets all the posts from [SavedPostsRepository], fetches
@@ -22,28 +28,29 @@ import kotlinx.coroutines.flow.first
* saved posts that were saved before comment counts were added to be able to show a comment count
* and for new-enough posts that are still getting comments to have an accurate one.
*/
@Suppress("DEPRECATION") // We're being nasty
@HiltWorker
@ContributesWorker
class SavedPostUpdaterWorker
@AssistedInject
@Inject
constructor(
@ForScope(WorkerScope::class) appContext: Context,
workerParams: WorkerParameters,
private val savedPostsRepository: SavedPostsRepository,
private val lobstersApi: LobstersApi,
@Assisted appContext: Context,
@Assisted workerParams: WorkerParameters,
) : CoroutineWorker(appContext, workerParams) {
override suspend fun doWork(): Result {
val posts = savedPostsRepository.savedPosts.first()
posts
.map { post ->
CoroutineScope(coroutineContext + Job()).async {
val details = runCatching { lobstersApi.getPostDetails(post.shortId) }.getOrNull()
if (details is ApiResult.Success) {
savedPostsRepository.savePost(details.value.toDbModel())
supervisorScope {
posts
.map { post ->
async {
val details = lobstersApi.getPostDetails(post.shortId)
if (details is ApiResult.Success) {
savedPostsRepository.savePost(details.value.toDbModel())
}
}
}
}
.awaitAll()
.awaitAll()
}
return Result.success()
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
#
# This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
#
versioning-plugin.versionCode=10300
versioning-plugin.versionName=1.3.0
versioning-plugin.versionCode=10600
versioning-plugin.versionName=1.6.0
+17 -2
View File
@@ -1,14 +1,29 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
kotlin("jvm")
id("dev.msfjarvis.claw.kotlin-library")
kotlin("android")
id("dev.msfjarvis.claw.kotlin-common")
id("dev.msfjarvis.claw.android-library")
alias(libs.plugins.anvil)
alias(libs.plugins.whetstone)
}
android { namespace = "dev.msfjarvis.claw.api" }
anvil { generateDaggerFactories.set(true) }
dependencies {
api(projects.model)
api(libs.retrofit)
api(libs.eithernet)
implementation(libs.dagger)
implementation(libs.javax.inject)
testImplementation(testFixtures(libs.eithernet))
testImplementation(kotlin("test-junit"))
testImplementation(libs.kotlinx.coroutines.core)
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.0.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.0.0-alpha08)" variant="all" version="8.0.0-alpha08">
</issues>
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.api
import com.slack.eithernet.ApiResult
@@ -1,36 +1,37 @@
package dev.msfjarvis.claw.android.injection
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.api.injection
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.deliveryhero.whetstone.app.ApplicationScope
import com.slack.eithernet.ApiResultCallAdapterFactory
import com.slack.eithernet.ApiResultConverterFactory
import com.squareup.anvil.annotations.ContributesTo
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.claw.api.LobstersApi
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.create
@OptIn(ExperimentalSerializationApi::class)
@Module
@InstallIn(SingletonComponent::class)
@ContributesTo(ApplicationScope::class)
object ApiModule {
@Provides
fun provideRetrofit(
client: OkHttpClient,
json: Json,
converterFactories: Set<@JvmSuppressWildcards Converter.Factory>,
): Retrofit {
val contentType = "application/json".toMediaType()
return Retrofit.Builder()
.client(client)
.baseUrl(LobstersApi.BASE_URL)
.addConverterFactory(ApiResultConverterFactory)
.addConverterFactory(json.asConverterFactory(contentType))
.addCallAdapterFactory(ApiResultCallAdapterFactory)
.apply { converterFactories.forEach(this::addConverterFactory) }
.build()
}
@@ -38,9 +39,4 @@ object ApiModule {
fun provideApi(retrofit: Retrofit): LobstersApi {
return retrofit.create()
}
@Provides
fun provideJsonSerializer(): Json {
return Json { ignoreUnknownKeys = true }
}
}
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.api
import com.slack.eithernet.ApiResult.Success
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.api
import com.slack.eithernet.ApiResult.Companion.success
@@ -1,3 +1,9 @@
/*
* Copyright © 2021 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.util
import java.io.File
+6
View File
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.benchmark
import androidx.benchmark.macro.BaselineProfileMode
@@ -1,6 +1,11 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.benchmark
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
import androidx.benchmark.macro.junit4.BaselineProfileRule
import androidx.test.filters.MediumTest
import androidx.test.platform.app.InstrumentationRegistry
@@ -9,7 +14,6 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ExperimentalBaselineProfilesApi
@MediumTest
class BaselineProfileGenerator {
@get:Rule val baselineProfileRule = BaselineProfileRule()
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.benchmark
import androidx.benchmark.macro.MacrobenchmarkScope
+4 -3
View File
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
import org.gradle.api.JavaVersion
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.withType
@@ -1,9 +1,20 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("UnstableApiUsage")
package dev.msfjarvis.aps.gradle
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.Lint
import com.android.build.api.dsl.TestExtension
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.gradle.android.AndroidCacheFixPlugin
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
@@ -13,7 +24,6 @@ import org.gradle.kotlin.dsl.findByType
private const val SLIM_TESTS_PROPERTY = "slimTests"
@Suppress("UnstableApiUsage")
class AndroidCommonPlugin : Plugin<Project> {
private companion object {
@@ -21,9 +31,12 @@ class AndroidCommonPlugin : Plugin<Project> {
const val MIN_SDK = 26
const val TARGET_SDK = 33
}
override fun apply(project: Project) {
project.configureSlimTests()
project.pluginManager.apply(AndroidCacheFixPlugin::class)
project.extensions.findByType<BaseAppModuleExtension>()?.run { lint.configureLint(project) }
project.extensions.findByType<LibraryExtension>()?.run { lint.configureLint(project) }
project.extensions.findByType<TestedExtension>()?.run {
compileSdkVersion(COMPILE_SDK)
defaultConfig {
@@ -75,6 +88,14 @@ class AndroidCommonPlugin : Plugin<Project> {
}
}
private fun Lint.configureLint(project: Project) {
abortOnError = false
checkReleaseBuilds = false
warningsAsErrors = false
disable.add("DialogFragmentCallbacksDetector")
baseline = project.file("lint-baseline.xml")
}
/**
* When the "slimTests" project property is provided, disable the unit test tasks on `release` build
* type and `nonFree` product flavor to avoid running the same tests repeatedly in different build
@@ -83,7 +104,7 @@ class AndroidCommonPlugin : Plugin<Project> {
* Examples: `./gradlew test -PslimTests` will run unit tests for `nonFreeDebug` and `debug` build
* variants in Android App and Library projects, and all tests in JVM projects.
*/
internal fun Project.configureSlimTests() {
private fun Project.configureSlimTests() {
if (providers.gradleProperty(SLIM_TESTS_PROPERTY).isPresent) {
// Disable unit test tasks on the release build type for Android Library projects
extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("UnstableApiUsage")
package dev.msfjarvis.aps.gradle
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import com.android.build.gradle.LibraryPlugin
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import com.android.build.api.artifact.SingleArtifact
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.artifacts
import com.android.build.api.variant.BuiltArtifactsLoader
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.artifacts
import java.io.File
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.signing
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.versioning
const val VERSIONING_PROP_FILE = "version.properties"
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.versioning
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle.versioning
import com.vdurmont.semver4j.Semver
+8 -3
View File
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
import org.gradle.api.JavaVersion
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.withType
@@ -34,6 +35,10 @@ gradlePlugin {
id = "dev.msfjarvis.claw.kotlin-common"
implementationClass = "dev.msfjarvis.aps.gradle.KotlinCommonPlugin"
}
register("kotlin-kapt") {
id = "dev.msfjarvis.claw.kotlin-kapt"
implementationClass = "dev.msfjarvis.aps.gradle.KotlinKaptPlugin"
}
register("kotlin-library") {
id = "dev.msfjarvis.claw.kotlin-library"
implementationClass = "dev.msfjarvis.aps.gradle.KotlinLibraryPlugin"
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import com.github.benmanes.gradle.versions.VersionsPlugin
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import io.gitlab.arturbosch.detekt.DetektPlugin
@@ -6,7 +12,7 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
object Detekt {
private const val TWITTER_RULES_VERSION = "0.0.22"
private const val TWITTER_RULES_VERSION = "0.0.24"
fun apply(project: Project) {
project.pluginManager.apply(DetektPlugin::class.java)
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import org.gradle.api.Plugin
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import org.gradle.api.JavaVersion
@@ -26,7 +27,8 @@ class KotlinCommonPlugin : Plugin<Project> {
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
allWarningsAsErrors = project.providers.environmentVariable("GITHUB_WORKFLOW").isPresent
allWarningsAsErrors =
false // project.providers.environmentVariable("GITHUB_WORKFLOW").isPresent
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = freeCompilerArgs + ADDITIONAL_COMPILER_ARGS
languageVersion = "1.7"
@@ -0,0 +1,53 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.KaptExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
@Suppress("Unused")
class KotlinKaptPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.run {
apply(KotlinAndroidPluginWrapper::class)
apply(Kapt3GradleSubplugin::class)
}
project.afterEvaluate {
project.extensions.getByType<KaptExtension>().run {
javacOptions {
if (hasDaggerCompilerDependency()) {
// https://dagger.dev/dev-guide/compiler-options#fastinit-mode
option("-Adagger.fastInit=enabled")
// Enable the better, experimental error messages
// https://github.com/google/dagger/commit/0d2505a727b54f47b8677f42dd4fc5c1924e37f5
option("-Adagger.experimentalDaggerErrorMessages=enabled")
// KAPT nests errors causing real issues to be suppressed in CI logs
option("-Xmaxerrs", 500)
// Enables per-module validation for faster error detection
// https://github.com/google/dagger/commit/325b516ac6a53d3fc973d247b5231fafda9870a2
option("-Adagger.moduleBindingValidation=ERROR")
}
}
}
}
project.tasks
.matching { it.name.startsWith("kapt") && it.name.endsWith("UnitTestKotlin") }
.configureEach { enabled = false }
}
private fun Project.hasDaggerCompilerDependency(): Boolean {
return configurations.any {
it.dependencies.any { dependency -> dependency.name == "dagger-compiler" }
}
}
}
@@ -1,8 +1,9 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import org.gradle.api.Plugin
@@ -1,12 +1,14 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.aps.gradle
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
@@ -16,21 +18,26 @@ import org.gradle.kotlin.dsl.getByType
class SpotlessPlugin : Plugin<Project> {
override fun apply(project: Project) {
if (project.rootProject != project) {
throw GradleException("Spotless plugin must only be applied to the root project.")
}
project.pluginManager.apply(SpotlessPlugin::class)
project.extensions.getByType<SpotlessExtension>().run {
kotlin {
ktfmt(KTFMT_VERSION).googleStyle()
target("**/*.kt")
targetExclude("**/build/", "**/gen/")
targetExclude("**/build/", "/spotless/", "/checkouts/")
licenseHeaderFile(project.file("spotless/license.kt"))
}
kotlinGradle {
ktfmt(KTFMT_VERSION).googleStyle()
target("**/*.kts")
targetExclude("**/build/")
targetExclude("**/build/", "/checkouts/")
licenseHeaderFile(project.file("spotless/license.kt"), "import|plugins|@file")
}
format("xml") {
target("**/*.xml")
targetExclude("**/build/", ".idea/")
targetExclude("**/build/", ".idea/", "/checkouts/")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
+4 -2
View File
@@ -1,6 +1,8 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("UnstableApiUsage")
+6 -1
View File
@@ -1,9 +1,14 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("dev.msfjarvis.claw.spotless")
id("dev.msfjarvis.claw.versions")
id("dev.msfjarvis.claw.kotlin-common")
alias(libs.plugins.hilt) apply false
alias(libs.plugins.android.test) apply false
}
+11
View File
@@ -1,16 +1,27 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
kotlin("android")
id("dev.msfjarvis.claw.kotlin-common")
id("dev.msfjarvis.claw.android-library")
alias(libs.plugins.anvil)
alias(libs.plugins.whetstone)
}
anvil { generateDaggerFactories.set(true) }
androidComponents { beforeVariants { it.enableUnitTest = false } }
dependencies {
implementation(platform(libs.androidx.compose.bom))
api(libs.napier)
implementation(projects.core)
implementation(projects.database)
implementation(projects.model)
implementation(libs.accompanist.flowlayout)
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.0.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.0.0-alpha08)" variant="all" version="8.0.0-alpha08">
</issues>
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common
sealed class NetworkState {
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.comments
import android.text.format.DateUtils
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.comments
import androidx.compose.foundation.layout.PaddingValues
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.comments
/** Defines a contract to convert strings of HTML to Markdown. */
@@ -0,0 +1,37 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.injection
import android.app.Application
import coil.Coil
import coil.ImageLoader
import coil.disk.DiskCache
import coil.memory.MemoryCache
import dev.msfjarvis.claw.core.injection.AppPlugin
class CoilAppPlugin : AppPlugin {
override fun apply(application: Application) {
Coil.setImageLoader {
ImageLoader.Builder(application)
.memoryCache { MemoryCache.Builder(application).maxSizePercent(MEMORY_CACHE_RATIO).build() }
.diskCache {
DiskCache.Builder()
.directory(application.cacheDir.resolve("image_cache"))
.maxSizeBytes(DISK_CACHE_MAX_SIZE)
.build()
}
// Show a short crossfade when loading images asynchronously.
.crossfade(true)
.build()
}
}
private companion object {
private const val MEMORY_CACHE_RATIO = 0.25
private const val DISK_CACHE_MAX_SIZE = 25L * 1024 * 1024 // 25 MB
}
}
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.posts
import androidx.compose.animation.Crossfade
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.posts
import dev.msfjarvis.claw.database.local.SavedPost
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.posts
import dev.msfjarvis.claw.database.local.SavedPost
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.res
import dev.msfjarvis.claw.common.res.clawicons.account_circle_black_24dp
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress(
"ClassNaming",
"FunctionNaming",
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.theme
import androidx.compose.ui.graphics.Color
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.theme
import android.os.Build
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.theme
import androidx.compose.material3.Typography
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.material3.LocalContentColor
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.foundation.clickable
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.runtime.Composable
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.foundation.layout.Box
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui.decorations
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui.decorations
import androidx.compose.foundation.background
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.material3.ColorScheme
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("NON_SOURCE_REPEATED_ANNOTATION") // IDE false-positive
package dev.msfjarvis.claw.common.ui.preview
@@ -1,3 +1,9 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.urllauncher
import android.content.ActivityNotFoundException
@@ -1,3 +1,9 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.user
import androidx.compose.foundation.layout.Arrangement
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
@file:Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
kotlin("android")
id("dev.msfjarvis.claw.kotlin-common")
id("dev.msfjarvis.claw.android-library")
alias(libs.plugins.anvil)
alias(libs.plugins.whetstone)
}
anvil { generateDaggerFactories.set(true) }
android { namespace = "dev.msfjarvis.claw.core" }
dependencies {
api(libs.kotlinx.serialization.json)
api(libs.okhttp.loggingInterceptor)
implementation(libs.dagger)
implementation(libs.javax.inject)
implementation(libs.napier)
implementation(libs.okhttp.core)
implementation(libs.retrofit.kotlinxSerializationConverter)
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.0.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.0.0-alpha08)" variant="all" version="8.0.0-alpha08">
</issues>
@@ -0,0 +1,14 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.core.injection
import android.app.Application
/** Basic plugin-based architecture for doing things at [Application] initialization. */
interface AppPlugin {
fun apply(application: Application)
}
@@ -1,17 +1,23 @@
package dev.msfjarvis.claw.android.injection
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.core.injection
import android.content.Context
import android.net.TrafficStats
import com.deliveryhero.whetstone.ForScope
import com.deliveryhero.whetstone.app.ApplicationScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import dagger.multibindings.IntoSet
import dev.msfjarvis.claw.android.network.DelegatingSocketFactory
import dev.msfjarvis.claw.android.network.NapierLogger
import dev.msfjarvis.claw.android.network.UserAgentInterceptor
import dev.msfjarvis.claw.core.network.DelegatingSocketFactory
import dev.msfjarvis.claw.core.network.NapierLogger
import dev.msfjarvis.claw.core.network.UserAgentInterceptor
import java.net.Socket
import javax.net.SocketFactory
import okhttp3.Cache
@@ -20,7 +26,7 @@ import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
@Module
@InstallIn(SingletonComponent::class)
@ContributesTo(ApplicationScope::class)
interface OkHttpModule {
@Binds fun NapierLogger.bindLogger(): HttpLoggingInterceptor.Logger
@@ -32,7 +38,7 @@ interface OkHttpModule {
private const val THREAD_STATS_TAG = 0x000090000
@Provides
fun provideCache(@ApplicationContext context: Context): Cache {
fun provideCache(@ForScope(ApplicationScope::class) context: Context): Cache {
return Cache(context.cacheDir, CACHE_SIZE_MB)
}
@@ -64,7 +70,7 @@ interface OkHttpModule {
@Provides
@IntoSet
fun provideHttpLoggingInterceptor(logger: HttpLoggingInterceptor.Logger): Interceptor {
return HttpLoggingInterceptor(logger).setLevel(HttpLoggingInterceptor.Level.HEADERS)
return HttpLoggingInterceptor(logger).setLevel(HttpLoggingInterceptor.Level.BASIC)
}
}
}

Some files were not shown because too many files have changed in this diff Show More