This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object YoutubeDlHelper { | |
| enum class Selection(val value: Int) { | |
| PREVIEW(0), | |
| UNLOCKED(1) | |
| } | |
| private const val TAG = "youtube-dl" | |
| fun download(url: String, selection: Selection, file: File, showDebugLogs: Boolean = true): Boolean { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import okhttp3.HttpUrl | |
| import okhttp3.HttpUrl.Companion.toHttpUrlOrNull | |
| object EmbedResolver { | |
| data class Result( | |
| val url: String, | |
| val dimensionRatio: String | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.common.truth.Truth.assertThat | |
| import org.junit.Test | |
| class EmbedResolverTest { | |
| @Test | |
| fun `resolve youtube video regular`() { | |
| val url = "https://www.youtube.com/watch?v=7jzSXyEln9o&feature=youtu.be" | |
| assertThat(EmbedResolver.resolve(url)?.url) | |
| .isEqualTo("https://www.youtube.com/embed/7jzSXyEln9o?feature=youtu.be") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style name="Theme.App" parent="Theme.Material3.DayNight.NoActionBar"> | |
| <item name="android:statusBarColor">@android:color/transparent</item> | |
| <item name="android:navigationBarColor">@android:color/transparent</item> | |
| <item name="android:windowLightStatusBar">?isLightTheme</item> | |
| <item name="android:windowLightNavigationBar">?isLightTheme</item> | |
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EdgeToEdgeActivity : ViewBindingActivity<ActivityMainBinding>() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setupWindow() | |
| } | |
| private fun setupWindow() { | |
| WindowCompat.setDecorFitsSystemWindows(window, false) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EdgeToEdgeActivity : ViewBindingActivity<ActivityMainBinding>() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setupWindow() | |
| } | |
| private fun setupWindow() { | |
| WindowCompat.setDecorFitsSystemWindows(window, false) | |
| ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val systemWindowInsets = insets.getInsets( | |
| WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime() | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| binding.root.updatePadding( | |
| left = systemWindowInsets.left, | |
| right = systemWindowInsets.right, | |
| ) | |
| binding.appBarLayout.updatePadding( | |
| top = systemWindowInsets.top, | |
| ) | |
| binding.recyclerView.updatePadding( | |
| bottom = systemWindowInsets.bottom + 8f.dpToPxSize(v.context), | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | |
| val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()) | |
| WindowInsetsCompat.Builder(insets) | |
| .setInsets( | |
| WindowInsetsCompat.Type.systemBars(), | |
| Insets.of(0, 0, 0, systemBarInsets.bottom) | |
| ) | |
| .setInsets( | |
| WindowInsetsCompat.Type.ime(), | |
| Insets.of(0, 0, 0, imeInsets.bottom) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets -> | |
| val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()) | |
| Log.d("Hiking", "onApplyWindowInsets, bottom = ${imeInsets.bottom}") | |
| insets | |
| } | |
| ViewCompat.setWindowInsetsAnimationCallback( | |
| binding.root, | |
| object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) { | |
| override fun onPrepare(animation: WindowInsetsAnimationCompat) { |