From 604929d00224114268108778fab0f6a772a20821 Mon Sep 17 00:00:00 2001 From: inorichi Date: Tue, 28 Nov 2017 00:21:38 +0100 Subject: [PATCH] Update support library and kotlin --- .travis/build.sh | 2 +- app/build.gradle | 10 +++++----- .../kanade/tachiyomi/ui/library/LibraryAdapter.kt | 2 +- .../tachiyomi/ui/reader/ReaderCustomFilterDialog.kt | 2 +- .../tachiyomi/ui/reader/ReaderSettingsDialog.kt | 9 ++++++--- .../tachiyomi/ui/reader/viewer/pager/PagerReader.kt | 4 ++-- .../viewer/pager/horizontal/HorizontalPager.kt | 4 ++-- .../viewer/pager/horizontal/LeftToRightReader.kt | 2 +- .../viewer/pager/horizontal/RightToLeftReader.kt | 2 +- .../reader/viewer/pager/vertical/VerticalReader.kt | 2 +- .../pager/vertical/VerticalViewPagerImpl.java | 13 ++++--------- .../ui/reader/viewer/webtoon/WebtoonReader.kt | 4 ++-- .../ui/setting/SettingsDownloadController.kt | 2 +- build.gradle | 2 +- 14 files changed, 29 insertions(+), 31 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index d0c376bef..049fd015b 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -12,7 +12,7 @@ if [ -z "$TRAVIS_TAG" ]; then else ./gradlew clean assembleStandardRelease - TOOLS="${ANDROID_HOME}/build-tools/26.0.1" + TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)" export ARTIFACT="tachiyomi-${TRAVIS_TAG}.apk" ${TOOLS}/zipalign -v -p 4 app/build/outputs/apk/standard/release/app-standard-release-unsigned.apk app-aligned.apk diff --git a/app/build.gradle b/app/build.gradle index 4994c0755..b8dbf6ea5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,7 +30,7 @@ ext { android { compileSdkVersion 26 - buildToolsVersion "26.0.2" + buildToolsVersion "27.0.1" publishNonDefault true defaultConfig { @@ -106,7 +106,7 @@ dependencies { implementation 'com.github.inorichi:junrar-android:634c1f5' // Android support library - final support_library_version = '26.1.0' + final support_library_version = '27.0.1' implementation "com.android.support:support-v4:$support_library_version" implementation "com.android.support:appcompat-v7:$support_library_version" implementation "com.android.support:cardview-v7:$support_library_version" @@ -122,13 +122,13 @@ dependencies { // ReactiveX implementation 'io.reactivex:rxandroid:1.2.1' - implementation 'io.reactivex:rxjava:1.3.3' + implementation 'io.reactivex:rxjava:1.3.4' implementation 'com.jakewharton.rxrelay:rxrelay:1.2.0' implementation 'com.f2prateek.rx.preferences:rx-preferences:1.0.2' implementation 'com.github.pwittchen:reactivenetwork:0.7.0' // Network client - implementation "com.squareup.okhttp3:okhttp:3.9.0" + implementation "com.squareup.okhttp3:okhttp:3.9.1" implementation 'com.squareup.okio:okio:1.13.0' // REST @@ -232,7 +232,7 @@ dependencies { } buildscript { - ext.kotlin_version = '1.1.51' + ext.kotlin_version = '1.1.61' repositories { mavenCentral() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt index ae19c08ad..247b113ba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt @@ -79,7 +79,7 @@ class LibraryAdapter(private val controller: LibraryController) : RecyclerViewPa /** * Returns the position of the view. */ - override fun getItemPosition(obj: Any?): Int { + override fun getItemPosition(obj: Any): Int { val view = obj as? LibraryCategoryView ?: return POSITION_NONE val index = categories.indexOfFirst { it.id == view.category.id } return if (index == -1) POSITION_NONE else index diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt index 7e3ac1003..d76a5156f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt @@ -64,7 +64,7 @@ class ReaderCustomFilterDialog : DialogFragment() { * @param savedState The last saved instance state of the Fragment. */ override fun onCreateDialog(savedState: Bundle?): Dialog { - val dialog = MaterialDialog.Builder(activity) + val dialog = MaterialDialog.Builder(activity!!) .customView(R.layout.reader_custom_filter_dialog, false) .positiveText(android.R.string.ok) .build() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt index fa09cc120..8927ad4fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt @@ -24,7 +24,7 @@ class ReaderSettingsDialog : DialogFragment() { private lateinit var subscriptions: CompositeSubscription override fun onCreateDialog(savedState: Bundle?): Dialog { - val dialog = MaterialDialog.Builder(activity) + val dialog = MaterialDialog.Builder(activity!!) .title(R.string.label_settings) .customView(R.layout.reader_settings_dialog, true) .positiveText(android.R.string.ok) @@ -40,8 +40,11 @@ class ReaderSettingsDialog : DialogFragment() { viewer.onItemSelectedListener = IgnoreFirstSpinnerListener { position -> subscriptions += Observable.timer(250, MILLISECONDS, AndroidSchedulers.mainThread()) .subscribe { - (activity as ReaderActivity).presenter.updateMangaViewer(position) - activity.recreate() + val readerActivity = activity as? ReaderActivity + if (readerActivity != null) { + readerActivity.presenter.updateMangaViewer(position) + readerActivity.recreate() + } } } viewer.setSelection((activity as ReaderActivity).presenter.manga.viewer, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt index ab12c872a..a5a4e71d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt @@ -100,12 +100,12 @@ abstract class PagerReader : BaseReader() { /** * Text color for black theme. */ - val whiteColor by lazy { ContextCompat.getColor(context, R.color.textColorSecondaryDark) } + val whiteColor by lazy { ContextCompat.getColor(context!!, R.color.textColorSecondaryDark) } /** * Text color for white theme. */ - val blackColor by lazy { ContextCompat.getColor(context, R.color.textColorSecondaryLight) } + val blackColor by lazy { ContextCompat.getColor(context!!, R.color.textColorSecondaryLight) } /** * Initializes the pager. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/HorizontalPager.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/HorizontalPager.kt index e12f773a7..e359b7fbf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/HorizontalPager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/HorizontalPager.kt @@ -24,7 +24,7 @@ class HorizontalPager(context: Context) : ViewPager(context), Pager { override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { try { if (ev.action and MotionEvent.ACTION_MASK == MotionEvent.ACTION_DOWN) { - if (currentItem == 0 || currentItem == adapter.count - 1) { + if (currentItem == 0 || currentItem == adapter!!.count - 1) { startDragX = ev.x } } @@ -50,7 +50,7 @@ class HorizontalPager(context: Context) : ViewPager(context), Pager { startDragX = 0f } - } else if (currentItem == adapter.count - 1) { + } else if (currentItem == adapter!!.count - 1) { if (ev.action and MotionEvent.ACTION_MASK == MotionEvent.ACTION_UP) { val displacement = startDragX - ev.x diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/LeftToRightReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/LeftToRightReader.kt index 39f533c3f..28d170deb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/LeftToRightReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/LeftToRightReader.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader class LeftToRightReader : PagerReader() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? { - return HorizontalPager(activity).apply { initializePager(this) } + return HorizontalPager(activity!!).apply { initializePager(this) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/RightToLeftReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/RightToLeftReader.kt index 7815bc66b..ab866cbd6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/RightToLeftReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/horizontal/RightToLeftReader.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader class RightToLeftReader : PagerReader() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? { - return HorizontalPager(activity).apply { + return HorizontalPager(activity!!).apply { rotation = 180f initializePager(this) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalReader.kt index 3a5716025..028e9b187 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalReader.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader class VerticalReader : PagerReader() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? { - return VerticalPager(activity).apply { initializePager(this) } + return VerticalPager(activity!!).apply { initializePager(this) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java index d435dd24e..d9174ff3d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java @@ -33,7 +33,6 @@ import android.support.annotation.DrawableRes; import android.support.v4.os.ParcelableCompat; import android.support.v4.os.ParcelableCompatCreatorCallbacks; import android.support.v4.view.AccessibilityDelegateCompat; -import android.support.v4.view.KeyEventCompat; import android.support.v4.view.MotionEventCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.VelocityTrackerCompat; @@ -2598,14 +2597,10 @@ public class VerticalViewPagerImpl extends ViewGroup { handled = arrowScroll(FOCUS_RIGHT); break; case KeyEvent.KEYCODE_TAB: - if (Build.VERSION.SDK_INT >= 11) { - // The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD - // before Android 3.0. Ignore the tab key on those devices. - if (KeyEventCompat.hasNoModifiers(event)) { - handled = arrowScroll(FOCUS_FORWARD); - } else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) { - handled = arrowScroll(FOCUS_BACKWARD); - } + if (event.hasNoModifiers()) { + handled = arrowScroll(FOCUS_FORWARD); + } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) { + handled = arrowScroll(FOCUS_BACKWARD); } break; default: diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt index d10cb41b1..83d3f88df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt @@ -73,7 +73,7 @@ class WebtoonReader : BaseReader() { private var scrollDistance: Int = 0 val screenHeight by lazy { - val display = activity.windowManager.defaultDisplay + val display = activity!!.windowManager.defaultDisplay if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { val metrics = DisplayMetrics() @@ -91,7 +91,7 @@ class WebtoonReader : BaseReader() { val screenHeight = resources.displayMetrics.heightPixels scrollDistance = screenHeight * 3 / 4 - layoutManager = PreCachingLayoutManager(activity) + layoutManager = PreCachingLayoutManager(activity!!) layoutManager.extraLayoutSpace = screenHeight / 2 recycler = RecyclerView(activity).apply { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt index 39485d6ec..04ec17f60 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsDownloadController.kt @@ -194,7 +194,7 @@ class SettingsDownloadController : SettingsController() { File.separator + "downloads" return mutableListOf(File(defaultDir)) + - ContextCompat.getExternalFilesDirs(activity, "").filterNotNull() + ContextCompat.getExternalFilesDirs(activity!!, "").filterNotNull() } } diff --git a/build.gradle b/build.gradle index 1115873b6..7bdf0497e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.1' // NOTE: Do not place your application dependencies here; they belong