Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p1: Add Gradle binary compatibility plugin #145

Merged
merged 54 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
25b284c
Add gradle binary compatibility checker plugin
ab-gnm Dec 6, 2024
d68f673
Generate API dump for Source
ab-gnm Dec 6, 2024
f1c0686
Import `DensityExtensions` from news project
ab-gnm Dec 6, 2024
cd0c601
Create `ExpandingText` component
ab-gnm Dec 6, 2024
51be8f3
Add `SourceBaseChip`
ab-gnm Dec 6, 2024
d490089
Add `SourceChip` with text only
ab-gnm Dec 6, 2024
26c9007
Simplify `SourceBaseChip` to provide just a single `content` lambda
ab-gnm Dec 7, 2024
0c36ef5
Lint issues in build scripts
ab-gnm Dec 7, 2024
2ee1133
Remove inner text padding from `ExpandingText`
ab-gnm Dec 7, 2024
d58f631
Import marina_hyde.png cutout for previews
ab-gnm Dec 7, 2024
d33d2a7
Streamline styling of `SourceChip`
ab-gnm Dec 7, 2024
e7bca6b
Run lint in CI
ab-gnm Dec 7, 2024
7f757d3
Lint
ab-gnm Dec 7, 2024
81cc259
Extract `ChipIndicator` and provide variants for vector, painter, com…
ab-gnm Dec 7, 2024
aee0496
Add KDoc and preview for `ChipIndicator`
ab-gnm Dec 7, 2024
c2469c1
Update `HorizontalExpandingText` so it expands/collapses based on tex…
ab-gnm Dec 7, 2024
7bf5994
Use `HorizontalExpandingText` in `SourceChip`
ab-gnm Dec 7, 2024
deb9b60
Remove redundant label from manifest
ab-gnm Dec 7, 2024
ac62df5
Add screenshot test
ab-gnm Dec 7, 2024
4679eef
Separate style model for `SourceBaseChip`
ab-gnm Dec 7, 2024
d8b6fbb
Add selected state to `SourceChip`
ab-gnm Dec 7, 2024
2e1822b
Update screenshot test - remove tablet previews, add font scale previews
ab-gnm Dec 7, 2024
3968716
Add detekt baseline
ab-gnm Dec 7, 2024
20749ef
Lint
ab-gnm Dec 9, 2024
a5c49f1
Remove detekt convention plugin. Instead apply it to all module conve…
ab-gnm Dec 9, 2024
ee38878
Merge branch 'ab/change-detekt-config' into ab/add-chips-components
ab-gnm Dec 9, 2024
28e5587
Remove detekt convention plugin. Instead apply it to all module conve…
ab-gnm Dec 9, 2024
2101ef7
Merge branch 'ab/change-detekt-config' into ab/add-chips-components
ab-gnm Dec 9, 2024
7a458d3
Add detekt baseline
ab-gnm Dec 9, 2024
af173f1
Update lint baseline
ab-gnm Dec 9, 2024
0748699
Merge branch 'ab/change-detekt-config' into ab/add-chips-components
ab-gnm Dec 9, 2024
448bb21
Clean up previews, add dark mode support to screenshot test
ab-gnm Dec 9, 2024
959a75f
Baselines update
ab-gnm Dec 9, 2024
56a84fa
Add `SourceChipSupportingButton`
ab-gnm Dec 9, 2024
22f2d86
Move preview components inside package
ab-gnm Dec 9, 2024
6b1a416
Add preview to sample and clean up baseline
ab-gnm Dec 9, 2024
ee8ad1d
Make size mandatory in `SourceChipSupportingButton`
ab-gnm Dec 9, 2024
3f44b96
Split out single and multi select components as variants
ab-gnm Dec 9, 2024
d076255
Add README.md for chips
ab-gnm Dec 9, 2024
d813ae6
Split out `README.md` files for buttons and pager components as well
ab-gnm Dec 9, 2024
1ae8075
Update chips README.md
ab-gnm Dec 9, 2024
4bd3ef4
Formatting in README.md
ab-gnm Dec 9, 2024
1d44aca
Add example for version catalot
ab-gnm Dec 9, 2024
22eeeb2
Update minor version for addition of chips component
ab-gnm Dec 9, 2024
e24d0bb
Merge branch 'ab/add-chips-components' into ab/add-documentation
ab-gnm Dec 9, 2024
eb67513
Remove old `detekt-baseline-debug.xml`
ab-gnm Dec 9, 2024
1b70642
Merge branch 'ab/add-chips-components' into ab/add-documentation
ab-gnm Dec 9, 2024
75d603a
PR feedback driven changes:
ab-gnm Dec 10, 2024
697f2d5
Rename `ChipIndicator` to `ChipDecoration`
ab-gnm Dec 10, 2024
fd47629
Update baseline images
ab-gnm Dec 10, 2024
66e2e5f
Simplify table in KDoc
ab-gnm Dec 10, 2024
6a35af8
Merge pull request #149 from guardian/ab/add-documentation
ab-gnm Dec 12, 2024
62539e7
Merge pull request #148 from guardian/ab/change-detekt-config
ab-gnm Dec 12, 2024
13e0633
Merge pull request #146 from guardian/ab/add-chips-components
ab-gnm Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ jobs:
- name: Run ktlint
run: |
cd android
./gradlew lintKotlin --continue
./gradlew :build-logic:convention:lint --continue
./gradlew lint lintKotlin :build-logic:convention:lint --continue

