From 367da03d029b8d78af7ba321dc8e9241f930c90a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 19 Mar 2017 13:10:32 +0100 Subject: [PATCH] update the Settings screen --- .../camera/activities/SettingsActivity.kt | 59 +++---- app/src/main/res/layout/activity_settings.xml | 162 ++++++++++-------- 2 files changed, 109 insertions(+), 112 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt index 93d9bfd3..e1293f19 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -4,23 +4,33 @@ import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import com.simplemobiletools.camera.R +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.updateTextColors +import kotlinx.android.synthetic.main.activity_settings.* class SettingsActivity : SimpleActivity() { - val OPEN_DOCUMENT_TREE = 1 var mCurrPath = "" var mWantedPath = "" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_settings) + } - /*setupSavePhotosFolder() + override fun onResume() { + super.onResume() + + setupSavePhotosFolder() setupShowPreview() setupSound() setupForceRatio() setupMaxPhotoResolution() - setupMaxVideoResolution()*/ + setupMaxVideoResolution() + updateTextColors(settings_holder) } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -38,17 +48,17 @@ class SettingsActivity : SimpleActivity() { } } - /*private fun setupSavePhotosFolder() { + private fun setupSavePhotosFolder() { mCurrPath = config.savePhotosFolder settings_save_photos.text = getHumanPath() settings_save_photos_holder.setOnClickListener { FilePickerDialog(this, mCurrPath, false) { - mWantedPath = pickedPath + /*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() - } + }*/ } } } @@ -65,31 +75,6 @@ class SettingsActivity : SimpleActivity() { private fun getStorageName(basePath: String) = "${getHumanReadablePath(basePath)}/" - @TargetApi(Build.VERSION_CODES.KITKAT) - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - super.onActivityResult(requestCode, resultCode, resultData) - if (requestCode == OPEN_DOCUMENT_TREE) { - if (resultCode == Activity.RESULT_OK && resultData != null) { - mCurrPath = mWantedPath - config.savePhotosFolder = mCurrPath - settings_save_photos.text = getHumanPath() - saveTreeUri(resultData) - } else { - mCurrPath = config.savePhotosFolder - settings_save_photos.text = getHumanPath() - } - } - } - - @TargetApi(Build.VERSION_CODES.KITKAT) - private fun saveTreeUri(resultData: Intent) { - val treeUri = resultData.data - config.treeUri = treeUri.toString() - - val takeFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION - contentResolver.takePersistableUriPermission(treeUri, takeFlags) - } - private fun setupShowPreview() { settings_show_preview.isChecked = config.isShowPreviewEnabled settings_show_preview_holder.setOnClickListener { @@ -115,7 +100,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupMaxPhotoResolution() { - settings_max_photo_resolution.setSelection(getMaxPhotoSelection()) + /*settings_max_photo_resolution.setSelection(getMaxPhotoSelection()) settings_max_photo_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { config.maxPhotoResolution = getMaxPhotoPx(settings_max_photo_resolution.selectedItemPosition) @@ -123,7 +108,7 @@ class SettingsActivity : SimpleActivity() { override fun onNothingSelected(parent: AdapterView<*>?) { } - } + }*/ } private fun getMaxPhotoSelection(): Int { @@ -146,7 +131,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupMaxVideoResolution() { - settings_max_video_resolution.setSelection(getMaxVideoSelection()) + /*settings_max_video_resolution.setSelection(getMaxVideoSelection()) settings_max_video_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onNothingSelected(parent: AdapterView<*>?) { } @@ -154,7 +139,7 @@ class SettingsActivity : SimpleActivity() { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { config.maxVideoResolution = getMaxVideoPx(settings_max_video_resolution.selectedItemPosition) } - } + }*/ } private fun getMaxVideoSelection(): Int { @@ -173,5 +158,5 @@ class SettingsActivity : SimpleActivity() { 2 -> P1080 else -> -1 } - }*/ + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 76ada836..ba61f6f2 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -6,37 +6,60 @@ android:layout_height="wrap_content"> - + + + + + + - @@ -46,27 +69,19 @@ android:id="@+id/settings_show_preview_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/settings_padding" + android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" android:padding="@dimen/activity_margin"> - - - + android:clickable="false" + android:paddingLeft="@dimen/medium_margin" + android:paddingStart="@dimen/medium_margin" + android:text="@string/show_preview"/> @@ -74,27 +89,19 @@ android:id="@+id/settings_sound_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/settings_padding" + android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" android:padding="@dimen/activity_margin"> - - - + android:clickable="false" + android:paddingLeft="@dimen/medium_margin" + android:paddingStart="@dimen/medium_margin" + android:text="@string/shutter_sound"/> @@ -102,27 +109,19 @@ android:id="@+id/settings_force_ratio_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/settings_padding" + android:layout_marginTop="@dimen/medium_margin" android:background="?attr/selectableItemBackground" android:padding="@dimen/activity_margin"> - - - + android:clickable="false" + android:paddingLeft="@dimen/medium_margin" + android:paddingStart="@dimen/medium_margin" + android:text="@string/force_ratio"/> @@ -130,57 +129,70 @@ android:id="@+id/settings_max_photo_resolution_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/settings_padding" - android:paddingBottom="@dimen/activity_margin" + android:layout_marginTop="@dimen/medium_margin" + android:background="?attr/selectableItemBackground" + android:paddingBottom="@dimen/bigger_margin" android:paddingLeft="@dimen/activity_margin" - android:paddingRight="@dimen/settings_padding" - android:paddingTop="@dimen/activity_margin"> + android:paddingRight="@dimen/activity_margin" + android:paddingTop="@dimen/bigger_margin"> - - + android:layout_marginEnd="@dimen/small_margin" + android:layout_marginRight="@dimen/small_margin" + android:background="@null" + android:clickable="false"/> + + android:paddingRight="@dimen/activity_margin" + android:paddingTop="@dimen/bigger_margin"> - - + android:layout_marginEnd="@dimen/small_margin" + android:layout_marginRight="@dimen/small_margin" + android:background="@null" + android:clickable="false"/>