ktlint: Drop unused trailing commas

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta 2026-01-21 16:48:46 +08:00
parent f388d7abb0
commit 4fd959ed60
25 changed files with 58 additions and 60 deletions

View file

@ -38,5 +38,3 @@ ktlint_standard_spacing-between-declarations-with-annotations = disabled
ktlint_standard_spacing-between-declarations-with-comments = disabled ktlint_standard_spacing-between-declarations-with-comments = disabled
ktlint_standard_statement-wrapping = disabled ktlint_standard_statement-wrapping = disabled
ktlint_standard_string-template-indent = disabled ktlint_standard_string-template-indent = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled

View file

@ -111,7 +111,7 @@ class FeedDAOTest {
SubscriptionEntity.from(ChannelInfo(serviceId, "1", "https://youtube.com/channel/1", "https://youtube.com/channel/1", "channel-1")), SubscriptionEntity.from(ChannelInfo(serviceId, "1", "https://youtube.com/channel/1", "https://youtube.com/channel/1", "channel-1")),
SubscriptionEntity.from(ChannelInfo(serviceId, "2", "https://youtube.com/channel/2", "https://youtube.com/channel/2", "channel-2")), SubscriptionEntity.from(ChannelInfo(serviceId, "2", "https://youtube.com/channel/2", "https://youtube.com/channel/2", "channel-2")),
SubscriptionEntity.from(ChannelInfo(serviceId, "3", "https://youtube.com/channel/3", "https://youtube.com/channel/3", "channel-3")), SubscriptionEntity.from(ChannelInfo(serviceId, "3", "https://youtube.com/channel/3", "https://youtube.com/channel/3", "channel-3")),
SubscriptionEntity.from(ChannelInfo(serviceId, "4", "https://youtube.com/channel/4", "https://youtube.com/channel/4", "channel-4")), SubscriptionEntity.from(ChannelInfo(serviceId, "4", "https://youtube.com/channel/4", "https://youtube.com/channel/4", "channel-4"))
) )
) )
feedDAO.insertAll( feedDAO.insertAll(
@ -122,7 +122,7 @@ class FeedDAOTest {
FeedEntity(4, 2), FeedEntity(4, 2),
FeedEntity(5, 2), FeedEntity(5, 2),
FeedEntity(6, 3), FeedEntity(6, 3),
FeedEntity(7, 4), FeedEntity(7, 4)
) )
) )
} }

View file

@ -54,7 +54,7 @@ class HistoryRecordManagerTest {
SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 0, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 0, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 2, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 2, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 1, search = "B"), SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 1, search = "B"),
SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 0, search = "B"), SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 0, search = "B")
) )
// make sure all 4 were inserted // make sure all 4 were inserted
@ -85,7 +85,7 @@ class HistoryRecordManagerTest {
val entries = listOf( val entries = listOf(
SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 1, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 1, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 2, search = "B"), SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 2, search = "B"),
SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 0, search = "C"), SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 0, search = "C")
) )
// make sure all 3 were inserted // make sure all 3 were inserted
@ -121,7 +121,7 @@ class HistoryRecordManagerTest {
RELATED_SEARCHES_ENTRIES[6].search, // A (even if in two places) RELATED_SEARCHES_ENTRIES[6].search, // A (even if in two places)
RELATED_SEARCHES_ENTRIES[4].search, // B RELATED_SEARCHES_ENTRIES[4].search, // B
RELATED_SEARCHES_ENTRIES[5].search, // AA RELATED_SEARCHES_ENTRIES[5].search, // AA
RELATED_SEARCHES_ENTRIES[2].search, // BA RELATED_SEARCHES_ENTRIES[2].search // BA
) )
} }
@ -136,7 +136,7 @@ class HistoryRecordManagerTest {
SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 3, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 3, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 3, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 3, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 0, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 0, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 2, search = "AA"), SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 2, search = "AA")
) )
insertShuffledRelatedSearches(relatedSearches) insertShuffledRelatedSearches(relatedSearches)
@ -153,7 +153,7 @@ class HistoryRecordManagerTest {
assertThat(searches).containsExactly( assertThat(searches).containsExactly(
RELATED_SEARCHES_ENTRIES[6].search, // A (even if in two places) RELATED_SEARCHES_ENTRIES[6].search, // A (even if in two places)
RELATED_SEARCHES_ENTRIES[5].search, // AA RELATED_SEARCHES_ENTRIES[5].search, // AA
RELATED_SEARCHES_ENTRIES[1].search, // BA RELATED_SEARCHES_ENTRIES[1].search // BA
) )
// also make sure that the string comparison is case insensitive // also make sure that the string comparison is case insensitive
@ -171,7 +171,7 @@ class HistoryRecordManagerTest {
SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 3, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(4), serviceId = 3, search = "A"),
SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 0, search = "B"), SearchHistoryEntry(creationDate = time.minusSeconds(2), serviceId = 0, search = "B"),
SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 2, search = "AA"), SearchHistoryEntry(creationDate = time.minusSeconds(3), serviceId = 2, search = "AA"),
SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 1, search = "A"), SearchHistoryEntry(creationDate = time.minusSeconds(1), serviceId = 1, search = "A")
) )
} }
} }

