Skip to content

Commit 9b7874f

Browse files
committed
ktlint: Fix blank-line-between-when-conditions violations
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
1 parent ff2390b commit 9b7874f

15 files changed

Lines changed: 75 additions & 2 deletions

File tree

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ ktlint_function_naming_ignore_when_annotated_with = Composable
1212

1313
ktlint_standard_argument-list-wrapping = disabled
1414
ktlint_standard_backing-property-naming = disabled
15-
ktlint_standard_blank-line-before-declaration = disabled
16-
ktlint_standard_blank-line-between-when-conditions = disabled
1715
ktlint_standard_chain-method-continuation = disabled
1816
ktlint_standard_class-signature = disabled
1917
ktlint_standard_function-expression-body = disabled

app/src/main/java/org/schabi/newpipe/error/ErrorInfo.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,24 @@ class ErrorInfo private constructor(
193193
ErrorMessage(R.string.player_http_invalid_status, cause.responseCode.toString())
194194
}
195195
}
196+
196197
cause is Loader.UnexpectedLoaderException && cause.cause is ExtractionException ->
197198
getMessage(throwable, action, serviceId)
199+
198200
throwable.type == ExoPlaybackException.TYPE_SOURCE ->
199201
ErrorMessage(R.string.player_stream_failure)
202+
200203
throwable.type == ExoPlaybackException.TYPE_UNEXPECTED ->
201204
ErrorMessage(R.string.player_recoverable_failure)
205+
202206
else ->
203207
ErrorMessage(R.string.player_unrecoverable_failure)
204208
}
205209
}
210+
206211
throwable is FailedMediaSource.FailedMediaSourceException ->
207212
getMessage(throwable.cause, action, serviceId)
213+
208214
throwable is PlaybackResolver.ResolverException ->
209215
ErrorMessage(R.string.player_stream_failure)
210216

@@ -220,34 +226,46 @@ class ErrorInfo private constructor(
220226
)
221227
}
222228
?: ErrorMessage(R.string.account_terminated)
229+
223230
throwable is AgeRestrictedContentException ->
224231
ErrorMessage(R.string.restricted_video_no_stream)
232+
225233
throwable is GeographicRestrictionException ->
226234
ErrorMessage(R.string.georestricted_content)
235+
227236
throwable is PaidContentException ->
228237
ErrorMessage(R.string.paid_content)
238+
229239
throwable is PrivateContentException ->
230240
ErrorMessage(R.string.private_content)
241+
231242
throwable is SoundCloudGoPlusContentException ->
232243
ErrorMessage(R.string.soundcloud_go_plus_content)
244+
233245
throwable is UnsupportedContentInCountryException ->
234246
ErrorMessage(R.string.unsupported_content_in_country)
247+
235248
throwable is YoutubeMusicPremiumContentException ->
236249
ErrorMessage(R.string.youtube_music_premium_content)
250+
237251
throwable is SignInConfirmNotBotException ->
238252
ErrorMessage(R.string.sign_in_confirm_not_bot_error, getServiceName(serviceId))
253+
239254
throwable is ContentNotAvailableException ->
240255
ErrorMessage(R.string.content_not_available)
241256

242257
// other extractor exceptions
243258
throwable is ContentNotSupportedException ->
244259
ErrorMessage(R.string.content_not_supported)
260+
245261
// ReCaptchas will be handled in a special way anyway
246262
throwable is ReCaptchaException ->
247263
ErrorMessage(R.string.recaptcha_request_toast)
264+
248265
// test this at the end as many exceptions could be a subclass of IOException
249266
throwable != null && throwable.isNetworkRelated ->
250267
ErrorMessage(R.string.network_error)
268+
251269
// an extraction exception unrelated to the network
252270
// is likely an issue with parsing the website
253271
throwable is ExtractionException ->
@@ -256,16 +274,22 @@ class ErrorInfo private constructor(
256274
// user actions (in case the exception is null or unrecognizable)
257275
action == UserAction.UI_ERROR ->
258276
ErrorMessage(R.string.app_ui_crash)
277+
259278
action == UserAction.REQUESTED_COMMENTS ->
260279
ErrorMessage(R.string.error_unable_to_load_comments)
280+
261281
action == UserAction.SUBSCRIPTION_CHANGE ->
262282
ErrorMessage(R.string.subscription_change_failed)
283+
263284
action == UserAction.SUBSCRIPTION_UPDATE ->
264285
ErrorMessage(R.string.subscription_update_failed)
286+
265287
action == UserAction.LOAD_IMAGE ->
266288
ErrorMessage(R.string.could_not_load_thumbnails)
289+
267290
action == UserAction.DOWNLOAD_OPEN_DIALOG ->
268291
ErrorMessage(R.string.could_not_setup_download_menu)
292+
269293
else ->
270294
ErrorMessage(R.string.error_snackbar_message)
271295
}
@@ -276,15 +300,19 @@ class ErrorInfo private constructor(
276300
// we don't have an exception, so this is a manually built error, which likely
277301
// indicates that it's important and is thus reportable
278302
null -> true
303+
279304
// the service explicitly said that content is not available (e.g. age restrictions,
280305
// video deleted, etc.), there is no use in letting users report it
281306
is ContentNotAvailableException -> false
307+
282308
// we know the content is not supported, no need to let the user report it
283309
is ContentNotSupportedException -> false
310+
284311
// happens often when there is no internet connection; we don't use
285312
// `throwable.isNetworkRelated` since any `IOException` would make that function
286313
// return true, but not all `IOException`s are network related
287314
is UnknownHostException -> false
315+
288316
// by default, this is an unexpected exception, which the user could report
289317
else -> true
290318
}
@@ -294,8 +322,10 @@ class ErrorInfo private constructor(
294322
return when (throwable) {
295323
// we know the content is not available, retrying won't help
296324
is ContentNotAvailableException -> false
325+
297326
// we know the content is not supported, retrying won't help
298327
is ContentNotSupportedException -> false
328+
299329
// by default (including if throwable is null), enable retrying (though the retry
300330
// button will be shown only if a way to perform the retry is implemented)
301331
else -> true

app/src/main/java/org/schabi/newpipe/local/feed/item/StreamItem.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ data class StreamItem(
132132
viewsAndDate.isEmpty() -> uploadDate!!
133133
else -> Localization.concatenateStrings(viewsAndDate, uploadDate)
134134
}
135+
135136
else -> viewsAndDate
136137
}
137138
}

app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadManager.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ class FeedLoadManager(private val context: Context) {
8585
FeedGroupEntity.GROUP_ALL_ID -> feedDatabaseManager.outdatedSubscriptions(
8686
outdatedThreshold
8787
)
88+
8889
GROUP_NOTIFICATION_ENABLED -> feedDatabaseManager.outdatedSubscriptionsWithNotificationMode(
8990
outdatedThreshold, NotificationMode.ENABLED
9091
)
92+
9193
else -> feedDatabaseManager.outdatedSubscriptionsForGroup(groupId, outdatedThreshold)
9294
}
9395

@@ -305,6 +307,7 @@ class FeedLoadManager(private val context: Context) {
305307
feedDatabaseManager.markAsOutdated(info.uid)
306308
}
307309
}
310+
308311
notification.isOnError -> {
309312
val error = notification.error
310313
feedResultsHolder.addError(error!!)

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,13 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
276276
when (item) {
277277
is FeedGroupCardItem ->
278278
NavigationHelper.openFeedFragment(fm, item.groupId, item.name)
279+
279280
is FeedGroupCardGridItem ->
280281
NavigationHelper.openFeedFragment(fm, item.groupId, item.name)
282+
281283
is FeedGroupAddNewItem ->
282284
FeedGroupDialog.newInstance().show(fm, null)
285+
283286
is FeedGroupAddNewGridItem ->
284287
FeedGroupDialog.newInstance().show(fm, null)
285288
}
@@ -294,6 +297,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
294297
when (item) {
295298
is FeedGroupCardItem ->
296299
FeedGroupDialog.newInstance(item.groupId).show(fm, null)
300+
297301
is FeedGroupCardGridItem ->
298302
FeedGroupDialog.newInstance(item.groupId).show(fm, null)
299303
}
@@ -344,7 +348,9 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
344348
0 -> ShareUtils.shareText(
345349
requireContext(), selectedItem.name, selectedItem.url, selectedItem.thumbnails
346350
)
351+
347352
1 -> ShareUtils.openUrlInBrowser(requireContext(), selectedItem.url)
353+
348354
2 -> deleteChannel(selectedItem)
349355
}
350356
}
@@ -404,6 +410,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
404410
itemsListState = null
405411
}
406412
}
413+
407414
is SubscriptionState.ErrorState -> {
408415
result.error?.let {
409416
showError(ErrorInfo(result.error, UserAction.SOMETHING_ELSE, "Subscriptions"))

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionManager.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class SubscriptionManager(context: Context) {
4343
subscriptionTable.getSubscriptionsFiltered(filterQuery)
4444
}
4545
}
46+
4647
showOnlyUngrouped -> subscriptionTable.getSubscriptionsOnlyUngrouped(currentGroupId)
48+
4749
else -> subscriptionTable.getAll()
4850
}
4951
}

app/src/main/java/org/schabi/newpipe/player/gesture/MainPlayerGestureListener.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ class MainPlayerGestureListener(
4242
v.parent?.requestDisallowInterceptTouchEvent(playerUi.isFullscreen)
4343
true
4444
}
45+
4546
MotionEvent.ACTION_UP -> {
4647
v.parent?.requestDisallowInterceptTouchEvent(false)
4748
false
4849
}
50+
4951
else -> true
5052
}
5153
}
@@ -198,13 +200,15 @@ class MainPlayerGestureListener(
198200
when (PlayerHelper.getActionForRightGestureSide(player.context)) {
199201
player.context.getString(R.string.volume_control_key) ->
200202
onScrollVolume(distanceY)
203+
201204
player.context.getString(R.string.brightness_control_key) ->
202205
onScrollBrightness(distanceY)
203206
}
204207
} else {
205208
when (PlayerHelper.getActionForLeftGestureSide(player.context)) {
206209
player.context.getString(R.string.volume_control_key) ->
207210
onScrollVolume(distanceY)
211+
208212
player.context.getString(R.string.brightness_control_key) ->
209213
onScrollBrightness(distanceY)
210214
}

app/src/main/java/org/schabi/newpipe/player/mediabrowser/PackageValidator.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,21 @@ internal class PackageValidator(context: Context) {
9494
val isCallerKnown = when {
9595
// If it's our own app making the call, allow it.
9696
callingUid == Process.myUid() -> true
97+
9798
// If the system is making the call, allow it.
9899
callingUid == Process.SYSTEM_UID -> true
100+
99101
// If the app was signed by the same certificate as the platform itself, also allow it.
100102
callerSignature == platformSignature -> true
103+
101104
/*
102105
* [MEDIA_CONTENT_CONTROL] permission is only available to system applications, and
103106
* while it isn't required to allow these apps to connect to a
104107
* [MediaBrowserServiceCompat], allowing this ensures optimal compatability with apps
105108
* such as Android TV and the Google Assistant.
106109
*/
107110
callerPackageInfo.permissions.contains(MEDIA_CONTENT_CONTROL) -> true
111+
108112
/*
109113
* If the calling app has a notification listener it is able to retrieve notifications
110114
* and can connect to an active [MediaSessionCompat].

app/src/main/java/org/schabi/newpipe/settings/export/ImportExportManager.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,15 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
122122
for ((key, value) in entries) {
123123
when (value) {
124124
is Boolean -> editor.putBoolean(key, value)
125+
125126
is Float -> editor.putFloat(key, value)
127+
126128
is Int -> editor.putInt(key, value)
129+
127130
is Long -> editor.putLong(key, value)
131+
128132
is String -> editor.putString(key, value)
133+
129134
is Set<*> -> {
130135
// There are currently only Sets with type String possible
131136
@Suppress("UNCHECKED_CAST")
@@ -159,10 +164,15 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
159164
for ((key, value) in jsonObject) {
160165
when (value) {
161166
is Boolean -> editor.putBoolean(key, value)
167+
162168
is Float -> editor.putFloat(key, value)
169+
163170
is Int -> editor.putInt(key, value)
171+
164172
is Long -> editor.putLong(key, value)
173+
165174
is String -> editor.putString(key, value)
175+
166176
is JsonArray -> {
167177
editor.putStringSet(key, value.mapNotNull { e -> e as? String }.toSet())
168178
}

app/src/main/java/org/schabi/newpipe/settings/notifications/NotificationModeConfigFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class NotificationModeConfigFragment : Fragment() {
8888
toggleAll()
8989
true
9090
}
91+
9192
else -> super.onOptionsItemSelected(item)
9293
}
9394
}

0 commit comments

Comments
 (0)