mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Minor code cleanup
This commit is contained in:
		| @@ -91,7 +91,7 @@ class SearchController( | ||||
|                 ) | ||||
|  | ||||
|             return MaterialDialog(activity!!) | ||||
|                 .message(R.string.migration_dialog_what_to_include) | ||||
|                 .title(R.string.migration_dialog_what_to_include) | ||||
|                 .listItemsMultiChoice( | ||||
|                     items = MigrationFlags.titles.map { resources?.getString(it) as CharSequence }, | ||||
|                     initialSelection = preselected.toIntArray() | ||||
|   | ||||
| @@ -10,7 +10,6 @@ import android.view.View | ||||
| import android.view.ViewPropertyAnimator | ||||
| import androidx.core.content.ContextCompat | ||||
| import androidx.core.view.isVisible | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation | ||||
| import kotlin.math.abs | ||||
|  | ||||
| @@ -34,7 +33,7 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) | ||||
|  | ||||
|         viewPropertyAnimator = animate() | ||||
|             .alpha(1f) | ||||
|             .setDuration(1000L) | ||||
|             .setDuration(FADE_DURATION) | ||||
|             .withStartAction { | ||||
|                 isVisible = true | ||||
|             } | ||||
| @@ -44,6 +43,8 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) | ||||
|         viewPropertyAnimator?.start() | ||||
|     } | ||||
|  | ||||
|     private val regionPaint = Paint() | ||||
|  | ||||
|     private val textPaint = Paint().apply { | ||||
|         textAlign = Paint.Align.CENTER | ||||
|         color = Color.WHITE | ||||
| @@ -62,16 +63,14 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) | ||||
|         if (navigation == null) return | ||||
|  | ||||
|         navigation?.regions?.forEach { region -> | ||||
|  | ||||
|             val paint = paintForRegion(region.type) | ||||
|  | ||||
|             val rect = region.rectF | ||||
|  | ||||
|             canvas?.save() | ||||
|  | ||||
|             // Scale rect from 1f,1f to screen width and height | ||||
|             canvas?.scale(width.toFloat(), height.toFloat()) | ||||
|             canvas?.drawRect(rect, paint) | ||||
|             regionPaint.color = ContextCompat.getColor(context, region.type.colorRes) | ||||
|             canvas?.drawRect(rect, regionPaint) | ||||
|  | ||||
|             canvas?.restore() | ||||
|             // Don't want scale anymore because it messes with drawText | ||||
| @@ -86,42 +85,20 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) | ||||
|             // Calculate center of rect height on screen | ||||
|             val y = height * (abs(rect.top - rect.bottom) / 2) | ||||
|  | ||||
|             canvas?.drawText(region.type.name, x, y, textBorderPaint) | ||||
|             canvas?.drawText(region.type.name, x, y, textPaint) | ||||
|             canvas?.drawText(context.getString(region.type.nameRes), x, y, textBorderPaint) | ||||
|             canvas?.drawText(context.getString(region.type.nameRes), x, y, textPaint) | ||||
|  | ||||
|             canvas?.restore() | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun paintForRegion(type: ViewerNavigation.NavigationRegion): Paint { | ||||
|         return Paint().apply { | ||||
|             when (type) { | ||||
|                 ViewerNavigation.NavigationRegion.NEXT -> { | ||||
|                     color = ContextCompat.getColor(context, R.color.navigation_next) | ||||
|                 } | ||||
|                 ViewerNavigation.NavigationRegion.PREV -> { | ||||
|                     color = ContextCompat.getColor(context, R.color.navigation_prev) | ||||
|                 } | ||||
|                 ViewerNavigation.NavigationRegion.MENU -> { | ||||
|                     color = ContextCompat.getColor(context, R.color.navigation_menu) | ||||
|                 } | ||||
|                 ViewerNavigation.NavigationRegion.RIGHT -> { | ||||
|                     color = ContextCompat.getColor(context, R.color.navigation_right) | ||||
|                 } | ||||
|                 ViewerNavigation.NavigationRegion.LEFT -> { | ||||
|                     color = ContextCompat.getColor(context, R.color.navigation_left) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun performClick(): Boolean { | ||||
|         super.performClick() | ||||
|  | ||||
|         if (viewPropertyAnimator == null && isVisible) { | ||||
|             viewPropertyAnimator = animate() | ||||
|                 .alpha(0f) | ||||
|                 .setDuration(1000L) | ||||
|                 .setDuration(FADE_DURATION) | ||||
|                 .withEndAction { | ||||
|                     isVisible = false | ||||
|                     viewPropertyAnimator = null | ||||
| @@ -138,3 +115,5 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) | ||||
|         return super.onTouchEvent(event) | ||||
|     } | ||||
| } | ||||
|  | ||||
| private const val FADE_DURATION = 1000L | ||||
|   | ||||
| @@ -2,13 +2,19 @@ package eu.kanade.tachiyomi.ui.reader.viewer | ||||
|  | ||||
| import android.graphics.PointF | ||||
| import android.graphics.RectF | ||||
| import androidx.annotation.StringRes | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.preference.PreferenceValues | ||||
| import eu.kanade.tachiyomi.util.lang.invert | ||||
|  | ||||
| abstract class ViewerNavigation { | ||||
|  | ||||
|     enum class NavigationRegion { | ||||
|         NEXT, PREV, MENU, RIGHT, LEFT | ||||
|     sealed class NavigationRegion(@StringRes val nameRes: Int, val colorRes: Int) { | ||||
|         object MENU : NavigationRegion(R.string.action_menu, R.color.navigation_menu) | ||||
|         object PREV : NavigationRegion(R.string.nav_zone_prev, R.color.navigation_prev) | ||||
|         object NEXT : NavigationRegion(R.string.nav_zone_next, R.color.navigation_next) | ||||
|         object LEFT : NavigationRegion(R.string.nav_zone_left, R.color.navigation_left) | ||||
|         object RIGHT : NavigationRegion(R.string.nav_zone_right, R.color.navigation_right) | ||||
|     } | ||||
|  | ||||
|     data class Region( | ||||
|   | ||||
| @@ -253,7 +253,7 @@ | ||||
|       <!-- Reader section --> | ||||
|     <string name="pref_fullscreen">Fullscreen</string> | ||||
|     <string name="pref_show_navigation_mode">Show navigation layout overlay</string> | ||||
|     <string name="pref_show_navigation_mode_summary">Show overlay when reader is opened</string> | ||||
|     <string name="pref_show_navigation_mode_summary">Briefly show tap zones when reader is opened</string> | ||||
|     <string name="pref_dual_page_split">Dual page split (ALPHA)</string> | ||||
|     <string name="pref_dual_page_invert">Invert dual page split placement</string> | ||||
|     <string name="pref_dual_page_invert_summary">If the placement of the dual page split doesn\'t match reading direction</string> | ||||
| @@ -300,6 +300,10 @@ | ||||
|     <string name="kindlish_nav">Kindle-ish</string> | ||||
|     <string name="edge_nav">Edge</string> | ||||
|     <string name="right_and_left_nav">Right and Left</string> | ||||
|     <string name="nav_zone_prev">Prev</string> | ||||
|     <string name="nav_zone_next">Next</string> | ||||
|     <string name="nav_zone_left">Left</string> | ||||
|     <string name="nav_zone_right">Right</string> | ||||
|     <string name="left_to_right_viewer">Left to right</string> | ||||
|     <string name="right_to_left_viewer">Right to left</string> | ||||
|     <string name="vertical_viewer">Vertical</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user