Skip to content

Commit

Permalink
Merge pull request noties#268 from noties/f/sample-app
Browse files Browse the repository at this point in the history
Sample app unification
  • Loading branch information
noties committed Aug 3, 2020
2 parents 3ab0151 + 76fccb1 commit 72f6174
Show file tree
Hide file tree
Showing 400 changed files with 15,309 additions and 8,281 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -Prelease -PCI --stacktrace
33 changes: 0 additions & 33 deletions .github/workflows/develop.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
with:
java-version: 1.8
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -PCI --stacktrace
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Changelog

# SNAPSHOT

#### Added
* `core` - `MovementMethodPlugin.none()`, `MovementMethodPlugin.link()` factory methods
* `core` - `CorePlugin` `hasExplicitMovementMethod` configuration method to **not** add implicit `LinkMovementMethod` in `afterSetText`
* `core` - `MarkwonTheme` `isLinkedUnderlined` attribute for links([#270])<br>Thanks to [@dallasgutauckis]
* `ext-latex` - `JLatexMathTheme.Padding.of(int,int,int,int)` factory method
* `app-sample` - example application

#### Changed
* `html` - `SimpleTagHandler` visits children tags if supplied tag is block one ([#235])
* `inline-parser` - `BangInlineProcessor` properly returns `null` if no image node is found (possible to define other inline parsers that use `!` as special character)
* `image` - `AsyncDrawable` won't trigger loading if it has result (aim: `RecyclerView` due to multiple attach/detach events of a View)
* `image` - `AsyncDrawable` will resume result if it is `Animatable` and was playing before detach event (aim: `RecyclerView`) ([#241])
* `core` - `MarkwonReducer` filter out `LinkReferenceDefinition` nodes

#### Fixed
* `image-glide` cache `RequestManager` in `GlideImagesPlugin#create(Context)` factory method ([#259])

#### Deprecated
* `core` - `MovementMethodPlugin.create()` use explicit `MovementMethodPlugin.link()` instead

#### Removed
* `image` - `AsyncDrawable#hasKnownDimentions` (deprecated in `4.2.1`)
* `app` and `sample` applications (merged together in a `app-sample` single app)

[#235]: https://github.com/noties/Markwon/issues/235
[#241]: https://github.com/noties/Markwon/issues/241
[#259]: https://github.com/noties/Markwon/issues/259
[#270]: https://github.com/noties/Markwon/pull/270

[@dallasgutauckis]: https://github.com/dallasgutauckis


# 4.4.0
* `TextViewSpan` to obtain `TextView` in which markdown is displayed (applied by `CorePlugin`)
* `TextLayoutSpan` to obtain `Layout` in which markdown is displayed (applied by `TablePlugin`, more specifically `TableRowSpan` to propagate layout in which cell content is displayed)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ features listed in [commonmark-spec] are supported
(including support for **inlined/block HTML code**, **markdown tables**,
**images** and **syntax highlight**).

`Markwon` comes with a [sample application](./app-sample/). It is a
collection of library usages that comes with search and source code for
each code sample.

Since version **4.2.0** **Markwon** comes with an [editor](./markwon-editor/) to _highlight_ markdown input
as user types (for example in **EditText**).

[commonmark-spec]: https://spec.commonmark.org/0.28/
[commonmark-java]: https://github.com/atlassian/commonmark-java/blob/master/README.md

<sup>*</sup>*This file is displayed by default in the [sample-apk] (`markwon-sample-{latest-version}-debug.apk`) application. Which is a generic markdown viewer with support to display markdown via `http`, `https` & `file` schemes and 2 themes included: Light & Dark*

[sample-apk]: https://github.com/noties/Markwon/releases

## Installation

![stable](https://img.shields.io/maven-central/v/io.noties.markwon/core.svg?label=stable)
Expand Down
75 changes: 75 additions & 0 deletions app-sample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Markwon sample app

Collection of sample snippets showing different aspects of `Markwon` library usage. Includes
source code of samples, latest stable/snapshot version of the library and search functionality.
Additionally can check for updates. Can be used to preview markdown documents from the `Github.com`.

<a href="../art/sample-screen-01.png"><img src="../art/sample-screen-01.png" width="30%" /></a>
<a href="../art/sample-screen-02.png"><img src="../art/sample-screen-02.png" width="30%" /></a>
<a href="../art/sample-screen-03.png"><img src="../art/sample-screen-03.png" width="30%" /></a>
<a href="../art/sample-screen-04.png"><img src="../art/sample-screen-04.png" width="30%" /></a>

## Distribution

Sample app is distributed via special parent-less branch [sample-store](https://github.com/noties/Markwon/tree/sample-store).
Inside the app, under version badges, tap `CHECK FOR UPDATES` to check for updates. Sample app
is not attached to main libraries versions and can be _released_ independently.

Application is signed with `keystore.jks`, which fingerprints are:
* __SHA1__: `BA:70:A5:D2:40:65:F1:FA:88:90:59:BA:FC:B7:31:81:E6:37:D9:41`
* __SHA256__: `82:C9:61:C5:DF:35:B1:CB:29:D5:48:83:FB:EB:9F:3E:7D:52:67:63:4F:D2:CE:0A:2D:70:17:85:FF:48:67:51`


[Download latest APK](https://github.com/noties/Markwon/raw/sample-store/markwon-debug.apk)


## Deeplink

Sample app handles special `markwon` scheme:
* `markwon://sample/{ID}` to open specific sample given the `{ID}`
* `markwon://search?q={TEXT TO SEARCH}&a={ARTIFACT}&t={TAG}`

Please note that search deeplink can have one of type: artifact or tag (if both are specified artifact will be used).

To test locally:

```
adb shell am start -a android.intent.action.ACTION_VIEW -d markwon://sample/ID
```

Please note that you might need to _url encode_ the `-d` argument

## Building

When adding/removing samples _most likely_ a clean build would be required.
First, for annotation processor to create `samples.json`. And secondly,
in order for Android Gradle plugin to bundle resources referenced via
symbolic links (the `sample.json` itself and `io.noties.markwon.app.samples.*` directory)

```
./gradlew :app-s:clean :app-s:asDe
```

## Sample id

Sample `id` is generated manually when creating new sample. A `Live Template` can be used
to simplify generation part (for example `mid` shortcut with a single variable in `Java` and `Kotlin` scopes):

```
groovyScript("new Date().format('YYYYMMddHHmmss', TimeZone.getTimeZone('UTC'))")
```

## Tests

This app uses [Robolectric](https://robolectric.org)(v3.8) for tests which is incompatible
with JDK > 1.8. In order to run tests from command line with IDEA-bundled JDK - a special argument is
required:

```
./gradlew :app-s:testDe -Dorg.gradle.java.home="{INSERT BUNDLED JDK PATH HERE}"
```

To obtain bundled JDK:
* open `Project Structure...`
* open `SDK Location`
* copy contents of the field under `JDK Location`
164 changes: 164 additions & 0 deletions app-sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

def gitSha = { ->
def output = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = output
}
return output.toString().trim()
}.memoize()

android {

compileSdkVersion config['compile-sdk']
buildToolsVersion config['build-tools']

defaultConfig {
applicationId 'io.noties.markwon.app'
minSdkVersion 23
targetSdkVersion config['target-sdk']
versionCode 1
versionName version

resConfig 'en'

setProperty("archivesBaseName", "markwon")

buildConfigField 'String', 'GIT_SHA', "\"${gitSha()}\""
buildConfigField 'String', 'GIT_REPOSITORY', '"https://github.com/noties/Markwon"'

final def scheme = 'markwon'
buildConfigField 'String', 'DEEPLINK_SCHEME', "\"$scheme\""
manifestPlaceholders += [
'deeplink_scheme': scheme
]
}

dexOptions {
preDexLibraries true
javaMaxHeapSize '5g'
}

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
java.srcDirs += '../sample-utils/annotations'
}
}

// do not sign in CI
if (!project.hasProperty('CI')) {
signingConfigs {
config {

final def keystoreFile = project.file('keystore.jks')
final def keystoreFilePassword = 'MARKWON_KEYSTORE_FILE_PASSWORD'
final def keystoreAlias = 'MARKWON_KEY_ALIAS'
final def keystoreAliasPassword = 'MARKWON_KEY_ALIAS_PASSWORD'

final def properties = [
keystoreFilePassword,
keystoreAlias,
keystoreAliasPassword
]

if (!keystoreFile.exists()) {
throw new IllegalStateException("No '${keystoreFile.name}' file is found.")
}

final def missingProperties = properties.findAll { !project.hasProperty(it) }
if (!missingProperties.isEmpty()) {
throw new IllegalStateException("Missing required signing properties: $missingProperties")
}

storeFile keystoreFile
storePassword project[keystoreFilePassword]

keyAlias project[keystoreAlias]
keyPassword project[keystoreAliasPassword]
}
}

buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
}
}
} else {
// it seems to be a bug in NDK handling, github fail to build the project with the:
// `com.android.builder.errors.EvalIssueException: No version of NDK matched the requested version 21.0.6113669. Versions available locally: 21.3.6528147`
ndkVersion '21.3.6528147'
}
}

kapt {
arguments {
arg('markwon.samples.file', "${projectDir}/samples.json".toString())
}
}

androidExtensions {
features = ["parcelize"]
}

configurations.all {
exclude group: 'org.jetbrains', module: 'annotations-java5'
}

dependencies {
kapt project(':sample-utils:processor')
deps['annotationProcessor'].with {
kapt it['prism4j-bundler']
}

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation project(':markwon-core')
implementation project(':markwon-editor')
implementation project(':markwon-ext-latex')
implementation project(':markwon-ext-strikethrough')
implementation project(':markwon-ext-tables')
implementation project(':markwon-ext-tasklist')
implementation project(':markwon-html')
implementation project(':markwon-image')
implementation project(':markwon-inline-parser')
implementation project(':markwon-linkify')
implementation project(':markwon-recycler')
implementation project(':markwon-recycler-table')
implementation project(':markwon-simple-ext')
implementation project(':markwon-syntax-highlight')

implementation project(':markwon-image-picasso')
implementation project(':markwon-image-glide')

deps.with {
// implementation it['x-appcompat']
implementation it['x-recycler-view']
implementation it['x-cardview']
implementation it['x-fragment']
implementation it['okhttp']
implementation it['prism4j']
implementation it['gson']
implementation it['adapt']
implementation it['debug']
implementation it['android-svg']
implementation it['android-gif-impl']
}

deps['test'].with {
testImplementation it['junit']
testImplementation it['robolectric']
testImplementation it['mockito']
}
}
24 changes: 24 additions & 0 deletions app-sample/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env sh

# abort on errors
set -e

# build
../gradlew :app-sample:clean
../gradlew :app-sample:assembleDebug

# navigate into the build output directory
cd ./build/outputs/apk/debug/

revision=$(git rev-parse --short HEAD)

echo "output.json" > ./.gitignore
echo "$revision" > ./version

git init
git add -A
git commit -m "sample $revision"

git push -f git@github.com:noties/Markwon.git master:sample-store

cd -
Binary file added app-sample/keystore.jks
Binary file not shown.
Loading

0 comments on commit 72f6174

Please sign in to comment.