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