diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 3bde390d8f..89e12df125 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper +import eu.kanade.tachiyomi.databinding.ReaderActivityBinding import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity import eu.kanade.tachiyomi.ui.main.MainActivity @@ -71,8 +72,6 @@ import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.SimpleAnimationListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener -import kotlinx.android.synthetic.main.reader_activity.* -import kotlinx.android.synthetic.main.reader_chapters_sheet.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -101,6 +100,8 @@ class ReaderActivity : BaseRxActivity(), SystemUiHelper.OnVisibilityChangeListener { + lateinit var binding: ReaderActivityBinding + /** * Preferences helper. */ @@ -186,7 +187,8 @@ class ReaderActivity : AppCompatDelegate.setDefaultNightMode(ThemeUtil.nightMode(preferences.theme())) setTheme(ThemeUtil.theme(preferences.theme())) super.onCreate(savedInstanceState) - setContentView(R.layout.reader_activity) + binding = ReaderActivityBinding.inflate(layoutInflater) + setContentView(binding.root) val a = obtainStyledAttributes(intArrayOf(android.R.attr.windowLightStatusBar)) lightStatusBar = a.getBoolean(0, false) a.recycle() @@ -196,9 +198,9 @@ class ReaderActivity : if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { systemUiFlag = systemUiFlag.or(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) } - reader_layout.systemUiVisibility = when (lightStatusBar) { - true -> reader_layout.systemUiVisibility.or(systemUiFlag) - false -> reader_layout.systemUiVisibility.rem(systemUiFlag) + binding.readerLayout.systemUiVisibility = when (lightStatusBar) { + true -> binding.readerLayout.systemUiVisibility.or(systemUiFlag) + false -> binding.readerLayout.systemUiVisibility.rem(systemUiFlag) } if (presenter.needsInit()) { @@ -212,7 +214,7 @@ class ReaderActivity : } presenter.init(manga, chapter) } else { - please_wait.visible() + binding.pleaseWait.visible() } } @@ -220,9 +222,9 @@ class ReaderActivity : menuVisible = savedInstanceState.getBoolean(::menuVisible.name) } - chapters_bottom_sheet.setup(this) + binding.readerChaptersSheet.chaptersBottomSheet.setup(this) if (ThemeUtil.isBlueTheme(preferences.theme())) { - chapter_recycler.setBackgroundColor(getResourceColor(android.R.attr.colorBackground)) + binding.readerChaptersSheet.chapterRecycler.setBackgroundColor(getResourceColor(android.R.attr.colorBackground)) } config = ReaderConfig() initializeMenu() @@ -234,7 +236,7 @@ class ReaderActivity : override fun onDestroy() { super.onDestroy() viewer?.destroy() - chapters_bottom_sheet.adapter = null + binding.readerChaptersSheet.chaptersBottomSheet.adapter = null viewer = null config = null bottomSheet?.dismiss() @@ -272,7 +274,7 @@ class ReaderActivity : } /** - * Called when the options menu of the toolbar is being created. It adds our custom menu. + * Called when the options menu of the binding.toolbar is being created. It adds our custom menu. */ override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.reader, menu) @@ -289,7 +291,7 @@ class ReaderActivity : R.id.action_display_settings -> TabbedReaderSettingsSheet(this).show() R.id.action_share_page, R.id.action_set_page_as_cover, R.id.action_save_page -> { val currentChapter = presenter.getCurrentChapter() ?: return true - val page = currentChapter.pages?.getOrNull(page_seekbar.progress) ?: return true + val page = currentChapter.pages?.getOrNull(binding.readerChaptersSheet.pageSeekBar.progress) ?: return true when (item.itemId) { R.id.action_share_page -> shareImage(page) R.id.action_set_page_as_cover -> showSetCoverPrompt(page) @@ -319,12 +321,12 @@ class ReaderActivity : } /** - * Called when the user clicks the back key or the button on the toolbar. The call is + * Called when the user clicks the back key or the button on the binding.toolbar. The call is * delegated to the presenter. */ override fun onBackPressed() { - if (chapters_bottom_sheet.sheetBehavior.isExpanded()) { - chapters_bottom_sheet.sheetBehavior?.collapse() + if (binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() return } presenter.onBackPressed() @@ -363,20 +365,20 @@ class ReaderActivity : * Initializes the reader menu. It sets up click listeners and the initial visibility. */ private fun initializeMenu() { - // Set toolbar - setSupportActionBar(toolbar) + // Set binding.toolbar + setSupportActionBar(binding.toolbar) val primaryColor = ColorUtils.setAlphaComponent( getResourceColor(R.attr.colorSecondary), 200 ) - appbar.setBackgroundColor(primaryColor) + binding.appBar.setBackgroundColor(primaryColor) window.statusBarColor = Color.TRANSPARENT supportActionBar?.setDisplayHomeAsUpEnabled(true) - toolbar.setNavigationOnClickListener { + binding.toolbar.setNavigationOnClickListener { popToMain() } - toolbar.setOnClickListener { + binding.toolbar.setOnClickListener { presenter.manga?.id?.let { id -> val intent = SearchActivity.openMangaIntent(this, id) startActivity(intent) @@ -384,7 +386,7 @@ class ReaderActivity : } // Init listeners on bottom menu - page_seekbar.setOnSeekBarChangeListener( + binding.readerChaptersSheet.pageSeekBar.setOnSeekBarChangeListener( object : SimpleSeekBarListener() { override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { if (viewer != null && fromUser) { @@ -396,10 +398,10 @@ class ReaderActivity : // Set initial visibility setMenuVisibility(menuVisible) - chapters_bottom_sheet.sheetBehavior?.isHideable = !menuVisible - if (!menuVisible) chapters_bottom_sheet.sheetBehavior?.hide() - val peek = chapters_bottom_sheet.sheetBehavior?.peekHeight ?: 30.dpToPx - reader_layout.doOnApplyWindowInsets { v, insets, _ -> + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible + if (!menuVisible) binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() + val peek = binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight ?: 30.dpToPx + binding.readerLayout.doOnApplyWindowInsets { v, insets, _ -> sheetManageNavColor = when { insets.isBottomTappable() -> { window.navigationBarColor = Color.TRANSPARENT @@ -415,21 +417,21 @@ class ReaderActivity : } } - appbar.updateLayoutParams { + binding.appBar.updateLayoutParams { leftMargin = insets.systemWindowInsetLeft rightMargin = insets.systemWindowInsetRight } - toolbar.updateLayoutParams { + binding.toolbar.updateLayoutParams { topMargin = insets.systemWindowInsetTop } - chapters_bottom_sheet.updateLayoutParams { + binding.readerChaptersSheet.chaptersBottomSheet.updateLayoutParams { leftMargin = insets.systemWindowInsetLeft rightMargin = insets.systemWindowInsetRight height = 280.dpToPx + insets.systemWindowInsetBottom } - chapters_bottom_sheet.sheetBehavior?.peekHeight = peek + insets.getBottomGestureInsets() - chapter_recycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) - viewer_container.requestLayout() + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.peekHeight = peek + insets.getBottomGestureInsets() + binding.readerChaptersSheet.chapterRecycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom) + binding.viewerContainer.requestLayout() } } @@ -440,16 +442,16 @@ class ReaderActivity : private fun setMenuVisibility(visible: Boolean, animate: Boolean = true) { menuVisible = visible if (visible) coroutine?.cancel() - viewer_container.requestLayout() + binding.viewerContainer.requestLayout() if (visible) { snackbar?.dismiss() systemUi?.show() - reader_menu.visible() + binding.readerMenu.visible() - if (chapters_bottom_sheet.sheetBehavior.isExpanded()) { - chapters_bottom_sheet.sheetBehavior?.isHideable = false + if (binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = false } - if (!chapters_bottom_sheet.sheetBehavior.isExpanded() && sheetManageNavColor) { + if (!binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && sheetManageNavColor) { window.navigationBarColor = Color.TRANSPARENT } if (animate) { @@ -462,9 +464,9 @@ class ReaderActivity : } } ) - appbar.startAnimation(toolbarAnimation) + binding.appBar.startAnimation(toolbarAnimation) } - chapters_bottom_sheet.sheetBehavior?.collapse() + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() } } else { systemUi?.hide() @@ -474,15 +476,15 @@ class ReaderActivity : toolbarAnimation.setAnimationListener( object : SimpleAnimationListener() { override fun onAnimationEnd(animation: Animation) { - reader_menu.gone() + binding.readerMenu.gone() } } ) - appbar.startAnimation(toolbarAnimation) - BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true - chapters_bottom_sheet.sheetBehavior?.hide() + binding.appBar.startAnimation(toolbarAnimation) + BottomSheetBehavior.from(binding.readerChaptersSheet.chaptersBottomSheet).isHideable = true + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() } else { - reader_menu.gone() + binding.readerMenu.gone() } } menuStickyVisible = false @@ -490,7 +492,7 @@ class ReaderActivity : /** * Called from the presenter when a manga is ready. Used to instantiate the appropriate viewer - * and the toolbar title. + * and the binding.toolbar title. */ fun setManga(manga: Manga) { val prevViewer = viewer @@ -506,7 +508,7 @@ class ReaderActivity : } if (noDefault && presenter.manga?.viewer!! > 0) { - snackbar = reader_layout.snack( + snackbar = binding.readerLayout.snack( getString( R.string.reading_, getString( @@ -529,13 +531,13 @@ class ReaderActivity : // Destroy previous viewer if there was one if (prevViewer != null) { prevViewer.destroy() - viewer_container.removeAllViews() + binding.viewerContainer.removeAllViews() } viewer = newViewer - viewer_container.addView(newViewer.getView()) + binding.viewerContainer.addView(newViewer.getView()) - navigation_overlay.isLTR = !(viewer is L2RPagerViewer) - viewer_container.setBackgroundColor( + binding.navigationOverlay.isLTR = !(viewer is L2RPagerViewer) + binding.viewerContainer.setBackgroundColor( if (viewer is WebtoonViewer) { Color.BLACK } else { @@ -543,12 +545,12 @@ class ReaderActivity : } ) - toolbar.title = manga.title + binding.toolbar.title = manga.title - page_seekbar.isRTL = newViewer is R2LPagerViewer + binding.readerChaptersSheet.pageSeekBar.isRTL = newViewer is R2LPagerViewer - please_wait.visible() - please_wait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) + binding.pleaseWait.visible() + binding.pleaseWait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long)) } override fun onPause() { @@ -558,14 +560,14 @@ class ReaderActivity : /** * Called from the presenter whenever a new [viewerChapters] have been set. It delegates the - * method to the current viewer, but also set the subtitle on the toolbar. + * method to the current viewer, but also set the subtitle on the binding.toolbar. */ fun setChapters(viewerChapters: ViewerChapters) { - please_wait.gone() + binding.pleaseWait.gone() viewer?.setChapters(viewerChapters) intentPageNumber?.let { moveToPageIndex(it) } intentPageNumber = null - toolbar.subtitle = viewerChapters.currChapter.chapter.name + binding.toolbar.subtitle = viewerChapters.currChapter.chapter.name } /** @@ -581,7 +583,7 @@ class ReaderActivity : /** * Called from the presenter whenever it's loading the next or previous chapter. It shows or * dismisses a non-cancellable dialog to prevent user interaction according to the value of - * [show]. This is only used when the next/previous buttons on the toolbar are clicked; the + * [show]. This is only used when the next/previous buttons on the binding.toolbar are clicked; the * other cases are handled with chapter transitions on the viewers and chapter preloading. */ @Suppress("DEPRECATION") @@ -606,7 +608,7 @@ class ReaderActivity : } fun refreshChapters() { - chapters_bottom_sheet.refreshList() + binding.readerChaptersSheet.chaptersBottomSheet.refreshList() } /** @@ -619,21 +621,21 @@ class ReaderActivity : val pages = page.chapter.pages ?: return // Set bottom page number - page_number.text = "${page.number}/${pages.size}" + binding.pageNumber.text = "${page.number}/${pages.size}" // Set seekbar page number - page_text.text = "${page.number} / ${pages.size}" + binding.readerChaptersSheet.pageText.text = "${page.number} / ${pages.size}" - if (!newChapter && chapters_bottom_sheet.shouldCollapse && chapters_bottom_sheet.sheetBehavior.isExpanded()) { - chapters_bottom_sheet.sheetBehavior?.collapse() + if (!newChapter && binding.readerChaptersSheet.chaptersBottomSheet.shouldCollapse && binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded()) { + binding.readerChaptersSheet.chaptersBottomSheet.sheetBehavior?.collapse() } - if (chapters_bottom_sheet.selectedChapterId != page.chapter.chapter.id) { - chapters_bottom_sheet.refreshList() + if (binding.readerChaptersSheet.chaptersBottomSheet.selectedChapterId != page.chapter.chapter.id) { + binding.readerChaptersSheet.chaptersBottomSheet.refreshList() } - chapters_bottom_sheet.shouldCollapse = true + binding.readerChaptersSheet.chaptersBottomSheet.shouldCollapse = true // Set seekbar progress - page_seekbar.max = pages.lastIndex - page_seekbar.progress = page.index + binding.readerChaptersSheet.pageSeekBar.max = pages.lastIndex + binding.readerChaptersSheet.pageSeekBar.progress = page.index } /** @@ -763,7 +765,7 @@ class ReaderActivity : } if (sheetManageNavColor) window.navigationBarColor = getResourceColor(R.attr.colorSecondary) - reader_menu.visible() + binding.readerMenu.visible() val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) toolbarAnimation.setAnimationListener( object : SimpleAnimationListener() { @@ -772,7 +774,7 @@ class ReaderActivity : } } ) - appbar.startAnimation(toolbarAnimation) + binding.appBar.startAnimation(toolbarAnimation) } } else { if (menuStickyVisible && !menuVisible) { @@ -922,7 +924,7 @@ class ReaderActivity : * Sets the visibility of the bottom page indicator according to [visible]. */ private fun setPageNumberVisibility(visible: Boolean) { - page_number.visibility = if (visible) View.VISIBLE else View.INVISIBLE + binding.pageNumber.visibility = if (visible) View.VISIBLE else View.INVISIBLE } /** @@ -985,7 +987,7 @@ class ReaderActivity : .onEach { setColorFilterValue(it) } .launchIn(scope) } else { - color_overlay.gone() + binding.colorOverlay.gone() } } @@ -1011,11 +1013,11 @@ class ReaderActivity : // Set black overlay visibility. if (value < 0) { - brightness_overlay.visible() + binding.brightnessOverlay.visible() val alpha = (abs(value) * 2.56).toInt() - brightness_overlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0)) + binding.brightnessOverlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0)) } else { - brightness_overlay.gone() + binding.brightnessOverlay.gone() } } @@ -1023,8 +1025,8 @@ class ReaderActivity : * Sets the color filter [value]. */ private fun setColorFilterValue(value: Int) { - color_overlay.visible() - color_overlay.setFilterColor(value, preferences.colorFilterMode().get()) + binding.colorOverlay.visible() + binding.colorOverlay.setFilterColor(value, preferences.colorFilterMode().get()) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt index 9b4d78ae2a..4f27c53da8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt @@ -14,6 +14,7 @@ import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.fastadapter.listeners.ClickEventHook import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.databinding.ReaderChaptersSheetBinding import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderPresenter import eu.kanade.tachiyomi.util.system.dpToPx @@ -24,7 +25,6 @@ import eu.kanade.tachiyomi.util.view.expand import eu.kanade.tachiyomi.util.view.isExpanded import eu.kanade.tachiyomi.util.view.visInvisIf import eu.kanade.tachiyomi.util.view.visibleIf -import kotlinx.android.synthetic.main.reader_chapters_sheet.view.* import kotlin.math.max import kotlin.math.min import kotlin.math.roundToInt @@ -39,13 +39,20 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr var shouldCollapse = true var selectedChapterId = -1L + lateinit var binding: ReaderChaptersSheetBinding + + override fun onFinishInflate() { + super.onFinishInflate() + binding = ReaderChaptersSheetBinding.bind(this) + } + fun setup(activity: ReaderActivity) { presenter = activity.presenter val fullPrimary = activity.getResourceColor(R.attr.colorSecondary) val primary = ColorUtils.setAlphaComponent(fullPrimary, 200) sheetBehavior = BottomSheetBehavior.from(this) - chapters_button.setOnClickListener { + binding.chaptersButton.setOnClickListener { if (sheetBehavior.isExpanded()) { sheetBehavior?.collapse() } else { @@ -53,28 +60,28 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr } } - webview_button.setOnClickListener { + binding.webviewButton.setOnClickListener { activity.openMangaInBrowser() } post { - chapter_recycler?.alpha = if (sheetBehavior.isExpanded()) 1f else 0f - chapter_recycler?.isClickable = sheetBehavior.isExpanded() - chapter_recycler?.isFocusable = sheetBehavior.isExpanded() + binding.chapterRecycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f + binding.chapterRecycler.isClickable = sheetBehavior.isExpanded() + binding.chapterRecycler.isFocusable = sheetBehavior.isExpanded() } sheetBehavior?.addBottomSheetCallback( object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) { - pill.alpha = (1 - max(0f, progress)) * 0.25f + binding.pill.alpha = (1 - max(0f, progress)) * 0.25f val trueProgress = max(progress, 0f) - chapters_button.alpha = 1 - trueProgress - webview_button.alpha = trueProgress - webview_button.visibleIf(webview_button.alpha > 0) - chapters_button.visInvisIf(chapters_button.alpha > 0) + binding.chaptersButton.alpha = 1 - trueProgress + binding.webviewButton.alpha = trueProgress + binding.webviewButton.visibleIf(binding.webviewButton.alpha > 0) + binding.chaptersButton.visInvisIf(binding.chaptersButton.alpha > 0) backgroundTintList = ColorStateList.valueOf(lerpColor(primary, fullPrimary, trueProgress)) - chapter_recycler.alpha = trueProgress + binding.chapterRecycler.alpha = trueProgress if (activity.sheetManageNavColor && progress > 0f) { activity.window.navigationBarColor = lerpColor(ColorUtils.setAlphaComponent(primary, 0), primary, trueProgress) @@ -85,29 +92,29 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr if (state == BottomSheetBehavior.STATE_COLLAPSED) { shouldCollapse = true sheetBehavior?.isHideable = false - (chapter_recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( + (binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0, - chapter_recycler.height / 2 - 30.dpToPx + binding.chapterRecycler.height / 2 - 30.dpToPx ) - chapters_button.alpha = 1f - webview_button.alpha = 0f + binding.chaptersButton.alpha = 1f + binding.webviewButton.alpha = 0f } if (state == BottomSheetBehavior.STATE_EXPANDED) { - chapter_recycler.alpha = 1f - chapters_button.alpha = 0f - webview_button.alpha = 1f + binding.chapterRecycler.alpha = 1f + binding.chaptersButton.alpha = 0f + binding.webviewButton.alpha = 1f if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary } - chapter_recycler.isClickable = state == BottomSheetBehavior.STATE_EXPANDED - chapter_recycler.isFocusable = state == BottomSheetBehavior.STATE_EXPANDED - webview_button.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) - chapters_button.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) + binding.chapterRecycler.isClickable = state == BottomSheetBehavior.STATE_EXPANDED + binding.chapterRecycler.isFocusable = state == BottomSheetBehavior.STATE_EXPANDED + binding.webviewButton.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) + binding.chaptersButton.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) } } ) adapter = FastAdapter.with(itemAdapter) - chapter_recycler.adapter = adapter + binding.chapterRecycler.adapter = adapter adapter?.onClickListener = { _, _, item, _ -> if (!sheetBehavior.isExpanded()) { false @@ -146,7 +153,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr else fullPrimary ) - chapter_recycler.layoutManager = LinearLayoutManager(context) + binding.chapterRecycler.layoutManager = LinearLayoutManager(context) refreshList() } @@ -158,9 +165,9 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr itemAdapter.clear() itemAdapter.add(chapters) - (chapter_recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( + (binding.chapterRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( adapter?.getPosition(presenter.getCurrentChapter()?.chapter?.id ?: 0L) ?: 0, - chapter_recycler.height / 2 - 30.dpToPx + binding.chapterRecycler.height / 2 - 30.dpToPx ) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt index e4788db572..18decea969 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt @@ -8,10 +8,6 @@ import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visInvisIf import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog -import kotlinx.android.synthetic.main.reader_activity.* -import kotlinx.android.synthetic.main.reader_color_filter.view.* -import kotlinx.android.synthetic.main.recycler_with_scroller.view.* -import kotlinx.android.synthetic.main.tabbed_bottom_sheet.* class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) : TabbedBottomSheetDialog( readerActivity @@ -57,14 +53,14 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) : TabbedBott filterView.activity = readerActivity generalView.sheet = this - menu.gone() + binding.menu.gone() val attrs = window?.attributes val ogDim = attrs?.dimAmount ?: 0.25f - pager.adapter?.notifyDataSetChanged() - tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { + binding.pager.adapter?.notifyDataSetChanged() + binding.tabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab?) { window?.setDimAmount(if (tab?.position == 2) 0f else ogDim) - readerActivity.appbar.visInvisIf(tab?.position != 2) + readerActivity.binding.appBar.visInvisIf(tab?.position != 2) } override fun onTabUnselected(tab: TabLayout.Tab?) { @@ -77,12 +73,12 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) : TabbedBott override fun dismiss() { super.dismiss() - readerActivity.appbar.visible() + readerActivity.binding.appBar.visible() } fun updateTabs(isWebtoon: Boolean) { showWebview = isWebtoon - pager.adapter?.notifyDataSetChanged() + binding.pager.adapter?.notifyDataSetChanged() pagedView.updatePrefs() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt index 2c19dfe107..f9679c5c73 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerViewer.kt @@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.visible -import kotlinx.android.synthetic.main.reader_activity.* import timber.log.Timber /** @@ -107,9 +106,9 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { config.navigationModeChangedListener = { val showOnStart = config.navigationOverlayForNewUser - activity.navigation_overlay.setNavigation(config.navigator, showOnStart) + activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart) } - config.navigationModeInvertedListener = { activity.navigation_overlay.showNavigationAgain() } + config.navigationModeInvertedListener = { activity.binding.navigationOverlay.showNavigationAgain() } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index bb4453e776..f911c8db26 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation import eu.kanade.tachiyomi.util.view.visible -import kotlinx.android.synthetic.main.reader_activity.* import rx.subscriptions.CompositeSubscription import timber.log.Timber import kotlin.math.max @@ -126,9 +125,9 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals config.navigationModeChangedListener = { val showOnStart = config.navigationOverlayForNewUser - activity.navigation_overlay.setNavigation(config.navigator, showOnStart) + activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart) } - config.navigationModeInvertedListener = { activity.navigation_overlay.showNavigationAgain() } + config.navigationModeInvertedListener = { activity.binding.navigationOverlay.showNavigationAgain() } frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) frame.addView(recycler) diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index bb9dadd7f7..7ae06029e2 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -47,7 +47,7 @@ android:visibility="gone" > @@ -61,7 +61,8 @@ - + @@ -38,7 +38,7 @@ android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/next_title" android:padding="@dimen/material_layout_keylines_screen_edge_margin" - android:tint="?actionBarTintColor" + app:tint="?actionBarTintColor" android:tooltipText="@string/view_chapters" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -52,7 +52,7 @@ android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/open_in_webview" android:padding="@dimen/material_layout_keylines_screen_edge_margin" - android:tint="?actionBarTintColor" + app:tint="?actionBarTintColor" android:tooltipText="@string/open_in_webview" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -61,7 +61,7 @@ app:srcCompat="@drawable/ic_open_in_webview_24dp" />