fix #105, allow changing the photo compression quality
This commit is contained in:
parent
d38eb229d7
commit
a1865811a9
|
@ -7,6 +7,7 @@ import com.simplemobiletools.camera.BuildConfig
|
|||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
|
@ -14,6 +15,7 @@ import com.simplemobiletools.commons.extensions.useEnglishToggled
|
|||
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_LEAK_CANARY
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
@ -39,6 +41,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupAlwaysOpenBackCamera()
|
||||
setupSavePhotoMetadata()
|
||||
setupSavePhotosFolder()
|
||||
setupPhotoQuality()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
||||
|
@ -159,4 +162,27 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupPhotoQuality() {
|
||||
settings_photo_quality.text = "${config.photoQuality}%"
|
||||
settings_photo_quality_holder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(50, "50%"),
|
||||
RadioItem(55, "55%"),
|
||||
RadioItem(60, "60%"),
|
||||
RadioItem(65, "65%"),
|
||||
RadioItem(70, "70%"),
|
||||
RadioItem(75, "75%"),
|
||||
RadioItem(80, "80%"),
|
||||
RadioItem(85, "85%"),
|
||||
RadioItem(90, "90%"),
|
||||
RadioItem(95, "95%"),
|
||||
RadioItem(100, "100%"))
|
||||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.photoQuality) {
|
||||
config.photoQuality = it as Int
|
||||
settings_photo_quality.text = "${config.photoQuality}%"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,4 +85,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var savePhotoMetadata: Boolean
|
||||
get() = prefs.getBoolean(SAVE_PHOTO_METADATA, true)
|
||||
set(savePhotoMetadata) = prefs.edit().putBoolean(SAVE_PHOTO_METADATA, savePhotoMetadata).apply()
|
||||
|
||||
var photoQuality: Int
|
||||
get() = prefs.getInt(PHOTO_QUALITY, 80)
|
||||
set(photoQuality) = prefs.edit().putInt(PHOTO_QUALITY, photoQuality).apply()
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ val PHOTO_PREVIEW_HINT_SHOWN = "photo_preview_hint_shown"
|
|||
val KEEP_SETTINGS_VISIBLE = "keep_settings_visible"
|
||||
val ALWAYS_OPEN_BACK_CAMERA = "always_open_back_camera"
|
||||
val SAVE_PHOTO_METADATA = "save_photo_metadata"
|
||||
val PHOTO_QUALITY = "photo_quality"
|
||||
|
||||
val FLASH_OFF = 0
|
||||
val FLASH_ON = 1
|
||||
|
|
|
@ -89,7 +89,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||
image = Bitmap.createBitmap(image, 0, 0, image.width, image.height, matrix, false)
|
||||
}
|
||||
|
||||
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
|
||||
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
|
||||
|
||||
val fileExif = ExifInterface(path)
|
||||
var exifOrientation = ExifInterface.ORIENTATION_NORMAL.toString()
|
||||
|
|
|
@ -264,5 +264,40 @@
|
|||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_photo_quality_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/bigger_margin"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/bigger_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_photo_quality_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/settings_photo_quality"
|
||||
android:layout_toStartOf="@+id/settings_photo_quality"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/photo_compression_quality"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_photo_quality"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue