diff --git a/app/build.gradle b/app/build.gradle index 9963dbd4c..9d2b84b32 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt index 6141c6c76..37815fa88 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/App.kt @@ -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) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index d20cbb97a..3c69ea85c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index b0bcdee3b..b500af01e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index 6e988b0e3..ca4b6023e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -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)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 569deaa34..84803c157 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -67,6 +67,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private var mSlideshowMedia = mutableListOf() 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) { val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 0090560db..9b80d6fc3 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -68,6 +68,26 @@ + + + + + +