Start splash screen API migration
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
package gq.kirmanak.mealient.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
@@ -39,32 +33,6 @@ fun SwipeRefreshLayout.refreshRequestFlow(logger: Logger): Flow<Unit> = callback
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.setSystemUiVisibility(isVisible: Boolean, logger: Logger) {
|
||||
logger.v { "setSystemUiVisibility() called with: isVisible = $isVisible" }
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) setSystemUiVisibilityV30(isVisible, logger)
|
||||
else setSystemUiVisibilityV1(isVisible, logger)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun Activity.setSystemUiVisibilityV1(isVisible: Boolean, logger: Logger) {
|
||||
logger.v { "setSystemUiVisibilityV1() called with: isVisible = $isVisible" }
|
||||
window.decorView.systemUiVisibility = if (isVisible) 0 else View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun Activity.setSystemUiVisibilityV30(isVisible: Boolean, logger: Logger) {
|
||||
logger.v { "setSystemUiVisibilityV30() called with: isVisible = $isVisible" }
|
||||
val systemBars = WindowInsets.Type.systemBars()
|
||||
window.insetsController?.apply { if (isVisible) show(systemBars) else hide(systemBars) }
|
||||
?: logger.w { "setSystemUiVisibilityV30: insets controller is null" }
|
||||
}
|
||||
|
||||
fun AppCompatActivity.setActionBarVisibility(isVisible: Boolean, logger: Logger) {
|
||||
logger.v { "setActionBarVisibility() called with: isVisible = $isVisible" }
|
||||
supportActionBar?.apply { if (isVisible) show() else hide() }
|
||||
?: logger.w { "setActionBarVisibility: action bar is null" }
|
||||
}
|
||||
|
||||
fun TextView.textChangesFlow(logger: Logger): Flow<CharSequence?> = callbackFlow {
|
||||
logger.v { "textChangesFlow() called" }
|
||||
val textWatcher = doAfterTextChanged {
|
||||
|
||||
Reference in New Issue
Block a user