Cleanup Project
parent
e43090410d
commit
e51957615d
Binary file not shown.
|
@ -8,10 +8,8 @@
|
|||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/annotations" />
|
||||
<option value="$PROJECT_DIR$/matrix_android_sdk" />
|
||||
<option value="$PROJECT_DIR$/mobile" />
|
||||
<option value="$PROJECT_DIR$/processor" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/build
|
|
@ -1,24 +0,0 @@
|
|||
apply plugin: 'java-library'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.21"
|
||||
}
|
||||
|
||||
sourceCompatibility = "8"
|
||||
targetCompatibility = "8"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package blog.nordgedanken.annotations
|
||||
|
||||
// TODO fix <T>
|
||||
// TODO fix returnType. Instead use some kind of type derived from kclass
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
annotation class BindingInit(val layoutID: Int, val returnType: String)
|
|
@ -136,8 +136,6 @@ project.android.buildTypes.all { buildType ->
|
|||
dependencies {
|
||||
implementation project(':matrix_android_sdk')
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compileOnly project(path: ':annotations')
|
||||
kapt project(':processor')
|
||||
|
||||
// Kotlin
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.21"
|
||||
|
|
|
@ -11,11 +11,11 @@ import android.view.inputmethod.EditorInfo
|
|||
import android.widget.EditText
|
||||
import android.widget.ImageButton
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import blog.nordgedanken.annotations.BindingInit
|
||||
import blog.nordgedanken.simplematrix.OutgoingTextMessageLayoutElementBindingModel_
|
||||
import blog.nordgedanken.simplematrix.R
|
||||
import blog.nordgedanken.simplematrix.State
|
||||
|
@ -27,6 +27,7 @@ import blog.nordgedanken.simplematrix.data.view.Message
|
|||
import blog.nordgedanken.simplematrix.data.view.MessageFull
|
||||
import blog.nordgedanken.simplematrix.data.view.MessageViewModel
|
||||
import blog.nordgedanken.simplematrix.data.view.RoomFull
|
||||
import blog.nordgedanken.simplematrix.databinding.ActivityChatRoomBinding
|
||||
import blog.nordgedanken.simplematrix.utils.MediaStoreHelper
|
||||
import blog.nordgedanken.simplematrix.utils.db.DBHelpers
|
||||
import blog.nordgedanken.simplematrix.utils.db.DBHelpers.doesRoomExistInDB
|
||||
|
@ -74,7 +75,6 @@ class ChatRoom : AppCompatActivity() {
|
|||
|
||||
private val slideAnimationsUtil = SlideAnimations()
|
||||
|
||||
@BindingInit(R.layout.activity_chat_room, "blog.nordgedanken.simplematrix.databinding.ActivityChatRoomBinding")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Sentry.getContext().recordBreadcrumb(
|
||||
|
@ -84,7 +84,10 @@ class ChatRoom : AppCompatActivity() {
|
|||
/**
|
||||
* Setup DataBinding UI
|
||||
*/
|
||||
val activityBinding = getBindingActivityChatRoomBinding(this)
|
||||
val activityBinding = DataBindingUtil.setContentView<ActivityChatRoomBinding>(
|
||||
this,
|
||||
R.layout.activity_chat_room
|
||||
)
|
||||
|
||||
setSupportActionBar(activityBinding.toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package blog.nordgedanken.simplematrix.data.matrix.sync.processing
|
||||
|
||||
import android.content.Context
|
||||
import android.test.suitebuilder.annotation.LargeTest
|
||||
import androidx.room.Room
|
||||
import blog.nordgedanken.simplematrix.data.db.AppDatabase
|
||||
import com.google.gson.JsonObject
|
||||
|
@ -11,7 +10,6 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.mockito.Mockito.mock
|
||||
|
||||
@LargeTest
|
||||
class SyncProcessingTest {
|
||||
|
||||
private lateinit var database: AppDatabase
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/build
|
|
@ -1,19 +0,0 @@
|
|||
apply plugin: 'java-library'
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation project(':annotations')
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.21"
|
||||
|
||||
// Code generation library for kotlin, highly recommended
|
||||
implementation 'com.squareup:kotlinpoet:1.0.1'
|
||||
|
||||
// configuration generator for service providers
|
||||
implementation "com.google.auto.service:auto-service:1.0-rc4"
|
||||
kapt "com.google.auto.service:auto-service:1.0-rc4"
|
||||
}
|
||||
|
||||
sourceCompatibility = "8"
|
||||
targetCompatibility = "8"
|
|
@ -1,76 +0,0 @@
|
|||
package blog.nordgedanken.processor
|
||||
|
||||
import blog.nordgedanken.annotations.BindingInit
|
||||
import com.google.auto.service.AutoService
|
||||
import com.squareup.kotlinpoet.*
|
||||
import java.io.File
|
||||
import javax.annotation.processing.*
|
||||
import javax.lang.model.SourceVersion
|
||||
import javax.lang.model.element.Element
|
||||
import javax.lang.model.element.ElementKind
|
||||
import javax.lang.model.element.TypeElement
|
||||
import javax.tools.Diagnostic
|
||||
|
||||
@AutoService(Processor::class) // For registering the service
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_8) // to support Java 8
|
||||
@SupportedOptions(BindingInitProcessor.KAPT_KOTLIN_GENERATED_OPTION_NAME)
|
||||
class BindingInitProcessor: AbstractProcessor() {
|
||||
|
||||
companion object {
|
||||
const val KAPT_KOTLIN_GENERATED_OPTION_NAME = "kapt.kotlin.generated"
|
||||
}
|
||||
|
||||
override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment?): Boolean {
|
||||
roundEnv?.getElementsAnnotatedWith(BindingInit::class.java)?.forEach { methodElement: Element ->
|
||||
if (methodElement.kind != ElementKind.METHOD) {
|
||||
processingEnv.messager.printMessage(Diagnostic.Kind.ERROR, "Can only be applied to functions, element: $methodElement ")
|
||||
return false
|
||||
}
|
||||
|
||||
generateNewMethod(methodElement, processingEnv.elementUtils.getPackageOf(methodElement).toString())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun generateNewMethod(method: Element, packageOfMethod: String) {
|
||||
val generatedSourcesRoot: String = processingEnv.options[KAPT_KOTLIN_GENERATED_OPTION_NAME].orEmpty()
|
||||
if(generatedSourcesRoot.isEmpty()) {
|
||||
processingEnv.messager.printMessage(Diagnostic.Kind.ERROR, "Can't find the target directory for generated Kotlin files.")
|
||||
return
|
||||
}
|
||||
|
||||
val returnType = method.getAnnotation(BindingInit::class.java).returnType
|
||||
val returnTypeName = returnType.split("\\.".toRegex()).last()
|
||||
val layoutID = method.getAnnotation(BindingInit::class.java).layoutID
|
||||
|
||||
val funcBuilder = FunSpec.builder("getBinding$returnTypeName")
|
||||
.addModifiers(KModifier.PUBLIC)
|
||||
.addParameter("context", ClassName("android.app", "Activity"))
|
||||
.addCode("return %T.setContentView<%T>(\n" +
|
||||
" context,\n" +
|
||||
" $layoutID\n" +
|
||||
" )",
|
||||
ClassName("androidx.databinding", "DataBindingUtil"),
|
||||
easyClassName(returnType))
|
||||
.returns(easyClassName(returnType))
|
||||
|
||||
val file = File(generatedSourcesRoot)
|
||||
// TODO fix this breaks having more than 1 annotation of this type
|
||||
if (file.exists()) file.delete()
|
||||
file.mkdir()
|
||||
FileSpec.builder(packageOfMethod, "BindingInitGenerated")
|
||||
.addFunction(funcBuilder.build())
|
||||
.build().writeTo(file)
|
||||
}
|
||||
|
||||
override fun getSupportedAnnotationTypes(): MutableSet<String> {
|
||||
return mutableSetOf(BindingInit::class.java.canonicalName)
|
||||
}
|
||||
}
|
||||
|
||||
fun easyClassName(fullClassName: String): TypeName {
|
||||
val splits = fullClassName.split("\\.".toRegex())
|
||||
val packageName = splits.subList(0, splits.lastIndex).joinToString(".")
|
||||
val className = splits[splits.lastIndex]
|
||||
return ClassName(packageName, className)
|
||||
}
|
|
@ -1 +1 @@
|
|||
include ':mobile', ':annotations', ':processor', ':matrix_android_sdk'
|
||||
include ':mobile', ':matrix_android_sdk'
|
||||
|
|
Loading…
Reference in New Issue