-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
将 qmui 和 qmuidemo(example) 合并为一个 repo 到 github
- Loading branch information
1 parent
b2472be
commit 9732ed6
Showing
4,170 changed files
with
147,148 additions
and
63 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
/*.bin | ||
/*.iml | ||
/.DS_Store | ||
.DS_Store | ||
/.gradle | ||
/.gradletasknamecache | ||
/.idea | ||
app/*.iml | ||
app/build | ||
/bin | ||
/build | ||
/local.properties | ||
/deploy.properties | ||
release.properties | ||
qmuidemo.keystore |
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 |
---|---|---|
@@ -1,65 +1,28 @@ | ||
apply plugin: 'com.android.library' | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
group = 'com.qmuiteam' | ||
version = "1.0.0" | ||
|
||
android { | ||
compileSdkVersion parent.ext.compileSdkVersion | ||
buildToolsVersion parent.ext.buildToolsVersion | ||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion parent.ext.minSdkVersion | ||
targetSdkVersion parent.ext.targetSdkVersion | ||
versionCode 1 | ||
versionName "1.0" | ||
// vectorDrawables.useSupportLibrary = true // 与 com.android.support:support-vector-drawable 搭配使用,禁掉 Android Studio 自动生成 png 的功能 | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
mavenLocal() | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.2.3' | ||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' | ||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2' | ||
} | ||
|
||
// libraryVariants.all{ variant -> | ||
// variant.mergeResources.doLast { | ||
// replaceTheme variant | ||
// } | ||
// } | ||
// testVariants.all { variant -> | ||
// variant.mergeResources.doLast { | ||
// replaceTheme variant | ||
// } | ||
// } | ||
} | ||
|
||
//def replaceTheme(variant){ | ||
// println "dirName::${variant.dirName}" | ||
// def output = "AppConfigTheme" | ||
// | ||
// File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml") | ||
// String content = valuesFile.getText('UTF-8') | ||
// content = content.replaceAll(/\$\{QMUI_PARENT_THEME\}/, output) | ||
// valuesFile.write(content, 'UTF-8') | ||
//} | ||
allprojects { | ||
repositories { | ||
jcenter() | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
compile("com.android.support:recyclerview-v7:$supportVersion") | ||
compile("com.android.support:appcompat-v7:$supportVersion") | ||
compile("com.android.support:design:$supportVersion") | ||
compile("com.android.support:support-vector-drawable:$supportVersion") // need Gradle Plugin v1.5.0 or above | ||
//test | ||
// testCompile 'junit:junit:4.12' | ||
// testCompile 'org.mockito:mockito-core:1.10.19' | ||
ext { | ||
buildToolsVersion = "24.0.3" | ||
minSdkVersion = 14 | ||
targetSdkVersion = 25 | ||
compileSdkVersion = 25 | ||
supportVersion = "25.3.1" | ||
} | ||
} | ||
|
||
// deploy | ||
File deployConfig = project.file('deploy.properties') | ||
if (deployConfig.exists()) { | ||
apply from: "deployMaven.gradle" | ||
apply from: "deployBintray.gradle" | ||
} |
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,2 @@ | ||
/build | ||
/*.iml |
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,11 @@ | ||
apply plugin: 'java' | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile project(':lib') | ||
compile 'com.squareup:javapoet:1.7.0' | ||
compile 'com.google.auto.service:auto-service:1.0-rc2' | ||
} | ||
|
||
sourceCompatibility = "1.7" | ||
targetCompatibility = "1.7" |
177 changes: 177 additions & 0 deletions
177
compiler/src/main/java/com/qmuiteam/qmuidemo/compiler/WidgetProcessor.java
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,177 @@ | ||
package com.qmuiteam.qmuidemo.compiler; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.squareup.javapoet.ClassName; | ||
import com.squareup.javapoet.FieldSpec; | ||
import com.squareup.javapoet.JavaFile; | ||
import com.squareup.javapoet.MethodSpec; | ||
import com.squareup.javapoet.ParameterizedTypeName; | ||
import com.squareup.javapoet.TypeName; | ||
import com.squareup.javapoet.TypeSpec; | ||
import com.squareup.javapoet.WildcardTypeName; | ||
import com.qmuiteam.qmuidemo.lib.annotation.Widget; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import javax.annotation.processing.AbstractProcessor; | ||
import javax.annotation.processing.Filer; | ||
import javax.annotation.processing.Messager; | ||
import javax.annotation.processing.ProcessingEnvironment; | ||
import javax.annotation.processing.Processor; | ||
import javax.annotation.processing.RoundEnvironment; | ||
import javax.lang.model.SourceVersion; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.Modifier; | ||
import javax.lang.model.element.TypeElement; | ||
import javax.lang.model.type.DeclaredType; | ||
import javax.lang.model.type.MirroredTypeException; | ||
import javax.lang.model.type.TypeKind; | ||
import javax.lang.model.type.TypeMirror; | ||
import javax.lang.model.util.Elements; | ||
import javax.tools.Diagnostic; | ||
|
||
/** | ||
* @author cginechen | ||
* @date 2016-12-13 | ||
*/ | ||
|
||
@AutoService(Processor.class) | ||
public class WidgetProcessor extends AbstractProcessor { | ||
private Filer mFiler; //文件相关的辅助类 | ||
private Elements mElementUtils; //元素相关的辅助类 | ||
private Messager mMessager; //日志相关的辅助类 | ||
private boolean mIsFileCreated = false; | ||
|
||
private final String mClassName = "QDWidgetContainer"; | ||
private final String mPackageName = "com.qmuiteam.qmuidemo"; | ||
|
||
ClassName mMapName = ClassName.get("java.util", "Map"); | ||
ClassName mHashMapName = ClassName.get("java.util", "HashMap"); | ||
ClassName mItemDescName = ClassName.get("com.qmuiteam.qmuidemo.model", "QDItemDescription"); | ||
ClassName mBaseFragmentName = ClassName.get("com.qmuiteam.qmuidemo.base", "BaseFragment"); | ||
TypeName mBaseFragmentClassName = ParameterizedTypeName.get(ClassName.get(Class.class), | ||
WildcardTypeName.subtypeOf(mBaseFragmentName)); | ||
TypeName mMapFieldTypeName = ParameterizedTypeName.get(mMapName, | ||
mBaseFragmentClassName, mItemDescName); | ||
|
||
ClassName mWidgetContainerName = ClassName.get(mPackageName, mClassName); | ||
|
||
@Override | ||
public synchronized void init(ProcessingEnvironment processingEnv) { | ||
super.init(processingEnv); | ||
mFiler = processingEnv.getFiler(); | ||
mElementUtils = processingEnv.getElementUtils(); | ||
mMessager = processingEnv.getMessager(); | ||
mIsFileCreated = false; | ||
} | ||
|
||
/** | ||
* @return 指定哪些注解应该被注解处理器注册 | ||
*/ | ||
@Override | ||
public Set<String> getSupportedAnnotationTypes() { | ||
Set<String> types = new LinkedHashSet<>(); | ||
types.add(Widget.class.getCanonicalName()); | ||
return types; | ||
} | ||
|
||
@Override | ||
public SourceVersion getSupportedSourceVersion() { | ||
return SourceVersion.latestSupported(); | ||
} | ||
|
||
@Override | ||
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) { | ||
if (mIsFileCreated) { | ||
return true; | ||
} | ||
mIsFileCreated = true; | ||
TypeSpec.Builder widgetContainerBuilder = TypeSpec.classBuilder(mWidgetContainerName); | ||
|
||
FieldSpec instanceField = FieldSpec.builder(mWidgetContainerName, "sInstance") | ||
.addModifiers(Modifier.PRIVATE) | ||
.addModifiers(Modifier.STATIC) | ||
.initializer("new $T()", mWidgetContainerName) | ||
.build(); | ||
|
||
FieldSpec mapField = FieldSpec.builder(mMapFieldTypeName, "mWidgets") | ||
.addModifiers(Modifier.PRIVATE) | ||
.build(); | ||
|
||
MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder() | ||
.addModifiers(Modifier.PRIVATE) | ||
.addStatement("mWidgets = new $T<>()", mHashMapName); | ||
|
||
for (Element element : roundEnvironment.getElementsAnnotatedWith(Widget.class)) { | ||
if (element instanceof TypeElement) { | ||
TypeElement classElement = (TypeElement) element; | ||
ClassName elementName = ClassName.get(classElement); | ||
Widget widget = classElement.getAnnotation(Widget.class); | ||
String name = null; | ||
// http://www.programcreek.com/java-api-examples/index.php?api=javax.lang.model.type.TypeMirror | ||
// https://blog.retep.org/2009/02/13/getting-class-values-from-annotations-in-an-annotationprocessor/ | ||
try { | ||
widget.widgetClass(); | ||
} catch (MirroredTypeException mte) { | ||
TypeMirror nameMirror = mte.getTypeMirror(); | ||
if (nameMirror.getKind() == TypeKind.DECLARED) { | ||
name = ((DeclaredType) nameMirror).asElement().getSimpleName().toString(); | ||
info("nameMirror: kind = " + nameMirror.getKind().name() + " ; name = " + name); | ||
} | ||
} | ||
if (name == null && widget.name().length() > 0) { | ||
name = widget.name(); | ||
} | ||
|
||
if (name == null || name.length() == 0) { | ||
error("please provide widgetClass or name"); | ||
} | ||
constructorBuilder.addStatement("mWidgets.put($T.class, new $T($T.class, $S, $L))", | ||
elementName, | ||
mItemDescName, | ||
elementName, | ||
name, | ||
widget.iconRes()); | ||
} | ||
|
||
} | ||
MethodSpec constructorMethod = constructorBuilder.build(); | ||
|
||
MethodSpec instanceMethod = MethodSpec.methodBuilder("getInstance") | ||
.addModifiers(Modifier.PUBLIC) | ||
.addModifiers(Modifier.STATIC) | ||
.returns(mWidgetContainerName) | ||
.addStatement("return sInstance") | ||
.build(); | ||
|
||
MethodSpec getMethod = MethodSpec.methodBuilder("get") | ||
.addModifiers(Modifier.PUBLIC) | ||
.returns(mItemDescName) | ||
.addParameter(mBaseFragmentClassName, "fragment") | ||
.addStatement("return mWidgets.get($L)", "fragment") | ||
.build(); | ||
|
||
try { | ||
widgetContainerBuilder | ||
.addField(instanceField) | ||
.addField(mapField) | ||
.addMethod(constructorMethod) | ||
.addMethod(instanceMethod) | ||
.addMethod(getMethod); | ||
JavaFile.builder(mPackageName, widgetContainerBuilder.build()).build().writeTo(mFiler); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return true; | ||
} | ||
|
||
private void error(String msg, Object... args) { | ||
mMessager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args)); | ||
} | ||
|
||
private void info(String msg, Object... args) { | ||
mMessager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args)); | ||
} | ||
} |
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,21 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx1536m | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
|
||
systemProp.http.proxyHost=dev_proxy.oa.com | ||
systemProp.http.nonProxyHosts=*.oa.com|localhost | ||
systemProp.http.proxyPort=8080 |
Binary file not shown.
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,6 @@ | ||
#Mon Dec 28 10:00:20 PST 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip |
Oops, something went wrong.