diff --git a/app-test/build.gradle b/app-test/build.gradle index d918a66..343f171 100644 --- a/app-test/build.gradle +++ b/app-test/build.gradle @@ -6,7 +6,6 @@ apply plugin: 'com.github.kt3k.coveralls' evaluationDependsOn(":app") buildscript { - ext.kotlin_version = '0.10.770' repositories { mavenCentral() } @@ -49,7 +48,7 @@ dependencies { testCompile 'org.robolectric:robolectric:2.+' testCompile 'org.mockito:mockito-core:+' testCompile 'com.jayway.awaitility:awaitility:+' - testCompile 'org.jetbrains.spek:spek:+' + testCompile 'org.jetbrains.spek:spek:0.1-SNAPSHOT' testCompile firstVariant.javaCompile.classpath testCompile firstVariant.javaCompile.outputs.files diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/BookListFragmentTest.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/BookListFragmentTest.kt index b2aa8e4..216ba34 100644 --- a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/BookListFragmentTest.kt +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/BookListFragmentTest.kt @@ -1,14 +1,14 @@ package org.bspeice.minimalbible.activity.downloader +import android.content.DialogInterface import org.jetbrains.spek.api.Spek import kotlin.test.assertTrue -import android.content.DialogInterface /** * Created by bspeice on 11/22/14. */ -class BookListFragmentSpek : Spek() {{ +class BookListFragmentSpek : Spek() {init { given("A BookListFragment with showDialog() mocked out") { val fragment = object : BookListFragment() { diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEventSpek.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEventSpek.kt index 8cfc34c..dea0c68 100644 --- a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEventSpek.kt +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEventSpek.kt @@ -4,11 +4,12 @@ import org.bspeice.minimalbible.activity.downloader.manager.DLProgressEvent import org.crosswire.jsword.book.Book -import org.mockito.Mockito.mock import org.jetbrains.spek.api.Spek +import org.mockito.Mockito.mock import kotlin.test.assertEquals -class DLProgressEventSpek : Spek() {{ + +class DLProgressEventSpek : Spek() {init { given("a DLProgressEvent created with 50% progress and a mock book") { val mockBook = mock(javaClass()) diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManagerSpek.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManagerSpek.kt index 21007d5..e84a715 100644 --- a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManagerSpek.kt +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManagerSpek.kt @@ -1,13 +1,13 @@ package org.bspeice.minimalbible.activity.downloader.manager -import org.jetbrains.spek.api.Spek import org.crosswire.common.util.Language +import org.jetbrains.spek.api.Spek /** * Created by bspeice on 12/14/14. */ -class LocaleManagerSpek() : Spek() {{ +class LocaleManagerSpek() : Spek() {init { given("some example language objects") { val english = Language("en") diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManagerSpek.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManagerSpek.kt index ab83cbb..dd3c462 100644 --- a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManagerSpek.kt +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/downloader/manager/RefreshManagerSpek.kt @@ -1,23 +1,23 @@ package org.bspeice.minimalbible.activity.downloader.manager -import org.jetbrains.spek.api.Spek -import org.bspeice.minimalbible.activity.downloader.DownloadPrefs -import java.util.Calendar -import org.crosswire.jsword.book.install.Installer -import org.mockito.Mockito.* -import org.mockito.Matchers.* -import rx.schedulers.Schedulers -import java.util.concurrent.atomic.AtomicBoolean import com.jayway.awaitility.Awaitility -import java.util.concurrent.TimeUnit -import rx.Subscriber +import org.bspeice.minimalbible.activity.downloader.DownloadPrefs import org.crosswire.jsword.book.Book +import org.crosswire.jsword.book.install.Installer +import org.jetbrains.spek.api.Spek +import org.mockito.Matchers.anyLong +import org.mockito.Mockito.* +import rx.Subscriber +import rx.schedulers.Schedulers +import java.util.Calendar +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean /** * Created by bspeice on 1/3/15. */ -class RefreshManagerSpek() : Spek() {{ +class RefreshManagerSpek() : Spek() {init { fun buildRefreshmanager(installers: List, prefs: DownloadPrefs) = RefreshManager(installers, listOf(""), prefs, null) diff --git a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/search/MBIndexManagerSpek.kt b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/search/MBIndexManagerSpek.kt index 3df1dd1..5ce7288 100644 --- a/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/search/MBIndexManagerSpek.kt +++ b/app-test/src/test/kotlin/org/bspeice/minimalbible/activity/search/MBIndexManagerSpek.kt @@ -1,17 +1,17 @@ package org.bspeice.minimalbible.activity.search +import com.jayway.awaitility.Awaitility +import org.crosswire.jsword.book.Book +import org.crosswire.jsword.index.IndexManager +import org.crosswire.jsword.index.IndexStatus import org.jetbrains.spek.api.Spek import org.mockito.Mockito -import org.crosswire.jsword.index.IndexManager -import org.crosswire.jsword.book.Book -import org.crosswire.jsword.index.IndexStatus +import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference import kotlin.test.assertEquals -import com.jayway.awaitility.Awaitility -import java.util.concurrent.TimeUnit -import kotlin.test.assertTrue import kotlin.test.assertFalse +import kotlin.test.assertTrue import kotlin.test.fail /** @@ -23,7 +23,7 @@ data class Mocks() { val indexManager = MBIndexManager(mockIndex) } -class MBIndexManagerSpek() : Spek() {{ +class MBIndexManagerSpek() : Spek() {init { given("a mock IndexManager, Book, and real MBIndexManager") { val mocks = Mocks() diff --git a/app/build.gradle b/app/build.gradle index e21d402..5156c16 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,9 @@ buildscript { repositories { mavenCentral() } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" + } } apply plugin: 'com.android.application' diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/BookManager.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/BookManager.kt index bb4194a..d0805c1 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/BookManager.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/BookManager.kt @@ -1,19 +1,14 @@ package org.bspeice.minimalbible.activity.downloader.manager -import org.crosswire.common.progress.JobManager; -import org.crosswire.common.progress.WorkEvent; -import org.crosswire.common.progress.WorkListener; -import org.crosswire.jsword.book.Book; -import org.crosswire.jsword.book.Books; -import org.crosswire.jsword.book.BooksEvent; -import org.crosswire.jsword.book.BooksListener; - -import rx.Observable; -import rx.schedulers.Schedulers; -import rx.subjects.PublishSubject; -import org.crosswire.jsword.book.BookException -import org.crosswire.common.progress.Progress import org.bspeice.minimalbible.activity.search.MBIndexManager +import org.crosswire.common.progress.JobManager +import org.crosswire.common.progress.Progress +import org.crosswire.common.progress.WorkEvent +import org.crosswire.common.progress.WorkListener +import org.crosswire.jsword.book.* +import rx.Observable +import rx.schedulers.Schedulers +import rx.subjects.PublishSubject /** * Single point of authority for what is being downloaded and its progress @@ -27,7 +22,6 @@ class BookManager(private val installedBooks: Books, WorkListener, BooksListener { private val bookJobNamePrefix = Progress.INSTALL_BOOK.substringBeforeLast("%s") - private val indexJobNamePrefix = Progress.DOWNLOAD_SEARCH_INDEX.substringBeforeLast("%s") /** * List of jobs currently active by their job name @@ -42,9 +36,9 @@ class BookManager(private val installedBooks: Books, /** * A list of books that is locally maintained - installedBooks isn't always up-to-date */ - val installedBooksList: MutableList = installedBooks.getBooks() ?: linkedListOf(); + val installedBooksList: MutableList = installedBooks.getBooks() ?: linkedListOf() - { + init { JobManager.addWorkListener(this) installedBooks.addBooksListener(this) downloadEvents.subscribe { this.inProgressDownloads[it.b] = it } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEvent.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEvent.kt index 98acaaf..5c91126 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEvent.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/DLProgressEvent.kt @@ -7,7 +7,7 @@ import org.crosswire.jsword.book.Book */ data class DLProgressEvent(val progress: Int, val b: Book) { - class object { + companion object { val PROGRESS_COMPLETE = 100 val PROGRESS_BEGINNING = 0 diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManager.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManager.kt index edd2a71..0b2accf 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManager.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/downloader/manager/LocaleManager.kt @@ -1,8 +1,8 @@ package org.bspeice.minimalbible.activity.downloader.manager import org.crosswire.common.util.Language -import rx.Observable import org.crosswire.jsword.book.BookCategory +import rx.Observable import kotlin.platform.platformStatic /** @@ -38,7 +38,7 @@ class LocaleManager(val rM: RefreshManager) { // And flatten this into the actual List needed .toBlocking().first() - class object { + companion object { platformStatic fun compareLanguages(left: Language, right: Language, current: Language) = if (left == right) diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/search/SearchResultsView.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/search/SearchResultsView.kt index 310728b..4ba05e3 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/search/SearchResultsView.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/search/SearchResultsView.kt @@ -1,17 +1,17 @@ package org.bspeice.minimalbible.activity.search import android.content.Context -import android.util.AttributeSet -import android.widget.LinearLayout -import android.support.v7.widget.RecyclerView import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView +import android.util.AttributeSet import android.view.LayoutInflater -import org.bspeice.minimalbible.R -import org.crosswire.jsword.passage.Verse +import android.view.ViewGroup +import android.widget.LinearLayout import android.widget.TextView +import org.bspeice.minimalbible.R import org.bspeice.minimalbible.service.format.osisparser.OsisParser import org.crosswire.jsword.book.Book -import android.view.ViewGroup +import org.crosswire.jsword.passage.Verse /** * Created by bspeice on 2/26/15. @@ -21,9 +21,9 @@ class SearchResultsListView(val ctx: Context, val attrs: AttributeSet) : LinearL val layoutManager = LinearLayoutManager(ctx) val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val contentView = inflater.inflate(R.layout.view_search_results_list, this, true) - val searchResults = contentView.findViewById(R.id.search_results) as RecyclerView; + val searchResults = contentView.findViewById(R.id.search_results) as RecyclerView - { + init { searchResults setLayoutManager layoutManager } @@ -69,7 +69,7 @@ class ResultViewHolder(val view: SearchResultView) : RecyclerView.ViewHolder(vie * A custom view to wrap showing a search result */ class SearchResultView(val group: ViewGroup?) { - val inflater = LayoutInflater.from(group?.getContext()) + val inflater = LayoutInflater.from(group!!.getContext()) val contentView = inflater.inflate(R.layout.view_search_result, group, false) val verseName = contentView.findViewById(R.id.verseName) as TextView diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt index ae50da0..bb59db5 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt @@ -1,17 +1,17 @@ package org.bspeice.minimalbible.activity.settings import android.content.Context -import android.util.AttributeSet -import android.preference.Preference import android.content.Intent -import org.bspeice.minimalbible.R -import android.os.Build import android.net.Uri +import android.os.Build +import android.preference.Preference +import android.util.AttributeSet +import org.bspeice.minimalbible.R class ContactPreference(val ctx: Context, val attrs: AttributeSet) : Preference(ctx, attrs), Preference.OnPreferenceClickListener { - { + init { setOnPreferenceClickListener(this); } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt index fcd4e25..65f7e17 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleMenu.kt @@ -1,29 +1,27 @@ package org.bspeice.minimalbible.activity.viewer -import android.widget.BaseExpandableListAdapter +import android.content.Context +import android.content.res.Resources +import android.support.annotation.LayoutRes +import android.util.AttributeSet +import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import org.crosswire.jsword.book.Book -import org.crosswire.jsword.book.getVersification -import org.crosswire.jsword.versification.getBooks -import org.crosswire.jsword.book.bookName +import android.widget.BaseExpandableListAdapter +import android.widget.ExpandableListView +import android.widget.LinearLayout import android.widget.TextView import org.bspeice.minimalbible.R -import android.content.Context -import android.view.LayoutInflater -import android.content.res.Resources -import android.widget.ExpandableListView -import rx.subjects.PublishSubject -import android.widget.LinearLayout -import android.app.Activity -import android.util.AttributeSet -import org.bspeice.minimalbible.activity.setInset -import android.support.annotation.LayoutRes +import org.crosswire.jsword.book.Book +import org.crosswire.jsword.book.bookName +import org.crosswire.jsword.book.getVersification import org.crosswire.jsword.versification.BibleBook +import org.crosswire.jsword.versification.getBooks +import rx.subjects.PublishSubject class BibleMenu(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, attrs) { - val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater - val contentView = inflater.inflate(R.layout.view_bible_menu, this, true) + // val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater + // val contentView = inflater.inflate(R.layout.view_bible_menu, this, true) val menuContent = findViewById(R.id._bible_menu) as ExpandableListView fun doInitialize(b: Book, publisher: PublishSubject) { @@ -33,8 +31,6 @@ class BibleMenu(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, a menuContent.collapseGroup(adapter.getGroupIdForBook(it.b)) } } - - fun placeInset(a: Activity) = setInset(a) } /** @@ -62,7 +58,6 @@ class BibleAdapter(val b: Book, val scrollPublisher: PublishSubject): View { val holder = diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt index a1054f4..feea95a 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/viewer/BibleView.kt @@ -1,25 +1,25 @@ package org.bspeice.minimalbible.activity.viewer -import android.support.v7.widget.RecyclerView -import android.view.ViewGroup -import org.crosswire.jsword.book.Book -import android.view.LayoutInflater -import org.bspeice.minimalbible.R -import android.widget.TextView -import org.crosswire.jsword.book.getVersification -import org.crosswire.jsword.versification.getBooks -import org.crosswire.jsword.versification.BibleBook -import org.bspeice.minimalbible.activity.viewer.BookAdapter.ChapterInfo -import rx.subjects.PublishSubject -import android.text.SpannableStringBuilder -import android.util.TypedValue -import android.util.Log import android.content.Context -import android.util.AttributeSet import android.support.v7.widget.LinearLayoutManager -import android.widget.LinearLayout +import android.support.v7.widget.RecyclerView +import android.text.SpannableStringBuilder +import android.util.AttributeSet +import android.util.Log +import android.util.TypedValue +import android.view.LayoutInflater import android.view.View +import android.view.ViewGroup +import android.widget.LinearLayout +import android.widget.TextView +import org.bspeice.minimalbible.R +import org.bspeice.minimalbible.activity.viewer.BookAdapter.ChapterInfo import org.bspeice.minimalbible.service.format.osisparser.OsisParser +import org.crosswire.jsword.book.Book +import org.crosswire.jsword.book.getVersification +import org.crosswire.jsword.versification.BibleBook +import org.crosswire.jsword.versification.getBooks +import rx.subjects.PublishSubject class BibleView(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, attrs) { @@ -28,7 +28,7 @@ class BibleView(val ctx: Context, val attrs: AttributeSet) : LinearLayout(ctx, a val contentView: View = inflater.inflate(R.layout.view_bible, this, true) val bibleContent = contentView.findViewById(R.id.bible_content) as RecyclerView - { + init { bibleContent setLayoutManager layoutManager } @@ -96,7 +96,7 @@ class BookAdapter(val b: Book, val prefs: BibleViewerPreferences) */ override fun onCreateViewHolder(parent: ViewGroup?, position: Int): PassageView { - val emptyView = LayoutInflater.from(parent?.getContext()) + val emptyView = LayoutInflater.from(parent!!.getContext()) .inflate(R.layout.viewer_passage_view, parent, false) as TextView // TODO: Listen for changes to the text size? @@ -125,14 +125,14 @@ class BookAdapter(val b: Book, val prefs: BibleViewerPreferences) val event = it lM scrollToPosition // Get all objects in the form (index, object) - chapterList.withIndices() - // Get one that matches our book and chapter + chapterList.withIndex() + // get one that matches our book and chapter .first { - event.b == it.second.bibleBook && - event.chapter == it.second.chapter + event.b == it.value.bibleBook && + event.chapter == it.value.chapter } - // And get that index value to scroll to - .first + // and get that index value to scroll to + .index } } } diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/service/manager/BookManager.kt b/app/src/main/kotlin/org/bspeice/minimalbible/service/manager/BookManager.kt index 8ab5a6f..d7b737b 100644 --- a/app/src/main/kotlin/org/bspeice/minimalbible/service/manager/BookManager.kt +++ b/app/src/main/kotlin/org/bspeice/minimalbible/service/manager/BookManager.kt @@ -1,11 +1,11 @@ package org.bspeice.minimalbible.service.manager -import rx.Observable -import org.crosswire.jsword.book.Books -import rx.functions.Action1 -import org.crosswire.jsword.book.Book -import rx.functions.Action0 import org.bspeice.minimalbible.exception.NoBooksInstalledException +import org.crosswire.jsword.book.Book +import org.crosswire.jsword.book.Books +import rx.Observable +import rx.functions.Action0 +import rx.functions.Action1 import javax.inject.Singleton /** @@ -21,9 +21,9 @@ open class BookManager(val ignore: List) { ?.filter { !ignore.contains(it!!.getInitials()) } ?.cache() ?: throw NoBooksInstalledException() - var refreshComplete = false; + var refreshComplete = false - { + init { // TODO: Cleaner way of expressing this? installedBooks.subscribe(Action1 { result -> }, Action1 { error -> }, diff --git a/build.gradle b/build.gradle index c39dd83..2975acb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '0.9.976' + ext.kotlin_version = '0.11.91' repositories { mavenCentral()