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() {
return hasProperty("include_updater");
return hasProperty("include_updater")
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion "23.0.3"
publishNonDefault true
defaultConfig {
@ -88,7 +88,7 @@ kapt {
}
dependencies {
final SUPPORT_LIBRARY_VERSION = '23.2.1'
final SUPPORT_LIBRARY_VERSION = '23.3.0'
final DAGGER_VERSION = '2.2'
final OKHTTP_VERSION = '3.2.0'
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.setting.SettingsActivity
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.toolbar.*
@ -57,7 +57,7 @@ class MainActivity : BaseActivity() {
// Set behavior of Navigation drawer
nav_view.setNavigationItemSelectedListener { item ->
// Make information view invisible
image_view.setDrawableCompat(null)
image_view.setImageResource(android.R.color.transparent)
text_label.text = ""
when (item.itemId) {
@ -93,10 +93,10 @@ class MainActivity : BaseActivity() {
fun updateEmptyView(show: Boolean, textResource: Int, drawable: Int) {
if (show) {
image_view.setDrawableCompat(drawable)
image_view.setVectorCompat(drawable, theme.getResourceColor(android.R.attr.textColorHint))
text_label.text = getString(textResource)
} else {
image_view.setDrawableCompat(null)
image_view.setImageResource(android.R.color.transparent)
text_label.text = ""
}
}

View File

@ -77,9 +77,8 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
val chapter = presenter.getNextUnreadChapter()
if (chapter != null) {
// Create animation listener
var revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
// On done open chapter
val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?) {
openChapter(chapter, true)
}
}
@ -109,7 +108,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
// Check if animation view is visible
if (reveal_view.visibility == View.VISIBLE) {
// Show the unReveal effect
var coordinates = fab.getCoordinates()
val coordinates = fab.getCoordinates()
reveal_view.hideRevealEffect(coordinates.x, coordinates.y, 1920)
}
super.onResume()
@ -184,7 +183,7 @@ class ChaptersFragment : BaseRxFragment<ChaptersPresenter>(), ActionMode.Callbac
val isCatalogueManga: Boolean
get() = (activity as MangaActivity).isCatalogueManga
protected fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) {
fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) {
presenter.onOpenChapter(chapter)
val intent = ReaderActivity.newIntent(activity)
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.source.base.Source
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment
import eu.kanade.tachiyomi.util.setDrawableCompat
import kotlinx.android.synthetic.main.fragment_manga_info.*
import nucleus.factory.RequiresPresenter
@ -137,7 +136,7 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
private fun setFavoriteDrawable(isFavorite: Boolean) {
// Set the Favorite drawable to the correct one.
// Border drawable if false, filled drawable if true.
fab_favorite.setDrawableCompat(if (isFavorite)
fab_favorite.setImageResource(if (isFavorite)
R.drawable.ic_bookmark_white_24dp
else
R.drawable.ic_bookmark_border_white_24dp)

View File

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

View File

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

View File

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.ui.setting
import android.app.FragmentManager
import android.os.Build
import android.os.Bundle
import android.support.v14.preference.PreferenceFragment
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -40,4 +42,11 @@ open class SettingsNestedFragment : PreferenceFragment() {
val preferences: PreferencesHelper
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 {
val fragment = SourceLoginDialog.newInstance(source)
fragment.setTargetFragment(this@SettingsSourcesFragment, SOURCE_CHANGE_REQUEST)
fragment.show(childFragmentManager, null)
fragment.show(fragmentManagerCompat, null)
true
}

View File

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

View File

@ -1,21 +1,20 @@
package eu.kanade.tachiyomi.util
import android.support.annotation.DrawableRes
import android.support.graphics.drawable.VectorDrawableCompat
import android.support.v4.content.ContextCompat
import android.support.v4.graphics.drawable.DrawableCompat
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
*/
fun ImageView.setDrawableCompat(@DrawableRes drawable: Int?) {
if (drawable != null) {
var drawable = ContextCompat.getDrawable(context, drawable)
DrawableCompat.setTint(drawable,this.context.theme.getResourceColor(android.R.attr.textColorHint))
setImageDrawable(drawable)
} else {
setImageResource(android.R.color.transparent)
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
if (tint != null) {
vector?.setTint(tint)
}
setImageDrawable(vector)
}

View File

@ -18,13 +18,10 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
with(holder.itemView.image_view) {
if (getPersistedString("").isNullOrEmpty()) {
setImageResource(android.R.color.transparent)
} else {
setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_done_green_24dp))
}
}
holder.itemView.image_view.setImageResource(if (getPersistedString("").isNullOrEmpty())
android.R.color.transparent
else
R.drawable.ic_done_green_24dp)
}
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"?>
<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:drawable="@drawable/ic_reader_background_checkbox_white_24dp" />
<item android:state_checked="true" android:drawable="@drawable/reader_background_checkbox_selected" />
<item android:drawable="@drawable/reader_background_checkbox_unselected" />
</selector>

View File

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

View File

@ -6,7 +6,7 @@ buildscript {
jcenter()
}
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'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files