Fix ktlint errors
This commit is contained in:
parent
f0ca916432
commit
b66047e084
|
@ -150,7 +150,7 @@ task formatKtlint(type: JavaExec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
preDebugBuild.dependsOn runCheckstyle, runKtlint
|
preDebugBuild.dependsOn formatKtlint, runCheckstyle, runKtlint
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.schabi.newpipe.about
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import java.io.Serializable
|
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for storing information about a software license.
|
* 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 {
|
class License(val name: String, val abbreviation: String, val filename: String) : Parcelable, Serializable {
|
||||||
val contentUri: Uri
|
val contentUri: Uri
|
||||||
get() = Uri.Builder()
|
get() = Uri.Builder()
|
||||||
.scheme("file")
|
.scheme("file")
|
||||||
.path("/android_asset")
|
.path("/android_asset")
|
||||||
.appendPath(filename)
|
.appendPath(filename)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.schabi.newpipe.database.feed.dao
|
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 io.reactivex.rxjava3.core.Flowable
|
||||||
import org.schabi.newpipe.database.feed.model.FeedEntity
|
import org.schabi.newpipe.database.feed.model.FeedEntity
|
||||||
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity
|
import org.schabi.newpipe.database.feed.model.FeedLastUpdatedEntity
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.schabi.newpipe.database.stream.dao
|
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 io.reactivex.rxjava3.core.Flowable
|
||||||
import org.schabi.newpipe.database.BasicDAO
|
import org.schabi.newpipe.database.BasicDAO
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity
|
import org.schabi.newpipe.database.stream.model.StreamEntity
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package org.schabi.newpipe.database.stream.model
|
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_SERVICE_ID
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_TABLE
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_TABLE
|
||||||
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_URL
|
import org.schabi.newpipe.database.stream.model.StreamEntity.Companion.STREAM_URL
|
||||||
|
|
|
@ -7,9 +7,6 @@ import io.reactivex.rxjava3.core.Completable
|
||||||
import io.reactivex.rxjava3.core.Flowable
|
import io.reactivex.rxjava3.core.Flowable
|
||||||
import io.reactivex.rxjava3.core.Maybe
|
import io.reactivex.rxjava3.core.Maybe
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
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.MainActivity.DEBUG
|
||||||
import org.schabi.newpipe.NewPipeDatabase
|
import org.schabi.newpipe.NewPipeDatabase
|
||||||
import org.schabi.newpipe.database.feed.model.FeedEntity
|
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.StreamInfoItem
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType
|
import org.schabi.newpipe.extractor.stream.StreamType
|
||||||
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
import org.schabi.newpipe.local.subscription.FeedGroupIcon
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.OffsetDateTime
|
||||||
|
import java.time.ZoneOffset
|
||||||
|
|
||||||
class FeedDatabaseManager(context: Context) {
|
class FeedDatabaseManager(context: Context) {
|
||||||
private val database = NewPipeDatabase.getInstance(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.
|
* Only items that are newer than this will be saved.
|
||||||
*/
|
*/
|
||||||
val FEED_OLDEST_ALLOWED_DATE: OffsetDateTime = LocalDate.now().minusWeeks(13)
|
val FEED_OLDEST_ALLOWED_DATE: OffsetDateTime = LocalDate.now().minusWeeks(13)
|
||||||
.atStartOfDay().atOffset(ZoneOffset.UTC)
|
.atStartOfDay().atOffset(ZoneOffset.UTC)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun groups() = feedGroupTable.getAll()
|
fun groups() = feedGroupTable.getAll()
|
||||||
|
@ -92,8 +92,12 @@ class FeedDatabaseManager(context: Context) {
|
||||||
feedTable.insertAll(feedEntities)
|
feedTable.insertAll(feedEntities)
|
||||||
}
|
}
|
||||||
|
|
||||||
feedTable.setLastUpdatedForSubscription(FeedLastUpdatedEntity(subscriptionId,
|
feedTable.setLastUpdatedForSubscription(
|
||||||
OffsetDateTime.now(ZoneOffset.UTC)))
|
FeedLastUpdatedEntity(
|
||||||
|
subscriptionId,
|
||||||
|
OffsetDateTime.now(ZoneOffset.UTC)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun removeOrphansOrOlderStreams(oldestAllowedDate: OffsetDateTime = FEED_OLDEST_ALLOWED_DATE) {
|
fun removeOrphansOrOlderStreams(oldestAllowedDate: OffsetDateTime = FEED_OLDEST_ALLOWED_DATE) {
|
||||||
|
|
|
@ -13,7 +13,10 @@ import org.schabi.newpipe.database.feed.model.FeedGroupEntity
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.ktx.toCalendar
|
import org.schabi.newpipe.ktx.toCalendar
|
||||||
import org.schabi.newpipe.local.feed.service.FeedEventManager
|
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 org.schabi.newpipe.util.DEFAULT_THROTTLE_TIMEOUT
|
||||||
import java.time.OffsetDateTime
|
import java.time.OffsetDateTime
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
@ -37,9 +40,9 @@ class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEn
|
||||||
feedDatabaseManager.asStreamItems(groupId),
|
feedDatabaseManager.asStreamItems(groupId),
|
||||||
feedDatabaseManager.notLoadedCount(groupId),
|
feedDatabaseManager.notLoadedCount(groupId),
|
||||||
feedDatabaseManager.oldestSubscriptionUpdate(groupId),
|
feedDatabaseManager.oldestSubscriptionUpdate(groupId),
|
||||||
Function4 { t1: FeedEventManager.Event, t2: List<StreamInfoItem>, t3: Long, t4: List<OffsetDateTime> ->
|
Function4 { t1: FeedEventManager.Event, t2: List<StreamInfoItem>, t3: Long, t4: List<OffsetDateTime> ->
|
||||||
return@Function4 CombineResultHolder(t1, t2, t3, t4.firstOrNull())
|
return@Function4 CombineResultHolder(t1, t2, t3, t4.firstOrNull())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.throttleLatest(DEFAULT_THROTTLE_TIMEOUT, TimeUnit.MILLISECONDS)
|
.throttleLatest(DEFAULT_THROTTLE_TIMEOUT, TimeUnit.MILLISECONDS)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
|
@ -49,7 +49,9 @@ import org.schabi.newpipe.extractor.ListInfo
|
||||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem
|
||||||
import org.schabi.newpipe.local.feed.FeedDatabaseManager
|
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.feed.service.FeedEventManager.postEvent
|
||||||
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
import org.schabi.newpipe.local.subscription.SubscriptionManager
|
||||||
import org.schabi.newpipe.util.ExceptionUtils
|
import org.schabi.newpipe.util.ExceptionUtils
|
||||||
|
@ -262,7 +264,7 @@ class FeedLoadService : Service() {
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
if (maxProgress.get() == 0) {
|
if (maxProgress.get() == 0) {
|
||||||
postEvent(IdleEvent)
|
postEvent(FeedEventManager.Event.IdleEvent)
|
||||||
stopService()
|
stopService()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -118,22 +118,30 @@ abstract class BasePlayerGestureListener(
|
||||||
initSecPointerX = event.getX(1)
|
initSecPointerX = event.getX(1)
|
||||||
initSecPointerY = event.getY(1)
|
initSecPointerY = event.getY(1)
|
||||||
// record distance between fingers
|
// record distance between fingers
|
||||||
initPointerDistance = hypot(initFirstPointerX - initSecPointerX.toDouble(),
|
initPointerDistance = hypot(
|
||||||
initFirstPointerY - initSecPointerY.toDouble())
|
initFirstPointerX - initSecPointerX.toDouble(),
|
||||||
|
initFirstPointerY - initSecPointerY.toDouble()
|
||||||
|
)
|
||||||
|
|
||||||
isResizing = true
|
isResizing = true
|
||||||
}
|
}
|
||||||
if (event.action == MotionEvent.ACTION_MOVE && !isMovingInPopup && isResizing) {
|
if (event.action == MotionEvent.ACTION_MOVE && !isMovingInPopup && isResizing) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onTouch() ACTION_MOVE > v = [$v], e1.getRaw = [${event.rawX}" +
|
Log.d(
|
||||||
", ${event.rawY}]")
|
TAG,
|
||||||
|
"onTouch() ACTION_MOVE > v = [$v], e1.getRaw =" +
|
||||||
|
"[${event.rawX}, ${event.rawY}]"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return handleMultiDrag(event)
|
return handleMultiDrag(event)
|
||||||
}
|
}
|
||||||
if (event.action == MotionEvent.ACTION_UP) {
|
if (event.action == MotionEvent.ACTION_UP) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onTouch() ACTION_UP > v = [$v], e1.getRaw = [${event.rawX}" +
|
Log.d(
|
||||||
", ${event.rawY}]")
|
TAG,
|
||||||
|
"onTouch() ACTION_UP > v = [$v], e1.getRaw =" +
|
||||||
|
" [${event.rawX}, ${event.rawY}]"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (isMovingInPopup) {
|
if (isMovingInPopup) {
|
||||||
isMovingInPopup = false
|
isMovingInPopup = false
|
||||||
|
@ -163,18 +171,24 @@ abstract class BasePlayerGestureListener(
|
||||||
private fun handleMultiDrag(event: MotionEvent): Boolean {
|
private fun handleMultiDrag(event: MotionEvent): Boolean {
|
||||||
if (initPointerDistance != -1.0 && event.pointerCount == 2) {
|
if (initPointerDistance != -1.0 && event.pointerCount == 2) {
|
||||||
// get the movements of the fingers
|
// get the movements of the fingers
|
||||||
val firstPointerMove = hypot(event.getX(0) - initFirstPointerX.toDouble(),
|
val firstPointerMove = hypot(
|
||||||
event.getY(0) - initFirstPointerY.toDouble())
|
event.getX(0) - initFirstPointerX.toDouble(),
|
||||||
val secPointerMove = hypot(event.getX(1) - initSecPointerX.toDouble(),
|
event.getY(0) - initFirstPointerY.toDouble()
|
||||||
event.getY(1) - initSecPointerY.toDouble())
|
)
|
||||||
|
val secPointerMove = hypot(
|
||||||
|
event.getX(1) - initSecPointerX.toDouble(),
|
||||||
|
event.getY(1) - initSecPointerY.toDouble()
|
||||||
|
)
|
||||||
|
|
||||||
// minimum threshold beyond which pinch gesture will work
|
// minimum threshold beyond which pinch gesture will work
|
||||||
val minimumMove = ViewConfiguration.get(service).scaledTouchSlop
|
val minimumMove = ViewConfiguration.get(service).scaledTouchSlop
|
||||||
|
|
||||||
if (max(firstPointerMove, secPointerMove) > minimumMove) {
|
if (max(firstPointerMove, secPointerMove) > minimumMove) {
|
||||||
// calculate current distance between the pointers
|
// calculate current distance between the pointers
|
||||||
val currentPointerDistance = hypot(event.getX(0) - event.getX(1).toDouble(),
|
val currentPointerDistance = hypot(
|
||||||
event.getY(0) - event.getY(1).toDouble())
|
event.getX(0) - event.getX(1).toDouble(),
|
||||||
|
event.getY(0) - event.getY(1).toDouble()
|
||||||
|
)
|
||||||
|
|
||||||
val popupWidth = playerImpl.popupWidth.toDouble()
|
val popupWidth = playerImpl.popupWidth.toDouble()
|
||||||
// change co-ordinates of popup so the center stays at the same position
|
// change co-ordinates of popup so the center stays at the same position
|
||||||
|
@ -187,7 +201,8 @@ abstract class BasePlayerGestureListener(
|
||||||
|
|
||||||
playerImpl.updatePopupSize(
|
playerImpl.updatePopupSize(
|
||||||
min(playerImpl.screenWidth.toDouble(), newWidth).toInt(),
|
min(playerImpl.screenWidth.toDouble(), newWidth).toInt(),
|
||||||
-1)
|
-1
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,22 +331,30 @@ abstract class BasePlayerGestureListener(
|
||||||
}
|
}
|
||||||
|
|
||||||
val isTouchingStatusBar: Boolean = initialEvent.y < getStatusBarHeight(service)
|
val isTouchingStatusBar: Boolean = initialEvent.y < getStatusBarHeight(service)
|
||||||
val isTouchingNavigationBar: Boolean = (initialEvent.y
|
val isTouchingNavigationBar: Boolean =
|
||||||
> playerImpl.rootView.height - getNavigationBarHeight(service))
|
initialEvent.y > (playerImpl.rootView.height - getNavigationBarHeight(service))
|
||||||
if (isTouchingStatusBar || isTouchingNavigationBar) {
|
if (isTouchingStatusBar || isTouchingNavigationBar) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val insideThreshold = abs(movingEvent.y - initialEvent.y) <= MOVEMENT_THRESHOLD
|
val insideThreshold = abs(movingEvent.y - initialEvent.y) <= MOVEMENT_THRESHOLD
|
||||||
if (!isMovingInMain && (insideThreshold || abs(distanceX) > abs(distanceY)) ||
|
if (
|
||||||
playerImpl.currentState == BasePlayer.STATE_COMPLETED) {
|
!isMovingInMain && (insideThreshold || abs(distanceX) > abs(distanceY)) ||
|
||||||
|
playerImpl.currentState == BasePlayer.STATE_COMPLETED
|
||||||
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
isMovingInMain = true
|
isMovingInMain = true
|
||||||
|
|
||||||
onScroll(MainPlayer.PlayerType.VIDEO, getDisplayHalfPortion(initialEvent),
|
onScroll(
|
||||||
initialEvent, movingEvent, distanceX, distanceY)
|
MainPlayer.PlayerType.VIDEO,
|
||||||
|
getDisplayHalfPortion(initialEvent),
|
||||||
|
initialEvent,
|
||||||
|
movingEvent,
|
||||||
|
distanceX,
|
||||||
|
distanceY
|
||||||
|
)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -373,8 +396,14 @@ abstract class BasePlayerGestureListener(
|
||||||
playerImpl.popupLayoutParams.x = posX.toInt()
|
playerImpl.popupLayoutParams.x = posX.toInt()
|
||||||
playerImpl.popupLayoutParams.y = posY.toInt()
|
playerImpl.popupLayoutParams.y = posY.toInt()
|
||||||
|
|
||||||
onScroll(MainPlayer.PlayerType.POPUP, getDisplayHalfPortion(initialEvent),
|
onScroll(
|
||||||
initialEvent, movingEvent, distanceX, distanceY)
|
MainPlayer.PlayerType.POPUP,
|
||||||
|
getDisplayHalfPortion(initialEvent),
|
||||||
|
initialEvent,
|
||||||
|
movingEvent,
|
||||||
|
distanceX,
|
||||||
|
distanceY
|
||||||
|
)
|
||||||
|
|
||||||
playerImpl.windowManager
|
playerImpl.windowManager
|
||||||
.updateViewLayout(playerImpl.rootView, playerImpl.popupLayoutParams)
|
.updateViewLayout(playerImpl.rootView, playerImpl.popupLayoutParams)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package us.shandian.giga.get
|
package us.shandian.giga.get
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import java.io.Serializable
|
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
import org.schabi.newpipe.extractor.MediaFormat
|
import org.schabi.newpipe.extractor.MediaFormat
|
||||||
import org.schabi.newpipe.extractor.stream.AudioStream
|
import org.schabi.newpipe.extractor.stream.AudioStream
|
||||||
import org.schabi.newpipe.extractor.stream.Stream
|
import org.schabi.newpipe.extractor.stream.Stream
|
||||||
import org.schabi.newpipe.extractor.stream.SubtitlesStream
|
import org.schabi.newpipe.extractor.stream.SubtitlesStream
|
||||||
import org.schabi.newpipe.extractor.stream.VideoStream
|
import org.schabi.newpipe.extractor.stream.VideoStream
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
class MissionRecoveryInfo(
|
class MissionRecoveryInfo(
|
||||||
|
@ -62,10 +62,10 @@ class MissionRecoveryInfo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str.append(" format=")
|
str.append(" format=")
|
||||||
.append(format.getName())
|
.append(format.getName())
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append(info)
|
.append(info)
|
||||||
.append('}')
|
.append('}')
|
||||||
return str.toString()
|
return str.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue