fix setting the photo save folder
This commit is contained in:
parent
862295fbba
commit
f40d7f6f7c
|
@ -26,6 +26,7 @@ import com.simplemobiletools.camera.extensions.config
|
||||||
import com.simplemobiletools.camera.views.FocusRectView
|
import com.simplemobiletools.camera.views.FocusRectView
|
||||||
import com.simplemobiletools.commons.extensions.checkWhatsNew
|
import com.simplemobiletools.commons.extensions.checkWhatsNew
|
||||||
import com.simplemobiletools.commons.extensions.hasWriteStoragePermission
|
import com.simplemobiletools.commons.extensions.hasWriteStoragePermission
|
||||||
|
import com.simplemobiletools.commons.extensions.storeStoragePaths
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.models.Release
|
import com.simplemobiletools.commons.models.Release
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
|
@ -66,6 +67,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
||||||
mRes = resources
|
mRes = resources
|
||||||
tryInitCamera()
|
tryInitCamera()
|
||||||
supportActionBar?.hide()
|
supportActionBar?.hide()
|
||||||
|
storeStoragePaths()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,14 @@ import android.view.MenuItem
|
||||||
import com.simplemobiletools.camera.*
|
import com.simplemobiletools.camera.*
|
||||||
import com.simplemobiletools.camera.extensions.config
|
import com.simplemobiletools.camera.extensions.config
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.getBasePath
|
import com.simplemobiletools.commons.extensions.humanizePath
|
||||||
import com.simplemobiletools.commons.extensions.getHumanReadablePath
|
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
var mCurrPath = ""
|
|
||||||
var mWantedPath = ""
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(R.layout.activity_settings)
|
||||||
|
@ -48,32 +45,22 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSavePhotosFolder() {
|
private fun setupSavePhotosFolder() {
|
||||||
mCurrPath = config.savePhotosFolder
|
settings_save_photos.text = getLastPart(config.savePhotosFolder)
|
||||||
settings_save_photos.text = getHumanPath()
|
|
||||||
settings_save_photos_holder.setOnClickListener {
|
settings_save_photos_holder.setOnClickListener {
|
||||||
FilePickerDialog(this, mCurrPath, false) {
|
FilePickerDialog(this, config.savePhotosFolder, false) {
|
||||||
/*mWantedPath = pickedPath
|
handleSAFDialog(File(it)) {
|
||||||
if (!isShowingWritePermissions(File(pickedPath), config.treeUri, OPEN_DOCUMENT_TREE)) {
|
config.savePhotosFolder = it
|
||||||
mCurrPath = if (pickedPath.length == 1) pickedPath else pickedPath.trimEnd('/')
|
settings_save_photos.text = getLastPart(config.savePhotosFolder)
|
||||||
config.savePhotosFolder = mCurrPath
|
}
|
||||||
settings_save_photos.text = getHumanPath()
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getHumanPath(): String {
|
private fun getLastPart(path: String): String {
|
||||||
val basePath = mCurrPath.getBasePath(this)
|
val humanized = humanizePath(path)
|
||||||
val path = mCurrPath.replaceFirst(basePath, getStorageName(basePath)).trimEnd('/')
|
return humanized.substringAfterLast("/", humanized)
|
||||||
|
|
||||||
return if (path.contains('/'))
|
|
||||||
path.substring(path.lastIndexOf("/") + 1)
|
|
||||||
else
|
|
||||||
path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getStorageName(basePath: String) = "${getHumanReadablePath(basePath)}/"
|
|
||||||
|
|
||||||
private fun setupShowPreview() {
|
private fun setupShowPreview() {
|
||||||
settings_show_preview.isChecked = config.isShowPreviewEnabled
|
settings_show_preview.isChecked = config.isShowPreviewEnabled
|
||||||
settings_show_preview_holder.setOnClickListener {
|
settings_show_preview_holder.setOnClickListener {
|
||||||
|
|
Loading…
Reference in New Issue