mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-06-05 21:59:19 +02:00
initial implementation of rewriting the app in kotlin
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
package com.simplemobiletools.flashlight.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
|
||||
import com.simplemobiletools.flashlight.R
|
||||
|
||||
class BrightDisplayActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_bright_display)
|
||||
supportActionBar?.hide()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
toggleBrightness(true)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
toggleBrightness(false)
|
||||
}
|
||||
|
||||
private fun toggleBrightness(increase: Boolean) {
|
||||
val layout = window.attributes
|
||||
layout.screenBrightness = (if (increase) 1 else 0).toFloat()
|
||||
window.attributes = layout
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user