mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
do some preparations for allowing decimals at aspect ratios
This commit is contained in:
parent
51673ebdf4
commit
197d504326
6 changed files with 50 additions and 50 deletions
|
@ -78,7 +78,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
private var resizeWidth = 0
|
private var resizeWidth = 0
|
||||||
private var resizeHeight = 0
|
private var resizeHeight = 0
|
||||||
private var drawColor = 0
|
private var drawColor = 0
|
||||||
private var lastOtherAspectRatio: Pair<Int, Int>? = null
|
private var lastOtherAspectRatio: Pair<Float, Float>? = null
|
||||||
private var currPrimaryAction = PRIMARY_ACTION_NONE
|
private var currPrimaryAction = PRIMARY_ACTION_NONE
|
||||||
private var currCropRotateAction = CROP_ROTATE_ASPECT_RATIO
|
private var currCropRotateAction = CROP_ROTATE_ASPECT_RATIO
|
||||||
private var currAspectRatio = ASPECT_RATIO_FREE
|
private var currAspectRatio = ASPECT_RATIO_FREE
|
||||||
|
@ -177,12 +177,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
setupBottomActions()
|
setupBottomActions()
|
||||||
|
|
||||||
if (config.lastEditorCropAspectRatio == ASPECT_RATIO_OTHER) {
|
if (config.lastEditorCropAspectRatio == ASPECT_RATIO_OTHER) {
|
||||||
if (config.lastEditorCropOtherAspectRatioX == 0) {
|
if (config.lastEditorCropOtherAspectRatioX == 0f) {
|
||||||
config.lastEditorCropOtherAspectRatioX = 1
|
config.lastEditorCropOtherAspectRatioX = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.lastEditorCropOtherAspectRatioY == 0) {
|
if (config.lastEditorCropOtherAspectRatioY == 0f) {
|
||||||
config.lastEditorCropOtherAspectRatioY = 1
|
config.lastEditorCropOtherAspectRatioY = 1f
|
||||||
}
|
}
|
||||||
|
|
||||||
lastOtherAspectRatio = Pair(config.lastEditorCropOtherAspectRatioX, config.lastEditorCropOtherAspectRatioY)
|
lastOtherAspectRatio = Pair(config.lastEditorCropOtherAspectRatioX, config.lastEditorCropOtherAspectRatioY)
|
||||||
|
@ -654,13 +654,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
setFixedAspectRatio(false)
|
setFixedAspectRatio(false)
|
||||||
} else {
|
} else {
|
||||||
val newAspectRatio = when (aspectRatio) {
|
val newAspectRatio = when (aspectRatio) {
|
||||||
ASPECT_RATIO_ONE_ONE -> Pair(1, 1)
|
ASPECT_RATIO_ONE_ONE -> Pair(1f, 1f)
|
||||||
ASPECT_RATIO_FOUR_THREE -> Pair(4, 3)
|
ASPECT_RATIO_FOUR_THREE -> Pair(4f, 3f)
|
||||||
ASPECT_RATIO_SIXTEEN_NINE -> Pair(16, 9)
|
ASPECT_RATIO_SIXTEEN_NINE -> Pair(16f, 9f)
|
||||||
else -> Pair(lastOtherAspectRatio!!.first, lastOtherAspectRatio!!.second)
|
else -> Pair(lastOtherAspectRatio!!.first, lastOtherAspectRatio!!.second)
|
||||||
}
|
}
|
||||||
|
|
||||||
setAspectRatio(newAspectRatio.first, newAspectRatio.second)
|
setAspectRatio(newAspectRatio.first.toInt(), newAspectRatio.second.toInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -790,8 +790,8 @@ class SettingsActivity : SimpleActivity() {
|
||||||
SLIDESHOW_MOVE_BACKWARDS -> config.slideshowMoveBackwards = value.toBoolean()
|
SLIDESHOW_MOVE_BACKWARDS -> config.slideshowMoveBackwards = value.toBoolean()
|
||||||
SLIDESHOW_LOOP -> config.loopSlideshow = value.toBoolean()
|
SLIDESHOW_LOOP -> config.loopSlideshow = value.toBoolean()
|
||||||
LAST_EDITOR_CROP_ASPECT_RATIO -> config.lastEditorCropAspectRatio = value.toInt()
|
LAST_EDITOR_CROP_ASPECT_RATIO -> config.lastEditorCropAspectRatio = value.toInt()
|
||||||
LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X -> config.lastEditorCropOtherAspectRatioX = value.toInt()
|
LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X -> config.lastEditorCropOtherAspectRatioX = value.toString().toFloat()
|
||||||
LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y -> config.lastEditorCropOtherAspectRatioY = value.toInt()
|
LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y -> config.lastEditorCropOtherAspectRatioY = value.toString().toFloat()
|
||||||
LAST_EDITOR_DRAW_COLOR -> config.lastEditorDrawColor = value.toInt()
|
LAST_EDITOR_DRAW_COLOR -> config.lastEditorDrawColor = value.toInt()
|
||||||
LAST_EDITOR_BRUSH_SIZE -> config.lastEditorBrushSize = value.toInt()
|
LAST_EDITOR_BRUSH_SIZE -> config.lastEditorBrushSize = value.toInt()
|
||||||
LAST_CONFLICT_RESOLUTION -> config.lastConflictResolution = value.toInt()
|
LAST_CONFLICT_RESOLUTION -> config.lastConflictResolution = value.toInt()
|
||||||
|
|
|
@ -9,11 +9,11 @@ import com.simplemobiletools.commons.extensions.value
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.*
|
import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.*
|
||||||
|
|
||||||
class CustomAspectRatioDialog(val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Int, Int>?, val callback: (aspectRatio: Pair<Int, Int>) -> Unit) {
|
class CustomAspectRatioDialog(val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply {
|
||||||
aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toString() ?: "")
|
aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "")
|
||||||
aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toString() ?: "")
|
aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
|
@ -32,8 +32,8 @@ class CustomAspectRatioDialog(val activity: BaseSimpleActivity, val defaultCusto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getViewValue(view: EditText): Int {
|
private fun getViewValue(view: EditText): Float {
|
||||||
val textValue = view.value
|
val textValue = view.value
|
||||||
return if (textValue.isEmpty()) 0 else textValue.toInt()
|
return if (textValue.isEmpty()) 0f else textValue.toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,44 +6,44 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.*
|
import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.*
|
||||||
|
|
||||||
class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val lastOtherAspectRatio: Pair<Int, Int>?, val callback: (aspectRatio: Pair<Int, Int>) -> Unit) {
|
class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val lastOtherAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit) {
|
||||||
private val dialog: AlertDialog
|
private val dialog: AlertDialog
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply {
|
val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply {
|
||||||
other_aspect_ratio_2_1.setOnClickListener { ratioPicked(Pair(2, 1)) }
|
other_aspect_ratio_2_1.setOnClickListener { ratioPicked(Pair(2f, 1f)) }
|
||||||
other_aspect_ratio_3_2.setOnClickListener { ratioPicked(Pair(3, 2)) }
|
other_aspect_ratio_3_2.setOnClickListener { ratioPicked(Pair(3f, 2f)) }
|
||||||
other_aspect_ratio_4_3.setOnClickListener { ratioPicked(Pair(4, 3)) }
|
other_aspect_ratio_4_3.setOnClickListener { ratioPicked(Pair(4f, 3f)) }
|
||||||
other_aspect_ratio_5_3.setOnClickListener { ratioPicked(Pair(5, 3)) }
|
other_aspect_ratio_5_3.setOnClickListener { ratioPicked(Pair(5f, 3f)) }
|
||||||
other_aspect_ratio_16_9.setOnClickListener { ratioPicked(Pair(16, 9)) }
|
other_aspect_ratio_16_9.setOnClickListener { ratioPicked(Pair(16f, 9f)) }
|
||||||
other_aspect_ratio_19_9.setOnClickListener { ratioPicked(Pair(19, 9)) }
|
other_aspect_ratio_19_9.setOnClickListener { ratioPicked(Pair(19f, 9f)) }
|
||||||
other_aspect_ratio_custom.setOnClickListener { customRatioPicked() }
|
other_aspect_ratio_custom.setOnClickListener { customRatioPicked() }
|
||||||
|
|
||||||
other_aspect_ratio_1_2.setOnClickListener { ratioPicked(Pair(1, 2)) }
|
other_aspect_ratio_1_2.setOnClickListener { ratioPicked(Pair(1f, 2f)) }
|
||||||
other_aspect_ratio_2_3.setOnClickListener { ratioPicked(Pair(2, 3)) }
|
other_aspect_ratio_2_3.setOnClickListener { ratioPicked(Pair(2f, 3f)) }
|
||||||
other_aspect_ratio_3_4.setOnClickListener { ratioPicked(Pair(3, 4)) }
|
other_aspect_ratio_3_4.setOnClickListener { ratioPicked(Pair(3f, 4f)) }
|
||||||
other_aspect_ratio_3_5.setOnClickListener { ratioPicked(Pair(3, 5)) }
|
other_aspect_ratio_3_5.setOnClickListener { ratioPicked(Pair(3f, 5f)) }
|
||||||
other_aspect_ratio_9_16.setOnClickListener { ratioPicked(Pair(9, 16)) }
|
other_aspect_ratio_9_16.setOnClickListener { ratioPicked(Pair(9f, 16f)) }
|
||||||
other_aspect_ratio_9_19.setOnClickListener { ratioPicked(Pair(9, 19)) }
|
other_aspect_ratio_9_19.setOnClickListener { ratioPicked(Pair(9f, 19f)) }
|
||||||
|
|
||||||
val radio1SelectedItemId = when (lastOtherAspectRatio) {
|
val radio1SelectedItemId = when (lastOtherAspectRatio) {
|
||||||
Pair(2, 1) -> other_aspect_ratio_2_1.id
|
Pair(2f, 1f) -> other_aspect_ratio_2_1.id
|
||||||
Pair(3, 2) -> other_aspect_ratio_3_2.id
|
Pair(3f, 2f) -> other_aspect_ratio_3_2.id
|
||||||
Pair(4, 3) -> other_aspect_ratio_4_3.id
|
Pair(4f, 3f) -> other_aspect_ratio_4_3.id
|
||||||
Pair(5, 3) -> other_aspect_ratio_5_3.id
|
Pair(5f, 3f) -> other_aspect_ratio_5_3.id
|
||||||
Pair(16, 9) -> other_aspect_ratio_16_9.id
|
Pair(16f, 9f) -> other_aspect_ratio_16_9.id
|
||||||
Pair(19, 9) -> other_aspect_ratio_19_9.id
|
Pair(19f, 9f) -> other_aspect_ratio_19_9.id
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
other_aspect_ratio_dialog_radio_1.check(radio1SelectedItemId)
|
other_aspect_ratio_dialog_radio_1.check(radio1SelectedItemId)
|
||||||
|
|
||||||
val radio2SelectedItemId = when (lastOtherAspectRatio) {
|
val radio2SelectedItemId = when (lastOtherAspectRatio) {
|
||||||
Pair(1, 2) -> other_aspect_ratio_1_2.id
|
Pair(1f, 2f) -> other_aspect_ratio_1_2.id
|
||||||
Pair(2, 3) -> other_aspect_ratio_2_3.id
|
Pair(2f, 3f) -> other_aspect_ratio_2_3.id
|
||||||
Pair(3, 4) -> other_aspect_ratio_3_4.id
|
Pair(3f, 4f) -> other_aspect_ratio_3_4.id
|
||||||
Pair(3, 5) -> other_aspect_ratio_3_5.id
|
Pair(3f, 5f) -> other_aspect_ratio_3_5.id
|
||||||
Pair(9, 16) -> other_aspect_ratio_9_16.id
|
Pair(9f, 16f) -> other_aspect_ratio_9_16.id
|
||||||
Pair(9, 19) -> other_aspect_ratio_9_19.id
|
Pair(9f, 19f) -> other_aspect_ratio_9_19.id
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
other_aspect_ratio_dialog_radio_2.check(radio2SelectedItemId)
|
other_aspect_ratio_dialog_radio_2.check(radio2SelectedItemId)
|
||||||
|
@ -67,7 +67,7 @@ class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val lastOtherAspe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ratioPicked(pair: Pair<Int, Int>) {
|
private fun ratioPicked(pair: Pair<Float, Float>) {
|
||||||
callback(pair)
|
callback(pair)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,13 +447,13 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getInt(LAST_EDITOR_CROP_ASPECT_RATIO, ASPECT_RATIO_FREE)
|
get() = prefs.getInt(LAST_EDITOR_CROP_ASPECT_RATIO, ASPECT_RATIO_FREE)
|
||||||
set(lastEditorCropAspectRatio) = prefs.edit().putInt(LAST_EDITOR_CROP_ASPECT_RATIO, lastEditorCropAspectRatio).apply()
|
set(lastEditorCropAspectRatio) = prefs.edit().putInt(LAST_EDITOR_CROP_ASPECT_RATIO, lastEditorCropAspectRatio).apply()
|
||||||
|
|
||||||
var lastEditorCropOtherAspectRatioX: Int
|
var lastEditorCropOtherAspectRatioX: Float
|
||||||
get() = prefs.getInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X, 2)
|
get() = prefs.getFloat(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X, 2f)
|
||||||
set(lastEditorCropOtherAspectRatioX) = prefs.edit().putInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X, lastEditorCropOtherAspectRatioX).apply()
|
set(lastEditorCropOtherAspectRatioX) = prefs.edit().putFloat(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X, lastEditorCropOtherAspectRatioX).apply()
|
||||||
|
|
||||||
var lastEditorCropOtherAspectRatioY: Int
|
var lastEditorCropOtherAspectRatioY: Float
|
||||||
get() = prefs.getInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, 1)
|
get() = prefs.getFloat(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, 1f)
|
||||||
set(lastEditorCropOtherAspectRatioY) = prefs.edit().putInt(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, lastEditorCropOtherAspectRatioY).apply()
|
set(lastEditorCropOtherAspectRatioY) = prefs.edit().putFloat(LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y, lastEditorCropOtherAspectRatioY).apply()
|
||||||
|
|
||||||
var groupDirectSubfolders: Boolean
|
var groupDirectSubfolders: Boolean
|
||||||
get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false)
|
get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false)
|
||||||
|
|
|
@ -67,8 +67,8 @@ const val LAST_BIN_CHECK = "last_bin_check"
|
||||||
const val SHOW_HIGHEST_QUALITY = "show_highest_quality"
|
const val SHOW_HIGHEST_QUALITY = "show_highest_quality"
|
||||||
const val ALLOW_DOWN_GESTURE = "allow_down_gesture"
|
const val ALLOW_DOWN_GESTURE = "allow_down_gesture"
|
||||||
const val LAST_EDITOR_CROP_ASPECT_RATIO = "last_editor_crop_aspect_ratio"
|
const val LAST_EDITOR_CROP_ASPECT_RATIO = "last_editor_crop_aspect_ratio"
|
||||||
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect_ratio_x"
|
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect_ratio_x_2"
|
||||||
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y"
|
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y_2"
|
||||||
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
||||||
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
|
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
|
||||||
const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom"
|
const val ALLOW_ONE_TO_ONE_ZOOM = "allow_one_to_one_zoom"
|
||||||
|
|
Loading…
Reference in a new issue