Skip to content

Commit b619923

Browse files
committed
docs: add MIT license and JitPack release setup
1 parent b9d003e commit b619923

4 files changed

Lines changed: 127 additions & 0 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build
2+
on:
3+
push:
4+
pull_request:
5+
permissions:
6+
contents: read
7+
jobs:
8+
verify:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-java@v4
13+
with:
14+
distribution: temurin
15+
java-version: '17'
16+
- uses: android-actions/setup-android@v3
17+
- uses: gradle/actions/setup-gradle@v4
18+
- run: ./gradlew testDebugUnitTest lintRelease publishToMavenLocal

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Halil Özel
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# CodeBlockView
2+
3+
An Android View for displaying read-only code snippets. Extracted from
4+
[Kotlin](https://github.com/halilozel1903/Kotlin).
5+
6+
- Kotlin syntax highlighting, line numbers and horizontal scrolling
7+
- Selectable source and a copy button that preserves the original whitespace
8+
- Light/dark palettes and English/Turkish copy labels
9+
- XML and Kotlin usage; no network access or permissions
10+
11+
## Install
12+
13+
Requires Android API 24+, a Material Components/Material 3 theme, and a consumer
14+
build compatible with the AndroidX/Material dependencies (compile SDK 37 for the
15+
versions used in this release). The library is built with Java 17 and AGP 9.4.0.
16+
17+
Add the repository in `settings.gradle.kts`:
18+
19+
```kotlin
20+
dependencyResolutionManagement {
21+
repositories {
22+
google()
23+
mavenCentral()
24+
maven("https://jitpack.io") {
25+
content { includeGroup("com.github.halilozel1903") }
26+
}
27+
}
28+
}
29+
```
30+
31+
Add the versioned dependency in your module:
32+
33+
```kotlin
34+
implementation("com.github.halilozel1903:CodeBlockView:1.0.0")
35+
```
36+
37+
## Usage
38+
39+
```xml
40+
<com.halilozel.codeblockview.CodeBlockView
41+
android:id="@+id/codeBlock"
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content" />
44+
```
45+
46+
```kotlin
47+
import com.halilozel.codeblockview.CodeBlockView
48+
49+
val codeBlock = findViewById<CodeBlockView>(R.id.codeBlock)
50+
codeBlock.setCode("val greeting = \"Hello Kotlin\"\nprintln(greeting)")
51+
// Other language labels are displayed as plain text, without Kotlin highlighting.
52+
codeBlock.setCode("SELECT * FROM users", language = "sql")
53+
```
54+
55+
`setCode(source, language)` replaces the snippet and resets the copy button.
56+
The default language is `kotlin`; `kt` and `kts` also enable highlighting.
57+
An empty language shows a localized “Code” label. Empty source disables copying.
58+
The tokenizer is a lightweight display helper, not a compiler or full parser.
59+
This is an Android View, not a Compose component or code editor.
60+
61+
## Appearance and localization
62+
63+
The host activity must use a theme derived from `Theme.MaterialComponents` or
64+
`Theme.Material3`. Colors adapt to Android's night mode. Override the `cbv_`
65+
resources in your app's `values` / `values-night` directories to customize the
66+
palette (for example `cbv_code_keyword` or `cbv_code_block_background`).
67+
Copy button labels use `cbv_code_copy`, `cbv_code_copied`, `cbv_code_clip_label`
68+
and `cbv_code_plain`; provide localized overrides for additional languages.
69+
70+
## Build and contribute
71+
72+
Install JDK 17 and Android SDK 37, then run:
73+
74+
```sh
75+
./gradlew testDebugUnitTest lintRelease publishToMavenLocal
76+
```
77+
78+
Pull requests and issues are welcome. Keep source-copy behavior and token ranges
79+
covered by tests. CI checks tests, lint and the Maven publication. Releases use
80+
immutable version tags consumed through [JitPack](https://docs.jitpack.io/android/).
81+
82+
## License
83+
84+
[MIT](LICENSE).

‎jitpack.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jdk:
2+
- openjdk17
3+
install:
4+
- ./gradlew testDebugUnitTest lintRelease publishToMavenLocal

0 commit comments

Comments
 (0)