Fix a number of lint issues (#2)
* Fix systemUiVisibility deprecation warnings This commit extracts setSystemUiVisibility as an extension and uses the new API depending on the Build.VERSION * Fix splash fragment vector issues Clip-path isn't available before V24 and width/height should not exceed 200 dp. * Remove unused disclaimer fragment header * Remove unused ic_launcher_round * Ignore IconMissingDensityFolder lint Ignoring it because all the images are vector * Ignore UnusedAttribute lint It warns about networkSecurityConfig which is used only in debug builds to allow user SSL certificates. Lint says it's not available before v24. But it doesn't matter since before v24 the user SSL certificates were allowed by default. * Use plurals for disclaimer count down
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
package gq.kirmanak.mealient.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
@@ -28,4 +34,30 @@ fun SwipeRefreshLayout.refreshesLiveData(): LiveData<Unit> {
|
||||
}
|
||||
}
|
||||
return callbackFlow.asLiveData()
|
||||
}
|
||||
|
||||
fun Activity.setSystemUiVisibility(isVisible: Boolean) {
|
||||
Timber.v("setSystemUiVisibility() called with: isVisible = $isVisible")
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) setSystemUiVisibilityV30(isVisible)
|
||||
else setSystemUiVisibilityV1(isVisible)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun Activity.setSystemUiVisibilityV1(isVisible: Boolean) {
|
||||
Timber.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) {
|
||||
Timber.v("setSystemUiVisibilityV30() called with: isVisible = $isVisible")
|
||||
val systemBars = WindowInsets.Type.systemBars()
|
||||
window.insetsController?.apply { if (isVisible) show(systemBars) else hide(systemBars) }
|
||||
?: Timber.w("setSystemUiVisibilityV30: insets controller is null")
|
||||
}
|
||||
|
||||
fun AppCompatActivity.setActionBarVisibility(isVisible: Boolean) {
|
||||
Timber.v("setActionBarVisibility() called with: isVisible = $isVisible")
|
||||
supportActionBar?.apply { if (isVisible) show() else hide() }
|
||||
?: Timber.w("setActionBarVisibility: action bar is null")
|
||||
}
|
||||
Reference in New Issue
Block a user