Skip to content

Instantly share code, notes, and snippets.

View hiking93's full-sized avatar

Hsingchien Cheng (工程師 Hiking) hiking93

View GitHub Profile
@hiking93
hiking93 / disable_chrome_remote_desktop_curtain_mode.bat
Created April 27, 2024 09:57
Chrome Remote Desktop Curtain Mode
reg add HKLM\Software\Policies\Google\Chrome /v RemoteAccessHostRequireCurtain /d 0 /t REG_DWORD /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /d 1 /t REG_DWORD /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v SecurityLayer /d 2 /t REG_DWORD /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /d 1 /t REG_DWORD /f
net stop chromoting
net start chromoting
$files = Get-ChildItem -Recurse -Filter '*.ts'
foreach ($file in $files) {
ffmpeg.exe -i ($file) ($file -replace '\.ts$', '.mp4')
}
fun View.doOnWindowInsetsChanged(
listenToAnimation: Boolean = false,
@DispatchMode dispatchMode: Int = DISPATCH_MODE_STOP,
callback: (v: View, insets: WindowInsetsCompat) -> WindowInsetsCompat,
) {
var isAnimationRunning = false
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
if (isAnimationRunning) insets else callback(v, insets)
}
if (listenToAnimation) {
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) {
@hiking93
hiking93 / ConsumeWindowInsets.kt
Created March 17, 2022 07:25
Return consumed insets in OnApplyWindowInsetsListener#onApplyWindowInsets.
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)
@hiking93
hiking93 / HandleWindowInsets.kt
Last active March 17, 2022 07:23
Update padding with system window insets.
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),
)
@hiking93
hiking93 / GetSystemWindowInsets.kt
Last active March 17, 2022 07:23
Getting system window insets.
val systemWindowInsets = insets.getInsets(
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime()
)
@hiking93
hiking93 / EdgeToEdgeActivity.kt
Created March 16, 2022 08:41
Use `OnApplyWindowInsetsListener` to get window insets.
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 ->
@hiking93
hiking93 / EdgeToEdgeActivity.kt
Last active March 16, 2022 08:40
Setting decor to fit system windows.
class EdgeToEdgeActivity : ViewBindingActivity<ActivityMainBinding>() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupWindow()
}
private fun setupWindow() {
WindowCompat.setDecorFitsSystemWindows(window, false)
}
@hiking93
hiking93 / themes.xml
Last active July 21, 2022 19:47
Edge-to-edge theme configuration with Material 3.
<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>