Upgrade support library. Switch gradle build tools and AS to 2.0. Adapt code to new support lib

This commit is contained in:
len 2016-04-08 16:18:41 +02:00
parent fe49286d97
commit 67c4781376
26 changed files with 40 additions and 59 deletions

View File

@ -25,12 +25,12 @@ ext {
} }
def includeUpdater() { def includeUpdater() {
return hasProperty("include_updater"); return hasProperty("include_updater")
} }
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "23.0.2" buildToolsVersion "23.0.3"
publishNonDefault true publishNonDefault true
defaultConfig { defaultConfig {
@ -88,7 +88,7 @@ kapt {
} }
dependencies { dependencies {
final SUPPORT_LIBRARY_VERSION = '23.2.1' final SUPPORT_LIBRARY_VERSION = '23.3.0'
final DAGGER_VERSION = '2.2' final DAGGER_VERSION = '2.2'
final OKHTTP_VERSION = '3.2.0' final OKHTTP_VERSION = '3.2.0'
final RETROFIT_VERSION = '2.0.1' final RETROFIT_VERSION = '2.0.1'

View File

@ -17,7 +17,7 @@ import eu.kanade.tachiyomi.ui.library.LibraryFragment
import eu.kanade.tachiyomi.ui.recent.RecentChaptersFragment import eu.kanade.tachiyomi.ui.recent.RecentChaptersFragment
import eu.kanade.tachiyomi.ui.setting.SettingsActivity import eu.kanade.tachiyomi.ui.setting.SettingsActivity
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
import eu.kanade.tachiyomi.util.setDrawableCompat import eu.kanade.tachiyomi.util.setVectorCompat
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.toolbar.* import kotlinx.android.synthetic.main.toolbar.*
@ -57,7 +57,7 @@ class MainActivity : BaseActivity() {
// Set behavior of Navigation drawer // Set behavior of Navigation drawer
nav_view.setNavigationItemSelectedListener { item -> nav_view.setNavigationItemSelectedListener { item ->
// Make information view invisible // Make information view invisible
image_view.setDrawableCompat(null) image_view.setImageResource(android.R.color.transparent)
text_label.text = "" text_label.text = ""
when (item.itemId) { when (item.itemId) {
@ -93,10 +93,10 @@ class MainActivity : BaseActivity() {
fun updateEmptyView(show: Boolean, textResource: Int, drawable: Int) { fun updateEmptyView(show: Boolean, textResource: Int, drawable: Int) {
if (show) { if (show) {
image_view.setDrawableCompat(drawable) image_view.setVectorCompat(drawable, theme.getResourceColor(android.R.attr.textColorHint))
text_label.text = getString(textResource) text_label.text = getString(textResource)
} else { } else {
image_view.setDrawableCompat(null) image_view.setImageResource(android.R.color.transparent)
text_label.text = "" text_label.text = ""
} }
} }

View File

@ -77,9 +77,8 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
val chapter = presenter.getNextUnreadChapter() val chapter = presenter.getNextUnreadChapter()
if (chapter != null) { if (chapter != null) {
// Create animation listener // Create animation listener
var revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() { val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) { override fun onAnimationStart(animation: Animator?) {
// On done open chapter
openChapter(chapter, true) openChapter(chapter, true)
} }
} }
@ -109,7 +108,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
// Check if animation view is visible // Check if animation view is visible
if (reveal_view.visibility == View.VISIBLE) { if (reveal_view.visibility == View.VISIBLE) {
// Show the unReveal effect // Show the unReveal effect
var coordinates = fab.getCoordinates() val coordinates = fab.getCoordinates()
reveal_view.hideRevealEffect(coordinates.x, coordinates.y, 1920) reveal_view.hideRevealEffect(coordinates.x, coordinates.y, 1920)
} }
super.onResume() super.onResume()
@ -184,7 +183,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
val isCatalogueManga: Boolean val isCatalogueManga: Boolean
get() = (activity as MangaActivity).isCatalogueManga get() = (activity as MangaActivity).isCatalogueManga
protected fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) { fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) {
presenter.onOpenChapter(chapter) presenter.onOpenChapter(chapter)
val intent = ReaderActivity.newIntent(activity) val intent = ReaderActivity.newIntent(activity)
if (hasAnimation) { if (hasAnimation) {

View File

@ -8,7 +8,6 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.source.base.Source import eu.kanade.tachiyomi.data.source.base.Source
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
import eu.kanade.tachiyomi.util.setDrawableCompat
import kotlinx.android.synthetic.main.fragment_manga_info.* import kotlinx.android.synthetic.main.fragment_manga_info.*
import nucleus.factory.RequiresPresenter import nucleus.factory.RequiresPresenter
@ -137,7 +136,7 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
private fun setFavoriteDrawable(isFavorite: Boolean) { private fun setFavoriteDrawable(isFavorite: Boolean) {
// Set the Favorite drawable to the correct one. // Set the Favorite drawable to the correct one.
// Border drawable if false, filled drawable if true. // Border drawable if false, filled drawable if true.
fab_favorite.setDrawableCompat(if (isFavorite) fab_favorite.setImageResource(if (isFavorite)
R.drawable.ic_bookmark_white_24dp R.drawable.ic_bookmark_white_24dp
else else
R.drawable.ic_bookmark_border_white_24dp) R.drawable.ic_bookmark_border_white_24dp)

View File

@ -110,7 +110,7 @@ class WebtoonReader : BaseReader() {
} }
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
val savedPosition = pages[layoutManager.findFirstVisibleItemPosition()].pageNumber val savedPosition = pages.getOrNull(layoutManager.findFirstVisibleItemPosition())?.pageNumber ?: 0
outState.putInt(SAVED_POSITION, savedPosition) outState.putInt(SAVED_POSITION, savedPosition)
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
} }

View File

@ -74,7 +74,7 @@ class SettingsGeneralFragment : SettingsNestedFragment() {
if (preference === columnsPreference) { if (preference === columnsPreference) {
val fragment = LibraryColumnsDialog.newInstance(preference) val fragment = LibraryColumnsDialog.newInstance(preference)
fragment.setTargetFragment(this, 0) fragment.setTargetFragment(this, 0)
fragment.show(childFragmentManager, null) fragment.show(fragmentManagerCompat, null)
} else { } else {
super.onDisplayPreferenceDialog(preference) super.onDisplayPreferenceDialog(preference)
} }

View File

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.ui.setting package eu.kanade.tachiyomi.ui.setting
import android.app.FragmentManager
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.support.v14.preference.PreferenceFragment import android.support.v14.preference.PreferenceFragment
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -40,4 +42,11 @@ open class SettingsNestedFragment : PreferenceFragment() {
val preferences: PreferencesHelper val preferences: PreferencesHelper
get() = settingsActivity.preferences get() = settingsActivity.preferences
val fragmentManagerCompat: FragmentManager
get() = if (Build.VERSION.SDK_INT >= 17) {
childFragmentManager
} else {
fragmentManager
}
} }

View File

@ -71,7 +71,7 @@ class SettingsSourcesFragment : SettingsNestedFragment() {
setOnPreferenceClickListener { setOnPreferenceClickListener {
val fragment = SourceLoginDialog.newInstance(source) val fragment = SourceLoginDialog.newInstance(source)
fragment.setTargetFragment(this@SettingsSourcesFragment, SOURCE_CHANGE_REQUEST) fragment.setTargetFragment(this@SettingsSourcesFragment, SOURCE_CHANGE_REQUEST)
fragment.show(childFragmentManager, null) fragment.show(fragmentManagerCompat, null)
true true
} }

View File

@ -33,7 +33,7 @@ class SettingsSyncFragment : SettingsNestedFragment() {
setOnPreferenceClickListener { setOnPreferenceClickListener {
val fragment = MangaSyncLoginDialog.newInstance(sync) val fragment = MangaSyncLoginDialog.newInstance(sync)
fragment.setTargetFragment(this@SettingsSyncFragment, SYNC_CHANGE_REQUEST) fragment.setTargetFragment(this@SettingsSyncFragment, SYNC_CHANGE_REQUEST)
fragment.show(childFragmentManager, null) fragment.show(fragmentManagerCompat, null)
true true
} }
} }

View File

@ -1,21 +1,20 @@
package eu.kanade.tachiyomi.util package eu.kanade.tachiyomi.util
import android.support.annotation.DrawableRes import android.support.annotation.DrawableRes
import android.support.graphics.drawable.VectorDrawableCompat
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.graphics.drawable.DrawableCompat import android.support.v4.graphics.drawable.DrawableCompat
import android.widget.ImageView import android.widget.ImageView
/** /**
* Set a drawable on a [ImageView] using [ContextCompat] for backwards compatibility. * Set a vector on a [ImageView].
* *
* @param drawable id of drawable resource * @param drawable id of drawable resource
*/ */
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) { fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
if (drawable != null) { val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
var drawable = ContextCompat.getDrawable(context, drawable) if (tint != null) {
DrawableCompat.setTint(drawable,this.context.theme.getResourceColor(android.R.attr.textColorHint)) vector?.setTint(tint)
setImageDrawable(drawable)
} else {
setImageResource(android.R.color.transparent)
} }
setImageDrawable(vector)
} }

View File

@ -18,13 +18,10 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
override fun onBindViewHolder(holder: PreferenceViewHolder) { override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
with(holder.itemView.image_view) { holder.itemView.image_view.setImageResource(if (getPersistedString("").isNullOrEmpty())
if (getPersistedString("").isNullOrEmpty()) { android.R.color.transparent
setImageResource(android.R.color.transparent) else
} else { R.drawable.ic_done_green_24dp)
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_done_green_24dp))
}
}
} }
override public fun notifyChanged() { override public fun notifyChanged() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z"/>
</vector>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/ic_reader_background_checkbox_black_24dp" /> <item android:state_checked="true" android:drawable="@drawable/reader_background_checkbox_selected" />
<item android:drawable="@drawable/ic_reader_background_checkbox_white_24dp" /> <item android:drawable="@drawable/reader_background_checkbox_unselected" />
</selector> </selector>

View File

@ -39,10 +39,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="36dp" android:layout_height="36dp"
android:gravity="center" android:gravity="center"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:text="@string/pref_reader_theme"/> android:text="@string/pref_reader_theme"/>
<android.support.v7.widget.AppCompatCheckBox <android.support.v7.widget.AppCompatCheckBox

View File

@ -6,7 +6,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha4' classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0' classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files