detekt:
name: Detekt
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

[Android library details and usage notes are here.](/android/README.md).

[API documentation is here.](https://guardian.github.io/source-apps/android/docs/index.html).

# iOS Usage

## Adding the Swift Package To Xcode
Expand Down
188 changes: 32 additions & 156 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@

## Add the library dependency

Add the dependency to `build.gradle.kts` for the consuming module:
Add the dependency to `build.gradle.kts` for the consuming module.

In `build.gradle.kts`:

```kotlin
implementation("com.gu.source:source-android:<version>")
```

In version catalog:
```toml
[versions]
source = "<version>"

[libraries]
source = { module = "com.gu.source:source-android", version.ref = "source" }
```

<!-- Alternatively, add it to your app's core design module as an `api` dependency. It will be transitively available to all other modules:

```kotlin
Expand All @@ -28,7 +39,9 @@ The library provides design presets and components.

The design presets are available name spaced under the `com.gu.Source` object, e.g. `Source.Typography.HeadlineBold15`.

[API documentation is here.](https://guardian.github.io/source-apps/android/docs/index.html).
**[Full API documentation is available here.](https://guardian.github.io/source-apps/android/docs/index.html)**

---

### Typography presets

Expand Down Expand Up @@ -61,98 +74,31 @@ Text(
```

---

### Buttons

Four core button components are available - `SourceButton`, `SourceIconButton`, `PlainSourceButton` and `SourceBaseIconButton`.

#### Themed buttons


The first two source buttons have preset style and size variants corresponding to Source specifications. Both _Core_ and _Reader Revenue_ themes are provided. The latter two use Source defined sizing but can be used for custom colour schemes.
[See here for full details of the button components.][buttons]

| Core theme | Reader revenue theme |
| --- | --- |
| ![Core themed text only buttons](https://github.com/user-attachments/assets/e69393fb-675b-4f0e-9f52-62a28736bcfc) | ![Reader revenue themed text only buttons](https://github.com/user-attachments/assets/7ca3d409-252e-45e1-964f-efd03b1ebe39) |

##### Usage examples

Using `SourceButton`:
```kotlin
SourceButton(
text = "Sign in",
priority = SourceButton.Priority.PrimaryOnWhite,
onClick = {},
size = SourceButton.Size.Small,
)
```

Using `SourceIconButton` with a Material Icon:
```kotlin
SourceIconButton(
icon = Icons.Default.Person,
priority = SourceButton.Priority.SecondaryOnBlue,
contentDescription = null,
onClick = {},
size = SourceButton.Size.Medium,
)
```

Using `SourceIconButton` with a drawable resource:
```kotlin
SourceIconButton(
painter = painterResource(R.drawable.ic_person),
priority = SourceButton.Priority.SecondaryOnBlue,
contentDescription = null,
onClick = {},
)
```

#### Base buttons
---

The plain and base buttons are intended for when custom colour schemes are needed. These do not use preconfigured `priority` or `theme`. They expect to be directly be provided with `ButtonColours`. (`PlainSourceButton` is available from version `0.2.1`, `SourceBaseIconButton` is available from `0.3.0`)
### Chips

##### Usage examples
Chip components are typically used for filter, tags, or actions in a concise
format.

```kotlin
PlainSourceButton(
text = "Culture themed",
onClick = {},
modifier = Modifier.align(CenterHorizontally),
buttonColours = ButtonColours(
border = AppColour(
light = Source.Palette.Culture200,
dark = Source.Palette.Culture800,
),
container = AppColour(
light = Source.Palette.Culture800,
dark = Source.Palette.Culture200,
),
content = AppColour(
light = Source.Palette.Culture200,
dark = Source.Palette.Culture800,
),
),
)
```

```kotlin
SourceBaseIconButton(
buttonColours = buttonColours,
size = SourceButton.Size.Small,
onClick = { },
) {
Icon(
imageVector = Source.Icons.Base.ChevronRight,
contentDescription = null,
modifier = it,
)
}
```
[See here for full details of the chip components.][chips]

---

### Pager progress components

There are three pager progress components available:
Three pager progress components are available:

1. `PagerProgressIndicator` - a set of indicators to signify progress as a user
progresses through the items in the pager
Expand All @@ -161,87 +107,12 @@ in a pager
3. `PagerProgressBar` - a higher level component that combines the above two
and has different phone and tablet behaviour.

[See here for more details on pager progress components.][pager]

#### `PagerProgressBar`

The `PagerProgressBar` component is used to signify progress as a user flips through the items in a `HorizontalPager`. It is typically used for image carousels.

The progress bar is styled to match Source specifications. It is expected to be placed below the pager.

On tablets, the bar also displays `PagerProgressButtons` to allow the user to go
to next or previous pages.

##### Usage example

![Progress bar for tablets](https://github.com/user-attachments/assets/ec1c2520-8c2c-42c0-9a8c-631054e77a67)


```kotlin
Column(
modifier = modifier .widthIn(max = 695.dp),
) {
HorizontalPager(
state = pagerState,
modifier = Modifier
.aspectRatio(695 / 544f)
.clip(RoundedCornerShape(16.dp)),
) { page ->
SampleImage(
randomKey = page,
modifier = Modifier.fillMaxWidth(),
)
}

// Place the bar below the pager
PagerProgressBar(pagerState = pagerState)
}
```

#### Custom progress indicators

`PagerProgressIndicator` is a lower level component used to signify progress in the bar. It provides a lot more options for customising appearance of the indicators.

##### Usage example:

![Custom indicator styling](https://github.com/user-attachments/assets/2d08a04d-a146-4ab0-a61c-5b8a89502cd1)


```kotlin
Column(modifier = Modifier.padding(8.dp)) {
HorizontalPager(state = pagerState) {
Box(
modifier = Modifier
.size(400.dp)
.background(Source.Palette.Neutral86, RoundedCornerShape(8.dp)),
) {
Text(
text = (it + 1).toString(),
style = Source.Typography.Titlepiece70,
modifier = Modifier.align(Alignment.Center),
color = Source.Palette.Neutral46,
)
}
}

// Place indicator below the pager, style it and set alignment explicitly
PagerProgressIndicator(
pagerState = pagerState,
selectedIndicatorColour = Source.Palette.Sport500,
unSelectedIndicatorColour = Source.Palette.Sport500.copy(alpha = 0.3F),
indicatorShape = CutCornerShape(8.dp),
maxIndicatorCount = 7,
numberOfItemsToScale = 5,
modifier = Modifier
.padding(top = 8.dp)
.align(Alignment.CenterHorizontally),
)
}
```

#### `PagerProgressButton`s

A set of next & previous icon buttons to progress through the pages. The button
enabled state depends on availability of a next/previous page.
---

### Alert banners

Expand Down Expand Up @@ -305,4 +176,9 @@ AlertBanner(

### Other notes

1. We use the `com.gu` package name and group id so we can use the Guardian's Sonatype infra for signing and publishing the library. See [this comment](https://github.com/guardian/source-android/pull/10/files?w=1#r1567071142) for reference.
1. We use the `com.gu` package name and group id so we can use the Guardian's Sonatype infra for signing and publishing the library. See [this comment](https://github.com/guardian/source-android/pull/10/files?w=1#r1567071142) for reference.


[buttons]: ./source/src/main/kotlin/com/gu/source/components/buttons/README.md
[pager]: ./source/src/main/kotlin/com/gu/source/components/pager/README.md
[chips]: ./source/src/main/kotlin/com/gu/source/components/chips/README.md
5 changes: 0 additions & 5 deletions android/build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ gradlePlugin {
implementationClass = "com.theguardian.convention.ComposeApplicationConventionPlugin"
version = "1"
}
register("guardianDetektPlugin") {
id = "com.theguardian.detekt"
implementationClass = "com.theguardian.convention.DetektPlugin"
version = "1"
}
register("androidTestPlugin") {
id = "com.theguardian.test.android"
implementationClass = "com.theguardian.convention.AndroidTestConventionPlugin"
Expand Down
23 changes: 17 additions & 6 deletions android/build-logic/convention/gradle-lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.7.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.2)" variant="all" version="8.7.2">
<issues format="6" by="lint 8.7.3" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.3)" variant="all" version="8.7.3">

<issue
id="GradleProjectIsolation"
message="Avoid using method getRootProject"
errorLine1=" val rootProject = target.rootProject"
errorLine2=" ~~~~~~~~~~~">
errorLine1=" rootProject.layout.buildDirectory.file(&quot;reports/detekt/merge.sarif&quot;),"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/kotlin/com/theguardian/convention/DetektPlugin.kt"
line="23"
column="38"/>
file="src/main/kotlin/com/theguardian/convention/shared/SetupDetekt.kt"
line="20"
column="17"/>
</issue>

<issue
id="GradleProjectIsolation"
message="Avoid using method getRootProject"
errorLine1=" basePath = rootProject.projectDir.absolutePath"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/kotlin/com/theguardian/convention/shared/SetupDetekt.kt"
line="57"
column="24"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.theguardian.convention

import com.android.build.api.dsl.ApplicationExtension
import com.theguardian.convention.shared.configureAndroidModule
import com.theguardian.convention.shared.configureAndroidTests
import com.theguardian.convention.shared.libs
import com.theguardian.convention.shared.plugin
import com.theguardian.convention.shared.*
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
Expand All @@ -29,6 +26,8 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
apply(libs.plugin("kotlinter").pluginId)
}

setupDetekt()

extensions.configure<ApplicationExtension> {
defaultConfig {
targetSdk = libs.findVersion("targetsdk").get().toString().toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
apply(libs.plugin("kotlinter").pluginId)
}

setupDetekt()

extensions.configure<LibraryExtension> {
configureAndroidModule<KotlinAndroidProjectExtension>(this)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.theguardian.convention

import com.android.build.gradle.TestExtension
import com.theguardian.convention.shared.configureAndroidModule
import com.theguardian.convention.shared.configureAndroidTests
import com.theguardian.convention.shared.libs
import com.theguardian.convention.shared.plugin
import com.theguardian.convention.shared.*
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
Expand All @@ -29,6 +26,8 @@ class AndroidTestConventionPlugin : Plugin<Project> {
apply(libs.plugin("kotlinter").pluginId)
}

setupDetekt()

extensions.configure<TestExtension> {
configureAndroidModule<KotlinAndroidProjectExtension>(this)

Expand Down
Loading
Loading