Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 20 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
name: Build
on: [pull_request, push]

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Build the app
- name: Checkout
uses: actions/checkout@v4

- name: Configure JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '17'
cache: gradle

- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4

- name: Build
run: ./gradlew build
33 changes: 33 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Release

on:
push:
tags:
- '*'

env:
RELEASE_SIGNING_ENABLED: true

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'Commit451/coil-imagegetter'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '17'
cache: gradle

- name: Release to Maven Central
run: ./gradlew publishAndReleaseToMavenCentral -PVERSION_NAME="${GITHUB_REF_NAME}" --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
2 changes: 0 additions & 2 deletions .jitpack.yml

This file was deleted.

16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# coil-imagegetter
Loads images for Html rendering in Android using [Coil](https://coil-kt.github.io/coil/)

[![](https://jitpack.io/v/Commit451/coil-imagegetter.svg)](https://jitpack.io/#Commit451/coil-imagegetter)
[![Build](https://github.com/Commit451/coil-imagegetter/actions/workflows/ci.yml/badge.svg)](https://github.com/Commit451/coil-imagegetter/actions/workflows/ci.yml) [![Maven Central](https://img.shields.io/maven-central/v/com.commit451/coil-imagegetter.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.commit451/coil-imagegetter)

## Dependency
Add this in your root `build.gradle` file (**not** your module `build.gradle` file):
Add the library to your project `build.gradle`:

```gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```

Then, add the library to your project `build.gradle`
```gradle
dependencies {
implementation("com.github.Commit451:CoilImageGetter:latest.version.here")
implementation("com.commit451:coil-imagegetter:latest.version.here")
}
```

Expand Down
47 changes: 0 additions & 47 deletions app/build.gradle

This file was deleted.

49 changes: 49 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id("com.android.application")
}

android {
namespace = "com.commit451.coilimagegetter.sample"
compileSdk = 35

defaultConfig {
applicationId = "com.commit451.coilimagegetter.sample"
minSdk = 21
targetSdk = 35
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
viewBinding = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}
}

dependencies {
val coroutinesVersion = "1.10.2"

implementation("androidx.appcompat:appcompat:1.7.1")
implementation("androidx.core:core-ktx:1.16.0")
implementation("org.commonmark:commonmark:0.24.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")

implementation(project(":coilimagegetter"))
}
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.commit451.coilimagegetter.sample">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

Expand All @@ -25,4 +24,4 @@
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import android.text.Spanned
import androidx.appcompat.app.AppCompatActivity
import com.commit451.coilimagegetter.CoilImageGetter
import com.commit451.coilimagegetter.sample.databinding.ActivityMainBinding
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient
import okhttp3.Request
import org.commonmark.parser.Parser
import org.commonmark.renderer.html.HtmlRenderer
import ru.gildor.coroutines.okhttp.await
import kotlin.coroutines.CoroutineContext

class MainActivity : AppCompatActivity(), CoroutineScope {
Expand Down Expand Up @@ -54,8 +58,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
val request = Request.Builder()
.url("https://raw.githubusercontent.com/Jawnnypoo/open-meh/master/README.md")
.build()
val result = client.newCall(request).await()
val markdown = result.body?.string()
val markdown = withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
response.body?.string()
}
} ?: ""

val document = parser.parse(markdown)
return renderer.render(document)
Expand Down
22 changes: 0 additions & 22 deletions build.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id("com.android.application") version "9.1.0" apply false
id("com.android.library") version "9.1.0" apply false
id("com.vanniktech.maven.publish") version "0.30.0" apply false
}

tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
35 changes: 0 additions & 35 deletions coilimagegetter/build.gradle

This file was deleted.

52 changes: 52 additions & 0 deletions coilimagegetter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.android.library")
id("com.vanniktech.maven.publish")
}

group = findProperty("GROUP") as String
version = findProperty("VERSION_NAME") as String

android {
namespace = "com.commit451.coilimagegetter"
compileSdk = 35

defaultConfig {
minSdk = 21
consumerProguardFiles("consumer-rules.pro")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

dependencies {
val coilVersion = "3.4.0"

api("io.coil-kt.coil3:coil:$coilVersion")
api("io.coil-kt.coil3:coil-network-okhttp:$coilVersion")
}

mavenPublishing {
configure(AndroidSingleVariantLibrary("release", true, true))
coordinates("com.commit451", "coil-imagegetter", version.toString())
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
if (System.getenv("RELEASE_SIGNING_ENABLED") == "true") {
signAllPublications()
}
}
2 changes: 1 addition & 1 deletion coilimagegetter/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.commit451.coilimagegetter" />
<manifest />
Loading