Skip to content
Snippets Groups Projects
Commit d9c5d98b authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Reorganized code for readability

parent f799da78
No related branches found
No related tags found
No related merge requests found
......@@ -88,52 +88,71 @@ android {
}
}
val appCompatVersion = "27.0.2"
val appArchVersion = "1.1.0"
dependencies {
implementation(kotlin("stdlib", "1.2.21"))
implementation(appCompat("appcompat-v7"))
implementation(appCompat("design"))
implementation(appCompat("customtabs"))
implementation(appCompat("cardview-v7"))
implementation(appCompat("recyclerview-v7"))
implementation(appCompat("constraint", "constraint-layout", version = "1.0.2"))
implementation("io.reactivex.rxjava2", "rxjava", "2.1.9")
// App Compat
withVersion("27.0.2") {
implementation("com.android.support", "appcompat-v7", version)
implementation("com.android.support", "design", version)
implementation("com.android.support", "customtabs", version)
implementation("com.android.support", "cardview-v7", version)
implementation("com.android.support", "recyclerview-v7", version)
}
implementation("com.android.support.constraint", "constraint-layout", "1.0.2")
implementation(appArch("lifecycle", "extensions"))
implementation(appArch("lifecycle", "reactivestreams"))
kapt(appArch("lifecycle", "compiler"))
// App Arch Lifecycle
withVersion("1.1.0") {
implementation("android.arch.lifecycle", "extensions", version)
implementation("android.arch.lifecycle", "reactivestreams", version)
kapt("android.arch.lifecycle", "compiler", version)
}
implementation(appArch("persistence.room", "runtime", "1.1.0-alpha2"))
implementation(appArch("persistence.room", "rxjava2", "1.1.0-alpha2"))
kapt(appArch("persistence.room", "compiler", "1.1.0-alpha2"))
// App Arch Persistence
withVersion("1.1.0-alpha2") {
implementation("android.arch.persistence.room", "runtime", version)
implementation("android.arch.persistence.room", "rxjava2", version)
kapt("android.arch.persistence.room", "compiler", version)
testImplementation("android.arch.persistence.room", "testing", version)
}
implementation(appArch("paging", "runtime", version = "1.0.0-alpha5")) {
// App Arch Paging
implementation("android.arch.paging", "runtime", "1.0.0-alpha5") {
exclude(group = "junit", module = "junit")
}
implementation("me.zhanghai.android.materialprogressbar", "library", "1.4.2")
// Utility
implementation("io.reactivex.rxjava2", "rxjava", "2.1.9")
implementation("org.threeten", "threetenbp", "1.3.6", classifier = "no-tzdb")
implementation("org.jetbrains", "annotations", "15.0")
withVersion("2.14.1") {
implementation("com.google.dagger", "dagger-android", version)
implementation("com.google.dagger", "dagger-android-support", version)
implementation("com.jakewharton", "butterknife", "8.8.1")
kapt("com.jakewharton", "butterknife-compiler", "8.8.1")
kapt("com.google.dagger", "dagger-android-processor", version)
kapt("com.google.dagger", "dagger-compiler", version)
}
withVersion("8.8.1") {
implementation("com.jakewharton", "butterknife", version)
kapt("com.jakewharton", "butterknife-compiler", version)
}
// Quassel
implementation(project(":lib")) {
exclude(group = "org.threeten", module = "threetenbp")
}
implementation(project(":malheur"))
implementation("org.jetbrains", "annotations", "15.0")
testImplementation(appArch("persistence.room", "testing", "1.0.0"))
testImplementation("junit", "junit", "4.12")
// UI
implementation("me.zhanghai.android.materialprogressbar", "library", "1.4.2")
androidTestImplementation("com.android.support.test", "runner", "1.0.1")
androidTestImplementation("com.android.support.test", "rules", "1.0.1")
// Quality Assurance
implementation(project(":malheur"))
testImplementation("junit", "junit", "4.12")
withVersion("1.0.1") {
androidTestImplementation("com.android.support.test", "runner", version)
androidTestImplementation("com.android.support.test", "rules", version)
}
androidTestImplementation("com.android.support.test.espresso", "espresso-core", "3.0.1")
}
......@@ -167,27 +186,4 @@ fun Project.properties(fileName: String): Properties? {
val props = Properties()
props.load(file.inputStream())
return props
}
/**
* Builds the dependency notation for the named AppCompat [module] at the given [version].
*
* @param module simple name of the AppCompat module, for example "cardview-v7".
* @param version optional desired version, null implies [appCompatVersion].
*/
fun appCompat(module: String, submodule: String? = null, version: String? = null)
= if (submodule != null) {
"com.android.support.$module:$submodule:${version ?: appCompatVersion}"
} else {
"com.android.support:$module:${version ?: appCompatVersion}"
}
/**
* Builds the dependency notation for the named AppArch [module] at the given [version].
*
* @param module simple name of the AppArch module, for example "persistence.room".
* @param submodule simple name of the AppArch submodule, for example "runtime".
* @param version optional desired version, null implies [appCompatVersion].
*/
fun appArch(module: String, submodule: String, version: String? = null)
= "android.arch.$module:$submodule:${version ?: appArchVersion}"
}
\ No newline at end of file
......@@ -39,4 +39,6 @@
# Kotlin stuff
-dontnote kotlin.**
# Gson
-dontnote com.google.gson.**
\ No newline at end of file
-dontnote com.google.gson.**
# Dagger
-dontwarn com.google.errorprone.annotations.*
\ No newline at end of file
......@@ -22,6 +22,7 @@ import de.kuschku.quasseldroid_ng.Keys
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.persistence.AccountDatabase
import de.kuschku.quasseldroid_ng.persistence.QuasselDatabase
import de.kuschku.quasseldroid_ng.ui.settings.data.BacklogSettings
import de.kuschku.quasseldroid_ng.ui.viewmodel.QuasselViewModel
import de.kuschku.quasseldroid_ng.util.AndroidHandlerThread
import de.kuschku.quasseldroid_ng.util.helper.*
......@@ -54,6 +55,8 @@ class ChatActivity : ServiceBoundActivity() {
private lateinit var database: QuasselDatabase
private var backlogSettings = BacklogSettings()
override fun onCreate(savedInstanceState: Bundle?) {
handler.onCreate()
super.onCreate(savedInstanceState)
......@@ -177,6 +180,21 @@ class ChatActivity : ServiceBoundActivity() {
android.R.id.home -> {
drawerToggle.onOptionsItemSelected(item)
}
R.id.clear -> {
handler.post {
viewModel.sessionManager { manager ->
viewModel.getBuffer().let { buffer ->
manager.backlogStorage.clearMessages(buffer)
manager.backlogManager?.requestBacklog(
bufferId = buffer,
last = -1,
limit = backlogSettings.dynamicAmount
)
}
}
}
true
}
R.id.disconnect -> {
handler.post {
getSharedPreferences(Keys.Status.NAME, Context.MODE_PRIVATE).editApply {
......
......@@ -18,6 +18,7 @@ import de.kuschku.libquassel.protocol.MsgId
import de.kuschku.libquassel.quassel.syncables.BufferSyncer
import de.kuschku.quasseldroid_ng.R
import de.kuschku.quasseldroid_ng.persistence.QuasselDatabase
import de.kuschku.quasseldroid_ng.ui.settings.data.BacklogSettings
import de.kuschku.quasseldroid_ng.ui.viewmodel.QuasselViewModel
import de.kuschku.quasseldroid_ng.util.AndroidHandlerThread
import de.kuschku.quasseldroid_ng.util.helper.*
......@@ -41,6 +42,8 @@ class MessageListFragment : ServiceBoundFragment() {
private var lastBuffer: BufferId? = null
private var backlogSettings = BacklogSettings()
override fun onCreate(savedInstanceState: Bundle?) {
handler.onCreate()
super.onCreate(savedInstanceState)
......@@ -84,9 +87,9 @@ class MessageListFragment : ServiceBoundFragment() {
LivePagedListBuilder(
database.message().findByBufferIdPaged(it),
PagedList.Config.Builder()
.setPageSize(20)
.setPrefetchDistance(20)
.setInitialLoadSizeHint(20)
.setPageSize(backlogSettings.dynamicAmount)
.setPrefetchDistance(backlogSettings.dynamicAmount)
.setInitialLoadSizeHint(backlogSettings.dynamicAmount)
.setEnablePlaceholders(true)
.build()
).setBoundaryCallback(boundaryCallback).build()
......@@ -174,7 +177,7 @@ class MessageListFragment : ServiceBoundFragment() {
last = database.message().findFirstByBufferId(
bufferId
)?.messageId ?: -1,
limit = 20
limit = backlogSettings.dynamicAmount
)
}
}
......
package de.kuschku.quasseldroid_ng.ui.settings.data
data class BacklogSettings(
val dynamicAmount: Int = 20
)
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/clear"
android:title="Clear Backlog" />
<item
android:id="@+id/settings"
android:title="Settings" />
......
import org.gradle.kotlin.dsl.`kotlin-dsl`
plugins {
`kotlin-dsl`
}
\ No newline at end of file
data class VersionContext(val version: String)
inline fun withVersion(version: String, f: VersionContext.() -> Unit) {
VersionContext(version).f()
}
\ No newline at end of file
......@@ -13,14 +13,14 @@ val appCompatVersion = "27.0.2"
dependencies {
implementation(kotlin("stdlib", "1.2.21"))
implementation(appCompat("support-annotations"))
implementation("com.android.support", "support-annotations", "27.0.2")
implementation("org.threeten", "threetenbp", "1.3.6")
implementation("io.reactivex.rxjava2:rxjava:2.1.9")
implementation(project(":invokerannotations"))
kapt(project(":invokergenerator"))
testImplementation("junit:junit:4.12")
testImplementation("junit", "junit", "4.12")
}
/*
......@@ -33,12 +33,3 @@ tasks.withType(KotlinCompile::class.java) {
}
}
*/
/**
* Builds the dependency notation for the named AppCompat [module] at the given [version].
*
* @param module simple name of the AppCompat module, for example "cardview-v7".
* @param version optional desired version, null implies [appCompatVersion].
*/
fun appCompat(module: String, version: String? = null)
= "com.android.support:$module:${version ?: appCompatVersion}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment