Skip to content

Commit 1418264

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

2 files changed

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

0 commit comments

Comments
 (0)