forked from noties/Markwon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request noties#268 from noties/f/sample-app
Sample app unification
- Loading branch information
Showing
400 changed files
with
15,309 additions
and
8,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Oops, something went wrong.