mirror of
				https://github.com/SimpleMobileTools/Simple-Camera.git
				synced 2025-06-27 09:02:59 +02:00 
			
		
		
		
	fix setting the photo save folder
This commit is contained in:
		| @@ -26,6 +26,7 @@ import com.simplemobiletools.camera.extensions.config | ||||
| import com.simplemobiletools.camera.views.FocusRectView | ||||
| import com.simplemobiletools.commons.extensions.checkWhatsNew | ||||
| import com.simplemobiletools.commons.extensions.hasWriteStoragePermission | ||||
| import com.simplemobiletools.commons.extensions.storeStoragePaths | ||||
| import com.simplemobiletools.commons.extensions.toast | ||||
| import com.simplemobiletools.commons.models.Release | ||||
| import kotlinx.android.synthetic.main.activity_main.* | ||||
| @@ -66,6 +67,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho | ||||
|         mRes = resources | ||||
|         tryInitCamera() | ||||
|         supportActionBar?.hide() | ||||
|         storeStoragePaths() | ||||
|         checkWhatsNewDialog() | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -6,17 +6,14 @@ import android.view.MenuItem | ||||
| import com.simplemobiletools.camera.* | ||||
| import com.simplemobiletools.camera.extensions.config | ||||
| import com.simplemobiletools.commons.dialogs.FilePickerDialog | ||||
| import com.simplemobiletools.commons.extensions.getBasePath | ||||
| import com.simplemobiletools.commons.extensions.getHumanReadablePath | ||||
| import com.simplemobiletools.commons.extensions.humanizePath | ||||
| import com.simplemobiletools.commons.extensions.updateTextColors | ||||
| 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 | ||||
|  | ||||
| class SettingsActivity : SimpleActivity() { | ||||
|     var mCurrPath = "" | ||||
|     var mWantedPath = "" | ||||
|  | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|         super.onCreate(savedInstanceState) | ||||
|         setContentView(R.layout.activity_settings) | ||||
| @@ -48,32 +45,22 @@ class SettingsActivity : SimpleActivity() { | ||||
|     } | ||||
|  | ||||
|     private fun setupSavePhotosFolder() { | ||||
|         mCurrPath = config.savePhotosFolder | ||||
|         settings_save_photos.text = getHumanPath() | ||||
|         settings_save_photos.text = getLastPart(config.savePhotosFolder) | ||||
|         settings_save_photos_holder.setOnClickListener { | ||||
|             FilePickerDialog(this, mCurrPath, false) { | ||||
|                 /*mWantedPath = pickedPath | ||||
|                 if (!isShowingWritePermissions(File(pickedPath), config.treeUri, OPEN_DOCUMENT_TREE)) { | ||||
|                     mCurrPath = if (pickedPath.length == 1) pickedPath else pickedPath.trimEnd('/') | ||||
|                     config.savePhotosFolder = mCurrPath | ||||
|                     settings_save_photos.text = getHumanPath() | ||||
|                 }*/ | ||||
|             FilePickerDialog(this, config.savePhotosFolder, false) { | ||||
|                 handleSAFDialog(File(it)) { | ||||
|                     config.savePhotosFolder = it | ||||
|                     settings_save_photos.text = getLastPart(config.savePhotosFolder) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun getHumanPath(): String { | ||||
|         val basePath = mCurrPath.getBasePath(this) | ||||
|         val path = mCurrPath.replaceFirst(basePath, getStorageName(basePath)).trimEnd('/') | ||||
|  | ||||
|         return if (path.contains('/')) | ||||
|             path.substring(path.lastIndexOf("/") + 1) | ||||
|         else | ||||
|             path | ||||
|     private fun getLastPart(path: String): String { | ||||
|         val humanized = humanizePath(path) | ||||
|         return humanized.substringAfterLast("/", humanized) | ||||
|     } | ||||
|  | ||||
|     private fun getStorageName(basePath: String) = "${getHumanReadablePath(basePath)}/" | ||||
|  | ||||
|     private fun setupShowPreview() { | ||||
|         settings_show_preview.isChecked = config.isShowPreviewEnabled | ||||
|         settings_show_preview_holder.setOnClickListener { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user