use scope functions for repetitive binding usages
This commit is contained in:
parent
ff7037c24e
commit
c0ab3673b1
|
@ -216,10 +216,10 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
||||
private fun hideIntentButtons() {
|
||||
binding.cameraModeHolder.beGone()
|
||||
binding.layoutTop.settings.beGone()
|
||||
binding.lastPhotoVideoPreview.beInvisible()
|
||||
private fun hideIntentButtons() = binding.apply {
|
||||
cameraModeHolder.beGone()
|
||||
layoutTop.settings.beGone()
|
||||
lastPhotoVideoPreview.beInvisible()
|
||||
}
|
||||
|
||||
private fun tryInitCamera() {
|
||||
|
@ -299,9 +299,11 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
setContentView(binding.root)
|
||||
initButtons()
|
||||
initModeSwitcher()
|
||||
defaultScene = Scene(binding.topOptions, binding.layoutTop.defaultIcons)
|
||||
flashModeScene = Scene(binding.topOptions, binding.layoutFlash.flashToggleGroup)
|
||||
timerScene = Scene(binding.topOptions, binding.layoutTimer.timerToggleGroup)
|
||||
binding.apply {
|
||||
defaultScene = Scene(topOptions, layoutTop.defaultIcons)
|
||||
flashModeScene = Scene(topOptions, layoutFlash.flashToggleGroup)
|
||||
timerScene = Scene(topOptions, layoutTimer.timerToggleGroup)
|
||||
}
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(binding.viewHolder) { _, windowInsets ->
|
||||
|
@ -352,64 +354,72 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
}
|
||||
|
||||
private fun initFlashModeTransitionNames() {
|
||||
private fun initFlashModeTransitionNames() = binding.layoutFlash.apply {
|
||||
val baseName = getString(R.string.toggle_flash)
|
||||
binding.layoutFlash.flashAuto.transitionName = "$baseName$FLASH_AUTO"
|
||||
binding.layoutFlash.flashOff.transitionName = "$baseName$FLASH_OFF"
|
||||
binding.layoutFlash.flashOn.transitionName = "$baseName$FLASH_ON"
|
||||
binding.layoutFlash.flashAlwaysOn.transitionName = "$baseName$FLASH_ALWAYS_ON"
|
||||
flashAuto.transitionName = "$baseName$FLASH_AUTO"
|
||||
flashOff.transitionName = "$baseName$FLASH_OFF"
|
||||
flashOn.transitionName = "$baseName$FLASH_ON"
|
||||
flashAlwaysOn.transitionName = "$baseName$FLASH_ALWAYS_ON"
|
||||
}
|
||||
|
||||
private fun initTimerModeTransitionNames() {
|
||||
private fun initTimerModeTransitionNames() = binding.layoutTimer.apply {
|
||||
val baseName = getString(R.string.toggle_timer)
|
||||
binding.layoutTimer.timerOff.transitionName = "$baseName${TimerMode.OFF.name}"
|
||||
binding.layoutTimer.timer3s.transitionName = "$baseName${TimerMode.TIMER_3.name}"
|
||||
binding.layoutTimer.timer5s.transitionName = "$baseName${TimerMode.TIMER_5.name}"
|
||||
binding.layoutTimer.timer10S.transitionName = "$baseName${TimerMode.TIMER_10.name}"
|
||||
timerOff.transitionName = "$baseName${TimerMode.OFF.name}"
|
||||
timer3s.transitionName = "$baseName${TimerMode.TIMER_3.name}"
|
||||
timer5s.transitionName = "$baseName${TimerMode.TIMER_5.name}"
|
||||
timer10S.transitionName = "$baseName${TimerMode.TIMER_10.name}"
|
||||
}
|
||||
|
||||
private fun initButtons() {
|
||||
binding.timerText.setFactory { layoutInflater.inflate(R.layout.timer_text, null) }
|
||||
binding.toggleCamera.setOnClickListener { mPreview!!.toggleFrontBackCamera() }
|
||||
binding.lastPhotoVideoPreview.setOnClickListener { showLastMediaPreview() }
|
||||
binding.layoutTop.toggleFlash.setOnClickListener { mPreview!!.handleFlashlightClick() }
|
||||
binding.layoutTop.toggleTimer.setOnClickListener {
|
||||
private fun initButtons() = binding.apply {
|
||||
timerText.setFactory { layoutInflater.inflate(R.layout.timer_text, null) }
|
||||
toggleCamera.setOnClickListener { mPreview!!.toggleFrontBackCamera() }
|
||||
lastPhotoVideoPreview.setOnClickListener { showLastMediaPreview() }
|
||||
|
||||
layoutTop.apply {
|
||||
toggleFlash.setOnClickListener { mPreview!!.handleFlashlightClick() }
|
||||
toggleTimer.setOnClickListener {
|
||||
val transitionSet = createTransition()
|
||||
TransitionManager.go(timerScene, transitionSet)
|
||||
binding.layoutTimer.timerToggleGroup.beVisible()
|
||||
binding.layoutTimer.timerToggleGroup.check(config.timerMode.getTimerModeResId())
|
||||
binding.layoutTimer.timerToggleGroup.children.forEach { setButtonColors(it as MaterialButton) }
|
||||
layoutTimer.timerToggleGroup.beVisible()
|
||||
layoutTimer.timerToggleGroup.check(config.timerMode.getTimerModeResId())
|
||||
layoutTimer.timerToggleGroup.children.forEach { setButtonColors(it as MaterialButton) }
|
||||
}
|
||||
binding.shutter.setOnClickListener { shutterPressed() }
|
||||
|
||||
binding.layoutTop.settings.setShadowIcon(R.drawable.ic_settings_vector)
|
||||
binding.layoutTop.settings.setOnClickListener { launchSettings() }
|
||||
settings.setShadowIcon(R.drawable.ic_settings_vector)
|
||||
settings.setOnClickListener { launchSettings() }
|
||||
changeResolution.setOnClickListener { mPreview?.showChangeResolution() }
|
||||
}
|
||||
|
||||
binding.layoutTop.changeResolution.setOnClickListener { mPreview?.showChangeResolution() }
|
||||
shutter.setOnClickListener { shutterPressed() }
|
||||
|
||||
binding.layoutFlash.flashOn.setShadowIcon(R.drawable.ic_flash_on_vector)
|
||||
binding.layoutFlash.flashOn.setOnClickListener { selectFlashMode(FLASH_ON) }
|
||||
layoutFlash.apply {
|
||||
flashOn.setShadowIcon(R.drawable.ic_flash_on_vector)
|
||||
flashOn.setOnClickListener { selectFlashMode(FLASH_ON) }
|
||||
|
||||
binding.layoutFlash.flashOff.setShadowIcon(R.drawable.ic_flash_off_vector)
|
||||
binding.layoutFlash.flashOff.setOnClickListener { selectFlashMode(FLASH_OFF) }
|
||||
flashOff.setShadowIcon(R.drawable.ic_flash_off_vector)
|
||||
flashOff.setOnClickListener { selectFlashMode(FLASH_OFF) }
|
||||
|
||||
binding.layoutFlash.flashAuto.setShadowIcon(R.drawable.ic_flash_auto_vector)
|
||||
binding.layoutFlash.flashAuto.setOnClickListener { selectFlashMode(FLASH_AUTO) }
|
||||
flashAuto.setShadowIcon(R.drawable.ic_flash_auto_vector)
|
||||
flashAuto.setOnClickListener { selectFlashMode(FLASH_AUTO) }
|
||||
|
||||
binding.layoutFlash.flashAlwaysOn.setShadowIcon(R.drawable.ic_flashlight_vector)
|
||||
binding.layoutFlash.flashAlwaysOn.setOnClickListener { selectFlashMode(FLASH_ALWAYS_ON) }
|
||||
flashAlwaysOn.setShadowIcon(R.drawable.ic_flashlight_vector)
|
||||
flashAlwaysOn.setOnClickListener { selectFlashMode(FLASH_ALWAYS_ON) }
|
||||
}
|
||||
|
||||
binding.layoutTimer.timerOff.setShadowIcon(R.drawable.ic_timer_off_vector)
|
||||
binding.layoutTimer.timerOff.setOnClickListener { selectTimerMode(TimerMode.OFF) }
|
||||
layoutTimer.apply {
|
||||
timerOff.setShadowIcon(R.drawable.ic_timer_off_vector)
|
||||
timerOff.setOnClickListener { selectTimerMode(TimerMode.OFF) }
|
||||
|
||||
binding.layoutTimer.timer3s.setShadowIcon(R.drawable.ic_timer_3_vector)
|
||||
binding.layoutTimer.timer3s.setOnClickListener { selectTimerMode(TimerMode.TIMER_3) }
|
||||
timer3s.setShadowIcon(R.drawable.ic_timer_3_vector)
|
||||
timer3s.setOnClickListener { selectTimerMode(TimerMode.TIMER_3) }
|
||||
|
||||
binding.layoutTimer.timer5s.setShadowIcon(R.drawable.ic_timer_5_vector)
|
||||
binding.layoutTimer.timer5s.setOnClickListener { selectTimerMode(TimerMode.TIMER_5) }
|
||||
timer5s.setShadowIcon(R.drawable.ic_timer_5_vector)
|
||||
timer5s.setOnClickListener { selectTimerMode(TimerMode.TIMER_5) }
|
||||
|
||||
timer10S.setShadowIcon(R.drawable.ic_timer_10_vector)
|
||||
timer10S.setOnClickListener { selectTimerMode(TimerMode.TIMER_10) }
|
||||
}
|
||||
|
||||
binding.layoutTimer.timer10S.setShadowIcon(R.drawable.ic_timer_10_vector)
|
||||
binding.layoutTimer.timer10S.setOnClickListener { selectTimerMode(TimerMode.TIMER_10) }
|
||||
setTimerModeIcon(config.timerMode)
|
||||
}
|
||||
|
||||
|
@ -419,9 +429,9 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
closeOptions()
|
||||
}
|
||||
|
||||
private fun setTimerModeIcon(timerMode: TimerMode) {
|
||||
binding.layoutTop.toggleTimer.setShadowIcon(timerMode.getTimerModeDrawableRes())
|
||||
binding.layoutTop.toggleTimer.transitionName = "${getString(R.string.toggle_timer)}${timerMode.name}"
|
||||
private fun setTimerModeIcon(timerMode: TimerMode) = binding.layoutTop.toggleTimer.apply {
|
||||
setShadowIcon(timerMode.getTimerModeDrawableRes())
|
||||
transitionName = "${getString(R.string.toggle_timer)}${timerMode.name}"
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
|
@ -510,17 +520,21 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
|
||||
override fun onInitPhotoMode() {
|
||||
binding.shutter.setImageResource(R.drawable.ic_shutter_animated)
|
||||
binding.layoutTop.toggleTimer.beVisible()
|
||||
binding.layoutTop.toggleTimer.fadeIn()
|
||||
binding.apply {
|
||||
shutter.setImageResource(R.drawable.ic_shutter_animated)
|
||||
layoutTop.toggleTimer.beVisible()
|
||||
layoutTop.toggleTimer.fadeIn()
|
||||
}
|
||||
setupPreviewImage(true)
|
||||
selectPhotoTab()
|
||||
}
|
||||
|
||||
override fun onInitVideoMode() {
|
||||
binding.shutter.setImageResource(R.drawable.ic_video_rec_animated)
|
||||
binding.layoutTop.toggleTimer.fadeOut()
|
||||
binding.layoutTop.toggleTimer.beGone()
|
||||
binding.apply {
|
||||
shutter.setImageResource(R.drawable.ic_video_rec_animated)
|
||||
layoutTop.toggleTimer.fadeOut()
|
||||
layoutTop.toggleTimer.beGone()
|
||||
}
|
||||
setupPreviewImage(false)
|
||||
selectVideoTab()
|
||||
}
|
||||
|
@ -602,14 +616,14 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
}
|
||||
|
||||
private fun animateViews(degrees: Int) {
|
||||
val views = arrayOf<View>(
|
||||
binding.toggleCamera,
|
||||
binding.layoutTop.toggleFlash,
|
||||
binding.layoutTop.changeResolution,
|
||||
binding.shutter,
|
||||
binding.layoutTop.settings,
|
||||
binding.lastPhotoVideoPreview
|
||||
private fun animateViews(degrees: Int) = binding.apply {
|
||||
val views = arrayOf(
|
||||
toggleCamera,
|
||||
layoutTop.toggleFlash,
|
||||
layoutTop.changeResolution,
|
||||
shutter,
|
||||
layoutTop.settings,
|
||||
lastPhotoVideoPreview
|
||||
)
|
||||
for (view in views) {
|
||||
rotate(view, degrees)
|
||||
|
@ -643,13 +657,13 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
toggleActionButtons(enabled = true)
|
||||
}
|
||||
|
||||
private fun toggleActionButtons(enabled: Boolean) {
|
||||
private fun toggleActionButtons(enabled: Boolean) = binding.apply {
|
||||
runOnUiThread {
|
||||
binding.shutter.isClickable = enabled
|
||||
binding.previewView.isEnabled = enabled
|
||||
binding.layoutTop.changeResolution.isEnabled = enabled
|
||||
binding.toggleCamera.isClickable = enabled
|
||||
binding.layoutTop.toggleFlash.isClickable = enabled
|
||||
shutter.isClickable = enabled
|
||||
previewView.isEnabled = enabled
|
||||
layoutTop.changeResolution.isEnabled = enabled
|
||||
toggleCamera.isClickable = enabled
|
||||
layoutTop.toggleFlash.isClickable = enabled
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,44 +703,50 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
|
||||
override fun onChangeFlashMode(flashMode: Int) {
|
||||
binding.layoutTop.apply {
|
||||
val flashDrawable = when (flashMode) {
|
||||
FLASH_OFF -> R.drawable.ic_flash_off_vector
|
||||
FLASH_ON -> R.drawable.ic_flash_on_vector
|
||||
FLASH_AUTO -> R.drawable.ic_flash_auto_vector
|
||||
else -> R.drawable.ic_flashlight_vector
|
||||
}
|
||||
binding.layoutTop.toggleFlash.setShadowIcon(flashDrawable)
|
||||
binding.layoutTop.toggleFlash.transitionName = "${getString(R.string.toggle_flash)}$flashMode"
|
||||
toggleFlash.setShadowIcon(flashDrawable)
|
||||
toggleFlash.transitionName = "${getString(R.string.toggle_flash)}$flashMode"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVideoRecordingStarted() {
|
||||
binding.cameraModeHolder.beInvisible()
|
||||
binding.videoRecCurrTimer.beVisible()
|
||||
binding.apply {
|
||||
cameraModeHolder.beInvisible()
|
||||
videoRecCurrTimer.beVisible()
|
||||
|
||||
binding.toggleCamera.fadeOut()
|
||||
binding.lastPhotoVideoPreview.fadeOut()
|
||||
toggleCamera.fadeOut()
|
||||
lastPhotoVideoPreview.fadeOut()
|
||||
|
||||
binding.layoutTop.changeResolution.isEnabled = false
|
||||
binding.layoutTop.settings.isEnabled = false
|
||||
binding.shutter.post {
|
||||
layoutTop.changeResolution.isEnabled = false
|
||||
layoutTop.settings.isEnabled = false
|
||||
shutter.post {
|
||||
if (!isDestroyed) {
|
||||
binding.shutter.isSelected = true
|
||||
shutter.isSelected = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVideoRecordingStopped() {
|
||||
binding.cameraModeHolder.beVisible()
|
||||
binding.apply {
|
||||
cameraModeHolder.beVisible()
|
||||
|
||||
binding.toggleCamera.fadeIn()
|
||||
binding.lastPhotoVideoPreview.fadeIn()
|
||||
toggleCamera.fadeIn()
|
||||
lastPhotoVideoPreview.fadeIn()
|
||||
|
||||
binding.videoRecCurrTimer.text = 0.getFormattedDuration()
|
||||
binding.videoRecCurrTimer.beGone()
|
||||
videoRecCurrTimer.text = 0.getFormattedDuration()
|
||||
videoRecCurrTimer.beGone()
|
||||
|
||||
binding.shutter.isSelected = false
|
||||
binding.layoutTop.changeResolution.isEnabled = true
|
||||
binding.layoutTop.settings.isEnabled = true
|
||||
shutter.isSelected = false
|
||||
layoutTop.changeResolution.isEnabled = true
|
||||
layoutTop.settings.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVideoDurationChanged(durationNanos: Long) {
|
||||
|
@ -743,20 +763,22 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
|
||||
private fun closeOptions(): Boolean {
|
||||
binding.apply {
|
||||
if (mediaSizeToggleGroup?.isVisible() == true ||
|
||||
binding.layoutFlash.flashToggleGroup.isVisible() || binding.layoutTimer.timerToggleGroup.isVisible()
|
||||
layoutFlash.flashToggleGroup.isVisible() || layoutTimer.timerToggleGroup.isVisible()
|
||||
) {
|
||||
val transitionSet = createTransition()
|
||||
TransitionManager.go(defaultScene, transitionSet)
|
||||
mediaSizeToggleGroup?.beGone()
|
||||
binding.layoutFlash.flashToggleGroup.beGone()
|
||||
binding.layoutTimer.timerToggleGroup.beGone()
|
||||
binding.layoutTop.defaultIcons.beVisible()
|
||||
layoutFlash.flashToggleGroup.beGone()
|
||||
layoutTimer.timerToggleGroup.beGone()
|
||||
layoutTop.defaultIcons.beVisible()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
override fun displaySelectedResolution(resolutionOption: ResolutionOption) {
|
||||
val imageRes = resolutionOption.imageDrawableResId
|
||||
|
@ -824,14 +846,16 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
|
||||
override fun showFlashOptions(photoCapture: Boolean) {
|
||||
binding.layoutFlash.apply {
|
||||
val transitionSet = createTransition()
|
||||
TransitionManager.go(flashModeScene, transitionSet)
|
||||
binding.layoutFlash.flashAuto.beVisibleIf(photoCapture)
|
||||
binding.layoutFlash.flashAlwaysOn.beVisibleIf(photoCapture)
|
||||
binding.layoutFlash.flashToggleGroup.check(config.flashlightState.toFlashModeId())
|
||||
flashAuto.beVisibleIf(photoCapture)
|
||||
flashAlwaysOn.beVisibleIf(photoCapture)
|
||||
flashToggleGroup.check(config.flashlightState.toFlashModeId())
|
||||
|
||||
binding.layoutFlash.flashToggleGroup.beVisible()
|
||||
binding.layoutFlash.flashToggleGroup.children.forEach { setButtonColors(it as MaterialButton) }
|
||||
flashToggleGroup.beVisible()
|
||||
flashToggleGroup.children.forEach { setButtonColors(it as MaterialButton) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun setButtonColors(button: MaterialButton) {
|
||||
|
@ -842,16 +866,18 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}
|
||||
|
||||
override fun adjustPreviewView(requiresCentering: Boolean) {
|
||||
binding.apply {
|
||||
val constraintSet = ConstraintSet()
|
||||
constraintSet.clone(binding.viewHolder)
|
||||
constraintSet.clone(viewHolder)
|
||||
if (requiresCentering) {
|
||||
constraintSet.connect(binding.previewView.id, ConstraintSet.TOP, binding.topOptions.id, ConstraintSet.BOTTOM)
|
||||
constraintSet.connect(binding.previewView.id, ConstraintSet.BOTTOM, binding.cameraModeHolder.id, ConstraintSet.TOP)
|
||||
constraintSet.connect(previewView.id, ConstraintSet.TOP, topOptions.id, ConstraintSet.BOTTOM)
|
||||
constraintSet.connect(previewView.id, ConstraintSet.BOTTOM, cameraModeHolder.id, ConstraintSet.TOP)
|
||||
} else {
|
||||
constraintSet.connect(binding.previewView.id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
|
||||
constraintSet.connect(binding.previewView.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM)
|
||||
constraintSet.connect(previewView.id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP)
|
||||
constraintSet.connect(previewView.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM)
|
||||
}
|
||||
constraintSet.applyTo(viewHolder)
|
||||
}
|
||||
constraintSet.applyTo(binding.viewHolder)
|
||||
}
|
||||
|
||||
override fun mediaSaved(path: String) {
|
||||
|
@ -896,21 +922,21 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
|||
}.start()
|
||||
}
|
||||
|
||||
private fun hideViewsOnTimerStart() {
|
||||
arrayOf(binding.topOptions, binding.toggleCamera, binding.lastPhotoVideoPreview, binding.cameraModeHolder).forEach {
|
||||
private fun hideViewsOnTimerStart() = binding.apply {
|
||||
arrayOf(topOptions, toggleCamera, lastPhotoVideoPreview, cameraModeHolder).forEach {
|
||||
it.fadeOut()
|
||||
it.beInvisible()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetViewsOnTimerFinish() {
|
||||
arrayOf(binding.topOptions, binding.toggleCamera, binding.lastPhotoVideoPreview, binding.cameraModeHolder).forEach {
|
||||
private fun resetViewsOnTimerFinish() = binding.apply {
|
||||
arrayOf(topOptions, toggleCamera, lastPhotoVideoPreview, cameraModeHolder).forEach {
|
||||
it?.fadeIn()
|
||||
it?.beVisible()
|
||||
}
|
||||
|
||||
binding.timerText.beGone()
|
||||
binding.shutter.setImageState(intArrayOf(-R.attr.state_timer_cancel), true)
|
||||
timerText.beGone()
|
||||
shutter.setImageState(intArrayOf(-R.attr.state_timer_cancel), true)
|
||||
}
|
||||
|
||||
private fun checkWhatsNewDialog() {
|
||||
|
|
|
@ -23,12 +23,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.apply {
|
||||
setContentView(root)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||
updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settingsNestedScrollview, settingsToolbar)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -50,15 +52,17 @@ class SettingsActivity : SimpleActivity() {
|
|||
updateTextColors(binding.settingsHolder)
|
||||
|
||||
val properPrimaryColor = getProperPrimaryColor()
|
||||
binding.apply {
|
||||
arrayListOf(
|
||||
binding.settingsColorCustomizationLabel,
|
||||
binding.settingsGeneralSettingsLabel,
|
||||
binding.settingsShutterLabel,
|
||||
binding.settingsSavingLabel,
|
||||
settingsColorCustomizationLabel,
|
||||
settingsGeneralSettingsLabel,
|
||||
settingsShutterLabel,
|
||||
settingsSavingLabel,
|
||||
).forEach {
|
||||
it.setTextColor(properPrimaryColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
binding.settingsToolbar.menu.apply {
|
||||
|
@ -91,25 +95,25 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||
binding.settingsUseEnglish.toggle()
|
||||
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||
private fun setupUseEnglish() = binding.apply {
|
||||
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settingsUseEnglish.isChecked = config.useEnglish
|
||||
settingsUseEnglishHolder.setOnClickListener {
|
||||
settingsUseEnglish.toggle()
|
||||
config.useEnglish = settingsUseEnglish.isChecked
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLanguage() {
|
||||
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
private fun setupLanguage() = binding.apply {
|
||||
settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
|
||||
listOf(binding.settingsGeneralSettingsHolder, binding.settingsGeneralSettingsLabel).forEach {
|
||||
it.beGoneIf(binding.settingsUseEnglishHolder.isGone() && binding.settingsPurchaseThankYouHolder.isGone() && binding.settingsLanguageHolder.isGone())
|
||||
listOf(settingsGeneralSettingsHolder, settingsGeneralSettingsLabel).forEach {
|
||||
it.beGoneIf(settingsUseEnglishHolder.isGone() && settingsPurchaseThankYouHolder.isGone() && settingsLanguageHolder.isGone())
|
||||
}
|
||||
|
||||
binding.settingsLanguageHolder.setOnClickListener {
|
||||
settingsLanguageHolder.setOnClickListener {
|
||||
launchChangeAppLanguageIntent()
|
||||
}
|
||||
}
|
||||
|
@ -134,41 +138,41 @@ class SettingsActivity : SimpleActivity() {
|
|||
return humanized.substringAfterLast("/", humanized)
|
||||
}
|
||||
|
||||
private fun setupSound() {
|
||||
binding.settingsSound.isChecked = config.isSoundEnabled
|
||||
binding.settingsSoundHolder.setOnClickListener {
|
||||
binding.settingsSound.toggle()
|
||||
config.isSoundEnabled = binding.settingsSound.isChecked
|
||||
private fun setupSound() = binding.apply {
|
||||
settingsSound.isChecked = config.isSoundEnabled
|
||||
settingsSoundHolder.setOnClickListener {
|
||||
settingsSound.toggle()
|
||||
config.isSoundEnabled = settingsSound.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupVolumeButtonsAsShutter() {
|
||||
binding.settingsVolumeButtonsAsShutter.isChecked = config.volumeButtonsAsShutter
|
||||
binding.settingsVolumeButtonsAsShutterHolder.setOnClickListener {
|
||||
binding.settingsVolumeButtonsAsShutter.toggle()
|
||||
config.volumeButtonsAsShutter = binding.settingsVolumeButtonsAsShutter.isChecked
|
||||
private fun setupVolumeButtonsAsShutter() = binding.apply {
|
||||
settingsVolumeButtonsAsShutter.isChecked = config.volumeButtonsAsShutter
|
||||
settingsVolumeButtonsAsShutterHolder.setOnClickListener {
|
||||
settingsVolumeButtonsAsShutter.toggle()
|
||||
config.volumeButtonsAsShutter = settingsVolumeButtonsAsShutter.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFlipPhotos() {
|
||||
binding.settingsFlipPhotos.isChecked = config.flipPhotos
|
||||
binding.settingsFlipPhotosHolder.setOnClickListener {
|
||||
binding.settingsFlipPhotos.toggle()
|
||||
config.flipPhotos = binding.settingsFlipPhotos.isChecked
|
||||
private fun setupFlipPhotos() = binding.apply {
|
||||
settingsFlipPhotos.isChecked = config.flipPhotos
|
||||
settingsFlipPhotosHolder.setOnClickListener {
|
||||
settingsFlipPhotos.toggle()
|
||||
config.flipPhotos = settingsFlipPhotos.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSavePhotoMetadata() {
|
||||
binding.settingsSavePhotoMetadata.isChecked = config.savePhotoMetadata
|
||||
binding.settingsSavePhotoMetadataHolder.setOnClickListener {
|
||||
binding.settingsSavePhotoMetadata.toggle()
|
||||
config.savePhotoMetadata = binding.settingsSavePhotoMetadata.isChecked
|
||||
private fun setupSavePhotoMetadata() = binding.apply {
|
||||
settingsSavePhotoMetadata.isChecked = config.savePhotoMetadata
|
||||
settingsSavePhotoMetadataHolder.setOnClickListener {
|
||||
settingsSavePhotoMetadata.toggle()
|
||||
config.savePhotoMetadata = settingsSavePhotoMetadata.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSavePhotoVideoLocation() {
|
||||
binding.settingsSavePhotoVideoLocation.isChecked = config.savePhotoVideoLocation
|
||||
binding.settingsSavePhotoVideoLocationHolder.setOnClickListener {
|
||||
private fun setupSavePhotoVideoLocation() = binding.apply {
|
||||
settingsSavePhotoVideoLocation.isChecked = config.savePhotoVideoLocation
|
||||
settingsSavePhotoVideoLocationHolder.setOnClickListener {
|
||||
val willEnableSavePhotoVideoLocation = !config.savePhotoVideoLocation
|
||||
|
||||
if (willEnableSavePhotoVideoLocation) {
|
||||
|
@ -194,22 +198,22 @@ class SettingsActivity : SimpleActivity() {
|
|||
config.savePhotoVideoLocation = enabled
|
||||
}
|
||||
|
||||
private fun setupSavePhotosFolder() {
|
||||
binding.settingsSavePhotosLabel.text = addLockedLabelIfNeeded(R.string.save_photos)
|
||||
binding.settingsSavePhotos.text = getLastPart(config.savePhotosFolder)
|
||||
binding.settingsSavePhotosHolder.setOnClickListener {
|
||||
private fun setupSavePhotosFolder() = binding.apply {
|
||||
settingsSavePhotosLabel.text = addLockedLabelIfNeeded(R.string.save_photos)
|
||||
settingsSavePhotos.text = getLastPart(config.savePhotosFolder)
|
||||
settingsSavePhotosHolder.setOnClickListener {
|
||||
if (isOrWasThankYouInstalled()) {
|
||||
FilePickerDialog(this, config.savePhotosFolder, false, showFAB = true) {
|
||||
FilePickerDialog(this@SettingsActivity, config.savePhotosFolder, false, showFAB = true) {
|
||||
val path = it
|
||||
handleSAFDialog(it) { success ->
|
||||
if (success) {
|
||||
config.savePhotosFolder = path
|
||||
binding.settingsSavePhotos.text = getLastPart(config.savePhotosFolder)
|
||||
settingsSavePhotos.text = getLastPart(config.savePhotosFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FeatureLockedDialog(this) { }
|
||||
FeatureLockedDialog(this@SettingsActivity) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue