From b66047e084190533c3a86acc97b06070e7b1e240 Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 4 Nov 2020 18:07:40 +0100 Subject: [PATCH] Fix ktlint errors --- app/build.gradle | 2 +- .../java/org/schabi/newpipe/about/License.kt | 10 +-- .../newpipe/database/feed/dao/FeedDAO.kt | 7 +- .../newpipe/database/stream/dao/StreamDAO.kt | 7 +- .../database/stream/model/StreamEntity.kt | 6 +- .../newpipe/local/feed/FeedDatabaseManager.kt | 16 +++-- .../newpipe/local/feed/FeedViewModel.kt | 11 +-- .../local/feed/service/FeedLoadService.kt | 6 +- .../player/event/BasePlayerGestureListener.kt | 71 +++++++++++++------ .../shandian/giga/get/MissionRecoveryInfo.kt | 10 +-- 10 files changed, 99 insertions(+), 47 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6cf71e7ed..1df08292f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -150,7 +150,7 @@ task formatKtlint(type: JavaExec) { } afterEvaluate { - preDebugBuild.dependsOn runCheckstyle, runKtlint + preDebugBuild.dependsOn formatKtlint, runCheckstyle, runKtlint } dependencies { diff --git a/app/src/main/java/org/schabi/newpipe/about/License.kt b/app/src/main/java/org/schabi/newpipe/about/License.kt index 00a66c84a..ed0c9927f 100644 --- a/app/src/main/java/org/schabi/newpipe/about/License.kt +++ b/app/src/main/java/org/schabi/newpipe/about/License.kt @@ -2,8 +2,8 @@ package org.schabi.newpipe.about import android.net.Uri import android.os.Parcelable -import java.io.Serializable import kotlinx.android.parcel.Parcelize +import java.io.Serializable /** * Class for storing information about a software license. @@ -12,8 +12,8 @@ import kotlinx.android.parcel.Parcelize class License(val name: String, val abbreviation: String, val filename: String) : Parcelable, Serializable { val contentUri: Uri get() = Uri.Builder() - .scheme("file") - .path("/android_asset") - .appendPath(filename) - .build() + .scheme("file") + .path("/android_asset") + .appendPath(filename) + .build() } diff --git a/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt b/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt index f338a53ca..f216ba1d8 100644 --- a/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/feed/dao/FeedDAO.kt @@ -1,6 +1,11 @@ package org.schabi.newpipe.database.feed.dao -import androidx.room.* +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import androidx.room.Transaction +import androidx.room.Update import io.reactivex.rxjava3.core.Flowable import org.schabi.newpipe.database.feed.model.FeedEntity import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity diff --git a/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt b/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt index 4f328d6c0..be8590382 100644 --- a/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt +++ b/app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt @@ -1,6 +1,11 @@ package org.schabi.newpipe.database.stream.dao -import androidx.room.* +import androidx.room.ColumnInfo +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import androidx.room.Transaction import io.reactivex.rxjava3.core.Flowable import org.schabi.newpipe.database.BasicDAO import org.schabi.newpipe.database.stream.model.StreamEntity diff --git a/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamEntity.kt b/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamEntity.kt index 307c898ea..0f3e18e7b 100644 --- a/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamEntity.kt +++ b/app/src/main/java/org/schabi/newpipe/database/stream/model/StreamEntity.kt @@ -1,6 +1,10 @@ package org.schabi.newpipe.database.stream.model -import androidx.room.* +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.Ignore +import androidx.room.Index +import androidx.room.PrimaryKey import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_SERVICE_ID import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_TABLE import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_URL diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt index 42d8bcfc3..9a4832c81 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedDatabaseManager.kt @@ -7,9 +7,6 @@ import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Flowable import io.reactivex.rxjava3.core.Maybe import io.reactivex.rxjava3.schedulers.Schedulers -import java.time.LocalDate -import java.time.OffsetDateTime -import java.time.ZoneOffset import org.schabi.newpipe.MainActivity.DEBUG import org.schabi.newpipe.NewPipeDatabase import org.schabi.newpipe.database.feed.model.FeedEntity @@ -19,6 +16,9 @@ import org.schabi.newpipe.database.stream.model.StreamEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.extractor.stream.StreamType import org.schabi.newpipe.local.subscription.FeedGroupIcon +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.ZoneOffset class FeedDatabaseManager(context: Context) { private val database = NewPipeDatabase.getInstance(context) @@ -31,7 +31,7 @@ class FeedDatabaseManager(context: Context) { * Only items that are newer than this will be saved. */ val FEED_OLDEST_ALLOWED_DATE: OffsetDateTime = LocalDate.now().minusWeeks(13) - .atStartOfDay().atOffset(ZoneOffset.UTC) + .atStartOfDay().atOffset(ZoneOffset.UTC) } fun groups() = feedGroupTable.getAll() @@ -92,8 +92,12 @@ class FeedDatabaseManager(context: Context) { feedTable.insertAll(feedEntities) } - feedTable.setLastUpdatedForSubscription(FeedLastUpdatedEntity(subscriptionId, - OffsetDateTime.now(ZoneOffset.UTC))) + feedTable.setLastUpdatedForSubscription( + FeedLastUpdatedEntity( + subscriptionId, + OffsetDateTime.now(ZoneOffset.UTC) + ) + ) } fun removeOrphansOrOlderStreams(oldestAllowedDate: OffsetDateTime = FEED_OLDEST_ALLOWED_DATE) { diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt index 7802db272..84f913409 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt @@ -13,7 +13,10 @@ import org.schabi.newpipe.database.feed.model.FeedGroupEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.ktx.toCalendar import org.schabi.newpipe.local.feed.service.FeedEventManager -import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.* +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ErrorResultEvent +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.IdleEvent +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ProgressEvent +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.SuccessResultEvent import org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT import java.time.OffsetDateTime import java.util.concurrent.TimeUnit @@ -37,9 +40,9 @@ class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEn feedDatabaseManager.asStreamItems(groupId), feedDatabaseManager.notLoadedCount(groupId), feedDatabaseManager.oldestSubscriptionUpdate(groupId), - Function4 { t1: FeedEventManager.Event, t2: List, t3: Long, t4: List -> - return@Function4 CombineResultHolder(t1, t2, t3, t4.firstOrNull()) - } + Function4 { t1: FeedEventManager.Event, t2: List, t3: Long, t4: List -> + return@Function4 CombineResultHolder(t1, t2, t3, t4.firstOrNull()) + } ) .throttleLatest(DEFAULT_THROTTLE_TIMEOUT, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt b/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt index 7173ece84..ddbbea23d 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt @@ -49,7 +49,9 @@ import org.schabi.newpipe.extractor.ListInfo import org.schabi.newpipe.extractor.exceptions.ReCaptchaException import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.local.feed.FeedDatabaseManager -import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.* +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ErrorResultEvent +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ProgressEvent +import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.SuccessResultEvent import org.schabi.newpipe.local.feed.service.FeedEventManager.postEvent import org.schabi.newpipe.local.subscription.SubscriptionManager import org.schabi.newpipe.util.ExceptionUtils @@ -262,7 +264,7 @@ class FeedLoadService : Service() { override fun onComplete() { if (maxProgress.get() == 0) { - postEvent(IdleEvent) + postEvent(FeedEventManager.Event.IdleEvent) stopService() return diff --git a/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt b/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt index 5bd13a569..043e7f31d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt +++ b/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt @@ -118,22 +118,30 @@ abstract class BasePlayerGestureListener( initSecPointerX = event.getX(1) initSecPointerY = event.getY(1) // record distance between fingers - initPointerDistance = hypot(initFirstPointerX - initSecPointerX.toDouble(), - initFirstPointerY - initSecPointerY.toDouble()) + initPointerDistance = hypot( + initFirstPointerX - initSecPointerX.toDouble(), + initFirstPointerY - initSecPointerY.toDouble() + ) isResizing = true } if (event.action == MotionEvent.ACTION_MOVE && !isMovingInPopup && isResizing) { if (DEBUG) { - Log.d(TAG, "onTouch() ACTION_MOVE > v = [$v], e1.getRaw = [${event.rawX}" + - ", ${event.rawY}]") + Log.d( + TAG, + "onTouch() ACTION_MOVE > v = [$v], e1.getRaw =" + + "[${event.rawX}, ${event.rawY}]" + ) } return handleMultiDrag(event) } if (event.action == MotionEvent.ACTION_UP) { if (DEBUG) { - Log.d(TAG, "onTouch() ACTION_UP > v = [$v], e1.getRaw = [${event.rawX}" + - ", ${event.rawY}]") + Log.d( + TAG, + "onTouch() ACTION_UP > v = [$v], e1.getRaw =" + + " [${event.rawX}, ${event.rawY}]" + ) } if (isMovingInPopup) { isMovingInPopup = false @@ -163,18 +171,24 @@ abstract class BasePlayerGestureListener( private fun handleMultiDrag(event: MotionEvent): Boolean { if (initPointerDistance != -1.0 && event.pointerCount == 2) { // get the movements of the fingers - val firstPointerMove = hypot(event.getX(0) - initFirstPointerX.toDouble(), - event.getY(0) - initFirstPointerY.toDouble()) - val secPointerMove = hypot(event.getX(1) - initSecPointerX.toDouble(), - event.getY(1) - initSecPointerY.toDouble()) + val firstPointerMove = hypot( + event.getX(0) - initFirstPointerX.toDouble(), + event.getY(0) - initFirstPointerY.toDouble() + ) + val secPointerMove = hypot( + event.getX(1) - initSecPointerX.toDouble(), + event.getY(1) - initSecPointerY.toDouble() + ) // minimum threshold beyond which pinch gesture will work val minimumMove = ViewConfiguration.get(service).scaledTouchSlop if (max(firstPointerMove, secPointerMove) > minimumMove) { // calculate current distance between the pointers - val currentPointerDistance = hypot(event.getX(0) - event.getX(1).toDouble(), - event.getY(0) - event.getY(1).toDouble()) + val currentPointerDistance = hypot( + event.getX(0) - event.getX(1).toDouble(), + event.getY(0) - event.getY(1).toDouble() + ) val popupWidth = playerImpl.popupWidth.toDouble() // change co-ordinates of popup so the center stays at the same position @@ -187,7 +201,8 @@ abstract class BasePlayerGestureListener( playerImpl.updatePopupSize( min(playerImpl.screenWidth.toDouble(), newWidth).toInt(), - -1) + -1 + ) return true } } @@ -316,22 +331,30 @@ abstract class BasePlayerGestureListener( } val isTouchingStatusBar: Boolean = initialEvent.y < getStatusBarHeight(service) - val isTouchingNavigationBar: Boolean = (initialEvent.y - > playerImpl.rootView.height - getNavigationBarHeight(service)) + val isTouchingNavigationBar: Boolean = + initialEvent.y > (playerImpl.rootView.height - getNavigationBarHeight(service)) if (isTouchingStatusBar || isTouchingNavigationBar) { return false } val insideThreshold = abs(movingEvent.y - initialEvent.y) <= MOVEMENT_THRESHOLD - if (!isMovingInMain && (insideThreshold || abs(distanceX) > abs(distanceY)) || - playerImpl.currentState == BasePlayer.STATE_COMPLETED) { + if ( + !isMovingInMain && (insideThreshold || abs(distanceX) > abs(distanceY)) || + playerImpl.currentState == BasePlayer.STATE_COMPLETED + ) { return false } isMovingInMain = true - onScroll(MainPlayer.PlayerType.VIDEO, getDisplayHalfPortion(initialEvent), - initialEvent, movingEvent, distanceX, distanceY) + onScroll( + MainPlayer.PlayerType.VIDEO, + getDisplayHalfPortion(initialEvent), + initialEvent, + movingEvent, + distanceX, + distanceY + ) return true } @@ -373,8 +396,14 @@ abstract class BasePlayerGestureListener( playerImpl.popupLayoutParams.x = posX.toInt() playerImpl.popupLayoutParams.y = posY.toInt() - onScroll(MainPlayer.PlayerType.POPUP, getDisplayHalfPortion(initialEvent), - initialEvent, movingEvent, distanceX, distanceY) + onScroll( + MainPlayer.PlayerType.POPUP, + getDisplayHalfPortion(initialEvent), + initialEvent, + movingEvent, + distanceX, + distanceY + ) playerImpl.windowManager .updateViewLayout(playerImpl.rootView, playerImpl.popupLayoutParams) diff --git a/app/src/main/java/us/shandian/giga/get/MissionRecoveryInfo.kt b/app/src/main/java/us/shandian/giga/get/MissionRecoveryInfo.kt index 568ae8d13..b2364f058 100644 --- a/app/src/main/java/us/shandian/giga/get/MissionRecoveryInfo.kt +++ b/app/src/main/java/us/shandian/giga/get/MissionRecoveryInfo.kt @@ -1,13 +1,13 @@ package us.shandian.giga.get import android.os.Parcelable -import java.io.Serializable import kotlinx.android.parcel.Parcelize import org.schabi.newpipe.extractor.MediaFormat import org.schabi.newpipe.extractor.stream.AudioStream import org.schabi.newpipe.extractor.stream.Stream import org.schabi.newpipe.extractor.stream.SubtitlesStream import org.schabi.newpipe.extractor.stream.VideoStream +import java.io.Serializable @Parcelize class MissionRecoveryInfo( @@ -62,10 +62,10 @@ class MissionRecoveryInfo( } } str.append(" format=") - .append(format.getName()) - .append(' ') - .append(info) - .append('}') + .append(format.getName()) + .append(' ') + .append(info) + .append('}') return str.toString() } }