View file

@ -292,7 +292,7 @@ class StreamItemAdapterTest {
Assert.assertEquals( Assert.assertEquals(
"normal visibility (pos=[$position]) is not correct", "normal visibility (pos=[$position]) is not correct",
findViewById<View>(R.id.wo_sound_icon).visibility, findViewById<View>(R.id.wo_sound_icon).visibility,
normalVisibility, normalVisibility
) )
} }
spinner.adapter.getDropDownView(position, null, spinner).run { spinner.adapter.getDropDownView(position, null, spinner).run {

View file

@ -195,7 +195,7 @@ class AboutActivity : AppCompatActivity() {
SoftwareComponent( SoftwareComponent(
"SearchPreference", "2018", "ByteHamster", "SearchPreference", "2018", "ByteHamster",
"https://github.com/ByteHamster/SearchPreference", StandardLicenses.MIT "https://github.com/ByteHamster/SearchPreference", StandardLicenses.MIT
), )
) )
} }
} }

View file

@ -14,6 +14,6 @@ interface LocalItem {
PLAYLIST_REMOTE_ITEM, PLAYLIST_REMOTE_ITEM,
PLAYLIST_STREAM_ITEM, PLAYLIST_STREAM_ITEM,
STATISTIC_STREAM_ITEM, STATISTIC_STREAM_ITEM
} }
} }

View file

@ -29,7 +29,7 @@ data class SearchHistoryEntry @JvmOverloads constructor(
@ColumnInfo(name = ID) @ColumnInfo(name = ID)
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
val id: Long = 0, val id: Long = 0
) { ) {
@Ignore @Ignore

View file

@ -35,7 +35,7 @@ data class StreamHistoryEntry(
streamEntity.serviceId, streamEntity.serviceId,
streamEntity.url, streamEntity.url,
streamEntity.title, streamEntity.title,
streamEntity.streamType, streamEntity.streamType
).apply { ).apply {
duration = streamEntity.duration duration = streamEntity.duration
uploaderName = streamEntity.uploader uploaderName = streamEntity.uploader

View file

@ -37,7 +37,7 @@ data class PlaylistEntity @JvmOverloads constructor(
name = item.orderingName, name = item.orderingName,
isThumbnailPermanent = item.isThumbnailPermanent!!, isThumbnailPermanent = item.isThumbnailPermanent!!,
thumbnailStreamId = item.thumbnailStreamId!!, thumbnailStreamId = item.thumbnailStreamId!!,
displayIndex = item.displayIndex!!, displayIndex = item.displayIndex!!
) )
companion object { companion object {

View file

@ -59,7 +59,7 @@ class ErrorInfo private constructor(
* If present, this resource can alternatively be opened in browser (useful if NewPipe is * If present, this resource can alternatively be opened in browser (useful if NewPipe is
* badly broken). * badly broken).
*/ */
val openInBrowserUrl: String?, val openInBrowserUrl: String?
) : Parcelable { ) : Parcelable {
@JvmOverloads @JvmOverloads
@ -68,7 +68,7 @@ class ErrorInfo private constructor(
userAction: UserAction, userAction: UserAction,
request: String, request: String,
serviceId: Int? = null, serviceId: Int? = null,
openInBrowserUrl: String? = null, openInBrowserUrl: String? = null
) : this( ) : this(
throwableToStringList(throwable), throwableToStringList(throwable),
userAction, userAction,
@ -78,7 +78,7 @@ class ErrorInfo private constructor(
isReportable(throwable), isReportable(throwable),
isRetryable(throwable), isRetryable(throwable),
(throwable as? ReCaptchaException)?.url, (throwable as? ReCaptchaException)?.url,
openInBrowserUrl, openInBrowserUrl
) )
@JvmOverloads @JvmOverloads
@ -87,7 +87,7 @@ class ErrorInfo private constructor(
userAction: UserAction, userAction: UserAction,
request: String, request: String,
serviceId: Int? = null, serviceId: Int? = null,
openInBrowserUrl: String? = null, openInBrowserUrl: String? = null
) : this( ) : this(
throwableListToStringList(throwables), throwableListToStringList(throwables),
userAction, userAction,
@ -97,7 +97,7 @@ class ErrorInfo private constructor(
throwables.any(::isReportable), throwables.any(::isReportable),
throwables.isEmpty() || throwables.any(::isRetryable), throwables.isEmpty() || throwables.any(::isRetryable),
throwables.firstNotNullOfOrNull { it as? ReCaptchaException }?.url, throwables.firstNotNullOfOrNull { it as? ReCaptchaException }?.url,
openInBrowserUrl, openInBrowserUrl
) )
// constructor to manually build ErrorInfo when no throwable is available // constructor to manually build ErrorInfo when no throwable is available
@ -118,7 +118,7 @@ class ErrorInfo private constructor(
throwable: Throwable, throwable: Throwable,
userAction: UserAction, userAction: UserAction,
request: String, request: String,
info: Info?, info: Info?
) : ) :
this(throwable, userAction, request, info?.serviceId, info?.url) this(throwable, userAction, request, info?.serviceId, info?.url)
@ -127,7 +127,7 @@ class ErrorInfo private constructor(
throwables: List<Throwable>, throwables: List<Throwable>,
userAction: UserAction, userAction: UserAction,
request: String, request: String,
info: Info?, info: Info?
) : ) :
this(throwables, userAction, request, info?.serviceId, info?.url) this(throwables, userAction, request, info?.serviceId, info?.url)
@ -144,7 +144,7 @@ class ErrorInfo private constructor(
class ErrorMessage( class ErrorMessage(
@StringRes @StringRes
private val stringRes: Int, private val stringRes: Int,
private vararg val formatArgs: String, private vararg val formatArgs: String
) : Parcelable { ) : Parcelable {
fun getString(context: Context): String { fun getString(context: Context): String {
return if (formatArgs.isEmpty()) { return if (formatArgs.isEmpty()) {
@ -174,7 +174,7 @@ class ErrorInfo private constructor(
fun getMessage( fun getMessage(
throwable: Throwable?, throwable: Throwable?,
action: UserAction?, action: UserAction?,
serviceId: Int?, serviceId: Int?
): ErrorMessage { ): ErrorMessage {
return when { return when {
// player exceptions // player exceptions

View file

@ -20,7 +20,7 @@ import org.schabi.newpipe.util.external_communication.ShareUtils
class ErrorPanelHelper( class ErrorPanelHelper(
private val fragment: Fragment, private val fragment: Fragment,
rootView: View, rootView: View,
onRetry: Runnable?, onRetry: Runnable?
) { ) {
private val context: Context = rootView.context!! private val context: Context = rootView.context!!

View file

@ -31,7 +31,7 @@ import org.schabi.newpipe.local.feed.service.FeedLoadService
*/ */
class NotificationWorker( class NotificationWorker(
appContext: Context, appContext: Context,
workerParams: WorkerParameters, workerParams: WorkerParameters
) : RxWorker(appContext, workerParams) { ) : RxWorker(appContext, workerParams) {
private val notificationHelper by lazy { private val notificationHelper by lazy {

View file

@ -60,7 +60,7 @@ class FeedLoadManager(private val context: Context) {
*/ */
fun startLoading( fun startLoading(
groupId: Long = FeedGroupEntity.GROUP_ALL_ID, groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
ignoreOutdatedThreshold: Boolean = false, ignoreOutdatedThreshold: Boolean = false
): Single<List<Notification<FeedUpdateInfo>>> { ): Single<List<Notification<FeedUpdateInfo>>> {
val defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) val defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val useFeedExtractor = defaultSharedPreferences.getBoolean( val useFeedExtractor = defaultSharedPreferences.getBoolean(
@ -234,7 +234,7 @@ class FeedLoadManager(private val context: Context) {
subscriptionEntity, subscriptionEntity,
originalInfo!!, originalInfo!!,
streams!!, streams!!,
errors, errors
) )
) )
} catch (e: Throwable) { } catch (e: Throwable) {

View file

@ -3,5 +3,5 @@ package org.schabi.newpipe.local.feed.service
data class FeedLoadState( data class FeedLoadState(
val updateDescription: String, val updateDescription: String,
val maxProgress: Int, val maxProgress: Int,
val currentProgress: Int, val currentProgress: Int
) )

View file

@ -25,13 +25,13 @@ data class FeedUpdateInfo(
val description: String?, val description: String?,
val subscriberCount: Long?, val subscriberCount: Long?,
val streams: List<StreamInfoItem>, val streams: List<StreamInfoItem>,
val errors: List<Throwable>, val errors: List<Throwable>
) { ) {
constructor( constructor(
subscription: SubscriptionEntity, subscription: SubscriptionEntity,
info: Info, info: Info,
streams: List<StreamInfoItem>, streams: List<StreamInfoItem>,
errors: List<Throwable>, errors: List<Throwable>
) : this( ) : this(
uid = subscription.uid, uid = subscription.uid,
notificationMode = subscription.notificationMode, notificationMode = subscription.notificationMode,
@ -46,7 +46,7 @@ data class FeedUpdateInfo(
description = (info as? ChannelInfo)?.description, description = (info as? ChannelInfo)?.description,
subscriberCount = (info as? ChannelInfo)?.subscriberCount, subscriberCount = (info as? ChannelInfo)?.subscriberCount,
streams = streams, streams = streams,
errors = errors, errors = errors
) )
/** /**

View file

@ -309,7 +309,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
title = getString(R.string.feed_groups_header_title), title = getString(R.string.feed_groups_header_title),
onSortClicked = ::openReorderDialog, onSortClicked = ::openReorderDialog,
onToggleListViewModeClicked = ::toggleListViewMode, onToggleListViewModeClicked = ::toggleListViewMode,
listViewMode = viewModel.getListViewMode(), listViewMode = viewModel.getListViewMode()
) )
add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel))) add(Section(feedGroupsSortMenuItem, listOf(feedGroupsCarousel)))

View file

@ -10,7 +10,7 @@ import org.schabi.newpipe.local.subscription.FeedGroupIcon
data class FeedGroupCardGridItem( data class FeedGroupCardGridItem(
val groupId: Long = FeedGroupEntity.GROUP_ALL_ID, val groupId: Long = FeedGroupEntity.GROUP_ALL_ID,
val name: String, val name: String,
val icon: FeedGroupIcon, val icon: FeedGroupIcon
) : BindableItem<FeedGroupCardGridItemBinding>() { ) : BindableItem<FeedGroupCardGridItemBinding>() {
constructor (feedGroupEntity: FeedGroupEntity) : this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon) constructor (feedGroupEntity: FeedGroupEntity) : this(feedGroupEntity.uid, feedGroupEntity.name, feedGroupEntity.icon)

View file

@ -18,7 +18,7 @@ import org.schabi.newpipe.player.ui.VideoPlayerUi
* and provides some abstract methods to make it easier separating the logic from the UI. * and provides some abstract methods to make it easier separating the logic from the UI.
*/ */
abstract class BasePlayerGestureListener( abstract class BasePlayerGestureListener(
private val playerUi: VideoPlayerUi, private val playerUi: VideoPlayerUi
) : GestureDetector.SimpleOnGestureListener(), View.OnTouchListener { ) : GestureDetector.SimpleOnGestureListener(), View.OnTouchListener {
protected val player: Player = playerUi.player protected val player: Player = playerUi.player

View file

@ -15,7 +15,7 @@ import org.schabi.newpipe.ktx.animate
import org.schabi.newpipe.player.ui.PopupPlayerUi import org.schabi.newpipe.player.ui.PopupPlayerUi
class PopupPlayerGestureListener( class PopupPlayerGestureListener(
private val playerUi: PopupPlayerUi, private val playerUi: PopupPlayerUi
) : BasePlayerGestureListener(playerUi) { ) : BasePlayerGestureListener(playerUi) {
private var isMoving = false private var isMoving = false

View file

@ -47,7 +47,7 @@ import org.schabi.newpipe.util.image.ImageStrategy
*/ */
class MediaBrowserImpl( class MediaBrowserImpl(
private val context: Context, private val context: Context,
notifyChildrenChanged: Consumer<String>, // parentId notifyChildrenChanged: Consumer<String> // parentId
) { ) {
private val packageValidator = PackageValidator(context) private val packageValidator = PackageValidator(context)
private val database = NewPipeDatabase.getInstance(context) private val database = NewPipeDatabase.getInstance(context)
@ -204,12 +204,12 @@ class MediaBrowserImpl(
val extras = Bundle() val extras = Bundle()
extras.putString( extras.putString(
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE, MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_GROUP_TITLE,
context.resources.getString(R.string.tab_bookmarks), context.resources.getString(R.string.tab_bookmarks)
) )
builder.setExtras(extras) builder.setExtras(extras)
return MediaBrowserCompat.MediaItem( return MediaBrowserCompat.MediaItem(
builder.build(), builder.build(),
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE
) )
} }
@ -266,7 +266,7 @@ class MediaBrowserImpl(
private fun createLocalPlaylistStreamMediaItem( private fun createLocalPlaylistStreamMediaItem(
playlistId: Long, playlistId: Long,
item: PlaylistStreamEntry, item: PlaylistStreamEntry,
index: Int, index: Int
): MediaBrowserCompat.MediaItem { ): MediaBrowserCompat.MediaItem {
val builder = MediaDescriptionCompat.Builder() val builder = MediaDescriptionCompat.Builder()
builder.setMediaId(createMediaIdForPlaylistIndex(false, playlistId, index)) builder.setMediaId(createMediaIdForPlaylistIndex(false, playlistId, index))
@ -283,7 +283,7 @@ class MediaBrowserImpl(
private fun createRemotePlaylistStreamMediaItem( private fun createRemotePlaylistStreamMediaItem(
playlistId: Long, playlistId: Long,
item: StreamInfoItem, item: StreamInfoItem,
index: Int, index: Int
): MediaBrowserCompat.MediaItem { ): MediaBrowserCompat.MediaItem {
val builder = MediaDescriptionCompat.Builder() val builder = MediaDescriptionCompat.Builder()
builder.setMediaId(createMediaIdForPlaylistIndex(true, playlistId, index)) builder.setMediaId(createMediaIdForPlaylistIndex(true, playlistId, index))
@ -303,7 +303,7 @@ class MediaBrowserImpl(
private fun createMediaIdForPlaylistIndex( private fun createMediaIdForPlaylistIndex(
isRemote: Boolean, isRemote: Boolean,
playlistId: Long, playlistId: Long,
index: Int, index: Int
): String { ): String {
return buildLocalPlaylistItemMediaId(isRemote, playlistId) return buildLocalPlaylistItemMediaId(isRemote, playlistId)
.appendPath(index.toString()) .appendPath(index.toString())

View file

@ -51,7 +51,7 @@ class MediaBrowserPlaybackPreparer(
private val context: Context, private val context: Context,
private val setMediaSessionError: BiConsumer<String, Int>, // error string, error code private val setMediaSessionError: BiConsumer<String, Int>, // error string, error code
private val clearMediaSessionError: Runnable, private val clearMediaSessionError: Runnable,
private val onPrepare: Consumer<Boolean>, private val onPrepare: Consumer<Boolean>
) : PlaybackPreparer { ) : PlaybackPreparer {
private val database = NewPipeDatabase.getInstance(context) private val database = NewPipeDatabase.getInstance(context)
private var disposable: Disposable? = null private var disposable: Disposable? = null
@ -172,7 +172,7 @@ class MediaBrowserPlaybackPreparer(
private fun extractPlayQueueFromPlaylistMediaId( private fun extractPlayQueueFromPlaylistMediaId(
mediaId: String, mediaId: String,
path: MutableList<String>, path: MutableList<String>,
url: String?, url: String?
): Single<PlayQueue> { ): Single<PlayQueue> {
if (path.isEmpty()) { if (path.isEmpty()) {
throw parseError(mediaId) throw parseError(mediaId)
@ -209,7 +209,7 @@ class MediaBrowserPlaybackPreparer(
@Throws(ContentNotAvailableException::class) @Throws(ContentNotAvailableException::class)
private fun extractPlayQueueFromHistoryMediaId( private fun extractPlayQueueFromHistoryMediaId(
mediaId: String, mediaId: String,
path: List<String>, path: List<String>
): Single<PlayQueue> { ): Single<PlayQueue> {
if (path.size != 1) { if (path.size != 1) {
throw parseError(mediaId) throw parseError(mediaId)
@ -230,7 +230,7 @@ class MediaBrowserPlaybackPreparer(
private fun extractPlayQueueFromInfoItemMediaId( private fun extractPlayQueueFromInfoItemMediaId(
mediaId: String, mediaId: String,
path: List<String>, path: List<String>,
url: String, url: String
): Single<PlayQueue> { ): Single<PlayQueue> {
if (path.size != 2) { if (path.size != 2) {
throw parseError(mediaId) throw parseError(mediaId)

View file

@ -31,7 +31,7 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
ZipHelper.addFileToZip( ZipHelper.addFileToZip(
outZip, outZip,
BackupFileLocator.FILE_NAME_DB, BackupFileLocator.FILE_NAME_DB,
fileLocator.db.path, fileLocator.db.path
) )
// add the legacy vulnerable serialized preferences (will be removed in the future) // add the legacy vulnerable serialized preferences (will be removed in the future)
@ -78,7 +78,7 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
val success = ZipHelper.extractFileFromZip( val success = ZipHelper.extractFileFromZip(
file, file,
BackupFileLocator.FILE_NAME_DB, BackupFileLocator.FILE_NAME_DB,
fileLocator.db.path, fileLocator.db.path
) )
if (success) { if (success) {

View file

@ -45,7 +45,7 @@ class NotificationModeConfigFragment : Fragment() {
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?, savedInstanceState: Bundle?
): View { ): View {
_binding = FragmentChannelsNotificationsBinding.inflate(inflater, container, false) _binding = FragmentChannelsNotificationsBinding.inflate(inflater, container, false)
return binding.root return binding.root

View file

@ -23,7 +23,7 @@ import org.schabi.newpipe.DownloaderImpl
class PoTokenWebView private constructor( class PoTokenWebView private constructor(
context: Context, context: Context,
// to be used exactly once only during initialization! // to be used exactly once only during initialization!
private val generatorEmitter: SingleEmitter<PoTokenGenerator>, private val generatorEmitter: SingleEmitter<PoTokenGenerator>
) : PoTokenGenerator { ) : PoTokenGenerator {
private val webView = WebView(context) private val webView = WebView(context)
private val disposables = CompositeDisposable() // used only during initialization private val disposables = CompositeDisposable() // used only during initialization
@ -93,7 +93,7 @@ class PoTokenWebView private constructor(
), ),
"text/html", "text/html",
"utf-8", "utf-8",
null, null
) )
}, },
this::onInitializationErrorCloseAndCancel this::onInitializationErrorCloseAndCancel
@ -113,7 +113,7 @@ class PoTokenWebView private constructor(
makeBotguardServiceRequest( makeBotguardServiceRequest(
"https://www.youtube.com/api/jnn/v1/Create", "https://www.youtube.com/api/jnn/v1/Create",
"[ \"$REQUEST_KEY\" ]", "[ \"$REQUEST_KEY\" ]"
) { responseBody -> ) { responseBody ->
val parsedChallengeData = parseChallengeData(responseBody) val parsedChallengeData = parseChallengeData(responseBody)
webView.evaluateJavascript( webView.evaluateJavascript(
@ -156,7 +156,7 @@ class PoTokenWebView private constructor(
} }
makeBotguardServiceRequest( makeBotguardServiceRequest(
"https://www.youtube.com/api/jnn/v1/GenerateIT", "https://www.youtube.com/api/jnn/v1/GenerateIT",
"[ \"$REQUEST_KEY\", \"$botguardResponse\" ]", "[ \"$REQUEST_KEY\", \"$botguardResponse\" ]"
) { responseBody -> ) { responseBody ->
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Log.d(TAG, "GenerateIT response: $responseBody") Log.d(TAG, "GenerateIT response: $responseBody")
@ -200,7 +200,7 @@ class PoTokenWebView private constructor(
$JS_INTERFACE.onObtainPoTokenResult(identifier, poTokenU8String) $JS_INTERFACE.onObtainPoTokenResult(identifier, poTokenU8String)
} catch (error) { } catch (error) {
$JS_INTERFACE.onObtainPoTokenError(identifier, error + "\n" + error.stack) $JS_INTERFACE.onObtainPoTokenError(identifier, error + "\n" + error.stack)
}""", }"""
) {} ) {}
} }
} }
@ -294,7 +294,7 @@ class PoTokenWebView private constructor(
private fun makeBotguardServiceRequest( private fun makeBotguardServiceRequest(
url: String, url: String,
data: String, data: String,
handleResponseBody: (String) -> Unit, handleResponseBody: (String) -> Unit
) { ) {
disposables.add( disposables.add(
Single.fromCallable { Single.fromCallable {
@ -306,7 +306,7 @@ class PoTokenWebView private constructor(
"Accept" to listOf("application/json"), "Accept" to listOf("application/json"),
"Content-Type" to listOf("application/json+protobuf"), "Content-Type" to listOf("application/json+protobuf"),
"x-goog-api-key" to listOf(GOOGLE_API_KEY), "x-goog-api-key" to listOf(GOOGLE_API_KEY),
"x-user-agent" to listOf("grpc-web-javascript/0.1"), "x-user-agent" to listOf("grpc-web-javascript/0.1")
), ),
data.toByteArray() data.toByteArray()
) )
@ -385,7 +385,7 @@ class PoTokenWebView private constructor(
*/ */
private fun runOnMainThread( private fun runOnMainThread(
emitterIfPostFails: SingleEmitter<out Any>, emitterIfPostFails: SingleEmitter<out Any>,
runnable: Runnable, runnable: Runnable
) { ) {
if (!Handler(Looper.getMainLooper()).post(runnable)) { if (!Handler(Looper.getMainLooper()).post(runnable)) {
emitterIfPostFails.onError(PoTokenException("Could not run on main thread")) emitterIfPostFails.onError(PoTokenException("Could not run on main thread"))

View file

@ -29,7 +29,7 @@ class ImportAllCombinationsTest {
val containsSer: Ser, val containsSer: Ser,
val containsJson: Boolean, val containsJson: Boolean,
val filename: String, val filename: String,
val throwable: Throwable, val throwable: Throwable
) )
private fun testZipCombination( private fun testZipCombination(
@ -37,7 +37,7 @@ class ImportAllCombinationsTest {
containsSer: Ser, containsSer: Ser,
containsJson: Boolean, containsJson: Boolean,
filename: String, filename: String,
runTest: (test: () -> Unit) -> Unit, runTest: (test: () -> Unit) -> Unit
) { ) {
val zipFile = File(classloader.getResource(filename)?.file!!) val zipFile = File(classloader.getResource(filename)?.file!!)
val zip = Mockito.mock(StoredFileHelper::class.java, Mockito.withSettings().stubOnly()) val zip = Mockito.mock(StoredFileHelper::class.java, Mockito.withSettings().stubOnly())