From 67c478137651a08647db6a063e73b1f8fed3eb08 Mon Sep 17 00:00:00 2001 From: len Date: Fri, 8 Apr 2016 16:18:41 +0200 Subject: [PATCH] Upgrade support library. Switch gradle build tools and AS to 2.0. Adapt code to new support lib --- app/build.gradle | 6 +++--- .../kanade/tachiyomi/ui/main/MainActivity.kt | 8 ++++---- .../ui/manga/chapter/ChaptersFragment.kt | 9 ++++----- .../ui/manga/info/MangaInfoFragment.kt | 3 +-- .../ui/reader/viewer/webtoon/WebtoonReader.kt | 2 +- .../ui/setting/SettingsGeneralFragment.kt | 2 +- .../ui/setting/SettingsNestedFragment.kt | 9 +++++++++ .../ui/setting/SettingsSourcesFragment.kt | 2 +- .../ui/setting/SettingsSyncFragment.kt | 2 +- .../tachiyomi/util/ImageViewExtensions.kt | 17 ++++++++--------- .../widget/preference/LoginPreference.kt | 11 ++++------- .../reader_background_checkbox_selected.png | Bin 0 -> 227 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 249 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 136 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 153 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 142 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 148 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 366 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 387 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 434 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 499 bytes ...c_reader_background_checkbox_black_24dp.xml | 9 --------- ...c_reader_background_checkbox_white_24dp.xml | 9 --------- .../drawable/reader_background_checkbox.xml | 4 ++-- app/src/main/res/layout/reader_popup.xml | 4 ---- build.gradle | 2 +- 26 files changed, 40 insertions(+), 59 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-hdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-ldpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-xxhdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-xxhdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_unselected.png delete mode 100644 app/src/main/res/drawable/ic_reader_background_checkbox_black_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_reader_background_checkbox_white_24dp.xml diff --git a/app/build.gradle b/app/build.gradle index cb180b858..15bcfdeaf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 3ad54c68e..bea488f3c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -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 = "" } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt index 572baa377..f94cbe022 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.kt @@ -77,9 +77,8 @@ class ChaptersFragment : BaseRxFragment(), 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(), 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(), 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) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt index 0840e4b44..689fa20e8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt @@ -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() { 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) 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 76672abce..3d64bbcba 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 @@ -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) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralFragment.kt index ec5862484..d99741fc8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralFragment.kt @@ -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) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsNestedFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsNestedFragment.kt index b2d44e135..ef4a69a6f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsNestedFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsNestedFragment.kt @@ -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 + } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt index a5b5615e7..d6c2f39bc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt @@ -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 } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSyncFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSyncFragment.kt index e6400f339..da2c244fe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSyncFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSyncFragment.kt @@ -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 } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ImageViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ImageViewExtensions.kt index 518356f0e..179188870 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ImageViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ImageViewExtensions.kt @@ -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) +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt index c2889443c..e4068b9fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginPreference.kt @@ -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() { diff --git a/app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..9908433c073331a4d7356e7ea97e53e8377abaf3 GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtRh}-6Ar-gY&N#?>SV4g0r{cwi zyKylcg`SGJH~sGg^1Zyo*xh8T{8l`#fnS=5f#JY>L0!)&E9B}n+UV?7EkE}zd;O`0 z^QT=7a?Q*ZZ*}={Ia7Mi(ah?cz4L=VX|H2uS!KWSO0)vMh(((C2@Zt@1|}rp&P#90 zugmLF))r}IO?{9WEGQnG`(yg1xzT@1HtoM0xAjr^T3^dQx~F0p7#ik3V)mCgv;Fno SnjJt_GkCiCxvXIlZ*%=rLRGm0#*Uk?9y6*6CiT9^B z*%X}%UYim#`P@2Nw(}3?FP*aW+Ov@Cw;zqBU%33L?AC{S9!Vy#>Tj3N+i`c2`Rp(+ z+qJBh`j|dnWEEoKP-tL4BGP{a$^8o6pT6dkVSi}U22+iaBED@Ve{LJkoqXiRq60S# q!v4%%y7_LKz3UEc28Iv$HH>^Wj;nEXT4n?N!rn literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..d06d87c9571bac625d670ea2a8fbcfa0578831bc GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`{+=$5Ar-fh6C`>Xx*3jft2FH3 z>X2^OA;)X(@Koi)O`f0+Tpjx#99X{~Ye#|P1%}Wc{OtdjLYpr)R4MVSkblM&Ak!h@ js(h5QQ_FMaKL&7S66E(|eFe0O!PC{xWt~$(696tE BGmZcN literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..f0faf295f8548ba7617af2bcec6c1faff28fdf8d GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJP)`@fkcwMxr)}f~O0eYKIdE5I z9?0l#FY%d0$9mpmY!BUo-X$Lr_exj+jTJYD@<);T3K0RYA_E|vfQ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png new file mode 100644 index 0000000000000000000000000000000000000000..69e1ee734a399d3880c6b4aa55b467f257eba37a GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJXipc%kcwMxuNm?lFyL{ysFRqG zm-U^Mk~aSW-r_4dxfzC#WI4G%?C z(zQR-PT0Mj@t%NAfAB???#xSfOeA@PE}!}I_vDYf{b{e4nR-rAfg!v1>S-O8VzU+J z@6BnSVfaj>xPNBSGbQ7v#`8b(w0G(MH-9Gexg#>^TGHkxo9}=I8k){eQLd zIt{{hefIzPb>Zq-_y-COO#rv2TzsQU4-J$VD$2IaSW-r_4bZp-eCs;hl>qf zOW964*S3E%E6t0zEO*$QBSOsxx| literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png new file mode 100644 index 0000000000000000000000000000000000000000..90c1bd6f56549cce91c1055099eaf7bb5df43060 GIT binary patch literal 434 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrV660XaSW-r_4ckKSF?eLYvA#` z<-2)P%-}pHH}BowyyL0-eon9dOnyIH@BG?4ZHciwQou1V a{OD)T{q(Kt;-+0{AaPGuKbLh*2~7Yab%iD;uunK>+Ri(oXrLz4j1co z_uXdO)EjNll^~_4%es1sljp~|?BxuTowvrn5A)iona9V-&<-?5fPu+@frEijfq?}d z=f|Rr)3SFR^ha! zZ>!C(3MZZZZFc|uwnWPBpL+LuUQz$<7pw^@eBb@C47Q$Zz#zv_^x^u!Tjvs9l=9m$ z?x_=A@{LvIq5h*w^Gv^1JpZrEz(^o0k%QdsJ>QhCj;Ed%cDjQC#M9N!Wt~$(699+? BfB^si literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/ic_reader_background_checkbox_black_24dp.xml b/app/src/main/res/drawable/ic_reader_background_checkbox_black_24dp.xml deleted file mode 100644 index f041ff22a..000000000 --- a/app/src/main/res/drawable/ic_reader_background_checkbox_black_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_reader_background_checkbox_white_24dp.xml b/app/src/main/res/drawable/ic_reader_background_checkbox_white_24dp.xml deleted file mode 100644 index 6ec88b717..000000000 --- a/app/src/main/res/drawable/ic_reader_background_checkbox_white_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/reader_background_checkbox.xml b/app/src/main/res/drawable/reader_background_checkbox.xml index 07dff0006..2ace26fce 100644 --- a/app/src/main/res/drawable/reader_background_checkbox.xml +++ b/app/src/main/res/drawable/reader_background_checkbox.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/layout/reader_popup.xml b/app/src/main/res/layout/reader_popup.xml index d5205d517..b16dc33bf 100644 --- a/app/src/main/res/layout/reader_popup.xml +++ b/app/src/main/res/layout/reader_popup.xml @@ -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"/>