mirror of
				https://github.com/SimpleMobileTools/Simple-Camera.git
				synced 2025-06-27 09:02:59 +02:00 
			
		
		
		
	replace kotlin synthetic usages with viewbinding
This commit is contained in:
		| @@ -25,6 +25,7 @@ import com.google.android.material.button.MaterialButtonToggleGroup | |||||||
| import com.google.android.material.tabs.TabLayout | import com.google.android.material.tabs.TabLayout | ||||||
| import com.simplemobiletools.camera.BuildConfig | import com.simplemobiletools.camera.BuildConfig | ||||||
| import com.simplemobiletools.camera.R | import com.simplemobiletools.camera.R | ||||||
|  | import com.simplemobiletools.camera.databinding.ActivityMainBinding | ||||||
| import com.simplemobiletools.camera.extensions.config | import com.simplemobiletools.camera.extensions.config | ||||||
| import com.simplemobiletools.camera.extensions.fadeIn | import com.simplemobiletools.camera.extensions.fadeIn | ||||||
| import com.simplemobiletools.camera.extensions.fadeOut | import com.simplemobiletools.camera.extensions.fadeOut | ||||||
| @@ -40,10 +41,6 @@ import com.simplemobiletools.camera.views.FocusCircleView | |||||||
| import com.simplemobiletools.commons.extensions.* | import com.simplemobiletools.commons.extensions.* | ||||||
| import com.simplemobiletools.commons.helpers.* | import com.simplemobiletools.commons.helpers.* | ||||||
| import com.simplemobiletools.commons.models.Release | import com.simplemobiletools.commons.models.Release | ||||||
| import kotlinx.android.synthetic.main.activity_main.* |  | ||||||
| import kotlinx.android.synthetic.main.layout_flash.* |  | ||||||
| import kotlinx.android.synthetic.main.layout_timer.* |  | ||||||
| import kotlinx.android.synthetic.main.layout_top.* |  | ||||||
| import java.util.concurrent.TimeUnit | import java.util.concurrent.TimeUnit | ||||||
| import kotlin.math.abs | import kotlin.math.abs | ||||||
|  |  | ||||||
| @@ -62,6 +59,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     private lateinit var mOrientationEventListener: OrientationEventListener |     private lateinit var mOrientationEventListener: OrientationEventListener | ||||||
|     private lateinit var mFocusCircleView: FocusCircleView |     private lateinit var mFocusCircleView: FocusCircleView | ||||||
|     private lateinit var mediaSoundHelper: MediaSoundHelper |     private lateinit var mediaSoundHelper: MediaSoundHelper | ||||||
|  |     private lateinit var binding: ActivityMainBinding | ||||||
|     private var mPreview: MyPreview? = null |     private var mPreview: MyPreview? = null | ||||||
|     private var mediaSizeToggleGroup: MaterialButtonToggleGroup? = null |     private var mediaSizeToggleGroup: MaterialButtonToggleGroup? = null | ||||||
|     private var mPreviewUri: Uri? = null |     private var mPreviewUri: Uri? = null | ||||||
| @@ -92,6 +90,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         useDynamicTheme = false |         useDynamicTheme = false | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|  |         binding = ActivityMainBinding.inflate(layoutInflater) | ||||||
|         appLaunched(BuildConfig.APPLICATION_ID) |         appLaunched(BuildConfig.APPLICATION_ID) | ||||||
|         requestWindowFeature(Window.FEATURE_NO_TITLE) |         requestWindowFeature(Window.FEATURE_NO_TITLE) | ||||||
|         initVariables() |         initVariables() | ||||||
| @@ -166,7 +165,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|             removeTabListener() |             removeTabListener() | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         camera_mode_tab.getTabAt(PHOTO_MODE_INDEX)?.select() |         binding.cameraModeTab.getTabAt(PHOTO_MODE_INDEX)?.select() | ||||||
|         setTabListener() |         setTabListener() | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -174,16 +173,16 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|         if (!triggerListener) { |         if (!triggerListener) { | ||||||
|             removeTabListener() |             removeTabListener() | ||||||
|         } |         } | ||||||
|         camera_mode_tab.getTabAt(VIDEO_MODE_INDEX)?.select() |         binding.cameraModeTab.getTabAt(VIDEO_MODE_INDEX)?.select() | ||||||
|         setTabListener() |         setTabListener() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setTabListener() { |     private fun setTabListener() { | ||||||
|         camera_mode_tab.addOnTabSelectedListener(tabSelectedListener) |         binding.cameraModeTab.addOnTabSelectedListener(tabSelectedListener) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun removeTabListener() { |     private fun removeTabListener() { | ||||||
|         camera_mode_tab.removeOnTabSelectedListener(tabSelectedListener) |         binding.cameraModeTab.removeOnTabSelectedListener(tabSelectedListener) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun ensureTransparentNavigationBar() { |     private fun ensureTransparentNavigationBar() { | ||||||
| @@ -218,9 +217,9 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun hideIntentButtons() { |     private fun hideIntentButtons() { | ||||||
|         camera_mode_holder.beGone() |         binding.cameraModeHolder.beGone() | ||||||
|         settings.beGone() |         binding.layoutTop.settings.beGone() | ||||||
|         last_photo_video_preview.beInvisible() |         binding.lastPhotoVideoPreview.beInvisible() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun tryInitCamera() { |     private fun tryInitCamera() { | ||||||
| @@ -297,25 +296,25 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun initializeCamera(isInPhotoMode: Boolean) { |     private fun initializeCamera(isInPhotoMode: Boolean) { | ||||||
|         setContentView(R.layout.activity_main) |         setContentView(binding.root) | ||||||
|         initButtons() |         initButtons() | ||||||
|         initModeSwitcher() |         initModeSwitcher() | ||||||
|         defaultScene = Scene(top_options, default_icons) |         defaultScene = Scene(binding.topOptions, binding.layoutTop.defaultIcons) | ||||||
|         flashModeScene = Scene(top_options, flash_toggle_group) |         flashModeScene = Scene(binding.topOptions, binding.layoutFlash.flashToggleGroup) | ||||||
|         timerScene = Scene(top_options, timer_toggle_group) |         timerScene = Scene(binding.topOptions, binding.layoutTimer.timerToggleGroup) | ||||||
|  |  | ||||||
|         WindowCompat.setDecorFitsSystemWindows(window, false) |         WindowCompat.setDecorFitsSystemWindows(window, false) | ||||||
|         ViewCompat.setOnApplyWindowInsetsListener(view_holder) { _, windowInsets -> |         ViewCompat.setOnApplyWindowInsetsListener(binding.viewHolder) { _, windowInsets -> | ||||||
|             val safeInsetBottom = windowInsets.displayCutout?.safeInsetBottom ?: 0 |             val safeInsetBottom = windowInsets.displayCutout?.safeInsetBottom ?: 0 | ||||||
|             val safeInsetTop = windowInsets.displayCutout?.safeInsetTop ?: 0 |             val safeInsetTop = windowInsets.displayCutout?.safeInsetTop ?: 0 | ||||||
|  |  | ||||||
|             top_options.updateLayoutParams<ViewGroup.MarginLayoutParams> { |             binding.topOptions.updateLayoutParams<ViewGroup.MarginLayoutParams> { | ||||||
|                 topMargin = safeInsetTop |                 topMargin = safeInsetTop | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             val marginBottom = safeInsetBottom + navigationBarHeight + resources.getDimensionPixelSize(R.dimen.bigger_margin) |             val marginBottom = safeInsetBottom + navigationBarHeight + resources.getDimensionPixelSize(R.dimen.bigger_margin) | ||||||
|  |  | ||||||
|             shutter.updateLayoutParams<ViewGroup.MarginLayoutParams> { |             binding.shutter.updateLayoutParams<ViewGroup.MarginLayoutParams> { | ||||||
|                 bottomMargin = marginBottom |                 bottomMargin = marginBottom | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -331,7 +330,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|         val outputUri = intent.extras?.get(MediaStore.EXTRA_OUTPUT) as? Uri |         val outputUri = intent.extras?.get(MediaStore.EXTRA_OUTPUT) as? Uri | ||||||
|         val isThirdPartyIntent = isThirdPartyIntent() |         val isThirdPartyIntent = isThirdPartyIntent() | ||||||
|         mPreview = CameraXInitializer(this).createCameraXPreview( |         mPreview = CameraXInitializer(this).createCameraXPreview( | ||||||
|             preview_view, |             binding.previewView, | ||||||
|             listener = this, |             listener = this, | ||||||
|             mediaSoundHelper = mediaSoundHelper, |             mediaSoundHelper = mediaSoundHelper, | ||||||
|             outputUri = outputUri, |             outputUri = outputUri, | ||||||
| @@ -342,7 +341,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|         mFocusCircleView = FocusCircleView(this).apply { |         mFocusCircleView = FocusCircleView(this).apply { | ||||||
|             id = View.generateViewId() |             id = View.generateViewId() | ||||||
|         } |         } | ||||||
|         view_holder.addView(mFocusCircleView) |         binding.viewHolder.addView(mFocusCircleView) | ||||||
|  |  | ||||||
|         setupPreviewImage(true) |         setupPreviewImage(true) | ||||||
|         initFlashModeTransitionNames() |         initFlashModeTransitionNames() | ||||||
| @@ -355,62 +354,62 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     private fun initFlashModeTransitionNames() { |     private fun initFlashModeTransitionNames() { | ||||||
|         val baseName = getString(R.string.toggle_flash) |         val baseName = getString(R.string.toggle_flash) | ||||||
|         flash_auto.transitionName = "$baseName$FLASH_AUTO" |         binding.layoutFlash.flashAuto.transitionName = "$baseName$FLASH_AUTO" | ||||||
|         flash_off.transitionName = "$baseName$FLASH_OFF" |         binding.layoutFlash.flashOff.transitionName = "$baseName$FLASH_OFF" | ||||||
|         flash_on.transitionName = "$baseName$FLASH_ON" |         binding.layoutFlash.flashOn.transitionName = "$baseName$FLASH_ON" | ||||||
|         flash_always_on.transitionName = "$baseName$FLASH_ALWAYS_ON" |         binding.layoutFlash.flashAlwaysOn.transitionName = "$baseName$FLASH_ALWAYS_ON" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun initTimerModeTransitionNames() { |     private fun initTimerModeTransitionNames() { | ||||||
|         val baseName = getString(R.string.toggle_timer) |         val baseName = getString(R.string.toggle_timer) | ||||||
|         timer_off.transitionName = "$baseName${TimerMode.OFF.name}" |         binding.layoutTimer.timerOff.transitionName = "$baseName${TimerMode.OFF.name}" | ||||||
|         timer_3s.transitionName = "$baseName${TimerMode.TIMER_3.name}" |         binding.layoutTimer.timer3s.transitionName = "$baseName${TimerMode.TIMER_3.name}" | ||||||
|         timer_5s.transitionName = "$baseName${TimerMode.TIMER_5.name}" |         binding.layoutTimer.timer5s.transitionName = "$baseName${TimerMode.TIMER_5.name}" | ||||||
|         timer_10_s.transitionName = "$baseName${TimerMode.TIMER_10.name}" |         binding.layoutTimer.timer10S.transitionName = "$baseName${TimerMode.TIMER_10.name}" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun initButtons() { |     private fun initButtons() { | ||||||
|         timer_text.setFactory { layoutInflater.inflate(R.layout.timer_text, null) } |         binding.timerText.setFactory { layoutInflater.inflate(R.layout.timer_text, null) } | ||||||
|         toggle_camera.setOnClickListener { mPreview!!.toggleFrontBackCamera() } |         binding.toggleCamera.setOnClickListener { mPreview!!.toggleFrontBackCamera() } | ||||||
|         last_photo_video_preview.setOnClickListener { showLastMediaPreview() } |         binding.lastPhotoVideoPreview.setOnClickListener { showLastMediaPreview() } | ||||||
|         toggle_flash.setOnClickListener { mPreview!!.handleFlashlightClick() } |         binding.layoutTop.toggleFlash.setOnClickListener { mPreview!!.handleFlashlightClick() } | ||||||
|         toggle_timer.setOnClickListener { |         binding.layoutTop.toggleTimer.setOnClickListener { | ||||||
|             val transitionSet = createTransition() |             val transitionSet = createTransition() | ||||||
|             TransitionManager.go(timerScene, transitionSet) |             TransitionManager.go(timerScene, transitionSet) | ||||||
|             timer_toggle_group.beVisible() |             binding.layoutTimer.timerToggleGroup.beVisible() | ||||||
|             timer_toggle_group.check(config.timerMode.getTimerModeResId()) |             binding.layoutTimer.timerToggleGroup.check(config.timerMode.getTimerModeResId()) | ||||||
|             timer_toggle_group.children.forEach { setButtonColors(it as MaterialButton) } |             binding.layoutTimer.timerToggleGroup.children.forEach { setButtonColors(it as MaterialButton) } | ||||||
|         } |         } | ||||||
|         shutter.setOnClickListener { shutterPressed() } |         binding.shutter.setOnClickListener { shutterPressed() } | ||||||
|  |  | ||||||
|         settings.setShadowIcon(R.drawable.ic_settings_vector) |         binding.layoutTop.settings.setShadowIcon(R.drawable.ic_settings_vector) | ||||||
|         settings.setOnClickListener { launchSettings() } |         binding.layoutTop.settings.setOnClickListener { launchSettings() } | ||||||
|  |  | ||||||
|         change_resolution.setOnClickListener { mPreview?.showChangeResolution() } |         binding.layoutTop.changeResolution.setOnClickListener { mPreview?.showChangeResolution() } | ||||||
|  |  | ||||||
|         flash_on.setShadowIcon(R.drawable.ic_flash_on_vector) |         binding.layoutFlash.flashOn.setShadowIcon(R.drawable.ic_flash_on_vector) | ||||||
|         flash_on.setOnClickListener { selectFlashMode(FLASH_ON) } |         binding.layoutFlash.flashOn.setOnClickListener { selectFlashMode(FLASH_ON) } | ||||||
|  |  | ||||||
|         flash_off.setShadowIcon(R.drawable.ic_flash_off_vector) |         binding.layoutFlash.flashOff.setShadowIcon(R.drawable.ic_flash_off_vector) | ||||||
|         flash_off.setOnClickListener { selectFlashMode(FLASH_OFF) } |         binding.layoutFlash.flashOff.setOnClickListener { selectFlashMode(FLASH_OFF) } | ||||||
|  |  | ||||||
|         flash_auto.setShadowIcon(R.drawable.ic_flash_auto_vector) |         binding.layoutFlash.flashAuto.setShadowIcon(R.drawable.ic_flash_auto_vector) | ||||||
|         flash_auto.setOnClickListener { selectFlashMode(FLASH_AUTO) } |         binding.layoutFlash.flashAuto.setOnClickListener { selectFlashMode(FLASH_AUTO) } | ||||||
|  |  | ||||||
|         flash_always_on.setShadowIcon(R.drawable.ic_flashlight_vector) |         binding.layoutFlash.flashAlwaysOn.setShadowIcon(R.drawable.ic_flashlight_vector) | ||||||
|         flash_always_on.setOnClickListener { selectFlashMode(FLASH_ALWAYS_ON) } |         binding.layoutFlash.flashAlwaysOn.setOnClickListener { selectFlashMode(FLASH_ALWAYS_ON) } | ||||||
|  |  | ||||||
|         timer_off.setShadowIcon(R.drawable.ic_timer_off_vector) |         binding.layoutTimer.timerOff.setShadowIcon(R.drawable.ic_timer_off_vector) | ||||||
|         timer_off.setOnClickListener { selectTimerMode(TimerMode.OFF) } |         binding.layoutTimer.timerOff.setOnClickListener { selectTimerMode(TimerMode.OFF) } | ||||||
|  |  | ||||||
|         timer_3s.setShadowIcon(R.drawable.ic_timer_3_vector) |         binding.layoutTimer.timer3s.setShadowIcon(R.drawable.ic_timer_3_vector) | ||||||
|         timer_3s.setOnClickListener { selectTimerMode(TimerMode.TIMER_3) } |         binding.layoutTimer.timer3s.setOnClickListener { selectTimerMode(TimerMode.TIMER_3) } | ||||||
|  |  | ||||||
|         timer_5s.setShadowIcon(R.drawable.ic_timer_5_vector) |         binding.layoutTimer.timer5s.setShadowIcon(R.drawable.ic_timer_5_vector) | ||||||
|         timer_5s.setOnClickListener { selectTimerMode(TimerMode.TIMER_5) } |         binding.layoutTimer.timer5s.setOnClickListener { selectTimerMode(TimerMode.TIMER_5) } | ||||||
|  |  | ||||||
|         timer_10_s.setShadowIcon(R.drawable.ic_timer_10_vector) |         binding.layoutTimer.timer10S.setShadowIcon(R.drawable.ic_timer_10_vector) | ||||||
|         timer_10_s.setOnClickListener { selectTimerMode(TimerMode.TIMER_10) } |         binding.layoutTimer.timer10S.setOnClickListener { selectTimerMode(TimerMode.TIMER_10) } | ||||||
|         setTimerModeIcon(config.timerMode) |         setTimerModeIcon(config.timerMode) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -421,8 +420,8 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setTimerModeIcon(timerMode: TimerMode) { |     private fun setTimerModeIcon(timerMode: TimerMode) { | ||||||
|         toggle_timer.setShadowIcon(timerMode.getTimerModeDrawableRes()) |         binding.layoutTop.toggleTimer.setShadowIcon(timerMode.getTimerModeDrawableRes()) | ||||||
|         toggle_timer.transitionName = "${getString(R.string.toggle_timer)}${timerMode.name}" |         binding.layoutTop.toggleTimer.transitionName = "${getString(R.string.toggle_timer)}${timerMode.name}" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressLint("ClickableViewAccessibility") |     @SuppressLint("ClickableViewAccessibility") | ||||||
| @@ -453,19 +452,19 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|             } |             } | ||||||
|         }) |         }) | ||||||
|  |  | ||||||
|         camera_mode_tab.setOnTouchListener { _, event -> |         binding.cameraModeTab.setOnTouchListener { _, event -> | ||||||
|             gestureDetector.onTouchEvent(event) |             gestureDetector.onTouchEvent(event) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun onSwipeLeft() { |     private fun onSwipeLeft() { | ||||||
|         if (!isThirdPartyIntent() && camera_mode_holder.isVisible()) { |         if (!isThirdPartyIntent() && binding.cameraModeHolder.isVisible()) { | ||||||
|             selectPhotoTab(triggerListener = true) |             selectPhotoTab(triggerListener = true) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun onSwipeRight() { |     private fun onSwipeRight() { | ||||||
|         if (!isThirdPartyIntent() && camera_mode_holder.isVisible()) { |         if (!isThirdPartyIntent() && binding.cameraModeHolder.isVisible()) { | ||||||
|             selectVideoTab(triggerListener = true) |             selectVideoTab(triggerListener = true) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -511,17 +510,17 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onInitPhotoMode() { |     override fun onInitPhotoMode() { | ||||||
|         shutter.setImageResource(R.drawable.ic_shutter_animated) |         binding.shutter.setImageResource(R.drawable.ic_shutter_animated) | ||||||
|         toggle_timer.beVisible() |         binding.layoutTop.toggleTimer.beVisible() | ||||||
|         toggle_timer.fadeIn() |         binding.layoutTop.toggleTimer.fadeIn() | ||||||
|         setupPreviewImage(true) |         setupPreviewImage(true) | ||||||
|         selectPhotoTab() |         selectPhotoTab() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onInitVideoMode() { |     override fun onInitVideoMode() { | ||||||
|         shutter.setImageResource(R.drawable.ic_video_rec_animated) |         binding.shutter.setImageResource(R.drawable.ic_video_rec_animated) | ||||||
|         toggle_timer.fadeOut() |         binding.layoutTop.toggleTimer.fadeOut() | ||||||
|         toggle_timer.beGone() |         binding.layoutTop.toggleTimer.beGone() | ||||||
|         setupPreviewImage(false) |         setupPreviewImage(false) | ||||||
|         selectVideoTab() |         selectVideoTab() | ||||||
|     } |     } | ||||||
| @@ -550,7 +549,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|                     .load(uri) |                     .load(uri) | ||||||
|                     .apply(options) |                     .apply(options) | ||||||
|                     .transition(DrawableTransitionOptions.withCrossFade()) |                     .transition(DrawableTransitionOptions.withCrossFade()) | ||||||
|                     .into(last_photo_video_preview) |                     .into(binding.lastPhotoVideoPreview) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -604,7 +603,14 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun animateViews(degrees: Int) { |     private fun animateViews(degrees: Int) { | ||||||
|         val views = arrayOf<View>(toggle_camera, toggle_flash, change_resolution, shutter, settings, last_photo_video_preview) |         val views = arrayOf<View>( | ||||||
|  |             binding.toggleCamera, | ||||||
|  |             binding.layoutTop.toggleFlash, | ||||||
|  |             binding.layoutTop.changeResolution, | ||||||
|  |             binding.shutter, | ||||||
|  |             binding.layoutTop.settings, | ||||||
|  |             binding.lastPhotoVideoPreview | ||||||
|  |         ) | ||||||
|         for (view in views) { |         for (view in views) { | ||||||
|             rotate(view, degrees) |             rotate(view, degrees) | ||||||
|         } |         } | ||||||
| @@ -613,20 +619,20 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     private fun rotate(view: View, degrees: Int) = view.animate().rotation(degrees.toFloat()).start() |     private fun rotate(view: View, degrees: Int) = view.animate().rotation(degrees.toFloat()).start() | ||||||
|  |  | ||||||
|     override fun setHasFrontAndBackCamera(hasFrontAndBack: Boolean) { |     override fun setHasFrontAndBackCamera(hasFrontAndBack: Boolean) { | ||||||
|         toggle_camera?.beVisibleIf(hasFrontAndBack) |         binding.toggleCamera?.beVisibleIf(hasFrontAndBack) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun setFlashAvailable(available: Boolean) { |     override fun setFlashAvailable(available: Boolean) { | ||||||
|         if (available) { |         if (available) { | ||||||
|             toggle_flash.beVisible() |             binding.layoutTop.toggleFlash.beVisible() | ||||||
|         } else { |         } else { | ||||||
|             toggle_flash.beGone() |             binding.layoutTop.toggleFlash.beGone() | ||||||
|             mPreview?.setFlashlightState(FLASH_OFF) |             mPreview?.setFlashlightState(FLASH_OFF) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onChangeCamera(frontCamera: Boolean) { |     override fun onChangeCamera(frontCamera: Boolean) { | ||||||
|         toggle_camera.setImageResource(if (frontCamera) R.drawable.ic_camera_rear_vector else R.drawable.ic_camera_front_vector) |         binding.toggleCamera.setImageResource(if (frontCamera) R.drawable.ic_camera_rear_vector else R.drawable.ic_camera_front_vector) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onPhotoCaptureStart() { |     override fun onPhotoCaptureStart() { | ||||||
| @@ -639,21 +645,21 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     private fun toggleActionButtons(enabled: Boolean) { |     private fun toggleActionButtons(enabled: Boolean) { | ||||||
|         runOnUiThread { |         runOnUiThread { | ||||||
|             shutter.isClickable = enabled |             binding.shutter.isClickable = enabled | ||||||
|             preview_view.isEnabled = enabled |             binding.previewView.isEnabled = enabled | ||||||
|             change_resolution.isEnabled = enabled |             binding.layoutTop.changeResolution.isEnabled = enabled | ||||||
|             toggle_camera.isClickable = enabled |             binding.toggleCamera.isClickable = enabled | ||||||
|             toggle_flash.isClickable = enabled |             binding.layoutTop.toggleFlash.isClickable = enabled | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun shutterAnimation() { |     override fun shutterAnimation() { | ||||||
|         shutter_animation.alpha = 1.0f |         binding.shutterAnimation.alpha = 1.0f | ||||||
|         shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start() |         binding.shutterAnimation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onMediaSaved(uri: Uri) { |     override fun onMediaSaved(uri: Uri) { | ||||||
|         change_resolution.isEnabled = true |         binding.layoutTop.changeResolution.isEnabled = true | ||||||
|         loadLastTakenMedia(uri) |         loadLastTakenMedia(uri) | ||||||
|         if (isImageCaptureIntent()) { |         if (isImageCaptureIntent()) { | ||||||
|             Intent().apply { |             Intent().apply { | ||||||
| @@ -689,43 +695,43 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|             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 | ||||||
|         } |         } | ||||||
|         toggle_flash.setShadowIcon(flashDrawable) |         binding.layoutTop.toggleFlash.setShadowIcon(flashDrawable) | ||||||
|         toggle_flash.transitionName = "${getString(R.string.toggle_flash)}$flashMode" |         binding.layoutTop.toggleFlash.transitionName = "${getString(R.string.toggle_flash)}$flashMode" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onVideoRecordingStarted() { |     override fun onVideoRecordingStarted() { | ||||||
|         camera_mode_holder.beInvisible() |         binding.cameraModeHolder.beInvisible() | ||||||
|         video_rec_curr_timer.beVisible() |         binding.videoRecCurrTimer.beVisible() | ||||||
|  |  | ||||||
|         toggle_camera.fadeOut() |         binding.toggleCamera.fadeOut() | ||||||
|         last_photo_video_preview.fadeOut() |         binding.lastPhotoVideoPreview.fadeOut() | ||||||
|  |  | ||||||
|         change_resolution.isEnabled = false |         binding.layoutTop.changeResolution.isEnabled = false | ||||||
|         settings.isEnabled = false |         binding.layoutTop.settings.isEnabled = false | ||||||
|         shutter.post { |         binding.shutter.post { | ||||||
|             if (!isDestroyed) { |             if (!isDestroyed) { | ||||||
|                 shutter.isSelected = true |                 binding.shutter.isSelected = true | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onVideoRecordingStopped() { |     override fun onVideoRecordingStopped() { | ||||||
|         camera_mode_holder.beVisible() |         binding.cameraModeHolder.beVisible() | ||||||
|  |  | ||||||
|         toggle_camera.fadeIn() |         binding.toggleCamera.fadeIn() | ||||||
|         last_photo_video_preview.fadeIn() |         binding.lastPhotoVideoPreview.fadeIn() | ||||||
|  |  | ||||||
|         video_rec_curr_timer.text = 0.getFormattedDuration() |         binding.videoRecCurrTimer.text = 0.getFormattedDuration() | ||||||
|         video_rec_curr_timer.beGone() |         binding.videoRecCurrTimer.beGone() | ||||||
|  |  | ||||||
|         shutter.isSelected = false |         binding.shutter.isSelected = false | ||||||
|         change_resolution.isEnabled = true |         binding.layoutTop.changeResolution.isEnabled = true | ||||||
|         settings.isEnabled = true |         binding.layoutTop.settings.isEnabled = true | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onVideoDurationChanged(durationNanos: Long) { |     override fun onVideoDurationChanged(durationNanos: Long) { | ||||||
|         val seconds = TimeUnit.NANOSECONDS.toSeconds(durationNanos).toInt() |         val seconds = TimeUnit.NANOSECONDS.toSeconds(durationNanos).toInt() | ||||||
|         video_rec_curr_timer.text = seconds.getFormattedDuration() |         binding.videoRecCurrTimer.text = seconds.getFormattedDuration() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onFocusCamera(xPos: Float, yPos: Float) { |     override fun onFocusCamera(xPos: Float, yPos: Float) { | ||||||
| @@ -738,14 +744,14 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     private fun closeOptions(): Boolean { |     private fun closeOptions(): Boolean { | ||||||
|         if (mediaSizeToggleGroup?.isVisible() == true || |         if (mediaSizeToggleGroup?.isVisible() == true || | ||||||
|             flash_toggle_group.isVisible() || timer_toggle_group.isVisible() |             binding.layoutFlash.flashToggleGroup.isVisible() || binding.layoutTimer.timerToggleGroup.isVisible() | ||||||
|         ) { |         ) { | ||||||
|             val transitionSet = createTransition() |             val transitionSet = createTransition() | ||||||
|             TransitionManager.go(defaultScene, transitionSet) |             TransitionManager.go(defaultScene, transitionSet) | ||||||
|             mediaSizeToggleGroup?.beGone() |             mediaSizeToggleGroup?.beGone() | ||||||
|             flash_toggle_group.beGone() |             binding.layoutFlash.flashToggleGroup.beGone() | ||||||
|             timer_toggle_group.beGone() |             binding.layoutTimer.timerToggleGroup.beGone() | ||||||
|             default_icons.beVisible() |             binding.layoutTop.defaultIcons.beVisible() | ||||||
|             return true |             return true | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -754,8 +760,8 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     override fun displaySelectedResolution(resolutionOption: ResolutionOption) { |     override fun displaySelectedResolution(resolutionOption: ResolutionOption) { | ||||||
|         val imageRes = resolutionOption.imageDrawableResId |         val imageRes = resolutionOption.imageDrawableResId | ||||||
|         change_resolution.setShadowIcon(imageRes) |         binding.layoutTop.changeResolution.setShadowIcon(imageRes) | ||||||
|         change_resolution.transitionName = "${resolutionOption.buttonViewId}" |         binding.layoutTop.changeResolution.transitionName = "${resolutionOption.buttonViewId}" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun showImageSizes( |     override fun showImageSizes( | ||||||
| @@ -765,12 +771,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|         isFrontCamera: Boolean, |         isFrontCamera: Boolean, | ||||||
|         onSelect: (index: Int, changed: Boolean) -> Unit |         onSelect: (index: Int, changed: Boolean) -> Unit | ||||||
|     ) { |     ) { | ||||||
|         top_options.removeView(mediaSizeToggleGroup) |         binding.topOptions.removeView(mediaSizeToggleGroup) | ||||||
|         val mediaSizeToggleGroup = createToggleGroup().apply { |         val mediaSizeToggleGroup = createToggleGroup().apply { | ||||||
|             mediaSizeToggleGroup = this |             mediaSizeToggleGroup = this | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         top_options.addView(mediaSizeToggleGroup) |         binding.topOptions.addView(mediaSizeToggleGroup) | ||||||
|  |  | ||||||
|         val onItemClick = { clickedViewId: Int -> |         val onItemClick = { clickedViewId: Int -> | ||||||
|             closeOptions() |             closeOptions() | ||||||
| @@ -786,9 +792,9 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|         mediaSizeToggleGroup.check(selectedResolution.buttonViewId) |         mediaSizeToggleGroup.check(selectedResolution.buttonViewId) | ||||||
|  |  | ||||||
|         val transitionSet = createTransition() |         val transitionSet = createTransition() | ||||||
|         val mediaSizeScene = Scene(top_options, mediaSizeToggleGroup) |         val mediaSizeScene = Scene(binding.topOptions, mediaSizeToggleGroup) | ||||||
|         TransitionManager.go(mediaSizeScene, transitionSet) |         TransitionManager.go(mediaSizeScene, transitionSet) | ||||||
|         default_icons.beGone() |         binding.layoutTop.defaultIcons.beGone() | ||||||
|         mediaSizeToggleGroup.beVisible() |         mediaSizeToggleGroup.beVisible() | ||||||
|         mediaSizeToggleGroup.children.map { it as MaterialButton }.forEach(::setButtonColors) |         mediaSizeToggleGroup.children.map { it as MaterialButton }.forEach(::setButtonColors) | ||||||
|     } |     } | ||||||
| @@ -820,12 +826,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     override fun showFlashOptions(photoCapture: Boolean) { |     override fun showFlashOptions(photoCapture: Boolean) { | ||||||
|         val transitionSet = createTransition() |         val transitionSet = createTransition() | ||||||
|         TransitionManager.go(flashModeScene, transitionSet) |         TransitionManager.go(flashModeScene, transitionSet) | ||||||
|         flash_auto.beVisibleIf(photoCapture) |         binding.layoutFlash.flashAuto.beVisibleIf(photoCapture) | ||||||
|         flash_always_on.beVisibleIf(photoCapture) |         binding.layoutFlash.flashAlwaysOn.beVisibleIf(photoCapture) | ||||||
|         flash_toggle_group.check(config.flashlightState.toFlashModeId()) |         binding.layoutFlash.flashToggleGroup.check(config.flashlightState.toFlashModeId()) | ||||||
|  |  | ||||||
|         flash_toggle_group.beVisible() |         binding.layoutFlash.flashToggleGroup.beVisible() | ||||||
|         flash_toggle_group.children.forEach { setButtonColors(it as MaterialButton) } |         binding.layoutFlash.flashToggleGroup.children.forEach { setButtonColors(it as MaterialButton) } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setButtonColors(button: MaterialButton) { |     private fun setButtonColors(button: MaterialButton) { | ||||||
| @@ -837,15 +843,15 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     override fun adjustPreviewView(requiresCentering: Boolean) { |     override fun adjustPreviewView(requiresCentering: Boolean) { | ||||||
|         val constraintSet = ConstraintSet() |         val constraintSet = ConstraintSet() | ||||||
|         constraintSet.clone(view_holder) |         constraintSet.clone(binding.viewHolder) | ||||||
|         if (requiresCentering) { |         if (requiresCentering) { | ||||||
|             constraintSet.connect(preview_view.id, ConstraintSet.TOP, top_options.id, ConstraintSet.BOTTOM) |             constraintSet.connect(binding.previewView.id, ConstraintSet.TOP, binding.topOptions.id, ConstraintSet.BOTTOM) | ||||||
|             constraintSet.connect(preview_view.id, ConstraintSet.BOTTOM, camera_mode_holder.id, ConstraintSet.TOP) |             constraintSet.connect(binding.previewView.id, ConstraintSet.BOTTOM, binding.cameraModeHolder.id, ConstraintSet.TOP) | ||||||
|         } else { |         } else { | ||||||
|             constraintSet.connect(preview_view.id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP) |             constraintSet.connect(binding.previewView.id, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP) | ||||||
|             constraintSet.connect(preview_view.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM) |             constraintSet.connect(binding.previewView.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM) | ||||||
|         } |         } | ||||||
|         constraintSet.applyTo(view_holder) |         constraintSet.applyTo(binding.viewHolder) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun mediaSaved(path: String) { |     override fun mediaSaved(path: String) { | ||||||
| @@ -866,13 +872,13 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|  |  | ||||||
|     private fun scheduleTimer(timerMode: TimerMode) { |     private fun scheduleTimer(timerMode: TimerMode) { | ||||||
|         hideViewsOnTimerStart() |         hideViewsOnTimerStart() | ||||||
|         shutter.setImageState(intArrayOf(R.attr.state_timer_cancel), true) |         binding.shutter.setImageState(intArrayOf(R.attr.state_timer_cancel), true) | ||||||
|         timer_text.beVisible() |         binding.timerText.beVisible() | ||||||
|         var playSound = true |         var playSound = true | ||||||
|         countDownTimer = object : CountDownTimer(timerMode.millisInFuture, 1000) { |         countDownTimer = object : CountDownTimer(timerMode.millisInFuture, 1000) { | ||||||
|             override fun onTick(millisUntilFinished: Long) { |             override fun onTick(millisUntilFinished: Long) { | ||||||
|                 val seconds = (TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + 1).toString() |                 val seconds = (TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) + 1).toString() | ||||||
|                 timer_text.setText(seconds) |                 binding.timerText.setText(seconds) | ||||||
|                 if (playSound && config.isSoundEnabled) { |                 if (playSound && config.isSoundEnabled) { | ||||||
|                     if (millisUntilFinished <= TIMER_2_SECONDS) { |                     if (millisUntilFinished <= TIMER_2_SECONDS) { | ||||||
|                         mediaSoundHelper.playTimerCountdown2SecondsSound() |                         mediaSoundHelper.playTimerCountdown2SecondsSound() | ||||||
| @@ -891,20 +897,20 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun hideViewsOnTimerStart() { |     private fun hideViewsOnTimerStart() { | ||||||
|         arrayOf(top_options, toggle_camera, last_photo_video_preview, camera_mode_holder).forEach { |         arrayOf(binding.topOptions, binding.toggleCamera, binding.lastPhotoVideoPreview, binding.cameraModeHolder).forEach { | ||||||
|             it.fadeOut() |             it.fadeOut() | ||||||
|             it.beInvisible() |             it.beInvisible() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun resetViewsOnTimerFinish() { |     private fun resetViewsOnTimerFinish() { | ||||||
|         arrayOf(top_options, toggle_camera, last_photo_video_preview, camera_mode_holder).forEach { |         arrayOf(binding.topOptions, binding.toggleCamera, binding.lastPhotoVideoPreview, binding.cameraModeHolder).forEach { | ||||||
|             it?.fadeIn() |             it?.fadeIn() | ||||||
|             it?.beVisible() |             it?.beVisible() | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         timer_text.beGone() |         binding.timerText.beGone() | ||||||
|         shutter.setImageState(intArrayOf(-R.attr.state_timer_cancel), true) |         binding.shutter.setImageState(intArrayOf(-R.attr.state_timer_cancel), true) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun checkWhatsNewDialog() { |     private fun checkWhatsNewDialog() { | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ import android.annotation.SuppressLint | |||||||
| import android.os.Bundle | import android.os.Bundle | ||||||
| import com.simplemobiletools.camera.BuildConfig | import com.simplemobiletools.camera.BuildConfig | ||||||
| import com.simplemobiletools.camera.R | import com.simplemobiletools.camera.R | ||||||
|  | import com.simplemobiletools.camera.databinding.ActivitySettingsBinding | ||||||
| import com.simplemobiletools.camera.extensions.checkLocationPermission | import com.simplemobiletools.camera.extensions.checkLocationPermission | ||||||
| import com.simplemobiletools.camera.extensions.config | import com.simplemobiletools.camera.extensions.config | ||||||
| import com.simplemobiletools.camera.models.CaptureMode | import com.simplemobiletools.camera.models.CaptureMode | ||||||
| @@ -12,25 +13,27 @@ import com.simplemobiletools.commons.extensions.* | |||||||
| import com.simplemobiletools.commons.helpers.* | import com.simplemobiletools.commons.helpers.* | ||||||
| import com.simplemobiletools.commons.models.FAQItem | import com.simplemobiletools.commons.models.FAQItem | ||||||
| import com.simplemobiletools.commons.models.RadioItem | import com.simplemobiletools.commons.models.RadioItem | ||||||
| import kotlinx.android.synthetic.main.activity_settings.* |  | ||||||
| import java.util.* | import java.util.* | ||||||
| import kotlin.system.exitProcess | import kotlin.system.exitProcess | ||||||
|  |  | ||||||
| class SettingsActivity : SimpleActivity() { | class SettingsActivity : SimpleActivity() { | ||||||
|  |     private lateinit var binding: ActivitySettingsBinding | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         isMaterialActivity = true |         isMaterialActivity = true | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|         setContentView(R.layout.activity_settings) |         binding = ActivitySettingsBinding.inflate(layoutInflater) | ||||||
|  |         setContentView(binding.root) | ||||||
|         setupOptionsMenu() |         setupOptionsMenu() | ||||||
|         refreshMenuItems() |         refreshMenuItems() | ||||||
|  |  | ||||||
|         updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false) |         updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) | ||||||
|         setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar) |         setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onResume() { |     override fun onResume() { | ||||||
|         super.onResume() |         super.onResume() | ||||||
|         setupToolbar(settings_toolbar, NavigationIcon.Arrow) |         setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow) | ||||||
|  |  | ||||||
|         setupPurchaseThankYou() |         setupPurchaseThankYou() | ||||||
|         setupCustomizeColors() |         setupCustomizeColors() | ||||||
| @@ -44,27 +47,27 @@ class SettingsActivity : SimpleActivity() { | |||||||
|         setupSavePhotosFolder() |         setupSavePhotosFolder() | ||||||
|         setupPhotoQuality() |         setupPhotoQuality() | ||||||
|         setupCaptureMode() |         setupCaptureMode() | ||||||
|         updateTextColors(settings_holder) |         updateTextColors(binding.settingsHolder) | ||||||
|  |  | ||||||
|         val properPrimaryColor = getProperPrimaryColor() |         val properPrimaryColor = getProperPrimaryColor() | ||||||
|         arrayListOf( |         arrayListOf( | ||||||
|             settings_color_customization_label, |             binding.settingsColorCustomizationLabel, | ||||||
|             settings_general_settings_label, |             binding.settingsGeneralSettingsLabel, | ||||||
|             settings_shutter_label, |             binding.settingsShutterLabel, | ||||||
|             settings_saving_label |             binding.settingsSavingLabel, | ||||||
|         ).forEach { |         ).forEach { | ||||||
|             it.setTextColor(properPrimaryColor) |             it.setTextColor(properPrimaryColor) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun refreshMenuItems() { |     private fun refreshMenuItems() { | ||||||
|         settings_toolbar.menu.apply { |         binding.settingsToolbar.menu.apply { | ||||||
|             findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations) |             findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupOptionsMenu() { |     private fun setupOptionsMenu() { | ||||||
|         settings_toolbar.setOnMenuItemClickListener { menuItem -> |         binding.settingsToolbar.setOnMenuItemClickListener { menuItem -> | ||||||
|             when (menuItem.itemId) { |             when (menuItem.itemId) { | ||||||
|                 R.id.more_apps_from_us -> launchMoreAppsFromUsIntent() |                 R.id.more_apps_from_us -> launchMoreAppsFromUsIntent() | ||||||
|                 R.id.about -> launchAbout() |                 R.id.about -> launchAbout() | ||||||
| @@ -75,38 +78,38 @@ class SettingsActivity : SimpleActivity() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupPurchaseThankYou() { |     private fun setupPurchaseThankYou() { | ||||||
|         settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled()) |         binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled()) | ||||||
|         settings_purchase_thank_you_holder.setOnClickListener { |         binding.settingsPurchaseThankYouHolder.setOnClickListener { | ||||||
|             launchPurchaseThankYouIntent() |             launchPurchaseThankYouIntent() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupCustomizeColors() { |     private fun setupCustomizeColors() { | ||||||
|         settings_customize_colors_label.text = getCustomizeColorsString() |         binding.settingsCustomizeColorsLabel.text = getCustomizeColorsString() | ||||||
|         settings_color_customization_holder.setOnClickListener { |         binding.settingsColorCustomizationHolder.setOnClickListener { | ||||||
|             handleCustomizeColorsClick() |             handleCustomizeColorsClick() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupUseEnglish() { |     private fun setupUseEnglish() { | ||||||
|         settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) |         binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) | ||||||
|         settings_use_english.isChecked = config.useEnglish |         binding.settingsUseEnglish.isChecked = config.useEnglish | ||||||
|         settings_use_english_holder.setOnClickListener { |         binding.settingsUseEnglishHolder.setOnClickListener { | ||||||
|             settings_use_english.toggle() |             binding.settingsUseEnglish.toggle() | ||||||
|             config.useEnglish = settings_use_english.isChecked |             config.useEnglish = binding.settingsUseEnglish.isChecked | ||||||
|             exitProcess(0) |             exitProcess(0) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupLanguage() { |     private fun setupLanguage() { | ||||||
|         settings_language.text = Locale.getDefault().displayLanguage |         binding.settingsLanguage.text = Locale.getDefault().displayLanguage | ||||||
|         settings_language_holder.beVisibleIf(isTiramisuPlus()) |         binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus()) | ||||||
|  |  | ||||||
|         listOf(settings_general_settings_holder, settings_general_settings_label).forEach { |         listOf(binding.settingsGeneralSettingsHolder, binding.settingsGeneralSettingsLabel).forEach { | ||||||
|             it.beGoneIf(settings_use_english_holder.isGone() && settings_purchase_thank_you_holder.isGone() && settings_language_holder.isGone()) |             it.beGoneIf(binding.settingsUseEnglishHolder.isGone() && binding.settingsPurchaseThankYouHolder.isGone() && binding.settingsLanguageHolder.isGone()) | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         settings_language_holder.setOnClickListener { |         binding.settingsLanguageHolder.setOnClickListener { | ||||||
|             launchChangeAppLanguageIntent() |             launchChangeAppLanguageIntent() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -132,40 +135,40 @@ class SettingsActivity : SimpleActivity() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupSound() { |     private fun setupSound() { | ||||||
|         settings_sound.isChecked = config.isSoundEnabled |         binding.settingsSound.isChecked = config.isSoundEnabled | ||||||
|         settings_sound_holder.setOnClickListener { |         binding.settingsSoundHolder.setOnClickListener { | ||||||
|             settings_sound.toggle() |             binding.settingsSound.toggle() | ||||||
|             config.isSoundEnabled = settings_sound.isChecked |             config.isSoundEnabled = binding.settingsSound.isChecked | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupVolumeButtonsAsShutter() { |     private fun setupVolumeButtonsAsShutter() { | ||||||
|         settings_volume_buttons_as_shutter.isChecked = config.volumeButtonsAsShutter |         binding.settingsVolumeButtonsAsShutter.isChecked = config.volumeButtonsAsShutter | ||||||
|         settings_volume_buttons_as_shutter_holder.setOnClickListener { |         binding.settingsVolumeButtonsAsShutterHolder.setOnClickListener { | ||||||
|             settings_volume_buttons_as_shutter.toggle() |             binding.settingsVolumeButtonsAsShutter.toggle() | ||||||
|             config.volumeButtonsAsShutter = settings_volume_buttons_as_shutter.isChecked |             config.volumeButtonsAsShutter = binding.settingsVolumeButtonsAsShutter.isChecked | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupFlipPhotos() { |     private fun setupFlipPhotos() { | ||||||
|         settings_flip_photos.isChecked = config.flipPhotos |         binding.settingsFlipPhotos.isChecked = config.flipPhotos | ||||||
|         settings_flip_photos_holder.setOnClickListener { |         binding.settingsFlipPhotosHolder.setOnClickListener { | ||||||
|             settings_flip_photos.toggle() |             binding.settingsFlipPhotos.toggle() | ||||||
|             config.flipPhotos = settings_flip_photos.isChecked |             config.flipPhotos = binding.settingsFlipPhotos.isChecked | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupSavePhotoMetadata() { |     private fun setupSavePhotoMetadata() { | ||||||
|         settings_save_photo_metadata.isChecked = config.savePhotoMetadata |         binding.settingsSavePhotoMetadata.isChecked = config.savePhotoMetadata | ||||||
|         settings_save_photo_metadata_holder.setOnClickListener { |         binding.settingsSavePhotoMetadataHolder.setOnClickListener { | ||||||
|             settings_save_photo_metadata.toggle() |             binding.settingsSavePhotoMetadata.toggle() | ||||||
|             config.savePhotoMetadata = settings_save_photo_metadata.isChecked |             config.savePhotoMetadata = binding.settingsSavePhotoMetadata.isChecked | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupSavePhotoVideoLocation() { |     private fun setupSavePhotoVideoLocation() { | ||||||
|         settings_save_photo_video_location.isChecked = config.savePhotoVideoLocation |         binding.settingsSavePhotoVideoLocation.isChecked = config.savePhotoVideoLocation | ||||||
|         settings_save_photo_video_location_holder.setOnClickListener { |         binding.settingsSavePhotoVideoLocationHolder.setOnClickListener { | ||||||
|             val willEnableSavePhotoVideoLocation = !config.savePhotoVideoLocation |             val willEnableSavePhotoVideoLocation = !config.savePhotoVideoLocation | ||||||
|  |  | ||||||
|             if (willEnableSavePhotoVideoLocation) { |             if (willEnableSavePhotoVideoLocation) { | ||||||
| @@ -187,21 +190,21 @@ class SettingsActivity : SimpleActivity() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun updateSavePhotoVideoLocationConfig(enabled: Boolean) { |     private fun updateSavePhotoVideoLocationConfig(enabled: Boolean) { | ||||||
|         settings_save_photo_video_location.isChecked = enabled |         binding.settingsSavePhotoVideoLocation.isChecked = enabled | ||||||
|         config.savePhotoVideoLocation = enabled |         config.savePhotoVideoLocation = enabled | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupSavePhotosFolder() { |     private fun setupSavePhotosFolder() { | ||||||
|         settings_save_photos_label.text = addLockedLabelIfNeeded(R.string.save_photos) |         binding.settingsSavePhotosLabel.text = addLockedLabelIfNeeded(R.string.save_photos) | ||||||
|         settings_save_photos.text = getLastPart(config.savePhotosFolder) |         binding.settingsSavePhotos.text = getLastPart(config.savePhotosFolder) | ||||||
|         settings_save_photos_holder.setOnClickListener { |         binding.settingsSavePhotosHolder.setOnClickListener { | ||||||
|             if (isOrWasThankYouInstalled()) { |             if (isOrWasThankYouInstalled()) { | ||||||
|                 FilePickerDialog(this, config.savePhotosFolder, false, showFAB = true) { |                 FilePickerDialog(this, 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 | ||||||
|                             settings_save_photos.text = getLastPart(config.savePhotosFolder) |                             binding.settingsSavePhotos.text = getLastPart(config.savePhotosFolder) | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -213,7 +216,7 @@ class SettingsActivity : SimpleActivity() { | |||||||
|  |  | ||||||
|     private fun setupPhotoQuality() { |     private fun setupPhotoQuality() { | ||||||
|         updatePhotoQuality(config.photoQuality) |         updatePhotoQuality(config.photoQuality) | ||||||
|         settings_photo_quality_holder.setOnClickListener { |         binding.settingsPhotoQualityHolder.setOnClickListener { | ||||||
|             val items = arrayListOf( |             val items = arrayListOf( | ||||||
|                 RadioItem(100, "100%"), |                 RadioItem(100, "100%"), | ||||||
|                 RadioItem(95, "95%"), |                 RadioItem(95, "95%"), | ||||||
| @@ -237,12 +240,12 @@ class SettingsActivity : SimpleActivity() { | |||||||
|  |  | ||||||
|     @SuppressLint("SetTextI18n") |     @SuppressLint("SetTextI18n") | ||||||
|     private fun updatePhotoQuality(quality: Int) { |     private fun updatePhotoQuality(quality: Int) { | ||||||
|         settings_photo_quality.text = "$quality%" |         binding.settingsPhotoQuality.text = "$quality%" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupCaptureMode() { |     private fun setupCaptureMode() { | ||||||
|         updateCaptureMode(config.captureMode) |         updateCaptureMode(config.captureMode) | ||||||
|         settings_capture_mode_holder.setOnClickListener { |         binding.settingsCaptureModeHolder.setOnClickListener { | ||||||
|             val items = CaptureMode.values().mapIndexed { index, captureMode -> |             val items = CaptureMode.values().mapIndexed { index, captureMode -> | ||||||
|                 RadioItem(index, getString(captureMode.stringResId), captureMode) |                 RadioItem(index, getString(captureMode.stringResId), captureMode) | ||||||
|             } |             } | ||||||
| @@ -255,7 +258,6 @@ class SettingsActivity : SimpleActivity() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun updateCaptureMode(captureMode: CaptureMode) { |     private fun updateCaptureMode(captureMode: CaptureMode) { | ||||||
|         settings_capture_mode.text = getString(captureMode.stringResId) |         binding.settingsCaptureMode.text = getString(captureMode.stringResId) | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,11 +30,17 @@ | |||||||
|         app:layout_constraintStart_toStartOf="parent" |         app:layout_constraintStart_toStartOf="parent" | ||||||
|         app:layout_constraintTop_toTopOf="parent"> |         app:layout_constraintTop_toTopOf="parent"> | ||||||
|  |  | ||||||
|         <include layout="@layout/layout_top" /> |         <include | ||||||
|  |             android:id="@+id/layout_top" | ||||||
|  |             layout="@layout/layout_top" /> | ||||||
|  |  | ||||||
|         <include layout="@layout/layout_flash" /> |         <include | ||||||
|  |             android:id="@+id/layout_flash" | ||||||
|  |             layout="@layout/layout_flash" /> | ||||||
|  |  | ||||||
|         <include layout="@layout/layout_timer" /> |         <include | ||||||
|  |             android:id="@+id/layout_timer" | ||||||
|  |             layout="@layout/layout_timer" /> | ||||||
|  |  | ||||||
|     </FrameLayout> |     </FrameLayout> | ||||||
|  |  | ||||||
| @@ -80,13 +86,11 @@ | |||||||
|             app:tabTextColor="@color/md_grey_white"> |             app:tabTextColor="@color/md_grey_white"> | ||||||
|  |  | ||||||
|             <com.google.android.material.tabs.TabItem |             <com.google.android.material.tabs.TabItem | ||||||
|                 android:id="@+id/camera_mode_tab_video" |  | ||||||
|                 android:layout_width="wrap_content" |                 android:layout_width="wrap_content" | ||||||
|                 android:layout_height="wrap_content" |                 android:layout_height="wrap_content" | ||||||
|                 android:text="@string/video" /> |                 android:text="@string/video" /> | ||||||
|  |  | ||||||
|             <com.google.android.material.tabs.TabItem |             <com.google.android.material.tabs.TabItem | ||||||
|                 android:id="@+id/camera_mode_tab_photo" |  | ||||||
|                 android:layout_width="wrap_content" |                 android:layout_width="wrap_content" | ||||||
|                 android:layout_height="wrap_content" |                 android:layout_height="wrap_content" | ||||||
|                 android:text="@string/photo" /> |                 android:text="@string/photo" /> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user