add a toggle for using english
This commit is contained in:
parent
1d2a5d225f
commit
608af14ce9
|
@ -19,6 +19,7 @@
|
|||
tools:node="remove"/>
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_launcher_name"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.simplemobiletools.camera
|
||||
|
||||
import android.app.Application
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import java.util.*
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
if (config.useEnglish) {
|
||||
val conf = resources.configuration
|
||||
conf.locale = Locale.ENGLISH
|
||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,6 +66,49 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||
setupOrientationEventListener()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (hasStorageAndCameraPermissions()) {
|
||||
resumeCameraItems()
|
||||
setupPreviewImage(mIsInPhotoMode)
|
||||
scheduleFadeOut()
|
||||
mFocusRectView.setStrokeColor(config.primaryColor)
|
||||
|
||||
if (mIsVideoCaptureIntent && mIsInPhotoMode) {
|
||||
handleTogglePhotoVideo()
|
||||
checkButtons()
|
||||
}
|
||||
toggleBottomButtons(false)
|
||||
}
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (hasStorageAndCameraPermissions()) {
|
||||
mOrientationEventListener.enable()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (!hasStorageAndCameraPermissions() || isAskingPermissions) {
|
||||
return
|
||||
}
|
||||
|
||||
mFadeHandler.removeCallbacksAndMessages(null)
|
||||
|
||||
hideTimer()
|
||||
mPreview?.releaseCamera()
|
||||
mOrientationEventListener.disable()
|
||||
|
||||
if (mPreview?.isWaitingForTakePictureCallback == true) {
|
||||
toast(R.string.photo_not_saved)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mPreview?.releaseCamera()
|
||||
}
|
||||
|
||||
private fun initVariables() {
|
||||
mRes = resources
|
||||
mIsInPhotoMode = false
|
||||
|
@ -418,26 +461,6 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (hasStorageAndCameraPermissions()) {
|
||||
resumeCameraItems()
|
||||
setupPreviewImage(mIsInPhotoMode)
|
||||
scheduleFadeOut()
|
||||
mFocusRectView.setStrokeColor(config.primaryColor)
|
||||
|
||||
if (mIsVideoCaptureIntent && mIsInPhotoMode) {
|
||||
handleTogglePhotoVideo()
|
||||
checkButtons()
|
||||
}
|
||||
toggleBottomButtons(false)
|
||||
}
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (hasStorageAndCameraPermissions()) {
|
||||
mOrientationEventListener.enable()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeCameraItems() {
|
||||
showToggleCameraIfNeeded()
|
||||
if (mPreview?.setCamera(mCurrCameraId) == true) {
|
||||
|
@ -456,24 +479,6 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||
toggle_camera.beInvisibleIf(Camera.getNumberOfCameras() <= 1)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
if (!hasStorageAndCameraPermissions() || isAskingPermissions) {
|
||||
return
|
||||
}
|
||||
|
||||
mFadeHandler.removeCallbacksAndMessages(null)
|
||||
|
||||
hideTimer()
|
||||
mPreview?.releaseCamera()
|
||||
mOrientationEventListener.disable()
|
||||
|
||||
if (mPreview?.isWaitingForTakePictureCallback == true) {
|
||||
toast(R.string.photo_not_saved)
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasStorageAndCameraPermissions() = hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
||||
|
||||
private fun setupOrientationEventListener() {
|
||||
|
@ -563,11 +568,6 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mPreview?.releaseCamera()
|
||||
}
|
||||
|
||||
private fun checkWhatsNewDialog() {
|
||||
arrayListOf<Release>().apply {
|
||||
add(Release(33, R.string.release_33))
|
||||
|
|
|
@ -7,12 +7,15 @@ import com.simplemobiletools.camera.BuildConfig
|
|||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.useEnglishToggled
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -24,6 +27,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
super.onResume()
|
||||
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupSavePhotosFolder()
|
||||
setupShowPreview()
|
||||
setupSound()
|
||||
|
@ -56,6 +60,16 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf(config.wasUseEnglishToggled || Locale.getDefault().language != "en")
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
useEnglishToggled()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSavePhotosFolder() {
|
||||
settings_save_photos.text = getLastPart(config.savePhotosFolder)
|
||||
settings_save_photos_holder.setOnClickListener {
|
||||
|
|
|
@ -30,6 +30,26 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_use_english_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_use_english"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/use_english_language"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_save_photos_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue