diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3d1bfe84c..96e5a4258 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -72,8 +72,8 @@ android { "de", "th", "tr", - "nb-rNO" - ) + "nb-rNO", + ), ) buildConfigField("String", "COMMIT_SHA", "\"$commitSha\"") buildConfigField("String", "BUILD_TIME", "\"$buildTime\"") @@ -124,7 +124,6 @@ android { excludes += "**.txt" excludes += "**.bin" } - } dependenciesInfo.includeInApk = false diff --git a/app/src/main/java/androidx/navigation/ui/NavigationUI.kt b/app/src/main/java/androidx/navigation/ui/NavigationUI.kt index 1a0505500..8ff28ed9d 100644 --- a/app/src/main/java/androidx/navigation/ui/NavigationUI.kt +++ b/app/src/main/java/androidx/navigation/ui/NavigationUI.kt @@ -13,7 +13,7 @@ fun onNavDestinationSelected2(item: MenuItem, navController: NavController): Boo val builder = NavOptions.Builder().setLaunchSingleTop(true) if ( navController.currentDestination!!.parent!!.findNode(item.itemId) - is ActivityNavigator.Destination + is ActivityNavigator.Destination ) { builder.setEnterAnim(R.anim.nav_default_enter_anim) .setExitAnim(R.anim.nav_default_exit_anim) @@ -37,4 +37,4 @@ fun onNavDestinationSelected2(item: MenuItem, navController: NavController): Boo } fun NavDestination.matchDestination(@IdRes destId: Int): Boolean = - hierarchy.any { it.id == destId } \ No newline at end of file + hierarchy.any { it.id == destId } diff --git a/app/src/main/java/androidx/swiperefreshlayout/widget/ThemedSwipeRefreshLayout.kt b/app/src/main/java/androidx/swiperefreshlayout/widget/ThemedSwipeRefreshLayout.kt index a9407e62f..32b64074a 100644 --- a/app/src/main/java/androidx/swiperefreshlayout/widget/ThemedSwipeRefreshLayout.kt +++ b/app/src/main/java/androidx/swiperefreshlayout/widget/ThemedSwipeRefreshLayout.kt @@ -7,10 +7,10 @@ import android.util.AttributeSet import androidx.core.graphics.ColorUtils import rikka.core.res.resolveColor - @SuppressLint("PrivateResource") class ThemedSwipeRefreshLayout @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : SwipeRefreshLayout(context, attrs) { init { @@ -22,4 +22,4 @@ class ThemedSwipeRefreshLayout @JvmOverloads constructor( (mCircleView.background as ShapeDrawable).paint.color = backgroundColor setColorSchemeColors(context.theme.resolveColor(com.google.android.material.R.attr.colorAccent)) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.kt b/app/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.kt index 2f546b472..23baa23f4 100644 --- a/app/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.kt +++ b/app/src/main/java/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.kt @@ -62,7 +62,7 @@ import kotlin.math.sqrt @Suppress("unused") open class SubsamplingScaleImageView @JvmOverloads constructor( context: Context, - attr: AttributeSet? = null + attr: AttributeSet? = null, ) : View(context, attr) { private val decoderLock: ReadWriteLock = ReentrantReadWriteLock(true) @@ -78,7 +78,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( private val srcArray = FloatArray(8) private val dstArray = FloatArray(8) - //The logical density of the display + // The logical density of the display private val density: Float = resources.displayMetrics.density // Bitmap (preview or full image) @@ -139,6 +139,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( // Double tap zoom behaviour private var doubleTapZoomScale = 1F + @ZoomStyle private var doubleTapZoomStyle = ZOOM_FOCUS_FIXED private var doubleTapZoomDuration = 500 @@ -331,8 +332,9 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( imageSource.sRegion.left, imageSource.sRegion.top, imageSource.sRegion.width(), - imageSource.sRegion.height() - ), false + imageSource.sRegion.height(), + ), + false, ) } else if (imageSource.bitmap != null) { onImageLoaded(imageSource.bitmap, imageSource.isCached) @@ -436,64 +438,70 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( } private fun setGestureDetector(context: Context) { - detector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() { - override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { - if (panEnabled && isReady && vTranslate != null && (abs(e1.x - e2.x) > 50 || abs(e1.y - e2.y) > 50) && (abs(velocityX) > 500 || abs(velocityY) > 500) && !isZooming) { - val vTranslateEnd = PointF(vTranslate!!.x + velocityX * 0.25F, vTranslate!!.y + velocityY * 0.25F) - val sCenterXEnd = (width / 2 - vTranslateEnd.x) / scale - val sCenterYEnd = (height / 2 - vTranslateEnd.y) / scale - AnimationBuilder(PointF(sCenterXEnd, sCenterYEnd)) - .withEasing(EASE_OUT_QUAD) - .withPanLimited(false) - .withOrigin(ORIGIN_FLING) - .start() + detector = GestureDetector( + context, + object : GestureDetector.SimpleOnGestureListener() { + override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { + if (panEnabled && isReady && vTranslate != null && (abs(e1.x - e2.x) > 50 || abs(e1.y - e2.y) > 50) && (abs(velocityX) > 500 || abs(velocityY) > 500) && !isZooming) { + val vTranslateEnd = PointF(vTranslate!!.x + velocityX * 0.25F, vTranslate!!.y + velocityY * 0.25F) + val sCenterXEnd = (width / 2 - vTranslateEnd.x) / scale + val sCenterYEnd = (height / 2 - vTranslateEnd.y) / scale + AnimationBuilder(PointF(sCenterXEnd, sCenterYEnd)) + .withEasing(EASE_OUT_QUAD) + .withPanLimited(false) + .withOrigin(ORIGIN_FLING) + .start() + return true + } + return super.onFling(e1, e2, velocityX, velocityY) + } + + override fun onSingleTapConfirmed(e: MotionEvent): Boolean { + performClick() return true } - return super.onFling(e1, e2, velocityX, velocityY) - } - override fun onSingleTapConfirmed(e: MotionEvent): Boolean { - performClick() - return true - } - - override fun onDoubleTap(e: MotionEvent): Boolean { - if (isZoomEnabled && isReady && vTranslate != null) { - // Hacky solution for #15 - after a double tap the GestureDetector gets in a state - // where the next fling is ignored, so here we replace it with a new one. - setGestureDetector(context) - return if (isQuickScaleEnabled) { - // Store quick scale params. This will become either a double tap zoom or a - // quick scale depending on whether the user swipes. - vCenterStart = PointF(e.x, e.y) - vTranslateStart = PointF(vTranslate!!.x, vTranslate!!.y) - scaleStart = scale - isQuickScaling = true - isZooming = true - quickScaleLastDistance = -1F - quickScaleSCenter = viewToSourceCoord(vCenterStart!!) - quickScaleVStart = PointF(e.x, e.y) - quickScaleVLastPoint = PointF(quickScaleSCenter!!.x, quickScaleSCenter!!.y) - quickScaleMoved = false - // We need to get events in onTouchEvent after this. - false - } else { - // Start double tap zoom animation. - viewToSourceCoord(PointF(e.x, e.y))?.let { center -> - doubleTapZoom(center, PointF(e.x, e.y)) + override fun onDoubleTap(e: MotionEvent): Boolean { + if (isZoomEnabled && isReady && vTranslate != null) { + // Hacky solution for #15 - after a double tap the GestureDetector gets in a state + // where the next fling is ignored, so here we replace it with a new one. + setGestureDetector(context) + return if (isQuickScaleEnabled) { + // Store quick scale params. This will become either a double tap zoom or a + // quick scale depending on whether the user swipes. + vCenterStart = PointF(e.x, e.y) + vTranslateStart = PointF(vTranslate!!.x, vTranslate!!.y) + scaleStart = scale + isQuickScaling = true + isZooming = true + quickScaleLastDistance = -1F + quickScaleSCenter = viewToSourceCoord(vCenterStart!!) + quickScaleVStart = PointF(e.x, e.y) + quickScaleVLastPoint = PointF(quickScaleSCenter!!.x, quickScaleSCenter!!.y) + quickScaleMoved = false + // We need to get events in onTouchEvent after this. + false + } else { + // Start double tap zoom animation. + viewToSourceCoord(PointF(e.x, e.y))?.let { center -> + doubleTapZoom(center, PointF(e.x, e.y)) + } + true } - true } + return super.onDoubleTapEvent(e) } - return super.onDoubleTapEvent(e) - } - }) - singleDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() { - override fun onSingleTapConfirmed(e: MotionEvent): Boolean { - performClick() - return true - } - }) + }, + ) + singleDetector = GestureDetector( + context, + object : GestureDetector.SimpleOnGestureListener() { + override fun onSingleTapConfirmed(e: MotionEvent): Boolean { + performClick() + return true + } + }, + ) } override fun onDetachedFromWindow() { @@ -730,7 +738,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( val dx = abs(event.x - vCenterStart!!.x) val dy = abs(event.y - vCenterStart!!.y) - //On the Samsung S6 long click event does not work, because the dx > 5 usually true + // On the Samsung S6 long click event does not work, because the dx > 5 usually true val offset = density * 5 if (dx > offset || dy > offset || isPanning) { consumed = true @@ -894,7 +902,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( scaleElapsed, anim!!.scaleStart, anim!!.scaleEnd - anim!!.scaleStart, - anim!!.duration + anim!!.duration, ) // Apply required animation to the focal point @@ -903,14 +911,14 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( scaleElapsed, anim!!.vFocusStart!!.x, anim!!.vFocusEnd.x - anim!!.vFocusStart!!.x, - anim!!.duration + anim!!.duration, ) val vFocusNowY = ease( anim!!.easing, scaleElapsed, anim!!.vFocusStart!!.y, anim!!.vFocusEnd.y - anim!!.vFocusStart!!.y, - anim!!.duration + anim!!.duration, ) // Find out where the focal point is at this scale and adjust its position to follow the animation path vTranslate!!.x -= sourceToViewX(anim!!.sCenterEnd.x) - vFocusNowX @@ -967,7 +975,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( tileWidth, tileHeight, 0F, - tileHeight + tileHeight, ) setMatrixArray( dstArray, @@ -978,7 +986,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( tile.vRect.right.toFloat(), tile.vRect.bottom.toFloat(), tile.vRect.left.toFloat(), - tile.vRect.bottom.toFloat() + tile.vRect.bottom.toFloat(), ) mtrx.setPolyToPoly(srcArray, 0, dstArray, 0, 4) canvas.drawBitmap(tile.bitmap!!, mtrx, bitmapPaint) @@ -990,7 +998,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( "LOADING", (tile.vRect.left + px(5)).toFloat(), (tile.vRect.top + px(35)).toFloat(), - debugTextPaint + debugTextPaint, ) } if (tile.visible && debug) { @@ -998,7 +1006,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( "ISS " + tile.sampleSize + " RECT " + tile.sRect.top + "," + tile.sRect.left + "," + tile.sRect.bottom + "," + tile.sRect.right, (tile.vRect.left + px(5)).toFloat(), (tile.vRect.top + px(15)).toFloat(), - debugTextPaint + debugTextPaint, ) } } @@ -1023,21 +1031,36 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( "Scale: " + String.format(Locale.ENGLISH, "%.2f", scale) + " (" + String.format( Locale.ENGLISH, "%.2f", - minScale() + minScale(), ) + " - " + String.format( - Locale.ENGLISH, "%.2f", maxScale - ) + ")", px(5).toFloat(), px(15).toFloat(), debugTextPaint + Locale.ENGLISH, + "%.2f", + maxScale, + ) + ")", + px(5).toFloat(), + px(15).toFloat(), + debugTextPaint, ) canvas.drawText( "Translate: " + String.format(Locale.ENGLISH, "%.2f", vTranslate!!.x) + ":" + String.format( - Locale.ENGLISH, "%.2f", vTranslate!!.y - ), px(5).toFloat(), px(30).toFloat(), debugTextPaint + Locale.ENGLISH, + "%.2f", + vTranslate!!.y, + ), + px(5).toFloat(), + px(30).toFloat(), + debugTextPaint, ) val center = center canvas.drawText( "Source center: " + String.format(Locale.ENGLISH, "%.2f", center!!.x) + ":" + String.format( - Locale.ENGLISH, "%.2f", center.y - ), px(5).toFloat(), px(45).toFloat(), debugTextPaint + Locale.ENGLISH, + "%.2f", + center.y, + ), + px(5).toFloat(), + px(45).toFloat(), + debugTextPaint, ) if (anim != null) { val vCenterStart = sourceToViewCoord(anim!!.sCenterStart) @@ -1061,7 +1084,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( sourceToViewX(quickScaleSCenter!!.x), sourceToViewY(quickScaleSCenter!!.y), px(35).toFloat(), - debugLinePaint + debugLinePaint, ) } if (quickScaleVStart != null && isQuickScaling) { @@ -1084,7 +1107,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( f4: Float, f5: Float, f6: Float, - f7: Float + f7: Float, ) { array[0] = f0 array[1] = f1 @@ -1158,7 +1181,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( debug( "loadTile, tile.sRect=%s, tile.sampleSize=%d", tile.sRect, - tile.sampleSize + tile.sampleSize, ) decoderLock.readLock().lock() try { @@ -1429,13 +1452,13 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( x * sTileWidth, y * sTileHeight, if (x == xTiles - 1) sWidth else (x + 1) * sTileWidth, - if (y == yTiles - 1) sHeight else (y + 1) * sTileHeight + if (y == yTiles - 1) sHeight else (y + 1) * sTileHeight, ) val tile = Tile( sRect = sRect, sampleSize = sampleSize, vRect = Rect(0, 0, 0, 0), - fileSRect = Rect(sRect) + fileSRect = Rect(sRect), ) tileGrid.add(tile) } @@ -1564,7 +1587,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( private fun getMaxBitmapDimensions(canvas: Canvas): Point { return Point( canvas.maximumBitmapWidth.coerceAtMost(maxTileWidth), - canvas.maximumBitmapHeight.coerceAtMost(maxTileHeight) + canvas.maximumBitmapHeight.coerceAtMost(maxTileHeight), ) } @@ -1629,15 +1652,15 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( if (vTranslate == null || !isReady) return fRect[ - viewToSourceX(vRect.left.toFloat()).toInt(), - viewToSourceY(vRect.top.toFloat()).toInt(), - viewToSourceX(vRect.right.toFloat()).toInt() + viewToSourceX(vRect.left.toFloat()).toInt(), + viewToSourceY(vRect.top.toFloat()).toInt(), + viewToSourceX(vRect.right.toFloat()).toInt(), ] = viewToSourceY(vRect.bottom.toFloat()).toInt() fileSRect(fRect, fRect) fRect[ - fRect.left.coerceAtLeast(0), - fRect.top.coerceAtLeast(0), - fRect.right.coerceAtLeast(sWidth) + fRect.left.coerceAtLeast(0), + fRect.top.coerceAtLeast(0), + fRect.right.coerceAtLeast(sWidth), ] = fRect.bottom.coerceAtLeast(sHeight) if (!sRegion.isEmpty) { fRect.offset(sRegion.left, sRegion.top) @@ -1754,9 +1777,9 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( */ private fun sourceToViewRect(sRect: Rect, vTarget: Rect) { vTarget[ - sourceToViewX(sRect.left.toFloat()).toInt(), - sourceToViewY(sRect.top.toFloat()).toInt(), - sourceToViewX(sRect.right.toFloat()).toInt() + sourceToViewX(sRect.left.toFloat()).toInt(), + sourceToViewY(sRect.top.toFloat()).toInt(), + sourceToViewX(sRect.right.toFloat()).toInt(), ] = sourceToViewY(sRect.bottom.toFloat()).toInt() } @@ -1803,11 +1826,11 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( return when (minimumScaleType) { SCALE_TYPE_CENTER_INSIDE -> min( (width - hPadding) / sWidth.toFloat(), - (height - vPadding) / sHeight.toFloat() + (height - vPadding) / sHeight.toFloat(), ) SCALE_TYPE_CENTER_CROP -> max( (width - hPadding) / sWidth.toFloat(), - (height - vPadding) / sHeight.toFloat() + (height - vPadding) / sHeight.toFloat(), ) SCALE_TYPE_FIT_WIDTH -> (width - hPadding) / sWidth.toFloat() SCALE_TYPE_FIT_HEIGHT -> (height - vPadding) / sHeight.toFloat() @@ -2111,7 +2134,9 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( val state: ImageViewState? get() = if (vTranslate != null && sWidth > 0 && sHeight > 0) { ImageViewState(scale, center!!) - } else null + } else { + null + } /** * Returns true if pan gesture detection is enabled. @@ -2397,7 +2422,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( val sRect: Rect, val sampleSize: Int, val vRect: Rect, - val fileSRect: Rect + val fileSRect: Rect, ) { var bitmap: Bitmap? = null var loading = false @@ -2432,7 +2457,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( val easing: Int, val origin: Int, val time: Long = System.currentTimeMillis(), - val listener: OnAnimationEventListener? + val listener: OnAnimationEventListener?, ) private data class ScaleAndTranslate(var scale: Float, val vTranslate: PointF) @@ -2578,12 +2603,16 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( val vxCenter = paddingLeft + (width - paddingRight - paddingLeft) / 2 val vyCenter = paddingTop + (height - paddingBottom - paddingTop) / 2 val targetScale = limitedScale(targetScale) - val targetSCenter = if (panLimited) limitedSCenter( - targetSCenter!!.x, - targetSCenter.y, - targetScale, - PointF() - ) else targetSCenter!! + val targetSCenter = if (panLimited) { + limitedSCenter( + targetSCenter!!.x, + targetSCenter.y, + targetScale, + PointF(), + ) + } else { + targetSCenter!! + } anim = Anim( scaleStart = scale, scaleEnd = targetScale, @@ -2593,13 +2622,13 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( vFocusStart = sourceToViewCoord(targetSCenter), vFocusEnd = PointF( vxCenter.toFloat(), - vyCenter.toFloat() + vyCenter.toFloat(), ), duration = duration, interruptible = interruptible, easing = easing, origin = origin, - listener = listener + listener = listener, ) if (vFocus != null) { // Calculate where translation will be at the end of the anim @@ -2611,7 +2640,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( // Adjust the position of the focus point at end so image will be in bounds anim!!.vFocusEnd.set( vFocus.x + (satEnd.vTranslate.x - vTranslateXEnd), - vFocus.y + (satEnd.vTranslate.y - vTranslateYEnd) + vFocus.y + (satEnd.vTranslate.y - vTranslateYEnd), ) } invalidate() @@ -2623,7 +2652,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( @IntDef( ZOOM_FOCUS_FIXED, ZOOM_FOCUS_CENTER, - ZOOM_FOCUS_CENTER_IMMEDIATE + ZOOM_FOCUS_CENTER_IMMEDIATE, ) annotation class ZoomStyle @@ -2645,7 +2674,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( @Retention(AnnotationRetention.SOURCE) @IntDef( EASE_IN_OUT_QUAD, - EASE_OUT_QUAD + EASE_OUT_QUAD, ) annotation class EasingStyle @@ -2663,7 +2692,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( @IntDef( PAN_LIMIT_INSIDE, PAN_LIMIT_OUTSIDE, - PAN_LIMIT_CENTER + PAN_LIMIT_CENTER, ) annotation class PanLimit @@ -2690,7 +2719,7 @@ open class SubsamplingScaleImageView @JvmOverloads constructor( SCALE_TYPE_FIT_HEIGHT, SCALE_TYPE_ORIGINAL_SIZE, SCALE_TYPE_SMART_FIT, - SCALE_TYPE_CUSTOM + SCALE_TYPE_CUSTOM, ) annotation class ScaleType diff --git a/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/Decoder.kt b/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/Decoder.kt index 97122c689..419021469 100644 --- a/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/Decoder.kt +++ b/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/Decoder.kt @@ -4,9 +4,9 @@ import android.content.Context import android.graphics.Bitmap import android.graphics.Point import android.graphics.Rect -import kotlin.Throws import com.davemorrissey.labs.subscaleview.provider.InputProvider import java.lang.Exception +import kotlin.Throws /** * Interface for image decoding classes. @@ -50,4 +50,4 @@ interface Decoder { * resources still in use. */ fun recycle() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/ImageDecoder.kt b/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/ImageDecoder.kt index d7d0cd788..7016d7a0d 100644 --- a/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/ImageDecoder.kt +++ b/app/src/main/java/com/davemorrissey/labs/subscaleview/decoder/ImageDecoder.kt @@ -9,7 +9,7 @@ import com.davemorrissey.labs.subscaleview.provider.InputProvider class ImageDecoder @JvmOverloads constructor( private val cropBorders: Boolean, - bitmapConfig: Bitmap.Config? = null + bitmapConfig: Bitmap.Config? = null, ) : Decoder { init { val globalBitmapConfig = SubsamplingScaleImageView.preferredBitmapConfig @@ -59,4 +59,4 @@ class ImageDecoder @JvmOverloads constructor( override fun recycle() { TODO() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/app/BaseDialogBuilder.kt b/app/src/main/java/com/hippo/app/BaseDialogBuilder.kt index 8acd2da4a..e0b442862 100644 --- a/app/src/main/java/com/hippo/app/BaseDialogBuilder.kt +++ b/app/src/main/java/com/hippo/app/BaseDialogBuilder.kt @@ -4,5 +4,5 @@ import android.content.Context import com.google.android.material.dialog.MaterialAlertDialogBuilder open class BaseDialogBuilder constructor( - context: Context + context: Context, ) : MaterialAlertDialogBuilder(context) diff --git a/app/src/main/java/com/hippo/app/CheckBoxDialogBuilder.kt b/app/src/main/java/com/hippo/app/CheckBoxDialogBuilder.kt index bdefecc37..b35d9778e 100644 --- a/app/src/main/java/com/hippo/app/CheckBoxDialogBuilder.kt +++ b/app/src/main/java/com/hippo/app/CheckBoxDialogBuilder.kt @@ -24,9 +24,9 @@ class CheckBoxDialogBuilder constructor( context: Context, message: String?, checkText: String?, - checked: Boolean + checked: Boolean, ) : BaseDialogBuilder( - context + context, ) { private val mCheckBox: CheckBox val isChecked: Boolean @@ -41,4 +41,4 @@ class CheckBoxDialogBuilder constructor( mCheckBox.isChecked = checked view.setOnClickListener { mCheckBox.toggle() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt b/app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt index 267f9cb7c..d616b7036 100644 --- a/app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt +++ b/app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt @@ -29,10 +29,11 @@ import com.hippo.ehviewer.R class EditTextDialogBuilder constructor( context: Context, text: String?, - hint: String? + hint: String?, ) : BaseDialogBuilder( - context -), OnEditorActionListener { + context, +), + OnEditorActionListener { private val mTextInputLayout: TextInputLayout val editText: EditText private var mDialog: AlertDialog? = null @@ -68,4 +69,4 @@ class EditTextDialogBuilder constructor( editText.setOnEditorActionListener(this) mTextInputLayout.hint = hint } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/app/HapticSlider.kt b/app/src/main/java/com/hippo/app/HapticSlider.kt index 7080f32d8..73d7424b6 100644 --- a/app/src/main/java/com/hippo/app/HapticSlider.kt +++ b/app/src/main/java/com/hippo/app/HapticSlider.kt @@ -6,9 +6,10 @@ import android.view.HapticFeedbackConstants import com.google.android.material.slider.Slider class HapticSlider @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : Slider(context, attrs) { init { addOnChangeListener { _, _, _ -> performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/app/ListCheckBoxDialogBuilder.kt b/app/src/main/java/com/hippo/app/ListCheckBoxDialogBuilder.kt index d691d51a2..5f18268f4 100644 --- a/app/src/main/java/com/hippo/app/ListCheckBoxDialogBuilder.kt +++ b/app/src/main/java/com/hippo/app/ListCheckBoxDialogBuilder.kt @@ -31,9 +31,9 @@ class ListCheckBoxDialogBuilder( items: List, listener: (ListCheckBoxDialogBuilder?, AlertDialog?, Int) -> Unit, checkText: String?, - checked: Boolean + checked: Boolean, ) : BaseDialogBuilder( - context + context, ) { private val mCheckBox: CheckBox private var mDialog: AlertDialog? = null @@ -60,4 +60,4 @@ class ListCheckBoxDialogBuilder( mCheckBox.text = checkText mCheckBox.isChecked = checked } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/database/MSQLiteBuilder.kt b/app/src/main/java/com/hippo/database/MSQLiteBuilder.kt index 00dcb01cb..34f701a4a 100644 --- a/app/src/main/java/com/hippo/database/MSQLiteBuilder.kt +++ b/app/src/main/java/com/hippo/database/MSQLiteBuilder.kt @@ -54,25 +54,25 @@ class MSQLiteBuilder { */ fun version(version: Int): MSQLiteBuilder { check(version > this.version) { - ("New version must be bigger than current version. " - + "current version: " + this.version + ", new version: " + version + ".") + ( + "New version must be bigger than current version. " + + "current version: " + this.version + ", new version: " + version + "." + ) } this.version = version statements = ArrayList() statementsMap.put(version, statements) return this } + /** * Creates a table. */ - /** - * Creates a table with int [.COLUMN_ID] primary key. - */ @JvmOverloads fun createTable( table: String, column: String = COLUMN_ID, - clazz: Class<*>? = Int::class.javaPrimitiveType + clazz: Class<*>? = Int::class.javaPrimitiveType, ): MSQLiteBuilder { return statement("CREATE TABLE " + table + " (" + column + " " + javaTypeToSQLiteType(clazz) + " PRIMARY KEY);") } @@ -90,8 +90,8 @@ class MSQLiteBuilder { fun insertColumn(table: String, column: String, clazz: Class<*>?): MSQLiteBuilder { return statement( "ALTER TABLE $table ADD COLUMN $column " + javaTypeToSQLiteType( - clazz - ) + ";" + clazz, + ) + ";", ) } @@ -121,4 +121,4 @@ class MSQLiteBuilder { } return result } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/database/MSQLiteOpenHelper.kt b/app/src/main/java/com/hippo/database/MSQLiteOpenHelper.kt index a410b362c..c2fea6c8f 100644 --- a/app/src/main/java/com/hippo/database/MSQLiteOpenHelper.kt +++ b/app/src/main/java/com/hippo/database/MSQLiteOpenHelper.kt @@ -24,7 +24,7 @@ internal class MSQLiteOpenHelper( context: Context?, name: String?, private val version: Int, - private val builder: MSQLiteBuilder + private val builder: MSQLiteBuilder, ) : SQLiteOpenHelper(context, name, null, version) { override fun onCreate(db: SQLiteDatabase) { onUpgrade(db, 0, version) @@ -40,4 +40,4 @@ internal class MSQLiteOpenHelper( SqlUtils.dropAllTable(db) onCreate(db) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt b/app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt index d5f4bdfdb..fc037ffa3 100644 --- a/app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt +++ b/app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt @@ -30,7 +30,7 @@ class PreciselyClipDrawable( offsetX: Int, offsetY: Int, width: Int, - height: Int + height: Int, ) : DrawableWrapper(drawable) { private val mScale: RectF private val mTemp = Rect() diff --git a/app/src/main/java/com/hippo/drawable/UnikeryDrawable.kt b/app/src/main/java/com/hippo/drawable/UnikeryDrawable.kt index 7f105a4e7..4ceed5d38 100644 --- a/app/src/main/java/com/hippo/drawable/UnikeryDrawable.kt +++ b/app/src/main/java/com/hippo/drawable/UnikeryDrawable.kt @@ -22,7 +22,8 @@ import coil.request.ImageRequest import com.hippo.ehviewer.coil.imageRequest import com.hippo.widget.ObservedTextView -class UnikeryDrawable(private val mTextView: ObservedTextView, url: String) : WrapDrawable(), +class UnikeryDrawable(private val mTextView: ObservedTextView, url: String) : + WrapDrawable(), ObservedTextView.OnWindowAttachListener { private val mImageRequest: ImageRequest @@ -78,4 +79,4 @@ class UnikeryDrawable(private val mTextView: ObservedTextView, url: String) : Wr drawable.start() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/Crash.kt b/app/src/main/java/com/hippo/ehviewer/Crash.kt index 2c159f669..972bbe3a7 100644 --- a/app/src/main/java/com/hippo/ehviewer/Crash.kt +++ b/app/src/main/java/com/hippo/ehviewer/Crash.kt @@ -73,7 +73,7 @@ object Crash { fw.write("${collectClassStaticInfo(Build.VERSION::class.java)}\r\n") fw.write("MEMORY=") fw.write( - FileUtils.humanReadableByteCount(OSUtils.getAppAllocatedMemory(), false) + FileUtils.humanReadableByteCount(OSUtils.getAppAllocatedMemory(), false), ) fw.write("\r\n") fw.write("MEMORY_NATIVE=") @@ -121,4 +121,4 @@ object Crash { IOUtils.closeQuietly(fw) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt index fcac3f1c6..27fc8a132 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhApplication.kt +++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.kt @@ -168,8 +168,9 @@ class EhApplication : Application(), DefaultLifecycleObserver, ImageLoaderFactor } override fun onPause(owner: LifecycleOwner) { - if (!locked) + if (!locked) { locked_last_leave_time = System.currentTimeMillis() / 1000 + } locked = true } @@ -216,8 +217,8 @@ class EhApplication : Application(), DefaultLifecycleObserver, ImageLoaderFactor Cache( application.cacheDir.toOkioPath() / "http_cache", 20L * 1024L * 1024L, - FileSystem.SYSTEM - ) + FileSystem.SYSTEM, + ), ).build() } diff --git a/app/src/main/java/com/hippo/ehviewer/EhDB.kt b/app/src/main/java/com/hippo/ehviewer/EhDB.kt index f3603caa2..5b26f4286 100644 --- a/app/src/main/java/com/hippo/ehviewer/EhDB.kt +++ b/app/src/main/java/com/hippo/ehviewer/EhDB.kt @@ -459,4 +459,4 @@ object EhDB { } return null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/Settings.kt b/app/src/main/java/com/hippo/ehviewer/Settings.kt index 0bdbed5ec..83472f787 100755 --- a/app/src/main/java/com/hippo/ehviewer/Settings.kt +++ b/app/src/main/java/com/hippo/ehviewer/Settings.kt @@ -62,7 +62,7 @@ object Settings { KEY_SHOW_JPN_TITLE, KEY_REQUEST_NEWS, KEY_REQUEST_NEWS_TIMER, - KEY_HIDE_HV_EVENTS + KEY_HIDE_HV_EVENTS, ) /******************** @@ -275,8 +275,10 @@ object Settings { private fun putStringToStringSet(key: String, value: String) { var set = getStringSet(key) - if (set == null) set = - mutableSetOf(value) else if (set.contains(value)) return else set.add(value) + if (set == null) { + set = + mutableSetOf(value) + } else if (set.contains(value)) return else set.add(value) sSettingsPre.edit().putStringSet(key, set).apply() } @@ -284,7 +286,7 @@ object Settings { return try { NumberUtils.parseIntSafely( sSettingsPre.getString(key, defValue.toString()), - defValue + defValue, ) } catch (e: ClassCastException) { Log.d(TAG, "Get ClassCastException when get $key value", e) @@ -469,7 +471,7 @@ object Settings { sSettingsPre.getString(KEY_FAV_CAT_6, DEFAULT_FAV_CAT_6)!!, sSettingsPre.getString(KEY_FAV_CAT_7, DEFAULT_FAV_CAT_7)!!, sSettingsPre.getString(KEY_FAV_CAT_8, DEFAULT_FAV_CAT_8)!!, - sSettingsPre.getString(KEY_FAV_CAT_9, DEFAULT_FAV_CAT_9)!! + sSettingsPre.getString(KEY_FAV_CAT_9, DEFAULT_FAV_CAT_9)!!, ) fun putFavCat(value: Array) { @@ -499,7 +501,7 @@ object Settings { sSettingsPre.getInt(KEY_FAV_COUNT_6, DEFAULT_FAV_COUNT), sSettingsPre.getInt(KEY_FAV_COUNT_7, DEFAULT_FAV_COUNT), sSettingsPre.getInt(KEY_FAV_COUNT_8, DEFAULT_FAV_COUNT), - sSettingsPre.getInt(KEY_FAV_COUNT_9, DEFAULT_FAV_COUNT) + sSettingsPre.getInt(KEY_FAV_COUNT_9, DEFAULT_FAV_COUNT), ) fun putFavCount(count: IntArray) { @@ -642,4 +644,4 @@ object Settings { val preloadThumbAggressively: Boolean get() = getBoolean(KEY_PRELOAD_THUMB_AGGRESIVELY, DEFAULT_PRELOAD_THUMB_AGGRESIVELY) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt b/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt index 913d487b9..8424bebff 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhClient.kt @@ -28,15 +28,17 @@ object EhClient { val callback: Callback? = request.callback try { val result: Any? = request.run { - if (args == null) + if (args == null) { execute(method) - else + } else { execute(method, *args!!) + } } withUIContext { callback?.onSuccess(result) } } catch (e: Exception) { - if (e is CancellationException) + if (e is CancellationException) { throw e // Don't catch coroutine CancellationException + } e.printStackTrace() withUIContext { callback?.onFailure(e) } } @@ -46,15 +48,15 @@ object EhClient { suspend fun execute(method: Int, vararg params: Any?): Any? { return when (method) { METHOD_GET_GALLERY_LIST -> EhEngine.getGalleryList( - params[0] as String + params[0] as String, ) METHOD_GET_GALLERY_DETAIL -> EhEngine.getGalleryDetail( - params[0] as String + params[0] as String, ) METHOD_GET_PREVIEW_LIST -> EhEngine.getPreviewList( - params[0] as String + params[0] as String, ) METHOD_GET_RATE_GALLERY -> EhEngine.rateGallery( @@ -62,48 +64,50 @@ object EhClient { params[1] as String?, params[2] as Long, params[3] as String?, - params[4] as Float + params[4] as Float, ) METHOD_GET_COMMENT_GALLERY -> EhEngine.commentGallery( params[0] as String?, params[1] as String, - params[2] as String? + params[2] as String?, ) METHOD_GET_GALLERY_TOKEN -> EhEngine.getGalleryToken( params[0] as Long, params[1] as String?, - params[2] as Int + params[2] as Int, ) METHOD_GET_FAVORITES -> EhEngine.getFavorites( - params[0] as String + params[0] as String, ) METHOD_ADD_FAVORITES -> EhEngine.addFavorites( params[0] as Long, params[1] as String?, params[2] as Int, - params[3] as String? + params[3] as String?, ) - METHOD_ADD_FAVORITES_RANGE -> @Suppress("UNCHECKED_CAST") EhEngine.addFavoritesRange( - params[0] as LongArray, - params[1] as Array, - params[2] as Int - ) + METHOD_ADD_FAVORITES_RANGE -> + @Suppress("UNCHECKED_CAST") + EhEngine.addFavoritesRange( + params[0] as LongArray, + params[1] as Array, + params[2] as Int, + ) METHOD_MODIFY_FAVORITES -> EhEngine.modifyFavorites( params[0] as String, params[1] as LongArray, - params[2] as Int + params[2] as Int, ) METHOD_GET_TORRENT_LIST -> EhEngine.getTorrentList( params[0] as String, params[1] as Long, - params[2] as String? + params[2] as String?, ) METHOD_VOTE_COMMENT -> EhEngine.voteComment( @@ -112,20 +116,20 @@ object EhClient { params[2] as Long, params[3] as String?, params[4] as Long, - params[5] as Int + params[5] as Int, ) METHOD_IMAGE_SEARCH -> EhEngine.imageSearch( params[0] as File, params[1] as Boolean, params[2] as Boolean, - params[3] as Boolean + params[3] as Boolean, ) METHOD_ARCHIVE_LIST -> EhEngine.getArchiveList( params[0] as String, params[1] as Long, - params[2] as String? + params[2] as String?, ) METHOD_DOWNLOAD_ARCHIVE -> EhEngine.downloadArchive( @@ -133,7 +137,7 @@ object EhClient { params[1] as String?, params[2] as String?, params[3] as String?, - params[4] as Boolean + params[4] as Boolean, ) METHOD_VOTE_TAG -> EhEngine.voteTag( @@ -142,7 +146,7 @@ object EhClient { params[2] as Long, params[3] as String?, params[4] as String?, - params[5] as Int + params[5] as Int, ) else -> throw IllegalStateException("Can't detect method $method") @@ -171,4 +175,4 @@ object EhClient { const val METHOD_ARCHIVE_LIST = 17 const val METHOD_DOWNLOAD_ARCHIVE = 18 const val METHOD_VOTE_TAG = 19 -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt b/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt index cee30511a..9171cd58a 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhCookieStore.kt @@ -41,7 +41,7 @@ object EhCookieStore : CookieJar, CookiesStorage { fun hasSignedIn(): Boolean { val url = EhUrl.HOST_E.toHttpUrl() return contains(url, KEY_IPB_MEMBER_ID) && - contains(url, KEY_IPB_PASS_HASH) + contains(url, KEY_IPB_PASS_HASH) } const val KEY_IPB_MEMBER_ID = "ipb_member_id" @@ -60,8 +60,11 @@ object EhCookieStore : CookieJar, CookiesStorage { .build() fun newCookie( - cookie: Cookie, newDomain: String, forcePersistent: Boolean = false, - forceLongLive: Boolean = false, forceNotHostOnly: Boolean = false + cookie: Cookie, + newDomain: String, + forcePersistent: Boolean = false, + forceLongLive: Boolean = false, + forceNotHostOnly: Boolean = false, ): Cookie { val builder = Cookie.Builder() builder.name(cookie.name) @@ -212,7 +215,7 @@ object EhCookieStore : CookieJar, CookiesStorage { return loadForRequest(requestUrl.toString().toHttpUrl()).map { okhttpCookieToKtorCookieMap[it] ?: KtorCookie( it.name, - it.value + it.value, ).apply { okhttpCookieToKtorCookieMap[it] = this } } } @@ -253,10 +256,12 @@ object EhCookieStore : CookieJar, CookiesStorage { val urlHost = url.host return if (urlHost == domain) { true // As in 'example.com' matching 'example.com'. - } else urlHost.endsWith(domain!!) - && urlHost[urlHost.length - domain.length - 1] == '.' && !verifyAsIpAddress( - urlHost - ) + } else { + urlHost.endsWith(domain!!) && + urlHost[urlHost.length - domain.length - 1] == '.' && !verifyAsIpAddress( + urlHost, + ) + } // As in 'example.com' matching 'www.example.com'. } @@ -280,4 +285,4 @@ object EhCookieStore : CookieJar, CookiesStorage { cookies } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt b/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt index f5a00dd2e..3200ec67c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhDns.kt @@ -70,27 +70,27 @@ object EhDns : Dns { put( builtInHosts, "ehgt.org", - *ehgtHosts + *ehgtHosts, ) put( builtInHosts, "gt0.ehgt.org", - *ehgtHosts + *ehgtHosts, ) put( builtInHosts, "gt1.ehgt.org", - *ehgtHosts + *ehgtHosts, ) put( builtInHosts, "gt2.ehgt.org", - *ehgtHosts + *ehgtHosts, ) put( builtInHosts, "gt3.ehgt.org", - *ehgtHosts + *ehgtHosts, ) put( builtInHosts, @@ -111,7 +111,7 @@ object EhDns : Dns { private fun put( map: MutableMap>, host: String, - vararg ips: Pair + vararg ips: Pair, ) { map[host] = ips.mapNotNull { pair -> Hosts.toInetAddress(host, pair.first).takeUnless { Settings.dF && pair.second } @@ -121,7 +121,7 @@ object EhDns : Dns { @Throws(UnknownHostException::class) override fun lookup(hostname: String): List { return hosts[hostname] ?: builtInHosts[hostname].takeIf { Settings.builtInHosts } - ?: Dns.SYSTEM.lookup(hostname) + ?: Dns.SYSTEM.lookup(hostname) } fun isInHosts(hostname: String): Boolean { diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt index 06e23c37f..5cd384d0d 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.kt @@ -157,7 +157,7 @@ object EhEngine { private suspend fun fillGalleryList( list: MutableList, url: String, - filter: Boolean + filter: Boolean, ) { // Filter title and uploader if (filter) { @@ -177,8 +177,8 @@ object EhEngine { hasRated = true } } - val needApi = filter && sEhFilter.needTags() && !hasTags - || Settings.showGalleryPages && !hasPages || hasRated + val needApi = filter && sEhFilter.needTags() && !hasTags || + Settings.showGalleryPages && !hasPages || hasRated if (needApi) { fillGalleryListByApi(list, url) } @@ -187,8 +187,8 @@ object EhEngine { if (filter) { // Thumbnail mode need filter uploader again list.removeAll { - !sEhFilter.filterUploader(it) || !sEhFilter.filterTag(it) - || !sEhFilter.filterTagNamespace(it) + !sEhFilter.filterUploader(it) || !sEhFilter.filterTag(it) || + !sEhFilter.filterTagNamespace(it) } } } @@ -202,7 +202,7 @@ object EhEngine { suspend fun fillGalleryListByApi( galleryInfoList: List, - referer: String + referer: String, ): List { val requestItems: MutableList = ArrayList(MAX_REQUEST_SIZE) var i = 0 @@ -220,7 +220,7 @@ object EhEngine { private suspend fun doFillGalleryListByApi( galleryInfoList: List, - referer: String + referer: String, ) { val json = JSONObject() json.put("method", "gdata") @@ -269,8 +269,11 @@ object EhEngine { @Throws(Throwable::class) suspend fun rateGallery( - apiUid: Long, apiKey: String?, gid: Long, token: String?, - rating: Float + apiUid: Long, + apiKey: String?, + gid: Long, + token: String?, + rating: Float, ): RateGalleryParser.Result { val json = JSONObject() json.put("method", "rategallery") @@ -290,7 +293,9 @@ object EhEngine { } suspend fun commentGallery( - url: String?, comment: String, id: String? + url: String?, + comment: String, + id: String?, ): GalleryCommentList { val builder = FormBody.Builder() if (id == null) { @@ -315,14 +320,16 @@ object EhEngine { suspend fun getGalleryToken( gid: Long, - gtoken: String?, page: Int + gtoken: String?, + page: Int, ): String { val json = JSONObject() .put("method", "gtoken") .put( - "pagelist", JSONArray().put( - JSONArray().put(gid).put(gtoken).put(page + 1) - ) + "pagelist", + JSONArray().put( + JSONArray().put(gid).put(gtoken).put(page + 1), + ), ) val requestBody: RequestBody = json.toString().toRequestBody(MEDIA_TYPE_JSON) val url = EhUrl.apiUrl @@ -335,7 +342,7 @@ object EhEngine { } suspend fun getFavorites( - url: String + url: String, ): FavoritesParser.Result { val referer = EhUrl.referer Log.d(TAG, url) @@ -349,7 +356,9 @@ object EhEngine { */ suspend fun addFavorites( gid: Long, - token: String?, dstCat: Int, note: String? + token: String?, + dstCat: Int, + note: String?, ) { val catStr: String = when (dstCat) { -1 -> { @@ -381,7 +390,8 @@ object EhEngine { @Throws(Throwable::class) suspend fun addFavoritesRange( gidArray: LongArray, - tokenArray: Array, dstCat: Int + tokenArray: Array, + dstCat: Int, ): Void? { check(gidArray.size == tokenArray.size) var i = 0 @@ -395,7 +405,8 @@ object EhEngine { suspend fun modifyFavorites( url: String, - gidArray: LongArray, dstCat: Int + gidArray: LongArray, + dstCat: Int, ): FavoritesParser.Result { val catStr: String = when (dstCat) { -1 -> { @@ -425,7 +436,9 @@ object EhEngine { } suspend fun getTorrentList( - url: String, gid: Long, token: String? + url: String, + gid: Long, + token: String?, ): List { val referer = EhUrl.getGalleryDetailUrl(gid, token) Log.d(TAG, url) @@ -433,7 +446,9 @@ object EhEngine { } suspend fun getArchiveList( - url: String, gid: Long, token: String? + url: String, + gid: Long, + token: String?, ): ArchiveParser.Result { val referer = EhUrl.getGalleryDetailUrl(gid, token) Log.d(TAG, url) @@ -443,7 +458,10 @@ object EhEngine { suspend fun downloadArchive( gid: Long, - token: String?, or: String?, res: String?, isHAtH: Boolean + token: String?, + or: String?, + res: String?, + isHAtH: Boolean, ): String? { if (or.isNullOrEmpty()) { throw EhException("Invalid form param or: $or") @@ -526,7 +544,8 @@ object EhEngine { } private suspend fun getProfileInternal( - url: String, referer: String + url: String, + referer: String, ): ProfileParser.Result { Log.d(TAG, url) return EhRequestBuilder(url, referer).executeAndParsingWith(ProfileParser::parse) @@ -537,7 +556,7 @@ object EhEngine { Log.d(TAG, url) return getProfileInternal( EhRequestBuilder(url).executeAndParsingWith(ForumsParser::parse), - url + url, ) } @@ -564,7 +583,11 @@ object EhEngine { suspend fun voteComment( apiUid: Long, - apiKey: String?, gid: Long, token: String?, commentId: Long, commentVote: Int + apiKey: String?, + gid: Long, + token: String?, + commentId: Long, + commentVote: Int, ): VoteCommentParser.Result { val json = JSONObject() json.put("method", "votecomment") @@ -588,7 +611,11 @@ object EhEngine { suspend fun voteTag( apiUid: Long, - apiKey: String?, gid: Long, token: String?, tags: String?, vote: Int + apiKey: String?, + gid: Long, + token: String?, + tags: String?, + vote: Int, ): VoteTagParser.Result { val json = JSONObject() json.put("method", "taggallery") @@ -613,38 +640,40 @@ object EhEngine { */ suspend fun imageSearch( image: File, - uss: Boolean, osc: Boolean, se: Boolean + uss: Boolean, + osc: Boolean, + se: Boolean, ): GalleryListParser.Result { val builder = MultipartBody.Builder() builder.setType(MultipartBody.FORM) builder.addPart( Headers.headersOf( "Content-Disposition", - "form-data; name=\"sfile\"; filename=\"a.jpg\"" + "form-data; name=\"sfile\"; filename=\"a.jpg\"", ), - image.asRequestBody(MEDIA_TYPE_JPEG) + image.asRequestBody(MEDIA_TYPE_JPEG), ) if (uss) { builder.addPart( Headers.headersOf("Content-Disposition", "form-data; name=\"fs_similar\""), - "on".toRequestBody() + "on".toRequestBody(), ) } if (osc) { builder.addPart( Headers.headersOf("Content-Disposition", "form-data; name=\"fs_covers\""), - "on".toRequestBody() + "on".toRequestBody(), ) } if (se) { builder.addPart( Headers.headersOf("Content-Disposition", "form-data; name=\"fs_exp\""), - "on".toRequestBody() + "on".toRequestBody(), ) } builder.addPart( Headers.headersOf("Content-Disposition", "form-data; name=\"f_sfile\""), - "File Search".toRequestBody() + "File Search".toRequestBody(), ) val url = EhUrl.imageSearchUrl val referer = EhUrl.referer @@ -659,7 +688,7 @@ object EhEngine { suspend fun getGalleryPage( url: String?, gid: Long, - token: String? + token: String?, ): GalleryPageParser.Result { val referer = EhUrl.getGalleryDetailUrl(gid, token) Log.d(TAG, url!!) @@ -671,7 +700,7 @@ object EhEngine { index: Int, pToken: String?, showKey: String?, - previousPToken: String? + previousPToken: String?, ): GalleryPageApiParser.Result { val json = JSONObject() json.put("method", "showpage") @@ -691,4 +720,4 @@ object EhEngine { .post(requestBody) .executeAndParsingWith(GalleryPageApiParser::parse) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt b/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt index eea9922c8..5180f8a38 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhFilter.kt @@ -149,7 +149,7 @@ object EhFilter { val n = filters.size while (i < n) { if (filters[i].enable!! && title.lowercase(Locale.getDefault()).contains( - filters[i].text!! + filters[i].text!!, ) ) { return false @@ -210,7 +210,9 @@ object EhFilter { tagNamespace != filterNamespace ) { false - } else tagName == filterName + } else { + tagName == filterName + } } @Synchronized @@ -312,4 +314,4 @@ object EhFilter { } return true } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhRequest.kt b/app/src/main/java/com/hippo/ehviewer/client/EhRequest.kt index b3aa4ef3e..23e3d95ee 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhRequest.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhRequest.kt @@ -77,4 +77,4 @@ class EhRequest { callback?.onCancel() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.kt b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.kt index aaf77853b..aaf47c76b 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhSSLSocketFactory.kt @@ -39,7 +39,7 @@ object EhSSLSocketFactory : SSLSocketFactory() { val sslSession = socket.session Log.d( "EhSSLSocketFactory", - "Host: " + host + " Address: " + address + " Protocol:" + sslSession.protocol + " CipherSuite:" + sslSession.cipherSuite + "Host: " + host + " Address: " + address + " Protocol:" + sslSession.protocol + " CipherSuite:" + sslSession.cipherSuite, ) return socket } @@ -52,7 +52,7 @@ object EhSSLSocketFactory : SSLSocketFactory() { host: String, port: Int, localHost: InetAddress, - localPort: Int + localPort: Int, ): Socket { return sslSocketFactory.createSocket(host, port, localHost, localPort) } @@ -65,7 +65,7 @@ object EhSSLSocketFactory : SSLSocketFactory() { address: InetAddress, port: Int, localAddress: InetAddress, - localPort: Int + localPort: Int, ): Socket { return sslSocketFactory.createSocket(address, port, localAddress, localPort) } diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.kt b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.kt index 2a4d8786c..72b904ba3 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhTagDatabase.kt @@ -74,7 +74,7 @@ object EhTagDatabase { tags: Map, keyword: String, translate: Boolean, - exactly: Boolean + exactly: Boolean, ): Flow> = flow { if (exactly) { tags[keyword]?.let { @@ -103,7 +103,7 @@ object EhTagDatabase { fun suggestFlow( keyword: String, translate: Boolean, - exactly: Boolean = false + exactly: Boolean = false, ): Flow> = flow { val keywordPrefix = keyword.substringBefore(':') val keywordTag = keyword.drop(keywordPrefix.length + 1) @@ -131,7 +131,6 @@ object EhTagDatabase { private fun String.containsIgnoreSpace(other: String, ignoreCase: Boolean = true): Boolean = removeSpace().contains(other.removeSpace(), ignoreCase) - private val NAMESPACE_TO_PREFIX = HashMap().also { it["artist"] = "a" it["cosplayer"] = "cos" @@ -279,4 +278,4 @@ object EhTagDatabase { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhUrl.kt b/app/src/main/java/com/hippo/ehviewer/client/EhUrl.kt index ac165cd96..b5530c20b 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhUrl.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhUrl.kt @@ -163,4 +163,4 @@ object EhUrl { fun getTagDefinitionUrl(tag: String): String { return "https://ehwiki.org/wiki/" + tag.replace(' ', '_') } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt index f4eb4fd4d..36db86bde 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/EhUtils.kt @@ -51,13 +51,13 @@ object EhUtils { // Remove [XXX], (XXX), {XXX}, ~XXX~ stuff private val PATTERN_TITLE_PREFIX = Pattern.compile( - "^(?:\\([^)]*\\)|\\[[^]]*]|\\{[^}]*\\}|~[^~]*~|\\s+)*" + "^(?:\\([^)]*\\)|\\[[^]]*]|\\{[^}]*\\}|~[^~]*~|\\s+)*", ) // Remove [XXX], (XXX), {XXX}, ~XXX~ stuff and something like ch. 1-23 private val PATTERN_TITLE_SUFFIX = Pattern.compile( "(?:\\s+ch.[\\s\\d-]+)?(?:\\([^)]*\\)|\\[[^]]*]|\\{[^}]*\\}|~[^~]*~|\\s+)*$", - Pattern.CASE_INSENSITIVE + Pattern.CASE_INSENSITIVE, ) private val CATEGORY_VALUES = hashMapOf( @@ -72,7 +72,7 @@ object EhUtils { NON_H to arrayOf("non-h"), WESTERN to arrayOf("western"), PRIVATE to arrayOf("private"), - UNKNOWN to arrayOf("unknown") + UNKNOWN to arrayOf("unknown"), ) private val CATEGORY_STRINGS = CATEGORY_VALUES.entries.map { (k, v) -> v to k } @@ -83,8 +83,9 @@ object EhUtils { fun getCategory(type: String?): Int { for (entry in CATEGORY_STRINGS) { for (str in entry.first) - if (str.equals(type, ignoreCase = true)) + if (str.equals(type, ignoreCase = true)) { return entry.second + } } return UNKNOWN } @@ -164,4 +165,4 @@ object EhUtils { url } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/AbstractGalleryInfo.kt b/app/src/main/java/com/hippo/ehviewer/client/data/AbstractGalleryInfo.kt index 960c5a674..b111459f0 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/AbstractGalleryInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/AbstractGalleryInfo.kt @@ -22,4 +22,4 @@ interface AbstractGalleryInfo { var simpleLanguage: String? var favoriteSlot: Int var favoriteName: String? -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/BaseGalleryInfo.kt b/app/src/main/java/com/hippo/ehviewer/client/data/BaseGalleryInfo.kt index ad555876d..1d64ca3a3 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/BaseGalleryInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/BaseGalleryInfo.kt @@ -84,6 +84,6 @@ open class BaseGalleryInfo( override var favoriteSlot: Int = -2, @Ignore - override var favoriteName: String? = null + override var favoriteName: String? = null, -) : GalleryInfo \ No newline at end of file +) : GalleryInfo diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/FavListUrlBuilder.kt b/app/src/main/java/com/hippo/ehviewer/client/data/FavListUrlBuilder.kt index 38f83dd96..5e109dad0 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/FavListUrlBuilder.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/FavListUrlBuilder.kt @@ -55,4 +55,4 @@ class FavListUrlBuilder( return favCat in 0..9 } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiInfo.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiInfo.kt index de08cdc6b..af141a982 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiInfo.kt @@ -34,5 +34,5 @@ class GalleryApiInfo( var expunged: Boolean = false, var rating: Float = 0f, var torrentcount: Int = 0, - var tags: Array? -) : Parcelable \ No newline at end of file + var tags: Array?, +) : Parcelable diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryComment.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryComment.kt index a5ead75fa..fd8a15237 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryComment.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryComment.kt @@ -46,5 +46,5 @@ class GalleryComment( @JvmField var comment: String? = null, @JvmField - var lastEdited: Long = 0 -) : Parcelable \ No newline at end of file + var lastEdited: Long = 0, +) : Parcelable diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.kt index 4d9835d76..4c0b190c5 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryCommentList.kt @@ -23,5 +23,5 @@ class GalleryCommentList( @JvmField var comments: Array?, @JvmField - var hasMore: Boolean -) : Parcelable \ No newline at end of file + var hasMore: Boolean, +) : Parcelable diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt index deb2b4bf8..b565373e2 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.kt @@ -64,7 +64,7 @@ class GalleryDetail( "Vietnamese", "Polish", "Hungarian", - "Dutch" + "Dutch", ) } } diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt index d74018ab4..43c13d1d5 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.kt @@ -78,20 +78,20 @@ interface GalleryInfo : AbstractGalleryInfo, Parcelable { S_LANG_VI, S_LANG_PL, S_LANG_HU, - S_LANG_NL + S_LANG_NL, ) val S_LANG_PATTERNS = arrayOf( Pattern.compile( "[(\\[]eng(?:lish)?[)\\]]|英訳", - Pattern.CASE_INSENSITIVE - ), // [((\[]ch(?:inese)?[))\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳 + Pattern.CASE_INSENSITIVE, + ), // [((\[]ch(?:inese)?[))\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳 Pattern.compile( "[(\uFF08\\[]ch(?:inese)?[)\uFF09\\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳", - Pattern.CASE_INSENSITIVE + Pattern.CASE_INSENSITIVE, ), Pattern.compile( "[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]|スペイン翻訳", - Pattern.CASE_INSENSITIVE + Pattern.CASE_INSENSITIVE, ), Pattern.compile("[(\\[]korean?[)\\]]|韓国翻訳", Pattern.CASE_INSENSITIVE), Pattern.compile("[(\\[]rus(?:sian)?[)\\]]|ロシア翻訳", Pattern.CASE_INSENSITIVE), @@ -99,17 +99,17 @@ interface GalleryInfo : AbstractGalleryInfo, Parcelable { Pattern.compile("[(\\[]portuguese|ポルトガル翻訳", Pattern.CASE_INSENSITIVE), Pattern.compile( "[(\\[]thai(?: ภาษาไทย)?[)\\]]|แปลไทย|タイ翻訳", - Pattern.CASE_INSENSITIVE + Pattern.CASE_INSENSITIVE, ), Pattern.compile("[(\\[]german[)\\]]|ドイツ翻訳", Pattern.CASE_INSENSITIVE), Pattern.compile("[(\\[]italiano?[)\\]]|イタリア翻訳", Pattern.CASE_INSENSITIVE), Pattern.compile( "[(\\[]vietnamese(?: Tiếng Việt)?[)\\]]|ベトナム翻訳", - Pattern.CASE_INSENSITIVE + Pattern.CASE_INSENSITIVE, ), Pattern.compile("[(\\[]polish[)\\]]|ポーランド翻訳", Pattern.CASE_INSENSITIVE), Pattern.compile("[(\\[]hun(?:garian)?[)\\]]|ハンガリー翻訳", Pattern.CASE_INSENSITIVE), - Pattern.compile("[(\\[]dutch[)\\]]|オランダ翻訳", Pattern.CASE_INSENSITIVE) + Pattern.compile("[(\\[]dutch[)\\]]|オランダ翻訳", Pattern.CASE_INSENSITIVE), ) val S_LANG_TAGS = arrayOf( "language:english", @@ -125,7 +125,7 @@ interface GalleryInfo : AbstractGalleryInfo, Parcelable { "language:vietnamese", "language:polish", "language:hungarian", - "language:dutch" + "language:dutch", ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryPreview.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryPreview.kt index b20e6781b..55103ea2c 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryPreview.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryPreview.kt @@ -33,4 +33,4 @@ data class GalleryPreview( view.setClip(offsetX, offsetY, clipWidth, clipHeight) view.load(imageUrl) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryTagGroup.kt b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryTagGroup.kt index 1c7c19fc1..7e7f524c7 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryTagGroup.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryTagGroup.kt @@ -22,5 +22,5 @@ import kotlinx.parcelize.Parcelize class GalleryTagGroup( private val mTagList: ArrayList = arrayListOf(), @JvmField - var groupName: String? = null -) : Parcelable, MutableList by mTagList \ No newline at end of file + var groupName: String? = null, +) : Parcelable, MutableList by mTagList diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt index 8a993f3be..93c4f569e 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/data/ListUrlBuilder.kt @@ -32,7 +32,8 @@ import java.net.URLDecoder @Parcelize data class ListUrlBuilder( - @get:Mode @Mode var mode: Int = MODE_NORMAL, + @get:Mode @Mode + var mode: Int = MODE_NORMAL, private var mPrev: String? = null, private var mNext: String? = null, private var mJumpTo: String? = null, @@ -129,7 +130,9 @@ data class ListUrlBuilder( } return if (q.pageFrom != pageFrom) { false - } else q.pageTo == pageTo + } else { + q.pageTo == pageTo + } } /** @@ -294,7 +297,7 @@ data class ListUrlBuilder( mNext?.let { ub.addQuery("next", it) } - // Search key + // Search key // the settings of ub:UrlBuilder may be overwritten by following Advance search StringUtils.split(mKeyword, '|')?.forEachIndexed { idx, keyword -> val keyword = keyword.trim { it <= ' ' } @@ -391,7 +394,7 @@ data class ListUrlBuilder( MODE_WHATS_HOT, MODE_IMAGE_SEARCH, MODE_SUBSCRIPTION, - MODE_TOPLIST + MODE_TOPLIST, ) @Retention(AnnotationRetention.SOURCE) private annotation class Mode @@ -404,4 +407,4 @@ data class ListUrlBuilder( const val MODE_SUBSCRIPTION = 0x5 const val MODE_TOPLIST = 0x6 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt index aa5c9e747..fec2cbb93 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt @@ -18,4 +18,4 @@ package com.hippo.ehviewer.client.exception open class EhException : Exception { constructor(detailMessage: String?) : super(detailMessage) constructor(detailMessage: String?, cause: Throwable?) : super(detailMessage, cause) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt index 8efb54662..b3ee4c02a 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt @@ -15,4 +15,4 @@ */ package com.hippo.ehviewer.client.exception -class NoHAtHClientException(detailMessage: String?) : EhException(detailMessage) \ No newline at end of file +class NoHAtHClientException(detailMessage: String?) : EhException(detailMessage) diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt index 7675e0205..72bd60e62 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt @@ -18,4 +18,4 @@ package com.hippo.ehviewer.client.exception /** * It is an exception for get offensive tip for g.e-hentai.org */ -class OffensiveException : EhException("OFFENSIVE") \ No newline at end of file +class OffensiveException : EhException("OFFENSIVE") diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt index 27860c007..df59bcce7 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt @@ -24,8 +24,8 @@ class ParseException : EhException { constructor(detailMessage: String?, body: String, cause: Throwable?) : super( detailMessage, - cause + cause, ) { this.body = body } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt index 00283bcab..c39c962b7 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt @@ -15,4 +15,4 @@ */ package com.hippo.ehviewer.client.exception -class PiningException : EhException("pining for the fjords") \ No newline at end of file +class PiningException : EhException("pining for the fjords") diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt index 1696717b4..5cd635652 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/ArchiveParser.kt @@ -78,7 +78,7 @@ object ArchiveParser { val name: String, val size: String, val cost: String, - val isHAtH: Boolean + val isHAtH: Boolean, ) class Result(val paramOr: String?, val archiveList: List, var funds: HomeParser.Funds?) diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/FavoritesParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/FavoritesParser.kt index 2211c4d51..5ecbf3db3 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/FavoritesParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/FavoritesParser.kt @@ -53,10 +53,10 @@ object FavoritesParser { class Result( val catArray: Array, val countArray: IntArray, - galleryListResult: GalleryListParser.Result + galleryListResult: GalleryListParser.Result, ) { val prev = galleryListResult.prev val next = galleryListResult.next val galleryInfoList = galleryListResult.galleryInfoList } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.kt index 7fb3dfd6e..cee0e161b 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.kt @@ -52,7 +52,7 @@ object GalleryDetailParser { private val PATTERN_ERROR = Regex("
\n

([^<]+)

") private val PATTERN_DETAIL = Regex( "var gid = (\\d+);.+?var token = \"([a-f0-9]+)\";.+?var apiuid = ([\\-\\d]+);.+?var apikey = \"([a-f0-9]+)\";", - RegexOption.DOT_MATCHES_ALL + RegexOption.DOT_MATCHES_ALL, ) private val PATTERN_TORRENT = Regex("]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Torrent Download[^<]+(\\d+)[^<]+() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/HomeParser.kt b/app/src/main/java/com/hippo/ehviewer/client/parser/HomeParser.kt index 4df94118f..afbda63ad 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/HomeParser.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/HomeParser.kt @@ -22,7 +22,7 @@ object HomeParser { } fun parseResetLimits(body: String): Limits? { - return if (body.contains(RESET_SUCCEED)){ + return if (body.contains(RESET_SUCCEED)) { null } else { parse(body) @@ -41,4 +41,4 @@ object HomeParser { data class Limits(val current: Int = 0, val maximum: Int, val resetCost: Int = 0) data class Funds(val fundsGP: Int, val fundsC: Int) class Result(val limits: Limits, val funds: Funds) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/coil/Extensions.kt b/app/src/main/java/com/hippo/ehviewer/coil/Extensions.kt index f85bc2dca..738a156b7 100644 --- a/app/src/main/java/com/hippo/ehviewer/coil/Extensions.kt +++ b/app/src/main/java/com/hippo/ehviewer/coil/Extensions.kt @@ -15,10 +15,10 @@ fun ImageRequest.Builder.ehUrl(url: String) = apply { inline fun Context.imageRequest( url: String, - builder: ImageRequest.Builder.() -> Unit = {} + builder: ImageRequest.Builder.() -> Unit = {}, ): ImageRequest { return ImageRequest.Builder(this) .ehUrl(url) .apply(builder) .build() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/coil/MergeInterceptor.kt b/app/src/main/java/com/hippo/ehviewer/coil/MergeInterceptor.kt index bc8e77632..3cba423dc 100644 --- a/app/src/main/java/com/hippo/ehviewer/coil/MergeInterceptor.kt +++ b/app/src/main/java/com/hippo/ehviewer/coil/MergeInterceptor.kt @@ -44,7 +44,7 @@ object MergeInterceptor : Interceptor { pendingContinuationMap.remove(key)?.forEach { it.resume(Unit) } } } - } + }, ).build() pendingContinuationMapLock.lock() diff --git a/app/src/main/java/com/hippo/ehviewer/dailycheck/DailyCheckWork.kt b/app/src/main/java/com/hippo/ehviewer/dailycheck/DailyCheckWork.kt index a45a36485..57f4db14e 100644 --- a/app/src/main/java/com/hippo/ehviewer/dailycheck/DailyCheckWork.kt +++ b/app/src/main/java/com/hippo/ehviewer/dailycheck/DailyCheckWork.kt @@ -72,7 +72,7 @@ fun updateDailyCheckWork(context: Context) { WorkManager.getInstance(context).enqueueUniquePeriodicWork( workName, ExistingPeriodicWorkPolicy.UPDATE, - getDailyCheckWorkRequest() + getDailyCheckWorkRequest(), ) } else { WorkManager.getInstance(context).cancelUniqueWork(workName) @@ -93,7 +93,6 @@ suspend fun checkDawn() = runCatching { it.printStackTrace() } - @SuppressLint("MissingPermission") fun showEventNotification(html: String) { if (Settings.hideHvEvents && html.contains("You have encountered a monster!")) { diff --git a/app/src/main/java/com/hippo/ehviewer/dao/BasicDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/BasicDao.kt index 836706af3..a37d678fa 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/BasicDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/BasicDao.kt @@ -3,4 +3,4 @@ package com.hippo.ehviewer.dao interface BasicDao { fun list(): List fun insert(t: T): Long -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt index 73ea57749..8b2e8f3e0 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/BookmarkInfo.kt @@ -13,4 +13,4 @@ class BookmarkInfo : BaseGalleryInfo() { @JvmField @ColumnInfo(name = "TIME") var time: Long = 0 -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/BookmarksDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/BookmarksDao.kt index f50c304e1..c402689ca 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/BookmarksDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/BookmarksDao.kt @@ -15,4 +15,4 @@ interface BookmarksDao : BasicDao { @Query("SELECT * FROM BOOKMARKS ORDER BY TIME DESC") override fun list(): List -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt index 9bade3aca..c2e5814b6 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirname.kt @@ -11,5 +11,5 @@ data class DownloadDirname( var gid: Long = 0, @ColumnInfo(name = "DIRNAME") - var dirname: String? = null -) \ No newline at end of file + var dirname: String? = null, +) diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirnameDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirnameDao.kt index 747b6079f..426b08811 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirnameDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadDirnameDao.kt @@ -24,4 +24,4 @@ interface DownloadDirnameDao : BasicDao { @Query("SELECT * FROM DOWNLOAD_DIRNAME") override fun list(): List -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt index e64ec3c8f..25f8bac5a 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadInfo.kt @@ -66,4 +66,4 @@ class DownloadInfo() : BaseGalleryInfo() { const val STATE_FINISH = 3 const val STATE_FAILED = 4 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabel.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabel.kt index e3e440c1c..2c1fd9d10 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabel.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabel.kt @@ -14,5 +14,5 @@ data class DownloadLabel( var label: String? = null, @ColumnInfo(name = "TIME") - var time: Long = 0 -) \ No newline at end of file + var time: Long = 0, +) diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabelDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabelDao.kt index f7c8dc40d..9f345100b 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabelDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadLabelDao.kt @@ -25,4 +25,4 @@ interface DownloadLabelDao : BasicDao { @Delete fun delete(downloadLabel: DownloadLabel) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/DownloadsDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/DownloadsDao.kt index 23a0aae92..31bcdda00 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/DownloadsDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/DownloadsDao.kt @@ -28,4 +28,4 @@ interface DownloadsDao : BasicDao { @Delete fun delete(downloadInfo: DownloadInfo) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/EhDatabase.kt b/app/src/main/java/com/hippo/ehviewer/dao/EhDatabase.kt index b1c5525a2..fc88c6281 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/EhDatabase.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/EhDatabase.kt @@ -8,7 +8,7 @@ import androidx.room.RoomDatabase @Database( entities = [BookmarkInfo::class, DownloadInfo::class, DownloadLabel::class, DownloadDirname::class, Filter::class, HistoryInfo::class, LocalFavoriteInfo::class, QuickSearch::class], version = 4, - exportSchema = false + exportSchema = false, ) abstract class EhDatabase : RoomDatabase() { abstract fun bookmarksBao(): BookmarksDao diff --git a/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt b/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt index 252e4131e..090947784 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/Filter.kt @@ -20,5 +20,5 @@ data class Filter( @PrimaryKey @ColumnInfo(name = "_id") - var id: Long? = null -) \ No newline at end of file + var id: Long? = null, +) diff --git a/app/src/main/java/com/hippo/ehviewer/dao/FilterDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/FilterDao.kt index 4d0682cf9..2262d0350 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/FilterDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/FilterDao.kt @@ -22,4 +22,4 @@ interface FilterDao : BasicDao { @Query("SELECT * FROM FILTER WHERE TEXT = :text AND MODE = :mode") fun load(text: String, mode: Int): Filter? -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/HistoryDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/HistoryDao.kt index 3cc42a865..1f6b3b2eb 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/HistoryDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/HistoryDao.kt @@ -35,4 +35,4 @@ interface HistoryDao : BasicDao { @Query("DELETE FROM HISTORY") fun deleteAll() -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt index 5cf92a5e5..b053008a5 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoriteInfo.kt @@ -28,4 +28,4 @@ class LocalFavoriteInfo() : BaseGalleryInfo() { init { favoriteSlot = -1 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoritesDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoritesDao.kt index 2196050bb..231ff9c6c 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoritesDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/LocalFavoritesDao.kt @@ -27,4 +27,4 @@ interface LocalFavoritesDao : BasicDao { @Query("DELETE FROM LOCAL_FAVORITES WHERE GID = :gid") fun deleteByKey(gid: Long) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt index a5aab34d7..23eb2ac89 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearch.kt @@ -35,5 +35,5 @@ data class QuickSearch( var pageTo: Int = 0, @ColumnInfo(name = "TIME") - var time: Long = 0 -) \ No newline at end of file + var time: Long = 0, +) diff --git a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearchDao.kt b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearchDao.kt index df8901d8b..bfdd8bbf8 100644 --- a/app/src/main/java/com/hippo/ehviewer/dao/QuickSearchDao.kt +++ b/app/src/main/java/com/hippo/ehviewer/dao/QuickSearchDao.kt @@ -25,4 +25,4 @@ interface QuickSearchDao : BasicDao { @Delete fun delete(quickSearch: QuickSearch) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/download/DownloadManager.kt b/app/src/main/java/com/hippo/ehviewer/download/DownloadManager.kt index 06d33aa49..e5b07de65 100644 --- a/app/src/main/java/com/hippo/ehviewer/download/DownloadManager.kt +++ b/app/src/main/java/com/hippo/ehviewer/download/DownloadManager.kt @@ -826,7 +826,7 @@ object DownloadManager : OnSpiderListener { index: Int, contentLength: Long, receivedSize: Long, - bytesRead: Int + bytesRead: Int, ) { var task = mNotifyTaskPool.pop() if (task == null) { @@ -850,7 +850,7 @@ object DownloadManager : OnSpiderListener { error: String?, finished: Int, downloaded: Int, - total: Int + total: Int, ) { var task = mNotifyTaskPool.pop() if (task == null) { @@ -972,7 +972,7 @@ object DownloadManager : OnSpiderListener { index: Int, contentLength: Long, receivedSize: Long, - bytesRead: Int + bytesRead: Int, ) { mType = TYPE_ON_PAGE_DOWNLOAD mIndex = index @@ -994,7 +994,7 @@ object DownloadManager : OnSpiderListener { error: String?, finished: Int, downloaded: Int, - total: Int + total: Int, ) { mType = TYPE_ON_PAGE_FAILURE mIndex = index @@ -1038,7 +1038,7 @@ object DownloadManager : OnSpiderListener { mIndex, mContentLength, mReceivedSize, - mBytesRead + mBytesRead, ) TYPE_ON_PAGE_SUCCESS -> { @@ -1229,4 +1229,4 @@ object DownloadManager : OnSpiderListener { private fun MutableList.sortByDateDescending() { sortByDescending { it.time } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt index 2801b376a..d894f4636 100644 --- a/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt +++ b/app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt @@ -60,10 +60,10 @@ class DownloadService : Service(), DownloadManager.DownloadListener { mNotifyManager!!.createNotificationChannel( NotificationChannelCompat.Builder( mChannelID!!, - NotificationManagerCompat.IMPORTANCE_LOW + NotificationManagerCompat.IMPORTANCE_LOW, ) .setName(getString(R.string.download_service)) - .build() + .build(), ) mDownloadManager = DownloadManager mDownloadManager!!.setDownloadListener(this) @@ -166,7 +166,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { .addAction( R.drawable.v_pause_x24, getString(R.string.stat_download_action_stop_all), - piStopAll + piStopAll, ) .setShowWhen(false) .setChannelId(mChannelID!!) @@ -187,8 +187,10 @@ class DownloadService : Service(), DownloadManager.DownloadListener { activityIntent.action = ACTION_START_DOWNLOADSCENE activityIntent.putExtra(ACTION_START_DOWNLOADSCENE_ARGS, bundle) val piActivity = PendingIntent.getActivity( - this@DownloadService, 0, - activityIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + this@DownloadService, + 0, + activityIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) mDownloadedBuilder = NotificationCompat.Builder(applicationContext, mChannelID!!) .setSmallIcon(android.R.drawable.stat_sys_download_done) @@ -210,7 +212,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { .setContentText(getString(R.string.stat_509_alert_title)) .setContentText(getString(R.string.stat_509_alert_text)) .setStyle( - NotificationCompat.BigTextStyle().bigText(getString(R.string.stat_509_alert_text)) + NotificationCompat.BigTextStyle().bigText(getString(R.string.stat_509_alert_text)), ) .setAutoCancel(true) .setOngoing(false) @@ -241,8 +243,10 @@ class DownloadService : Service(), DownloadManager.DownloadListener { activityIntent.action = ACTION_START_DOWNLOADSCENE activityIntent.putExtra(ACTION_START_DOWNLOADSCENE_ARGS, bundle) val piActivity = PendingIntent.getActivity( - this@DownloadService, 0, - activityIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + this@DownloadService, + 0, + activityIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) mDownloadingBuilder!!.setContentTitle(EhUtils.getSuitableTitle(info)) .setContentText(null) @@ -267,7 +271,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { getString( R.string.download_speed_text_2, text, - ReadableTime.getShortTimeInterval(remaining) + ReadableTime.getShortTimeInterval(remaining), ) } else { getString(R.string.download_speed_text, text) @@ -327,7 +331,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { text = if (sItemTitleArray.size() >= 1) { getString( R.string.stat_download_done_line_succeeded, - sItemTitleArray.valueAt(0) + sItemTitleArray.valueAt(0), ) } else { Log.d("TAG", "WTF, sItemTitleArray is null") @@ -343,7 +347,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { text = if (sItemTitleArray.size() >= 1) { getString( R.string.stat_download_done_line_failed, - sItemTitleArray.valueAt(0) + sItemTitleArray.valueAt(0), ) } else { Log.d("TAG", "WTF, sItemTitleArray is null") @@ -376,8 +380,8 @@ class DownloadService : Service(), DownloadManager.DownloadListener { style.addLine( getString( if (fin) R.string.stat_download_done_line_succeeded else R.string.stat_download_done_line_failed, - title - ) + title, + ), ) i++ } @@ -413,7 +417,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { private var mService: Service, private val mNotifyManager: NotificationManagerCompat, private val mBuilder: NotificationCompat.Builder, - private val mId: Int + private val mId: Int, ) : Runnable { private var mLastTime: Long = 0 private var mPosted = false @@ -431,7 +435,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { // Wait long enough, do it now if (ActivityCompat.checkSelfPermission( mService, - Manifest.permission.POST_NOTIFICATIONS + Manifest.permission.POST_NOTIFICATIONS, ) != PackageManager.PERMISSION_GRANTED ) { return @@ -487,7 +491,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener { OPS_NOTIFY -> { if (ActivityCompat.checkSelfPermission( mService, - Manifest.permission.POST_NOTIFICATIONS + Manifest.permission.POST_NOTIFICATIONS, ) != PackageManager.PERMISSION_GRANTED ) { return @@ -547,4 +551,4 @@ class DownloadService : Service(), DownloadManager.DownloadListener { sItemTitleArray.clear() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/EhPageLoader.kt b/app/src/main/java/com/hippo/ehviewer/gallery/EhPageLoader.kt index 0da19f632..8be745ea3 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/EhPageLoader.kt +++ b/app/src/main/java/com/hippo/ehviewer/gallery/EhPageLoader.kt @@ -48,7 +48,7 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi "%d-%s-%08d", mGalleryInfo.gid, mGalleryInfo.token, - index + 1 + index + 1, ) } @@ -61,7 +61,7 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi mGalleryInfo.gid, mGalleryInfo.token, index + 1, - extension + extension, ) } return String.format( @@ -69,7 +69,7 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi "%d-%s-%08d", mGalleryInfo.gid, mGalleryInfo.token, - index + 1 + index + 1, ) } @@ -115,7 +115,7 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi index: Int, contentLength: Long, receivedSize: Long, - bytesRead: Int + bytesRead: Int, ) { if (contentLength > 0) { notifyPagePercent(index, receivedSize.toFloat() / contentLength) @@ -128,7 +128,7 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi error: String?, finished: Int, downloaded: Int, - total: Int + total: Int, ) { notifyPageFailed(index, error) } @@ -152,4 +152,4 @@ class EhPageLoader(private val mGalleryInfo: GalleryInfo) : PageLoader2(), OnSpi mSpiderQueen = null } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/PageLoader2.kt b/app/src/main/java/com/hippo/ehviewer/gallery/PageLoader2.kt index 6cb1d61d0..926d28dde 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/PageLoader2.kt +++ b/app/src/main/java/com/hippo/ehviewer/gallery/PageLoader2.kt @@ -42,7 +42,7 @@ abstract class PageLoader2 : PageLoader() { } val SUPPORT_IMAGE_EXTENSIONS = arrayOf( - ".jpg", // Joint Photographic Experts Group - ".png", // Portable Network Graphics - ".gif" + ".jpg", // Joint Photographic Experts Group + ".png", // Portable Network Graphics + ".gif", ) diff --git a/app/src/main/java/com/hippo/ehviewer/legacy/CleanupObsoleteCache.kt b/app/src/main/java/com/hippo/ehviewer/legacy/CleanupObsoleteCache.kt index cbe3a5227..559cfa12d 100644 --- a/app/src/main/java/com/hippo/ehviewer/legacy/CleanupObsoleteCache.kt +++ b/app/src/main/java/com/hippo/ehviewer/legacy/CleanupObsoleteCache.kt @@ -9,7 +9,7 @@ private val OBSOLETE_CACHE_DIRS = arrayOf( "image", "thumb", "gallery_image", - "spider_info" + "spider_info", ) @OptIn(DelicateCoroutinesApi::class) diff --git a/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt index 3a266aeb2..d0e5212e2 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt @@ -33,7 +33,8 @@ import okhttp3.HttpUrl.Companion.toHttpUrl import java.util.LinkedList class AccountPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : MessagePreference(context, attrs) { private val mActivity = context as SettingsActivity private var message: String? = null @@ -59,16 +60,19 @@ class AccountPreference @JvmOverloads constructor( i++ } if (ipbMemberId != null || ipbPassHash != null || igneous != null) { - message = (EhCookieStore.KEY_IPB_MEMBER_ID + ": " + ipbMemberId + "
" - + EhCookieStore.KEY_IPB_PASS_HASH + ": " + ipbPassHash + "
" - + EhCookieStore.KEY_IGNEOUS + ": " + igneous) + message = ( + EhCookieStore.KEY_IPB_MEMBER_ID + ": " + ipbMemberId + "
" + + EhCookieStore.KEY_IPB_PASS_HASH + ": " + ipbPassHash + "
" + + EhCookieStore.KEY_IGNEOUS + ": " + igneous + ) setDialogMessage( Html.fromHtml( context.getString( R.string.settings_eh_identity_cookies_signed, - message - ), Html.FROM_HTML_MODE_LEGACY - ) + message, + ), + Html.FROM_HTML_MODE_LEGACY, + ), ) message = message!!.replace("
", "\n") } else { @@ -89,4 +93,4 @@ class AccountPreference @JvmOverloads constructor( mActivity.showTip(R.string.settings_eh_sign_out_tip, BaseScene.LENGTH_SHORT) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/preference/CleanRedundancyPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/CleanRedundancyPreference.kt index 4dd6ab2b0..453322af7 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/CleanRedundancyPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/CleanRedundancyPreference.kt @@ -17,7 +17,6 @@ package com.hippo.ehviewer.preference import android.content.Context import android.util.AttributeSet -import com.hippo.ehviewer.download.DownloadManager as downloadManager import com.hippo.ehviewer.GetText import com.hippo.ehviewer.R import com.hippo.ehviewer.Settings @@ -26,6 +25,7 @@ import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.lang.withUIContext import kotlinx.coroutines.Job import kotlinx.coroutines.launch +import com.hippo.ehviewer.download.DownloadManager as downloadManager private val NO_REDUNDANCY = GetText.getString(R.string.settings_download_clean_redundancy_no_redundancy) @@ -35,7 +35,8 @@ private val FINAL_CLEAR_REDUNDANCY_MSG = { cnt: Int -> if (cnt == 0) NO_REDUNDANCY else CLEAR_REDUNDANCY_DONE(cnt) } class CleanRedundancyPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : TaskPreference(context, attrs) { private fun clearFile(file: UniFile): Boolean { var name = file.name ?: return false @@ -56,16 +57,19 @@ class CleanRedundancyPreference @JvmOverloads constructor( } override fun launchJob() { - if (singletonJob?.isActive == true) singletonJob?.invokeOnCompletion { - launchUI { - dialog.dismiss() + if (singletonJob?.isActive == true) { + singletonJob?.invokeOnCompletion { + launchUI { + dialog.dismiss() + } } - } - else singletonJob = launch { - val cnt = doRealWork() - withUIContext { - showTip(FINAL_CLEAR_REDUNDANCY_MSG(cnt)) - dialog.dismiss() + } else { + singletonJob = launch { + val cnt = doRealWork() + withUIContext { + showTip(FINAL_CLEAR_REDUNDANCY_MSG(cnt)) + dialog.dismiss() + } } } } diff --git a/app/src/main/java/com/hippo/ehviewer/preference/ImageLimitsPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/ImageLimitsPreference.kt index 1c854f474..acbe4a52f 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/ImageLimitsPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/ImageLimitsPreference.kt @@ -71,7 +71,7 @@ class ImageLimitsPreference(context: Context, attrs: AttributeSet) : val (fundsGP, fundsC) = mActivity.mFunds!! val cost = if (fundsGP >= resetCost) "$resetCost GP" else "$resetCost Credits" val message = mActivity.getString(R.string.current_limits, "$current / $maximum", cost) + - "\n" + mActivity.getString(R.string.current_funds, "$fundsGP+", fundsC) + "\n" + mActivity.getString(R.string.current_funds, "$fundsGP+", fundsC) mDialog.setMessage(message) resetButton.isEnabled = resetCost in 1..maxOf(fundsGP, fundsC) } @@ -83,4 +83,4 @@ class ImageLimitsPreference(context: Context, attrs: AttributeSet) : mActivity.resetImageLimits() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/preference/ProxyPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/ProxyPreference.kt index 9ff186c78..0fd54edf3 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/ProxyPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/ProxyPreference.kt @@ -35,7 +35,8 @@ import com.hippo.yorozuya.MathUtils import com.hippo.yorozuya.ViewUtils class ProxyPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : DialogPreference(context, attrs), View.OnClickListener { private var mType: TextInputLayout? = null private var mIpInputLayout: TextInputLayout? = null @@ -56,8 +57,8 @@ class ProxyPreference @JvmOverloads constructor( private fun updateSummary(type: Int, ip: String?, port: Int) { var type1 = type - if ((type1 == EhProxySelector.TYPE_HTTP || type1 == EhProxySelector.TYPE_SOCKS) - && (TextUtils.isEmpty(ip) || !InetValidator.isValidInetPort(port)) + if ((type1 == EhProxySelector.TYPE_HTTP || type1 == EhProxySelector.TYPE_SOCKS) && + (TextUtils.isEmpty(ip) || !InetValidator.isValidInetPort(port)) ) { type1 = EhProxySelector.TYPE_SYSTEM } @@ -67,13 +68,13 @@ class ProxyPreference @JvmOverloads constructor( R.string.settings_advanced_proxy_summary_1, getProxyTypeText(type1), ip, - port + port, ) } else { val context = context context.getString( R.string.settings_advanced_proxy_summary_2, - getProxyTypeText(type1) + getProxyTypeText(type1), ) } } @@ -95,11 +96,14 @@ class ProxyPreference @JvmOverloads constructor( mPort = ViewUtils.`$$`(dialog, R.id.port) as EditText val type = Settings.proxyType (mType!!.editText as AutoCompleteTextView).setText( - array[MathUtils.clamp( - type, - 0, - array.size - )], false + array[ + MathUtils.clamp( + type, + 0, + array.size, + ), + ], + false, ) mIp!!.setText(Settings.proxyIp) val portString: String? @@ -164,4 +168,4 @@ class ProxyPreference @JvmOverloads constructor( EhApplication.ehProxySelector.updateProxy() dialog.dismiss() } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/preference/RestoreDownloadPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/RestoreDownloadPreference.kt index ff4e42279..90642f506 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/RestoreDownloadPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/RestoreDownloadPreference.kt @@ -17,7 +17,6 @@ package com.hippo.ehviewer.preference import android.content.Context import android.util.AttributeSet -import com.hippo.ehviewer.download.DownloadManager as downloadManager import com.hippo.ehviewer.EhDB import com.hippo.ehviewer.GetText import com.hippo.ehviewer.R @@ -35,6 +34,7 @@ import eu.kanade.tachiyomi.util.lang.withUIContext import kotlinx.coroutines.Job import kotlinx.coroutines.launch import moe.tarsin.coroutines.runSuspendCatching +import com.hippo.ehviewer.download.DownloadManager as downloadManager private val RESTORE_NOT_FOUND = GetText.getString(R.string.settings_download_restore_not_found) private val RESTORE_FAILED = GetText.getString(R.string.settings_download_restore_failed) @@ -42,7 +42,8 @@ private val RESTORE_COUNT_MSG = { cnt: Int -> if (cnt == 0) RESTORE_NOT_FOUND else GetText.getString(R.string.settings_download_restore_successfully, cnt) } class RestoreDownloadPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : TaskPreference(context, attrs) { private val mManager: DownloadManager = downloadManager private var restoreDirCount = 0 @@ -88,39 +89,42 @@ class RestoreDownloadPreference @JvmOverloads constructor( } override fun launchJob() { - if (singletonJob?.isActive == true) singletonJob?.invokeOnCompletion { - launchUI { - dialog.dismiss() + if (singletonJob?.isActive == true) { + singletonJob?.invokeOnCompletion { + launchUI { + dialog.dismiss() + } } - } - else singletonJob = launch { - val result = doRealWork() - withUIContext { - if (result == null) { - showTip(RESTORE_FAILED) - } else { - if (result.isEmpty()) { - showTip(RESTORE_COUNT_MSG(restoreDirCount)) + } else { + singletonJob = launch { + val result = doRealWork() + withUIContext { + if (result == null) { + showTip(RESTORE_FAILED) } else { - var count = 0 - var i = 0 - val n = result.size - while (i < n) { - val item = result[i] - // Avoid failed gallery info - if (null != item.title) { - // Put to download - mManager.addDownload(item, null) - // Put download dir to DB - EhDB.putDownloadDirname(item.gid, (item as RestoreItem).dirname) - count++ + if (result.isEmpty()) { + showTip(RESTORE_COUNT_MSG(restoreDirCount)) + } else { + var count = 0 + var i = 0 + val n = result.size + while (i < n) { + val item = result[i] + // Avoid failed gallery info + if (null != item.title) { + // Put to download + mManager.addDownload(item, null) + // Put download dir to DB + EhDB.putDownloadDirname(item.gid, (item as RestoreItem).dirname) + count++ + } + i++ } - i++ + showTip(RESTORE_COUNT_MSG(count + restoreDirCount)) } - showTip(RESTORE_COUNT_MSG(count + restoreDirCount)) } + dialog.dismiss() } - dialog.dismiss() } } } diff --git a/app/src/main/java/com/hippo/ehviewer/preference/TaskPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/TaskPreference.kt index 239e24037..4181c0144 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/TaskPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/TaskPreference.kt @@ -27,7 +27,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job abstract class TaskPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : DialogPreference(context, attrs), CoroutineScope { override val coroutineContext = Dispatchers.IO + Job() protected lateinit var dialog: AlertDialog @@ -47,7 +48,7 @@ abstract class TaskPreference @JvmOverloads constructor( protected fun showTip(msg: String) { (context as SettingsActivity).showTip( msg, - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ) } } diff --git a/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.kt index 7cb45a656..b3f4d228c 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/VersionPreference.kt @@ -22,11 +22,12 @@ import com.hippo.ehviewer.BuildConfig import com.hippo.ehviewer.R class VersionPreference @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : Preference(context, attrs) { init { setTitle(R.string.settings_about_version) summary = "${BuildConfig.VERSION_NAME} (${BuildConfig.COMMIT_SHA})\n" + - context.getString(R.string.settings_about_build_time, BuildConfig.BUILD_TIME) + context.getString(R.string.settings_about_build_time, BuildConfig.BUILD_TIME) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt b/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt index fa71857d4..7cfacd2f2 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderDen.kt @@ -30,9 +30,9 @@ import com.hippo.ehviewer.coil.read import com.hippo.ehviewer.gallery.SUPPORT_IMAGE_EXTENSIONS import com.hippo.image.Image.CloseableSource import com.hippo.image.rewriteGifSource2 -import com.hippo.util.sendTo import com.hippo.unifile.UniFile import com.hippo.unifile.openOutputStream +import com.hippo.util.sendTo import com.hippo.yorozuya.FileUtils import io.ktor.client.plugins.onDownload import io.ktor.client.request.prepareGet @@ -136,7 +136,7 @@ class SpiderDen(private val mGalleryInfo: GalleryInfo) { index: Int, url: String, referer: String?, - notifyProgress: (Long, Long, Int) -> Unit + notifyProgress: (Long, Long, Int) -> Unit, ): Boolean { return client.prepareGet(url) { var state: Long = 0 @@ -161,10 +161,11 @@ class SpiderDen(private val mGalleryInfo: GalleryInfo) { outFile.openOutputStream().use { ret = body.bodyAsChannel().copyTo(it.channel) } - if (contentType == ContentType.Image.GIF) + if (contentType == ContentType.Image.GIF) { outFile.openFileDescriptor("rw").use { rewriteGifSource2(it.fd) } + } return ret } diff --git a/app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.kt b/app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.kt index 090683610..34aa1570c 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderInfo.kt @@ -26,7 +26,7 @@ class SpiderInfo @JvmOverloads constructor( var previewPages: Int = -1, - var previewPerPage: Int = -1 + var previewPerPage: Int = -1, ) fun SpiderInfo.write(file: UniFile) { diff --git a/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt b/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt index b6d5405a8..da847daa7 100644 --- a/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt +++ b/app/src/main/java/com/hippo/ehviewer/spider/SpiderQueen.kt @@ -20,7 +20,6 @@ import android.util.Log import androidx.annotation.IntDef import androidx.collection.LongSparseArray import androidx.collection.set -import com.hippo.ehviewer.EhApplication.Companion.okHttpClient as plainTextOkHttpClient import com.hippo.ehviewer.GetText import com.hippo.ehviewer.R import com.hippo.ehviewer.Settings @@ -33,8 +32,8 @@ import com.hippo.ehviewer.client.EhUrl.referer import com.hippo.ehviewer.client.data.GalleryInfo import com.hippo.ehviewer.client.exception.ParseException import com.hippo.ehviewer.client.parser.GalleryDetailParser.parsePages -import com.hippo.ehviewer.client.parser.GalleryDetailParser.parsePreviewPages import com.hippo.ehviewer.client.parser.GalleryDetailParser.parsePreviewList +import com.hippo.ehviewer.client.parser.GalleryDetailParser.parsePreviewPages import com.hippo.ehviewer.client.parser.GalleryMultiPageViewerPTokenParser import com.hippo.ehviewer.client.parser.GalleryPageUrlParser import com.hippo.image.Image @@ -57,6 +56,7 @@ import moe.tarsin.coroutines.runSuspendCatching import okhttp3.executeAsync import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicInteger +import com.hippo.ehviewer.EhApplication.Companion.okHttpClient as plainTextOkHttpClient class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineScope { override val coroutineContext = Dispatchers.IO + Job() @@ -103,7 +103,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS index, contentLength, receivedSize, - bytesRead + bytesRead, ) } } @@ -116,7 +116,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS index, mFinishedPages.get(), mDownloadedPages.get(), - mPageStateArray.size + mPageStateArray.size, ) } } @@ -130,7 +130,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS error, mFinishedPages.get(), mDownloadedPages.get(), - mPageStateArray.size + mPageStateArray.size, ) } } @@ -142,7 +142,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS it.onFinish( mFinishedPages.get(), mDownloadedPages.get(), - mPageStateArray.size + mPageStateArray.size, ) } } @@ -298,7 +298,9 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS val state = getPageState(index) return if (STATE_FINISHED != state) { false - } else mSpiderDen.saveToUniFile(index, file) + } else { + mSpiderDen.saveToUniFile(index, file) + } } fun save(index: Int, dir: UniFile, filename: String): UniFile? { @@ -315,7 +317,9 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS val state = getPageState(index) return if (STATE_FINISHED != state) { null - } else mSpiderDen.getExtension(index) + } else { + mSpiderDen.getExtension(index) + } } val startPage: Int @@ -358,8 +362,12 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS private suspend fun readSpiderInfoFromInternet(): SpiderInfo? { val request = EhRequestBuilder( getGalleryDetailUrl( - galleryInfo.gid, galleryInfo.token, 0, false - ), referer + galleryInfo.gid, + galleryInfo.token, + 0, + false, + ), + referer, ).build() return runSuspendCatching { plainTextOkHttpClient.newCall(request).executeAsync().use { response -> @@ -378,7 +386,8 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS suspend fun getPTokenFromMultiPageViewer(index: Int): String? { val spiderInfo = mSpiderInfo val url = getGalleryMultiPageViewerUrl( - galleryInfo.gid, galleryInfo.token!! + galleryInfo.gid, + galleryInfo.token!!, ) val referer = referer val request = EhRequestBuilder(url, referer).build() @@ -411,7 +420,10 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS previewIndex = previewIndex.coerceAtMost(spiderInfo.previewPages - 1) } val url = getGalleryDetailUrl( - galleryInfo.gid, galleryInfo.token, previewIndex, false + galleryInfo.gid, + galleryInfo.token, + previewIndex, + false, ) val referer = referer val request = EhRequestBuilder(url, referer).build() @@ -552,12 +564,14 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS if (isDownloadMode) return synchronized(mFetcherJobMap) { mFetcherJobMap.forEach { (i, job) -> - if (i < cancelBounds.first || i > cancelBounds.second) + if (i < cancelBounds.first || i > cancelBounds.second) { job.cancel() + } } list.forEach { - if (mFetcherJobMap[it]?.isActive != true) + if (mFetcherJobMap[it]?.isActive != true) { doLaunchDownloadJob(it, false) + } } } } @@ -615,7 +629,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS pToken = getPToken(index) ?: return updatePageState( index, STATE_FAILED, - PTOKEN_FAILED_MESSAGE + PTOKEN_FAILED_MESSAGE, ).also { mSpiderInfo.pTokenMap[index] = TOKEN_FAILED } @@ -697,7 +711,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS index, pToken, localShowKey, - previousPToken + previousPToken, ).also { if (check509(it.imageUrl)) { // Get 509 @@ -742,7 +756,7 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS val success: Boolean = mSpiderDen.makeHttpCallAndSaveImage( index, targetImageUrl, - referer + referer, ) { contentLength: Long, receivedSize: Long, bytesRead: Int -> mPagePercentMap[index] = receivedSize.toFloat() / contentLength notifyPageDownload(index, contentLength, receivedSize, bytesRead) @@ -826,8 +840,8 @@ private val URL_509_ARRAY = arrayOf( "https://ehgt.org/g/509.gif", "https://ehgt.org/g/509s.gif", "https://exhentai.org/img/509.gif", - "https://exhentai.org/img/509s.gif" + "https://exhentai.org/img/509s.gif", ) private const val WORKER_DEBUG_TAG = "SpiderQueenWorker" -private fun check509(url: String) = url in URL_509_ARRAY \ No newline at end of file +private fun check509(url: String) = url in URL_509_ARRAY diff --git a/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.kt b/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.kt index 5c14afb58..e54bc020a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/CommonOperations.kt @@ -39,8 +39,10 @@ import com.hippo.ehviewer.download.DownloadManager as downloadManager object CommonOperations { private fun doAddToFavorites( - activity: Activity, galleryInfo: GalleryInfo, - slot: Int, listener: EhClient.Callback + activity: Activity, + galleryInfo: GalleryInfo, + slot: Int, + listener: EhClient.Callback, ) { when (slot) { -1 -> { @@ -64,8 +66,10 @@ object CommonOperations { @JvmOverloads fun addToFavorites( - activity: Activity, galleryInfo: GalleryInfo, - listener: EhClient.Callback, select: Boolean = false + activity: Activity, + galleryInfo: GalleryInfo, + listener: EhClient.Callback, + select: Boolean = false, ) { val slot = Settings.defaultFavSlot val localFav = activity.getString(R.string.local_favorites) @@ -76,11 +80,12 @@ object CommonOperations { activity, galleryInfo, slot, - DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot) + DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot), ) } else { ListCheckBoxDialogBuilder( - activity, items, + activity, + items, { builder: ListCheckBoxDialogBuilder?, _: AlertDialog?, position: Int -> val slot1 = position - 1 val newFavoriteName = if (slot1 in 0..9) items[slot1 + 1] else null @@ -88,14 +93,16 @@ object CommonOperations { activity, galleryInfo, slot1, - DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot1) + DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot1), ) if (builder?.isChecked == true) { Settings.putDefaultFavSlot(slot1) } else { Settings.putDefaultFavSlot(Settings.INVALID_DEFAULT_FAV_SLOT) } - }, activity.getString(R.string.remember_favorite_collection), false + }, + activity.getString(R.string.remember_favorite_collection), + false, ) .setTitle(R.string.add_favorites_dialog_title) .setOnCancelListener { listener.onCancel() } @@ -104,8 +111,9 @@ object CommonOperations { } fun removeFromFavorites( - activity: Activity?, galleryInfo: GalleryInfo, - listener: EhClient.Callback + activity: Activity?, + galleryInfo: GalleryInfo, + listener: EhClient.Callback, ) { EhDB.removeLocalFavorites(galleryInfo.gid) val request = EhRequest() @@ -122,7 +130,7 @@ object CommonOperations { fun startDownload( activity: MainActivity, galleryInfos: List, - forceDefault: Boolean + forceDefault: Boolean, ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { application.topActivity?.checkAndRequestNotificationPermission() @@ -133,7 +141,7 @@ object CommonOperations { private fun doStartDownload( activity: MainActivity, galleryInfos: List, - forceDefault: Boolean + forceDefault: Boolean, ) { val dm = downloadManager val toStart = LongList() @@ -185,7 +193,8 @@ object CommonOperations { items.add(activity.getString(R.string.default_download_label_name)) items.addAll(list.mapNotNull { it.label }) ListCheckBoxDialogBuilder( - activity, items, + activity, + items, { builder: ListCheckBoxDialogBuilder?, _: AlertDialog?, position: Int -> var label1: String? if (position == 0) { @@ -213,7 +222,9 @@ object CommonOperations { } // Notify activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT) - }, activity.getString(R.string.remember_download_label), false + }, + activity.getString(R.string.remember_download_label), + false, ) .setTitle(R.string.download) .show() @@ -221,8 +232,10 @@ object CommonOperations { } private class DelegateFavoriteCallback( - private val delegate: EhClient.Callback, private val info: GalleryInfo, - private val newFavoriteName: String?, private val slot: Int + private val delegate: EhClient.Callback, + private val info: GalleryInfo, + private val newFavoriteName: String?, + private val slot: Int, ) : EhClient.Callback { override fun onSuccess(result: Unit) { info.favoriteName = newFavoriteName diff --git a/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.kt b/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.kt index a9d7576b3..cd09c3d99 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/EhActivity.kt @@ -80,9 +80,11 @@ abstract class EhActivity : AppCompatActivity() { fun checkAndRequestNotificationPermission() { if (ContextCompat.checkSelfPermission( this, - Manifest.permission.POST_NOTIFICATIONS + Manifest.permission.POST_NOTIFICATIONS, ) == PackageManager.PERMISSION_GRANTED - ) return + ) { + return + } if (Settings.notificationRequired) return requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt b/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt index 72cca5dce..697439a7a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt @@ -40,7 +40,7 @@ class GalleryInfoBottomSheet(detail: GalleryDetail) : BottomSheetDialogFragment( override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View? { parseDetail() val view = inflater.inflate(R.layout.scene_gallery_info, container, false) @@ -155,8 +155,8 @@ class GalleryInfoBottomSheet(detail: GalleryDetail) : BottomSheetDialogFragment( mInflater.inflate( if (viewType == TYPE_HEADER) R.layout.item_gallery_info_header else R.layout.item_gallery_info_data, parent, - false - ) + false, + ), ) } @@ -179,4 +179,4 @@ class GalleryInfoBottomSheet(detail: GalleryDetail) : BottomSheetDialogFragment( private const val TYPE_HEADER = 0 private const val TYPE_DATA = 1 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.kt b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.kt index c638a330c..601ccb9d5 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/MainActivity.kt @@ -122,7 +122,7 @@ class MainActivity : EhActivity() { override fun onBackPressed() { check(Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) val isDrawerOpen = binding.drawView.isDrawerOpen(GravityCompat.START) or - binding.drawView.isDrawerOpen(GravityCompat.END) + binding.drawView.isDrawerOpen(GravityCompat.END) if (isDrawerOpen) { binding.drawView.closeDrawers() } else { @@ -142,7 +142,7 @@ class MainActivity : EhActivity() { .setPositiveButton(android.R.string.copy) { _: DialogInterface?, _: Int -> this@MainActivity.addTextToClipboard( url, - false + false, ) } .show() @@ -167,7 +167,7 @@ class MainActivity : EhActivity() { val args = Bundle() args.putString( GalleryListScene.KEY_ACTION, - GalleryListScene.ACTION_LIST_URL_BUILDER + GalleryListScene.ACTION_LIST_URL_BUILDER, ) args.putParcelable(GalleryListScene.KEY_LIST_URL_BUILDER, listUrlBuilder) navController.navigate(R.id.galleryListScene, args) @@ -201,7 +201,7 @@ class MainActivity : EhActivity() { builder.keyword = intent.getStringExtra(Intent.EXTRA_TEXT) navController.navigate( R.id.galleryListScene, - builder.toStartArgs() + builder.toStartArgs(), ) return true } else if (type != null && type.startsWith("image/")) { @@ -215,7 +215,7 @@ class MainActivity : EhActivity() { builder.isUseSimilarityScan = true navController.navigate( R.id.galleryListScene, - builder.toStartArgs() + builder.toStartArgs(), ) return true } @@ -329,13 +329,13 @@ class MainActivity : EhActivity() { try { val intent = Intent( android.provider.Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS, - Uri.parse("package:$packageName") + Uri.parse("package:$packageName"), ) startActivity(intent) } catch (t: Throwable) { val intent = Intent( android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, - Uri.parse("package:$packageName") + Uri.parse("package:$packageName"), ) startActivity(intent) } @@ -343,7 +343,7 @@ class MainActivity : EhActivity() { .setNegativeButton(android.R.string.cancel, null) .setNeutralButton(R.string.dont_show_again) { _: DialogInterface?, _: Int -> Settings.putAppLinkVerifyTip( - true + true, ) } .show() @@ -369,7 +369,7 @@ class MainActivity : EhActivity() { Snackbar.make( binding.drawView, R.string.metered_network_warning, - Snackbar.LENGTH_LONG + Snackbar.LENGTH_LONG, ) .setAction(R.string.settings) { val panelIntent = @@ -430,7 +430,7 @@ class MainActivity : EhActivity() { val snackbar = Snackbar.make( binding.drawView, R.string.clipboard_gallery_url_snack_message, - Snackbar.LENGTH_SHORT + Snackbar.LENGTH_SHORT, ) snackbar.setAction(R.string.clipboard_gallery_url_snack_action) { it() @@ -447,18 +447,20 @@ class MainActivity : EhActivity() { if (scene is BaseScene) { binding.rightDrawer.removeAllViews() val drawerView = scene.createDrawerView( - scene.layoutInflater, binding.rightDrawer, null + scene.layoutInflater, + binding.rightDrawer, + null, ) if (drawerView != null) { binding.rightDrawer.addView(drawerView) binding.drawView.setDrawerLockMode( DrawerLayout.LOCK_MODE_UNLOCKED, - GravityCompat.END + GravityCompat.END, ) } else { binding.drawView.setDrawerLockMode( DrawerLayout.LOCK_MODE_LOCKED_CLOSED, - GravityCompat.END + GravityCompat.END, ) } } @@ -510,12 +512,14 @@ class MainActivity : EhActivity() { fun showTip(message: CharSequence, length: Int, useToast: Boolean = false) { findViewById(R.id.snackbar)?.takeUnless { useToast }?.apply { Snackbar.make( - this, message, - if (length == BaseScene.LENGTH_LONG) Snackbar.LENGTH_LONG else Snackbar.LENGTH_SHORT + this, + message, + if (length == BaseScene.LENGTH_LONG) Snackbar.LENGTH_LONG else Snackbar.LENGTH_SHORT, ).show() } ?: Toast.makeText( - this, message, - if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT + this, + message, + if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT, ).show() } @@ -540,9 +544,9 @@ class MainActivity : EhActivity() { availableNetworks.remove(network) if (network == activeNetwork) { connectivityManager.bindProcessToNetwork( - availableNetworks.takeIf { it.isNotEmpty() }?.last() + availableNetworks.takeIf { it.isNotEmpty() }?.last(), ) } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/SecurityActivity.kt b/app/src/main/java/com/hippo/ehviewer/ui/SecurityActivity.kt index 2bf5f83ec..0f6031df8 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/SecurityActivity.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/SecurityActivity.kt @@ -39,10 +39,11 @@ fun Context.isAuthenticationSupported(): Boolean { class SecurityActivity : AppCompatActivity() { override fun onResume() { super.onResume() - if (isAuthenticationSupported()) + if (isAuthenticationSupported()) { startAuthentication(getString(R.string.settings_privacy_require_unlock)) - else + } else { onSuccess() + } } @Synchronized @@ -61,8 +62,8 @@ class SecurityActivity : AppCompatActivity() { callback = callback( { _, _, _ -> onFailed() }, { _, _ -> onSuccess() }, - { onFailed() } - ) + { onFailed() }, + ), ) } @@ -70,25 +71,25 @@ class SecurityActivity : AppCompatActivity() { crossinline onAuthenticationError: ( activity: FragmentActivity?, errorCode: Int, - errString: CharSequence + errString: CharSequence, ) -> Unit, crossinline onAuthenticationSucceeded: ( activity: FragmentActivity?, - result: BiometricPrompt.AuthenticationResult + result: BiometricPrompt.AuthenticationResult, ) -> Unit, crossinline onAuthenticationFailed: ( - activity: FragmentActivity? - ) -> Unit + activity: FragmentActivity?, + ) -> Unit, ) = object : AuthPromptCallback() { override fun onAuthenticationError( activity: FragmentActivity?, errorCode: Int, - errString: CharSequence + errString: CharSequence, ) = onAuthenticationError(activity, errorCode, errString) override fun onAuthenticationSucceeded( activity: FragmentActivity?, - result: BiometricPrompt.AuthenticationResult + result: BiometricPrompt.AuthenticationResult, ) = onAuthenticationSucceeded(activity, result) override fun onAuthenticationFailed(activity: FragmentActivity?) = @@ -109,4 +110,4 @@ class SecurityActivity : AppCompatActivity() { companion object { private var isAuthenticating = false } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.kt b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.kt index 21d68f4d6..0c7772fc1 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/SettingsActivity.kt @@ -87,8 +87,9 @@ class SettingsActivity : EhActivity() { fun showTip(message: CharSequence?, length: Int) { Snackbar.make( - findViewById(R.id.snackbar), message!!, - if (length == BaseScene.LENGTH_LONG) Snackbar.LENGTH_LONG else Snackbar.LENGTH_SHORT + findViewById(R.id.snackbar), + message!!, + if (length == BaseScene.LENGTH_LONG) Snackbar.LENGTH_LONG else Snackbar.LENGTH_SHORT, ).show() } @@ -116,4 +117,4 @@ class SettingsActivity : EhActivity() { super.finish() ActivityNavigator.applyPopAnimationsToPendingTransition(this) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.kt index 8c94c85a4..aea17432c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/AdvancedFragment.kt @@ -60,7 +60,7 @@ import com.hippo.ehviewer.Settings as AppSettings class AdvancedFragment : BasePreferenceFragment() { private var exportLauncher = registerForActivityResult( - ActivityResultContracts.CreateDocument("application/vnd.sqlite3") + ActivityResultContracts.CreateDocument("application/vnd.sqlite3"), ) { uri: Uri? -> if (uri != null) { try { @@ -68,7 +68,7 @@ class AdvancedFragment : BasePreferenceFragment() { requireActivity().grantUriPermission( BuildConfig.APPLICATION_ID, uri, - Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_WRITE_URI_PERMISSION, ) } catch (e: Exception) { ExceptionUtils.throwIfFatal(e) @@ -86,11 +86,15 @@ class AdvancedFragment : BasePreferenceFragment() { alertDialog.dismiss() } showTip( - if (success) GetText.getString( - R.string.settings_advanced_export_data_to, - uri.toString() - ) else GetText.getString(R.string.settings_advanced_export_data_failed), - BaseScene.LENGTH_SHORT + if (success) { + GetText.getString( + R.string.settings_advanced_export_data_to, + uri.toString(), + ) + } else { + GetText.getString(R.string.settings_advanced_export_data_failed) + }, + BaseScene.LENGTH_SHORT, ) } } @@ -100,7 +104,7 @@ class AdvancedFragment : BasePreferenceFragment() { } } private var dumpLogcatLauncher = registerForActivityResult( - ActivityResultContracts.CreateDocument("application/zip") + ActivityResultContracts.CreateDocument("application/zip"), ) { uri: Uri? -> if (uri != null) { try { @@ -108,7 +112,7 @@ class AdvancedFragment : BasePreferenceFragment() { requireActivity().grantUriPermission( BuildConfig.APPLICATION_ID, uri, - Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_WRITE_URI_PERMISSION, ) } catch (e: Exception) { ExceptionUtils.throwIfFatal(e) @@ -156,7 +160,7 @@ class AdvancedFragment : BasePreferenceFragment() { out.close() IOUtils.copy( FileInputStream(zipFile), - requireActivity().contentResolver.openOutputStream(uri) + requireActivity().contentResolver.openOutputStream(uri), ) finished = true } catch (e: Exception) { @@ -169,22 +173,26 @@ class AdvancedFragment : BasePreferenceFragment() { finished = LogCat.save(requireActivity().contentResolver.openOutputStream(uri)) } showTip( - if (finished) getString( - R.string.settings_advanced_dump_logcat_to, - uri.toString() - ) else getString(R.string.settings_advanced_dump_logcat_failed), - BaseScene.LENGTH_SHORT + if (finished) { + getString( + R.string.settings_advanced_dump_logcat_to, + uri.toString(), + ) + } else { + getString(R.string.settings_advanced_dump_logcat_failed) + }, + BaseScene.LENGTH_SHORT, ) } catch (e: Exception) { showTip( getString(R.string.settings_advanced_dump_logcat_failed), - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } } } private var importDataLauncher = registerForActivityResult, Uri>( - ActivityResultContracts.OpenDocument() + ActivityResultContracts.OpenDocument(), ) { uri: Uri? -> if (uri != null) { try { @@ -192,7 +200,7 @@ class AdvancedFragment : BasePreferenceFragment() { requireActivity().grantUriPermission( BuildConfig.APPLICATION_ID, uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION, ) } catch (e: Exception) { ExceptionUtils.throwIfFatal(e) @@ -212,7 +220,7 @@ class AdvancedFragment : BasePreferenceFragment() { if (null == error) { showTip( getString(R.string.settings_advanced_import_data_successfully), - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } else { showTip(error, BaseScene.LENGTH_SHORT) @@ -289,15 +297,16 @@ class AdvancedFragment : BasePreferenceFragment() { return true } else if (KEY_OPEN_BY_DEFAULT == key) { try { - @SuppressLint("InlinedApi") val intent = Intent( + @SuppressLint("InlinedApi") + val intent = Intent( Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS, - Uri.parse("package:" + requireContext().packageName) + Uri.parse("package:" + requireContext().packageName), ) startActivity(intent) } catch (t: Throwable) { val intent = Intent( Settings.ACTION_APPLICATION_DETAILS_SETTINGS, - Uri.parse("package:" + requireContext().packageName) + Uri.parse("package:" + requireContext().packageName), ) startActivity(intent) } @@ -319,7 +328,7 @@ class AdvancedFragment : BasePreferenceFragment() { if (result.galleryInfoList.isEmpty()) { showTip( R.string.settings_advanced_backup_favorite_nothing, - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } else { if (favTotal == 0 && result.countArray != null) { @@ -334,8 +343,9 @@ class AdvancedFragment : BasePreferenceFragment() { showTip( GetText.getString( R.string.settings_advanced_backup_favorite_start, - status - ), BaseScene.LENGTH_SHORT + status, + ), + BaseScene.LENGTH_SHORT, ) Log.d("LocalFavorites", "now backup page $status") EhDB.putLocalFavorites(result.galleryInfoList) @@ -357,14 +367,14 @@ class AdvancedFragment : BasePreferenceFragment() { } else { showTip( R.string.settings_advanced_backup_favorite_success, - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } } } catch (e: Exception) { showTip( R.string.settings_advanced_backup_favorite_failed, - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } } @@ -406,4 +416,4 @@ class AdvancedFragment : BasePreferenceFragment() { private const val KEY_OPEN_BY_DEFAULT = "open_by_default" private const val KEY_BACKUP_FAVORITE = "backup_favorite" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BaseFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BaseFragment.kt index f3597c5a5..3b0cc7c2c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BaseFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BaseFragment.kt @@ -70,4 +70,4 @@ abstract class BaseFragment : Fragment() { visibility = View.GONE } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt index 7d050396e..116d05659 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/BasePreferenceFragment.kt @@ -25,8 +25,10 @@ import androidx.preference.PreferenceFragmentCompat import com.hippo.ehviewer.R import com.hippo.ehviewer.ui.SettingsActivity -open class BasePreferenceFragment : PreferenceFragmentCompat(), - Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { +open class BasePreferenceFragment : + PreferenceFragmentCompat(), + Preference.OnPreferenceClickListener, + Preference.OnPreferenceChangeListener { override fun onStart() { super.onStart() setTitle(fragmentTitle) @@ -81,4 +83,4 @@ open class BasePreferenceFragment : PreferenceFragmentCompat(), fun showTip(message: CharSequence?, length: Int) { (requireActivity() as SettingsActivity).showTip(message, length) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.kt index 245906879..e43742f80 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/DownloadFragment.kt @@ -34,12 +34,12 @@ import eu.kanade.tachiyomi.util.lang.launchNonCancellable class DownloadFragment : BasePreferenceFragment() { private var mDownloadLocation: Preference? = null private var pickImageDirLauncher = registerForActivityResult( - ActivityResultContracts.OpenDocumentTree() + ActivityResultContracts.OpenDocumentTree(), ) { treeUri: Uri? -> if (treeUri != null) { requireActivity().contentResolver.takePersistableUriPermission( treeUri, - Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION, ) val uniFile = UniFile.fromTreeUri(activity, treeUri) if (uniFile != null) { @@ -51,7 +51,7 @@ class DownloadFragment : BasePreferenceFragment() { } else { showTip( R.string.settings_download_cant_get_download_location, - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } } @@ -89,7 +89,7 @@ class DownloadFragment : BasePreferenceFragment() { if (KEY_DOWNLOAD_LOCATION == key) { val file = Settings.downloadLocation if (file != null && !UniFile.isFileUri( - Settings.downloadLocation!!.uri + Settings.downloadLocation!!.uri, ) ) { BaseDialogBuilder(requireContext()) @@ -107,7 +107,7 @@ class DownloadFragment : BasePreferenceFragment() { } else { showTip( R.string.settings_download_cant_get_download_location, - BaseScene.LENGTH_SHORT + BaseScene.LENGTH_SHORT, ) } } @@ -148,4 +148,4 @@ class DownloadFragment : BasePreferenceFragment() { companion object { const val KEY_DOWNLOAD_LOCATION = "download_location" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/EhFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/EhFragment.kt index e2cd128c3..5d1de006e 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/EhFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/EhFragment.kt @@ -147,4 +147,4 @@ class EhFragment : BasePreferenceFragment() { @get:StringRes override val fragmentTitle: Int get() = R.string.settings_eh -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt index 1b668f769..8e6ee1c24 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/FilterFragment.kt @@ -68,7 +68,7 @@ class FilterFragment : BaseFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { val recyclerView = inflater.inflate(R.layout.rv_layout, container, false) as RecyclerView @@ -237,7 +237,7 @@ class FilterFragment : BaseFragment() { holder.itemView.setOnClickListener { mFilterList.trigger(filter) - //for updating delete line on filter text + // for updating delete line on filter text mAdapter.notifyItemChanged(position) } holder.delete?.setOnClickListener { showDeleteFilterDialog(filter) } @@ -253,7 +253,9 @@ class FilterFragment : BaseFragment() { val filter = mFilterList[position] if (filter.id != null) { (filter.text.hashCode() shr filter.mode) + filter.id!! - } else (filter.text.hashCode() shr filter.mode).toLong() + } else { + (filter.text.hashCode() shr filter.mode).toLong() + } } } } @@ -425,4 +427,4 @@ class FilterFragment : BaseFragment() { private const val TYPE_ITEM = 0 private const val TYPE_HEADER = 1 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt index 0cdf3fe4b..e4190dcc4 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/HostsFragment.kt @@ -52,7 +52,7 @@ class HostsFragment : BaseFragment(), View.OnClickListener { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { val recyclerView = inflater.inflate(R.layout.rv_layout, container, false) as RecyclerView val tip = getTipView(R.string.hosts) @@ -225,4 +225,4 @@ class HostsFragment : BaseFragment(), View.OnClickListener { private const val KEY_HOST = "com.hippo.ehviewer.ui.fragment.HostsFragment.HOST" private const val KEY_IP = "com.hippo.ehviewer.ui.fragment.HostsFragment.IP" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.kt index 35fcc0d35..dd45e4b61 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/PrivacyFragment.kt @@ -71,4 +71,4 @@ class PrivacyFragment : BasePreferenceFragment() { getString(R.string.settings_privacy_require_unlock_delay_summary, value.toString()) } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.kt b/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.kt index ddfde3b82..91d933c70 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/fragment/UConfigFragment.kt @@ -55,7 +55,7 @@ class UConfigFragment : BaseFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { _binding = ActivityWebviewBinding.inflate(inflater, container, false) binding.webview.run { @@ -74,21 +74,25 @@ class UConfigFragment : BaseFragment() { binding.progress.visibility = View.VISIBLE binding.webview.loadUrl(url) showTip(R.string.apply_tip, BaseScene.LENGTH_LONG) - requireActivity().addMenuProvider(object : MenuProvider { - override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { - menuInflater.inflate(R.menu.activity_u_config, menu) - } - - override fun onMenuItemSelected(menuItem: MenuItem): Boolean { - if (menuItem.itemId == R.id.action_apply) { - if (loaded) { - apply() - } - return true + requireActivity().addMenuProvider( + object : MenuProvider { + override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { + menuInflater.inflate(R.menu.activity_u_config, menu) } - return false - } - }, viewLifecycleOwner, Lifecycle.State.RESUMED) + + override fun onMenuItemSelected(menuItem: MenuItem): Boolean { + if (menuItem.itemId == R.id.action_apply) { + if (loaded) { + apply() + } + return true + } + return false + } + }, + viewLifecycleOwner, + Lifecycle.State.RESUMED, + ) } override fun onCreate(savedInstanceState: Bundle?) { @@ -112,7 +116,7 @@ class UConfigFragment : BaseFragment() { """javascript:(function() { var apply = document.getElementById("apply").children[0]; apply.click(); -})();""" +})();""", ) } @@ -170,4 +174,4 @@ class UConfigFragment : BaseFragment() { loaded = true } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/login/CookieSignInScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/login/CookieSignInScreen.kt index a66a703ad..9e14f7809 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/login/CookieSignInScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/login/CookieSignInScreen.kt @@ -187,12 +187,12 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { when (windowSizeClass.widthSizeClass) { WindowWidthSizeClass.Compact, WindowWidthSizeClass.Medium -> Box( - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Scaffold( snackbarHost = { SnackbarHost(hostState = snackbarHostState) - } + }, ) { padding -> Column( Modifier @@ -200,7 +200,7 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { .padding(padding) .fillMaxSize() .verticalScroll(rememberScrollState()), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Icon( imageVector = Icons.Default.Cookie, @@ -208,16 +208,16 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { modifier = Modifier .padding(dimensionResource(id = R.dimen.keyline_margin)) .size(48.dp), - tint = Color(0xff795548) + tint = Color(0xff795548), ) Text( text = stringResource(id = R.string.cookie_explain), modifier = Modifier .padding( horizontal = 32.dp, - vertical = dimensionResource(id = R.dimen.keyline_margin) + vertical = dimensionResource(id = R.dimen.keyline_margin), ), - fontSize = 16.sp + fontSize = 16.sp, ) OutlinedTextField( value = ipbMemberId, @@ -225,17 +225,19 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "ipb_member_id") }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), supportingText = { if (ipbMemberIdErrorState) Text(stringResource(R.string.text_is_empty)) }, trailingIcon = { - if (ipbMemberIdErrorState) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (ipbMemberIdErrorState) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, isError = ipbMemberIdErrorState, - singleLine = true + singleLine = true, ) OutlinedTextField( value = ipbPassHash, @@ -243,17 +245,19 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "ipb_pass_hash") }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), supportingText = { if (ipbPassHashErrorState) Text(stringResource(R.string.text_is_empty)) }, trailingIcon = { - if (ipbPassHashErrorState) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (ipbPassHashErrorState) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, isError = ipbPassHashErrorState, - singleLine = true + singleLine = true, ) OutlinedTextField( value = igneous, @@ -261,14 +265,14 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "igneous") }, keyboardActions = KeyboardActions( - onDone = { login() } + onDone = { login() }, ), - singleLine = true + singleLine = true, ) Spacer(modifier = Modifier.weight(1f)) Button( onClick = { login() }, - Modifier.fillMaxWidth() + Modifier.fillMaxWidth(), ) { Text(text = stringResource(id = android.R.string.ok)) } @@ -276,19 +280,20 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.from_clipboard)) } }, modifier = Modifier - .padding(horizontal = 8.dp) + .padding(horizontal = 8.dp), ) } } } - if (isProgressIndicatorVisible) + if (isProgressIndicatorVisible) { CircularProgressIndicator() + } if (showErrorDialog) { AlertDialog( onDismissRequest = { @@ -310,20 +315,20 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { """ ${ExceptionUtils.getReadableString(loginErrorException!!)} ${stringResource(R.string.wrong_cookie_warning)} - """.trimIndent() + """.trimIndent(), ) - } + }, ) } } WindowWidthSizeClass.Expanded -> Box( - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Scaffold( snackbarHost = { SnackbarHost(hostState = snackbarHostState) - } + }, ) { padding -> Row( Modifier @@ -331,13 +336,13 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { .padding(padding) .fillMaxSize() .verticalScroll(rememberScrollState()), - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { Column( Modifier .width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width)) .padding(dimensionResource(id = R.dimen.keyline_margin)), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Icon( imageVector = Icons.Default.Cookie, @@ -345,14 +350,14 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { modifier = Modifier .padding(dimensionResource(id = R.dimen.keyline_margin)) .size(48.dp), - tint = Color(0xff795548) + tint = Color(0xff795548), ) Text( text = stringResource(id = R.string.cookie_explain), Modifier .widthIn(max = dimensionResource(id = R.dimen.signinscreen_landscape_caption_text_width)) .padding(top = 24.dp), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } Column(Modifier.fillMaxWidth()) { @@ -362,17 +367,19 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "ipb_member_id") }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), supportingText = { if (ipbMemberIdErrorState) Text(stringResource(R.string.text_is_empty)) }, trailingIcon = { - if (ipbMemberIdErrorState) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (ipbMemberIdErrorState) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, isError = ipbMemberIdErrorState, - singleLine = true + singleLine = true, ) OutlinedTextField( value = ipbPassHash, @@ -380,17 +387,19 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "ipb_pass_hash") }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), supportingText = { if (ipbPassHashErrorState) Text(stringResource(R.string.text_is_empty)) }, trailingIcon = { - if (ipbPassHashErrorState) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (ipbPassHashErrorState) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, isError = ipbPassHashErrorState, - singleLine = true + singleLine = true, ) OutlinedTextField( value = igneous, @@ -398,39 +407,41 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { Modifier.width(dimensionResource(id = R.dimen.single_max_width)), label = { Text(text = "igneous") }, keyboardActions = KeyboardActions( - onDone = { login() } + onDone = { login() }, ), - singleLine = true + singleLine = true, ) Spacer(modifier = Modifier.height(16.dp)) Button( onClick = { login() }, Modifier .padding(horizontal = 4.dp) - .width(128.dp) + .width(128.dp), ) { Text(text = stringResource(id = android.R.string.ok)) } Spacer(modifier = Modifier.height(16.dp)) TextButton( - onClick = { fillCookiesFromClipboard() }, modifier = Modifier - .padding(horizontal = 4.dp) + onClick = { fillCookiesFromClipboard() }, + modifier = Modifier + .padding(horizontal = 4.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.from_clipboard)) } - } + }, ) } } } } - if (isProgressIndicatorVisible) + if (isProgressIndicatorVisible) { CircularProgressIndicator() + } if (showErrorDialog) { AlertDialog( onDismissRequest = { @@ -452,12 +463,11 @@ fun CookieSignInScene(windowSizeClass: WindowSizeClass) { """ ${ExceptionUtils.getReadableString(loginErrorException!!)} ${stringResource(R.string.wrong_cookie_warning)} - """.trimIndent() + """.trimIndent(), ) - } + }, ) } } } - -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/login/SelectSiteScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/login/SelectSiteScreen.kt index 02536acf8..832af1c13 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/login/SelectSiteScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/login/SelectSiteScreen.kt @@ -51,11 +51,11 @@ fun SelectSiteScreen() { .padding(horizontal = dimensionResource(R.dimen.keyline_margin)) .padding(top = dimensionResource(R.dimen.keyline_margin)) .fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Text( text = stringResource(id = R.string.select_scene), - style = MaterialTheme.typography.titleMedium + style = MaterialTheme.typography.titleMedium, ) Spacer(modifier = Modifier.weight(1f)) @@ -67,27 +67,28 @@ fun SelectSiteScreen() { .border( 1.dp, MaterialTheme.colorScheme.outline, - RoundedCornerShape(90f, 90f, 90f, 90f) + RoundedCornerShape(90f, 90f, 90f, 90f), ) - .clip(RoundedCornerShape(90f, 90f, 90f, 90f)) + .clip(RoundedCornerShape(90f, 90f, 90f, 90f)), ) { Box( modifier = Modifier .background(if (!siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface) .clickable { siteEx = false } .size(100.dp, 40.dp), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Text( text = stringResource(id = R.string.site_e), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } Divider( - color = MaterialTheme.colorScheme.outline, modifier = Modifier + color = MaterialTheme.colorScheme.outline, + modifier = Modifier .fillMaxHeight() - .width(1.dp) + .width(1.dp), ) Box( @@ -95,11 +96,11 @@ fun SelectSiteScreen() { .background(if (siteEx) MaterialTheme.colorScheme.secondaryContainer else MaterialTheme.colorScheme.surface) .clickable { siteEx = true } .size(100.dp, 40.dp), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Text( text = stringResource(id = R.string.site_ex), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } } @@ -107,7 +108,7 @@ fun SelectSiteScreen() { Text( text = stringResource(id = R.string.select_scene_explain), - modifier = Modifier.padding(top = 16.dp) + modifier = Modifier.padding(top = 16.dp), ) Spacer(modifier = Modifier.weight(1f)) @@ -115,7 +116,7 @@ fun SelectSiteScreen() { modifier = Modifier .padding(horizontal = 12.dp) .padding(top = 4.dp, bottom = 20.dp) - .fillMaxWidth() + .fillMaxWidth(), ) { Button(onClick = { Settings.putSelectSite(false) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/login/SignInScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/login/SignInScreen.kt index de48a1124..3a45c508b 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/login/SignInScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/login/SignInScreen.kt @@ -130,23 +130,21 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { } } - - when (windowSizeClass.widthSizeClass) { WindowWidthSizeClass.Compact, WindowWidthSizeClass.Medium -> Box( - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Column( Modifier .padding(dimensionResource(id = R.dimen.keyline_margin)) .fillMaxSize() .verticalScroll(rememberScrollState()), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Image( painter = painterResource(id = R.drawable.ic_launcher_foreground), contentDescription = null, - Modifier.padding(dimensionResource(id = R.dimen.keyline_margin)) + Modifier.padding(dimensionResource(id = R.dimen.keyline_margin)), ) OutlinedTextField( @@ -156,16 +154,18 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { label = { Text(stringResource(R.string.username)) }, supportingText = { if (showUsernameError) Text(stringResource(R.string.error_username_cannot_empty)) }, trailingIcon = { - if (showUsernameError) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (showUsernameError) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), singleLine = true, - isError = showUsernameError + isError = showUsernameError, ) OutlinedTextField( @@ -177,20 +177,21 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { supportingText = { if (showPasswordError) Text(stringResource(R.string.error_password_cannot_empty)) }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), keyboardActions = KeyboardActions( - onDone = { signIn() } + onDone = { signIn() }, ), trailingIcon = { - if (showPasswordError) + if (showPasswordError) { Icon(imageVector = Icons.Filled.Info, contentDescription = null) - else + } else { IconButton(onClick = { passwordHidden = !passwordHidden }) { val visibilityIcon = if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff Icon(imageVector = visibilityIcon, contentDescription = null) } + } }, singleLine = true, - isError = showPasswordError + isError = showPasswordError, ) Text( @@ -198,7 +199,7 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { Modifier .widthIn(max = dimensionResource(id = R.dimen.single_max_width)) .padding(top = 24.dp), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) Spacer(modifier = Modifier.weight(1f)) @@ -209,12 +210,12 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { UrlOpener.openUrl( requireActivity(context), EhUrl.URL_REGISTER, - false + false, ) }, Modifier .weight(1f) - .padding(horizontal = 4.dp) + .padding(horizontal = 4.dp), ) { Text(text = stringResource(id = R.string.register)) } @@ -223,42 +224,42 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { onClick = { signIn() }, Modifier .weight(1f) - .padding(horizontal = 4.dp) + .padding(horizontal = 4.dp), ) { Text(text = stringResource(id = R.string.sign_in)) } } Row( - Modifier.padding(horizontal = 4.dp) + Modifier.padding(horizontal = 4.dp), ) { TextButton( onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) }, - Modifier.padding(horizontal = 8.dp) + Modifier.padding(horizontal = 8.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.sign_in_via_webview)) } - } + }, ) } TextButton( onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) }, - Modifier.padding(horizontal = 8.dp) + Modifier.padding(horizontal = 8.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.sign_in_via_cookies)) } - } + }, ) } } @@ -273,11 +274,11 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.tourist_mode)) } - } + }, ) } } @@ -305,41 +306,41 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { """ ${ExceptionUtils.getReadableString(loginErrorException!!)} ${stringResource(R.string.sign_in_failed_tip)} - """.trimIndent() + """.trimIndent(), ) - } + }, ) } } WindowWidthSizeClass.Expanded -> Box( - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Row( Modifier .padding(dimensionResource(id = R.dimen.keyline_margin)) .fillMaxSize() .verticalScroll(rememberScrollState()), - verticalAlignment = Alignment.CenterVertically + verticalAlignment = Alignment.CenterVertically, ) { Column( Modifier .width(dimensionResource(id = R.dimen.signinscreen_landscape_caption_frame_width)) .padding(dimensionResource(id = R.dimen.keyline_margin)), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Image( painter = painterResource(id = R.drawable.ic_launcher_foreground), contentDescription = null, alignment = Alignment.Center, - modifier = Modifier.padding(dimensionResource(id = R.dimen.keyline_margin)) + modifier = Modifier.padding(dimensionResource(id = R.dimen.keyline_margin)), ) Text( text = stringResource(id = R.string.app_waring), Modifier .widthIn(max = 480.dp) .padding(top = 24.dp), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } @@ -351,16 +352,18 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { label = { Text(stringResource(R.string.username)) }, supportingText = { if (showUsernameError) Text(stringResource(R.string.error_username_cannot_empty)) }, trailingIcon = { - if (showUsernameError) Icon( - imageVector = Icons.Filled.Info, - contentDescription = null - ) + if (showUsernameError) { + Icon( + imageVector = Icons.Filled.Info, + contentDescription = null, + ) + } }, keyboardOptions = KeyboardOptions( - imeAction = ImeAction.Next + imeAction = ImeAction.Next, ), singleLine = true, - isError = showUsernameError + isError = showUsernameError, ) OutlinedTextField( @@ -372,20 +375,21 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { supportingText = { if (showPasswordError) Text(stringResource(R.string.error_password_cannot_empty)) }, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), keyboardActions = KeyboardActions( - onDone = { signIn() } + onDone = { signIn() }, ), trailingIcon = { - if (showPasswordError) + if (showPasswordError) { Icon(imageVector = Icons.Filled.Info, contentDescription = null) - else + } else { IconButton(onClick = { passwordHidden = !passwordHidden }) { val visibilityIcon = if (passwordHidden) Icons.Filled.Visibility else Icons.Filled.VisibilityOff Icon(imageVector = visibilityIcon, contentDescription = null) } + } }, singleLine = true, - isError = showPasswordError + isError = showPasswordError, ) Spacer(modifier = Modifier.height(8.dp)) @@ -394,7 +398,7 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { onClick = { signIn() }, Modifier .padding(horizontal = 4.dp) - .width(128.dp) + .width(128.dp), ) { Text(text = stringResource(id = R.string.sign_in)) } @@ -403,12 +407,12 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { UrlOpener.openUrl( requireActivity(context), EhUrl.URL_REGISTER, - false + false, ) }, Modifier .padding(horizontal = 4.dp) - .width(128.dp) + .width(128.dp), ) { Text(text = stringResource(id = R.string.register)) } @@ -417,30 +421,30 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { TextButton( onClick = { navController.navigate(COOKIE_SIGN_IN_ROUTE_NAME) }, - Modifier.padding(horizontal = 4.dp) + Modifier.padding(horizontal = 4.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.sign_in_via_cookies)) } - } + }, ) } TextButton( onClick = { navController.navigate(WEBVIEW_SIGN_IN_ROUTE_NAME) }, - Modifier.padding(horizontal = 4.dp) + Modifier.padding(horizontal = 4.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.sign_in_via_webview)) } - } + }, ) } @@ -450,20 +454,19 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { Settings.putGallerySite(EhUrl.SITE_E) navController.navigate(SELECT_SITE_ROUTE_NAME) }, - Modifier.padding(horizontal = 4.dp) + Modifier.padding(horizontal = 4.dp), ) { Text( text = buildAnnotatedString { withStyle( - style = SpanStyle(textDecoration = TextDecoration.Underline) + style = SpanStyle(textDecoration = TextDecoration.Underline), ) { append(stringResource(id = R.string.tourist_mode)) } - } + }, ) } } - } if (isProgressIndicatorVisible) { CircularProgressIndicator() @@ -489,9 +492,9 @@ fun SignInScreen(windowSizeClass: WindowSizeClass) { """ ${ExceptionUtils.getReadableString(loginErrorException!!)} ${stringResource(R.string.sign_in_failed_tip)} - """.trimIndent() + """.trimIndent(), ) - } + }, ) } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/login/WebviewSignInScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/login/WebviewSignInScreen.kt index 4a5327700..011dde55a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/login/WebviewSignInScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/login/WebviewSignInScreen.kt @@ -39,7 +39,7 @@ fun WebviewSignInScreen() { WebView(context).apply { layoutParams = ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT + ViewGroup.LayoutParams.MATCH_PARENT, ) setBackgroundColor(Color.TRANSPARENT) settings.run { @@ -74,8 +74,8 @@ fun WebviewSignInScreen() { domain, forcePersistent = true, forceLongLive = true, - forceNotHostOnly = true - ) + forceNotHostOnly = true, + ), ) } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseListAdapter.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseListAdapter.kt index 4aba1b673..ecac9a91b 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseListAdapter.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseListAdapter.kt @@ -9,4 +9,4 @@ abstract class BaseListAdapter(diffCallback: DiffUtil.ItemCallback) : val item = getItem(position) holder.bind(item) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.kt index 1a949cdc9..fa380b5aa 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseScene.kt @@ -66,7 +66,9 @@ abstract class BaseScene : Fragment() { val activity = activity return if (activity is MainActivity) { activity.getDrawerLockMode(edgeGravity) - } else null + } else { + null + } } fun openDrawer(drawerGravity: Int) { @@ -115,7 +117,8 @@ abstract class BaseScene : Fragment() { fun createDrawerView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View? { drawerView = onCreateDrawerView(inflater, container, savedInstanceState) if (drawerView != null) { @@ -132,7 +135,8 @@ abstract class BaseScene : Fragment() { open fun onCreateDrawerView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View? { return null } @@ -193,10 +197,12 @@ abstract class BaseScene : Fragment() { fun showSoftInput(view: View?) { if (view != null) { view.requestFocus() - view.post(Runnable { - val insetsController = getInsetsController() - insetsController?.show(WindowInsetsCompat.Type.ime()) - }) + view.post( + Runnable { + val insetsController = getInsetsController() + insetsController?.show(WindowInsetsCompat.Type.ime()) + }, + ) } } @@ -241,4 +247,4 @@ abstract class BaseScene : Fragment() { const val LENGTH_LONG = 1 const val KEY_DRAWER_VIEW_STATE = "com.hippo.ehviewer.ui.scene.BaseScene:DRAWER_VIEW_STATE" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseToolbarScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseToolbarScene.kt index fd1d9e53f..fcff51802 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseToolbarScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseToolbarScene.kt @@ -31,7 +31,8 @@ abstract class BaseToolbarScene : BaseScene(), ToolBarScene { override fun onCreateView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneToolbarBinding.inflate(inflater, container, false) val contentView = onCreateViewWithToolbar(inflater, binding.root, savedInstanceState) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseViewHolder.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseViewHolder.kt index 4ffdc54ec..d8b9461e6 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseViewHolder.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/BaseViewHolder.kt @@ -14,4 +14,4 @@ abstract class BaseViewHolder(binding: ViewBinding, onClick: (T) -> Unit) : } abstract fun bind(item: T) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.kt index b724a8e5b..5774534fb 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/DownloadsScene.kt @@ -81,7 +81,10 @@ import java.util.LinkedList import com.hippo.ehviewer.download.DownloadManager as downloadManager @SuppressLint("RtlHardcoded") -class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListener, +class DownloadsScene : + BaseToolbarScene(), + DownloadInfoListener, + OnClickFabListener, OnDragHandlerListener { /*--------------- Whole life cycle @@ -203,8 +206,8 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe setTitle( getString( R.string.scene_download_title, - if (mLabel != null) mLabel else getString(R.string.download_all) - ) + if (mLabel != null) mLabel else getString(R.string.download_all), + ), ) } @@ -227,7 +230,8 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe override fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneDownloadBinding.inflate(inflater, container, false) binding.run { @@ -318,7 +322,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe BaseDialogBuilder(requireActivity()) .setSingleChoiceItems( R.array.download_state, - mType + 1 + mType + 1, ) { dialog: DialogInterface, which: Int -> mType = which - 1 updateForLabel() @@ -395,7 +399,8 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe override fun onCreateDrawerView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { val drawerBinding = DrawerListRvBinding.inflate(inflater, container, false) drawerBinding.toolbar.setTitle(R.string.download_labels) @@ -406,7 +411,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe val builder = EditTextDialogBuilder( requireContext(), null, - getString(R.string.download_labels) + getString(R.string.download_labels), ) builder.setTitle(R.string.new_label_title) builder.setPositiveButton(android.R.string.ok, null) @@ -556,10 +561,12 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe context, getString(R.string.download_remove_dialog_message_2, gidList!!.size), getString(R.string.download_remove_dialog_check_text), - Settings.removeImageFiles + Settings.removeImageFiles, ) val helper = DeleteRangeDialogHelper( - downloadInfoList!!, gidList, builder + downloadInfoList!!, + gidList, + builder, ) builder.setTitle(R.string.download_remove_dialog_title) .setPositiveButton(android.R.string.ok, helper) @@ -678,7 +685,9 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe val label = mLabels[holder.bindingAdapterPosition] if (context != null) { val builder = EditTextDialogBuilder( - context, label, getString(R.string.download_labels) + context, + label, + getString(R.string.download_labels), ) builder.setTitle(R.string.rename_label_title) builder.setPositiveButton(android.R.string.ok, null) @@ -741,7 +750,8 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private inner class DeleteRangeDialogHelper( private val mDownloadInfoList: List, - private val mGidList: LongList, private val mBuilder: CheckBoxDialogBuilder + private val mGidList: LongList, + private val mBuilder: CheckBoxDialogBuilder, ) : DialogInterface.OnClickListener { override fun onClick(dialog: DialogInterface, which: Int) { if (which != DialogInterface.BUTTON_POSITIVE) { @@ -777,7 +787,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private inner class MoveDialogHelper( private val mLabels: Array, - private val mDownloadInfoList: List + private val mDownloadInfoList: List, ) : DialogInterface.OnClickListener { @SuppressLint("NotifyDataSetChanged") override fun onClick(dialog: DialogInterface, which: Int) { @@ -799,7 +809,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private inner class DownloadHolder( private val binding: ItemDownloadBinding, thumbWidth: Int, - thumbHeight: Int + thumbHeight: Int, ) : RecyclerView.ViewHolder(binding.root), View.OnClickListener { init { @@ -831,7 +841,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe val args = Bundle() args.putString( GalleryDetailScene.KEY_ACTION, - GalleryDetailScene.ACTION_GALLERY_INFO + GalleryDetailScene.ACTION_GALLERY_INFO, ) args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, list[index]) navigate(R.id.galleryDetailScene, args) @@ -866,12 +876,12 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe when (info.state) { DownloadInfo.STATE_NONE -> bindState( info, - context.getString(R.string.download_state_none) + context.getString(R.string.download_state_none), ) DownloadInfo.STATE_WAIT -> bindState( info, - context.getString(R.string.download_state_wait) + context.getString(R.string.download_state_wait), ) DownloadInfo.STATE_DOWNLOAD -> bindProgress(info) @@ -886,7 +896,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe DownloadInfo.STATE_FINISH -> bindState( info, - context.getString(R.string.download_state_finish) + context.getString(R.string.download_state_finish), ) } } @@ -959,13 +969,16 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe override fun getItemId(position: Int): Long { return if (mList == null || position < 0 || position >= mList!!.size) { 0 - } else mList!![position].gid + } else { + mList!![position].gid + } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DownloadHolder { val holder = DownloadHolder( ItemDownloadBinding.inflate(mInflater, parent, false), - mListThumbWidth, mListThumbHeight + mListThumbWidth, + mListThumbHeight, ) holder.itemView.setOnClickListener { onItemClick(holder.bindingAdapterPosition) } holder.itemView.setOnLongClickListener { onItemLongClick(holder.bindingAdapterPosition) } @@ -979,7 +992,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe override fun onBindViewHolder( holder: DownloadHolder, position: Int, - payloads: MutableList + payloads: MutableList, ) { payloads.forEach { payload -> when (payload) { @@ -1022,7 +1035,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe view: EasyRecyclerView, position: Int, id: Long, - checked: Boolean + checked: Boolean, ) { if (view.checkedItemCount == 0) { view.outOfCustomChoiceMode() @@ -1031,8 +1044,9 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe } private inner class RenameLabelDialogHelper( - private val mBuilder: EditTextDialogBuilder, private val mDialog: AlertDialog, - private val mOriginalLabel: String? + private val mBuilder: EditTextDialogBuilder, + private val mDialog: AlertDialog, + private val mOriginalLabel: String?, ) : View.OnClickListener { init { val button: Button = mDialog.getButton(DialogInterface.BUTTON_POSITIVE) @@ -1063,7 +1077,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private inner class NewLabelDialogHelper( private val mBuilder: EditTextDialogBuilder, - private val mDialog: AlertDialog + private val mDialog: AlertDialog, ) : View.OnClickListener { init { val button: Button = mDialog.getButton(DialogInterface.BUTTON_POSITIVE) @@ -1096,7 +1110,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private inner class DownloadLabelItemTouchHelperCallback : ItemTouchHelper.Callback() { override fun getMovementFlags( recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder + viewHolder: RecyclerView.ViewHolder, ): Int { val position = viewHolder.bindingAdapterPosition return if (position < LABEL_OFFSET) { @@ -1104,7 +1118,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe } else { makeMovementFlags( ItemTouchHelper.UP or ItemTouchHelper.DOWN, - ItemTouchHelper.LEFT + ItemTouchHelper.LEFT, ) } } @@ -1112,7 +1126,7 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, - target: RecyclerView.ViewHolder + target: RecyclerView.ViewHolder, ): Boolean { val fromPosition = viewHolder.bindingAdapterPosition val toPosition = target.bindingAdapterPosition @@ -1152,18 +1166,18 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private val itemTouchHelper = ItemTouchHelper(object : ItemTouchHelper.Callback() { override fun getMovementFlags( recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder + viewHolder: RecyclerView.ViewHolder, ): Int { return makeMovementFlags( ItemTouchHelper.UP or ItemTouchHelper.DOWN, - 0 + 0, ) } override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, - target: RecyclerView.ViewHolder + target: RecyclerView.ViewHolder, ): Boolean { val fromPosition = viewHolder.bindingAdapterPosition val toPosition = target.bindingAdapterPosition @@ -1204,4 +1218,4 @@ class DownloadsScene : BaseToolbarScene(), DownloadInfoListener, OnClickFabListe private const val LABEL_OFFSET = 2 private const val PAYLOAD_STATE = 0 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/EhCallback.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/EhCallback.kt index 64073a669..e6c10f4d8 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/EhCallback.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/EhCallback.kt @@ -45,8 +45,9 @@ abstract class EhCallback(context: Context) : EhClient.Callbac activity.showTip(id, length) } else { Toast.makeText( - application, id, - if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT + application, + id, + if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT, ).show() } } @@ -57,9 +58,10 @@ abstract class EhCallback(context: Context) : EhClient.Callbac activity.showTip(tip, length) } else { Toast.makeText( - application, tip, - if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT + application, + tip, + if (length == BaseScene.LENGTH_LONG) Toast.LENGTH_LONG else Toast.LENGTH_SHORT, ).show() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.kt index ea22b10c9..b992e7c1c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/FavoritesScene.kt @@ -73,14 +73,18 @@ import java.time.ZoneOffset // TODO Get favorite, modify favorite, add favorite, what a mess! @SuppressLint("NotifyDataSetChanged", "RtlHardcoded") -class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListener, - OnExpandListener, CustomChoiceListener { +class FavoritesScene : + SearchBarScene(), + OnDragHandlerListener, + OnClickFabListener, + OnExpandListener, + CustomChoiceListener { // For modify action private val mModifyGiList: MutableList = ArrayList() - var current // -1 for error - = 0 - var limit // -1 for error - = 0 + var current = // -1 for error + 0 + var limit = // -1 for error + 0 private var mRecyclerView: EasyRecyclerView? = null @@ -183,7 +187,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen override fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { val view = inflater.inflate(R.layout.scene_favorites, container, false) val mContentLayout = view.findViewById(R.id.content_layout) @@ -199,10 +204,11 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen (mFabLayout!!.parent as ViewGroup).removeView(mFabLayout) container!!.addView(mFabLayout) ViewCompat.setWindowInsetsAnimationCallback( - view, WindowInsetsAnimationHelper( + view, + WindowInsetsAnimationHelper( WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP, - mFabLayout - ) + mFabLayout, + ), ) val paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar) mHelper = FavoritesHelper() @@ -216,8 +222,10 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen mRecyclerView!!.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM) mRecyclerView!!.setCustomCheckedListener(this) fastScroller.setPadding( - fastScroller.paddingLeft, fastScroller.paddingTop + paddingTopSB, - fastScroller.paddingRight, fastScroller.paddingBottom + fastScroller.paddingLeft, + fastScroller.paddingTop + paddingTopSB, + fastScroller.paddingRight, + fastScroller.paddingBottom, ) setAllowEmptySearch(false) updateSearchBar() @@ -270,7 +278,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen } else { if (!ObjectUtils.equal(favCatName, mOldFavCat) || !ObjectUtils.equal( keyword, - mOldKeyword + mOldKeyword, ) ) { setSearchBarHint(getString(R.string.favorites_title_2, favCatName, keyword)) @@ -293,11 +301,11 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen if (mFabLayout != null && mUrlBuilder != null) { mFabLayout!!.setSecondaryFabVisibilityAt( 0, - mUrlBuilder!!.favCat != FavListUrlBuilder.FAV_CAT_LOCAL + mUrlBuilder!!.favCat != FavListUrlBuilder.FAV_CAT_LOCAL, ) mFabLayout!!.setSecondaryFabVisibilityAt( 2, - mUrlBuilder!!.favCat != FavListUrlBuilder.FAV_CAT_LOCAL + mUrlBuilder!!.favCat != FavListUrlBuilder.FAV_CAT_LOCAL, ) } } @@ -326,7 +334,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen override fun onCreateDrawerView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View? { val view = inflater.inflate(R.layout.drawer_list_rv, container, false) val toolbar = ViewUtils.`$$`(view, R.id.toolbar) as Toolbar @@ -344,7 +353,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen .setTitle(R.string.default_favorites_collection) .setItems(items) { _: DialogInterface?, which: Int -> Settings.putDefaultFavSlot( - which - 2 + which - 2, ) } .show() @@ -408,7 +417,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen val args = Bundle() args.putString( GalleryDetailScene.KEY_ACTION, - GalleryDetailScene.ACTION_GALLERY_INFO + GalleryDetailScene.ACTION_GALLERY_INFO, ) args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi) navigate(R.id.galleryDetailScene, args) @@ -483,7 +492,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen datePicker.show(requireActivity().supportFragmentManager, "date-picker") datePicker.addOnPositiveButtonClickListener { v: Long? -> mHelper!!.goTo( - v!!, true + v!!, + true, ) } } @@ -519,7 +529,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen i++ } when (position) { - 3 -> // Check all + 3 -> // Check all mRecyclerView!!.checkAll() 4 -> { // Download @@ -540,8 +550,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen .setMessage( getString( R.string.delete_favorites_dialog_message, - mModifyGiList.size - ) + mModifyGiList.size, + ), ) .setPositiveButton(android.R.string.ok, helper) .setOnCancelListener(helper) @@ -615,7 +625,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen view: EasyRecyclerView, position: Int, id: Long, - checked: Boolean + checked: Boolean, ) { if (view.checkedItemCount == 0) { view.outOfCustomChoiceMode() @@ -685,7 +695,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen context: Context, private val mTaskId: Int, private val mKeyword: String?, - private val mBackup: List + private val mBackup: List, ) : EhCallback(context) { override fun onSuccess(result: Void?) { val scene = this@FavoritesScene @@ -707,7 +717,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen context: Context, private val mTaskId: Int, // Local fav is shown now, but operation need be done for cloud fav private val mLocal: Boolean, - private val mKeyword: String? + private val mKeyword: String?, ) : EhCallback(context) { override fun onSuccess(result: FavoritesParser.Result) { // Put fav cat @@ -774,11 +784,14 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen override fun getItemCount(): Int { return if (null == mFavCatArray) { 2 - } else 12 + } else { + 12 + } } } - private inner class DeleteDialogHelper : DialogInterface.OnClickListener, + private inner class DeleteDialogHelper : + DialogInterface.OnClickListener, DialogInterface.OnCancelListener { override fun onClick(dialog: DialogInterface, which: Int) { if (which != DialogInterface.BUTTON_POSITIVE) { @@ -812,7 +825,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen } } - private inner class MoveDialogHelper : DialogInterface.OnClickListener, + private inner class MoveDialogHelper : + DialogInterface.OnClickListener, DialogInterface.OnCancelListener { override fun onClick(dialog: DialogInterface, which: Int) { if (mRecyclerView == null || mHelper == null || mUrlBuilder == null) { @@ -861,8 +875,10 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen } private inner class FavoritesAdapter( - inflater: LayoutInflater, resources: Resources, - recyclerView: RecyclerView, type: Int + inflater: LayoutInflater, + resources: Resources, + recyclerView: RecyclerView, + type: Int, ) : GalleryAdapter(inflater, resources, recyclerView, type, false) { override fun getItemCount(): Int { return if (null != mHelper) mHelper!!.size() else 0 @@ -893,7 +909,7 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen type: Int, page: Int, index: String?, - isNext: Boolean + isNext: Boolean, ) { val activity = mainActivity if (null == activity || null == mUrlBuilder || null == mClient) { @@ -922,8 +938,8 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen context, taskId, mUrlBuilder!!.keyword, - modifyGiListBackup - ) + modifyGiListBackup, + ), ) request.setArgs(gidArray, tokenArray, mModifyFavCat) request.enqueue(this@FavoritesScene) @@ -947,8 +963,10 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen request.setCallback( GetFavoritesListener( context, - taskId, local, mUrlBuilder!!.keyword - ) + taskId, + local, + mUrlBuilder!!.keyword, + ), ) request.setArgs(url, gidArray, mModifyFavCat) request.enqueue(this@FavoritesScene) @@ -965,8 +983,10 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen request.setCallback( GetFavoritesListener( context, - taskId, false, mUrlBuilder!!.keyword - ) + taskId, + false, + mUrlBuilder!!.keyword, + ), ) request.setArgs(url) request.enqueue(this@FavoritesScene) @@ -1013,4 +1033,4 @@ class FavoritesScene : SearchBarScene(), OnDragHandlerListener, OnClickFabListen private const val KEY_HAS_FIRST_REFRESH = "has_first_refresh" private const val KEY_FAV_COUNT_ARRAY = "fav_count_array" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryAdapter.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryAdapter.kt index 7054d6385..f0f9537c1 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryAdapter.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryAdapter.kt @@ -35,8 +35,11 @@ import com.hippo.widget.recyclerview.STRATEGY_SUITABLE_SIZE import com.hippo.yorozuya.ViewUtils internal abstract class GalleryAdapter( - private val mInflater: LayoutInflater, private val mResources: Resources, - private val mRecyclerView: RecyclerView, type: Int, showFavourited: Boolean + private val mInflater: LayoutInflater, + private val mResources: Resources, + private val mRecyclerView: RecyclerView, + type: Int, + showFavourited: Boolean, ) : RecyclerView.Adapter() { private val mLayoutManager: AutoStaggeredGridLayoutManager = AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL) @@ -106,7 +109,8 @@ internal abstract class GalleryAdapter( mShowFavourited = showFavourited mRecyclerView.adapter = this mRecyclerView.layoutManager = mLayoutManager - @SuppressLint("InflateParams") val calculator = + @SuppressLint("InflateParams") + val calculator = mInflater.inflate(R.layout.item_gallery_list_thumb_height, null) ViewUtils.measureView(calculator, 1024, ViewGroup.LayoutParams.WRAP_CONTENT) mListThumbHeight = calculator.measuredHeight @@ -118,8 +122,10 @@ internal abstract class GalleryAdapter( private fun adjustPaddings() { val recyclerView = mRecyclerView recyclerView.setPadding( - recyclerView.paddingLeft, recyclerView.paddingTop + mPaddingTopSB, - recyclerView.paddingRight, recyclerView.paddingBottom + recyclerView.paddingLeft, + recyclerView.paddingTop + mPaddingTopSB, + recyclerView.paddingRight, + recyclerView.paddingBottom, ) } @@ -129,7 +135,7 @@ internal abstract class GalleryAdapter( ItemGalleryListBinding.inflate(mInflater, parent, false), mShowFavourited, mListThumbWidth, - mListThumbHeight + mListThumbHeight, ) TYPE_GRID -> GridGalleryHolder(ItemGalleryGridBinding.inflate(mInflater, parent, false)) @@ -165,4 +171,4 @@ internal abstract class GalleryAdapter( const val TYPE_LIST = 0 const val TYPE_GRID = 1 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.kt index e2ef06e8c..735c44a6d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.kt @@ -149,7 +149,8 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh override fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { val view = inflater.inflate(R.layout.scene_gallery_comments, container, false) as ViewGroup mRecyclerView = ViewUtils.`$$`(view, R.id.recycler_view) as EasyRecyclerView @@ -162,7 +163,6 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh mFab = ViewUtils.`$$`(view, R.id.fab) as FloatingActionButton mRefreshLayout = ViewUtils.`$$`(view, R.id.refresh_layout) as SwipeRefreshLayout - // Workaround for fab and edittext render out of screen view.removeView(mFabLayout) view.removeView(mEditPanel!!.parent as View) @@ -170,11 +170,12 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh container!!.addView(mFabLayout) container.addView(mEditPanel!!.parent as View) ViewCompat.setWindowInsetsAnimationCallback( - view, WindowInsetsAnimationHelper( + view, + WindowInsetsAnimationHelper( WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP, mEditPanel, - mFabLayout - ) + mFabLayout, + ), ) mRefreshLayout!!.setOnRefreshListener(this) val context = requireContext() @@ -187,7 +188,8 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh mRecyclerView!!.adapter = mAdapter mRecyclerView!!.layoutManager = LinearLayoutManager( context, - RecyclerView.VERTICAL, false + RecyclerView.VERTICAL, + false, ) mRecyclerView!!.setHasFixedSize(true) // Cancel change animator @@ -229,24 +231,28 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh } } val builder = EditTextDialogBuilder( - context, oldUrl, getString(R.string.format_url) + context, + oldUrl, + getString(R.string.format_url), ) builder.setTitle(getString(R.string.format_url)) builder.setPositiveButton(android.R.string.ok, null) val dialog = builder.show() val button: View? = dialog.getButton(DialogInterface.BUTTON_POSITIVE) - button?.setOnClickListener(View.OnClickListener { - val url = builder.text.trim() - if (TextUtils.isEmpty(url)) { - builder.setError(getString(R.string.text_is_empty)) - return@OnClickListener - } else { - builder.setError(null) - } - text.clearSpan(start, end, true) - text[start, end] = URLSpan(url) - dialog.dismiss() - }) + button?.setOnClickListener( + View.OnClickListener { + val url = builder.text.trim() + if (TextUtils.isEmpty(url)) { + builder.setError(getString(R.string.text_is_empty)) + return@OnClickListener + } else { + builder.setError(null) + } + text.clearSpan(start, end, true) + text[start, end] = URLSpan(url) + dialog.dismiss() + }, + ) } R.id.action_clear -> { @@ -339,7 +345,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh } val oldCommentsList = mGalleryDetail!!.comments!!.comments val newCommentsList = arrayOfNulls( - oldCommentsList!!.size - 1 + oldCommentsList!!.size - 1, ) var i = 0 var j = 0 @@ -369,7 +375,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh mGalleryDetail!!.gid, mGalleryDetail!!.token, id, - vote + vote, ) .setCallback(VoteCommentListener(context)) request.enqueue(this) @@ -554,7 +560,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh halfW, halfH, 0f, - hypot(halfW.toDouble(), halfH.toDouble()).toFloat() + hypot(halfW.toDouble(), halfH.toDouble()).toFloat(), ).setDuration(300L) animator.addListener(object : SimpleAnimatorListener() { override fun onAnimationEnd(a: Animator) { @@ -591,7 +597,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh halfW, halfH, hypot(halfW.toDouble(), halfH.toDouble()).toFloat(), - 0.0f + 0.0f, ).setDuration(300L) animator.addListener(object : SimpleAnimatorListener() { override fun onAnimationEnd(a: Animator) { @@ -646,7 +652,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh mGalleryDetail!!.gid, mGalleryDetail!!.token, 0, - mShowAllComments + mShowAllComments, ) } else { null @@ -677,7 +683,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh .setArgs( url, comment, - if (mCommentId != 0L) mCommentId.toString() else null + if (mCommentId != 0L) mCommentId.toString() else null, ) .setCallback(CommentGalleryListener(context, mCommentId)) request.enqueue(this) @@ -774,7 +780,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh } private class InfoHolder(itemView: View?) : RecyclerView.ViewHolder( - itemView!! + itemView!!, ) { val key: TextView val value: TextView @@ -814,7 +820,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh override fun onSuccess(result: GalleryCommentList) { showTip( if (mCommentId != 0L) R.string.edit_comment_successfully else R.string.comment_successfully, - LENGTH_SHORT + LENGTH_SHORT, ) val scene = this@GalleryCommentsScene scene.onCommentGallerySuccess(result) @@ -825,7 +831,8 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh """ ${content.getString(if (mCommentId != 0L) R.string.edit_comment_failed else R.string.comment_failed)} ${ExceptionUtils.getReadableString(e)} - """.trimIndent(), LENGTH_LONG + """.trimIndent(), + LENGTH_LONG, ) } @@ -837,7 +844,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh override fun onSuccess(result: VoteCommentParser.Result) { showTip( if (result.expectVote > 0) (if (0 != result.vote) R.string.vote_up_successfully else R.string.cancel_vote_up_successfully) else if (0 != result.vote) R.string.vote_down_successfully else R.string.cancel_vote_down_successfully, - LENGTH_SHORT + LENGTH_SHORT, ) val scene = this@GalleryCommentsScene scene.onVoteCommentSuccess(result) @@ -860,13 +867,13 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh private fun generateComment( context: Context, textView: ObservedTextView, - comment: GalleryComment + comment: GalleryComment, ): CharSequence { sp = Html.fromHtml( comment.comment, Html.FROM_HTML_MODE_LEGACY, URLImageGetter(textView), - null + null, ) val ssb = SpannableStringBuilder(sp) if (0L != comment.id && 0 != comment.score) { @@ -875,7 +882,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh ssb.append(" ").inSpans( RelativeSizeSpan(0.8f), StyleSpan(Typeface.BOLD), - ForegroundColorSpan(theme.resolveColor(android.R.attr.textColorSecondary)) + ForegroundColorSpan(theme.resolveColor(android.R.attr.textColorSecondary)), ) { append(scoreString) } @@ -883,12 +890,12 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh if (comment.lastEdited != 0L) { val str = context.getString( R.string.last_edited, - ReadableTime.getTimeAgo(comment.lastEdited) + ReadableTime.getTimeAgo(comment.lastEdited), ) ssb.append("\n\n").inSpans( RelativeSizeSpan(0.8f), StyleSpan(Typeface.BOLD), - ForegroundColorSpan(theme.resolveColor(android.R.attr.textColorSecondary)) + ForegroundColorSpan(theme.resolveColor(android.R.attr.textColorSecondary)), ) { append(str) } @@ -935,7 +942,7 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh onItemClick( mRecyclerView, holder.itemView, - position + position, ) } holder.itemView.isClickable = true @@ -984,4 +991,4 @@ class GalleryCommentsScene : BaseToolbarScene(), View.OnClickListener, OnRefresh private const val TYPE_MORE = 1 private const val TYPE_PROGRESS = 2 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt index 1aecd23fc..f911bd08a 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.kt @@ -199,7 +199,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { private var mTorrentList: List? = null private var requestStoragePermissionLauncher = registerForActivityResult( - ActivityResultContracts.RequestPermission() + ActivityResultContracts.RequestPermission(), ) { result: Boolean -> if (result && composeBindingGD != null) { val helper = TorrentListDialogHelper() @@ -269,7 +269,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { // -1 for error private val gid: Long get() = composeBindingGD?.gid ?: composeBindingGI?.gid - ?: mGid.takeIf { mAction == ACTION_GID_TOKEN } ?: -1 + ?: mGid.takeIf { mAction == ACTION_GID_TOKEN } ?: -1 private val uploader: String? get() = composeBindingGD?.uploader ?: composeBindingGI?.uploader @@ -376,7 +376,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + savedInstanceState: Bundle?, ): View { // Get download state val gid = gid @@ -412,7 +412,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { composeBindingGI?.let { Text( text = EhUtils.getSuitableTitle(it), - maxLines = 2 + maxLines = 2, ) } }, @@ -422,7 +422,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { }) { Icon( imageVector = Icons.Default.ArrowBack, - contentDescription = null + contentDescription = null, ) } }, @@ -432,46 +432,50 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { IconButton(onClick = { dropdown = !dropdown }) { Icon( imageVector = Icons.Default.MoreVert, - contentDescription = null + contentDescription = null, ) } DropdownMenu( expanded = dropdown, - onDismissRequest = { dropdown = false }) { + onDismissRequest = { dropdown = false }, + ) { DropdownMenuItem( text = { Text(text = stringResource(id = R.string.action_add_tag)) }, onClick = { dropdown = false actionAddTag() - }) + }, + ) DropdownMenuItem( text = { Text(text = stringResource(id = R.string.refresh)) }, onClick = { dropdown = false actionRefresh() - }) + }, + ) DropdownMenuItem( text = { Text(text = stringResource(id = R.string.open_in_other_app)) }, onClick = { dropdown = false actionOpenInOtherApp() - }) + }, + ) } - } + }, ) - } + }, ) { Surface { if (getDetailError.isNotBlank()) { Column( modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center + verticalArrangement = Arrangement.Center, ) { Icon( painter = painterResource(id = R.drawable.big_sad_pandroid), contentDescription = null, - modifier = Modifier.clickable(onClick = ::actionRefresh) + modifier = Modifier.clickable(onClick = ::actionRefresh), ) Spacer(modifier = Modifier.size(8.dp)) Text(text = getDetailError) @@ -483,12 +487,12 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { galleryInfo = gi, galleryDetail = composeBindingGD, contentPadding = it, - modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection) + modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection), ) } else { Box( modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { CircularProgressIndicator() } @@ -501,20 +505,19 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } } - @Composable private fun GalleryDetailContent( galleryInfo: GalleryInfo, galleryDetail: GalleryDetail?, contentPadding: PaddingValues, - modifier: Modifier + modifier: Modifier, ) { val windowSizeClass = calculateWindowSizeClass(requireActivity()) when (windowSizeClass.widthSizeClass) { WindowWidthSizeClass.Medium, WindowWidthSizeClass.Compact -> LazyVerticalGrid( columns = GridCells.Adaptive(Settings.thumbSizeDp), contentPadding = contentPadding, - modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)) + modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)), ) { item(span = { GridItemSpan(maxCurrentLineSpan) }) { Column { @@ -527,14 +530,14 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { onBlockUploaderIconClick = ::showFilterUploaderDialog, modifier = Modifier .fillMaxWidth() - .padding(vertical = dimensionResource(id = R.dimen.keyline_margin)) + .padding(vertical = dimensionResource(id = R.dimen.keyline_margin)), ) Row { FilledTonalButton( onClick = ::onDownloadButtonClick, modifier = Modifier .padding(horizontal = 4.dp) - .weight(1F) + .weight(1F), ) { Text(text = downloadButtonText) } @@ -542,7 +545,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { onClick = ::onReadButtonClick, modifier = Modifier .padding(horizontal = 4.dp) - .weight(1F) + .weight(1F), ) { Text(text = readButtonText) } @@ -552,7 +555,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } else { Box( modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { CircularProgressIndicator() } @@ -567,12 +570,12 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { WindowWidthSizeClass.Expanded -> LazyVerticalGrid( columns = GridCells.Adaptive(Settings.thumbSizeDp), contentPadding = contentPadding, - modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)) + modifier = modifier.padding(horizontal = dimensionResource(id = R.dimen.keyline_margin)), ) { item(span = { GridItemSpan(maxCurrentLineSpan) }) { Column { Row( - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), ) { GalleryDetailHeaderCard( galleryInfo = galleryInfo, @@ -583,11 +586,11 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { onBlockUploaderIconClick = ::showFilterUploaderDialog, modifier = Modifier .width(dimensionResource(id = R.dimen.gallery_detail_card_landscape_width)) - .padding(vertical = dimensionResource(id = R.dimen.keyline_margin)) + .padding(vertical = dimensionResource(id = R.dimen.keyline_margin)), ) Column( modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Spacer(modifier = modifier.height(16.dp)) Button( @@ -595,7 +598,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { modifier = Modifier .height(56.dp) .padding(horizontal = 16.dp) - .width(192.dp) + .width(192.dp), ) { Text(text = readButtonText) } @@ -605,7 +608,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { modifier = Modifier .height(56.dp) .padding(horizontal = 16.dp) - .width(192.dp) + .width(192.dp), ) { Text(text = downloadButtonText) } @@ -616,7 +619,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } else { Box( modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { CircularProgressIndicator() } @@ -634,16 +637,16 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { val previewList = gd.previewList item { Column( - modifier = Modifier.padding(8.dp) + modifier = Modifier.padding(8.dp), ) { Box( - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { CrystalCard( onClick = ::navigateToPreview, modifier = Modifier .fillMaxWidth() - .aspectRatio(0.6666667F) + .aspectRatio(0.6666667F), ) {} Text(stringResource(R.string.more_previews)) } @@ -653,7 +656,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { items(previewList) { Column( modifier = Modifier.padding(8.dp), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { Box(contentAlignment = Alignment.Center) { CrystalCard( @@ -662,11 +665,11 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { }, modifier = Modifier .fillMaxWidth() - .aspectRatio(0.6666667F) + .aspectRatio(0.6666667F), ) { EhAsyncPreview( model = it, - modifier = Modifier.fillMaxSize() + modifier = Modifier.fillMaxSize(), ) } } @@ -698,12 +701,12 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { OutlinedButton( onClick = onClick, contentPadding = ButtonDefaults.TextButtonWithIconContentPadding, - modifier = Modifier.padding(end = 8.dp) + modifier = Modifier.padding(end = 8.dp), ) { Icon( imageVector = icon, contentDescription = null, - modifier = Modifier.size(ButtonDefaults.IconSize) + modifier = Modifier.size(ButtonDefaults.IconSize), ) Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing)) Text(text = text) @@ -720,12 +723,12 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { onClick = onClick, colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.onSecondaryContainer), contentPadding = ButtonDefaults.TextButtonWithIconContentPadding, - modifier = Modifier.padding(end = 8.dp) + modifier = Modifier.padding(end = 8.dp), ) { Icon( imageVector = icon, contentDescription = null, - modifier = Modifier.size(ButtonDefaults.IconSize) + modifier = Modifier.size(ButtonDefaults.IconSize), ) Spacer(modifier = Modifier.size(ButtonDefaults.IconSpacing)) Text(text = text) @@ -748,39 +751,39 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { EhAccentIconButton( icon = Icons.Default.Favorite, text = favButtonText, - onClick = ::modifyFavourite + onClick = ::modifyFavourite, ) } else { EhIconButton( icon = Icons.Default.FavoriteBorder, text = stringResource(id = R.string.not_favorited), - onClick = ::modifyFavourite + onClick = ::modifyFavourite, ) } EhIconButton( icon = Icons.Default.Difference, text = stringResource(id = R.string.similar_gallery), - onClick = ::showSimilarGalleryList + onClick = ::showSimilarGalleryList, ) EhIconButton( icon = Icons.Default.ImageSearch, text = stringResource(id = R.string.search_cover), - onClick = ::showCoverGalleryList + onClick = ::showCoverGalleryList, ) EhIconButton( icon = Icons.Default.Share, text = stringResource(id = R.string.share), - onClick = ::doShareGallery + onClick = ::doShareGallery, ) EhIconButton( icon = Icons.Default.SwapVerticalCircle, text = torrentText, - onClick = ::showTorrentDialog + onClick = ::showTorrentDialog, ) EhIconButton( icon = Icons.Default.CloudDone, text = stringResource(id = R.string.archive), - onClick = ::showArchiveDialog + onClick = ::showArchiveDialog, ) } Spacer(modifier = Modifier.size(dimensionResource(id = R.dimen.keyline_margin))) @@ -791,7 +794,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { modifier = Modifier .padding(8.dp) .fillMaxWidth(), - horizontalAlignment = Alignment.CenterHorizontally + horizontalAlignment = Alignment.CenterHorizontally, ) { GalleryDetailRating(rating = galleryDetail.rating) Spacer(modifier = Modifier.size(dimensionResource(id = R.dimen.keyline_margin))) @@ -803,7 +806,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { if (tags.isNullOrEmpty()) { Box( modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Text(text = stringResource(id = R.string.no_tags)) } @@ -822,7 +825,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { val galleryInfoBottomSheet = GalleryInfoBottomSheet(gd) galleryInfoBottomSheet.show( requireActivity().supportFragmentManager, - GalleryInfoBottomSheet.TAG + GalleryInfoBottomSheet.TAG, ) } @@ -852,20 +855,22 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { CommonOperations.startDownload( activity as MainActivity, galleryDetail, - false + false, ) } else { val builder = CheckBoxDialogBuilder( requireContext(), getString( R.string.download_remove_dialog_message, - galleryDetail.title + galleryDetail.title, ), getString(R.string.download_remove_dialog_check_text), - Settings.removeImageFiles + Settings.removeImageFiles, ) val helper = DeleteDialogHelper( - downloadManager, galleryDetail, builder + downloadManager, + galleryDetail, + builder, ) builder.setTitle(R.string.download_remove_dialog_title) .setPositiveButton(android.R.string.ok, helper) @@ -914,7 +919,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { galleryDetail.previewList.forEach { it.imageUrl.run { context?.imageLoader?.enqueue( - ImageRequest.Builder(requireContext()).ehUrl(this).build() + ImageRequest.Builder(requireContext()).ehUrl(this).build(), ) } } @@ -958,8 +963,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { if (containLocalFavorites || galleryDetail.isFavorited) { mModifyingFavorites = true CommonOperations.removeFromFavorites( - activity, galleryDetail, - ModifyFavoritesListener(requireContext(), true) + activity, + galleryDetail, + ModifyFavoritesListener(requireContext(), true), ) remove = true } @@ -967,8 +973,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { if (!remove) { mModifyingFavorites = true CommonOperations.addToFavorites( - requireActivity(), galleryDetail, - ModifyFavoritesListener(requireContext(), false) + requireActivity(), + galleryDetail, + ModifyFavoritesListener(requireContext(), false), ) } // Update UI @@ -986,8 +993,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { getString( R.string.newer_version_title, newerVersion.title, - newerVersion.posted - ) + newerVersion.posted, + ), ) } BaseDialogBuilder(requireContext()) @@ -1024,7 +1031,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { Snackbar.make( requireActivity().findViewById(R.id.snackbar), getString(R.string.read_from, mPage), - Snackbar.LENGTH_LONG + Snackbar.LENGTH_LONG, ) .setAction(R.string.read) { val intent = Intent(requireContext(), ReaderActivity::class.java) @@ -1050,7 +1057,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { text: String, weak: Boolean = false, isGroup: Boolean = false, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { val bgColor = if (isGroup) { MaterialTheme.colorScheme.primaryContainer @@ -1060,13 +1067,13 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { Surface( modifier = Modifier.padding(4.dp), color = bgColor, - shape = RoundedCornerShape(64.dp) + shape = RoundedCornerShape(64.dp), ) { Text( text = text, modifier = modifier.padding(horizontal = 12.dp, vertical = 4.dp), color = MaterialTheme.colorScheme.onSurface.let { if (weak) it.copy(0.5F) else it }, - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } } @@ -1087,7 +1094,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { it.groupName?.run { baseRoundText( text = translate(), - isGroup = true + isGroup = true, ) val prefix = namespaceToPrefix(this) FlowRow { @@ -1110,8 +1117,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { weak = weak, modifier = Modifier.combinedClickable( onClick = ::onClick, - onLongClick = ::onLongClick - ) + onLongClick = ::onLongClick, + ), ) } } @@ -1126,17 +1133,17 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { args.putLong(GalleryCommentsScene.KEY_API_UID, galleryDetail.apiUid) args.putString( GalleryCommentsScene.KEY_API_KEY, - galleryDetail.apiKey + galleryDetail.apiKey, ) args.putLong(GalleryCommentsScene.KEY_GID, galleryDetail.gid) args.putString(GalleryCommentsScene.KEY_TOKEN, galleryDetail.token) args.putParcelable( GalleryCommentsScene.KEY_COMMENT_LIST, - galleryDetail.comments + galleryDetail.comments, ) args.putParcelable( GalleryCommentsScene.KEY_GALLERY_DETAIL, - galleryDetail + galleryDetail, ) navigate(R.id.galleryCommentsScene, args) } @@ -1145,9 +1152,13 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { @Composable private fun GalleryDetailComment(commentsList: Array?) { val maxShowCount = 2 - val commentText = if (commentsList.isNullOrEmpty()) stringResource(R.string.no_comments) - else if (commentsList.size <= maxShowCount) stringResource(R.string.no_more_comments) - else stringResource(R.string.more_comment) + val commentText = if (commentsList.isNullOrEmpty()) { + stringResource(R.string.no_comments) + } else if (commentsList.size <= maxShowCount) { + stringResource(R.string.no_more_comments) + } else { + stringResource(R.string.more_comment) + } CrystalCard(onClick = ::onNavigateToCommentScene) { if (commentsList != null) { val length = maxShowCount.coerceAtMost(commentsList.size) @@ -1164,8 +1175,10 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { val c = findViewById(R.id.comment) c.maxLines = 5 c.text = Html.fromHtml( - comment.comment, Html.FROM_HTML_MODE_LEGACY, - URLImageGetter(c), null + comment.comment, + Html.FROM_HTML_MODE_LEGACY, + URLImageGetter(c), + null, ) } }) @@ -1173,7 +1186,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } Box( modifier = Modifier.fillMaxWidth(), - contentAlignment = Alignment.Center + contentAlignment = Alignment.Center, ) { Text(commentText) } @@ -1185,7 +1198,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { R.string.rating_text, getString(getRatingText(rating)), rating, - ratingCount + ratingCount, ) } @@ -1248,7 +1261,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { val galleryDetail = composeBindingGD ?: return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission( requireActivity(), - Manifest.permission.WRITE_EXTERNAL_STORAGE + Manifest.permission.WRITE_EXTERNAL_STORAGE, ) != PackageManager.PERMISSION_GRANTED ) { requestStoragePermissionLauncher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE) @@ -1370,7 +1383,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { composeBindingGD!!.gid, composeBindingGD!!.token!!, tag, - vote + vote, ) .setCallback(VoteTagListener(context)) request.enqueue(this) @@ -1412,8 +1425,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { if (EhDB.containLocalFavorites(composeBindingGD!!.gid) || composeBindingGD!!.isFavorited) { mModifyingFavorites = true CommonOperations.removeFromFavorites( - activity, composeBindingGD!!, - ModifyFavoritesListener(requireActivity(), true) + activity, + composeBindingGD!!, + ModifyFavoritesListener(requireActivity(), true), ) remove = true } @@ -1421,8 +1435,10 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { if (!remove) { mModifyingFavorites = true CommonOperations.addToFavorites( - requireActivity(), composeBindingGD!!, - ModifyFavoritesListener(requireActivity(), false), true + requireActivity(), + composeBindingGD!!, + ModifyFavoritesListener(requireActivity(), false), + true, ) } // Update UI @@ -1529,7 +1545,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { private class DownloadArchiveListener( context: Context, - private val mGalleryInfo: GalleryInfo? + private val mGalleryInfo: GalleryInfo?, ) : EhCallback(context) { override fun onSuccess(result: String?) { // TODO: Don't use buggy system download service @@ -1538,7 +1554,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { mGalleryInfo!!.gid.toString() + "-" + EhUtils.getSuitableTitle(mGalleryInfo) + ".zip" r.setDestinationInExternalPublicDir( Environment.DIRECTORY_DOWNLOADS, - FileUtils.sanitizeFilename(name) + FileUtils.sanitizeFilename(name), ) r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) val dm = application.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager @@ -1564,7 +1580,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { private inner class DeleteDialogHelper( private val mDownloadManager: com.hippo.ehviewer.download.DownloadManager?, - private val mGalleryInfo: GalleryInfo, private val mBuilder: CheckBoxDialogBuilder + private val mGalleryInfo: GalleryInfo, + private val mBuilder: CheckBoxDialogBuilder, ) : DialogInterface.OnClickListener { override fun onClick(dialog: DialogInterface, which: Int) { if (which != DialogInterface.BUTTON_POSITIVE) { @@ -1590,7 +1607,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } private inner class RateGalleryListener( - context: Context + context: Context, ) : EhCallback(context) { override fun onSuccess(result: RateGalleryParser.Result) { showTip(R.string.rate_successfully, LENGTH_SHORT) @@ -1608,13 +1625,13 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { private inner class ModifyFavoritesListener( context: Context, - private val mAddOrRemove: Boolean + private val mAddOrRemove: Boolean, ) : EhCallback(context) { override fun onSuccess(result: Unit) { showTip( if (mAddOrRemove) R.string.remove_from_favorite_success else R.string.add_to_favorite_success, - LENGTH_SHORT + LENGTH_SHORT, ) val scene = this@GalleryDetailScene scene.onModifyFavoritesSuccess(mAddOrRemove) @@ -1623,7 +1640,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { override fun onFailure(e: Exception) { showTip( if (mAddOrRemove) R.string.remove_from_favorite_failure else R.string.add_to_favorite_failure, - LENGTH_LONG + LENGTH_LONG, ) val scene = this@GalleryDetailScene scene.onModifyFavoritesFailure() @@ -1635,8 +1652,10 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } } - private inner class ArchiveListDialogHelper : AdapterView.OnItemClickListener, - DialogInterface.OnDismissListener, EhClient.Callback { + private inner class ArchiveListDialogHelper : + AdapterView.OnItemClickListener, + DialogInterface.OnDismissListener, + EhClient.Callback { private var mProgressView: CircularProgressIndicator? = null private var mErrorText: TextView? = null private var mListView: ListView? = null @@ -1713,7 +1732,8 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { return } else if (mCurrentFunds != null) { val cost = ParserUtils.parseInt( - mArchiveList!![position].cost.removeSuffix("GP").removeSuffix("Credits"), 0 + mArchiveList!![position].cost.removeSuffix("GP").removeSuffix("Credits"), + 0, ) if (cost > maxOf(mCurrentFunds!!.fundsGP, mCurrentFunds!!.fundsC)) { showTip(R.string.insufficient_funds, LENGTH_SHORT) @@ -1729,7 +1749,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { composeBindingGD!!.token!!, mArchiveFormParamOr!!, res, - isHAtH + isHAtH, ) request.setCallback(DownloadArchiveListener(context, composeBindingGD)) request.enqueue(this@GalleryDetailScene) @@ -1777,8 +1797,10 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { } } - private inner class TorrentListDialogHelper : AdapterView.OnItemClickListener, - DialogInterface.OnDismissListener, EhClient.Callback> { + private inner class TorrentListDialogHelper : + AdapterView.OnItemClickListener, + DialogInterface.OnDismissListener, + EhClient.Callback> { private var mProgressView: CircularProgressIndicator? = null private var mErrorText: TextView? = null private var mListView: ListView? = null @@ -1838,7 +1860,7 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { DownloadManager.Request(Uri.parse(url.replace("exhentai.org", "ehtracker.org"))) r.setDestinationInExternalPublicDir( Environment.DIRECTORY_DOWNLOADS, - FileUtils.sanitizeFilename("$name.torrent") + FileUtils.sanitizeFilename("$name.torrent"), ) r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) r.addRequestHeader("Cookie", EhCookieStore.getCookieHeader(url.toHttpUrl())) @@ -1919,13 +1941,16 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { val request = EhRequest() .setMethod(EhClient.METHOD_GET_RATE_GALLERY) .setArgs( - composeBindingGD!!.apiUid, composeBindingGD!!.apiKey!!, - composeBindingGD!!.gid, composeBindingGD!!.token!!, mRatingBar!!.rating + composeBindingGD!!.apiUid, + composeBindingGD!!.apiKey!!, + composeBindingGD!!.gid, + composeBindingGD!!.token!!, + mRatingBar!!.rating, ) .setCallback( RateGalleryListener( - context - ) + context, + ), ) request.enqueue(this@GalleryDetailScene) } @@ -1952,4 +1977,4 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener { return null } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryHolder.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryHolder.kt index b3ca102dc..fa660609f 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryHolder.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryHolder.kt @@ -37,7 +37,7 @@ internal class ListGalleryHolder( private val binding: ItemGalleryListBinding, private val showFavourited: Boolean, thumbWidth: Int, - thumbHeight: Int + thumbHeight: Int, ) : GalleryHolder(binding) { init { val lp = binding.thumb.layoutParams @@ -99,4 +99,4 @@ internal class GridGalleryHolder(private val binding: ItemGalleryGridBinding) : simpleLanguage.text = galleryInfo.simpleLanguage } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt index 4fc2617d3..460b877a4 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.kt @@ -117,8 +117,12 @@ import java.time.ZoneId import java.time.ZoneOffset import com.hippo.ehviewer.download.DownloadManager as downloadManager -class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.Helper, - OnClickFabListener, OnExpandListener { +class GalleryListScene : + SearchBarScene(), + OnDragHandlerListener, + SearchLayout.Helper, + OnClickFabListener, + OnExpandListener { private val mCallback = object : OnBackPressedCallback(false) { override fun handleOnBackPressed() { when (mState) { @@ -132,7 +136,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private var _binding: SceneGalleryListBinding? = null private val binding get() = _binding!! private val selectImageLauncher = registerForActivityResult( - ActivityResultContracts.PickVisualMedia() + ActivityResultContracts.PickVisualMedia(), ) { result: Uri? -> binding.searchLayout.setImageUri(result) } private var mSearchFab: View? = null private val mSearchFabAnimatorListener: Animator.AnimatorListener = @@ -287,8 +291,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H return listOf( GalleryDetailUrlSuggestion( result1.gid, - result1.token - ) + result1.token, + ), ) } val result2 = GalleryPageUrlParser.parse(text, false) @@ -297,8 +301,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H GalleryPageUrlSuggestion( result2.gid, result2.pToken, - result2.page - ) + result2.page, + ), ) } return null @@ -346,8 +350,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H } override fun onCreateViewWithToolbar( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneGalleryListBinding.inflate(inflater, container, false) requireActivity().onBackPressedDispatcher.addCallback(mCallback) @@ -355,11 +360,12 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H mShowActionFab = true mSearchFab = ViewUtils.`$$`(container, R.id.search_fab) ViewCompat.setWindowInsetsAnimationCallback( - binding.root, WindowInsetsAnimationHelper( + binding.root, + WindowInsetsAnimationHelper( WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_STOP, binding.fabLayout, - mSearchFab!!.parent as View - ) + mSearchFab!!.parent as View, + ), ) (binding.fabLayout.parent as ViewGroup).removeView(binding.fabLayout) container!!.addView(binding.fabLayout) @@ -371,8 +377,10 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H binding.contentLayout.fastScroller.setOnDragHandlerListener(this) binding.contentLayout.setFitPaddingTop(paddingTopSB) mAdapter = GalleryListAdapter( - inflater, resources, - binding.contentLayout.recyclerView, Settings.listMode + inflater, + resources, + binding.contentLayout.recyclerView, + Settings.listMode, ) binding.contentLayout.recyclerView.clipToPadding = false binding.contentLayout.recyclerView.clipChildren = false @@ -391,7 +399,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H paddingLeft, paddingTop + paddingTopSB, paddingRight, - paddingBottom + paddingBottomFab + paddingBottom + paddingBottomFab, ) } binding.fabLayout.setAutoCancel(true) @@ -449,7 +457,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private fun showAddQuickSearchDialog( adapter: QsDrawerAdapter, - recyclerView: EasyRecyclerView, tip: TextView + recyclerView: EasyRecyclerView, + tip: TextView, ) { val context = context if (null == context || null == mHelper) { @@ -477,7 +486,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H val builder = EditTextDialogBuilder( context, getSuitableTitleForUrlBuilder(context.resources, mUrlBuilder, false), - getString(R.string.quick_search) + getString(R.string.quick_search), ) builder.setTitle(R.string.add_quick_search_dialog_title) builder.setPositiveButton(android.R.string.ok, null) @@ -486,7 +495,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H val hint = arrayOf(getString(R.string.save_progress)) builder.setMultiChoiceItems( hint, - checked + checked, ) { _: DialogInterface?, which: Int, isChecked: Boolean -> checked[which] = isChecked } val dialog = builder.show() dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener { @@ -537,8 +546,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H } override fun onCreateDrawerView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { val drawerBinding = DrawerListRvBinding.inflate(inflater, container, false) drawerBinding.recyclerViewDrawer.layoutManager = LinearLayoutManager(context) @@ -574,7 +584,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H showAddQuickSearchDialog( qsDrawerAdapter, drawerBinding.recyclerViewDrawer, - drawerBinding.tip + drawerBinding.tip, ) } else if (id == R.id.action_help) { showQuickSearchTipDialog() @@ -655,7 +665,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H datePicker.show(requireActivity().supportFragmentManager, "date-picker") datePicker.addOnPositiveButtonClickListener { v: Long? -> mHelper!!.goTo( - v!!, true + v!!, + true, ) } } @@ -716,34 +727,42 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H val gi = mHelper!!.getDataAtEx(position) ?: return true val downloaded = mDownloadManager.getDownloadState(gi.gid) != DownloadInfo.STATE_INVALID val favourited = gi.favoriteSlot != -2 - val items = if (downloaded) arrayOf( - context.getString(R.string.read), - context.getString(R.string.delete_downloads), - context.getString(if (favourited) R.string.remove_from_favourites else R.string.add_to_favourites), - context.getString(R.string.download_move_dialog_title) - ) else arrayOf( - context.getString(R.string.read), - context.getString(R.string.download), - context.getString(if (favourited) R.string.remove_from_favourites else R.string.add_to_favourites) - ) - val icons = if (downloaded) intArrayOf( - R.drawable.v_book_open_x24, - R.drawable.v_delete_x24, - if (favourited) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, - R.drawable.v_folder_move_x24 - ) else intArrayOf( - R.drawable.v_book_open_x24, - R.drawable.v_download_x24, - if (favourited) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24 - ) + val items = if (downloaded) { + arrayOf( + context.getString(R.string.read), + context.getString(R.string.delete_downloads), + context.getString(if (favourited) R.string.remove_from_favourites else R.string.add_to_favourites), + context.getString(R.string.download_move_dialog_title), + ) + } else { + arrayOf( + context.getString(R.string.read), + context.getString(R.string.download), + context.getString(if (favourited) R.string.remove_from_favourites else R.string.add_to_favourites), + ) + } + val icons = if (downloaded) { + intArrayOf( + R.drawable.v_book_open_x24, + R.drawable.v_delete_x24, + if (favourited) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, + R.drawable.v_folder_move_x24, + ) + } else { + intArrayOf( + R.drawable.v_book_open_x24, + R.drawable.v_download_x24, + if (favourited) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, + ) + } BaseDialogBuilder(context) .setTitle(EhUtils.getSuitableTitle(gi)) .setAdapter( SelectItemWithIconAdapter( context, items, - icons - ) + icons, + ), ) { _: DialogInterface?, which: Int -> when (which) { 0 -> { @@ -759,12 +778,12 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H .setMessage( getString( R.string.download_remove_dialog_message, - gi.title - ) + gi.title, + ), ) .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> mDownloadManager.deleteDownload( - gi.gid + gi.gid, ) } .show() @@ -776,13 +795,13 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H CommonOperations.removeFromFavorites( activity, gi, - RemoveFromFavoriteListener(context) + RemoveFromFavoriteListener(context), ) } else { CommonOperations.addToFavorites( activity, gi, - AddToFavoriteListener(context) + AddToFavoriteListener(context), ) } @@ -1043,7 +1062,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H result.galleryInfoList.forEach { it.thumb?.run { context?.imageLoader?.enqueue( - ImageRequest.Builder(requireContext()).ehUrl(this).build() + ImageRequest.Builder(requireContext()).ehUrl(this).build(), ) } } @@ -1060,7 +1079,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H result.nextPage, null, null, - result.galleryInfoList + result.galleryInfoList, ) } else { mHelper!!.onGetPageData( @@ -1069,7 +1088,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H 0, result.prev, result.next, - result.galleryInfoList + result.galleryInfoList, ) } } @@ -1086,7 +1105,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private annotation class State private inner class GetGalleryListListener( context: Context, - private val mTaskId: Int + private val mTaskId: Int, ) : EhCallback(context) { override fun onSuccess(result: GalleryListParser.Result) { val scene = this@GalleryListScene @@ -1132,7 +1151,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private inner class MoveDialogHelper( private val mLabels: Array, - private val mGi: GalleryInfo + private val mGi: GalleryInfo, ) : DialogInterface.OnClickListener { override fun onClick(dialog: DialogInterface, which: Int) { // Cancel check mode @@ -1189,7 +1208,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H R.string.toplist_alltime, R.string.toplist_pastyear, R.string.toplist_pastmonth, - R.string.toplist_yesterday + R.string.toplist_yesterday, ) text.text = getString(toplists[position]) option.visibility = View.GONE @@ -1243,7 +1262,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private inner class GalleryDetailUrlSuggestion( private val mGid: Long, - private val mToken: String + private val mToken: String, ) : UrlSuggestion() { override fun getDestination(): Int { return R.id.galleryDetailScene @@ -1261,7 +1280,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private inner class GalleryPageUrlSuggestion( private val mGid: Long, private val mPToken: String, - private val mPage: Int + private val mPage: Int, ) : UrlSuggestion() { override fun getDestination(): Int { return R.id.progressScene @@ -1279,7 +1298,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H private inner class GalleryListAdapter( inflater: LayoutInflater, - resources: Resources, recyclerView: RecyclerView, type: Int + resources: Resources, + recyclerView: RecyclerView, + type: Int, ) : GalleryAdapter(inflater, resources, recyclerView, type, true) { override fun getItemCount(): Int { return if (null != mHelper) mHelper!!.size() else 0 @@ -1304,7 +1325,7 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H type: Int, page: Int, index: String?, - isNext: Boolean + isNext: Boolean, ) { val activity = mainActivity if (null == activity || null == mHelper) { @@ -1322,13 +1343,14 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H request.setCallback( GetGalleryListListener( context, - taskId - ) + taskId, + ), ) request.setArgs( File(StringUtils.avoidNull(mUrlBuilder.imagePath)), mUrlBuilder.isUseSimilarityScan, - mUrlBuilder.isOnlySearchCovers, mUrlBuilder.isShowExpunged + mUrlBuilder.isOnlySearchCovers, + mUrlBuilder.isShowExpunged, ) request.enqueue(this@GalleryListScene) } else { @@ -1338,8 +1360,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H request.setCallback( GetGalleryListListener( context, - taskId - ) + taskId, + ), ) request.setArgs(url) request.enqueue(this@GalleryListScene) @@ -1383,18 +1405,18 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H ItemTouchHelper.Callback() { override fun getMovementFlags( recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder + viewHolder: RecyclerView.ViewHolder, ): Int { return makeMovementFlags( ItemTouchHelper.UP or ItemTouchHelper.DOWN, - ItemTouchHelper.LEFT + ItemTouchHelper.LEFT, ) } override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, - target: RecyclerView.ViewHolder + target: RecyclerView.ViewHolder, ): Boolean { val fromPosition = viewHolder.bindingAdapterPosition val toPosition = target.bindingAdapterPosition @@ -1459,7 +1481,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H } private fun getSuitableTitleForUrlBuilder( - resources: Resources, urlBuilder: ListUrlBuilder, appName: Boolean + resources: Resources, + urlBuilder: ListUrlBuilder, + appName: Boolean, ): String? { val keyword = urlBuilder.keyword val category = urlBuilder.category @@ -1492,4 +1516,4 @@ private fun getSuitableTitleForUrlBuilder( } else { null } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsAdapter.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsAdapter.kt index 2fddbe7ee..6c9634b78 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsAdapter.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsAdapter.kt @@ -11,7 +11,7 @@ class GalleryPreviewsAdapter(private val onClick: (GalleryPreview) -> Unit) : BaseListAdapter(PreviewDiffCallback) { class GalleryPreviewHolder( private val binding: ItemGalleryPreviewBinding, - onClick: (GalleryPreview) -> Unit + onClick: (GalleryPreview) -> Unit, ) : BaseViewHolder(binding, onClick) { @SuppressLint("SetTextI18n") override fun bind(item: GalleryPreview) { @@ -23,7 +23,7 @@ class GalleryPreviewsAdapter(private val onClick: (GalleryPreview) -> Unit) : override fun onCreateViewHolder( parent: ViewGroup, - viewType: Int + viewType: Int, ): BaseViewHolder { val inflater = LayoutInflater.from(parent.context) val binding = ItemGalleryPreviewBinding.inflate(inflater, parent, false) @@ -43,4 +43,4 @@ object PreviewDiffCallback : DiffUtil.ItemCallback() { override fun areContentsTheSame(oldItem: GalleryPreview, newItem: GalleryPreview): Boolean { return oldItem == newItem } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.kt index b781f2f6f..2c775a806 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.kt @@ -87,7 +87,8 @@ class GalleryPreviewsScene : BaseToolbarScene() { override fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneGalleryPreviewsBinding.inflate(inflater, container, false) binding.contentLayout.hideFastScroll() @@ -117,7 +118,7 @@ class GalleryPreviewsScene : BaseToolbarScene() { 0, null, null, - mGalleryDetail!!.previewList + mGalleryDetail!!.previewList, ) } return binding.root @@ -172,7 +173,7 @@ class GalleryPreviewsScene : BaseToolbarScene() { result.first.forEach { it.imageUrl.run { context?.imageLoader?.enqueue( - ImageRequest.Builder(requireContext()).ehUrl(this).build() + ImageRequest.Builder(requireContext()).ehUrl(this).build(), ) } } @@ -190,7 +191,7 @@ class GalleryPreviewsScene : BaseToolbarScene() { private inner class GetPreviewListListener( context: Context, - private val mTaskId: Int + private val mTaskId: Int, ) : EhCallback, Int>>(context) { override fun onSuccess(result: Pair, Int>) { val scene = this@GalleryPreviewsScene @@ -211,7 +212,7 @@ class GalleryPreviewsScene : BaseToolbarScene() { type: Int, page: Int, index: String?, - isNext: Boolean + isNext: Boolean, ) { val activity = mainActivity if (null == activity || null == mGalleryDetail) { @@ -265,4 +266,4 @@ class GalleryPreviewsScene : BaseToolbarScene() { const val KEY_NEXT_PAGE = "next_page" private const val KEY_HAS_FIRST_REFRESH = "has_first_refresh" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt index dace8de4a..cffac07fa 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/HistoryScene.kt @@ -131,7 +131,8 @@ class HistoryScene : BaseToolbarScene() { override fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneHistoryBinding.inflate(inflater, container, false) setLiftOnScrollTargetView(binding.recyclerView) @@ -140,7 +141,7 @@ class HistoryScene : BaseToolbarScene() { drawable?.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight) binding.tip.setCompoundDrawables(null, drawable, null, null) val historyData = Pager( - PagingConfig(20) + PagingConfig(20), ) { EhDB.historyLazyList }.flow.cachedIn(viewLifecycleOwner.lifecycleScope) @@ -159,7 +160,7 @@ class HistoryScene : BaseToolbarScene() { lifecycleScope.launchIO { historyData.collectLatest { value -> mAdapter.submitData( - value + value, ) } } @@ -236,34 +237,42 @@ class HistoryScene : BaseToolbarScene() { val activity = mainActivity ?: return val downloaded = mDownloadManager.getDownloadState(gi.gid) != DownloadInfo.STATE_INVALID val favourite = gi.favoriteSlot != -2 - val items = if (downloaded) arrayOf( - context.getString(R.string.read), - context.getString(R.string.delete_downloads), - context.getString(if (favourite) R.string.remove_from_favourites else R.string.add_to_favourites), - context.getString(R.string.download_move_dialog_title) - ) else arrayOf( - context.getString(R.string.read), - context.getString(R.string.download), - context.getString(if (favourite) R.string.remove_from_favourites else R.string.add_to_favourites), - ) - val icons = if (downloaded) intArrayOf( - R.drawable.v_book_open_x24, - R.drawable.v_delete_x24, - if (favourite) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, - R.drawable.v_folder_move_x24 - ) else intArrayOf( - R.drawable.v_book_open_x24, - R.drawable.v_download_x24, - if (favourite) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, - ) + val items = if (downloaded) { + arrayOf( + context.getString(R.string.read), + context.getString(R.string.delete_downloads), + context.getString(if (favourite) R.string.remove_from_favourites else R.string.add_to_favourites), + context.getString(R.string.download_move_dialog_title), + ) + } else { + arrayOf( + context.getString(R.string.read), + context.getString(R.string.download), + context.getString(if (favourite) R.string.remove_from_favourites else R.string.add_to_favourites), + ) + } + val icons = if (downloaded) { + intArrayOf( + R.drawable.v_book_open_x24, + R.drawable.v_delete_x24, + if (favourite) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, + R.drawable.v_folder_move_x24, + ) + } else { + intArrayOf( + R.drawable.v_book_open_x24, + R.drawable.v_download_x24, + if (favourite) R.drawable.v_heart_broken_x24 else R.drawable.v_heart_x24, + ) + } BaseDialogBuilder(context) .setTitle(EhUtils.getSuitableTitle(gi)) .setAdapter( SelectItemWithIconAdapter( context, items, - icons - ) + icons, + ), ) { _: DialogInterface?, which: Int -> when (which) { 0 -> { @@ -279,12 +288,12 @@ class HistoryScene : BaseToolbarScene() { .setMessage( getString( R.string.download_remove_dialog_message, - gi.title - ) + gi.title, + ), ) .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> mDownloadManager.deleteDownload( - gi.gid + gi.gid, ) } .show() @@ -296,13 +305,13 @@ class HistoryScene : BaseToolbarScene() { CommonOperations.removeFromFavorites( activity, gi, - RemoveFromFavoriteListener(context) + RemoveFromFavoriteListener(context), ) } else { CommonOperations.addToFavorites( activity, gi, - AddToFavoriteListener(context) + AddToFavoriteListener(context), ) } @@ -355,10 +364,9 @@ class HistoryScene : BaseToolbarScene() { private class ComposeHolder(val composeView: ComposeView) : RecyclerView.ViewHolder(composeView) - private inner class MoveDialogHelper( private val mLabels: Array, - private val mGi: GalleryInfo + private val mGi: GalleryInfo, ) : DialogInterface.OnClickListener { override fun onClick(dialog: DialogInterface, which: Int) { val downloadManager = DownloadManager @@ -386,7 +394,7 @@ class HistoryScene : BaseToolbarScene() { onClick = ::onItemClick.partially1(gi), onLongClick = ::onItemLongClick.partially1(gi), info = gi, - modifier = Modifier.height(height) + modifier = Modifier.height(height), ) } } @@ -396,7 +404,7 @@ class HistoryScene : BaseToolbarScene() { private inner class HistoryItemTouchHelperCallback : ItemTouchHelper.Callback() { override fun getMovementFlags( recyclerView: RecyclerView, - viewHolder: RecyclerView.ViewHolder + viewHolder: RecyclerView.ViewHolder, ): Int { return makeMovementFlags(0, ItemTouchHelper.LEFT) } @@ -404,7 +412,7 @@ class HistoryScene : BaseToolbarScene() { override fun onMove( recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, - target: RecyclerView.ViewHolder + target: RecyclerView.ViewHolder, ): Boolean { return false } @@ -420,4 +428,4 @@ class HistoryScene : BaseToolbarScene() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/ProgressScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/ProgressScene.kt index 7e15f6230..b79641091 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/ProgressScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/ProgressScene.kt @@ -70,8 +70,8 @@ class ProgressScene : BaseScene(), View.OnClickListener { .setArgs(mGid, mPToken!!, mPage) .setCallback( GetGalleryTokenListener( - context - ) + context, + ), ) request.enqueue() return true @@ -124,7 +124,8 @@ class ProgressScene : BaseScene(), View.OnClickListener { override fun onCreateView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View? { val view = inflater.inflate(R.layout.scene_progress, container, false) val progress = ViewUtils.`$$`(view, R.id.progress) @@ -183,7 +184,7 @@ class ProgressScene : BaseScene(), View.OnClickListener { } private inner class GetGalleryTokenListener( - context: Context + context: Context, ) : EhCallback(context) { override fun onSuccess(result: String) { val scene = this@ProgressScene @@ -207,4 +208,4 @@ class ProgressScene : BaseScene(), View.OnClickListener { private const val KEY_VALID = "valid" private const val KEY_ERROR = "error" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/SearchBarScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/SearchBarScene.kt index 5111fd85d..338f6b337 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/SearchBarScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/SearchBarScene.kt @@ -30,7 +30,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.launch - abstract class SearchBarScene : BaseScene(), ToolBarScene { private var _binding: SceneSearchbarBinding? = null private val binding get() = _binding!! @@ -43,7 +42,8 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { override fun onCreateView( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View { _binding = SceneSearchbarBinding.inflate(inflater, container, false) binding.appbar.statusBarForeground = @@ -61,10 +61,11 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { val layoutManager = LinearLayoutManager(context) binding.searchBarList.layoutManager = layoutManager binding.searchview.addTransitionListener { _, _, newState -> - if (newState == SearchView.TransitionState.SHOWING) + if (newState == SearchView.TransitionState.SHOWING) { onSearchViewExpanded() - else if (newState == SearchView.TransitionState.HIDING) + } else if (newState == SearchView.TransitionState.HIDING) { onSearchViewHidden() + } } binding.searchview.addTransitionListener(mSearchViewOnBackPressedCallback) val contentView = onCreateViewWithToolbar(inflater, binding.root, savedInstanceState) @@ -100,13 +101,13 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { privLockModeStart?.let { setDrawerLockMode( DrawerLayout.LOCK_MODE_LOCKED_CLOSED, - GravityCompat.START + GravityCompat.START, ) } privLockModeEnd?.let { setDrawerLockMode( DrawerLayout.LOCK_MODE_LOCKED_CLOSED, - GravityCompat.END + GravityCompat.END, ) } updateSuggestions() @@ -183,7 +184,6 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { open fun onLongClick(): Boolean { return false } - } private class SuggestionHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { @@ -235,12 +235,11 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { override fun getItemCount(): Int { return mSuggestionList?.size ?: 0 } - } inner class TagSuggestion constructor( private var mHint: String?, - private var mKeyword: String + private var mKeyword: String, ) : Suggestion() { @@ -350,12 +349,13 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene { override fun onStateChanged( searchView: SearchView, previousState: SearchView.TransitionState, - newState: SearchView.TransitionState + newState: SearchView.TransitionState, ) { - if (newState == SearchView.TransitionState.SHOWING) + if (newState == SearchView.TransitionState.SHOWING) { isEnabled = true - else if (newState == SearchView.TransitionState.HIDING) + } else if (newState == SearchView.TransitionState.HIDING) { isEnabled = false + } } } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/ToolBarScene.kt b/app/src/main/java/com/hippo/ehviewer/ui/scene/ToolBarScene.kt index 0e91e3eb2..b74b1c2f2 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/ToolBarScene.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/ToolBarScene.kt @@ -9,7 +9,8 @@ import android.view.ViewGroup interface ToolBarScene { fun onCreateViewWithToolbar( inflater: LayoutInflater, - container: ViewGroup?, savedInstanceState: Bundle? + container: ViewGroup?, + savedInstanceState: Bundle?, ): View fun onNavigationClick() diff --git a/app/src/main/java/com/hippo/ehviewer/ui/widget/Card.kt b/app/src/main/java/com/hippo/ehviewer/ui/widget/Card.kt index 1ef2e0c00..076eb2cbc 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/widget/Card.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/widget/Card.kt @@ -12,21 +12,20 @@ import androidx.compose.ui.graphics.Color fun CrystalCard( onClick: () -> Unit, modifier: Modifier = Modifier, - content: @Composable ColumnScope.() -> Unit + content: @Composable ColumnScope.() -> Unit, ) = OutlinedCard( onClick = onClick, modifier = modifier, border = BorderStroke(CardDefaults.outlinedCardBorder().width, Color.Transparent), - content = content + content = content, ) @Composable fun CrystalCard( modifier: Modifier = Modifier, - content: @Composable ColumnScope.() -> Unit + content: @Composable ColumnScope.() -> Unit, ) = OutlinedCard( modifier = modifier, border = BorderStroke(CardDefaults.outlinedCardBorder().width, Color.Transparent), - content = content + content = content, ) - diff --git a/app/src/main/java/com/hippo/ehviewer/ui/widget/EhAsyncThumb.kt b/app/src/main/java/com/hippo/ehviewer/ui/widget/EhAsyncThumb.kt index 2a8070ac9..db21bc9cc 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/widget/EhAsyncThumb.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/widget/EhAsyncThumb.kt @@ -50,18 +50,21 @@ fun EhAsyncPreview( transform = { if (it is AsyncImagePainter.State.Success) { model.run { - if (offsetX == Int.MIN_VALUE) it - else it.copy( - painter = DrawablePainter( - PreciselyClipDrawable( - it.result.drawable, - offsetX, - offsetY, - clipWidth, - clipHeight - ) + if (offsetX == Int.MIN_VALUE) { + it + } else { + it.copy( + painter = DrawablePainter( + PreciselyClipDrawable( + it.result.drawable, + offsetX, + offsetY, + clipWidth, + clipHeight, + ), + ), ) - ) + } } } else { it diff --git a/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryDetailWidgets.kt b/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryDetailWidgets.kt index c46e93c90..a4baa3f5a 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryDetailWidgets.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryDetailWidgets.kt @@ -37,15 +37,15 @@ import com.hippo.ehviewer.client.data.GalleryInfo private fun GalleryDetailHeaderInfoCard( galleryDetail: GalleryDetail, onClick: () -> Unit, - modifier: Modifier + modifier: Modifier, ) { galleryDetail.run { Card( onClick = onClick, - modifier = modifier + modifier = modifier, ) { ConstraintLayout( - modifier = Modifier.padding(8.dp) + modifier = Modifier.padding(8.dp), ) { val (langRef, sizeRef, favRef, pagesRef, postRef) = createRefs() @@ -55,7 +55,7 @@ private fun GalleryDetailHeaderInfoCard( modifier = Modifier.constrainAs(langRef) { top.linkTo(parent.top) start.linkTo(parent.start) - } + }, ) Text( text = size.orEmpty(), @@ -67,12 +67,12 @@ private fun GalleryDetailHeaderInfoCard( horizontalBias = 1.0f start.linkTo(langRef.end) } - .padding(start = 16.dp) + .padding(start = 16.dp), ) Text( text = stringResource( id = R.string.favored_times, - favoriteCount + favoriteCount, ), style = MaterialTheme.typography.labelMedium, modifier = Modifier @@ -80,13 +80,13 @@ private fun GalleryDetailHeaderInfoCard( start.linkTo(parent.start) top.linkTo(langRef.bottom) } - .padding(top = 8.dp) + .padding(top = 8.dp), ) Text( text = pluralStringResource( id = R.plurals.page_count, pages, - pages + pages, ), style = MaterialTheme.typography.labelMedium, modifier = Modifier @@ -96,7 +96,7 @@ private fun GalleryDetailHeaderInfoCard( horizontalBias = 1.0f start.linkTo(favRef.end) } - .padding(start = 16.dp) + .padding(start = 16.dp), ) Text( text = posted.orEmpty(), @@ -107,7 +107,7 @@ private fun GalleryDetailHeaderInfoCard( start.linkTo(parent.start) top.linkTo(favRef.bottom) } - .padding(top = 8.dp) + .padding(top = 8.dp), ) } } @@ -122,10 +122,10 @@ fun GalleryDetailHeaderCard( onUploaderChipClick: () -> Unit, onBlockUploaderIconClick: () -> Unit, onCategoryChipClick: () -> Unit, - modifier: Modifier + modifier: Modifier, ) { ElevatedCard( - modifier = modifier + modifier = modifier, ) { Row { Card { @@ -134,13 +134,13 @@ fun GalleryDetailHeaderCard( contentScale = ContentScale.Crop, modifier = Modifier .height(dimensionResource(id = R.dimen.gallery_detail_thumb_height)) - .width(dimensionResource(id = R.dimen.gallery_detail_thumb_width)) + .width(dimensionResource(id = R.dimen.gallery_detail_thumb_width)), ) } Spacer(modifier = Modifier.weight(0.5F)) Column( modifier = Modifier.height(dimensionResource(id = R.dimen.gallery_detail_thumb_height)), - horizontalAlignment = Alignment.End + horizontalAlignment = Alignment.End, ) { galleryDetail?.let { GalleryDetailHeaderInfoCard( @@ -148,8 +148,8 @@ fun GalleryDetailHeaderCard( onClick = onInfoCardClick, modifier = Modifier.padding( top = 8.dp, - end = dimensionResource(id = R.dimen.keyline_margin) - ) + end = dimensionResource(id = R.dimen.keyline_margin), + ), ) } Spacer(modifier = Modifier.weight(1F)) @@ -162,9 +162,10 @@ fun GalleryDetailHeaderCard( leadingIcon = { Icon( imageVector = Icons.Default.Label, - contentDescription = null + contentDescription = null, ) - }) + }, + ) val uploaderText = galleryInfo.uploader.orEmpty().toUpperCase(Locale.current) AssistChip( @@ -174,16 +175,17 @@ fun GalleryDetailHeaderCard( leadingIcon = { Icon( imageVector = Icons.Default.PersonAdd, - contentDescription = null + contentDescription = null, ) }, trailingIcon = { Icon( imageVector = Icons.Default.GroupOff, contentDescription = null, - modifier = Modifier.clickable(onClick = onBlockUploaderIconClick) + modifier = Modifier.clickable(onClick = onBlockUploaderIconClick), ) - }) + }, + ) } } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryInfoCard.kt b/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryInfoCard.kt index 253455d21..3088ef40d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryInfoCard.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/widget/GalleryInfoCard.kt @@ -34,23 +34,23 @@ fun ListInfoCard( onClick: () -> Unit, onLongClick: () -> Unit, info: GalleryInfo, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { CrystalCard( - modifier = Modifier.padding(6.dp) + modifier = Modifier.padding(6.dp), ) { Row( modifier = modifier .combinedClickable( onClick = onClick, - onLongClick = onLongClick + onLongClick = onLongClick, ), ) { Card { EhAsyncThumb( model = info.thumb, contentScale = ContentScale.Crop, - modifier = modifier.aspectRatio(0.6666667F) + modifier = modifier.aspectRatio(0.6666667F), ) } Column(Modifier.padding(8.dp, 4.dp)) { @@ -59,7 +59,7 @@ fun ListInfoCard( maxLines = 2, modifier = Modifier.fillMaxWidth(), overflow = TextOverflow.Ellipsis, - style = MaterialTheme.typography.titleSmall + style = MaterialTheme.typography.titleSmall, ) Spacer(modifier = Modifier.weight(1f)) Row(verticalAlignment = Alignment.Bottom) { @@ -68,7 +68,7 @@ fun ListInfoCard( text = info.uploader ?: "(DISOWNED)", maxLines = 1, overflow = TextOverflow.Ellipsis, - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) GalleryListCardRating(rating = info.rating) val categoryColor = EhUtils.getCategoryColor(info.category) @@ -80,7 +80,7 @@ fun ListInfoCard( .padding(vertical = 2.dp, horizontal = 8.dp), color = Color.White, textAlign = TextAlign.Center, - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } Spacer(modifier = Modifier.weight(1f)) @@ -90,24 +90,24 @@ fun ListInfoCard( Icon( Icons.Default.Download, contentDescription = null, - modifier = Modifier.size(16.dp) + modifier = Modifier.size(16.dp), ) } if (info.favoriteSlot != -2) { Icon( Icons.Default.Favorite, contentDescription = null, - modifier = Modifier.size(16.dp) + modifier = Modifier.size(16.dp), ) } Text( text = info.simpleLanguage.orEmpty(), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } Text( text = info.posted.orEmpty(), - style = MaterialTheme.typography.labelLarge + style = MaterialTheme.typography.labelLarge, ) } } diff --git a/app/src/main/java/com/hippo/ehviewer/ui/widget/RatingWidget.kt b/app/src/main/java/com/hippo/ehviewer/ui/widget/RatingWidget.kt index f9bd907ec..947d3db04 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/widget/RatingWidget.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/widget/RatingWidget.kt @@ -32,7 +32,7 @@ fun MetaRatingWidget(rating: Float, ratingSize: Dp, ratingInterval: Dp) { imageVector = Icons.Default.Star, contentDescription = null, modifier = Modifier.size(ratingSize), - tint = colorYellow800 + tint = colorYellow800, ) Spacer(modifier = Modifier.width(ratingInterval)) } @@ -41,7 +41,7 @@ fun MetaRatingWidget(rating: Float, ratingSize: Dp, ratingInterval: Dp) { imageVector = Icons.Default.StarHalf, contentDescription = null, modifier = Modifier.size(ratingSize), - tint = colorYellow800 + tint = colorYellow800, ) Spacer(modifier = Modifier.width(ratingInterval)) } @@ -50,7 +50,7 @@ fun MetaRatingWidget(rating: Float, ratingSize: Dp, ratingInterval: Dp) { imageVector = Icons.Default.StarOutline, contentDescription = null, modifier = Modifier.size(ratingSize), - tint = colorYellow800 + tint = colorYellow800, ) Spacer(modifier = Modifier.width(ratingInterval)) } @@ -62,7 +62,7 @@ fun GalleryListCardRating(rating: Float) { MetaRatingWidget( rating = rating, ratingSize = dimensionResource(id = R.dimen.rating_size), - ratingInterval = dimensionResource(id = R.dimen.rating_interval) + ratingInterval = dimensionResource(id = R.dimen.rating_interval), ) } diff --git a/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.kt b/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.kt index 15ec0f660..f7661d1c1 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.kt +++ b/app/src/main/java/com/hippo/ehviewer/widget/AdvanceSearchTable.kt @@ -31,7 +31,8 @@ import com.hippo.ehviewer.R import com.hippo.yorozuya.NumberUtils class AdvanceSearchTable @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : LinearLayout(context, attrs) { private var mSh: CheckBox private var mSto: CheckBox @@ -64,7 +65,7 @@ class AdvanceSearchTable @JvmOverloads constructor( mSpt.setOnEditorActionListener { v: TextView, _: Int, _: KeyEvent? -> val nextView = v.focusSearch( - FOCUS_DOWN + FOCUS_DOWN, ) nextView?.requestFocus(FOCUS_DOWN) true @@ -107,13 +108,15 @@ class AdvanceSearchTable @JvmOverloads constructor( set(minRating) { (mMinRating.editText!! as AutoCompleteTextView).setText( mArray[if (minRating in 2..5) minRating - 1 else 0], - false + false, ) } var pageFrom: Int get() = if (mSp.isChecked) { NumberUtils.parseIntSafely(mSpf.text.toString(), -1) - } else -1 + } else { + -1 + } set(pageFrom) { if (pageFrom > 0) { mSpf.setText(pageFrom.toString()) @@ -126,7 +129,9 @@ class AdvanceSearchTable @JvmOverloads constructor( var pageTo: Int get() = if (mSp.isChecked) { NumberUtils.parseIntSafely(mSpt.text.toString(), -1) - } else -1 + } else { + -1 + } set(pageTo) { if (pageTo > 0) { mSpt.setText(pageTo.toString()) @@ -143,4 +148,4 @@ class AdvanceSearchTable @JvmOverloads constructor( const val SFU = 0x200 const val SFT = 0x400 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/widget/GalleryInfoContentHelper.kt b/app/src/main/java/com/hippo/ehviewer/widget/GalleryInfoContentHelper.kt index 79c72c77e..f480a0fef 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/GalleryInfoContentHelper.kt +++ b/app/src/main/java/com/hippo/ehviewer/widget/GalleryInfoContentHelper.kt @@ -106,4 +106,4 @@ abstract class GalleryInfoContentHelper : ContentHelper() { companion object { private const val KEY_DATA_MAP = "data_map" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/widget/ResizeableFixedThumb.kt b/app/src/main/java/com/hippo/ehviewer/widget/ResizeableFixedThumb.kt index a5a560561..dea6b986c 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/ResizeableFixedThumb.kt +++ b/app/src/main/java/com/hippo/ehviewer/widget/ResizeableFixedThumb.kt @@ -5,9 +5,10 @@ import android.util.AttributeSet import com.hippo.ehviewer.Settings class ResizeableFixedThumb @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : FixedThumb(context, attrs) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { setMeasuredDimension(Settings.listThumbSize * 2, Settings.listThumbSize * 3) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt index a57a71fd1..1683fdcb2 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt +++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchLayout.kt @@ -26,7 +26,11 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.* +import android.widget.CheckBox +import android.widget.CompoundButton +import android.widget.FrameLayout +import android.widget.ImageView +import android.widget.TextView import androidx.annotation.IntDef import androidx.core.content.edit import androidx.core.view.forEach @@ -51,9 +55,13 @@ import com.hippo.yorozuya.ViewUtils @SuppressLint("InflateParams") class SearchLayout @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : EasyRecyclerView(context, attrs), CompoundButton.OnCheckedChangeListener, View.OnClickListener, - ImageSearchLayout.Helper, OnTabSelectedListener { + context: Context, + attrs: AttributeSet? = null, +) : EasyRecyclerView(context, attrs), + CompoundButton.OnCheckedChangeListener, + View.OnClickListener, + ImageSearchLayout.Helper, + OnTabSelectedListener { @SearchMode private var mSearchMode = SEARCH_MODE_NORMAL @@ -88,7 +96,11 @@ class SearchLayout @JvmOverloads constructor( val paddingH = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_h) val paddingV = resources.getDimensionPixelOffset(R.dimen.search_layout_margin_v) val decoration = MarginItemDecoration( - interval, paddingH, paddingV, paddingH, paddingV + interval, + paddingH, + paddingV, + paddingH, + paddingV, ) addItemDecoration(decoration) decoration.applyPaddings(this) @@ -138,13 +150,12 @@ class SearchLayout @JvmOverloads constructor( mActionView = mInflater.inflate(R.layout.search_action, null) mActionView.layoutParams = LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT + ViewGroup.LayoutParams.WRAP_CONTENT, ) mAction = mActionView.findViewById(R.id.action) mAction.addOnTabSelectedListener(this) } - fun setHelper(helper: Helper?) { mHelper = helper } @@ -218,7 +229,8 @@ class SearchLayout @JvmOverloads constructor( } urlBuilder.keyword = query urlBuilder.category = PreferenceManager.getDefaultSharedPreferences(context).getInt( - SEARCH_CATEGORY_PREF, 0 + SEARCH_CATEGORY_PREF, + 0, ) if (mEnableAdvance) { urlBuilder.advanceSearch = mTableAdvanceSearch.advanceSearch @@ -359,7 +371,8 @@ class SearchLayout @JvmOverloads constructor( private const val ITEM_TYPE_IMAGE = 2 private const val ITEM_TYPE_ACTION = 3 private val SEARCH_ITEM_COUNT_ARRAY = intArrayOf( - 3, 2 + 3, + 2, ) private val mCategoryTable: ArrayList> = arrayListOf( Pair(EhUtils.DOUJINSHI, R.string.doujinshi), @@ -371,20 +384,24 @@ class SearchLayout @JvmOverloads constructor( Pair(EhUtils.IMAGE_SET, R.string.image_set), Pair(EhUtils.COSPLAY, R.string.cosplay), Pair(EhUtils.ASIAN_PORN, R.string.asian_porn), - Pair(EhUtils.MISC, R.string.misc) + Pair(EhUtils.MISC, R.string.misc), ) private val SEARCH_ITEM_TYPE = arrayOf( - intArrayOf(ITEM_TYPE_NORMAL, ITEM_TYPE_NORMAL_ADVANCE, ITEM_TYPE_ACTION), intArrayOf( - ITEM_TYPE_IMAGE, ITEM_TYPE_ACTION - ) + intArrayOf(ITEM_TYPE_NORMAL, ITEM_TYPE_NORMAL_ADVANCE, ITEM_TYPE_ACTION), + intArrayOf( + ITEM_TYPE_IMAGE, + ITEM_TYPE_ACTION, + ), ) } } class IdentifiedChip @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null + context: Context, + attrs: AttributeSet? = null, ) : Chip( - context, attrs + context, + attrs, ) { var idt = 0 -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/image/Image.kt b/app/src/main/java/com/hippo/image/Image.kt index 3e5a93da9..89068d771 100644 --- a/app/src/main/java/com/hippo/image/Image.kt +++ b/app/src/main/java/com/hippo/image/Image.kt @@ -39,7 +39,7 @@ class Image private constructor(private val src: CloseableSource) { } decoder.setTargetColorSpace(colorSpace) decoder.setTargetSampleSize( - calculateSampleSize(info, 2 * screenHeight, 2 * screenWidth) + calculateSampleSize(info, 2 * screenHeight, 2 * screenWidth), ) }.also { if (it !is Animatable) src.close() @@ -62,7 +62,7 @@ class Image private constructor(private val src: CloseableSource) { fun calculateSampleSize(info: ImageInfo, targetHeight: Int, targetWeight: Int): Int { return min( info.size.width / targetWeight, - info.size.height / targetHeight + info.size.height / targetHeight, ).coerceAtLeast(1) } @@ -73,7 +73,7 @@ class Image private constructor(private val src: CloseableSource) { val imageSearchDecoderSampleListener = ImageDecoder.OnHeaderDecodedListener { decoder, info, _ -> decoder.setTargetSampleSize( - calculateSampleSize(info, imageSearchMaxSize, imageSearchMaxSize) + calculateSampleSize(info, imageSearchMaxSize, imageSearchMaxSize), ) } val screenWidth = EhApplication.application.resources.displayMetrics.widthPixels @@ -83,7 +83,11 @@ class Image private constructor(private val src: CloseableSource) { var colorSpace = ColorSpace.get( if (isWideColorGamut && EhApplication.readerPreferences.wideColorGamut() .get() - ) ColorSpace.Named.DISPLAY_P3 else ColorSpace.Named.SRGB + ) { + ColorSpace.Named.DISPLAY_P3 + } else { + ColorSpace.Named.SRGB + }, ) @JvmStatic diff --git a/app/src/main/java/com/hippo/network/CookieDatabase.kt b/app/src/main/java/com/hippo/network/CookieDatabase.kt index f47f6d17d..5dcfc5fb0 100644 --- a/app/src/main/java/com/hippo/network/CookieDatabase.kt +++ b/app/src/main/java/com/hippo/network/CookieDatabase.kt @@ -52,7 +52,7 @@ class Cookie( var hostOnly: Boolean, @PrimaryKey @ColumnInfo(name = "_id") - var id: Long? + var id: Long?, ) @Dao @@ -77,9 +77,9 @@ interface CookiesDao { autoMigrations = [ AutoMigration( from = 1, - to = 2 - ) - ] + to = 2, + ), + ], ) abstract class CookiesDatabase : RoomDatabase() { abstract fun cookiesDao(): CookiesDao @@ -150,6 +150,6 @@ fun Cookie.toOkHttp3Cookie(): OkHttpCookie { private fun OkHttpCookie.toCookie(id: Long? = null): Cookie { return Cookie( - name, value, expiresAt, domain, path, secure, httpOnly, persistent, hostOnly, id + name, value, expiresAt, domain, path, secure, httpOnly, persistent, hostOnly, id, ) } diff --git a/app/src/main/java/com/hippo/network/CookieSet.kt b/app/src/main/java/com/hippo/network/CookieSet.kt index 508706c6f..778ade588 100644 --- a/app/src/main/java/com/hippo/network/CookieSet.kt +++ b/app/src/main/java/com/hippo/network/CookieSet.kt @@ -61,8 +61,8 @@ internal class CookieSet { internal data class Key( val name: String, val domain: String, - val path: String + val path: String, ) { constructor(cookie: Cookie) : this(cookie.name, cookie.domain, cookie.path) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/network/InetValidator.kt b/app/src/main/java/com/hippo/network/InetValidator.kt index caf1d55a2..736ee95ec 100644 --- a/app/src/main/java/com/hippo/network/InetValidator.kt +++ b/app/src/main/java/com/hippo/network/InetValidator.kt @@ -56,4 +56,4 @@ object InetValidator { fun isValidInetPort(inetPort: Int): Boolean { return inetPort in 0..65535 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/network/UrlBuilder.kt b/app/src/main/java/com/hippo/network/UrlBuilder.kt index 9cab7a6ef..a17d109f0 100644 --- a/app/src/main/java/com/hippo/network/UrlBuilder.kt +++ b/app/src/main/java/com/hippo/network/UrlBuilder.kt @@ -41,4 +41,4 @@ class UrlBuilder(private var mRootUrl: String) { sb.toString() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.kt b/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.kt index b343e2ffc..21ebbc597 100644 --- a/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.kt +++ b/app/src/main/java/com/hippo/okhttp/ChromeRequestBuilder.kt @@ -32,4 +32,4 @@ open class ChromeRequestBuilder(url: String) : Request.Builder() { this.addHeader("Accept", CHROME_ACCEPT) this.addHeader("Accept-Language", CHROME_ACCEPT_LANGUAGE) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/text/URLImageGetter.kt b/app/src/main/java/com/hippo/text/URLImageGetter.kt index 4e2b3888b..8bc1650a2 100644 --- a/app/src/main/java/com/hippo/text/URLImageGetter.kt +++ b/app/src/main/java/com/hippo/text/URLImageGetter.kt @@ -26,4 +26,4 @@ class URLImageGetter( override fun getDrawable(source: String): Drawable { return UnikeryDrawable(mTextView, source) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/util/ClipboardUtil.kt b/app/src/main/java/com/hippo/util/ClipboardUtil.kt index 8457ad66e..933d489fe 100644 --- a/app/src/main/java/com/hippo/util/ClipboardUtil.kt +++ b/app/src/main/java/com/hippo/util/ClipboardUtil.kt @@ -45,20 +45,24 @@ infix fun Context.tellClipboardWithToast(text: String?) { @JvmOverloads fun Context.addTextToClipboard(text: CharSequence?, isSensitive: Boolean, useToast: Boolean = false) { getClipboardManager().apply { - setPrimaryClip(ClipData.newPlainText(null, text).apply { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && isSensitive) - description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) + setPrimaryClip( + ClipData.newPlainText(null, text).apply { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && isSensitive) { + description.extras = PersistableBundle().apply { + putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) + } } - }) + }, + ) } // Avoid double notify user since system have done that on Tiramisu above - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { if (this is MainActivity) { showTip(R.string.copied_to_clipboard, BaseScene.LENGTH_SHORT, useToast) } else if (this is SettingsActivity) { showTip(R.string.copied_to_clipboard, BaseScene.LENGTH_SHORT) } + } } fun ClipboardManager.getTextFromClipboard(context: Context): String? { @@ -69,8 +73,10 @@ fun ClipboardManager.getTextFromClipboard(context: Context): String? { fun ClipboardManager.getUrlFromClipboard(context: Context): String? { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && primaryClipDescription?.classificationStatus == ClipDescription.CLASSIFICATION_COMPLETE) { - if ((primaryClipDescription?.getConfidenceScore(TextClassifier.TYPE_URL) - ?.let { it <= 0 }) == true + if (( + primaryClipDescription?.getConfidenceScore(TextClassifier.TYPE_URL) + ?.let { it <= 0 } + ) == true ) { return null } diff --git a/app/src/main/java/com/hippo/util/FDUtils.kt b/app/src/main/java/com/hippo/util/FDUtils.kt index 690f90e8a..82f9ca9d9 100644 --- a/app/src/main/java/com/hippo/util/FDUtils.kt +++ b/app/src/main/java/com/hippo/util/FDUtils.kt @@ -15,4 +15,4 @@ infix fun ParcelFileDescriptor.sendTo(fd: FileDescriptor) { infix fun ParcelFileDescriptor.sendTo(fd: ParcelFileDescriptor) { sendFileTotally(fileDescriptor, fd.fileDescriptor) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/util/URLEncoderCompat.kt b/app/src/main/java/com/hippo/util/URLEncoderCompat.kt index 5640af8bd..f09a844bd 100644 --- a/app/src/main/java/com/hippo/util/URLEncoderCompat.kt +++ b/app/src/main/java/com/hippo/util/URLEncoderCompat.kt @@ -15,4 +15,4 @@ fun encode(s: String, charset: Charset): String { fun encodeUTF8(s: String): String { return encode(s, StandardCharsets.UTF_8) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/widget/ContentLayout.kt b/app/src/main/java/com/hippo/widget/ContentLayout.kt index e9a1a495a..80c6c4474 100644 --- a/app/src/main/java/com/hippo/widget/ContentLayout.kt +++ b/app/src/main/java/com/hippo/widget/ContentLayout.kt @@ -85,7 +85,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout binding.refreshLayout.setProgressViewOffset( true, 0, - fitPaddingTop + LayoutUtils.dp2pix(context, 32f) + fitPaddingTop + LayoutUtils.dp2pix(context, 32f), ) // TODO } @@ -95,25 +95,25 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout binding.recyclerView.paddingLeft, binding.recyclerView.paddingTop, binding.recyclerView.paddingRight, - mRecyclerViewOriginBottom + fitPaddingBottom + mRecyclerViewOriginBottom + fitPaddingBottom, ) binding.tip.setPadding( binding.tip.paddingLeft, binding.tip.paddingTop, binding.tip.paddingRight, - fitPaddingBottom + fitPaddingBottom, ) binding.progress.setPadding( binding.progress.paddingLeft, binding.progress.paddingTop, binding.progress.paddingRight, - fitPaddingBottom + fitPaddingBottom, ) binding.fastScroller.setPadding( binding.fastScroller.paddingLeft, binding.fastScroller.paddingTop, binding.fastScroller.paddingRight, - mFastScrollerOriginBottom + fitPaddingBottom + mFastScrollerOriginBottom + fitPaddingBottom, ) if (fitPaddingBottom > LayoutUtils.dp2pix(context, 16f)) { binding.bottomProgress.setPadding(0, 0, 0, fitPaddingBottom) @@ -206,7 +206,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout mNextPage, null, null, - emptyList() + emptyList(), ) } mCurrentTaskId = mIdGenerator.nextId() @@ -217,7 +217,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout mCurrentTaskType, mCurrentTaskPage, mNext, - true + true, ) } else if (mStartPage > 0 && mEndPage == pages) { binding.bottomProgress.show() @@ -230,7 +230,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout mCurrentTaskType, mCurrentTaskPage, null, - true + true, ) } } @@ -263,7 +263,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout type: Int, page: Int, index: String?, - isNext: Boolean + isNext: Boolean, ) protected abstract val context: Context @@ -327,7 +327,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout nextPage: Int, prev: String?, next: String?, - data: List + data: List, ) { if (mCurrentTaskId == taskId) { val dataSize: Int @@ -410,8 +410,10 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout if (mCurrentTaskType == TYPE_PRE_PAGE_KEEP_POS) { binding.recyclerView.stopScroll() LayoutManagerUtils.scrollToPositionProperly( - binding.recyclerView.layoutManager, context, - dataSize - 1, mOnScrollToPositionListener + binding.recyclerView.layoutManager, + context, + dataSize - 1, + mOnScrollToPositionListener, ) } else { scrollToPosition(0) @@ -505,7 +507,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout Log.e( TAG, "TYPE_REFRESH_PAGE, but mCurrentTaskPage = " + mCurrentTaskPage + - ", mStartPage = " + mStartPage + ", mEndPage = " + mEndPage + ", mStartPage = " + mStartPage + ", mEndPage = " + mEndPage, ) return } @@ -522,7 +524,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout removeDuplicateData( data, oldIndexStart - CHECK_DUPLICATE_RANGE, - oldIndexStart + CHECK_DUPLICATE_RANGE + oldIndexStart + CHECK_DUPLICATE_RANGE, ) val newIndexEnd = oldIndexStart + data.size mData.addAll(oldIndexStart, data) @@ -575,7 +577,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout LayoutManagerUtils.scrollToPositionWithOffset( binding.recyclerView.layoutManager, position, - 0 + 0, ) onScrollToPosition(position) } @@ -815,4 +817,4 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout private const val KEY_NEXT = "next" } } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/widget/FabLayout.kt b/app/src/main/java/com/hippo/widget/FabLayout.kt index 8988df808..c30107478 100644 --- a/app/src/main/java/com/hippo/widget/FabLayout.kt +++ b/app/src/main/java/com/hippo/widget/FabLayout.kt @@ -32,7 +32,9 @@ import com.hippo.yorozuya.AnimationUtils import com.hippo.yorozuya.SimpleAnimatorListener class FabLayout @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, ) : ViewGroup(context, attrs, defStyleAttr), View.OnClickListener { private var mFabSize = 0 private var mFabMiniSize = 0 @@ -92,7 +94,9 @@ class FabLayout @JvmOverloads constructor( private fun getSecondaryFabAt(index: Int): FloatingActionButton? { return if (index < 0 || index >= secondaryFabCount) { null - } else getChildAt(index) as FloatingActionButton + } else { + getChildAt(index) as FloatingActionButton + } } fun setSecondaryFabVisibilityAt(index: Int, visible: Boolean) { @@ -152,7 +156,7 @@ class FabLayout @JvmOverloads constructor( maxWidth = maxWidth.coerceAtLeast(suggestedMinimumWidth) setMeasuredDimension( resolveSizeAndState(maxWidth, widthMeasureSpec, 0), - resolveSizeAndState(maxHeight, heightMeasureSpec, 0) + resolveSizeAndState(maxHeight, heightMeasureSpec, 0), ) } @@ -185,7 +189,7 @@ class FabLayout @JvmOverloads constructor( layoutRight - childWidth, layoutBottom - childHeight, layoutRight, - layoutBottom + layoutBottom, ) } } @@ -378,12 +382,14 @@ class FabLayout @JvmOverloads constructor( override fun onClick(v: View) { if (this === v) { isExpanded = false - } else mOnClickFabListener?.let { - val position = indexOfChild(v) - if (position == childCount - 1) { - it.onClickPrimaryFab(this, v as FloatingActionButton) - } else if (position >= 0 && mExpanded) { - it.onClickSecondaryFab(this, v as FloatingActionButton, position) + } else { + mOnClickFabListener?.let { + val position = indexOfChild(v) + if (position == childCount - 1) { + it.onClickPrimaryFab(this, v as FloatingActionButton) + } else if (position >= 0 && mExpanded) { + it.onClickSecondaryFab(this, v as FloatingActionButton, position) + } } } } @@ -423,4 +429,4 @@ class FabLayout @JvmOverloads constructor( private const val STATE_KEY_AUTO_CANCEL = "auto_cancel" private const val STATE_KEY_EXPANDED = "expanded" } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/widget/LoadImageView.kt b/app/src/main/java/com/hippo/widget/LoadImageView.kt index 71f5704c1..37101e0fd 100644 --- a/app/src/main/java/com/hippo/widget/LoadImageView.kt +++ b/app/src/main/java/com/hippo/widget/LoadImageView.kt @@ -33,8 +33,11 @@ private val application = EhApplication.application private val errorDrawable = AppCompatResources.getDrawable(application, R.drawable.image_failed) open class LoadImageView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : FixedAspectImageView(context, attrs, defStyleAttr), View.OnClickListener, + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, +) : FixedAspectImageView(context, attrs, defStyleAttr), + View.OnClickListener, View.OnLongClickListener { private var mOffsetX = Integer.MIN_VALUE private var mOffsetY = Integer.MIN_VALUE @@ -90,7 +93,7 @@ open class LoadImageView @JvmOverloads constructor( super.setImageDrawable(errorDrawable) setRetry(true) }, - { _, _ -> setRetry(false) } + { _, _ -> setRetry(false) }, ) ehUrl(url) } diff --git a/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.kt b/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.kt index 6b7ed49f8..0f0cd90d7 100644 --- a/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.kt +++ b/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.kt @@ -52,12 +52,12 @@ class AutoGridLayoutManager(context: Context?, columnSize: Int, private var fake val spanCount = when (mStrategy) { STRATEGY_MIN_SIZE -> getSpanCountForMinSize( totalSpace, - mColumnSize + mColumnSize, ) STRATEGY_SUITABLE_SIZE -> getSpanCountForSuitableSize( totalSpace, - mColumnSize + mColumnSize, ) else -> getSpanCountForMinSize(totalSpace, mColumnSize) @@ -67,4 +67,4 @@ class AutoGridLayoutManager(context: Context?, columnSize: Int, private var fake } super.onLayoutChildren(recycler, state) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/widget/recyclerview/AutoStaggeredGridLayoutManager.kt b/app/src/main/java/com/hippo/widget/recyclerview/AutoStaggeredGridLayoutManager.kt index f50912a96..46ccd6b95 100644 --- a/app/src/main/java/com/hippo/widget/recyclerview/AutoStaggeredGridLayoutManager.kt +++ b/app/src/main/java/com/hippo/widget/recyclerview/AutoStaggeredGridLayoutManager.kt @@ -51,38 +51,38 @@ class AutoStaggeredGridLayoutManager(columnSize: Int, orientation: Int) : recycler: RecyclerView.Recycler, state: RecyclerView.State, widthSpec: Int, - heightSpec: Int + heightSpec: Int, ) { if (mColumnSizeChanged && mColumnSize > 0) { val totalSpace = if (orientation == VERTICAL) { check( View.MeasureSpec.EXACTLY == View.MeasureSpec.getMode( - widthSpec - ) + widthSpec, + ), ) { "RecyclerView need a fixed width for AutoStaggeredGridLayoutManager" } View.MeasureSpec.getSize(widthSpec) - paddingRight - paddingLeft } else { check( View.MeasureSpec.EXACTLY == View.MeasureSpec.getMode( - heightSpec - ) + heightSpec, + ), ) { "RecyclerView need a fixed height for AutoStaggeredGridLayoutManager" } View.MeasureSpec.getSize(heightSpec) - paddingTop - paddingBottom } val spanCount = when (mStrategy) { STRATEGY_MIN_SIZE -> getSpanCountForMinSize( totalSpace, - mColumnSize + mColumnSize, ) STRATEGY_SUITABLE_SIZE -> getSpanCountForSuitableSize( totalSpace, - mColumnSize + mColumnSize, ) else -> getSpanCountForMinSize( totalSpace, - mColumnSize + mColumnSize, ) } setSpanCount(spanCount) @@ -100,4 +100,4 @@ fun getSpanCountForSuitableSize(total: Int, single: Int): Int { fun getSpanCountForMinSize(total: Int, single: Int): Int { return (total / single).coerceAtLeast(1) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/hippo/yorozuya/collect/IntList.kt b/app/src/main/java/com/hippo/yorozuya/collect/IntList.kt index 22d516460..fd3188f14 100644 --- a/app/src/main/java/com/hippo/yorozuya/collect/IntList.kt +++ b/app/src/main/java/com/hippo/yorozuya/collect/IntList.kt @@ -5,4 +5,4 @@ import kotlinx.parcelize.Parcelize @Parcelize class IntList constructor(private val delegate: MutableList = mutableListOf()) : - Parcelable, MutableList by delegate \ No newline at end of file + Parcelable, MutableList by delegate diff --git a/app/src/main/java/com/hippo/yorozuya/collect/LongList.kt b/app/src/main/java/com/hippo/yorozuya/collect/LongList.kt index ba5abc925..4b5d10ed2 100644 --- a/app/src/main/java/com/hippo/yorozuya/collect/LongList.kt +++ b/app/src/main/java/com/hippo/yorozuya/collect/LongList.kt @@ -5,4 +5,4 @@ import kotlinx.parcelize.Parcelize @Parcelize class LongList constructor(private val delegate: MutableList = mutableListOf()) : - Parcelable, MutableList by delegate \ No newline at end of file + Parcelable, MutableList by delegate diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt index 2ce45cd46..96b6d3db3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/Page.kt @@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.source.model import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow -open class Page(val index: Int) { +open class Page(val index: Int) { val number: Int get() = index + 1 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 d9ddbbc00..e0b0a8a14 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 @@ -73,11 +73,11 @@ import com.hippo.ehviewer.gallery.EhPageLoader import com.hippo.ehviewer.gallery.PageLoader2 import com.hippo.ehviewer.ui.EhActivity import com.hippo.image.Image -import com.hippo.util.sendTo import com.hippo.unifile.UniFile import com.hippo.util.ExceptionUtils import com.hippo.util.getParcelableCompat import com.hippo.util.getParcelableExtraCompat +import com.hippo.util.sendTo import com.hippo.yorozuya.FileUtils import dev.chrisbanes.insetter.applyInsetter import eu.kanade.tachiyomi.ui.reader.model.ReaderPage @@ -128,7 +128,7 @@ class ReaderActivity : EhActivity() { private set private var saveImageToLauncher = registerForActivityResult( - CreateDocument("todo/todo") + CreateDocument("todo/todo"), ) { uri -> if (uri != null) { val filepath = AppConfig.getExternalTempDir().toString() + File.separator + mCacheFileName @@ -147,7 +147,7 @@ class ReaderActivity : EhActivity() { Toast.makeText( this@ReaderActivity, getString(R.string.image_saved, uri.path), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() } } @@ -162,7 +162,7 @@ class ReaderActivity : EhActivity() { private var dialogShown = false private lateinit var dialog: AlertDialog private var requestStoragePermissionLauncher = registerForActivityResult( - ActivityResultContracts.RequestPermission() + ActivityResultContracts.RequestPermission(), ) { result -> if (result!! && mSavingPage != -1) { saveImage(mSavingPage) @@ -198,14 +198,16 @@ class ReaderActivity : EhActivity() { grantUriPermission( BuildConfig.APPLICATION_ID, mUri, - Intent.FLAG_GRANT_READ_URI_PERMISSION + Intent.FLAG_GRANT_READ_URI_PERMISSION, ) } catch (e: Exception) { Toast.makeText(this, R.string.error_reading_failed, Toast.LENGTH_SHORT).show() } val continuation: AtomicReference?> = AtomicReference(null) - mGalleryProvider = ArchivePageLoader(this, mUri!!, + mGalleryProvider = ArchivePageLoader( + this, + mUri!!, flow { if (!dialogShown) { withUIContext { @@ -214,9 +216,9 @@ class ReaderActivity : EhActivity() { show() getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val passwd = builder.text - if (passwd.isEmpty()) + if (passwd.isEmpty()) { builder.setError(getString(R.string.passwd_cannot_be_empty)) - else { + } else { continuation.getAndSet(null)?.resume(passwd) } } @@ -237,7 +239,7 @@ class ReaderActivity : EhActivity() { builder.setError(getString(R.string.passwd_wrong)) } } - } + }, ) } } @@ -274,9 +276,11 @@ class ReaderActivity : EhActivity() { mGalleryProvider?.let { lifecycleScope.launchIO { it.start() - if (it.awaitReady()) withUIContext { - viewer?.setGalleryProvider(it) - moveToPageIndex(0) + if (it.awaitReady()) { + withUIContext { + viewer?.setGalleryProvider(it) + moveToPageIndex(0) + } } } } @@ -298,7 +302,11 @@ class ReaderActivity : EhActivity() { super.onCreate(savedInstanceState) window.colorMode = if (Image.isWideColorGamut && readerPreferences.wideColorGamut() .get() - ) ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT else ActivityInfo.COLOR_MODE_DEFAULT + ) { + ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT + } else { + ActivityInfo.COLOR_MODE_DEFAULT + } if (savedInstanceState == null) { onInit() } else { @@ -333,8 +341,9 @@ class ReaderActivity : EhActivity() { dialog.dismiss() // Get start page - if (mCurrentIndex == 0) + if (mCurrentIndex == 0) { mCurrentIndex = if (mPage >= 0) mPage else mGalleryProvider!!.startPage + } val viewerMode = ReadingModeType.fromPreference(readerPreferences.defaultReadingMode().get()) binding.actionReadingMode.setImageResource(viewerMode.iconRes) @@ -373,7 +382,7 @@ class ReaderActivity : EhActivity() { val file = mGalleryProvider!!.save( page, UniFile.fromFile(dir)!!, - mGalleryProvider!!.getImageFilename(page) + mGalleryProvider!!.getImageFilename(page), ) if (file == null) { Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show() @@ -386,7 +395,7 @@ class ReaderActivity : EhActivity() { } var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( - MimeTypeMap.getFileExtensionFromUrl(filename) + MimeTypeMap.getFileExtensionFromUrl(filename), ) if (TextUtils.isEmpty(mimeType)) { mimeType = "image/jpeg" @@ -395,18 +404,19 @@ class ReaderActivity : EhActivity() { val uri = FileProvider.getUriForFile( this, BuildConfig.APPLICATION_ID + ".fileprovider", - File(dir, filename) + File(dir, filename), ) val intent = Intent() intent.action = Intent.ACTION_SEND intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.putExtra(Intent.EXTRA_STREAM, uri) - if (mGalleryInfo != null) + if (mGalleryInfo != null) { intent.putExtra( Intent.EXTRA_TEXT, - EhUrl.getGalleryDetailUrl(mGalleryInfo!!.gid, mGalleryInfo!!.token) + EhUrl.getGalleryDetailUrl(mGalleryInfo!!.gid, mGalleryInfo!!.token), ) + } intent.setDataAndType(uri, mimeType) try { @@ -415,7 +425,6 @@ class ReaderActivity : EhActivity() { ExceptionUtils.throwIfFatal(e) Toast.makeText(this, R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show() } - } fun copyImage(page: Int) { @@ -431,7 +440,7 @@ class ReaderActivity : EhActivity() { val file = mGalleryProvider!!.save( page, UniFile.fromFile(dir)!!, - mGalleryProvider!!.getImageFilename(page) + mGalleryProvider!!.getImageFilename(page), ) if (file == null) { Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show() @@ -446,7 +455,7 @@ class ReaderActivity : EhActivity() { val uri = FileProvider.getUriForFile( this, BuildConfig.APPLICATION_ID + ".fileprovider", - File(dir, filename) + File(dir, filename), ) val clipboardManager = getSystemService(ClipboardManager::class.java) @@ -464,7 +473,7 @@ class ReaderActivity : EhActivity() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission( this, - Manifest.permission.WRITE_EXTERNAL_STORAGE + Manifest.permission.WRITE_EXTERNAL_STORAGE, ) != PackageManager.PERMISSION_GRANTED ) { mSavingPage = page @@ -474,7 +483,7 @@ class ReaderActivity : EhActivity() { val filename = mGalleryProvider!!.getImageFilenameWithExtension(page) var mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( - MimeTypeMap.getFileExtensionFromUrl(filename) + MimeTypeMap.getFileExtensionFromUrl(filename), ) if (TextUtils.isEmpty(mimeType)) { mimeType = "image/jpeg" @@ -489,14 +498,14 @@ class ReaderActivity : EhActivity() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { values.put( MediaStore.MediaColumns.RELATIVE_PATH, - Environment.DIRECTORY_PICTURES + File.separator + AppConfig.APP_DIRNAME + Environment.DIRECTORY_PICTURES + File.separator + AppConfig.APP_DIRNAME, ) values.put(MediaStore.MediaColumns.IS_PENDING, 1) realPath = Environment.DIRECTORY_PICTURES + File.separator + AppConfig.APP_DIRNAME } else { val path = File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), - AppConfig.APP_DIRNAME + AppConfig.APP_DIRNAME, ) realPath = path.toString() if (!FileUtils.ensureDirectory(path)) { @@ -528,7 +537,7 @@ class ReaderActivity : EhActivity() { Toast.makeText( this, getString(R.string.image_saved, realPath + File.separator + filename), - Toast.LENGTH_SHORT + Toast.LENGTH_SHORT, ).show() } @@ -544,7 +553,7 @@ class ReaderActivity : EhActivity() { val file = mGalleryProvider!!.save( page, UniFile.fromFile(dir)!!, - mGalleryProvider!!.getImageFilename(page) + mGalleryProvider!!.getImageFilename(page), ) if (file == null) { Toast.makeText(this, R.string.error_cant_save_image, Toast.LENGTH_SHORT).show() @@ -603,7 +612,7 @@ class ReaderActivity : EhActivity() { private val windowInsetsController by lazy { WindowInsetsControllerCompat( window, - binding.root + binding.root, ) } @@ -810,7 +819,6 @@ class ReaderActivity : EhActivity() { } */ - /** * Dispatches a key event. If the viewer doesn't handle it, call the default implementation. */ @@ -1012,12 +1020,12 @@ class ReaderActivity : EhActivity() { merge( readerPreferences.grayscale().changes(), - readerPreferences.invertedColors().changes() + readerPreferences.invertedColors().changes(), ) .onEach { setLayerPaint( readerPreferences.grayscale().get(), - readerPreferences.invertedColors().get() + readerPreferences.invertedColors().get(), ) } .launchIn(lifecycleScope) @@ -1151,10 +1159,14 @@ class ReaderActivity : EhActivity() { } private fun setLayerPaint(grayscale: Boolean, invertedColors: Boolean) { - val paint = if (grayscale || invertedColors) getCombinedPaint( - grayscale, - invertedColors - ) else null + val paint = if (grayscale || invertedColors) { + getCombinedPaint( + grayscale, + invertedColors, + ) + } else { + null + } binding.viewerContainer.setLayerType(LAYER_TYPE_HARDWARE, paint) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/PageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/PageLoader.kt index b5bd90e4a..38915bc4c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/PageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/PageLoader.kt @@ -16,7 +16,7 @@ abstract class PageLoader { private val mImageCache = lruCache( maxSize = (OSUtils.getTotalMemory() / 16).toInt().coerceIn(MIN_CACHE_SIZE, MAX_CACHE_SIZE), sizeOf = { _, v -> v.size }, - onEntryRemoved = { _, _, o, _ -> o.recycle() } + onEntryRemoved = { _, _, o, _ -> o.recycle() }, ) val mPages by lazy { check(size > 0) @@ -55,9 +55,10 @@ abstract class PageLoader { val pagesAbsent = ((index - 5).coerceAtLeast(0) until (mPreloads + index).coerceAtMost(size)).mapNotNull { it.takeIf { mImageCache[it] == null } } preloadPages( - pagesAbsent, (index - 10).coerceAtLeast(0) to (mPreloads + index + 10).coerceAtMost( - size - ) + pagesAbsent, + (index - 10).coerceAtLeast(0) to (mPreloads + index + 10).coerceAtMost( + size, + ), ) } @@ -88,8 +89,9 @@ abstract class PageLoader { } fun notifyPageSucceed(index: Int, image: Image) { - if (mImageCache[index] != image) + if (mImageCache[index] != image) { mImageCache.put(index, image) + } mPages[index].image = image mPages[index].status.value = Page.State.READY } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt index 3b082fb52..8bb7ef111 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderColorFilterSettings.kt @@ -12,9 +12,9 @@ import androidx.core.graphics.green import androidx.core.graphics.red import androidx.core.widget.NestedScrollView import androidx.lifecycle.lifecycleScope -import eu.kanade.tachiyomi.core.preference.getAndSet import com.hippo.ehviewer.databinding.ReaderColorFilterSettingsBinding import com.hippo.image.Image +import eu.kanade.tachiyomi.core.preference.getAndSet import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.util.preference.asHotFlow import eu.kanade.tachiyomi.util.preference.bindToPreference @@ -36,8 +36,9 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr addView(binding.root) binding.wideColorGamut.isEnabled = Image.isWideColorGamut - if (!Image.isWideColorGamut) + if (!Image.isWideColorGamut) { readerPreferences.wideColorGamut().set(false) + } binding.wideColorGamut.bindToPreference(readerPreferences.wideColorGamut()) readerPreferences.wideColorGamut().asHotFlow { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt index 4ebd6c0b5..f9c8b4232 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderReadingModeSettings.kt @@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.launchIn */ class ReaderReadingModeSettings @JvmOverloads constructor( context: Context, - attrs: AttributeSet? = null + attrs: AttributeSet? = null, ) : NestedScrollView(context, attrs) { @@ -59,7 +59,8 @@ class ReaderReadingModeSettings @JvmOverloads constructor( } binding.viewer.setSelection( ReaderActivity.readerPreferences.defaultReadingMode().get() - .let { ReadingModeType.fromPreference(it).prefValue }) + .let { ReadingModeType.fromPreference(it).prefValue }, + ) binding.rotationMode.onItemSelectedListener = { position -> val rotationType = OrientationType.fromSpinner(position) @@ -68,7 +69,8 @@ class ReaderReadingModeSettings @JvmOverloads constructor( } binding.rotationMode.setSelection( ReaderActivity.readerPreferences.defaultOrientationType().get() - .let { OrientationType.fromPreference(it).prefValue }) + .let { OrientationType.fromPreference(it).prefValue }, + ) } /** @@ -80,7 +82,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor( binding.pagerPrefsGroup.tappingInverted.bindToPreference( readerPreferences.pagerNavInverted(), - PreferenceValues.TappingInvertMode::class.java + PreferenceValues.TappingInvertMode::class.java, ) binding.pagerPrefsGroup.navigatePan.bindToPreference(readerPreferences.navigateToPan()) @@ -112,7 +114,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor( binding.webtoonPrefsGroup.tappingInverted.bindToPreference( readerPreferences.webtoonNavInverted(), - PreferenceValues.TappingInvertMode::class.java + PreferenceValues.TappingInvertMode::class.java, ) binding.webtoonPrefsGroup.webtoonNav.bindToPreference(readerPreferences.navigationModeWebtoon()) @@ -122,7 +124,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor( // binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(readerPreferences.cropBordersWebtoon()) binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference( readerPreferences.webtoonSidePadding(), - R.array.webtoon_side_padding_values + R.array.webtoon_side_padding_values, ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt index 47e61601f..390655ac0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt @@ -35,8 +35,9 @@ class ReaderSettingsSheet( valueAnimator.addUpdateListener { window?.run { setDimAmount(it.animatedValue as Float) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { attributes.blurBehindRadius = (it.animatedValue as Float * 50).toInt() + } } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index ad6e8ddbd..d03ab72e6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -155,16 +155,19 @@ class PagerPageHolder( private fun setImage(drawable: Drawable) { progressIndicator.setProgress(0) errorLayout?.root?.isVisible = false - setImage(drawable, + setImage( + drawable, Config( zoomDuration = viewer.config.doubleTapAnimDuration, minimumScaleType = viewer.config.imageScaleType, cropBorders = viewer.config.imageCropBorders, zoomStartPosition = viewer.config.imageZoomType, landscapeZoom = viewer.config.landscapeZoom, - ),) - if (drawable !is Animatable) + ), + ) + if (drawable !is Animatable) { pageBackground = background + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 20df6d4c4..13928d21e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -197,12 +197,14 @@ class WebtoonPageHolder( private fun setImage(drawable: Drawable) { progressIndicator.setProgress(0) removeErrorLayout() - frame.setImage(drawable, + frame.setImage( + drawable, ReaderPageImageView.Config( - zoomDuration = viewer.config.doubleTapAnimDuration, - minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH, - cropBorders = viewer.config.imageCropBorders, - ),) + zoomDuration = viewer.config.doubleTapAnimDuration, + minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH, + cropBorders = viewer.config.imageCropBorders, + ), + ) } /** 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 eba9e3468..0a051418f 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 @@ -62,7 +62,6 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr */ private var currentPage: Any? = null - private val threshold: Int = 13 private var longPressed = false diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index c013b5308..ef1564f39 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -7,7 +7,6 @@ import android.content.pm.PackageManager import android.content.res.Configuration import android.content.res.Resources import android.graphics.Color -import android.graphics.drawable.Drawable import android.net.ConnectivityManager import android.net.NetworkCapabilities import android.net.Uri @@ -222,7 +221,7 @@ fun Context.getUriSize(uri: Uri): Long? { */ fun Context.isNavigationBarNeedsScrim(): Boolean { return Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || - InternalResourceHelper.getBoolean(this, "config_navBarNeedsScrim", true) + InternalResourceHelper.getBoolean(this, "config_navBarNeedsScrim", true) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt index 50b3f850f..bba821d92 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MaterialSpinnerView.kt @@ -16,8 +16,8 @@ import androidx.core.view.forEach import androidx.core.view.get import androidx.core.view.size import com.hippo.ehviewer.R -import eu.kanade.tachiyomi.core.preference.Preference import com.hippo.ehviewer.databinding.PrefSpinnerBinding +import eu.kanade.tachiyomi.core.preference.Preference import eu.kanade.tachiyomi.util.system.getResourceColor class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :