add a toggle for forcing English language, if it isnt the device language
This commit is contained in:
parent
6bc3e4cfa6
commit
3a23e2b0bf
|
@ -45,7 +45,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.37.2'
|
||||
compile 'com.simplemobiletools:commons:2.37.6'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.simplemobiletools.gallery
|
|||
import android.app.Application
|
||||
import com.github.ajalt.reprint.core.Reprint
|
||||
import com.simplemobiletools.gallery.BuildConfig.USE_LEAK_CANARY
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.squareup.leakcanary.LeakCanary
|
||||
import java.util.*
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
|
@ -15,6 +17,11 @@ class App : Application() {
|
|||
LeakCanary.install(this)
|
||||
}
|
||||
|
||||
if (config.useEnglish) {
|
||||
val conf = resources.configuration
|
||||
conf.locale = Locale.ENGLISH
|
||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
||||
}
|
||||
Reprint.initialize(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private var mAllowPickingMultiple = false
|
||||
private var mIsThirdPartyIntent = false
|
||||
private var mIsGettingDirs = false
|
||||
private var mStoredUseEnglish = false
|
||||
private var mStoredAnimateGifs = true
|
||||
private var mStoredCropThumbnails = true
|
||||
private var mStoredScrollHorizontally = true
|
||||
|
@ -124,6 +125,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
config.isThirdPartyIntent = false
|
||||
if (mStoredUseEnglish != config.useEnglish) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if (mStoredAnimateGifs != config.animateGifs) {
|
||||
getDirectoryAdapter()?.updateAnimateGifs(config.animateGifs)
|
||||
}
|
||||
|
@ -175,6 +181,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun storeStateVariables() {
|
||||
config.apply {
|
||||
mStoredUseEnglish = useEnglish
|
||||
mStoredAnimateGifs = animateGifs
|
||||
mStoredCropThumbnails = cropThumbnails
|
||||
mStoredScrollHorizontally = scrollHorizontally
|
||||
|
|
|
@ -50,6 +50,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private var mAllowPickingMultiple = false
|
||||
private var mShowAll = false
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mStoredUseEnglish = false
|
||||
private var mStoredAnimateGifs = true
|
||||
private var mStoredCropThumbnails = true
|
||||
private var mStoredScrollHorizontally = true
|
||||
|
@ -86,6 +87,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mStoredUseEnglish != config.useEnglish) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if (mStoredAnimateGifs != config.animateGifs) {
|
||||
getMediaAdapter()?.updateAnimateGifs(config.animateGifs)
|
||||
}
|
||||
|
@ -131,6 +137,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
private fun storeStateVariables() {
|
||||
config.apply {
|
||||
mStoredUseEnglish = useEnglish
|
||||
mStoredAnimateGifs = animateGifs
|
||||
mStoredCropThumbnails = cropThumbnails
|
||||
mStoredScrollHorizontally = scrollHorizontally
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.commons.dialogs.SecurityDialog
|
|||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.handleHiddenFolderPasswordProtection
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.useEnglishToggled
|
||||
import com.simplemobiletools.commons.helpers.PROTECTION_FINGERPRINT
|
||||
import com.simplemobiletools.commons.helpers.SHOW_ALL_TABS
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
|
@ -19,6 +20,7 @@ import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO
|
|||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION
|
||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.util.*
|
||||
|
||||
class SettingsActivity : SimpleActivity() {
|
||||
lateinit var res: Resources
|
||||
|
@ -33,6 +35,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
super.onResume()
|
||||
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupManageIncludedFolders()
|
||||
setupManageExcludedFolders()
|
||||
setupShowHiddenFolders()
|
||||
|
@ -62,6 +65,16 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf(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 setupManageIncludedFolders() {
|
||||
settings_manage_included_folders_holder.setOnClickListener {
|
||||
startActivity(Intent(this, IncludedFoldersActivity::class.java))
|
||||
|
|
|
@ -67,6 +67,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
private var mSlideshowMedia = mutableListOf<Medium>()
|
||||
private var mAreSlideShowMediaVisible = false
|
||||
|
||||
private var mStoredUseEnglish = false
|
||||
|
||||
companion object {
|
||||
var screenWidth = 0
|
||||
var screenHeight = 0
|
||||
|
@ -84,6 +86,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
private fun initViewPager() {
|
||||
|
@ -202,6 +206,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
finish()
|
||||
return
|
||||
}
|
||||
|
||||
if (mStoredUseEnglish != config.useEnglish) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
supportActionBar?.setBackgroundDrawable(resources.getDrawable(R.drawable.actionbar_gradient_background))
|
||||
|
||||
if (config.maxBrightness) {
|
||||
|
@ -223,6 +233,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
super.onPause()
|
||||
mOrientationEventListener?.disable()
|
||||
stopSlideshow()
|
||||
storeStateVariables()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
@ -274,6 +285,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
return true
|
||||
}
|
||||
|
||||
private fun storeStateVariables() {
|
||||
mStoredUseEnglish = config.useEnglish
|
||||
}
|
||||
|
||||
private fun updatePagerItems(media: MutableList<Medium>) {
|
||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
||||
|
|
|
@ -68,6 +68,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_show_hidden_folders_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue