Skip to content

Commit 4ef4ed1

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Convert newpipe/util/image/PreferredImageQuality to kotlin
1 parent fef8a24 commit 4ef4ed1

2 files changed

Lines changed: 38 additions & 39 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/image/PreferredImageQuality.java

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2025 NewPipe contributors <https://newpipe.net>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.util.image
7+
8+
import android.content.Context
9+
import org.schabi.newpipe.R
10+
import org.schabi.newpipe.extractor.Image.ResolutionLevel
11+
12+
enum class PreferredImageQuality {
13+
NONE,
14+
LOW,
15+
MEDIUM,
16+
HIGH;
17+
18+
fun toResolutionLevel(): ResolutionLevel {
19+
return when (this) {
20+
LOW -> ResolutionLevel.LOW
21+
MEDIUM -> ResolutionLevel.MEDIUM
22+
HIGH -> ResolutionLevel.HIGH
23+
NONE -> ResolutionLevel.UNKNOWN
24+
}
25+
}
26+
27+
companion object {
28+
@JvmStatic
29+
fun fromPreferenceKey(context: Context, key: String?): PreferredImageQuality {
30+
return when (key) {
31+
context.getString(R.string.image_quality_none_key) -> NONE
32+
context.getString(R.string.image_quality_low_key) -> LOW
33+
context.getString(R.string.image_quality_high_key) -> HIGH
34+
else -> MEDIUM // default to medium
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)