Merge pull request #205 from fatihergin/feature/bind-activities-consistently-across-the-simple-apps

make activity inflating consistent across simple apps
This commit is contained in:
Tibor Kaputa 2023-08-16 19:31:23 +02:00 committed by GitHub
commit d1d3b698f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 14 deletions

View File

@ -11,7 +11,7 @@ import com.simplemobiletools.flashlight.databinding.ActivityBrightDisplayBinding
import com.simplemobiletools.flashlight.extensions.config import com.simplemobiletools.flashlight.extensions.config
class BrightDisplayActivity : SimpleActivity() { class BrightDisplayActivity : SimpleActivity() {
private lateinit var binding: ActivityBrightDisplayBinding private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityBrightDisplayBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
window.addFlags( window.addFlags(
@ -23,7 +23,6 @@ class BrightDisplayActivity : SimpleActivity() {
useDynamicTheme = false useDynamicTheme = false
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityBrightDisplayBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
supportActionBar?.hide() supportActionBar?.hide()
setBackgroundColor(config.brightDisplayColor) setBackgroundColor(config.brightDisplayColor)

View File

@ -28,12 +28,15 @@ import org.greenrobot.eventbus.Subscribe
import java.util.* import java.util.*
class MainActivity : SimpleActivity() { class MainActivity : SimpleActivity() {
private val MAX_STROBO_DELAY = 2000L companion object {
private val MIN_STROBO_DELAY = 10L private const val MAX_STROBO_DELAY = 2000L
private val FLASHLIGHT_STATE = "flashlight_state" private const val MIN_STROBO_DELAY = 10L
private val STROBOSCOPE_STATE = "stroboscope_state" private const val FLASHLIGHT_STATE = "flashlight_state"
private const val STROBOSCOPE_STATE = "stroboscope_state"
}
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMainBinding.inflate(layoutInflater) }
private lateinit var binding: ActivityMainBinding
private var mBus: EventBus? = null private var mBus: EventBus? = null
private var mCameraImpl: MyCameraImpl? = null private var mCameraImpl: MyCameraImpl? = null
private var mIsFlashlightOn = false private var mIsFlashlightOn = false
@ -42,7 +45,6 @@ class MainActivity : SimpleActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true isMaterialActivity = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID) appLaunched(BuildConfig.APPLICATION_ID)
setupOptionsMenu() setupOptionsMenu()

View File

@ -12,12 +12,11 @@ import java.util.Locale
import kotlin.system.exitProcess import kotlin.system.exitProcess
class SettingsActivity : SimpleActivity() { class SettingsActivity : SimpleActivity() {
private lateinit var binding: ActivitySettingsBinding private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivitySettingsBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true isMaterialActivity = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
binding.apply { binding.apply {

View File

@ -17,7 +17,8 @@ import com.simplemobiletools.flashlight.extensions.config
import com.simplemobiletools.flashlight.helpers.MyWidgetBrightDisplayProvider import com.simplemobiletools.flashlight.helpers.MyWidgetBrightDisplayProvider
class WidgetBrightDisplayConfigureActivity : SimpleActivity() { class WidgetBrightDisplayConfigureActivity : SimpleActivity() {
private lateinit var binding: WidgetBrightDisplayConfigBinding private val binding by lazy(LazyThreadSafetyMode.NONE) { WidgetBrightDisplayConfigBinding.inflate(layoutInflater) }
private var mWidgetAlpha = 0f private var mWidgetAlpha = 0f
private var mWidgetId = 0 private var mWidgetId = 0
private var mWidgetColor = 0 private var mWidgetColor = 0
@ -27,7 +28,6 @@ class WidgetBrightDisplayConfigureActivity : SimpleActivity() {
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = WidgetBrightDisplayConfigBinding.inflate(layoutInflater)
setResult(Activity.RESULT_CANCELED) setResult(Activity.RESULT_CANCELED)
setContentView(binding.root) setContentView(binding.root)
initVariables() initVariables()

View File

@ -18,7 +18,8 @@ import com.simplemobiletools.flashlight.extensions.updateBrightDisplayWidget
import com.simplemobiletools.flashlight.helpers.MyWidgetTorchProvider import com.simplemobiletools.flashlight.helpers.MyWidgetTorchProvider
class WidgetTorchConfigureActivity : SimpleActivity() { class WidgetTorchConfigureActivity : SimpleActivity() {
private lateinit var binding: WidgetTorchConfigBinding private val binding by lazy(LazyThreadSafetyMode.NONE) { WidgetTorchConfigBinding.inflate(layoutInflater) }
private var mWidgetAlpha = 0f private var mWidgetAlpha = 0f
private var mWidgetId = 0 private var mWidgetId = 0
private var mWidgetColor = 0 private var mWidgetColor = 0
@ -28,7 +29,6 @@ class WidgetTorchConfigureActivity : SimpleActivity() {
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false useDynamicTheme = false
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = WidgetTorchConfigBinding.inflate(layoutInflater)
setResult(Activity.RESULT_CANCELED) setResult(Activity.RESULT_CANCELED)
setContentView(binding.root) setContentView(binding.root)
initVariables() initVariables()