Working with new sample application

This commit is contained in:
Dimitry Ivanov 2020-06-11 19:14:53 +03:00
parent 07310127be
commit cd7aae7c9e
28 changed files with 303 additions and 0 deletions

50
app-sample/build.gradle Normal file
View File

@ -0,0 +1,50 @@
apply plugin: 'com.android.application'
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'
javaCompileOptions {
annotationProcessorOptions {
arguments = [
// cannot cast GString...
// cannot use `-`
'markwon.samples.file': "\"${projectDir}/samples.json\"".toString()
]
}
}
}
dexOptions {
preDexLibraries true
javaMaxHeapSize '5g'
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
java.srcDirs += '../sample-utils/annotations'
}
}
}
dependencies {
implementation 'io.noties:debug:5.1.0'
annotationProcessor project(':sample-utils:processor')
}

View File

@ -0,0 +1,24 @@
<?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="io.noties.markwon.app">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,16 @@
package io.noties.markwon.app;
import android.app.Application;
import io.noties.debug.AndroidLogDebugOutput;
import io.noties.debug.Debug;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Debug.init(new AndroidLogDebugOutput(true));
}
}

View File

@ -0,0 +1,16 @@
package io.noties.markwon.app;
import android.app.Activity;
import android.os.Bundle;
import androidx.annotation.Nullable;
public class MainActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}

View File

@ -0,0 +1,15 @@
package io.noties.markwon.app;
import io.noties.markwon.sample.annotations.MarkwonArtifact;
import io.noties.markwon.sample.annotations.MarkwonSample;
@MarkwonSample(
id = "202006163161416",
title = "The first sample title",
description = "This is description",
artifacts = {MarkwonArtifact.CORE, MarkwonArtifact.EDITOR},
tags = "none"
)
public class Test {
}

View File

@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M0,0h512v256h-512z"
android:strokeAlpha="0.94117647"
android:strokeWidth="0.40000001"
android:fillColor="#d7d7d7"
android:strokeColor="#00000000"
android:fillType="nonZero"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
<path
android:pathData="M0,256h512v256h-512z"
android:strokeAlpha="0.94117647"
android:strokeWidth="0.40000001"
android:fillColor="#eeeeee"
android:strokeColor="#00000000"
android:fillType="nonZero"
android:fillAlpha="1"
android:strokeLineCap="butt"/>
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="accent">#5CB85C</color>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Markwon</string>
</resources>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppThemeBase" parent="android:Theme.Material.Light.NoActionBar">
</style>
<style name="AppTheme" parent="AppThemeBase" />
</resources>

Binary file not shown.

View File

@ -0,0 +1,21 @@
package io.noties.markwon.sample.annotations;
public enum MarkwonArtifact {
CORE,
EDITOR,
EXT_LATEX,
EXT_STRIKETHROUGH,
EXT_TABLES,
EXT_TASKLIST,
HTML,
IMAGE,
IMAGE_COIL,
IMAGE_GLIDE,
IMAGE_PICASSO,
INLINE_PARSER,
LINKIFY,
RECYCLER,
RECYCLER_TABLE,
SIMPLE_EXT,
SYNTAX_HIGHLIGHT
}

View File

@ -0,0 +1,30 @@
package io.noties.markwon.sample.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface MarkwonSample {
/**
* Actual format is not important, but this key must be set in order to persist sample.
* This key should not change during lifetime of sample
* <p>
* {@code id} date in `YYYYMMDDHHmmss` format (UTC),
* a simple live template can be used:
* {@code
* groovyScript("new Date().format('YYYYMMDDHHmmss', TimeZone.getTimeZone('UTC'))")
* }
*/
String id();
String title();
String description();
MarkwonArtifact[] artifacts();
String[] tags();
}

View File

@ -0,0 +1,12 @@
apply plugin: 'java-library'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
main.java.srcDirs += '../annotations'
}
dependencies {
implementation deps['x-annotations']
}

View File

@ -0,0 +1,65 @@
package io.noties.markwon.sample.processor;
import androidx.annotation.NonNull;
import java.util.Collections;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import io.noties.markwon.sample.annotations.MarkwonSample;
public class MarkwonSampleProcessor extends AbstractProcessor {
private static final String KEY_SAMPLES_FILE = "markwon.samples.file";
private Messager messager;
private String samplesFilePath;
@Override
public Set<String> getSupportedOptions() {
return Collections.singleton(KEY_SAMPLES_FILE);
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
@Override
public Set<String> getSupportedAnnotationTypes() {
return Collections.singleton(MarkwonSample.class.getName());
}
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
super.init(processingEnvironment);
messager = processingEnvironment.getMessager();
samplesFilePath = processingEnvironment.getOptions().get(KEY_SAMPLES_FILE);
}
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
if (!roundEnvironment.processingOver()) {
final Set<? extends Element> elements = roundEnvironment.getElementsAnnotatedWith(MarkwonSample.class);
if (elements != null) {
for (Element element : elements) {
process(element);
}
}
}
return false;
}
private void process(@NonNull Element element) {
messager.printMessage(Diagnostic.Kind.WARNING, samplesFilePath, element);
}
}

View File

@ -0,0 +1 @@
io.noties.markwon.sample.processor.MarkwonSampleProcessor

View File

@ -18,3 +18,6 @@ include ':app', ':sample',
':markwon-simple-ext',
':markwon-syntax-highlight',
':markwon-test-span'
include ':app-sample'
include ':sample-utils:processor'