diff --git a/app/build.gradle b/app/build.gradle index bdbca7261..840cd5f36 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,5 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' def keystorePropertiesFile = rootProject.file("keystore.properties") @@ -10,12 +9,13 @@ if (keystorePropertiesFile.exists()) { } android { - compileSdkVersion 33 + compileSdkVersion 34 + namespace = "com.simplemobiletools.gallery.pro" defaultConfig { applicationId "com.simplemobiletools.gallery.pro" minSdkVersion 23 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 394 versionName "6.27.2" setProperty("archivesBaseName", "gallery-$versionCode") @@ -68,17 +68,22 @@ android { } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } packagingOptions { exclude 'META-INF/library_release.kotlin_module' } + + buildFeatures { + buildConfig = true + viewBinding = true + } } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0' + implementation 'com.github.esensar:Simple-Commons:98cea1b5bb' implementation 'com.vanniktech:android-image-cropper:4.5.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index 46cee5feb..14cba2ecb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -36,6 +36,7 @@ import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter +import com.simplemobiletools.gallery.pro.databinding.ActivityEditBinding import com.simplemobiletools.gallery.pro.dialogs.OtherAspectRatioDialog import com.simplemobiletools.gallery.pro.dialogs.ResizeDialog import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog @@ -47,34 +48,30 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.FilterItem import com.zomato.photofilters.FilterPack import com.zomato.photofilters.imageprocessors.Filter -import kotlinx.android.synthetic.main.activity_edit.* -import kotlinx.android.synthetic.main.bottom_actions_aspect_ratio.* -import kotlinx.android.synthetic.main.bottom_editor_actions_filter.* -import kotlinx.android.synthetic.main.bottom_editor_crop_rotate_actions.* -import kotlinx.android.synthetic.main.bottom_editor_draw_actions.* -import kotlinx.android.synthetic.main.bottom_editor_primary_actions.* import java.io.* +import kotlin.math.max class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener { companion object { init { System.loadLibrary("NativeImageProcessor") } + + private const val TEMP_FOLDER_NAME = "images" + private const val ASPECT_X = "aspectX" + private const val ASPECT_Y = "aspectY" + private const val CROP = "crop" + + // constants for bottom primary action groups + private const val PRIMARY_ACTION_NONE = 0 + private const val PRIMARY_ACTION_FILTER = 1 + private const val PRIMARY_ACTION_CROP_ROTATE = 2 + private const val PRIMARY_ACTION_DRAW = 3 + + private const val CROP_ROTATE_NONE = 0 + private const val CROP_ROTATE_ASPECT_RATIO = 1 } - private val TEMP_FOLDER_NAME = "images" - private val ASPECT_X = "aspectX" - private val ASPECT_Y = "aspectY" - private val CROP = "crop" - - // constants for bottom primary action groups - private val PRIMARY_ACTION_NONE = 0 - private val PRIMARY_ACTION_FILTER = 1 - private val PRIMARY_ACTION_CROP_ROTATE = 2 - private val PRIMARY_ACTION_DRAW = 3 - - private val CROP_ROTATE_NONE = 0 - private val CROP_ROTATE_ASPECT_RATIO = 1 private lateinit var saveUri: Uri private var uri: Uri? = null @@ -92,10 +89,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private var oldExif: ExifInterface? = null private var filterInitialBitmap: Bitmap? = null private var originalUri: Uri? = null + private lateinit var binding: ActivityEditBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_edit) + binding = ActivityEditBinding.inflate(layoutInflater) + setContentView(binding.root) if (checkAppSideloading()) { return @@ -104,7 +103,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener setupOptionsMenu() handlePermission(getPermissionToRequest()) { if (!it) { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } initEditActivity() @@ -114,8 +113,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener override fun onResume() { super.onResume() isEditingWithThirdParty = false - bottom_draw_width.setColors(getProperTextColor(), getProperPrimaryColor(), getProperBackgroundColor()) - setupToolbar(editor_toolbar, NavigationIcon.Arrow) + binding.bottomEditorDrawActions.bottomDrawWidth.setColors(getProperTextColor(), getProperPrimaryColor(), getProperBackgroundColor()) + setupToolbar(binding.editorToolbar, NavigationIcon.Arrow) } override fun onStop() { @@ -126,7 +125,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun setupOptionsMenu() { - editor_toolbar.setOnMenuItemClickListener { menuItem -> + binding.editorToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.save_as -> saveImage() R.id.edit -> editWith() @@ -172,8 +171,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener isCropIntent = intent.extras?.get(CROP) == "true" if (isCropIntent) { - bottom_editor_primary_actions.beGone() - (bottom_editor_crop_rotate_actions.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1) + binding.bottomEditorPrimaryActions.root.beGone() + (binding.bottomEditorCropRotateActions.root.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1) } loadDefaultImageView() @@ -191,14 +190,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener lastOtherAspectRatio = Pair(config.lastEditorCropOtherAspectRatioX, config.lastEditorCropOtherAspectRatioY) } updateAspectRatio(config.lastEditorCropAspectRatio) - crop_image_view.guidelines = CropImageView.Guidelines.ON - bottom_aspect_ratios.beVisible() + binding.cropImageView.guidelines = CropImageView.Guidelines.ON + binding.bottomAspectRatios.root.beVisible() } private fun loadDefaultImageView() { - default_image_view.beVisible() - crop_image_view.beGone() - editor_draw_canvas.beGone() + binding.defaultImageView.beVisible() + binding.cropImageView.beGone() + binding.editorDrawCanvas.beGone() val options = RequestOptions() .skipMemoryCache(true) @@ -232,8 +231,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener bottomCropRotateClicked() } - if (filterInitialBitmap != null && currentFilter != null && currentFilter.filter.name != getString(R.string.none)) { - default_image_view.onGlobalLayout { + if (filterInitialBitmap != null && currentFilter != null && currentFilter.filter.name != getString(com.simplemobiletools.commons.R.string.none)) { + binding.defaultImageView.onGlobalLayout { applyFilter(currentFilter) } } else { @@ -241,19 +240,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } if (isCropIntent) { - bottom_primary_filter.beGone() - bottom_primary_draw.beGone() + binding.bottomEditorPrimaryActions.bottomPrimaryFilter.beGone() + binding.bottomEditorPrimaryActions.bottomPrimaryDraw.beGone() } return false } - }).into(default_image_view) + }).into(binding.defaultImageView) } private fun loadCropImageView() { - default_image_view.beGone() - editor_draw_canvas.beGone() - crop_image_view.apply { + binding.defaultImageView.beGone() + binding.editorDrawCanvas.beGone() + binding.cropImageView.apply { beVisible() setOnCropImageCompleteListener(this@EditActivity) setImageUriAsync(uri) @@ -262,19 +261,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (isCropIntent && shouldCropSquare()) { currAspectRatio = ASPECT_RATIO_ONE_ONE setFixedAspectRatio(true) - bottom_aspect_ratio.beGone() + binding.bottomEditorCropRotateActions.bottomAspectRatio.beGone() } } } private fun loadDrawCanvas() { - default_image_view.beGone() - crop_image_view.beGone() - editor_draw_canvas.beVisible() + binding.defaultImageView.beGone() + binding.cropImageView.beGone() + binding.editorDrawCanvas.beVisible() if (!wasDrawCanvasPositioned) { wasDrawCanvasPositioned = true - editor_draw_canvas.onGlobalLayout { + binding.editorDrawCanvas.onGlobalLayout { ensureBackgroundThread { fillCanvasBackground() } @@ -296,11 +295,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener .asBitmap() .load(uri) .apply(options) - .into(editor_draw_canvas.width, editor_draw_canvas.height) + .into(binding.editorDrawCanvas.width, binding.editorDrawCanvas.height) val bitmap = builder.get() runOnUiThread { - editor_draw_canvas.apply { + binding.editorDrawCanvas.apply { updateBackgroundBitmap(bitmap) layoutParams.width = bitmap.width layoutParams.height = bitmap.height @@ -317,10 +316,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun saveImage() { setOldExif() - if (crop_image_view.isVisible()) { - crop_image_view.croppedImageAsync() - } else if (editor_draw_canvas.isVisible()) { - val bitmap = editor_draw_canvas.getBitmap() + if (binding.cropImageView.isVisible()) { + binding.cropImageView.croppedImageAsync() + } else if (binding.editorDrawCanvas.isVisible()) { + val bitmap = binding.editorDrawCanvas.getBitmap() if (saveUri.scheme == "file") { SaveAsDialog(this, saveUri.path!!, true) { saveBitmapToFile(bitmap, it, true) @@ -335,13 +334,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener val currentFilter = getFiltersAdapter()?.getCurrentFilter() ?: return val filePathGetter = getNewFilePath() SaveAsDialog(this, filePathGetter.first, filePathGetter.second) { - toast(R.string.saving) + toast(com.simplemobiletools.commons.R.string.saving) // clean up everything to free as much memory as possible - default_image_view.setImageResource(0) - crop_image_view.setImageBitmap(null) - bottom_actions_filter_list.adapter = null - bottom_actions_filter_list.beGone() + binding.defaultImageView.setImageResource(0) + binding.cropImageView.setImageBitmap(null) + binding.bottomEditorFilterActions.bottomActionsFilterList.adapter = null + binding.bottomEditorFilterActions.bottomActionsFilterList.beGone() ensureBackgroundThread { try { @@ -349,7 +348,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener currentFilter.filter.processFilter(originalBitmap) saveBitmapToFile(originalBitmap, it, false) } catch (e: OutOfMemoryError) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) } } } @@ -373,10 +372,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun shareImage() { ensureBackgroundThread { when { - default_image_view.isVisible() -> { + binding.defaultImageView.isVisible() -> { val currentFilter = getFiltersAdapter()?.getCurrentFilter() if (currentFilter == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return@ensureBackgroundThread } @@ -384,13 +383,15 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener currentFilter.filter.processFilter(originalBitmap) shareBitmap(originalBitmap) } - crop_image_view.isVisible() -> { + + binding.cropImageView.isVisible() -> { isSharingBitmap = true runOnUiThread { - crop_image_view.croppedImageAsync() + binding.cropImageView.croppedImageAsync() } } - editor_draw_canvas.isVisible() -> shareBitmap(editor_draw_canvas.getBitmap()) + + binding.editorDrawCanvas.isVisible() -> shareBitmap(binding.editorDrawCanvas.getBitmap()) } } } @@ -430,12 +431,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (it != null) { sharePathIntent(it, BuildConfig.APPLICATION_ID) } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } - private fun getFiltersAdapter() = bottom_actions_filter_list.adapter as? FiltersAdapter + private fun getFiltersAdapter() = binding.bottomEditorFilterActions.bottomActionsFilterList.adapter as? FiltersAdapter private fun setupBottomActions() { setupPrimaryActionButtons() @@ -445,18 +446,22 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun setupPrimaryActionButtons() { - bottom_primary_filter.setOnClickListener { + binding.bottomEditorPrimaryActions.bottomPrimaryFilter.setOnClickListener { bottomFilterClicked() } - bottom_primary_crop_rotate.setOnClickListener { + binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate.setOnClickListener { bottomCropRotateClicked() } - bottom_primary_draw.setOnClickListener { + binding.bottomEditorPrimaryActions.bottomPrimaryDraw.setOnClickListener { bottomDrawClicked() } - arrayOf(bottom_primary_filter, bottom_primary_crop_rotate, bottom_primary_draw).forEach { + arrayOf( + binding.bottomEditorPrimaryActions.bottomPrimaryFilter, + binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate, + binding.bottomEditorPrimaryActions.bottomPrimaryDraw + ).forEach { setupLongPress(it) } } @@ -489,59 +494,65 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun setupCropRotateActionButtons() { - bottom_rotate.setOnClickListener { - crop_image_view.rotateImage(90) + binding.bottomEditorCropRotateActions.bottomRotate.setOnClickListener { + binding.cropImageView.rotateImage(90) } - bottom_resize.beGoneIf(isCropIntent) - bottom_resize.setOnClickListener { + binding.bottomEditorCropRotateActions.bottomResize.beGoneIf(isCropIntent) + binding.bottomEditorCropRotateActions.bottomResize.setOnClickListener { resizeImage() } - bottom_flip_horizontally.setOnClickListener { - crop_image_view.flipImageHorizontally() + binding.bottomEditorCropRotateActions.bottomFlipHorizontally.setOnClickListener { + binding.cropImageView.flipImageHorizontally() } - bottom_flip_vertically.setOnClickListener { - crop_image_view.flipImageVertically() + binding.bottomEditorCropRotateActions.bottomFlipVertically.setOnClickListener { + binding.cropImageView.flipImageVertically() } - bottom_aspect_ratio.setOnClickListener { + binding.bottomEditorCropRotateActions.bottomAspectRatio.setOnClickListener { currCropRotateAction = if (currCropRotateAction == CROP_ROTATE_ASPECT_RATIO) { - crop_image_view.guidelines = CropImageView.Guidelines.OFF - bottom_aspect_ratios.beGone() + binding.cropImageView.guidelines = CropImageView.Guidelines.OFF + binding.bottomAspectRatios.root.beGone() CROP_ROTATE_NONE } else { - crop_image_view.guidelines = CropImageView.Guidelines.ON - bottom_aspect_ratios.beVisible() + binding.cropImageView.guidelines = CropImageView.Guidelines.ON + binding.bottomAspectRatios.root.beVisible() CROP_ROTATE_ASPECT_RATIO } updateCropRotateActionButtons() } - arrayOf(bottom_rotate, bottom_resize, bottom_flip_horizontally, bottom_flip_vertically, bottom_aspect_ratio).forEach { + arrayOf( + binding.bottomEditorCropRotateActions.bottomRotate, + binding.bottomEditorCropRotateActions.bottomResize, + binding.bottomEditorCropRotateActions.bottomFlipHorizontally, + binding.bottomEditorCropRotateActions.bottomFlipVertically, + binding.bottomEditorCropRotateActions.bottomAspectRatio + ).forEach { setupLongPress(it) } } private fun setupAspectRatioButtons() { - bottom_aspect_ratio_free.setOnClickListener { + binding.bottomAspectRatios.bottomAspectRatioFree.setOnClickListener { updateAspectRatio(ASPECT_RATIO_FREE) } - bottom_aspect_ratio_one_one.setOnClickListener { + binding.bottomAspectRatios.bottomAspectRatioOneOne.setOnClickListener { updateAspectRatio(ASPECT_RATIO_ONE_ONE) } - bottom_aspect_ratio_four_three.setOnClickListener { + binding.bottomAspectRatios.bottomAspectRatioFourThree.setOnClickListener { updateAspectRatio(ASPECT_RATIO_FOUR_THREE) } - bottom_aspect_ratio_sixteen_nine.setOnClickListener { + binding.bottomAspectRatios.bottomAspectRatioSixteenNine.setOnClickListener { updateAspectRatio(ASPECT_RATIO_SIXTEEN_NINE) } - bottom_aspect_ratio_other.setOnClickListener { + binding.bottomAspectRatios.bottomAspectRatioOther.setOnClickListener { OtherAspectRatioDialog(this, lastOtherAspectRatio) { lastOtherAspectRatio = it config.lastEditorCropOtherAspectRatioX = it.first @@ -555,10 +566,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun setupDrawButtons() { updateDrawColor(config.lastEditorDrawColor) - bottom_draw_width.progress = config.lastEditorBrushSize + binding.bottomEditorDrawActions.bottomDrawWidth.progress = config.lastEditorBrushSize updateBrushSize(config.lastEditorBrushSize) - bottom_draw_color_clickable.setOnClickListener { + binding.bottomEditorDrawActions.bottomDrawColorClickable.setOnClickListener { ColorPickerDialog(this, drawColor) { wasPositivePressed, color -> if (wasPositivePressed) { updateDrawColor(color) @@ -566,49 +577,53 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } - bottom_draw_width.onSeekBarChangeListener { + binding.bottomEditorDrawActions.bottomDrawWidth.onSeekBarChangeListener { config.lastEditorBrushSize = it updateBrushSize(it) } - bottom_draw_undo.setOnClickListener { - editor_draw_canvas.undo() + binding.bottomEditorDrawActions.bottomDrawUndo.setOnClickListener { + binding.editorDrawCanvas.undo() } } private fun updateBrushSize(percent: Int) { - editor_draw_canvas.updateBrushSize(percent) - val scale = Math.max(0.03f, percent / 100f) - bottom_draw_color.scaleX = scale - bottom_draw_color.scaleY = scale + binding.editorDrawCanvas.updateBrushSize(percent) + val scale = max(0.03f, percent / 100f) + binding.bottomEditorDrawActions.bottomDrawColor.scaleX = scale + binding.bottomEditorDrawActions.bottomDrawColor.scaleY = scale } private fun updatePrimaryActionButtons() { - if (crop_image_view.isGone() && currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) { + if (binding.cropImageView.isGone() && currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) { loadCropImageView() - } else if (default_image_view.isGone() && currPrimaryAction == PRIMARY_ACTION_FILTER) { + } else if (binding.defaultImageView.isGone() && currPrimaryAction == PRIMARY_ACTION_FILTER) { loadDefaultImageView() - } else if (editor_draw_canvas.isGone() && currPrimaryAction == PRIMARY_ACTION_DRAW) { + } else if (binding.editorDrawCanvas.isGone() && currPrimaryAction == PRIMARY_ACTION_DRAW) { loadDrawCanvas() } - arrayOf(bottom_primary_filter, bottom_primary_crop_rotate, bottom_primary_draw).forEach { + arrayOf( + binding.bottomEditorPrimaryActions.bottomPrimaryFilter, + binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate, + binding.bottomEditorPrimaryActions.bottomPrimaryDraw + ).forEach { it.applyColorFilter(Color.WHITE) } val currentPrimaryActionButton = when (currPrimaryAction) { - PRIMARY_ACTION_FILTER -> bottom_primary_filter - PRIMARY_ACTION_CROP_ROTATE -> bottom_primary_crop_rotate - PRIMARY_ACTION_DRAW -> bottom_primary_draw + PRIMARY_ACTION_FILTER -> binding.bottomEditorPrimaryActions.bottomPrimaryFilter + PRIMARY_ACTION_CROP_ROTATE -> binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate + PRIMARY_ACTION_DRAW -> binding.bottomEditorPrimaryActions.bottomPrimaryDraw else -> null } currentPrimaryActionButton?.applyColorFilter(getProperPrimaryColor()) - bottom_editor_filter_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER) - bottom_editor_crop_rotate_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) - bottom_editor_draw_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_DRAW) + binding.bottomEditorFilterActions.root.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER) + binding.bottomEditorCropRotateActions.root.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) + binding.bottomEditorDrawActions.root.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_DRAW) - if (currPrimaryAction == PRIMARY_ACTION_FILTER && bottom_actions_filter_list.adapter == null) { + if (currPrimaryAction == PRIMARY_ACTION_FILTER && binding.bottomEditorFilterActions.bottomActionsFilterList.adapter == null) { ensureBackgroundThread { val thumbnailSize = resources.getDimension(R.dimen.bottom_filters_thumbnail_size).toInt() @@ -641,7 +656,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener val filterThumbnailsManager = FilterThumbnailsManager() filterThumbnailsManager.clearThumbs() - val noFilter = Filter(getString(R.string.none)) + val noFilter = Filter(getString(com.simplemobiletools.commons.R.string.none)) filterThumbnailsManager.addThumb(FilterItem(bitmap, noFilter)) FilterPack.getFilterPack(this).forEach { @@ -651,24 +666,24 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener val filterItems = filterThumbnailsManager.processThumbs() val adapter = FiltersAdapter(applicationContext, filterItems) { - val layoutManager = bottom_actions_filter_list.layoutManager as LinearLayoutManager + val layoutManager = binding.bottomEditorFilterActions.bottomActionsFilterList.layoutManager as LinearLayoutManager applyFilter(filterItems[it]) if (it == layoutManager.findLastCompletelyVisibleItemPosition() || it == layoutManager.findLastVisibleItemPosition()) { - bottom_actions_filter_list.smoothScrollBy(thumbnailSize, 0) + binding.bottomEditorFilterActions.bottomActionsFilterList.smoothScrollBy(thumbnailSize, 0) } else if (it == layoutManager.findFirstCompletelyVisibleItemPosition() || it == layoutManager.findFirstVisibleItemPosition()) { - bottom_actions_filter_list.smoothScrollBy(-thumbnailSize, 0) + binding.bottomEditorFilterActions.bottomActionsFilterList.smoothScrollBy(-thumbnailSize, 0) } } - bottom_actions_filter_list.adapter = adapter + binding.bottomEditorFilterActions.bottomActionsFilterList.adapter = adapter adapter.notifyDataSetChanged() } } } if (currPrimaryAction != PRIMARY_ACTION_CROP_ROTATE) { - bottom_aspect_ratios.beGone() + binding.bottomAspectRatios.root.beGone() currCropRotateAction = CROP_ROTATE_NONE } updateCropRotateActionButtons() @@ -676,7 +691,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun applyFilter(filterItem: FilterItem) { val newBitmap = Bitmap.createBitmap(filterInitialBitmap!!) - default_image_view.setImageBitmap(filterItem.filter.processFilter(newBitmap)) + binding.defaultImageView.setImageBitmap(filterItem.filter.processFilter(newBitmap)) } private fun updateAspectRatio(aspectRatio: Int) { @@ -684,7 +699,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener config.lastEditorCropAspectRatio = aspectRatio updateAspectRatioButtons() - crop_image_view.apply { + binding.cropImageView.apply { if (aspectRatio == ASPECT_RATIO_FREE) { setFixedAspectRatio(false) } else { @@ -702,33 +717,33 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun updateAspectRatioButtons() { arrayOf( - bottom_aspect_ratio_free, - bottom_aspect_ratio_one_one, - bottom_aspect_ratio_four_three, - bottom_aspect_ratio_sixteen_nine, - bottom_aspect_ratio_other + binding.bottomAspectRatios.bottomAspectRatioFree, + binding.bottomAspectRatios.bottomAspectRatioOneOne, + binding.bottomAspectRatios.bottomAspectRatioFourThree, + binding.bottomAspectRatios.bottomAspectRatioSixteenNine, + binding.bottomAspectRatios.bottomAspectRatioOther, ).forEach { it.setTextColor(Color.WHITE) } val currentAspectRatioButton = when (currAspectRatio) { - ASPECT_RATIO_FREE -> bottom_aspect_ratio_free - ASPECT_RATIO_ONE_ONE -> bottom_aspect_ratio_one_one - ASPECT_RATIO_FOUR_THREE -> bottom_aspect_ratio_four_three - ASPECT_RATIO_SIXTEEN_NINE -> bottom_aspect_ratio_sixteen_nine - else -> bottom_aspect_ratio_other + ASPECT_RATIO_FREE -> binding.bottomAspectRatios.bottomAspectRatioFree + ASPECT_RATIO_ONE_ONE -> binding.bottomAspectRatios.bottomAspectRatioOneOne + ASPECT_RATIO_FOUR_THREE -> binding.bottomAspectRatios.bottomAspectRatioFourThree + ASPECT_RATIO_SIXTEEN_NINE -> binding.bottomAspectRatios.bottomAspectRatioSixteenNine + else -> binding.bottomAspectRatios.bottomAspectRatioOther } currentAspectRatioButton.setTextColor(getProperPrimaryColor()) } private fun updateCropRotateActionButtons() { - arrayOf(bottom_aspect_ratio).forEach { + arrayOf(binding.bottomEditorCropRotateActions.bottomAspectRatio).forEach { it.applyColorFilter(Color.WHITE) } val primaryActionView = when (currCropRotateAction) { - CROP_ROTATE_ASPECT_RATIO -> bottom_aspect_ratio + CROP_ROTATE_ASPECT_RATIO -> binding.bottomEditorCropRotateActions.bottomAspectRatio else -> null } @@ -737,22 +752,22 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun updateDrawColor(color: Int) { drawColor = color - bottom_draw_color.applyColorFilter(color) + binding.bottomEditorDrawActions.bottomDrawColor.applyColorFilter(color) config.lastEditorDrawColor = color - editor_draw_canvas.updateColor(color) + binding.editorDrawCanvas.updateColor(color) } private fun resizeImage() { val point = getAreaSize() if (point == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } ResizeDialog(this, point) { resizeWidth = it.x resizeHeight = it.y - crop_image_view.croppedImageAsync() + binding.cropImageView.croppedImageAsync() } } @@ -766,8 +781,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun getAreaSize(): Point? { - val rect = crop_image_view.cropRect ?: return null - val rotation = crop_image_view.rotatedDegrees + val rect = binding.cropImageView.cropRect ?: return null + val rotation = binding.cropImageView.rotatedDegrees return if (rotation == 0 || rotation == 180) { Point(rect.width(), rect.height()) } else { @@ -861,7 +876,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener val label = "sknahT .moc.slootelibomelpmis.www morf eno lanigiro eht daolnwod ytefas nwo ruoy roF .ppa eht fo noisrev ekaf a gnisu era uoY".reversed() runOnUiThread { - ConfirmationDialog(this, label, positive = R.string.ok, negative = 0) { + ConfirmationDialog(this, label, positive = com.simplemobiletools.commons.R.string.ok, negative = 0) { launchViewIntent("6629852208836920709=di?ved/sppa/erots/moc.elgoog.yalp//:sptth".reversed()) } } @@ -889,14 +904,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } catch (e: Exception) { showErrorToast(e) } catch (e: OutOfMemoryError) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) } } @TargetApi(Build.VERSION_CODES.N) private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) { if (showSavingToast) { - toast(R.string.saving) + toast(com.simplemobiletools.commons.R.string.saving) } if (resizeWidth > 0 && resizeHeight > 0) { @@ -929,7 +944,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener rescanPaths(paths) { fixDateTaken(paths, false) setResult(Activity.RESULT_OK, intent) - toast(R.string.file_saved) + toast(com.simplemobiletools.commons.R.string.file_saved) finish() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt index 25ac18699..99d98562f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt @@ -11,33 +11,36 @@ import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter +import com.simplemobiletools.gallery.pro.databinding.ActivityManageFoldersBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.activity_manage_folders.* class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { + private lateinit var binding: ActivityManageFoldersBinding + override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_manage_folders) + binding = ActivityManageFoldersBinding.inflate(layoutInflater) + setContentView(binding.root) updateFolders() setupOptionsMenu() - manage_folders_toolbar.title = getString(R.string.excluded_folders) + binding.manageFoldersToolbar.title = getString(com.simplemobiletools.commons.R.string.excluded_folders) - updateMaterialActivityViews(manage_folders_coordinator, manage_folders_list, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar) + updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false) + setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar) } override fun onResume() { super.onResume() - setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow) + setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow) } private fun updateFolders() { val folders = ArrayList() config.excludedFolders.mapTo(folders) { it } var placeholderText = getString(R.string.excluded_activity_placeholder) - manage_folders_placeholder.apply { + binding.manageFoldersPlaceholder.apply { beVisibleIf(folders.isEmpty()) setTextColor(getProperTextColor()) @@ -48,12 +51,12 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { text = placeholderText } - val adapter = ManageFoldersAdapter(this, folders, true, this, manage_folders_list) {} - manage_folders_list.adapter = adapter + val adapter = ManageFoldersAdapter(this, folders, true, this, binding.manageFoldersList) {} + binding.manageFoldersList.adapter = adapter } private fun setupOptionsMenu() { - manage_folders_toolbar.setOnMenuItemClickListener { menuItem -> + binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.add_folder -> addFolder() else -> return@setOnMenuItemClickListener false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt index 0e1b03531..456793bde 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/HiddenFoldersActivity.kt @@ -9,47 +9,49 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.ManageHiddenFoldersAdapter +import com.simplemobiletools.gallery.pro.databinding.ActivityManageFoldersBinding import com.simplemobiletools.gallery.pro.extensions.addNoMedia import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.getNoMediaFolders -import kotlinx.android.synthetic.main.activity_manage_folders.* class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { + private lateinit var binding: ActivityManageFoldersBinding override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_manage_folders) + binding = ActivityManageFoldersBinding.inflate(layoutInflater) + setContentView(binding.root) updateFolders() setupOptionsMenu() - manage_folders_toolbar.title = getString(R.string.hidden_folders) + binding.manageFoldersToolbar.title = getString(R.string.hidden_folders) - updateMaterialActivityViews(manage_folders_coordinator, manage_folders_list, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar) + updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false) + setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar) } override fun onResume() { super.onResume() - setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow) + setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow) } private fun updateFolders() { getNoMediaFolders { runOnUiThread { - manage_folders_placeholder.apply { + binding.manageFoldersPlaceholder.apply { text = getString(R.string.hidden_folders_placeholder) beVisibleIf(it.isEmpty()) setTextColor(getProperTextColor()) } - val adapter = ManageHiddenFoldersAdapter(this, it, this, manage_folders_list) {} - manage_folders_list.adapter = adapter + val adapter = ManageHiddenFoldersAdapter(this, it, this, binding.manageFoldersList) {} + binding.manageFoldersList.adapter = adapter } } } private fun setupOptionsMenu() { - manage_folders_toolbar.setOnMenuItemClickListener { menuItem -> + binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.add_folder -> addFolder() else -> return@setOnMenuItemClickListener false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt index 14deab9ef..640dc878e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt @@ -7,43 +7,46 @@ import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter +import com.simplemobiletools.gallery.pro.databinding.ActivityManageFoldersBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.activity_manage_folders.* class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { + private lateinit var binding: ActivityManageFoldersBinding + override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_manage_folders) + binding = ActivityManageFoldersBinding.inflate(layoutInflater) + setContentView(binding.root) updateFolders() setupOptionsMenu() - manage_folders_toolbar.title = getString(R.string.include_folders) + binding.manageFoldersToolbar.title = getString(R.string.include_folders) - updateMaterialActivityViews(manage_folders_coordinator, manage_folders_list, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar) + updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false) + setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar) } override fun onResume() { super.onResume() - setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow) + setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow) } private fun updateFolders() { val folders = ArrayList() config.includedFolders.mapTo(folders) { it } - manage_folders_placeholder.apply { + binding.manageFoldersPlaceholder.apply { text = getString(R.string.included_activity_placeholder) beVisibleIf(folders.isEmpty()) setTextColor(getProperTextColor()) } - val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {} - manage_folders_list.adapter = adapter + val adapter = ManageFoldersAdapter(this, folders, false, this, binding.manageFoldersList) {} + binding.manageFoldersList.adapter = adapter } private fun setupOptionsMenu() { - manage_folders_toolbar.setOnMenuItemClickListener { menuItem -> + binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.add_folder -> addFolder() else -> return@setOnMenuItemClickListener false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index f1c9e9ff0..6d9687847 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter import com.simplemobiletools.gallery.pro.databases.GalleryDatabase +import com.simplemobiletools.gallery.pro.databinding.ActivityMainBinding import com.simplemobiletools.gallery.pro.dialogs.ChangeSortingDialog import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog @@ -38,13 +39,14 @@ import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener import com.simplemobiletools.gallery.pro.jobs.NewPhotoFetcher import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium -import kotlinx.android.synthetic.main.activity_main.* import java.io.* class MainActivity : SimpleActivity(), DirectoryOperationsListener { - private val PICK_MEDIA = 2 - private val PICK_WALLPAPER = 3 - private val LAST_MEDIA_CHECK_PERIOD = 3000L + companion object { + private const val PICK_MEDIA = 2 + private const val PICK_WALLPAPER = 3 + private const val LAST_MEDIA_CHECK_PERIOD = 3000L + } private var mIsPickImageIntent = false private var mIsPickVideoIntent = false @@ -81,11 +83,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private var mStoredTextColor = 0 private var mStoredPrimaryColor = 0 private var mStoredStyleString = "" + private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) appLaunched(BuildConfig.APPLICATION_ID) if (savedInstanceState == null) { @@ -111,9 +115,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupOptionsMenu() refreshMenuItems() - updateMaterialActivityViews(directories_coordinator, directories_grid, useTransparentNavigation = !config.scrollHorizontally, useTopSearchMenu = true) + updateMaterialActivityViews( + binding.directoriesCoordinator, + binding.directoriesGrid, + useTransparentNavigation = !config.scrollHorizontally, + useTopSearchMenu = true + ) - directories_refresh_layout.setOnRefreshListener { getDirectories() } + binding.directoriesRefreshLayout.setOnRefreshListener { getDirectories() } storeStateVariables() checkWhatsNewDialog() @@ -146,32 +155,25 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { updateWidgets() registerFileUpdateListener() - directories_switch_searching.setOnClickListener { + binding.directoriesSwitchSearching.setOnClickListener { launchSearchActivity() } // just request the permission, tryLoadGallery will then trigger in onResume handleMediaPermissions { success -> if (!success) { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } } - private fun handleMediaPermissions(callback: (granted: Boolean) -> Unit) { - handlePermission(getPermissionToRequest()) { granted -> - callback(granted) - if (granted && isRPlus()) { - handlePermission(PERMISSION_MEDIA_LOCATION) {} - if (isTiramisuPlus()) { - handlePermission(PERMISSION_READ_MEDIA_VIDEO) {} - } - - if (!mWasMediaManagementPromptShown) { - mWasMediaManagementPromptShown = true - handleMediaManagementPrompt { } - } + private fun handleMediaPermissions(force: Boolean = false, callback: (granted: Boolean) -> Unit) { + handlePartialMediaPermissions(getPermissionsToRequest(), force) { + callback(it) + if (!mWasMediaManagementPromptShown) { + mWasMediaManagementPromptShown = true + handleMediaManagementPrompt { } } } } @@ -200,7 +202,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mStoredScrollHorizontally != config.scrollHorizontally) { mLoadedInitialPhotos = false - directories_grid.adapter = null + binding.directoriesGrid.adapter = null getDirectories() } @@ -218,20 +220,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupAdapter(mDirs, forceRecreate = true) } - directories_fastscroller.updateColors(primaryColor) - directories_refresh_layout.isEnabled = config.enablePullToRefresh + binding.directoriesFastscroller.updateColors(primaryColor) + binding.directoriesRefreshLayout.isEnabled = config.enablePullToRefresh getRecyclerAdapter()?.apply { dateFormat = config.dateFormat timeFormat = getTimeFormat() } - directories_empty_placeholder.setTextColor(getProperTextColor()) - directories_empty_placeholder_2.setTextColor(primaryColor) - directories_switch_searching.setTextColor(primaryColor) - directories_switch_searching.underlineText() - directories_empty_placeholder_2.bringToFront() + binding.directoriesEmptyPlaceholder.setTextColor(getProperTextColor()) + binding.directoriesEmptyPlaceholder2.setTextColor(primaryColor) + binding.directoriesSwitchSearching.setTextColor(primaryColor) + binding.directoriesSwitchSearching.underlineText() + binding.directoriesEmptyPlaceholder2.bringToFront() - if (!main_menu.isSearchOpen) { + if (!binding.mainMenu.isSearchOpen) { refreshMenuItems() if (mIsPasswordProtectionPending && !mWasProtectionHandled) { handleAppPasswordProtection { @@ -249,15 +251,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } if (config.searchAllFilesByDefault) { - main_menu.updateHintText(getString(R.string.search_files)) + binding.mainMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_files)) } else { - main_menu.updateHintText(getString(R.string.search_folders)) + binding.mainMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_folders)) } } override fun onPause() { super.onPause() - directories_refresh_layout.isRefreshing = false + binding.directoriesRefreshLayout.isRefreshing = false mIsGettingDirs = false storeStateVariables() mLastMediaHandler.removeCallbacksAndMessages(null) @@ -297,8 +299,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } override fun onBackPressed() { - if (main_menu.isSearchOpen) { - main_menu.closeSearch() + if (binding.mainMenu.isSearchOpen) { + binding.mainMenu.closeSearch() } else if (config.groupDirectSubfolders) { if (mCurrentPathPrefix.isEmpty()) { super.onBackPressed() @@ -345,15 +347,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun refreshMenuItems() { if (!mIsThirdPartyIntent) { - main_menu.getToolbar().menu.apply { + binding.mainMenu.getToolbar().menu.apply { findItem(R.id.column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty() findItem(R.id.open_recycle_bin).isVisible = config.useRecycleBin && !config.showRecycleBinAtFolders - findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations) + findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations) } } - main_menu.getToolbar().menu.apply { + binding.mainMenu.getToolbar().menu.apply { findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden @@ -369,23 +371,23 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { R.menu.menu_main } - main_menu.getToolbar().inflateMenu(menuId) - main_menu.toggleHideOnScroll(!config.scrollHorizontally) - main_menu.setupMenu() + binding.mainMenu.getToolbar().inflateMenu(menuId) + binding.mainMenu.toggleHideOnScroll(!config.scrollHorizontally) + binding.mainMenu.setupMenu() - main_menu.onSearchOpenListener = { + binding.mainMenu.onSearchOpenListener = { if (config.searchAllFilesByDefault) { launchSearchActivity() } } - main_menu.onSearchTextChangedListener = { text -> + binding.mainMenu.onSearchTextChangedListener = { text -> setupAdapter(mDirsIgnoringSearch, text) - directories_refresh_layout.isEnabled = text.isEmpty() && config.enablePullToRefresh - directories_switch_searching.beVisibleIf(text.isNotEmpty()) + binding.directoriesRefreshLayout.isEnabled = text.isEmpty() && config.enablePullToRefresh + binding.directoriesSwitchSearching.beVisibleIf(text.isNotEmpty()) } - main_menu.getToolbar().setOnMenuItemClickListener { menuItem -> + binding.mainMenu.getToolbar().setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.sort -> showSortingDialog() R.id.filter -> showFilterMediaDialog() @@ -396,6 +398,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded() R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded() + R.id.access_more_media -> handleMediaPermissions(force = true) { } R.id.create_new_folder -> createNewFolder() R.id.open_recycle_bin -> openRecycleBin() R.id.column_count -> changeColumnCount() @@ -421,10 +424,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun updateMenuColors() { updateStatusbarColor(getProperBackgroundColor()) - main_menu.updateColors() + binding.mainMenu.updateColors() } - private fun getRecyclerAdapter() = directories_grid.adapter as? DirectoryAdapter + private fun getRecyclerAdapter() = binding.directoriesGrid.adapter as? DirectoryAdapter private fun storeStateVariables() { mStoredTextColor = getProperTextColor() @@ -451,7 +454,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val newFolder = File(config.tempFolderPath) if (getDoesFilePathExist(newFolder.absolutePath) && newFolder.isDirectory) { if (newFolder.getProperSize(true) == 0L && newFolder.getFileCount(true) == 0 && newFolder.list()?.isEmpty() == true) { - toast(String.format(getString(R.string.deleting_folder), config.tempFolderPath), Toast.LENGTH_LONG) + toast(String.format(getString(com.simplemobiletools.commons.R.string.deleting_folder), config.tempFolderPath), Toast.LENGTH_LONG) tryDeleteFileDirItem(newFolder.toFileDirItem(applicationContext), true, true) } } @@ -503,7 +506,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } if (isPackageInstalled("com.simplemobiletools.gallery")) { - ConfirmationDialog(this, "", R.string.upgraded_from_free_gallery, R.string.ok, 0, false) {} + ConfirmationDialog( + this, + "", + com.simplemobiletools.commons.R.string.upgraded_from_free_gallery, + com.simplemobiletools.commons.R.string.ok, + 0, + false + ) {} } checkOTGPath() @@ -517,7 +527,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupLayoutManager() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -544,14 +554,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { startActivity(this) } - main_menu.postDelayed({ - main_menu.closeSearch() + binding.mainMenu.postDelayed({ + binding.mainMenu.closeSearch() }, 500) } private fun showSortingDialog() { ChangeSortingDialog(this, true, false) { - directories_grid.adapter = null + binding.directoriesGrid.adapter = null if (config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || config.directorySorting and SORT_BY_DATE_TAKEN != 0) { getDirectories() } else { @@ -567,8 +577,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun showFilterMediaDialog() { FilterMediaDialog(this) { mShouldStopFetching = true - directories_refresh_layout.isRefreshing = true - directories_grid.adapter = null + binding.directoriesRefreshLayout.isRefreshing = true + binding.directoriesGrid.adapter = null getDirectories() } } @@ -592,7 +602,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { ChangeViewTypeDialog(this, true) { refreshMenuItems() setupLayoutManager() - directories_grid.adapter = null + binding.directoriesGrid.adapter = null setupAdapter(getRecyclerAdapter()?.dirs ?: mDirs) } } @@ -614,7 +624,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun toggleTemporarilyShowHidden(show: Boolean) { mLoadedInitialPhotos = false config.temporarilyShowHidden = show - directories_grid.adapter = null + binding.directoriesGrid.adapter = null getDirectories() refreshMenuItems() } @@ -632,7 +642,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun toggleTemporarilyShowExcluded(show: Boolean) { mLoadedInitialPhotos = false config.temporarilyShowExcluded = show - directories_grid.adapter = null + binding.directoriesGrid.adapter = null getDirectories() refreshMenuItems() } @@ -644,14 +654,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { fileDirItems.isEmpty() -> return fileDirItems.size == 1 -> { try { - toast(String.format(getString(R.string.deleting_folder), fileDirItems.first().name)) + toast(String.format(getString(com.simplemobiletools.commons.R.string.deleting_folder), fileDirItems.first().name)) } catch (e: Exception) { showErrorToast(e) } } else -> { - val baseString = if (config.useRecycleBin && !config.tempSkipRecycleBin) R.plurals.moving_items_into_bin else R.plurals.delete_items + val baseString = + if (config.useRecycleBin && !config.tempSkipRecycleBin) com.simplemobiletools.commons.R.plurals.moving_items_into_bin else com.simplemobiletools.commons.R.plurals.delete_items val deletingItems = resources.getQuantityString(baseString, fileDirItems.size, fileDirItems.size) toast(deletingItems) } @@ -680,7 +691,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (it) { deleteFilteredFileDirItems(itemsToDelete, folders) } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } else { @@ -717,33 +728,35 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupListLayoutManager() } - (directories_refresh_layout.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.BELOW, R.id.directories_switch_searching) + (binding.directoriesRefreshLayout.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.BELOW, R.id.directories_switch_searching) } private fun setupGridLayoutManager() { - val layoutManager = directories_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = RecyclerView.HORIZONTAL - directories_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) + binding.directoriesRefreshLayout.layoutParams = + RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) } else { layoutManager.orientation = RecyclerView.VERTICAL - directories_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + binding.directoriesRefreshLayout.layoutParams = + RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } layoutManager.spanCount = config.dirColumnCnt } private fun setupListLayoutManager() { - val layoutManager = directories_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager layoutManager.spanCount = 1 layoutManager.orientation = RecyclerView.VERTICAL - directories_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + binding.directoriesRefreshLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) mZoomListener = null } private fun initZoomListener() { if (config.viewTypeFolders == VIEW_TYPE_GRID) { - val layoutManager = directories_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager mZoomListener = object : MyRecyclerView.MyZoomListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { @@ -778,10 +791,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun changeColumnCount() { val items = ArrayList() for (i in 1..MAX_COLUMN_COUNT) { - items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i))) + items.add(RadioItem(i, resources.getQuantityString(com.simplemobiletools.commons.R.plurals.column_counts, i, i))) } - val currentColumnCount = (directories_grid.layoutManager as MyGridLayoutManager).spanCount + val currentColumnCount = (binding.directoriesGrid.layoutManager as MyGridLayoutManager).spanCount RadioGroupDialog(this, items, currentColumnCount) { val newColumnCount = it as Int if (currentColumnCount != newColumnCount) { @@ -802,7 +815,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun columnCountChanged() { - (directories_grid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt + (binding.directoriesGrid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt refreshMenuItems() getRecyclerAdapter()?.apply { notifyItemRangeChanged(0, dirs.size) @@ -953,7 +966,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mediaDB.getDeletedMediaCount() > 0) { val recycleBin = Directory().apply { path = RECYCLE_BIN - name = getString(R.string.recycle_bin) + name = getString(com.simplemobiletools.commons.R.string.recycle_bin) location = LOCATION_INTERNAL } @@ -967,7 +980,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mediaDB.getFavoritesCount() > 0) { val favorites = Directory().apply { path = FAVORITES - name = getString(R.string.favorites) + name = getString(com.simplemobiletools.commons.R.string.favorites) location = LOCATION_INTERNAL } @@ -1114,9 +1127,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (isPlaceholderVisible) { isPlaceholderVisible = false runOnUiThread { - directories_empty_placeholder.beGone() - directories_empty_placeholder_2.beGone() - directories_fastscroller.beVisible() + binding.directoriesEmptyPlaceholder.beGone() + binding.directoriesEmptyPlaceholder2.beGone() + binding.directoriesFastscroller.beVisible() } } @@ -1142,7 +1155,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } runOnUiThread { - directories_refresh_layout.isRefreshing = false + binding.directoriesRefreshLayout.isRefreshing = false checkPlaceholderVisibility(dirs) } @@ -1201,41 +1214,41 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun checkPlaceholderVisibility(dirs: ArrayList) { - directories_empty_placeholder.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) - directories_empty_placeholder_2.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) + binding.directoriesEmptyPlaceholder.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) + binding.directoriesEmptyPlaceholder2.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) - if (main_menu.isSearchOpen) { - directories_empty_placeholder.text = getString(R.string.no_items_found) - directories_empty_placeholder_2.beGone() + if (binding.mainMenu.isSearchOpen) { + binding.directoriesEmptyPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found) + binding.directoriesEmptyPlaceholder2.beGone() } else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) { if (isRPlus() && !isExternalStorageManager()) { - directories_empty_placeholder.text = getString(R.string.no_items_found) - directories_empty_placeholder_2.beGone() + binding.directoriesEmptyPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found) + binding.directoriesEmptyPlaceholder2.beGone() } else { - directories_empty_placeholder.text = getString(R.string.no_media_add_included) - directories_empty_placeholder_2.text = getString(R.string.add_folder) + binding.directoriesEmptyPlaceholder.text = getString(R.string.no_media_add_included) + binding.directoriesEmptyPlaceholder2.text = getString(R.string.add_folder) } - directories_empty_placeholder_2.setOnClickListener { + binding.directoriesEmptyPlaceholder2.setOnClickListener { showAddIncludedFolderDialog { refreshItems() } } } else { - directories_empty_placeholder.text = getString(R.string.no_media_with_filters) - directories_empty_placeholder_2.text = getString(R.string.change_filters_underlined) + binding.directoriesEmptyPlaceholder.text = getString(R.string.no_media_with_filters) + binding.directoriesEmptyPlaceholder2.text = getString(R.string.change_filters_underlined) - directories_empty_placeholder_2.setOnClickListener { + binding.directoriesEmptyPlaceholder2.setOnClickListener { showFilterMediaDialog() } } - directories_empty_placeholder_2.underlineText() - directories_fastscroller.beVisibleIf(directories_empty_placeholder.isGone()) + binding.directoriesEmptyPlaceholder2.underlineText() + binding.directoriesFastscroller.beVisibleIf(binding.directoriesEmptyPlaceholder.isGone()) } - private fun setupAdapter(dirs: ArrayList, textToSearch: String = main_menu.getCurrentQuery(), forceRecreate: Boolean = false) { - val currAdapter = directories_grid.adapter + private fun setupAdapter(dirs: ArrayList, textToSearch: String = binding.mainMenu.getCurrentQuery(), forceRecreate: Boolean = false) { + val currAdapter = binding.directoriesGrid.adapter val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList val sortedDirs = getSortedDirectories(distinctDirs) var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList @@ -1247,9 +1260,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { this, dirsToShow, this, - directories_grid, + binding.directoriesGrid, isPickIntent(intent) || isGetAnyContentIntent(intent), - directories_refresh_layout + binding.directoriesRefreshLayout ) { val clickedDir = it as Directory val path = clickedDir.path @@ -1265,11 +1278,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { }.apply { setupZoomListener(mZoomListener) runOnUiThread { - directories_grid.adapter = this + binding.directoriesGrid.adapter = this setupScrollDirection() if (config.viewTypeFolders == VIEW_TYPE_LIST && areSystemAnimationsEnabled) { - directories_grid.scheduleLayoutAnimation() + binding.directoriesGrid.scheduleLayoutAnimation() } } } @@ -1281,19 +1294,19 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } checkPlaceholderVisibility(dirsToShow) - (directories_grid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) + (binding.directoriesGrid.adapter as? DirectoryAdapter)?.updateDirs(dirsToShow) } } // recyclerview sometimes becomes empty at init/update, triggering an invisible refresh like this seems to work fine - directories_grid.postDelayed({ - directories_grid.scrollBy(0, 0) + binding.directoriesGrid.postDelayed({ + binding.directoriesGrid.scrollBy(0, 0) }, 500) } private fun setupScrollDirection() { val scrollHorizontally = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID - directories_fastscroller.setScrollVertically(!scrollHorizontally) + binding.directoriesFastscroller.setScrollVertically(!scrollHorizontally) } private fun checkInvalidDirectories(dirs: ArrayList) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 9738a8bfd..c7c17de7a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.MediaAdapter import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask import com.simplemobiletools.gallery.pro.databases.GalleryDatabase +import com.simplemobiletools.gallery.pro.databinding.ActivityMediaBinding import com.simplemobiletools.gallery.pro.dialogs.* import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* @@ -35,7 +36,6 @@ import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection -import kotlinx.android.synthetic.main.activity_media.* import java.io.File import java.io.IOException @@ -70,6 +70,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private var mStoredPrimaryColor = 0 private var mStoredThumbnailSpacing = 0 + private lateinit var binding: ActivityMediaBinding + companion object { var mMedia = ArrayList() } @@ -77,7 +79,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_media) + binding = ActivityMediaBinding.inflate(layoutInflater) + setContentView(binding.root) intent.apply { mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false) @@ -86,7 +89,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { mAllowPickingMultiple = getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) } - media_refresh_layout.setOnRefreshListener { getMedia() } + binding.mediaRefreshLayout.setOnRefreshListener { getMedia() } try { mPath = intent.getStringExtra(DIRECTORY) ?: "" } catch (e: Exception) { @@ -98,17 +101,24 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { setupOptionsMenu() refreshMenuItems() storeStateVariables() - updateMaterialActivityViews(media_coordinator, media_grid, useTransparentNavigation = !config.scrollHorizontally, useTopSearchMenu = true) + updateMaterialActivityViews(binding.mediaCoordinator, binding.mediaGrid, useTransparentNavigation = !config.scrollHorizontally, useTopSearchMenu = true) if (mShowAll) { registerFileUpdateListener() if (isPackageInstalled("com.simplemobiletools.gallery")) { - ConfirmationDialog(this, "", R.string.upgraded_from_free_gallery, R.string.ok, 0, false) {} + ConfirmationDialog( + this, + "", + com.simplemobiletools.commons.R.string.upgraded_from_free_gallery, + com.simplemobiletools.commons.R.string.ok, + 0, + false + ) {} } } - media_empty_text_placeholder_2.setOnClickListener { + binding.mediaEmptyTextPlaceholder2.setOnClickListener { showFilterMediaDialog() } @@ -133,7 +143,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (mStoredScrollHorizontally != config.scrollHorizontally) { mLoadedInitialPhotos = false - media_grid.adapter = null + binding.mediaGrid.adapter = null getMedia() } @@ -155,22 +165,22 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { || mStoredRoundedCorners != config.fileRoundedCorners || mStoredMarkFavoriteItems != config.markFavoriteItems ) { - media_grid.adapter = null + binding.mediaGrid.adapter = null setupAdapter() } refreshMenuItems() - media_fastscroller.updateColors(primaryColor) - media_refresh_layout.isEnabled = config.enablePullToRefresh + binding.mediaFastscroller.updateColors(primaryColor) + binding.mediaRefreshLayout.isEnabled = config.enablePullToRefresh getMediaAdapter()?.apply { dateFormat = config.dateFormat timeFormat = getTimeFormat() } - media_empty_text_placeholder.setTextColor(getProperTextColor()) - media_empty_text_placeholder_2.setTextColor(getProperPrimaryColor()) - media_empty_text_placeholder_2.bringToFront() + binding.mediaEmptyTextPlaceholder.setTextColor(getProperTextColor()) + binding.mediaEmptyTextPlaceholder2.setTextColor(getProperPrimaryColor()) + binding.mediaEmptyTextPlaceholder2.bringToFront() // do not refresh Random sorted files after opening a fullscreen image and going Back val isRandomSorting = config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0 @@ -192,7 +202,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { override fun onPause() { super.onPause() mIsGettingMedia = false - media_refresh_layout.isRefreshing = false + binding.mediaRefreshLayout.isRefreshing = false storeStateVariables() mLastMediaHandler.removeCallbacksAndMessages(null) @@ -229,8 +239,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } override fun onBackPressed() { - if (media_menu.isSearchOpen) { - media_menu.closeSearch() + if (binding.mediaMenu.isSearchOpen) { + binding.mediaMenu.closeSearch() } else { super.onBackPressed() } @@ -249,7 +259,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun refreshMenuItems() { val isDefaultFolder = !config.defaultFolder.isEmpty() && File(config.defaultFolder).compareTo(File(mPath)) == 0 - media_menu.getToolbar().menu.apply { + binding.mediaMenu.getToolbar().menu.apply { findItem(R.id.group).isVisible = !config.scrollHorizontally findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN @@ -275,17 +285,17 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun setupOptionsMenu() { - media_menu.getToolbar().inflateMenu(R.menu.menu_media) - media_menu.toggleHideOnScroll(!config.scrollHorizontally) - media_menu.setupMenu() + binding.mediaMenu.getToolbar().inflateMenu(R.menu.menu_media) + binding.mediaMenu.toggleHideOnScroll(!config.scrollHorizontally) + binding.mediaMenu.setupMenu() - media_menu.onSearchTextChangedListener = { text -> + binding.mediaMenu.onSearchTextChangedListener = { text -> mLastSearchedText = text searchQueryChanged(text) - media_refresh_layout.isEnabled = text.isEmpty() && config.enablePullToRefresh + binding.mediaRefreshLayout.isEnabled = text.isEmpty() && config.enablePullToRefresh } - media_menu.getToolbar().setOnMenuItemClickListener { menuItem -> + binding.mediaMenu.getToolbar().setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.sort -> showSortingDialog() R.id.filter -> showFilterMediaDialog() @@ -329,7 +339,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun updateMenuColors() { updateStatusbarColor(getProperBackgroundColor()) - media_menu.updateColors() + binding.mediaMenu.updateColors() } private fun storeStateVariables() { @@ -355,12 +365,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList, mPath) runOnUiThread { if (grouped.isEmpty()) { - media_empty_text_placeholder.text = getString(R.string.no_items_found) - media_empty_text_placeholder.beVisible() - media_fastscroller.beGone() + binding.mediaEmptyTextPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found) + binding.mediaEmptyTextPlaceholder.beVisible() + binding.mediaFastscroller.beGone() } else { - media_empty_text_placeholder.beGone() - media_fastscroller.beVisible() + binding.mediaEmptyTextPlaceholder.beGone() + binding.mediaFastscroller.beVisible() } handleGridSpacing(grouped) @@ -375,22 +385,22 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { handlePermission(getPermissionToRequest()) { if (it) { val dirName = when { - mPath == FAVORITES -> getString(R.string.favorites) - mPath == RECYCLE_BIN -> getString(R.string.recycle_bin) - mPath == config.OTGPath -> getString(R.string.usb) + mPath == FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites) + mPath == RECYCLE_BIN -> getString(com.simplemobiletools.commons.R.string.recycle_bin) + mPath == config.OTGPath -> getString(com.simplemobiletools.commons.R.string.usb) else -> getHumanizedFilename(mPath) } val searchHint = if (mShowAll) { - getString(R.string.search_files) + getString(com.simplemobiletools.commons.R.string.search_files) } else { - getString(R.string.search_in_placeholder, dirName) + getString(com.simplemobiletools.commons.R.string.search_in_placeholder, dirName) } - media_menu.updateHintText(searchHint) + binding.mediaMenu.updateHintText(searchHint) if (!mShowAll) { - media_menu.toggleForceArrowBackIcon(true) - media_menu.onNavigateBackClickListener = { + binding.mediaMenu.toggleForceArrowBackIcon(true) + binding.mediaMenu.onNavigateBackClickListener = { onBackPressed() } } @@ -398,37 +408,37 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { getMedia() setupLayoutManager() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } } - private fun getMediaAdapter() = media_grid.adapter as? MediaAdapter + private fun getMediaAdapter() = binding.mediaGrid.adapter as? MediaAdapter private fun setupAdapter() { if (!mShowAll && isDirEmpty()) { return } - val currAdapter = media_grid.adapter + val currAdapter = binding.mediaGrid.adapter if (currAdapter == null) { initZoomListener() MediaAdapter( this, mMedia.clone() as ArrayList, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent, - mAllowPickingMultiple, mPath, media_grid + mAllowPickingMultiple, mPath, binding.mediaGrid ) { if (it is Medium && !isFinishing) { itemClicked(it.path) } }.apply { setupZoomListener(mZoomListener) - media_grid.adapter = this + binding.mediaGrid.adapter = this } val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath) if (viewType == VIEW_TYPE_LIST && areSystemAnimationsEnabled) { - media_grid.scheduleLayoutAnimation() + binding.mediaGrid.scheduleLayoutAnimation() } setupLayoutManager() @@ -446,7 +456,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun setupScrollDirection() { val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath) val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID - media_fastscroller.setScrollVertically(!scrollHorizontally) + binding.mediaFastscroller.setScrollVertically(!scrollHorizontally) } private fun checkLastMediaChanged() { @@ -475,7 +485,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun showSortingDialog() { ChangeSortingDialog(this, false, true, mPath) { mLoadedInitialPhotos = false - media_grid.adapter = null + binding.mediaGrid.adapter = null getMedia() } } @@ -483,8 +493,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun showFilterMediaDialog() { FilterMediaDialog(this) { mLoadedInitialPhotos = false - media_refresh_layout.isRefreshing = true - media_grid.adapter = null + binding.mediaRefreshLayout.isRefreshing = true + binding.mediaGrid.adapter = null getMedia() } } @@ -531,7 +541,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { ChangeViewTypeDialog(this, false, mPath) { refreshMenuItems() setupLayoutManager() - media_grid.adapter = null + binding.mediaGrid.adapter = null setupAdapter() } } @@ -539,7 +549,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun showGroupByDialog() { ChangeGroupingDialog(this, mPath) { mLoadedInitialPhotos = false - media_grid.adapter = null + binding.mediaGrid.adapter = null getMedia() } } @@ -569,7 +579,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent) { if (it.isEmpty()) { runOnUiThread { - media_refresh_layout.isRefreshing = true + binding.mediaRefreshLayout.isRefreshing = true } } else { gotMedia(it, true) @@ -622,9 +632,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } if (mPath == RECYCLE_BIN) { - media_empty_text_placeholder.setText(R.string.no_items_found) - media_empty_text_placeholder.beVisible() - media_empty_text_placeholder_2.beGone() + binding.mediaEmptyTextPlaceholder.setText(com.simplemobiletools.commons.R.string.no_items_found) + binding.mediaEmptyTextPlaceholder.beVisible() + binding.mediaEmptyTextPlaceholder2.beGone() } else { finish() } @@ -681,13 +691,13 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun setupGridLayoutManager() { - val layoutManager = media_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = RecyclerView.HORIZONTAL - media_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) + binding.mediaRefreshLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) } else { layoutManager.orientation = RecyclerView.VERTICAL - media_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + binding.mediaRefreshLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } layoutManager.spanCount = config.mediaColumnCnt @@ -704,10 +714,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun setupListLayoutManager() { - val layoutManager = media_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager layoutManager.spanCount = 1 layoutManager.orientation = RecyclerView.VERTICAL - media_refresh_layout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + binding.mediaRefreshLayout.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) mZoomListener = null } @@ -719,17 +729,17 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val useGridPosition = media.firstOrNull() is ThumbnailSection var currentGridDecoration: GridSpacingItemDecoration? = null - if (media_grid.itemDecorationCount > 0) { - currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration + if (binding.mediaGrid.itemDecorationCount > 0) { + currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration currentGridDecoration.items = media } val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition) if (currentGridDecoration.toString() != newGridDecoration.toString()) { if (currentGridDecoration != null) { - media_grid.removeItemDecoration(currentGridDecoration) + binding.mediaGrid.removeItemDecoration(currentGridDecoration) } - media_grid.addItemDecoration(newGridDecoration) + binding.mediaGrid.addItemDecoration(newGridDecoration) } } } @@ -737,7 +747,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun initZoomListener() { val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath) if (viewType == VIEW_TYPE_GRID) { - val layoutManager = media_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager mZoomListener = object : MyRecyclerView.MyZoomListener { override fun zoomIn() { if (layoutManager.spanCount > 1) { @@ -761,10 +771,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun changeColumnCount() { val items = ArrayList() for (i in 1..MAX_COLUMN_COUNT) { - items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i))) + items.add(RadioItem(i, resources.getQuantityString(com.simplemobiletools.commons.R.plurals.column_counts, i, i))) } - val currentColumnCount = (media_grid.layoutManager as MyGridLayoutManager).spanCount + val currentColumnCount = (binding.mediaGrid.layoutManager as MyGridLayoutManager).spanCount RadioGroupDialog(this, items, currentColumnCount) { val newColumnCount = it as Int if (currentColumnCount != newColumnCount) { @@ -785,7 +795,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun columnCountChanged() { - (media_grid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt + (binding.mediaGrid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt handleGridSpacing() refreshMenuItems() getMediaAdapter()?.apply { @@ -863,14 +873,14 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { mMedia = media runOnUiThread { - media_refresh_layout.isRefreshing = false - media_empty_text_placeholder.beVisibleIf(media.isEmpty() && !isFromCache) - media_empty_text_placeholder_2.beVisibleIf(media.isEmpty() && !isFromCache) + binding.mediaRefreshLayout.isRefreshing = false + binding.mediaEmptyTextPlaceholder.beVisibleIf(media.isEmpty() && !isFromCache) + binding.mediaEmptyTextPlaceholder2.beVisibleIf(media.isEmpty() && !isFromCache) - if (media_empty_text_placeholder.isVisible()) { - media_empty_text_placeholder.text = getString(R.string.no_media_with_filters) + if (binding.mediaEmptyTextPlaceholder.isVisible()) { + binding.mediaEmptyTextPlaceholder.text = getString(R.string.no_media_with_filters) } - media_fastscroller.beVisibleIf(media_empty_text_placeholder.isGone()) + binding.mediaFastscroller.beVisibleIf(binding.mediaEmptyTextPlaceholder.isGone()) setupAdapter() } @@ -894,18 +904,18 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } if (config.useRecycleBin && !skipRecycleBin && !filtered.first().path.startsWith(recycleBinPath)) { - val movingItems = resources.getQuantityString(R.plurals.moving_items_into_bin, filtered.size, filtered.size) + val movingItems = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.moving_items_into_bin, filtered.size, filtered.size) toast(movingItems) movePathsInRecycleBin(filtered.map { it.path } as ArrayList) { if (it) { deleteFilteredFiles(filtered) } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } else { - val deletingItems = resources.getQuantityString(R.plurals.deleting_items, filtered.size, filtered.size) + val deletingItems = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.deleting_items, filtered.size, filtered.size) toast(deletingItems) deleteFilteredFiles(filtered) } @@ -916,7 +926,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun deleteFilteredFiles(filtered: ArrayList) { deleteFiles(filtered) { if (!it) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return@deleteFiles } @@ -961,8 +971,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } } - if (media_grid.itemDecorationCount > 0) { - val currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration + if (binding.mediaGrid.itemDecorationCount > 0) { + val currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration currentGridDecoration.items = media } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt index c6708837e..e649bc4b7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt @@ -16,11 +16,11 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ActivityPanoramaPhotoBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.hideSystemUI import com.simplemobiletools.gallery.pro.extensions.showSystemUI import com.simplemobiletools.gallery.pro.helpers.PATH -import kotlinx.android.synthetic.main.activity_panorama_photo.* open class PanoramaPhotoActivity : SimpleActivity() { private val CARDBOARD_DISPLAY_MODE = 3 @@ -29,23 +29,26 @@ open class PanoramaPhotoActivity : SimpleActivity() { private var isExploreEnabled = true private var isRendering = false + private lateinit var binding: ActivityPanoramaPhotoBinding + public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false requestWindowFeature(Window.FEATURE_NO_TITLE) super.onCreate(savedInstanceState) - setContentView(R.layout.activity_panorama_photo) + binding = ActivityPanoramaPhotoBinding.inflate(layoutInflater) + setContentView(binding.root) checkNotchSupport() setupButtonMargins() - cardboard.setOnClickListener { - panorama_view.displayMode = CARDBOARD_DISPLAY_MODE + binding.cardboard.setOnClickListener { + binding.panoramaView.displayMode = CARDBOARD_DISPLAY_MODE } - explore.setOnClickListener { + binding.explore.setOnClickListener { isExploreEnabled = !isExploreEnabled - panorama_view.setPureTouchTracking(isExploreEnabled) - explore.setImageResource(if (isExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector) + binding.panoramaView.setPureTouchTracking(isExploreEnabled) + binding.explore.setImageResource(if (isExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector) } checkIntent() @@ -57,7 +60,7 @@ open class PanoramaPhotoActivity : SimpleActivity() { override fun onResume() { super.onResume() - panorama_view.resumeRendering() + binding.panoramaView.resumeRendering() isRendering = true if (config.blackBackground) { updateStatusbarColor(Color.BLACK) @@ -74,14 +77,14 @@ open class PanoramaPhotoActivity : SimpleActivity() { override fun onPause() { super.onPause() - panorama_view.pauseRendering() + binding.panoramaView.pauseRendering() isRendering = false } override fun onDestroy() { super.onDestroy() if (isRendering) { - panorama_view.shutdown() + binding.panoramaView.shutdown() } } @@ -106,7 +109,7 @@ open class PanoramaPhotoActivity : SimpleActivity() { ensureBackgroundThread { val bitmap = getBitmapToLoad(path) runOnUiThread { - panorama_view.apply { + binding.panoramaView.apply { beVisible() loadImageFromBitmap(bitmap, options) setFlingingEnabled(true) @@ -164,20 +167,20 @@ open class PanoramaPhotoActivity : SimpleActivity() { private fun setupButtonMargins() { val navBarHeight = navigationBarHeight - (cardboard.layoutParams as RelativeLayout.LayoutParams).apply { + (binding.cardboard.layoutParams as RelativeLayout.LayoutParams).apply { bottomMargin = navBarHeight rightMargin = navigationBarWidth } - (explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight + (binding.explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight - cardboard.onGlobalLayout { - panorama_gradient_background.layoutParams.height = navBarHeight + cardboard.height + binding.cardboard.onGlobalLayout { + binding.panoramaGradientBackground.layoutParams.height = navBarHeight + binding.cardboard.height } } private fun toggleButtonVisibility() { - arrayOf(cardboard, explore, panorama_gradient_background).forEach { + arrayOf(binding.cardboard, binding.explore, binding.panoramaGradientBackground).forEach { it.animate().alpha(if (isFullscreen) 0f else 1f) it.isClickable = !isFullscreen } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt index 07166d2d8..8857aebf5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt @@ -16,14 +16,13 @@ import com.google.vr.sdk.widgets.video.VrVideoView import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ActivityPanoramaVideoBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.hasNavBar import com.simplemobiletools.gallery.pro.extensions.hideSystemUI import com.simplemobiletools.gallery.pro.extensions.showSystemUI import com.simplemobiletools.gallery.pro.helpers.MIN_SKIP_LENGTH import com.simplemobiletools.gallery.pro.helpers.PATH -import kotlinx.android.synthetic.main.activity_panorama_video.* -import kotlinx.android.synthetic.main.bottom_video_time_holder.* import java.io.File open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener { @@ -39,12 +38,14 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList private var mCurrTime = 0 private var mTimerHandler = Handler() + private lateinit var binding: ActivityPanoramaVideoBinding public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false requestWindowFeature(Window.FEATURE_NO_TITLE) super.onCreate(savedInstanceState) - setContentView(R.layout.activity_panorama_video) + binding = ActivityPanoramaVideoBinding.inflate(layoutInflater) + setContentView(binding.root) checkNotchSupport() checkIntent() @@ -56,7 +57,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList override fun onResume() { super.onResume() - vr_video_view.resumeRendering() + binding.vrVideoView.resumeRendering() mIsRendering = true if (config.blackBackground) { updateStatusbarColor(Color.BLACK) @@ -73,14 +74,14 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList override fun onPause() { super.onPause() - vr_video_view.pauseRendering() + binding.vrVideoView.pauseRendering() mIsRendering = false } override fun onDestroy() { super.onDestroy() if (mIsRendering) { - vr_video_view.shutdown() + binding.vrVideoView.shutdown() } if (!isChangingConfigurations) { @@ -104,8 +105,8 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList setupButtons() intent.removeExtra(PATH) - video_curr_time.setOnClickListener { skip(false) } - video_duration.setOnClickListener { skip(true) } + binding.bottomVideoTimeHolder.videoCurrTime.setOnClickListener { skip(false) } + binding.bottomVideoTimeHolder.videoDuration.setOnClickListener { skip(true) } try { val options = VrVideoView.Options() @@ -116,7 +117,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList Uri.fromFile(File(path)) } - vr_video_view.apply { + binding.vrVideoView.apply { loadVideo(uri, options) pauseVideo() @@ -149,9 +150,9 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList mIsPlaying = true resumeVideo() } else { - video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) } - video_toggle_play_pause.beVisible() + binding.bottomVideoTimeHolder.videoTogglePlayPause.beVisible() } override fun onCompletion() { @@ -160,7 +161,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList }) } - video_toggle_play_pause.setOnClickListener { + binding.bottomVideoTimeHolder.videoTogglePlayPause.setOnClickListener { togglePlayPause() } } catch (e: Exception) { @@ -175,8 +176,8 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList private fun setupDuration(duration: Long) { mDuration = (duration / 1000).toInt() - video_seekbar.max = mDuration - video_duration.text = mDuration.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration + binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration() setVideoProgress(0) } @@ -184,9 +185,9 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList runOnUiThread(object : Runnable { override fun run() { if (mIsPlaying && !mIsDragged) { - mCurrTime = (vr_video_view!!.currentPosition / 1000).toInt() - video_seekbar.progress = mCurrTime - video_curr_time.text = mCurrTime.getFormattedDuration() + mCurrTime = (binding.vrVideoView.currentPosition / 1000).toInt() + binding.bottomVideoTimeHolder.videoSeekbar.progress = mCurrTime + binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration() } mTimerHandler.postDelayed(this, 1000) @@ -204,35 +205,35 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList } private fun resumeVideo() { - video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_pause_outline_vector) if (mCurrTime == mDuration) { setVideoProgress(0) mPlayOnReady = true return } - vr_video_view.playVideo() + binding.vrVideoView.playVideo() window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } private fun pauseVideo() { - vr_video_view.pauseVideo() - video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline_vector) + binding.vrVideoView.pauseVideo() + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } private fun setVideoProgress(seconds: Int) { - vr_video_view.seekTo(seconds * 1000L) - video_seekbar.progress = seconds + binding.vrVideoView.seekTo(seconds * 1000L) + binding.bottomVideoTimeHolder.videoSeekbar.progress = seconds mCurrTime = seconds - video_curr_time.text = seconds.getFormattedDuration() + binding.bottomVideoTimeHolder.videoCurrTime.text = seconds.getFormattedDuration() } private fun videoCompleted() { mIsPlaying = false - mCurrTime = (vr_video_view.duration / 1000).toInt() - video_seekbar.progress = video_seekbar.max - video_curr_time.text = mDuration.getFormattedDuration() + mCurrTime = (binding.vrVideoView.duration / 1000).toInt() + binding.bottomVideoTimeHolder.videoSeekbar.progress = binding.bottomVideoTimeHolder.videoSeekbar.max + binding.bottomVideoTimeHolder.videoCurrTime.text = mDuration.getFormattedDuration() pauseVideo() } @@ -249,44 +250,50 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList } } - video_time_holder.setPadding(0, 0, right, bottom) - video_time_holder.background = resources.getDrawable(R.drawable.gradient_background) - video_time_holder.onGlobalLayout { - val newBottomMargin = video_time_holder.height - resources.getDimension(R.dimen.video_player_play_pause_size) - .toInt() - resources.getDimension(R.dimen.activity_margin).toInt() - (explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = newBottomMargin + binding.bottomVideoTimeHolder.root.setPadding(0, 0, right, bottom) + binding.bottomVideoTimeHolder.root.background = resources.getDrawable(R.drawable.gradient_background) + binding.bottomVideoTimeHolder.root.onGlobalLayout { + val newBottomMargin = binding.bottomVideoTimeHolder.root.height - resources.getDimension(R.dimen.video_player_play_pause_size) + .toInt() - resources.getDimension(com.simplemobiletools.commons.R.dimen.activity_margin).toInt() + (binding.explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = newBottomMargin - (cardboard.layoutParams as RelativeLayout.LayoutParams).apply { + (binding.cardboard.layoutParams as RelativeLayout.LayoutParams).apply { bottomMargin = newBottomMargin rightMargin = navigationBarWidth } - explore.requestLayout() + binding.explore.requestLayout() } - video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) - cardboard.setOnClickListener { - vr_video_view.displayMode = CARDBOARD_DISPLAY_MODE + binding.cardboard.setOnClickListener { + binding.vrVideoView.displayMode = CARDBOARD_DISPLAY_MODE } - explore.setOnClickListener { + binding.explore.setOnClickListener { mIsExploreEnabled = !mIsExploreEnabled - vr_video_view.setPureTouchTracking(mIsExploreEnabled) - explore.setImageResource(if (mIsExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector) + binding.vrVideoView.setPureTouchTracking(mIsExploreEnabled) + binding.explore.setImageResource(if (mIsExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector) } } private fun toggleButtonVisibility() { val newAlpha = if (mIsFullscreen) 0f else 1f - arrayOf(cardboard, explore).forEach { + arrayOf(binding.cardboard, binding.explore).forEach { it.animate().alpha(newAlpha) } - arrayOf(cardboard, explore, video_toggle_play_pause, video_curr_time, video_duration).forEach { + arrayOf( + binding.cardboard, + binding.explore, + binding.bottomVideoTimeHolder.videoTogglePlayPause, + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoDuration + ).forEach { it.isClickable = !mIsFullscreen } - video_seekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) - video_time_holder.animate().alpha(newAlpha).start() + binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) + binding.bottomVideoTimeHolder.videoTimeHolder.animate().alpha(newAlpha).start() } private fun handleClick() { @@ -304,11 +311,11 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList return } - val curr = vr_video_view.currentPosition - val twoPercents = Math.max((vr_video_view.duration / 50).toInt(), MIN_SKIP_LENGTH) + val curr = binding.vrVideoView.currentPosition + val twoPercents = Math.max((binding.vrVideoView.duration / 50).toInt(), MIN_SKIP_LENGTH) val newProgress = if (forward) curr + twoPercents else curr - twoPercents val roundProgress = Math.round(newProgress / 1000f) - val limitedProgress = Math.max(Math.min(vr_video_view.duration.toInt(), roundProgress), 0) + val limitedProgress = Math.max(Math.min(binding.vrVideoView.duration.toInt(), roundProgress), 0) setVideoProgress(limitedProgress) if (!mIsPlaying) { togglePlayPause() @@ -322,7 +329,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList } override fun onStartTrackingTouch(seekBar: SeekBar?) { - vr_video_view.pauseVideo() + binding.vrVideoView.pauseVideo() mIsDragged = true } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index efb977a44..fada34ec4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -15,14 +15,13 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.FragmentHolderBinding import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.fragments.PhotoFragment import com.simplemobiletools.gallery.pro.fragments.VideoFragment import com.simplemobiletools.gallery.pro.fragments.ViewPagerFragment import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium -import kotlinx.android.synthetic.main.bottom_actions.* -import kotlinx.android.synthetic.main.fragment_holder.* import java.io.File import java.io.FileInputStream @@ -35,11 +34,14 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList var mIsVideo = false + private lateinit var binding: FragmentHolderBinding + public override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true super.onCreate(savedInstanceState) - setContentView(R.layout.fragment_holder) + binding = FragmentHolderBinding.inflate(layoutInflater) + setContentView(binding.root) if (checkAppSideloading()) { return } @@ -50,7 +52,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (it) { checkIntent(savedInstanceState) } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -74,19 +76,19 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList super.onConfigurationChanged(newConfig) initBottomActionsLayout() - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight - (fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight + (binding.fragmentViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) + binding.fragmentViewerToolbar.setPadding(0, 0, navigationBarWidth, 0) } else { - fragment_viewer_toolbar.setPadding(0, 0, 0, 0) + binding.fragmentViewerToolbar.setPadding(0, 0, 0, 0) } } fun refreshMenuItems() { val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0 - fragment_viewer_toolbar.menu.apply { + binding.fragmentViewerToolbar.menu.apply { findItem(R.id.menu_set_as).isVisible = mMedium?.isImage() == true && visibleBottomActions and BOTTOM_ACTION_SET_AS == 0 findItem(R.id.menu_edit).isVisible = mMedium?.isImage() == true && mUri?.scheme == "file" && visibleBottomActions and BOTTOM_ACTION_EDIT == 0 findItem(R.id.menu_properties).isVisible = mUri?.scheme == "file" && visibleBottomActions and BOTTOM_ACTION_PROPERTIES == 0 @@ -96,15 +98,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } private fun setupOptionsMenu() { - (fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight - fragment_viewer_toolbar.apply { + (binding.fragmentViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + binding.fragmentViewerToolbar.apply { setTitleTextColor(Color.WHITE) - overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE) - navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE) + overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE) + navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE) } - updateMenuItemColors(fragment_viewer_toolbar.menu, forceWhiteIcons = true) - fragment_viewer_toolbar.setOnMenuItemClickListener { menuItem -> + updateMenuItemColors(binding.fragmentViewerToolbar.menu, forceWhiteIcons = true) + binding.fragmentViewerToolbar.setOnMenuItemClickListener { menuItem -> if (mMedium == null || mUri == null) { return@setOnMenuItemClickListener true } @@ -121,7 +123,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList return@setOnMenuItemClickListener true } - fragment_viewer_toolbar.setNavigationOnClickListener { + binding.fragmentViewerToolbar.setNavigationOnClickListener { finish() } } @@ -162,7 +164,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (!preventShowingHiddenFile) { if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) { if (isFileTypeVisible(realPath)) { - bottom_actions.beGone() + binding.bottomActions.root.beGone() sendViewPagerIntent(realPath) finish() return @@ -176,7 +178,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (mUri!!.scheme == "file") { if (filename.contains('.')) { - bottom_actions.beGone() + binding.bottomActions.root.beGone() rescanPaths(arrayListOf(mUri!!.path!!)) sendViewPagerIntent(mUri!!.path!!) finish() @@ -189,7 +191,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (!preventShowingHiddenFile) { if (realPath != mUri.toString() && realPath.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(realPath)) { if (isFileTypeVisible(realPath)) { - bottom_actions.beGone() + binding.bottomActions.root.beGone() rescanPaths(arrayListOf(mUri!!.path!!)) sendViewPagerIntent(realPath) finish() @@ -199,11 +201,11 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } } - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight + binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) + binding.fragmentViewerToolbar.setPadding(0, 0, navigationBarWidth, 0) } else { - fragment_viewer_toolbar.setPadding(0, 0, 0, 0) + binding.fragmentViewerToolbar.setPadding(0, 0, 0, 0) } checkNotchSupport() @@ -222,7 +224,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList mIsVideo = type == TYPE_VIDEOS mMedium = Medium(null, filename, mUri.toString(), mUri!!.path!!.getParentPath(), 0, 0, file.length(), type, 0, false, 0L, 0) - fragment_viewer_toolbar.title = Html.fromHtml("${mMedium!!.name}") + binding.fragmentViewerToolbar.title = Html.fromHtml("${mMedium!!.name}") bundle.putSerializable(MEDIUM, mMedium) if (savedInstanceState == null) { @@ -233,7 +235,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } if (config.blackBackground) { - fragment_holder.background = ColorDrawable(Color.BLACK) + binding.fragmentHolder.background = ColorDrawable(Color.BLACK) } if (config.maxBrightness) { @@ -253,7 +255,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun launchVideoPlayer() { val newUri = getFinalUriFromPath(mUri.toString(), BuildConfig.APPLICATION_ID) if (newUri == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -356,44 +358,54 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } private fun initBottomActionsLayout() { - bottom_actions.layoutParams.height = resources.getDimension(R.dimen.bottom_actions_height).toInt() + navigationBarHeight + binding.bottomActions.root.layoutParams.height = resources.getDimension(R.dimen.bottom_actions_height).toInt() + navigationBarHeight if (config.bottomActions) { - bottom_actions.beVisible() + binding.bottomActions.root.beVisible() } else { - bottom_actions.beGone() + binding.bottomActions.root.beGone() } } private fun initBottomActionButtons() { arrayListOf( - bottom_favorite, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, bottom_slideshow, bottom_show_on_map, - bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move, bottom_resize + binding.bottomActions.bottomFavorite, + binding.bottomActions.bottomDelete, + binding.bottomActions.bottomRotate, + binding.bottomActions.bottomProperties, + binding.bottomActions.bottomChangeOrientation, + binding.bottomActions.bottomSlideshow, + binding.bottomActions.bottomShowOnMap, + binding.bottomActions.bottomToggleFileVisibility, + binding.bottomActions.bottomRename, + binding.bottomActions.bottomCopy, + binding.bottomActions.bottomMove, + binding.bottomActions.bottomResize, ).forEach { it.beGone() } val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0 - bottom_edit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && mMedium?.isImage() == true) - bottom_edit.setOnClickListener { - if (mUri != null && bottom_actions.alpha == 1f) { + binding.bottomActions.bottomEdit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && mMedium?.isImage() == true) + binding.bottomActions.bottomEdit.setOnClickListener { + if (mUri != null && binding.bottomActions.root.alpha == 1f) { openEditor(mUri!!.toString()) } } - bottom_share.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0) - bottom_share.setOnClickListener { - if (mUri != null && bottom_actions.alpha == 1f) { + binding.bottomActions.bottomShare.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0) + binding.bottomActions.bottomShare.setOnClickListener { + if (mUri != null && binding.bottomActions.root.alpha == 1f) { sharePath(mUri!!.toString()) } } - bottom_set_as.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0 && mMedium?.isImage() == true) - bottom_set_as.setOnClickListener { + binding.bottomActions.bottomSetAs.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0 && mMedium?.isImage() == true) + binding.bottomActions.bottomSetAs.setOnClickListener { setAs(mUri!!.toString()) } - bottom_show_on_map.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0) - bottom_show_on_map.setOnClickListener { + binding.bottomActions.bottomShowOnMap.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0) + binding.bottomActions.bottomShowOnMap.setOnClickListener { showFileOnMap(mUri!!.toString()) } } @@ -407,15 +419,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } val newAlpha = if (mIsFullScreen) 0f else 1f - top_shadow.animate().alpha(newAlpha).start() - if (!bottom_actions.isGone()) { - bottom_actions.animate().alpha(newAlpha).start() + binding.topShadow.animate().alpha(newAlpha).start() + if (!binding.bottomActions.root.isGone()) { + binding.bottomActions.root.animate().alpha(newAlpha).start() } - fragment_viewer_toolbar.animate().alpha(newAlpha).withStartAction { - fragment_viewer_toolbar.beVisible() + binding.fragmentViewerToolbar.animate().alpha(newAlpha).withStartAction { + binding.fragmentViewerToolbar.beVisible() }.withEndAction { - fragment_viewer_toolbar.beVisibleIf(newAlpha == 1f) + binding.fragmentViewerToolbar.beVisibleIf(newAlpha == 1f) }.start() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt index 91fdea955..608701497 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SearchActivity.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.MediaAdapter import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask +import com.simplemobiletools.gallery.pro.databinding.ActivitySearchBinding import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.GridSpacingItemDecoration import com.simplemobiletools.gallery.pro.helpers.MediaFetcher @@ -22,7 +23,6 @@ import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem -import kotlinx.android.synthetic.main.activity_search.* import java.io.File class SearchActivity : SimpleActivity(), MediaOperationsListener { @@ -31,15 +31,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private var mCurrAsyncTask: GetMediaAsynctask? = null private var mAllMedia = ArrayList() + private lateinit var binding: ActivitySearchBinding + override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_search) + binding = ActivitySearchBinding.inflate(layoutInflater) + setContentView(binding.root) setupOptionsMenu() - updateMaterialActivityViews(search_coordinator, search_grid, useTransparentNavigation = true, useTopSearchMenu = true) - search_empty_text_placeholder.setTextColor(getProperTextColor()) + updateMaterialActivityViews(binding.searchCoordinator, binding.searchGrid, useTransparentNavigation = true, useTopSearchMenu = true) + binding.searchEmptyTextPlaceholder.setTextColor(getProperTextColor()) getAllMedia() - search_fastscroller.updateColors(getProperPrimaryColor()) + binding.searchFastscroller.updateColors(getProperPrimaryColor()) } override fun onResume() { @@ -53,27 +56,27 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } private fun setupOptionsMenu() { - search_menu.getToolbar().inflateMenu(R.menu.menu_search) - search_menu.toggleHideOnScroll(true) - search_menu.setupMenu() - search_menu.toggleForceArrowBackIcon(true) - search_menu.focusView() - search_menu.updateHintText(getString(R.string.search_files)) + binding.searchMenu.getToolbar().inflateMenu(R.menu.menu_search) + binding.searchMenu.toggleHideOnScroll(true) + binding.searchMenu.setupMenu() + binding.searchMenu.toggleForceArrowBackIcon(true) + binding.searchMenu.focusView() + binding.searchMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_files)) - search_menu.onNavigateBackClickListener = { - if (search_menu.getCurrentQuery().isEmpty()) { + binding.searchMenu.onNavigateBackClickListener = { + if (binding.searchMenu.getCurrentQuery().isEmpty()) { finish() } else { - search_menu.closeSearch() + binding.searchMenu.closeSearch() } } - search_menu.onSearchTextChangedListener = { text -> + binding.searchMenu.onSearchTextChangedListener = { text -> mLastSearchedText = text textChanged(text) } - search_menu.getToolbar().setOnMenuItemClickListener { menuItem -> + binding.searchMenu.getToolbar().setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.toggle_filename -> toggleFilenameVisibility() else -> return@setOnMenuItemClickListener false @@ -84,7 +87,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private fun updateMenuColors() { updateStatusbarColor(getProperBackgroundColor()) - search_menu.updateColors() + binding.searchMenu.updateColors() } private fun textChanged(text: String) { @@ -95,10 +98,10 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList, "") runOnUiThread { if (grouped.isEmpty()) { - search_empty_text_placeholder.text = getString(R.string.no_items_found) - search_empty_text_placeholder.beVisible() + binding.searchEmptyTextPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found) + binding.searchEmptyTextPlaceholder.beVisible() } else { - search_empty_text_placeholder.beGone() + binding.searchEmptyTextPlaceholder.beGone() } handleGridSpacing(grouped) @@ -110,14 +113,14 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } private fun setupAdapter() { - val currAdapter = search_grid.adapter + val currAdapter = binding.searchGrid.adapter if (currAdapter == null) { - MediaAdapter(this, mAllMedia, this, false, false, "", search_grid) { + MediaAdapter(this, mAllMedia, this, false, false, "", binding.searchGrid) { if (it is Medium) { itemClicked(it.path) } }.apply { - search_grid.adapter = this + binding.searchGrid.adapter = this } setupLayoutManager() handleGridSpacing(mAllMedia) @@ -134,18 +137,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private fun handleGridSpacing(media: ArrayList) { val viewType = config.getFolderViewType(SHOW_ALL) if (viewType == VIEW_TYPE_GRID) { - if (search_grid.itemDecorationCount > 0) { - search_grid.removeItemDecorationAt(0) + if (binding.searchGrid.itemDecorationCount > 0) { + binding.searchGrid.removeItemDecorationAt(0) } val spanCount = config.mediaColumnCnt val spacing = config.thumbnailSpacing val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true) - search_grid.addItemDecoration(decoration) + binding.searchGrid.addItemDecoration(decoration) } } - private fun getMediaAdapter() = search_grid.adapter as? MediaAdapter + private fun getMediaAdapter() = binding.searchGrid.adapter as? MediaAdapter private fun toggleFilenameVisibility() { config.displayFileNames = !config.displayFileNames @@ -175,13 +178,13 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } private fun setupGridLayoutManager() { - val layoutManager = search_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.searchGrid.layoutManager as MyGridLayoutManager if (config.scrollHorizontally) { layoutManager.orientation = RecyclerView.HORIZONTAL - search_grid.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) + binding.searchGrid.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT) } else { layoutManager.orientation = RecyclerView.VERTICAL - search_grid.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + binding.searchGrid.layoutParams = RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } layoutManager.spanCount = config.mediaColumnCnt @@ -198,7 +201,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } private fun setupListLayoutManager() { - val layoutManager = search_grid.layoutManager as MyGridLayoutManager + val layoutManager = binding.searchGrid.layoutManager as MyGridLayoutManager layoutManager.spanCount = 1 layoutManager.orientation = RecyclerView.VERTICAL } @@ -206,7 +209,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private fun setupScrollDirection() { val viewType = config.getFolderViewType(SHOW_ALL) val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID - search_fastscroller.setScrollVertically(!scrollHorizontally) + binding.searchFastscroller.setScrollVertically(!scrollHorizontally) } private fun getAllMedia() { @@ -244,18 +247,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { } if (config.useRecycleBin && !skipRecycleBin && !filtered.first().path.startsWith(recycleBinPath)) { - val movingItems = resources.getQuantityString(R.plurals.moving_items_into_bin, filtered.size, filtered.size) + val movingItems = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.moving_items_into_bin, filtered.size, filtered.size) toast(movingItems) movePathsInRecycleBin(filtered.map { it.path } as ArrayList) { if (it) { deleteFilteredFiles(filtered) } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } else { - val deletingItems = resources.getQuantityString(R.plurals.deleting_items, filtered.size, filtered.size) + val deletingItems = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.deleting_items, filtered.size, filtered.size) toast(deletingItems) deleteFilteredFiles(filtered) } @@ -264,7 +267,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener { private fun deleteFilteredFiles(filtered: ArrayList) { deleteFiles(filtered) { if (!it) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return@deleteFiles } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 5de0ae738..9621ad358 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -15,10 +15,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.activity_set_wallpaper.crop_image_view -import kotlinx.android.synthetic.main.activity_set_wallpaper.set_wallpaper_toolbar -import kotlinx.android.synthetic.main.bottom_set_wallpaper_actions.bottom_set_wallpaper_aspect_ratio -import kotlinx.android.synthetic.main.bottom_set_wallpaper_actions.bottom_set_wallpaper_rotate +import com.simplemobiletools.gallery.pro.databinding.ActivitySetWallpaperBinding class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener { private val RATIO_PORTRAIT = 0 @@ -32,9 +29,12 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete lateinit var uri: Uri lateinit var wallpaperManager: WallpaperManager + private lateinit var binding: ActivitySetWallpaperBinding + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_set_wallpaper) + binding = ActivitySetWallpaperBinding.inflate(layoutInflater) + setContentView(binding.root) setupBottomActions() if (checkAppSideloading()) { @@ -55,7 +55,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete override fun onResume() { super.onResume() - setupToolbar(set_wallpaper_toolbar, NavigationIcon.Arrow) + setupToolbar(binding.setWallpaperToolbar, NavigationIcon.Arrow) } override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { @@ -70,10 +70,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } private fun setupOptionsMenu() { - set_wallpaper_toolbar.setOnMenuItemClickListener { menuItem -> + binding.setWallpaperToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.save -> confirmWallpaper() - R.id.allow_changing_aspect_ratio -> crop_image_view.clearAspectRatio() + R.id.allow_changing_aspect_ratio -> binding.cropImageView.clearAspectRatio() else -> return@setOnMenuItemClickListener false } return@setOnMenuItemClickListener true @@ -89,7 +89,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } wallpaperManager = WallpaperManager.getInstance(applicationContext) - crop_image_view.apply { + binding.cropImageView.apply { setOnCropImageCompleteListener(this@SetWallpaperActivity) setImageUriAsync(uri) } @@ -98,12 +98,12 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } private fun setupBottomActions() { - bottom_set_wallpaper_aspect_ratio.setOnClickListener { + binding.bottomSetWallpaperActions.bottomSetWallpaperAspectRatio.setOnClickListener { changeAspectRatio() } - bottom_set_wallpaper_rotate.setOnClickListener { - crop_image_view.rotateImage(90) + binding.bottomSetWallpaperActions.bottomSetWallpaperRotate.setOnClickListener { + binding.cropImageView.rotateImage(90) } } @@ -115,9 +115,9 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } when (aspectRatio) { - RATIO_PORTRAIT -> crop_image_view.setAspectRatio(heightToUse, widthToUse) - RATIO_LANDSCAPE -> crop_image_view.setAspectRatio(widthToUse, heightToUse) - else -> crop_image_view.setAspectRatio(widthToUse, widthToUse) + RATIO_PORTRAIT -> binding.cropImageView.setAspectRatio(heightToUse, widthToUse) + RATIO_LANDSCAPE -> binding.cropImageView.setAspectRatio(widthToUse, heightToUse) + else -> binding.cropImageView.setAspectRatio(widthToUse, widthToUse) } } @@ -136,10 +136,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete RadioGroupDialog(this, items) { wallpaperFlag = it as Int - crop_image_view.croppedImageAsync() + binding.cropImageView.croppedImageAsync() } } else { - crop_image_view.croppedImageAsync() + binding.cropImageView.croppedImageAsync() } } @@ -163,7 +163,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } setResult(Activity.RESULT_OK) } catch (e: OutOfMemoryError) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) setResult(Activity.RESULT_CANCELED) } finish() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 7fdd94368..0d1d4f3a7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -13,35 +13,40 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ActivitySettingsBinding import com.simplemobiletools.gallery.pro.dialogs.* import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.AlbumCover -import kotlinx.android.synthetic.main.activity_settings.* import java.io.File import java.io.InputStream import java.io.OutputStream -import java.util.* +import java.util.Locale import kotlin.system.exitProcess class SettingsActivity : SimpleActivity() { - private val PICK_IMPORT_SOURCE_INTENT = 1 - private val SELECT_EXPORT_FAVORITES_FILE_INTENT = 2 - private val SELECT_IMPORT_FAVORITES_FILE_INTENT = 3 + companion object { + private const val PICK_IMPORT_SOURCE_INTENT = 1 + private const val SELECT_EXPORT_FAVORITES_FILE_INTENT = 2 + private const val SELECT_IMPORT_FAVORITES_FILE_INTENT = 3 + } + private var mRecycleBinContentSize = 0L + private lateinit var binding: ActivitySettingsBinding override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_settings) + binding = ActivitySettingsBinding.inflate(layoutInflater) + setContentView(binding.root) - updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false) - setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar) + updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) + setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar) } override fun onResume() { super.onResume() - setupToolbar(settings_toolbar, NavigationIcon.Arrow) + setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow) setupSettingItems() } @@ -94,7 +99,7 @@ class SettingsActivity : SimpleActivity() { setupShowRecycleBin() setupShowRecycleBinLast() setupEmptyRecycleBin() - updateTextColors(settings_holder) + updateTextColors(binding.settingsHolder) setupClearCache() setupExportFavorites() setupImportFavorites() @@ -102,19 +107,19 @@ class SettingsActivity : SimpleActivity() { setupImportSettings() arrayOf( - settings_color_customization_section_label, - settings_general_settings_label, - settings_videos_label, - settings_thumbnails_label, - settings_scrolling_label, - settings_fullscreen_media_label, - settings_deep_zoomable_images_label, - settings_extended_details_label, - settings_security_label, - settings_file_operations_label, - settings_bottom_actions_label, - settings_recycle_bin_label, - settings_migrating_label + binding.settingsColorCustomizationSectionLabel, + binding.settingsGeneralSettingsLabel, + binding.settingsVideosLabel, + binding.settingsThumbnailsLabel, + binding.settingsScrollingLabel, + binding.settingsFullscreenMediaLabel, + binding.settingsDeepZoomableImagesLabel, + binding.settingsExtendedDetailsLabel, + binding.settingsSecurityLabel, + binding.settingsFileOperationsLabel, + binding.settingsBottomActionsLabel, + binding.settingsRecycleBinLabel, + binding.settingsMigratingLabel ).forEach { it.setTextColor(getProperPrimaryColor()) } @@ -135,39 +140,39 @@ class SettingsActivity : SimpleActivity() { } private fun setupCustomizeColors() { - settings_color_customization_holder.setOnClickListener { + binding.settingsColorCustomizationHolder.setOnClickListener { startCustomizationActivity() } } private fun setupUseEnglish() { - settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) - settings_use_english.isChecked = config.useEnglish - settings_use_english_holder.setOnClickListener { - settings_use_english.toggle() - config.useEnglish = settings_use_english.isChecked + binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) + binding.settingsUseEnglish.isChecked = config.useEnglish + binding.settingsUseEnglishHolder.setOnClickListener { + binding.settingsUseEnglish.toggle() + config.useEnglish = binding.settingsUseEnglish.isChecked exitProcess(0) } } private fun setupLanguage() { - settings_language.text = Locale.getDefault().displayLanguage - settings_language_holder.beVisibleIf(isTiramisuPlus()) - settings_language_holder.setOnClickListener { + binding.settingsLanguage.text = Locale.getDefault().displayLanguage + binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus()) + binding.settingsLanguageHolder.setOnClickListener { launchChangeAppLanguageIntent() } } private fun setupChangeDateTimeFormat() { - settings_change_date_time_format_holder.setOnClickListener { + binding.settingsChangeDateTimeFormatHolder.setOnClickListener { ChangeDateTimeFormatDialog(this) {} } } private fun setupFileLoadingPriority() { - settings_file_loading_priority_holder.beGoneIf(isRPlus() && !isExternalStorageManager()) - settings_file_loading_priority.text = getFileLoadingPriorityText() - settings_file_loading_priority_holder.setOnClickListener { + binding.settingsFileLoadingPriorityHolder.beGoneIf(isRPlus() && !isExternalStorageManager()) + binding.settingsFileLoadingPriority.text = getFileLoadingPriorityText() + binding.settingsFileLoadingPriorityHolder.setOnClickListener { val items = arrayListOf( RadioItem(PRIORITY_SPEED, getString(R.string.speed)), RadioItem(PRIORITY_COMPROMISE, getString(R.string.compromise)), @@ -176,7 +181,7 @@ class SettingsActivity : SimpleActivity() { RadioGroupDialog(this@SettingsActivity, items, config.fileLoadingPriority) { config.fileLoadingPriority = it as Int - settings_file_loading_priority.text = getFileLoadingPriorityText() + binding.settingsFileLoadingPriority.text = getFileLoadingPriorityText() } } } @@ -191,12 +196,13 @@ class SettingsActivity : SimpleActivity() { private fun setupManageIncludedFolders() { if (isRPlus() && !isExternalStorageManager()) { - settings_manage_included_folders.text = "${getString(R.string.manage_included_folders)} (${getString(R.string.no_permission)})" + binding.settingsManageIncludedFolders.text = + "${getString(R.string.manage_included_folders)} (${getString(com.simplemobiletools.commons.R.string.no_permission)})" } else { - settings_manage_included_folders.setText(R.string.manage_included_folders) + binding.settingsManageIncludedFolders.setText(R.string.manage_included_folders) } - settings_manage_included_folders_holder.setOnClickListener { + binding.settingsManageIncludedFoldersHolder.setOnClickListener { if (isRPlus() && !isExternalStorageManager()) { GrantAllFilesDialog(this) } else { @@ -206,7 +212,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupManageExcludedFolders() { - settings_manage_excluded_folders_holder.setOnClickListener { + binding.settingsManageExcludedFoldersHolder.setOnClickListener { handleExcludedFolderPasswordProtection { startActivity(Intent(this, ExcludedFoldersActivity::class.java)) } @@ -214,8 +220,8 @@ class SettingsActivity : SimpleActivity() { } private fun setupManageHiddenFolders() { - settings_manage_hidden_folders_holder.beGoneIf(isQPlus()) - settings_manage_hidden_folders_holder.setOnClickListener { + binding.settingsManageHiddenFoldersHolder.beGoneIf(isQPlus()) + binding.settingsManageHiddenFoldersHolder.setOnClickListener { handleHiddenFolderPasswordProtection { startActivity(Intent(this, HiddenFoldersActivity::class.java)) } @@ -224,13 +230,14 @@ class SettingsActivity : SimpleActivity() { private fun setupShowHiddenItems() { if (isRPlus() && !isExternalStorageManager()) { - settings_show_hidden_items.text = "${getString(R.string.show_hidden_items)} (${getString(R.string.no_permission)})" + binding.settingsShowHiddenItems.text = + "${getString(com.simplemobiletools.commons.R.string.show_hidden_items)} (${getString(com.simplemobiletools.commons.R.string.no_permission)})" } else { - settings_show_hidden_items.setText(R.string.show_hidden_items) + binding.settingsShowHiddenItems.setText(com.simplemobiletools.commons.R.string.show_hidden_items) } - settings_show_hidden_items.isChecked = config.showHiddenMedia - settings_show_hidden_items_holder.setOnClickListener { + binding.settingsShowHiddenItems.isChecked = config.showHiddenMedia + binding.settingsShowHiddenItemsHolder.setOnClickListener { if (isRPlus() && !isExternalStorageManager()) { GrantAllFilesDialog(this) } else if (config.showHiddenMedia) { @@ -244,112 +251,112 @@ class SettingsActivity : SimpleActivity() { } private fun toggleHiddenItems() { - settings_show_hidden_items.toggle() - config.showHiddenMedia = settings_show_hidden_items.isChecked + binding.settingsShowHiddenItems.toggle() + config.showHiddenMedia = binding.settingsShowHiddenItems.isChecked } private fun setupSearchAllFiles() { - settings_search_all_files.isChecked = config.searchAllFilesByDefault - settings_search_all_files_holder.setOnClickListener { - settings_search_all_files.toggle() - config.searchAllFilesByDefault = settings_search_all_files.isChecked + binding.settingsSearchAllFiles.isChecked = config.searchAllFilesByDefault + binding.settingsSearchAllFilesHolder.setOnClickListener { + binding.settingsSearchAllFiles.toggle() + config.searchAllFilesByDefault = binding.settingsSearchAllFiles.isChecked } } private fun setupAutoplayVideos() { - settings_autoplay_videos.isChecked = config.autoplayVideos - settings_autoplay_videos_holder.setOnClickListener { - settings_autoplay_videos.toggle() - config.autoplayVideos = settings_autoplay_videos.isChecked + binding.settingsAutoplayVideos.isChecked = config.autoplayVideos + binding.settingsAutoplayVideosHolder.setOnClickListener { + binding.settingsAutoplayVideos.toggle() + config.autoplayVideos = binding.settingsAutoplayVideos.isChecked } } private fun setupRememberLastVideo() { - settings_remember_last_video_position.isChecked = config.rememberLastVideoPosition - settings_remember_last_video_position_holder.setOnClickListener { - settings_remember_last_video_position.toggle() - config.rememberLastVideoPosition = settings_remember_last_video_position.isChecked + binding.settingsRememberLastVideoPosition.isChecked = config.rememberLastVideoPosition + binding.settingsRememberLastVideoPositionHolder.setOnClickListener { + binding.settingsRememberLastVideoPosition.toggle() + config.rememberLastVideoPosition = binding.settingsRememberLastVideoPosition.isChecked } } private fun setupLoopVideos() { - settings_loop_videos.isChecked = config.loopVideos - settings_loop_videos_holder.setOnClickListener { - settings_loop_videos.toggle() - config.loopVideos = settings_loop_videos.isChecked + binding.settingsLoopVideos.isChecked = config.loopVideos + binding.settingsLoopVideosHolder.setOnClickListener { + binding.settingsLoopVideos.toggle() + config.loopVideos = binding.settingsLoopVideos.isChecked } } private fun setupOpenVideosOnSeparateScreen() { - settings_open_videos_on_separate_screen.isChecked = config.openVideosOnSeparateScreen - settings_open_videos_on_separate_screen_holder.setOnClickListener { - settings_open_videos_on_separate_screen.toggle() - config.openVideosOnSeparateScreen = settings_open_videos_on_separate_screen.isChecked + binding.settingsOpenVideosOnSeparateScreen.isChecked = config.openVideosOnSeparateScreen + binding.settingsOpenVideosOnSeparateScreenHolder.setOnClickListener { + binding.settingsOpenVideosOnSeparateScreen.toggle() + config.openVideosOnSeparateScreen = binding.settingsOpenVideosOnSeparateScreen.isChecked } } private fun setupMaxBrightness() { - settings_max_brightness.isChecked = config.maxBrightness - settings_max_brightness_holder.setOnClickListener { - settings_max_brightness.toggle() - config.maxBrightness = settings_max_brightness.isChecked + binding.settingsMaxBrightness.isChecked = config.maxBrightness + binding.settingsMaxBrightnessHolder.setOnClickListener { + binding.settingsMaxBrightness.toggle() + config.maxBrightness = binding.settingsMaxBrightness.isChecked } } private fun setupCropThumbnails() { - settings_crop_thumbnails.isChecked = config.cropThumbnails - settings_crop_thumbnails_holder.setOnClickListener { - settings_crop_thumbnails.toggle() - config.cropThumbnails = settings_crop_thumbnails.isChecked + binding.settingsCropThumbnails.isChecked = config.cropThumbnails + binding.settingsCropThumbnailsHolder.setOnClickListener { + binding.settingsCropThumbnails.toggle() + config.cropThumbnails = binding.settingsCropThumbnails.isChecked } } private fun setupDarkBackground() { - settings_black_background.isChecked = config.blackBackground - settings_black_background_holder.setOnClickListener { - settings_black_background.toggle() - config.blackBackground = settings_black_background.isChecked + binding.settingsBlackBackground.isChecked = config.blackBackground + binding.settingsBlackBackgroundHolder.setOnClickListener { + binding.settingsBlackBackground.toggle() + config.blackBackground = binding.settingsBlackBackground.isChecked } } private fun setupScrollHorizontally() { - settings_scroll_horizontally.isChecked = config.scrollHorizontally - settings_scroll_horizontally_holder.setOnClickListener { - settings_scroll_horizontally.toggle() - config.scrollHorizontally = settings_scroll_horizontally.isChecked + binding.settingsScrollHorizontally.isChecked = config.scrollHorizontally + binding.settingsScrollHorizontallyHolder.setOnClickListener { + binding.settingsScrollHorizontally.toggle() + config.scrollHorizontally = binding.settingsScrollHorizontally.isChecked if (config.scrollHorizontally) { config.enablePullToRefresh = false - settings_enable_pull_to_refresh.isChecked = false + binding.settingsEnablePullToRefresh.isChecked = false } } } private fun setupHideSystemUI() { - settings_hide_system_ui.isChecked = config.hideSystemUI - settings_hide_system_ui_holder.setOnClickListener { - settings_hide_system_ui.toggle() - config.hideSystemUI = settings_hide_system_ui.isChecked + binding.settingsHideSystemUi.isChecked = config.hideSystemUI + binding.settingsHideSystemUiHolder.setOnClickListener { + binding.settingsHideSystemUi.toggle() + config.hideSystemUI = binding.settingsHideSystemUi.isChecked } } private fun setupHiddenItemPasswordProtection() { - settings_hidden_item_password_protection_holder.beGoneIf(isRPlus() && !isExternalStorageManager()) - settings_hidden_item_password_protection.isChecked = config.isHiddenPasswordProtectionOn - settings_hidden_item_password_protection_holder.setOnClickListener { + binding.settingsHiddenItemPasswordProtectionHolder.beGoneIf(isRPlus() && !isExternalStorageManager()) + binding.settingsHiddenItemPasswordProtection.isChecked = config.isHiddenPasswordProtectionOn + binding.settingsHiddenItemPasswordProtectionHolder.setOnClickListener { val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success -> if (success) { val hasPasswordProtection = config.isHiddenPasswordProtectionOn - settings_hidden_item_password_protection.isChecked = !hasPasswordProtection + binding.settingsHiddenItemPasswordProtection.isChecked = !hasPasswordProtection config.isHiddenPasswordProtectionOn = !hasPasswordProtection config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash config.hiddenProtectionType = type if (config.isHiddenPasswordProtectionOn) { val confirmationTextId = if (config.hiddenProtectionType == PROTECTION_FINGERPRINT) - R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully - ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { } + com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully + ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { } } } } @@ -357,22 +364,22 @@ class SettingsActivity : SimpleActivity() { } private fun setupExcludedItemPasswordProtection() { - settings_excluded_item_password_protection_holder.beGoneIf(settings_hidden_item_password_protection_holder.isVisible()) - settings_excluded_item_password_protection.isChecked = config.isExcludedPasswordProtectionOn - settings_excluded_item_password_protection_holder.setOnClickListener { + binding.settingsExcludedItemPasswordProtectionHolder.beGoneIf(binding.settingsHiddenItemPasswordProtectionHolder.isVisible()) + binding.settingsExcludedItemPasswordProtection.isChecked = config.isExcludedPasswordProtectionOn + binding.settingsExcludedItemPasswordProtectionHolder.setOnClickListener { val tabToShow = if (config.isExcludedPasswordProtectionOn) config.excludedProtectionType else SHOW_ALL_TABS SecurityDialog(this, config.excludedPasswordHash, tabToShow) { hash, type, success -> if (success) { val hasPasswordProtection = config.isExcludedPasswordProtectionOn - settings_excluded_item_password_protection.isChecked = !hasPasswordProtection + binding.settingsExcludedItemPasswordProtection.isChecked = !hasPasswordProtection config.isExcludedPasswordProtectionOn = !hasPasswordProtection config.excludedPasswordHash = if (hasPasswordProtection) "" else hash config.excludedProtectionType = type if (config.isExcludedPasswordProtectionOn) { val confirmationTextId = if (config.excludedProtectionType == PROTECTION_FINGERPRINT) - R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully - ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { } + com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully + ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { } } } } @@ -380,21 +387,21 @@ class SettingsActivity : SimpleActivity() { } private fun setupAppPasswordProtection() { - settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn - settings_app_password_protection_holder.setOnClickListener { + binding.settingsAppPasswordProtection.isChecked = config.isAppPasswordProtectionOn + binding.settingsAppPasswordProtectionHolder.setOnClickListener { val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success -> if (success) { val hasPasswordProtection = config.isAppPasswordProtectionOn - settings_app_password_protection.isChecked = !hasPasswordProtection + binding.settingsAppPasswordProtection.isChecked = !hasPasswordProtection config.isAppPasswordProtectionOn = !hasPasswordProtection config.appPasswordHash = if (hasPasswordProtection) "" else hash config.appProtectionType = type if (config.isAppPasswordProtectionOn) { val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT) - R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully - ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { } + com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully + ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { } } } } @@ -402,21 +409,21 @@ class SettingsActivity : SimpleActivity() { } private fun setupFileDeletionPasswordProtection() { - settings_file_deletion_password_protection.isChecked = config.isDeletePasswordProtectionOn - settings_file_deletion_password_protection_holder.setOnClickListener { + binding.settingsFileDeletionPasswordProtection.isChecked = config.isDeletePasswordProtectionOn + binding.settingsFileDeletionPasswordProtectionHolder.setOnClickListener { val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success -> if (success) { val hasPasswordProtection = config.isDeletePasswordProtectionOn - settings_file_deletion_password_protection.isChecked = !hasPasswordProtection + binding.settingsFileDeletionPasswordProtection.isChecked = !hasPasswordProtection config.isDeletePasswordProtectionOn = !hasPasswordProtection config.deletePasswordHash = if (hasPasswordProtection) "" else hash config.deleteProtectionType = type if (config.isDeletePasswordProtectionOn) { val confirmationTextId = if (config.deleteProtectionType == PROTECTION_FINGERPRINT) - R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully - ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { } + com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully + ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { } } } } @@ -424,65 +431,65 @@ class SettingsActivity : SimpleActivity() { } private fun setupDeleteEmptyFolders() { - settings_delete_empty_folders.isChecked = config.deleteEmptyFolders - settings_delete_empty_folders_holder.setOnClickListener { - settings_delete_empty_folders.toggle() - config.deleteEmptyFolders = settings_delete_empty_folders.isChecked + binding.settingsDeleteEmptyFolders.isChecked = config.deleteEmptyFolders + binding.settingsDeleteEmptyFoldersHolder.setOnClickListener { + binding.settingsDeleteEmptyFolders.toggle() + config.deleteEmptyFolders = binding.settingsDeleteEmptyFolders.isChecked } } private fun setupAllowPhotoGestures() { - settings_allow_photo_gestures.isChecked = config.allowPhotoGestures - settings_allow_photo_gestures_holder.setOnClickListener { - settings_allow_photo_gestures.toggle() - config.allowPhotoGestures = settings_allow_photo_gestures.isChecked + binding.settingsAllowPhotoGestures.isChecked = config.allowPhotoGestures + binding.settingsAllowPhotoGesturesHolder.setOnClickListener { + binding.settingsAllowPhotoGestures.toggle() + config.allowPhotoGestures = binding.settingsAllowPhotoGestures.isChecked } } private fun setupAllowVideoGestures() { - settings_allow_video_gestures.isChecked = config.allowVideoGestures - settings_allow_video_gestures_holder.setOnClickListener { - settings_allow_video_gestures.toggle() - config.allowVideoGestures = settings_allow_video_gestures.isChecked + binding.settingsAllowVideoGestures.isChecked = config.allowVideoGestures + binding.settingsAllowVideoGesturesHolder.setOnClickListener { + binding.settingsAllowVideoGestures.toggle() + config.allowVideoGestures = binding.settingsAllowVideoGestures.isChecked } } private fun setupAllowDownGesture() { - settings_allow_down_gesture.isChecked = config.allowDownGesture - settings_allow_down_gesture_holder.setOnClickListener { - settings_allow_down_gesture.toggle() - config.allowDownGesture = settings_allow_down_gesture.isChecked + binding.settingsAllowDownGesture.isChecked = config.allowDownGesture + binding.settingsAllowDownGestureHolder.setOnClickListener { + binding.settingsAllowDownGesture.toggle() + config.allowDownGesture = binding.settingsAllowDownGesture.isChecked } } private fun setupAllowRotatingWithGestures() { - settings_allow_rotating_with_gestures.isChecked = config.allowRotatingWithGestures - settings_allow_rotating_with_gestures_holder.setOnClickListener { - settings_allow_rotating_with_gestures.toggle() - config.allowRotatingWithGestures = settings_allow_rotating_with_gestures.isChecked + binding.settingsAllowRotatingWithGestures.isChecked = config.allowRotatingWithGestures + binding.settingsAllowRotatingWithGesturesHolder.setOnClickListener { + binding.settingsAllowRotatingWithGestures.toggle() + config.allowRotatingWithGestures = binding.settingsAllowRotatingWithGestures.isChecked } } private fun setupShowNotch() { - settings_show_notch_holder.beVisibleIf(isPiePlus()) - settings_show_notch.isChecked = config.showNotch - settings_show_notch_holder.setOnClickListener { - settings_show_notch.toggle() - config.showNotch = settings_show_notch.isChecked + binding.settingsShowNotchHolder.beVisibleIf(isPiePlus()) + binding.settingsShowNotch.isChecked = config.showNotch + binding.settingsShowNotchHolder.setOnClickListener { + binding.settingsShowNotch.toggle() + config.showNotch = binding.settingsShowNotch.isChecked } } private fun setupFileThumbnailStyle() { - settings_file_thumbnail_style_holder.setOnClickListener { + binding.settingsFileThumbnailStyleHolder.setOnClickListener { ChangeFileThumbnailStyleDialog(this) } } private fun setupFolderThumbnailStyle() { - settings_folder_thumbnail_style.text = getFolderStyleText() - settings_folder_thumbnail_style_holder.setOnClickListener { + binding.settingsFolderThumbnailStyle.text = getFolderStyleText() + binding.settingsFolderThumbnailStyleHolder.setOnClickListener { ChangeFolderThumbnailStyleDialog(this) { - settings_folder_thumbnail_style.text = getFolderStyleText() + binding.settingsFolderThumbnailStyle.text = getFolderStyleText() } } } @@ -495,107 +502,107 @@ class SettingsActivity : SimpleActivity() { ) private fun setupKeepLastModified() { - settings_keep_last_modified.isChecked = config.keepLastModified - settings_keep_last_modified_holder.setOnClickListener { + binding.settingsKeepLastModified.isChecked = config.keepLastModified + binding.settingsKeepLastModifiedHolder.setOnClickListener { handleMediaManagementPrompt { - settings_keep_last_modified.toggle() - config.keepLastModified = settings_keep_last_modified.isChecked + binding.settingsKeepLastModified.toggle() + config.keepLastModified = binding.settingsKeepLastModified.isChecked } } } private fun setupEnablePullToRefresh() { - settings_enable_pull_to_refresh.isChecked = config.enablePullToRefresh - settings_enable_pull_to_refresh_holder.setOnClickListener { - settings_enable_pull_to_refresh.toggle() - config.enablePullToRefresh = settings_enable_pull_to_refresh.isChecked + binding.settingsEnablePullToRefresh.isChecked = config.enablePullToRefresh + binding.settingsEnablePullToRefreshHolder.setOnClickListener { + binding.settingsEnablePullToRefresh.toggle() + config.enablePullToRefresh = binding.settingsEnablePullToRefresh.isChecked } } private fun setupAllowZoomingImages() { - settings_allow_zooming_images.isChecked = config.allowZoomingImages + binding.settingsAllowZoomingImages.isChecked = config.allowZoomingImages updateDeepZoomToggleButtons() - settings_allow_zooming_images_holder.setOnClickListener { - settings_allow_zooming_images.toggle() - config.allowZoomingImages = settings_allow_zooming_images.isChecked + binding.settingsAllowZoomingImagesHolder.setOnClickListener { + binding.settingsAllowZoomingImages.toggle() + config.allowZoomingImages = binding.settingsAllowZoomingImages.isChecked updateDeepZoomToggleButtons() } } private fun updateDeepZoomToggleButtons() { - settings_allow_rotating_with_gestures_holder.beVisibleIf(config.allowZoomingImages) - settings_show_highest_quality_holder.beVisibleIf(config.allowZoomingImages) - settings_allow_one_to_one_zoom_holder.beVisibleIf(config.allowZoomingImages) + binding.settingsAllowRotatingWithGesturesHolder.beVisibleIf(config.allowZoomingImages) + binding.settingsShowHighestQualityHolder.beVisibleIf(config.allowZoomingImages) + binding.settingsAllowOneToOneZoomHolder.beVisibleIf(config.allowZoomingImages) } private fun setupShowHighestQuality() { - settings_show_highest_quality.isChecked = config.showHighestQuality - settings_show_highest_quality_holder.setOnClickListener { - settings_show_highest_quality.toggle() - config.showHighestQuality = settings_show_highest_quality.isChecked + binding.settingsShowHighestQuality.isChecked = config.showHighestQuality + binding.settingsShowHighestQualityHolder.setOnClickListener { + binding.settingsShowHighestQuality.toggle() + config.showHighestQuality = binding.settingsShowHighestQuality.isChecked } } private fun setupAllowOneToOneZoom() { - settings_allow_one_to_one_zoom.isChecked = config.allowOneToOneZoom - settings_allow_one_to_one_zoom_holder.setOnClickListener { - settings_allow_one_to_one_zoom.toggle() - config.allowOneToOneZoom = settings_allow_one_to_one_zoom.isChecked + binding.settingsAllowOneToOneZoom.isChecked = config.allowOneToOneZoom + binding.settingsAllowOneToOneZoomHolder.setOnClickListener { + binding.settingsAllowOneToOneZoom.toggle() + config.allowOneToOneZoom = binding.settingsAllowOneToOneZoom.isChecked } } private fun setupAllowInstantChange() { - settings_allow_instant_change.isChecked = config.allowInstantChange - settings_allow_instant_change_holder.setOnClickListener { - settings_allow_instant_change.toggle() - config.allowInstantChange = settings_allow_instant_change.isChecked + binding.settingsAllowInstantChange.isChecked = config.allowInstantChange + binding.settingsAllowInstantChangeHolder.setOnClickListener { + binding.settingsAllowInstantChange.toggle() + config.allowInstantChange = binding.settingsAllowInstantChange.isChecked } } private fun setupShowExtendedDetails() { - settings_show_extended_details.isChecked = config.showExtendedDetails + binding.settingsShowExtendedDetails.isChecked = config.showExtendedDetails updateExtendedDetailsButtons() - settings_show_extended_details_holder.setOnClickListener { - settings_show_extended_details.toggle() - config.showExtendedDetails = settings_show_extended_details.isChecked + binding.settingsShowExtendedDetailsHolder.setOnClickListener { + binding.settingsShowExtendedDetails.toggle() + config.showExtendedDetails = binding.settingsShowExtendedDetails.isChecked updateExtendedDetailsButtons() } } private fun setupHideExtendedDetails() { - settings_hide_extended_details.isChecked = config.hideExtendedDetails - settings_hide_extended_details_holder.setOnClickListener { - settings_hide_extended_details.toggle() - config.hideExtendedDetails = settings_hide_extended_details.isChecked + binding.settingsHideExtendedDetails.isChecked = config.hideExtendedDetails + binding.settingsHideExtendedDetailsHolder.setOnClickListener { + binding.settingsHideExtendedDetails.toggle() + config.hideExtendedDetails = binding.settingsHideExtendedDetails.isChecked } } private fun setupManageExtendedDetails() { - settings_manage_extended_details_holder.setOnClickListener { + binding.settingsManageExtendedDetailsHolder.setOnClickListener { ManageExtendedDetailsDialog(this) { if (config.extendedDetails == 0) { - settings_show_extended_details_holder.callOnClick() + binding.settingsShowExtendedDetailsHolder.callOnClick() } } } } private fun updateExtendedDetailsButtons() { - settings_manage_extended_details_holder.beVisibleIf(config.showExtendedDetails) - settings_hide_extended_details_holder.beVisibleIf(config.showExtendedDetails) + binding.settingsManageExtendedDetailsHolder.beVisibleIf(config.showExtendedDetails) + binding.settingsHideExtendedDetailsHolder.beVisibleIf(config.showExtendedDetails) } private fun setupSkipDeleteConfirmation() { - settings_skip_delete_confirmation.isChecked = config.skipDeleteConfirmation - settings_skip_delete_confirmation_holder.setOnClickListener { - settings_skip_delete_confirmation.toggle() - config.skipDeleteConfirmation = settings_skip_delete_confirmation.isChecked + binding.settingsSkipDeleteConfirmation.isChecked = config.skipDeleteConfirmation + binding.settingsSkipDeleteConfirmationHolder.setOnClickListener { + binding.settingsSkipDeleteConfirmation.toggle() + config.skipDeleteConfirmation = binding.settingsSkipDeleteConfirmation.isChecked } } private fun setupScreenRotation() { - settings_screen_rotation.text = getScreenRotationText() - settings_screen_rotation_holder.setOnClickListener { + binding.settingsScreenRotation.text = getScreenRotationText() + binding.settingsScreenRotationHolder.setOnClickListener { val items = arrayListOf( RadioItem(ROTATE_BY_SYSTEM_SETTING, getString(R.string.screen_rotation_system_setting)), RadioItem(ROTATE_BY_DEVICE_ROTATION, getString(R.string.screen_rotation_device_rotation)), @@ -604,7 +611,7 @@ class SettingsActivity : SimpleActivity() { RadioGroupDialog(this@SettingsActivity, items, config.screenRotation) { config.screenRotation = it as Int - settings_screen_rotation.text = getScreenRotationText() + binding.settingsScreenRotation.text = getScreenRotationText() } } } @@ -618,20 +625,20 @@ class SettingsActivity : SimpleActivity() { ) private fun setupBottomActions() { - settings_bottom_actions_checkbox.isChecked = config.bottomActions - settings_manage_bottom_actions_holder.beVisibleIf(config.bottomActions) - settings_bottom_actions_checkbox_holder.setOnClickListener { - settings_bottom_actions_checkbox.toggle() - config.bottomActions = settings_bottom_actions_checkbox.isChecked - settings_manage_bottom_actions_holder.beVisibleIf(config.bottomActions) + binding.settingsBottomActionsCheckbox.isChecked = config.bottomActions + binding.settingsManageBottomActionsHolder.beVisibleIf(config.bottomActions) + binding.settingsBottomActionsCheckboxHolder.setOnClickListener { + binding.settingsBottomActionsCheckbox.toggle() + config.bottomActions = binding.settingsBottomActionsCheckbox.isChecked + binding.settingsManageBottomActionsHolder.beVisibleIf(config.bottomActions) } } private fun setupManageBottomActions() { - settings_manage_bottom_actions_holder.setOnClickListener { + binding.settingsManageBottomActionsHolder.setOnClickListener { ManageBottomActionsDialog(this) { if (config.visibleBottomActions == 0) { - settings_bottom_actions_checkbox_holder.callOnClick() + binding.settingsBottomActionsCheckboxHolder.callOnClick() config.bottomActions = false config.visibleBottomActions = DEFAULT_BOTTOM_ACTIONS } @@ -641,28 +648,28 @@ class SettingsActivity : SimpleActivity() { private fun setupUseRecycleBin() { updateRecycleBinButtons() - settings_use_recycle_bin.isChecked = config.useRecycleBin - settings_use_recycle_bin_holder.setOnClickListener { - settings_use_recycle_bin.toggle() - config.useRecycleBin = settings_use_recycle_bin.isChecked + binding.settingsUseRecycleBin.isChecked = config.useRecycleBin + binding.settingsUseRecycleBinHolder.setOnClickListener { + binding.settingsUseRecycleBin.toggle() + config.useRecycleBin = binding.settingsUseRecycleBin.isChecked updateRecycleBinButtons() } } private fun setupShowRecycleBin() { - settings_show_recycle_bin.isChecked = config.showRecycleBinAtFolders - settings_show_recycle_bin_holder.setOnClickListener { - settings_show_recycle_bin.toggle() - config.showRecycleBinAtFolders = settings_show_recycle_bin.isChecked + binding.settingsShowRecycleBin.isChecked = config.showRecycleBinAtFolders + binding.settingsShowRecycleBinHolder.setOnClickListener { + binding.settingsShowRecycleBin.toggle() + config.showRecycleBinAtFolders = binding.settingsShowRecycleBin.isChecked updateRecycleBinButtons() } } private fun setupShowRecycleBinLast() { - settings_show_recycle_bin_last.isChecked = config.showRecycleBinLast - settings_show_recycle_bin_last_holder.setOnClickListener { - settings_show_recycle_bin_last.toggle() - config.showRecycleBinLast = settings_show_recycle_bin_last.isChecked + binding.settingsShowRecycleBinLast.isChecked = config.showRecycleBinLast + binding.settingsShowRecycleBinLastHolder.setOnClickListener { + binding.settingsShowRecycleBinLast.toggle() + config.showRecycleBinLast = binding.settingsShowRecycleBinLast.isChecked if (config.showRecycleBinLast) { config.removePinnedFolders(setOf(RECYCLE_BIN)) } @@ -670,9 +677,9 @@ class SettingsActivity : SimpleActivity() { } private fun updateRecycleBinButtons() { - settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders) - settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin) - settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin) + binding.settingsShowRecycleBinLastHolder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders) + binding.settingsEmptyRecycleBinHolder.beVisibleIf(config.useRecycleBin) + binding.settingsShowRecycleBinHolder.beVisibleIf(config.useRecycleBin) } private fun setupEmptyRecycleBin() { @@ -691,18 +698,18 @@ class SettingsActivity : SimpleActivity() { } runOnUiThread { - settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize() + binding.settingsEmptyRecycleBinSize.text = mRecycleBinContentSize.formatSize() } } - settings_empty_recycle_bin_holder.setOnClickListener { + binding.settingsEmptyRecycleBinHolder.setOnClickListener { if (mRecycleBinContentSize == 0L) { - toast(R.string.recycle_bin_empty) + toast(com.simplemobiletools.commons.R.string.recycle_bin_empty) } else { showRecycleBinEmptyingDialog { emptyTheRecycleBin() mRecycleBinContentSize = 0L - settings_empty_recycle_bin_size.text = 0L.formatSize() + binding.settingsEmptyRecycleBinSize.text = 0L.formatSize() } } } @@ -712,22 +719,22 @@ class SettingsActivity : SimpleActivity() { ensureBackgroundThread { val size = cacheDir.getProperSize(true).formatSize() runOnUiThread { - settings_clear_cache_size.text = size + binding.settingsClearCacheSize.text = size } } - settings_clear_cache_holder.setOnClickListener { + binding.settingsClearCacheHolder.setOnClickListener { ensureBackgroundThread { cacheDir.deleteRecursively() runOnUiThread { - settings_clear_cache_size.text = cacheDir.getProperSize(true).formatSize() + binding.settingsClearCacheSize.text = cacheDir.getProperSize(true).formatSize() } } } } private fun setupExportFavorites() { - settings_export_favorites_holder.setOnClickListener { + binding.settingsExportFavoritesHolder.setOnClickListener { if (isQPlus()) { ExportFavoritesDialog(this, getExportFavoritesFilename(), true) { path, filename -> Intent(Intent.ACTION_CREATE_DOCUMENT).apply { @@ -738,7 +745,7 @@ class SettingsActivity : SimpleActivity() { try { startActivityForResult(this, SELECT_EXPORT_FAVORITES_FILE_INTENT) } catch (e: ActivityNotFoundException) { - toast(R.string.system_service_disabled, Toast.LENGTH_LONG) + toast(com.simplemobiletools.commons.R.string.system_service_disabled, Toast.LENGTH_LONG) } catch (e: Exception) { showErrorToast(e) } @@ -761,7 +768,7 @@ class SettingsActivity : SimpleActivity() { private fun exportFavoritesTo(outputStream: OutputStream?) { if (outputStream == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -774,9 +781,9 @@ class SettingsActivity : SimpleActivity() { } } - toast(R.string.exporting_successful) + toast(com.simplemobiletools.commons.R.string.exporting_successful) } else { - toast(R.string.no_items_found) + toast(com.simplemobiletools.commons.R.string.no_items_found) } } } @@ -787,7 +794,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupImportFavorites() { - settings_import_favorites_holder.setOnClickListener { + binding.settingsImportFavoritesHolder.setOnClickListener { if (isQPlus()) { Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) @@ -810,7 +817,7 @@ class SettingsActivity : SimpleActivity() { private fun importFavorites(inputStream: InputStream?) { if (inputStream == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -831,12 +838,12 @@ class SettingsActivity : SimpleActivity() { } } - toast(if (importedItems > 0) R.string.importing_successful else R.string.no_entries_for_importing) + toast(if (importedItems > 0) com.simplemobiletools.commons.R.string.importing_successful else com.simplemobiletools.commons.R.string.no_entries_for_importing) } } private fun setupExportSettings() { - settings_export_holder.setOnClickListener { + binding.settingsExportHolder.setOnClickListener { val configItems = LinkedHashMap().apply { put(IS_USING_SHARED_THEME, config.isUsingSharedTheme) put(TEXT_COLOR, config.textColor) @@ -930,7 +937,7 @@ class SettingsActivity : SimpleActivity() { } private fun setupImportSettings() { - settings_import_holder.setOnClickListener { + binding.settingsImportHolder.setOnClickListener { if (isQPlus()) { Intent(Intent.ACTION_GET_CONTENT).apply { addCategory(Intent.CATEGORY_OPENABLE) @@ -953,7 +960,7 @@ class SettingsActivity : SimpleActivity() { private fun parseFile(inputStream: InputStream?) { if (inputStream == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -987,6 +994,7 @@ class SettingsActivity : SimpleActivity() { checkAppIconColor() } } + USE_ENGLISH -> config.useEnglish = value.toBoolean() WAS_USE_ENGLISH_TOGGLED -> config.wasUseEnglishToggled = value.toBoolean() WIDGET_BG_COLOR -> config.widgetBgColor = value.toInt() @@ -1080,7 +1088,7 @@ class SettingsActivity : SimpleActivity() { } } - toast(if (configValues.size > 0) R.string.settings_imported_successfully else R.string.no_entries_for_importing) + toast(if (configValues.size > 0) com.simplemobiletools.commons.R.string.settings_imported_successfully else com.simplemobiletools.commons.R.string.no_entries_for_importing) runOnUiThread { setupSettingItems() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index af22ede1d..2ddf8567f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -27,12 +27,12 @@ import androidx.media3.exoplayer.source.MediaSource import androidx.media3.exoplayer.source.ProgressiveMediaSource import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ActivityVideoPlayerBinding import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.activity_video_player.* -import kotlinx.android.synthetic.main.bottom_video_time_holder.* -@UnstableApi open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener, TextureView.SurfaceTextureListener { +@UnstableApi +open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener, TextureView.SurfaceTextureListener { private val PLAY_WHEN_READY_DRAG_DELAY = 100L private var mIsFullscreen = false @@ -58,10 +58,13 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* private var mIgnoreCloseDown = false + private lateinit var binding: ActivityVideoPlayerBinding + public override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_video_player) + binding = ActivityVideoPlayerBinding.inflate(layoutInflater) + setContentView(binding.root) setupOptionsMenu() setupOrientation() checkNotchSupport() @@ -70,11 +73,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* override fun onResume() { super.onResume() - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight + binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight window.statusBarColor = Color.TRANSPARENT window.navigationBarColor = Color.TRANSPARENT if (config.blackBackground) { - video_player_holder.background = ColorDrawable(Color.BLACK) + binding.videoPlayerHolder.background = ColorDrawable(Color.BLACK) } if (config.maxBrightness) { @@ -83,12 +86,12 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* window.attributes = attributes } - updateTextColors(video_player_holder) + updateTextColors(binding.videoPlayerHolder) if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - video_toolbar.setPadding(0, 0, navigationBarWidth, 0) + binding.videoToolbar.setPadding(0, 0, navigationBarWidth, 0) } else { - video_toolbar.setPadding(0, 0, 0, 0) + binding.videoToolbar.setPadding(0, 0, 0, 0) } } @@ -105,24 +108,24 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* super.onDestroy() if (!isChangingConfigurations) { pauseVideo() - video_curr_time.text = 0.getFormattedDuration() + binding.bottomVideoTimeHolder.videoCurrTime.text = 0.getFormattedDuration() releaseExoPlayer() - video_seekbar.progress = 0 + binding.bottomVideoTimeHolder.videoSeekbar.progress = 0 mTimerHandler.removeCallbacksAndMessages(null) mPlayWhenReadyHandler.removeCallbacksAndMessages(null) } } private fun setupOptionsMenu() { - (video_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight - video_toolbar.apply { + (binding.videoAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + binding.videoToolbar.apply { setTitleTextColor(Color.WHITE) - overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE) - navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE) + overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE) + navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE) } - updateMenuItemColors(video_toolbar.menu, forceWhiteIcons = true) - video_toolbar.setOnMenuItemClickListener { menuItem -> + updateMenuItemColors(binding.videoToolbar.menu, forceWhiteIcons = true) + binding.videoToolbar.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.menu_change_orientation -> changeOrientation() R.id.menu_open_with -> openPath(mUri!!.toString(), true) @@ -132,7 +135,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* return@setOnMenuItemClickListener true } - video_toolbar.setNavigationOnClickListener { + binding.videoToolbar.setNavigationOnClickListener { finish() } } @@ -141,16 +144,16 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* super.onConfigurationChanged(newConfig) setVideoSize() initTimeHolder() - video_surface_frame.onGlobalLayout { - video_surface_frame.controller.resetState() + binding.videoSurfaceFrame.onGlobalLayout { + binding.videoSurfaceFrame.controller.resetState() } - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight - (video_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight + (binding.videoAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - video_toolbar.setPadding(0, 0, navigationBarWidth, 0) + binding.videoToolbar.setPadding(0, 0, navigationBarWidth, 0) } else { - video_toolbar.setPadding(0, 0, 0, 0) + binding.videoToolbar.setPadding(0, 0, 0, 0) } } @@ -166,7 +169,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* private fun initPlayer() { mUri = intent.data ?: return - video_toolbar.title = getFilenameFromUri(mUri!!) + binding.videoToolbar.title = getFilenameFromUri(mUri!!) initTimeHolder() showSystemUI(true) @@ -175,17 +178,17 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* fullscreenToggled(isFullscreen) } - video_curr_time.setOnClickListener { doSkip(false) } - video_duration.setOnClickListener { doSkip(true) } - video_toggle_play_pause.setOnClickListener { togglePlayPause() } - video_surface_frame.setOnClickListener { toggleFullscreen() } - video_surface_frame.controller.settings.swallowDoubleTaps = true + binding.bottomVideoTimeHolder.videoCurrTime.setOnClickListener { doSkip(false) } + binding.bottomVideoTimeHolder.videoDuration.setOnClickListener { doSkip(true) } + binding.bottomVideoTimeHolder.videoTogglePlayPause.setOnClickListener { togglePlayPause() } + binding.videoSurfaceFrame.setOnClickListener { toggleFullscreen() } + binding.videoSurfaceFrame.controller.settings.swallowDoubleTaps = true - video_next_file.beVisibleIf(intent.getBooleanExtra(SHOW_NEXT_ITEM, false)) - video_next_file.setOnClickListener { handleNextFile() } + binding.bottomVideoTimeHolder.videoNextFile.beVisibleIf(intent.getBooleanExtra(SHOW_NEXT_ITEM, false)) + binding.bottomVideoTimeHolder.videoNextFile.setOnClickListener { handleNextFile() } - video_prev_file.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false)) - video_prev_file.setOnClickListener { handlePrevFile() } + binding.bottomVideoTimeHolder.videoPrevFile.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false)) + binding.bottomVideoTimeHolder.videoPrevFile.setOnClickListener { handlePrevFile() } val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() { override fun onDoubleTap(e: MotionEvent): Boolean { @@ -194,30 +197,30 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* } }) - video_surface_frame.setOnTouchListener { view, event -> + binding.videoSurfaceFrame.setOnTouchListener { view, event -> handleEvent(event) gestureDetector.onTouchEvent(event) false } initExoPlayer() - video_surface.surfaceTextureListener = this + binding.videoSurface.surfaceTextureListener = this if (config.allowVideoGestures) { - video_brightness_controller.initialize(this, slide_info, true, video_player_holder, singleTap = { x, y -> + binding.videoBrightnessController.initialize(this, binding.slideInfo, true, binding.videoPlayerHolder, singleTap = { x, y -> toggleFullscreen() }, doubleTap = { x, y -> doSkip(false) }) - video_volume_controller.initialize(this, slide_info, false, video_player_holder, singleTap = { x, y -> + binding.videoVolumeController.initialize(this, binding.slideInfo, false, binding.videoPlayerHolder, singleTap = { x, y -> toggleFullscreen() }, doubleTap = { x, y -> doSkip(true) }) } else { - video_brightness_controller.beGone() - video_volume_controller.beGone() + binding.videoBrightnessController.beGone() + binding.videoVolumeController.beGone() } if (config.hideSystemUI) { @@ -267,8 +270,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* override fun onPositionDiscontinuity(oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, @Player.DiscontinuityReason reason: Int) { // Reset progress views when video loops. if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) { - video_seekbar.progress = 0 - video_curr_time.text = 0.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.progress = 0 + binding.bottomVideoTimeHolder.videoCurrTime.text = 0.getFormattedDuration() } } @@ -289,10 +292,10 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* private fun videoPrepared() { if (!mWasVideoStarted) { - video_toggle_play_pause.beVisible() + binding.bottomVideoTimeHolder.videoTogglePlayPause.beVisible() mDuration = (mExoPlayer!!.duration / 1000).toInt() - video_seekbar.max = mDuration - video_duration.text = mDuration.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration + binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration() setPosition(mCurrTime) if (config.rememberLastVideoPosition) { @@ -302,7 +305,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* if (config.autoplayVideos) { resumeVideo() } else { - video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) } } } @@ -317,7 +320,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* } private fun resumeVideo() { - video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_pause_outline_vector) if (mExoPlayer == null) { return } @@ -334,7 +337,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* } private fun pauseVideo() { - video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline_vector) + binding.bottomVideoTimeHolder.videoTogglePlayPause.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) if (mExoPlayer == null) { return } @@ -358,8 +361,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* private fun setPosition(seconds: Int) { mExoPlayer?.seekTo(seconds * 1000L) - video_seekbar.progress = seconds - video_curr_time.text = seconds.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.progress = seconds + binding.bottomVideoTimeHolder.videoCurrTime.text = seconds.getFormattedDuration() } private fun setLastVideoSavedPosition() { @@ -376,8 +379,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* clearLastVideoSavedProgress() mCurrTime = (mExoPlayer!!.duration / 1000).toInt() - video_seekbar.progress = video_seekbar.max - video_curr_time.text = mDuration.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.progress = binding.bottomVideoTimeHolder.videoSeekbar.max + binding.bottomVideoTimeHolder.videoCurrTime.text = mDuration.getFormattedDuration() pauseVideo() } @@ -410,7 +413,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* val screenProportion = screenWidth.toFloat() / screenHeight.toFloat() - video_surface.layoutParams.apply { + binding.videoSurface.layoutParams.apply { if (videoProportion > screenProportion) { width = screenWidth height = (screenWidth.toFloat() / videoProportion).toInt() @@ -418,7 +421,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* width = (videoProportion * screenHeight.toFloat()).toInt() height = screenHeight } - video_surface.layoutParams = this + binding.videoSurface.layoutParams = this } val multiplier = if (screenWidth > screenHeight) 0.5 else 0.8 @@ -456,26 +459,31 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* val newAlpha = if (isFullScreen) 0f else 1f arrayOf( - video_prev_file, - video_toggle_play_pause, - video_next_file, - video_curr_time, - video_seekbar, - video_duration, - top_shadow, - video_bottom_gradient + binding.bottomVideoTimeHolder.videoPrevFile, + binding.bottomVideoTimeHolder.videoTogglePlayPause, + binding.bottomVideoTimeHolder.videoNextFile, + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoSeekbar, + binding.bottomVideoTimeHolder.videoDuration, + binding.topShadow, + binding.videoBottomGradient ).forEach { it.animate().alpha(newAlpha).start() } - video_seekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) - arrayOf(video_prev_file, video_next_file, video_curr_time, video_duration).forEach { + binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) + arrayOf( + binding.bottomVideoTimeHolder.videoPrevFile, + binding.bottomVideoTimeHolder.videoNextFile, + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoDuration, + ).forEach { it.isClickable = !mIsFullscreen } - video_appbar.animate().alpha(newAlpha).withStartAction { - video_appbar.beVisible() + binding.videoAppbar.animate().alpha(newAlpha).withStartAction { + binding.videoAppbar.beVisible() }.withEndAction { - video_appbar.beVisibleIf(newAlpha == 1f) + binding.videoAppbar.beVisibleIf(newAlpha == 1f) }.start() } @@ -492,11 +500,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* } } - video_time_holder.setPadding(0, 0, right, bottom) - video_seekbar.setOnSeekBarChangeListener(this) - video_seekbar.max = mDuration - video_duration.text = mDuration.getFormattedDuration() - video_curr_time.text = mCurrTime.getFormattedDuration() + binding.bottomVideoTimeHolder.videoTimeHolder.setPadding(0, 0, right, bottom) + binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(this) + binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration + binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration() + binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration() setupTimer() } @@ -505,8 +513,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* override fun run() { if (mExoPlayer != null && !mIsDragged && mIsPlaying) { mCurrTime = (mExoPlayer!!.currentPosition / 1000).toInt() - video_seekbar.progress = mCurrTime - video_curr_time.text = mCurrTime.getFormattedDuration() + binding.bottomVideoTimeHolder.videoSeekbar.progress = mCurrTime + binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration() } mTimerHandler.postDelayed(this, 1000) @@ -543,9 +551,13 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* val diffX = event.rawX - mTouchDownX val diffY = event.rawY - mTouchDownY - if (mIsDragged || (Math.abs(diffX) > mDragThreshold && Math.abs(diffX) > Math.abs(diffY)) && video_surface_frame.controller.state.zoom == 1f) { + if (mIsDragged || (Math.abs(diffX) > mDragThreshold && Math.abs(diffX) > Math.abs(diffY)) && binding.videoSurfaceFrame.controller.state.zoom == 1f) { if (!mIsDragged) { - arrayOf(video_curr_time, video_seekbar, video_duration).forEach { + arrayOf( + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoSeekbar, + binding.bottomVideoTimeHolder.videoDuration, + ).forEach { it.animate().alpha(1f).start() } } @@ -570,7 +582,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* val downGestureDuration = System.currentTimeMillis() - mTouchDownTime if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold && downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && - video_surface_frame.controller.state.zoom == 1f + binding.videoSurfaceFrame.controller.state.zoom == 1f ) { supportFinishAfterTransition() } @@ -578,7 +590,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* mIgnoreCloseDown = false if (mIsDragged) { if (mIsFullscreen) { - arrayOf(video_curr_time, video_seekbar, video_duration).forEach { + arrayOf( + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoSeekbar, + binding.bottomVideoTimeHolder.videoDuration, + ).forEach { it.animate().alpha(0f).start() } } @@ -653,7 +669,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.* override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) { - mExoPlayer?.setVideoSurface(Surface(video_surface!!.surfaceTexture)) + mExoPlayer?.setVideoSurface(Surface(binding.videoSurface.surfaceTexture)) } override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index eb6e2c94a..808bb89b4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -43,6 +43,7 @@ import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.MyPagerAdapter import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask +import com.simplemobiletools.gallery.pro.databinding.ActivityMediumBinding import com.simplemobiletools.gallery.pro.dialogs.DeleteWithRememberDialog import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog import com.simplemobiletools.gallery.pro.dialogs.SlideshowDialog @@ -53,8 +54,6 @@ import com.simplemobiletools.gallery.pro.fragments.ViewPagerFragment import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem -import kotlinx.android.synthetic.main.activity_medium.* -import kotlinx.android.synthetic.main.bottom_actions.* import java.io.File import kotlin.math.min @@ -83,15 +82,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private var mFavoritePaths = ArrayList() private var mIgnoredPaths = ArrayList() + private lateinit var binding: ActivityMediumBinding + override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true super.onCreate(savedInstanceState) - setContentView(R.layout.activity_medium) + binding = ActivityMediumBinding.inflate(layoutInflater) + setContentView(binding.root) setupOptionsMenu() refreshMenuItems() window.decorView.setBackgroundColor(getProperBackgroundColor()) - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight + binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight checkNotchSupport() (MediaActivity.mMedia.clone() as ArrayList).filterIsInstanceTo(mMediaFiles, Medium::class.java) @@ -99,7 +101,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (it) { initViewPager() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -132,7 +134,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View refreshMenuItems() val filename = getCurrentMedium()?.name ?: mPath.getFilenameFromPath() - medium_viewer_toolbar.title = filename + binding.mediumViewerToolbar.title = filename } override fun onPause() { @@ -162,7 +164,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View runOnUiThread { val rotationDegrees = getCurrentPhotoFragment()?.mCurrentRotationDegrees ?: 0 - medium_viewer_toolbar.menu.apply { + binding.mediumViewerToolbar.menu.apply { findItem(R.id.menu_show_on_map).isVisible = visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP == 0 findItem(R.id.menu_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0 findItem(R.id.menu_properties).isVisible = visibleBottomActions and BOTTOM_ACTION_PROPERTIES == 0 @@ -209,15 +211,15 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun setupOptionsMenu() { - (medium_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight - medium_viewer_toolbar.apply { + (binding.mediumViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + binding.mediumViewerToolbar.apply { setTitleTextColor(Color.WHITE) - overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE) - navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE) + overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE) + navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE) } - updateMenuItemColors(medium_viewer_toolbar.menu, forceWhiteIcons = true) - medium_viewer_toolbar.setOnMenuItemClickListener { menuItem -> + updateMenuItemColors(binding.mediumViewerToolbar.menu, forceWhiteIcons = true) + binding.mediumViewerToolbar.setOnMenuItemClickListener { menuItem -> if (getCurrentMedium() == null) { return@setOnMenuItemClickListener true } @@ -255,7 +257,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return@setOnMenuItemClickListener true } - medium_viewer_toolbar.setNavigationOnClickListener { + binding.mediumViewerToolbar.setNavigationOnClickListener { finish() } } @@ -280,7 +282,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) initBottomActionsLayout() - (medium_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + (binding.mediumViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight } private fun initViewPager() { @@ -314,7 +316,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (mPath.isEmpty()) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) finish() return } @@ -368,9 +370,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View isShowingRecycleBin -> RECYCLE_BIN else -> mPath.getParentPath() } - medium_viewer_toolbar.title = mPath.getFilenameFromPath() + binding.mediumViewerToolbar.title = mPath.getFilenameFromPath() - view_pager.onGlobalLayout { + binding.viewPager.onGlobalLayout { if (!isDestroyed) { if (mMediaFiles.isNotEmpty()) { gotMedia(mMediaFiles as ArrayList, refetchViewPagerPosition = true) @@ -390,14 +392,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } refreshViewPager(true) - view_pager.offscreenPageLimit = 2 + binding.viewPager.offscreenPageLimit = 2 if (config.blackBackground) { - view_pager.background = ColorDrawable(Color.BLACK) + binding.viewPager.background = ColorDrawable(Color.BLACK) } if (config.hideSystemUI) { - view_pager.onGlobalLayout { + binding.viewPager.onGlobalLayout { Handler().postDelayed({ fragmentClicked() }, HIDE_SYSTEM_UI_DELAY) @@ -469,7 +471,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media) if (!isDestroyed) { pagerAdapter.shouldInitFragment = mPos < 5 - view_pager.apply { + binding.viewPager.apply { // must remove the listener before changing adapter, otherwise it might cause `mPos` to be set to 0 removeOnPageChangeListener(this@ViewPagerActivity) adapter = pagerAdapter @@ -494,10 +496,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun startSlideshow() { if (getMediaForSlideshow()) { - view_pager.onGlobalLayout { + binding.viewPager.onGlobalLayout { if (!isDestroyed) { if (config.slideshowAnimation == SLIDESHOW_ANIMATION_FADE) { - view_pager.setPageTransformer(false, FadePageTransformer()) + binding.viewPager.setPageTransformer(false, FadePageTransformer()) } hideSystemUI(true) @@ -513,35 +515,35 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun goToNextMedium(forward: Boolean) { - val oldPosition = view_pager.currentItem + val oldPosition = binding.viewPager.currentItem val newPosition = if (forward) oldPosition + 1 else oldPosition - 1 - if (newPosition == -1 || newPosition > view_pager.adapter!!.count - 1) { + if (newPosition == -1 || newPosition > binding.viewPager.adapter!!.count - 1) { slideshowEnded(forward) } else { - view_pager.setCurrentItem(newPosition, false) + binding.viewPager.setCurrentItem(newPosition, false) } } private fun animatePagerTransition(forward: Boolean) { - val oldPosition = view_pager.currentItem - val animator = ValueAnimator.ofInt(0, view_pager.width) + val oldPosition = binding.viewPager.currentItem + val animator = ValueAnimator.ofInt(0, binding.viewPager.width) animator.addListener(object : Animator.AnimatorListener { override fun onAnimationEnd(animation: Animator) { - if (view_pager.isFakeDragging) { + if (binding.viewPager.isFakeDragging) { try { - view_pager.endFakeDrag() + binding.viewPager.endFakeDrag() } catch (ignored: Exception) { stopSlideshow() } - if (view_pager.currentItem == oldPosition) { + if (binding.viewPager.currentItem == oldPosition) { slideshowEnded(forward) } } } override fun onAnimationCancel(animation: Animator) { - view_pager.endFakeDrag() + binding.viewPager.endFakeDrag() } override fun onAnimationStart(animation: Animator) {} @@ -559,12 +561,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View animator.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener { var oldDragPosition = 0 override fun onAnimationUpdate(animation: ValueAnimator) { - if (view_pager?.isFakeDragging == true) { + if (binding.viewPager?.isFakeDragging == true) { val dragPosition = animation.animatedValue as Int val dragOffset = dragPosition - oldDragPosition oldDragPosition = dragPosition try { - view_pager.fakeDragBy(dragOffset * (if (forward) -1f else 1f)) + binding.viewPager.fakeDragBy(dragOffset * (if (forward) -1f else 1f)) } catch (e: Exception) { stopSlideshow() } @@ -572,16 +574,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } }) - view_pager.beginFakeDrag() + binding.viewPager.beginFakeDrag() animator.start() } private fun slideshowEnded(forward: Boolean) { if (config.loopSlideshow) { if (forward) { - view_pager.setCurrentItem(0, false) + binding.viewPager.setCurrentItem(0, false) } else { - view_pager.setCurrentItem(view_pager.adapter!!.count - 1, false) + binding.viewPager.setCurrentItem(binding.viewPager.adapter!!.count - 1, false) } } else { stopSlideshow() @@ -591,7 +593,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun stopSlideshow() { if (mIsSlideshowActive) { - view_pager.setPageTransformer(false, DefaultPageTransformer()) + binding.viewPager.setPageTransformer(false, DefaultPageTransformer()) mIsSlideshowActive = false showSystemUI(true) mSlideshowHandler.removeCallbacksAndMessages(null) @@ -665,7 +667,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun copyMoveTo(isCopyOperation: Boolean) { val currPath = getCurrentPath() if (!isCopyOperation && currPath.startsWith(recycleBinPath)) { - toast(R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG) + toast(com.simplemobiletools.commons.R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG) return } @@ -687,7 +689,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun toggleFileVisibility(hide: Boolean, callback: (() -> Unit)? = null) { toggleFileVisibility(getCurrentPath(), hide) { val newFileName = it.getFilenameFromPath() - medium_viewer_toolbar.title = newFileName + binding.mediumViewerToolbar.title = newFileName getCurrentMedium()!!.apply { name = newFileName @@ -727,12 +729,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun getChangeOrientationIcon(): Int { return if (mIsOrientationLocked) { if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { - R.drawable.ic_orientation_portrait_vector + com.simplemobiletools.commons.R.drawable.ic_orientation_portrait_vector } else { - R.drawable.ic_orientation_landscape_vector + com.simplemobiletools.commons.R.drawable.ic_orientation_landscape_vector } } else { - R.drawable.ic_orientation_auto_vector + com.simplemobiletools.commons.R.drawable.ic_orientation_auto_vector } } @@ -745,11 +747,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return@handleSAFDialog } - toast(R.string.saving) + toast(com.simplemobiletools.commons.R.string.saving) ensureBackgroundThread { val photoFragment = getCurrentPhotoFragment() ?: return@ensureBackgroundThread saveRotatedImageToFile(currPath, newPath, photoFragment.mCurrentRotationDegrees, true) { - toast(R.string.file_saved) + toast(com.simplemobiletools.commons.R.string.file_saved) getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0 refreshMenuItems() } @@ -814,7 +816,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return false } - private fun getCurrentFragment() = (view_pager.adapter as? MyPagerAdapter)?.getCurrentFragment(view_pager.currentItem) + private fun getCurrentFragment() = (binding.viewPager.adapter as? MyPagerAdapter)?.getCurrentFragment(binding.viewPager.currentItem) private fun showProperties() { if (getCurrentMedium() != null) { @@ -823,63 +825,63 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun initBottomActionsLayout() { - bottom_actions.layoutParams.height = resources.getDimension(R.dimen.bottom_actions_height).toInt() + navigationBarHeight + binding.bottomActions.root.layoutParams.height = resources.getDimension(R.dimen.bottom_actions_height).toInt() + navigationBarHeight if (config.bottomActions) { - bottom_actions.beVisible() + binding.bottomActions.root.beVisible() } else { - bottom_actions.beGone() + binding.bottomActions.root.beGone() } if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - medium_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) + binding.mediumViewerToolbar.setPadding(0, 0, navigationBarWidth, 0) } else { - medium_viewer_toolbar.setPadding(0, 0, 0, 0) + binding.mediumViewerToolbar.setPadding(0, 0, 0, 0) } } private fun initBottomActionButtons() { val currentMedium = getCurrentMedium() val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0 - bottom_favorite.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 && currentMedium?.getIsInRecycleBin() == false) - bottom_favorite.setOnLongClickListener { toast(R.string.toggle_favorite); true } - bottom_favorite.setOnClickListener { + binding.bottomActions.bottomFavorite.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 && currentMedium?.getIsInRecycleBin() == false) + binding.bottomActions.bottomFavorite.setOnLongClickListener { toast(R.string.toggle_favorite); true } + binding.bottomActions.bottomFavorite.setOnClickListener { toggleFavorite() } - bottom_edit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && currentMedium?.isSVG() == false) - bottom_edit.setOnLongClickListener { toast(R.string.edit); true } - bottom_edit.setOnClickListener { + binding.bottomActions.bottomEdit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && currentMedium?.isSVG() == false) + binding.bottomActions.bottomEdit.setOnLongClickListener { toast(R.string.edit); true } + binding.bottomActions.bottomEdit.setOnClickListener { openEditor(getCurrentPath()) } - bottom_share.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0) - bottom_share.setOnLongClickListener { toast(R.string.share); true } - bottom_share.setOnClickListener { + binding.bottomActions.bottomShare.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0) + binding.bottomActions.bottomShare.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.share); true } + binding.bottomActions.bottomShare.setOnClickListener { shareMediumPath(getCurrentPath()) } - bottom_delete.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_DELETE != 0) - bottom_delete.setOnLongClickListener { toast(R.string.delete); true } - bottom_delete.setOnClickListener { + binding.bottomActions.bottomDelete.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_DELETE != 0) + binding.bottomActions.bottomDelete.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.delete); true } + binding.bottomActions.bottomDelete.setOnClickListener { checkDeleteConfirmation() } - bottom_rotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true) - bottom_rotate.setOnLongClickListener { toast(R.string.rotate); true } - bottom_rotate.setOnClickListener { + binding.bottomActions.bottomRotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true) + binding.bottomActions.bottomRotate.setOnLongClickListener { toast(R.string.rotate); true } + binding.bottomActions.bottomRotate.setOnClickListener { rotateImage(90) } - bottom_properties.applyColorFilter(Color.WHITE) - bottom_properties.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_PROPERTIES != 0) - bottom_properties.setOnLongClickListener { toast(R.string.properties); true } - bottom_properties.setOnClickListener { + binding.bottomActions.bottomProperties.applyColorFilter(Color.WHITE) + binding.bottomActions.bottomProperties.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_PROPERTIES != 0) + binding.bottomActions.bottomProperties.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.properties); true } + binding.bottomActions.bottomProperties.setOnClickListener { showProperties() } - bottom_change_orientation.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0) - bottom_change_orientation.setOnLongClickListener { toast(R.string.change_orientation); true } - bottom_change_orientation.setOnClickListener { + binding.bottomActions.bottomChangeOrientation.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0) + binding.bottomActions.bottomChangeOrientation.setOnLongClickListener { toast(R.string.change_orientation); true } + binding.bottomActions.bottomChangeOrientation.setOnClickListener { requestedOrientation = when (requestedOrientation) { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED @@ -889,24 +891,24 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View updateBottomActionIcons(currentMedium) } - bottom_slideshow.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SLIDESHOW != 0) - bottom_slideshow.setOnLongClickListener { toast(R.string.slideshow); true } - bottom_slideshow.setOnClickListener { + binding.bottomActions.bottomSlideshow.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SLIDESHOW != 0) + binding.bottomActions.bottomSlideshow.setOnLongClickListener { toast(R.string.slideshow); true } + binding.bottomActions.bottomSlideshow.setOnClickListener { initSlideshow() } - bottom_show_on_map.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0) - bottom_show_on_map.setOnLongClickListener { toast(R.string.show_on_map); true } - bottom_show_on_map.setOnClickListener { + binding.bottomActions.bottomShowOnMap.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0) + binding.bottomActions.bottomShowOnMap.setOnLongClickListener { toast(R.string.show_on_map); true } + binding.bottomActions.bottomShowOnMap.setOnClickListener { showFileOnMap(getCurrentPath()) } - bottom_toggle_file_visibility.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0) - bottom_toggle_file_visibility.setOnLongClickListener { - toast(if (currentMedium?.isHidden() == true) R.string.unhide else R.string.hide); true + binding.bottomActions.bottomToggleFileVisibility.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0) + binding.bottomActions.bottomToggleFileVisibility.setOnLongClickListener { + toast(if (currentMedium?.isHidden() == true) com.simplemobiletools.commons.R.string.unhide else com.simplemobiletools.commons.R.string.hide); true } - bottom_toggle_file_visibility.setOnClickListener { + binding.bottomActions.bottomToggleFileVisibility.setOnClickListener { currentMedium?.apply { toggleFileVisibility(!isHidden()) { updateBottomActionIcons(currentMedium) @@ -914,33 +916,33 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - bottom_rename.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RENAME != 0 && currentMedium?.getIsInRecycleBin() == false) - bottom_rename.setOnLongClickListener { toast(R.string.rename); true } - bottom_rename.setOnClickListener { + binding.bottomActions.bottomRename.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RENAME != 0 && currentMedium?.getIsInRecycleBin() == false) + binding.bottomActions.bottomRename.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.rename); true } + binding.bottomActions.bottomRename.setOnClickListener { checkMediaManagementAndRename() } - bottom_set_as.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0) - bottom_set_as.setOnLongClickListener { toast(R.string.set_as); true } - bottom_set_as.setOnClickListener { + binding.bottomActions.bottomSetAs.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0) + binding.bottomActions.bottomSetAs.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.set_as); true } + binding.bottomActions.bottomSetAs.setOnClickListener { setAs(getCurrentPath()) } - bottom_copy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0) - bottom_copy.setOnLongClickListener { toast(R.string.copy); true } - bottom_copy.setOnClickListener { + binding.bottomActions.bottomCopy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0) + binding.bottomActions.bottomCopy.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.copy); true } + binding.bottomActions.bottomCopy.setOnClickListener { checkMediaManagementAndCopy(true) } - bottom_move.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_MOVE != 0) - bottom_move.setOnLongClickListener { toast(R.string.move); true } - bottom_move.setOnClickListener { + binding.bottomActions.bottomMove.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_MOVE != 0) + binding.bottomActions.bottomMove.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.move); true } + binding.bottomActions.bottomMove.setOnClickListener { moveFileTo() } - bottom_resize.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RESIZE != 0 && currentMedium?.isImage() == true) - bottom_resize.setOnLongClickListener { toast(R.string.resize); true } - bottom_resize.setOnClickListener { + binding.bottomActions.bottomResize.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RESIZE != 0 && currentMedium?.isImage() == true) + binding.bottomActions.bottomResize.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.resize); true } + binding.bottomActions.bottomResize.setOnClickListener { resizeImage() } } @@ -950,14 +952,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return } - val favoriteIcon = if (medium.isFavorite) R.drawable.ic_star_vector else R.drawable.ic_star_outline_vector - bottom_favorite.setImageResource(favoriteIcon) + val favoriteIcon = + if (medium.isFavorite) com.simplemobiletools.commons.R.drawable.ic_star_vector else com.simplemobiletools.commons.R.drawable.ic_star_outline_vector + binding.bottomActions.bottomFavorite.setImageResource(favoriteIcon) - val hideIcon = if (medium.isHidden()) R.drawable.ic_unhide_vector else R.drawable.ic_hide_vector - bottom_toggle_file_visibility.setImageResource(hideIcon) + val hideIcon = + if (medium.isHidden()) com.simplemobiletools.commons.R.drawable.ic_unhide_vector else com.simplemobiletools.commons.R.drawable.ic_hide_vector + binding.bottomActions.bottomToggleFileVisibility.setImageResource(hideIcon) - bottom_rotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true) - bottom_change_orientation.setImageResource(getChangeOrientationIcon()) + binding.bottomActions.bottomRotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true) + binding.bottomActions.bottomChangeOrientation.setImageResource(getChangeOrientationIcon()) } private fun toggleFavorite() { @@ -989,7 +993,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View try { val resolution = path.getImageResolution(this) if (resolution == null) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -1073,9 +1077,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val isInRecycleBin = getCurrentMedium()!!.getIsInRecycleBin() val baseString = if (config.useRecycleBin && !config.tempSkipRecycleBin && !isInRecycleBin) { - R.string.move_to_recycle_bin_confirmation + com.simplemobiletools.commons.R.string.move_to_recycle_bin_confirmation } else { - R.string.deletion_confirmation + com.simplemobiletools.commons.R.string.deletion_confirmation } val message = String.format(resources.getString(baseString), filenameAndSize) @@ -1128,7 +1132,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } @@ -1186,7 +1190,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val isSDOrOtgRootFolder = isAStorageRootFolder(oldPath.getParentPath()) && !oldPath.startsWith(internalStoragePath) if (isRPlus() && isSDOrOtgRootFolder && !isExternalStorageManager()) { - toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) + toast(com.simplemobiletools.commons.R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) return } @@ -1320,12 +1324,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun isSlideShowActive() = mIsSlideshowActive override fun goToPrevItem() { - view_pager.setCurrentItem(view_pager.currentItem - 1, false) + binding.viewPager.setCurrentItem(binding.viewPager.currentItem - 1, false) checkOrientation() } override fun goToNextItem() { - view_pager.setCurrentItem(view_pager.currentItem + 1, false) + binding.viewPager.setCurrentItem(binding.viewPager.currentItem + 1, false) checkOrientation() } @@ -1340,14 +1344,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) putExtra(IS_FROM_GALLERY, true) putExtra(REAL_FILE_PATH, path) - putExtra(SHOW_PREV_ITEM, view_pager.currentItem != 0) - putExtra(SHOW_NEXT_ITEM, view_pager.currentItem != mMediaFiles.lastIndex) + putExtra(SHOW_PREV_ITEM, binding.viewPager.currentItem != 0) + putExtra(SHOW_NEXT_ITEM, binding.viewPager.currentItem != mMediaFiles.lastIndex) try { startActivityForResult(this, REQUEST_VIEW_VIDEO) } catch (e: ActivityNotFoundException) { if (!tryGenericMimeType(this, mimeType, newUri)) { - toast(R.string.no_app_found) + toast(com.simplemobiletools.commons.R.string.no_app_found) } } catch (e: Exception) { showErrorToast(e) @@ -1366,20 +1370,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun fullscreenToggled() { - view_pager.adapter?.let { + binding.viewPager.adapter?.let { (it as MyPagerAdapter).toggleFullscreen(mIsFullScreen) val newAlpha = if (mIsFullScreen) 0f else 1f - top_shadow.animate().alpha(newAlpha).start() - bottom_actions.animate().alpha(newAlpha).withStartAction { - bottom_actions.beVisible() + binding.topShadow.animate().alpha(newAlpha).start() + binding.bottomActions.root.animate().alpha(newAlpha).withStartAction { + binding.bottomActions.root.beVisible() }.withEndAction { - bottom_actions.beVisibleIf(newAlpha == 1f) + binding.bottomActions.root.beVisibleIf(newAlpha == 1f) }.start() - medium_viewer_appbar.animate().alpha(newAlpha).withStartAction { - medium_viewer_appbar.beVisible() + binding.mediumViewerAppbar.animate().alpha(newAlpha).withStartAction { + binding.mediumViewerAppbar.beVisible() }.withEndAction { - medium_viewer_appbar.beVisibleIf(newAlpha == 1f) + binding.mediumViewerAppbar.beVisibleIf(newAlpha == 1f) }.start() } } @@ -1388,7 +1392,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View runOnUiThread { val medium = getCurrentMedium() if (medium != null) { - medium_viewer_toolbar.title = medium.path.getFilenameFromPath() + binding.mediumViewerToolbar.title = medium.path.getFilenameFromPath() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 3cd69b0a1..dc11e03bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -13,13 +13,13 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ActivityWidgetConfigBinding import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.MyWidgetProvider import com.simplemobiletools.gallery.pro.helpers.ROUNDED_CORNERS_NONE import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Widget -import kotlinx.android.synthetic.main.activity_widget_config.* class WidgetConfigureActivity : SimpleActivity() { private var mBgAlpha = 0f @@ -30,11 +30,14 @@ class WidgetConfigureActivity : SimpleActivity() { private var mFolderPath = "" private var mDirectories = ArrayList() + private lateinit var binding: ActivityWidgetConfigBinding + public override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false super.onCreate(savedInstanceState) setResult(RESULT_CANCELED) - setContentView(R.layout.activity_widget_config) + binding = ActivityWidgetConfigBinding.inflate(layoutInflater) + setContentView(binding.root) initVariables() mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID @@ -43,21 +46,21 @@ class WidgetConfigureActivity : SimpleActivity() { finish() } - config_save.setOnClickListener { saveConfig() } - config_bg_color.setOnClickListener { pickBackgroundColor() } - config_text_color.setOnClickListener { pickTextColor() } - folder_picker_value.setOnClickListener { changeSelectedFolder() } - config_image_holder.setOnClickListener { changeSelectedFolder() } + binding.configSave.setOnClickListener { saveConfig() } + binding.configBgColor.setOnClickListener { pickBackgroundColor() } + binding.configTextColor.setOnClickListener { pickTextColor() } + binding.folderPickerValue.setOnClickListener { changeSelectedFolder() } + binding.configImageHolder.setOnClickListener { changeSelectedFolder() } - updateTextColors(folder_picker_holder) + updateTextColors(binding.folderPickerHolder) val primaryColor = getProperPrimaryColor() - config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor) - folder_picker_holder.background = ColorDrawable(getProperBackgroundColor()) + binding.configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor) + binding.folderPickerHolder.background = ColorDrawable(getProperBackgroundColor()) - folder_picker_show_folder_name.isChecked = config.showWidgetFolderName + binding.folderPickerShowFolderName.isChecked = config.showWidgetFolderName handleFolderNameDisplay() - folder_picker_show_folder_name_holder.setOnClickListener { - folder_picker_show_folder_name.toggle() + binding.folderPickerShowFolderNameHolder.setOnClickListener { + binding.folderPickerShowFolderName.toggle() handleFolderNameDisplay() } @@ -75,7 +78,7 @@ class WidgetConfigureActivity : SimpleActivity() { mBgAlpha = Color.alpha(mBgColor) / 255f mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor)) - config_bg_seekbar.apply { + binding.configBgSeekbar.apply { progress = (mBgAlpha * 100).toInt() onSeekBarChangeListener { progress -> @@ -86,8 +89,8 @@ class WidgetConfigureActivity : SimpleActivity() { updateBackgroundColor() mTextColor = config.widgetTextColor - if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) { - mTextColor = resources.getColor(R.color.you_primary_color, theme) + if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) { + mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme) } updateTextColor() @@ -97,7 +100,7 @@ class WidgetConfigureActivity : SimpleActivity() { val views = RemoteViews(packageName, R.layout.widget) views.setBackgroundColor(R.id.widget_holder, mBgColor) AppWidgetManager.getInstance(this)?.updateAppWidget(mWidgetId, views) ?: return - config.showWidgetFolderName = folder_picker_show_folder_name.isChecked + config.showWidgetFolderName = binding.folderPickerShowFolderName.isChecked val widget = Widget(null, mWidgetId, mFolderPath) ensureBackgroundThread { widgetsDB.insertOrUpdate(widget) @@ -128,16 +131,16 @@ class WidgetConfigureActivity : SimpleActivity() { } private fun updateTextColor() { - config_folder_name.setTextColor(mTextColor) - config_text_color.setFillWithStroke(mTextColor, mTextColor) - config_save.setTextColor(getProperPrimaryColor().getContrastColor()) + binding.configFolderName.setTextColor(mTextColor) + binding.configTextColor.setFillWithStroke(mTextColor, mTextColor) + binding.configSave.setTextColor(getProperPrimaryColor().getContrastColor()) } private fun updateBackgroundColor() { mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha) - config_image_holder.background.applyColorFilter(mBgColor) - config_bg_color.setFillWithStroke(mBgColor, mBgColor) - config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor()) + binding.configImageHolder.background.applyColorFilter(mBgColor) + binding.configBgColor.setFillWithStroke(mBgColor, mBgColor) + binding.configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor()) } private fun pickBackgroundColor() { @@ -167,8 +170,8 @@ class WidgetConfigureActivity : SimpleActivity() { private fun updateFolderImage(folderPath: String) { mFolderPath = folderPath runOnUiThread { - folder_picker_value.text = getFolderNameFromPath(folderPath) - config_folder_name.text = getFolderNameFromPath(folderPath) + binding.folderPickerValue.text = getFolderNameFromPath(folderPath) + binding.configFolderName.text = getFolderNameFromPath(folderPath) } ensureBackgroundThread { @@ -176,14 +179,14 @@ class WidgetConfigureActivity : SimpleActivity() { if (path != null) { runOnUiThread { val signature = ObjectKey(System.currentTimeMillis().toString()) - loadJpg(path, config_image, config.cropThumbnails, ROUNDED_CORNERS_NONE, signature) + loadJpg(path, binding.configImage, config.cropThumbnails, ROUNDED_CORNERS_NONE, signature) } } } } private fun handleFolderNameDisplay() { - val showFolderName = folder_picker_show_folder_name.isChecked - config_folder_name.beVisibleIf(showFolderName) + val showFolderName = binding.folderPickerShowFolderName.isChecked + binding.configFolderName.beVisibleIf(showFolderName) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 83410e998..80809b34d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -31,6 +31,9 @@ import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.MediaActivity +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridRoundedCornersBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridSquareBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemListBinding import com.simplemobiletools.gallery.pro.dialogs.ConfirmDeleteFolderDialog import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog @@ -39,20 +42,8 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.Directory -import kotlinx.android.synthetic.main.directory_item_grid_square.view.* -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_check -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_location -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_lock -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_name -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_pin -import kotlinx.android.synthetic.main.directory_item_grid_square.view.dir_thumbnail -import kotlinx.android.synthetic.main.directory_item_list.view.* -import kotlinx.android.synthetic.main.directory_item_list.view.dir_drag_handle -import kotlinx.android.synthetic.main.directory_item_list.view.dir_holder -import kotlinx.android.synthetic.main.directory_item_list.view.photo_cnt import java.io.File import java.util.* -import kotlin.collections.ArrayList class DirectoryAdapter( activity: BaseSimpleActivity, var dirs: ArrayList, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView, @@ -87,13 +78,13 @@ class DirectoryAdapter( override fun getActionMenuId() = R.menu.cab_directories override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val layoutType = when { - isListViewType -> R.layout.directory_item_list - folderStyle == FOLDER_STYLE_SQUARE -> R.layout.directory_item_grid_square - else -> R.layout.directory_item_grid_rounded_corners + val binding = when { + isListViewType -> DirectoryItemListBinding.inflate(layoutInflater, parent, false) + folderStyle == FOLDER_STYLE_SQUARE -> DirectoryItemGridSquareBinding.inflate(layoutInflater, parent, false) + else -> DirectoryItemGridRoundedCornersBinding.inflate(layoutInflater, parent, false) } - return createViewHolder(layoutType, parent) + return createViewHolder(binding.root) } override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { @@ -188,7 +179,7 @@ class DirectoryAdapter( override fun onViewRecycled(holder: ViewHolder) { super.onViewRecycled(holder) if (!activity.isDestroyed) { - Glide.with(activity).clear(holder.itemView.dir_thumbnail!!) + Glide.with(activity).clear(bindItem(holder.itemView).dirThumbnail) } } @@ -251,7 +242,7 @@ class DirectoryAdapter( val sourcePath = firstDir.path val dir = File(sourcePath) if (activity.isAStorageRootFolder(dir.absolutePath)) { - activity.toast(R.string.rename_folder_root) + activity.toast(com.simplemobiletools.commons.R.string.rename_folder_root) return } @@ -306,7 +297,7 @@ class DirectoryAdapter( } } else { if (selectedPaths.any { it.isThisOrParentFolderHidden() }) { - ConfirmationDialog(activity, "", R.string.cant_unhide_folder, R.string.ok, 0) {} + ConfirmationDialog(activity, "", R.string.cant_unhide_folder, com.simplemobiletools.commons.R.string.ok, 0) {} return } @@ -602,7 +593,13 @@ class DirectoryAdapter( else -> { val itemsCnt = selectedKeys.size if (itemsCnt == 1 && getSelectedItems().first().isRecycleBin()) { - ConfirmationDialog(activity, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) { + ConfirmationDialog( + activity, + "", + com.simplemobiletools.commons.R.string.empty_recycle_bin_confirmation, + com.simplemobiletools.commons.R.string.yes, + com.simplemobiletools.commons.R.string.no + ) { deleteFolders() } return @@ -612,18 +609,18 @@ class DirectoryAdapter( val folder = getSelectedPaths().first().getFilenameFromPath() "\"$folder\"" } else { - resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt) + resources.getQuantityString(com.simplemobiletools.commons.R.plurals.delete_items, itemsCnt, itemsCnt) } val fileDirItem = getFirstSelectedItem() ?: return val baseString = if (!config.useRecycleBin || config.tempSkipRecycleBin || (isOneItemSelected() && fileDirItem.areFavorites())) { - R.string.deletion_confirmation + com.simplemobiletools.commons.R.string.deletion_confirmation } else { - R.string.move_to_recycle_bin_confirmation + com.simplemobiletools.commons.R.string.move_to_recycle_bin_confirmation } val question = String.format(resources.getString(baseString), items) - val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt) + val warning = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.delete_warning, itemsCnt, itemsCnt) ConfirmDeleteFolderDialog(activity, question, warning) { deleteFolders() } @@ -772,8 +769,8 @@ class DirectoryAdapter( private fun setupView(view: View, directory: Directory, holder: ViewHolder) { val isSelected = selectedKeys.contains(directory.path.hashCode()) - view.apply { - dir_path?.text = "${directory.path.substringBeforeLast("/")}/" + bindItem(view).apply { + dirPath?.text = "${directory.path.substringBeforeLast("/")}/" val thumbnailType = when { directory.tmb.isVideoFast() -> TYPE_VIDEOS directory.tmb.isGif() -> TYPE_GIFS @@ -782,25 +779,25 @@ class DirectoryAdapter( else -> TYPE_IMAGES } - dir_check?.beVisibleIf(isSelected) + dirCheck.beVisibleIf(isSelected) if (isSelected) { - dir_check.background?.applyColorFilter(properPrimaryColor) - dir_check.applyColorFilter(contrastColor) + dirCheck.background?.applyColorFilter(properPrimaryColor) + dirCheck.applyColorFilter(contrastColor) } if (isListViewType) { - dir_holder.isSelected = isSelected + dirHolder.isSelected = isSelected } if (scrollHorizontally && !isListViewType && folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) { - (dir_thumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dir_name.id) + (dirThumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dirName.id) - val photoCntParams = (photo_cnt.layoutParams as RelativeLayout.LayoutParams) - val nameParams = (dir_name.layoutParams as RelativeLayout.LayoutParams) + val photoCntParams = (photoCnt.layoutParams as RelativeLayout.LayoutParams) + val nameParams = (dirName.layoutParams as RelativeLayout.LayoutParams) nameParams.removeRule(RelativeLayout.BELOW) if (config.showFolderMediaCount == FOLDER_MEDIA_CNT_LINE) { - nameParams.addRule(RelativeLayout.ABOVE, photo_cnt.id) + nameParams.addRule(RelativeLayout.ABOVE, photoCnt.id) nameParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM) photoCntParams.removeRule(RelativeLayout.BELOW) @@ -811,11 +808,11 @@ class DirectoryAdapter( } if (lockedFolderPaths.contains(directory.path)) { - dir_lock.beVisible() - dir_lock.background = ColorDrawable(context.getProperBackgroundColor()) - dir_lock.applyColorFilter(context.getProperBackgroundColor().getContrastColor()) + dirLock.beVisible() + dirLock.background = ColorDrawable(root.context.getProperBackgroundColor()) + dirLock.applyColorFilter(root.context.getProperBackgroundColor().getContrastColor()) } else { - dir_lock.beGone() + dirLock.beGone() val roundedCorners = when { isListViewType -> ROUNDED_CORNERS_SMALL folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE @@ -825,7 +822,7 @@ class DirectoryAdapter( activity.loadImage( thumbnailType, directory.tmb, - dir_thumbnail, + dirThumbnail, scrollHorizontally, animateGifs, cropThumbnails, @@ -834,18 +831,18 @@ class DirectoryAdapter( ) } - dir_pin.beVisibleIf(pinnedFolders.contains(directory.path)) - dir_location.beVisibleIf(directory.location != LOCATION_INTERNAL) - if (dir_location.isVisible()) { - dir_location.setImageResource(if (directory.location == LOCATION_SD) R.drawable.ic_sd_card_vector else R.drawable.ic_usb_vector) + dirPin.beVisibleIf(pinnedFolders.contains(directory.path)) + dirLocation.beVisibleIf(directory.location != LOCATION_INTERNAL) + if (dirLocation.isVisible()) { + dirLocation.setImageResource(if (directory.location == LOCATION_SD) com.simplemobiletools.commons.R.drawable.ic_sd_card_vector else com.simplemobiletools.commons.R.drawable.ic_usb_vector) } - photo_cnt.text = directory.subfoldersMediaCount.toString() - photo_cnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE) + photoCnt.text = directory.subfoldersMediaCount.toString() + photoCnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE) if (limitFolderTitle) { - dir_name.setSingleLine() - dir_name.ellipsize = TextUtils.TruncateAt.MIDDLE + dirName.setSingleLine() + dirName.ellipsize = TextUtils.TruncateAt.MIDDLE } var nameCount = directory.name @@ -859,26 +856,26 @@ class DirectoryAdapter( } } - dir_name.text = nameCount + dirName.text = nameCount if (isListViewType || folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) { - photo_cnt.setTextColor(textColor) - dir_name.setTextColor(textColor) - dir_location.applyColorFilter(textColor) + photoCnt.setTextColor(textColor) + dirName.setTextColor(textColor) + dirLocation.applyColorFilter(textColor) } if (isListViewType) { - dir_path.setTextColor(textColor) - dir_pin.applyColorFilter(textColor) - dir_location.applyColorFilter(textColor) - dir_drag_handle.beVisibleIf(isDragAndDropping) + dirPath?.setTextColor(textColor) + dirPin.applyColorFilter(textColor) + dirLocation.applyColorFilter(textColor) + dirDragHandle.beVisibleIf(isDragAndDropping) } else { - dir_drag_handle_wrapper.beVisibleIf(isDragAndDropping) + dirDragHandleWrapper?.beVisibleIf(isDragAndDropping) } if (isDragAndDropping) { - dir_drag_handle.applyColorFilter(textColor) - dir_drag_handle.setOnTouchListener { v, event -> + dirDragHandle.applyColorFilter(textColor) + dirDragHandle.setOnTouchListener { v, event -> if (event.action == MotionEvent.ACTION_DOWN) { startReorderDragListener?.requestDrag(holder) } @@ -911,4 +908,12 @@ class DirectoryAdapter( } override fun onChange(position: Int) = dirs.getOrNull(position)?.getBubbleText(directorySorting, activity, dateFormat, timeFormat) ?: "" + + private fun bindItem(view: View): DirectoryItemBinding { + return when { + isListViewType -> DirectoryItemListBinding.bind(view).toItemBinding() + folderStyle == FOLDER_STYLE_SQUARE -> DirectoryItemGridSquareBinding.bind(view).toItemBinding() + else -> DirectoryItemGridRoundedCornersBinding.bind(view).toItemBinding() + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryItemBinding.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryItemBinding.kt new file mode 100644 index 000000000..bd91efdf6 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryItemBinding.kt @@ -0,0 +1,75 @@ +package com.simplemobiletools.gallery.pro.adapters + +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import com.simplemobiletools.commons.views.MySquareImageView +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridRoundedCornersBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridSquareBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemListBinding + +interface DirectoryItemBinding { + val root: ViewGroup + val dirThumbnail: MySquareImageView + val dirPath: TextView? + val dirCheck: ImageView + val dirHolder: ViewGroup + val photoCnt: TextView + val dirName: TextView + val dirLock: ImageView + val dirPin: ImageView + val dirLocation: ImageView + val dirDragHandle: ImageView + val dirDragHandleWrapper: ViewGroup? +} + +class ListDirectoryItemBinding(val binding: DirectoryItemListBinding) : DirectoryItemBinding { + override val root: ViewGroup = binding.root + override val dirThumbnail: MySquareImageView = binding.dirThumbnail + override val dirPath: TextView = binding.dirPath + override val dirCheck: ImageView = binding.dirCheck + override val dirHolder: ViewGroup = binding.dirHolder + override val photoCnt: TextView = binding.photoCnt + override val dirName: TextView = binding.dirName + override val dirLock: ImageView = binding.dirLock + override val dirPin: ImageView = binding.dirPin + override val dirLocation: ImageView = binding.dirLocation + override val dirDragHandle: ImageView = binding.dirDragHandle + override val dirDragHandleWrapper: ViewGroup? = null +} + +fun DirectoryItemListBinding.toItemBinding() = ListDirectoryItemBinding(this) + +class GridDirectoryItemSquareBinding(val binding: DirectoryItemGridSquareBinding) : DirectoryItemBinding { + override val root: ViewGroup = binding.root + override val dirThumbnail: MySquareImageView = binding.dirThumbnail + override val dirPath: TextView? = null + override val dirCheck: ImageView = binding.dirCheck + override val dirHolder: ViewGroup = binding.dirHolder + override val photoCnt: TextView = binding.photoCnt + override val dirName: TextView = binding.dirName + override val dirLock: ImageView = binding.dirLock + override val dirPin: ImageView = binding.dirPin + override val dirLocation: ImageView = binding.dirLocation + override val dirDragHandle: ImageView = binding.dirDragHandle + override val dirDragHandleWrapper: ViewGroup = binding.dirDragHandleWrapper +} + +fun DirectoryItemGridSquareBinding.toItemBinding() = GridDirectoryItemSquareBinding(this) + +class GridDirectoryItemRoundedCornersBinding(val binding: DirectoryItemGridRoundedCornersBinding) : DirectoryItemBinding { + override val root: ViewGroup = binding.root + override val dirThumbnail: MySquareImageView = binding.dirThumbnail + override val dirPath: TextView? = null + override val dirCheck: ImageView = binding.dirCheck + override val dirHolder: ViewGroup = binding.dirHolder + override val photoCnt: TextView = binding.photoCnt + override val dirName: TextView = binding.dirName + override val dirLock: ImageView = binding.dirLock + override val dirPin: ImageView = binding.dirPin + override val dirLocation: ImageView = binding.dirLocation + override val dirDragHandle: ImageView = binding.dirDragHandle + override val dirDragHandleWrapper: ViewGroup = binding.dirDragHandleWrapper +} + +fun DirectoryItemGridRoundedCornersBinding.toItemBinding() = GridDirectoryItemRoundedCornersBinding(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/FiltersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/FiltersAdapter.kt index 550900a22..e32bccea5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/FiltersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/FiltersAdapter.kt @@ -6,8 +6,8 @@ import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.EditorFilterItemBinding import com.simplemobiletools.gallery.pro.models.FilterItem -import kotlinx.android.synthetic.main.editor_filter_item.view.* class FiltersAdapter(val context: Context, val filterItems: ArrayList, val itemClick: (Int) -> Unit) : RecyclerView.Adapter() { @@ -20,8 +20,8 @@ class FiltersAdapter(val context: Context, val filterItems: ArrayList, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?, @@ -24,13 +23,13 @@ class ManageFoldersAdapter( setupDragListener(true) } - override fun getActionMenuId() = R.menu.cab_remove_only + override fun getActionMenuId() = com.simplemobiletools.commons.R.menu.cab_remove_only override fun prepareActionMode(menu: Menu) {} override fun actionItemPressed(id: Int) { when (id) { - R.id.cab_remove -> removeSelection() + com.simplemobiletools.commons.R.id.cab_remove -> removeSelection() } } @@ -46,7 +45,9 @@ class ManageFoldersAdapter( override fun onActionModeDestroyed() {} - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_manage_folder, parent) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return createViewHolder(ItemManageFolderBinding.inflate(layoutInflater, parent, false).root) + } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val folder = folders[position] @@ -61,21 +62,21 @@ class ManageFoldersAdapter( private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList private fun setupView(view: View, folder: String) { - view.apply { - setupViewBackground(activity) - manage_folder_holder?.isSelected = selectedKeys.contains(folder.hashCode()) - manage_folder_title.apply { + ItemManageFolderBinding.bind(view).apply { + root.setupViewBackground(activity) + manageFolderHolder.isSelected = selectedKeys.contains(folder.hashCode()) + manageFolderTitle.apply { text = folder setTextColor(context.getProperTextColor()) } - overflow_menu_icon.drawable.apply { + overflowMenuIcon.drawable.apply { mutate() setTint(activity.getProperTextColor()) } - overflow_menu_icon.setOnClickListener { - showPopupMenu(overflow_menu_anchor, folder) + overflowMenuIcon.setOnClickListener { + showPopupMenu(overflowMenuAnchor, folder) } } } @@ -90,7 +91,7 @@ class ManageFoldersAdapter( setOnMenuItemClickListener { item -> val eventTypeId = folder.hashCode() when (item.itemId) { - R.id.cab_remove -> { + com.simplemobiletools.commons.R.id.cab_remove -> { executeItemMenuOperation(eventTypeId) { removeSelection() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt index b31addb50..41e10fe44 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/ManageHiddenFoldersAdapter.kt @@ -11,8 +11,8 @@ import com.simplemobiletools.commons.extensions.setupViewBackground import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.ItemManageFolderBinding import com.simplemobiletools.gallery.pro.extensions.removeNoMedia -import kotlinx.android.synthetic.main.item_manage_folder.view.* class ManageHiddenFoldersAdapter( activity: BaseSimpleActivity, var folders: ArrayList, val listener: RefreshRecyclerViewListener?, @@ -45,7 +45,9 @@ class ManageHiddenFoldersAdapter( override fun onActionModeDestroyed() {} - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_manage_folder, parent) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + return createViewHolder(ItemManageFolderBinding.inflate(layoutInflater, parent, false).root) + } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val folder = folders[position] @@ -60,10 +62,10 @@ class ManageHiddenFoldersAdapter( private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList private fun setupView(view: View, folder: String) { - view.apply { - setupViewBackground(activity) - manage_folder_holder?.isSelected = selectedKeys.contains(folder.hashCode()) - manage_folder_title.apply { + ItemManageFolderBinding.bind(view).apply { + root.setupViewBackground(activity) + manageFolderHolder.isSelected = selectedKeys.contains(folder.hashCode()) + manageFolderTitle.apply { text = folder setTextColor(context.getProperTextColor()) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 027eedf23..5e4adefb9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -10,6 +10,7 @@ import android.view.Menu import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.core.view.allViews import com.bumptech.glide.Glide import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -23,6 +24,7 @@ import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity +import com.simplemobiletools.gallery.pro.databinding.* import com.simplemobiletools.gallery.pro.dialogs.DeleteWithRememberDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* @@ -30,9 +32,6 @@ import com.simplemobiletools.gallery.pro.interfaces.MediaOperationsListener import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection -import kotlinx.android.synthetic.main.photo_item_grid.view.file_type -import kotlinx.android.synthetic.main.thumbnail_section.view.thumbnail_section -import kotlinx.android.synthetic.main.video_item_grid.view.* class MediaAdapter( activity: BaseSimpleActivity, var media: ArrayList, val listener: MediaOperationsListener?, val isAGetIntent: Boolean, @@ -74,24 +73,24 @@ class MediaAdapter( override fun getActionMenuId() = R.menu.cab_media override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val layoutType = if (viewType == ITEM_SECTION) { - R.layout.thumbnail_section + val binding = if (viewType == ITEM_SECTION) { + ThumbnailSectionBinding.inflate(layoutInflater, parent, false) } else { if (isListViewType) { if (viewType == ITEM_MEDIUM_PHOTO) { - R.layout.photo_item_list + PhotoItemListBinding.inflate(layoutInflater, parent, false) } else { - R.layout.video_item_list + VideoItemListBinding.inflate(layoutInflater, parent, false) } } else { if (viewType == ITEM_MEDIUM_PHOTO) { - R.layout.photo_item_grid + PhotoItemGridBinding.inflate(layoutInflater, parent, false) } else { - R.layout.video_item_grid + VideoItemGridBinding.inflate(layoutInflater, parent, false) } } } - return createViewHolder(layoutType, parent) + return createViewHolder(binding.root) } override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { @@ -196,8 +195,8 @@ class MediaAdapter( super.onViewRecycled(holder) if (!activity.isDestroyed) { val itemView = holder.itemView - visibleItemPaths.remove(itemView.medium_name?.tag) - val tmb = itemView.medium_thumbnail + visibleItemPaths.remove(itemView.allViews.firstOrNull { it.id == R.id.medium_name }?.tag) + val tmb = itemView.allViews.firstOrNull { it.id == R.id.medium_thumbnail } if (tmb != null) { Glide.with(activity).clear(tmb) } @@ -242,7 +241,7 @@ class MediaAdapter( val isSDOrOtgRootFolder = activity.isAStorageRootFolder(firstPath.getParentPath()) && !firstPath.startsWith(activity.internalStoragePath) if (isRPlus() && isSDOrOtgRootFolder && !isExternalStorageManager()) { - activity.toast(R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) + activity.toast(com.simplemobiletools.commons.R.string.rename_in_sd_card_system_restriction, Toast.LENGTH_LONG) finishActMode() return } @@ -354,7 +353,7 @@ class MediaAdapter( private fun handleRotate(paths: List, degrees: Int) { var fileCnt = paths.size rotatedImagePaths.clear() - activity.toast(R.string.saving) + activity.toast(com.simplemobiletools.commons.R.string.saving) ensureBackgroundThread { paths.forEach { rotatedImagePaths.add(it) @@ -406,7 +405,7 @@ class MediaAdapter( }.toMutableList() as ArrayList if (!isCopyOperation && paths.any { it.startsWith(recycleBinPath) }) { - activity.toast(R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG) + activity.toast(com.simplemobiletools.commons.R.string.moving_recycle_bin_items_disabled, Toast.LENGTH_LONG) } if (fileDirItems.isEmpty()) { @@ -500,13 +499,13 @@ class MediaAdapter( fileDirItems.add(curFileDirItem) } val fileSize = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize() - val deleteItemsString = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt) + val deleteItemsString = resources.getQuantityString(com.simplemobiletools.commons.R.plurals.delete_items, itemsCnt, itemsCnt) "$deleteItemsString ($fileSize)" } val isRecycleBin = firstPath.startsWith(activity.recycleBinPath) val baseString = - if (config.useRecycleBin && !config.tempSkipRecycleBin && !isRecycleBin) R.string.move_to_recycle_bin_confirmation else R.string.deletion_confirmation + if (config.useRecycleBin && !config.tempSkipRecycleBin && !isRecycleBin) com.simplemobiletools.commons.R.string.move_to_recycle_bin_confirmation else com.simplemobiletools.commons.R.string.deletion_confirmation val question = String.format(resources.getString(baseString), itemsAndSize) val showSkipRecycleBinOption = config.useRecycleBin && !isRecycleBin @@ -607,62 +606,62 @@ class MediaAdapter( private fun setupThumbnail(view: View, medium: Medium) { val isSelected = selectedKeys.contains(medium.path.hashCode()) - view.apply { + bindItem(view, medium).apply { val padding = if (config.thumbnailSpacing <= 1) { config.thumbnailSpacing } else { 0 } - media_item_holder.setPadding(padding, padding, padding, padding) + mediaItemHolder.setPadding(padding, padding, padding, padding) favorite.beVisibleIf(medium.isFavorite && config.markFavoriteItems) - play_portrait_outline?.beVisibleIf(medium.isVideo() || medium.isPortrait()) + playPortraitOutline?.beVisibleIf(medium.isVideo() || medium.isPortrait()) if (medium.isVideo()) { - play_portrait_outline?.setImageResource(R.drawable.ic_play_outline_vector) - play_portrait_outline?.beVisible() + playPortraitOutline?.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) + playPortraitOutline?.beVisible() } else if (medium.isPortrait()) { - play_portrait_outline?.setImageResource(R.drawable.ic_portrait_photo_vector) - play_portrait_outline?.beVisibleIf(showFileTypes) + playPortraitOutline?.setImageResource(R.drawable.ic_portrait_photo_vector) + playPortraitOutline?.beVisibleIf(showFileTypes) } if (showFileTypes && (medium.isGIF() || medium.isRaw() || medium.isSVG())) { - file_type.setText( + fileType?.setText( when (medium.type) { TYPE_GIFS -> R.string.gif TYPE_RAWS -> R.string.raw else -> R.string.svg } ) - file_type.beVisible() + fileType?.beVisible() } else { - file_type?.beGone() + fileType?.beGone() } - medium_name.beVisibleIf(displayFilenames || isListViewType) - medium_name.text = medium.name - medium_name.tag = medium.path + mediumName.beVisibleIf(displayFilenames || isListViewType) + mediumName.text = medium.name + mediumName.tag = medium.path val showVideoDuration = medium.isVideo() && config.showThumbnailVideoDuration if (showVideoDuration) { - video_duration?.text = medium.videoDuration.getFormattedDuration() + videoDuration?.text = medium.videoDuration.getFormattedDuration() } - video_duration?.beVisibleIf(showVideoDuration) + videoDuration?.beVisibleIf(showVideoDuration) - medium_check?.beVisibleIf(isSelected) + mediumCheck.beVisibleIf(isSelected) if (isSelected) { - medium_check?.background?.applyColorFilter(properPrimaryColor) - medium_check.applyColorFilter(contrastColor) + mediumCheck.background?.applyColorFilter(properPrimaryColor) + mediumCheck.applyColorFilter(contrastColor) } if (isListViewType) { - media_item_holder.isSelected = isSelected + mediaItemHolder.isSelected = isSelected } var path = medium.path - if (hasOTGConnected && context.isPathOnOTG(path)) { - path = path.getOTGPublicPath(context) + if (hasOTGConnected && root.context.isPathOnOTG(path)) { + path = path.getOTGPublicPath(root.context) } val roundedCorners = when { @@ -673,16 +672,16 @@ class MediaAdapter( if (loadImageInstantly) { activity.loadImage( - medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, medium.getKey(), rotatedImagePaths + medium.type, path, mediumThumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, medium.getKey(), rotatedImagePaths ) } else { - medium_thumbnail.setImageDrawable(null) - medium_thumbnail.isHorizontalScrolling = scrollHorizontally + mediumThumbnail.setImageDrawable(null) + mediumThumbnail.isHorizontalScrolling = scrollHorizontally delayHandler.postDelayed({ val isVisible = visibleItemPaths.contains(medium.path) if (isVisible) { activity.loadImage( - medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, + medium.type, path, mediumThumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners, medium.getKey(), rotatedImagePaths ) } @@ -690,16 +689,16 @@ class MediaAdapter( } if (isListViewType) { - medium_name.setTextColor(textColor) - play_portrait_outline?.applyColorFilter(textColor) + mediumName.setTextColor(textColor) + playPortraitOutline?.applyColorFilter(textColor) } } } private fun setupSection(view: View, section: ThumbnailSection) { - view.apply { - thumbnail_section.text = section.title - thumbnail_section.setTextColor(textColor) + ThumbnailSectionBinding.bind(view).apply { + thumbnailSection.text = section.title + thumbnailSection.setTextColor(textColor) } } @@ -711,4 +710,20 @@ class MediaAdapter( return (media[realIndex] as? Medium)?.getBubbleText(sorting, activity, dateFormat, timeFormat) ?: "" } + + private fun bindItem(view: View, medium: Medium): MediaItemBinding { + return if (isListViewType) { + if (!medium.isVideo() && !medium.isPortrait()) { + PhotoItemListBinding.bind(view).toMediaItemBinding() + } else { + VideoItemListBinding.bind(view).toMediaItemBinding() + } + } else { + if (!medium.isVideo() && !medium.isPortrait()) { + PhotoItemGridBinding.bind(view).toMediaItemBinding() + } else { + VideoItemGridBinding.bind(view).toMediaItemBinding() + } + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaItemBinding.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaItemBinding.kt new file mode 100644 index 000000000..6f3db6b27 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaItemBinding.kt @@ -0,0 +1,78 @@ +package com.simplemobiletools.gallery.pro.adapters + +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView +import com.simplemobiletools.commons.views.MySquareImageView +import com.simplemobiletools.gallery.pro.databinding.PhotoItemGridBinding +import com.simplemobiletools.gallery.pro.databinding.PhotoItemListBinding +import com.simplemobiletools.gallery.pro.databinding.VideoItemGridBinding +import com.simplemobiletools.gallery.pro.databinding.VideoItemListBinding + +interface MediaItemBinding { + val root: ViewGroup + val mediaItemHolder: ViewGroup + val favorite: ImageView + val playPortraitOutline: ImageView? + val fileType: TextView? + val mediumName: TextView + val videoDuration: TextView? + val mediumCheck: ImageView + val mediumThumbnail: MySquareImageView +} + +class PhotoListMediaItemBinding(val binding: PhotoItemListBinding) : MediaItemBinding { + override val root: ViewGroup = binding.root + override val mediaItemHolder: ViewGroup = binding.mediaItemHolder + override val favorite: ImageView = binding.favorite + override val playPortraitOutline: ImageView? = null + override val fileType: TextView = binding.fileType + override val mediumName: TextView = binding.mediumName + override val videoDuration: TextView? = null + override val mediumCheck: ImageView = binding.mediumCheck + override val mediumThumbnail: MySquareImageView = binding.mediumThumbnail +} + +fun PhotoItemListBinding.toMediaItemBinding() = PhotoListMediaItemBinding(this) + +class PhotoGridMediaItemBinding(val binding: PhotoItemGridBinding) : MediaItemBinding { + override val root: ViewGroup = binding.root + override val mediaItemHolder: ViewGroup = binding.mediaItemHolder + override val favorite: ImageView = binding.favorite + override val playPortraitOutline: ImageView? = null + override val fileType: TextView = binding.fileType + override val mediumName: TextView = binding.mediumName + override val videoDuration: TextView? = null + override val mediumCheck: ImageView = binding.mediumCheck + override val mediumThumbnail: MySquareImageView = binding.mediumThumbnail +} + +fun PhotoItemGridBinding.toMediaItemBinding() = PhotoGridMediaItemBinding(this) + +class VideoListMediaItemBinding(val binding: VideoItemListBinding) : MediaItemBinding { + override val root: ViewGroup = binding.root + override val mediaItemHolder: ViewGroup = binding.mediaItemHolder + override val favorite: ImageView = binding.favorite + override val playPortraitOutline: ImageView? = binding.playPortraitOutline + override val fileType: TextView? = null + override val mediumName: TextView = binding.mediumName + override val videoDuration: TextView = binding.videoDuration + override val mediumCheck: ImageView = binding.mediumCheck + override val mediumThumbnail: MySquareImageView = binding.mediumThumbnail +} + +fun VideoItemListBinding.toMediaItemBinding() = VideoListMediaItemBinding(this) + +class VideoGridMediaItemBinding(val binding: VideoItemGridBinding) : MediaItemBinding { + override val root: ViewGroup = binding.root + override val mediaItemHolder: ViewGroup = binding.mediaItemHolder + override val favorite: ImageView = binding.favorite + override val playPortraitOutline: ImageView = binding.playPortraitOutline + override val fileType: TextView? = null + override val mediumName: TextView = binding.mediumName + override val videoDuration: TextView = binding.videoDuration + override val mediumCheck: ImageView = binding.mediumCheck + override val mediumThumbnail: MySquareImageView = binding.mediumThumbnail +} + +fun VideoItemGridBinding.toMediaItemBinding() = VideoGridMediaItemBinding(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt index 6154e6df6..f626a69b1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt @@ -12,7 +12,7 @@ import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.extensions.getFileKey import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.portrait_photo_item.view.* +import com.simplemobiletools.gallery.pro.databinding.PortraitPhotoItemBinding class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) : RecyclerView.Adapter() { @@ -27,8 +27,8 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent.context).inflate(R.layout.portrait_photo_item, parent, false) - return ViewHolder(view) + val binding = PortraitPhotoItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) + return ViewHolder(binding.root) } override fun getItemCount() = photos.size @@ -46,14 +46,14 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bindView(photo: String, position: Int): View { - itemView.apply { - portrait_photo_item_thumbnail.layoutParams.width = if (position == 0 || position == photos.lastIndex) { + PortraitPhotoItemBinding.bind(itemView).apply { + portraitPhotoItemThumbnail.layoutParams.width = if (position == 0 || position == photos.lastIndex) { sideElementWidth } else { itemWidth } - portrait_photo_item_thumbnail.background = if (photo.isEmpty() || position != currentSelectionIndex) { + portraitPhotoItemThumbnail.background = if (photo.isEmpty() || position != currentSelectionIndex) { null } else { strokeBackground @@ -68,17 +68,17 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, .load(photo) .transition(DrawableTransitionOptions.withCrossFade()) .apply(options) - .into(portrait_photo_item_thumbnail) + .into(portraitPhotoItemThumbnail) if (photo.isNotEmpty()) { - isClickable = true - views[position] = this - setOnClickListener { - itemClick(position, x.toInt()) + root.isClickable = true + views[position] = root + root.setOnClickListener { + itemClick(position, root.x.toInt()) setCurrentPhoto(position) } } else { - isClickable = false + root.isClickable = false } } return itemView diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/AllFilesPermissionDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/AllFilesPermissionDialog.kt index d52526e90..6526d7390 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/AllFilesPermissionDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/AllFilesPermissionDialog.kt @@ -13,7 +13,7 @@ class AllFilesPermissionDialog( private var dialog: AlertDialog? = null init { - val view = activity.layoutInflater.inflate(R.layout.dialog_message, null) + val view = activity.layoutInflater.inflate(com.simplemobiletools.commons.R.layout.dialog_message, null) view.findViewById(R.id.message).text = message activity.getAlertDialogBuilder().setPositiveButton(R.string.all_files) { dialog, which -> positivePressed() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFileThumbnailStyleDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFileThumbnailStyleDialog.kt index 7517c53f3..2070f406d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFileThumbnailStyleDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFileThumbnailStyleDialog.kt @@ -1,36 +1,34 @@ package com.simplemobiletools.gallery.pro.dialogs import android.content.DialogInterface -import android.view.View import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.models.RadioItem -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogChangeFileThumbnailStyleBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.dialog_change_file_thumbnail_style.view.* class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogInterface.OnClickListener { private var config = activity.config - private var view: View + private val binding: DialogChangeFileThumbnailStyleBinding private var thumbnailSpacing = config.thumbnailSpacing init { - view = activity.layoutInflater.inflate(R.layout.dialog_change_file_thumbnail_style, null).apply { - dialog_file_style_rounded_corners.isChecked = config.fileRoundedCorners - dialog_file_style_animate_gifs.isChecked = config.animateGifs - dialog_file_style_show_thumbnail_video_duration.isChecked = config.showThumbnailVideoDuration - dialog_file_style_show_thumbnail_file_types.isChecked = config.showThumbnailFileTypes - dialog_file_style_mark_favorite_items.isChecked = config.markFavoriteItems + binding = DialogChangeFileThumbnailStyleBinding.inflate(activity.layoutInflater).apply { + dialogFileStyleRoundedCorners.isChecked = config.fileRoundedCorners + dialogFileStyleAnimateGifs.isChecked = config.animateGifs + dialogFileStyleShowThumbnailVideoDuration.isChecked = config.showThumbnailVideoDuration + dialogFileStyleShowThumbnailFileTypes.isChecked = config.showThumbnailFileTypes + dialogFileStyleMarkFavoriteItems.isChecked = config.markFavoriteItems - dialog_file_style_rounded_corners_holder.setOnClickListener { dialog_file_style_rounded_corners.toggle() } - dialog_file_style_animate_gifs_holder.setOnClickListener { dialog_file_style_animate_gifs.toggle() } - dialog_file_style_show_thumbnail_video_duration_holder.setOnClickListener { dialog_file_style_show_thumbnail_video_duration.toggle() } - dialog_file_style_show_thumbnail_file_types_holder.setOnClickListener { dialog_file_style_show_thumbnail_file_types.toggle() } - dialog_file_style_mark_favorite_items_holder.setOnClickListener { dialog_file_style_mark_favorite_items.toggle() } + dialogFileStyleRoundedCornersHolder.setOnClickListener { dialogFileStyleRoundedCorners.toggle() } + dialogFileStyleAnimateGifsHolder.setOnClickListener { dialogFileStyleAnimateGifs.toggle() } + dialogFileStyleShowThumbnailVideoDurationHolder.setOnClickListener { dialogFileStyleShowThumbnailVideoDuration.toggle() } + dialogFileStyleShowThumbnailFileTypesHolder.setOnClickListener { dialogFileStyleShowThumbnailFileTypes.toggle() } + dialogFileStyleMarkFavoriteItemsHolder.setOnClickListener { dialogFileStyleMarkFavoriteItems.toggle() } - dialog_file_style_spacing_holder.setOnClickListener { + dialogFileStyleSpacingHolder.setOnClickListener { val items = arrayListOf( RadioItem(0, "0x"), RadioItem(1, "1x"), @@ -52,23 +50,23 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI updateThumbnailSpacingText() activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, this) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(binding.root, this) } } override fun onClick(dialog: DialogInterface, which: Int) { - config.fileRoundedCorners = view.dialog_file_style_rounded_corners.isChecked - config.animateGifs = view.dialog_file_style_animate_gifs.isChecked - config.showThumbnailVideoDuration = view.dialog_file_style_show_thumbnail_video_duration.isChecked - config.showThumbnailFileTypes = view.dialog_file_style_show_thumbnail_file_types.isChecked - config.markFavoriteItems = view.dialog_file_style_mark_favorite_items.isChecked + config.fileRoundedCorners = binding.dialogFileStyleRoundedCorners.isChecked + config.animateGifs = binding.dialogFileStyleAnimateGifs.isChecked + config.showThumbnailVideoDuration = binding.dialogFileStyleShowThumbnailVideoDuration.isChecked + config.showThumbnailFileTypes = binding.dialogFileStyleShowThumbnailFileTypes.isChecked + config.markFavoriteItems = binding.dialogFileStyleMarkFavoriteItems.isChecked config.thumbnailSpacing = thumbnailSpacing } private fun updateThumbnailSpacingText() { - view.dialog_file_style_spacing.text = "${thumbnailSpacing}x" + binding.dialogFileStyleSpacing.text = "${thumbnailSpacing}x" } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFolderThumbnailStyleDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFolderThumbnailStyleDialog.kt index 0b2e3ba28..06173bafa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFolderThumbnailStyleDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeFolderThumbnailStyleDialog.kt @@ -9,23 +9,25 @@ import com.bumptech.glide.request.RequestOptions import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.adapters.toItemBinding +import com.simplemobiletools.gallery.pro.databinding.DialogChangeFolderThumbnailStyleBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridRoundedCornersBinding +import com.simplemobiletools.gallery.pro.databinding.DirectoryItemGridSquareBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.dialog_change_folder_thumbnail_style.view.* -import kotlinx.android.synthetic.main.directory_item_grid_square.view.* class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener { private var config = activity.config - private var view = activity.layoutInflater.inflate(R.layout.dialog_change_folder_thumbnail_style, null).apply { - dialog_folder_limit_title.isChecked = config.limitFolderTitle + private val binding = DialogChangeFolderThumbnailStyleBinding.inflate(activity.layoutInflater).apply { + dialogFolderLimitTitle.isChecked = config.limitFolderTitle } init { activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, this) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { + activity.setupDialogStuff(binding.root, this) { setupStyle() setupMediaCount() updateSample() @@ -34,29 +36,29 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal } private fun setupStyle() { - val styleRadio = view.dialog_radio_folder_style + val styleRadio = binding.dialogRadioFolderStyle styleRadio.setOnCheckedChangeListener { group, checkedId -> updateSample() } val styleBtn = when (config.folderStyle) { - FOLDER_STYLE_SQUARE -> styleRadio.dialog_radio_folder_square - else -> styleRadio.dialog_radio_folder_rounded_corners + FOLDER_STYLE_SQUARE -> binding.dialogRadioFolderSquare + else -> binding.dialogRadioFolderRoundedCorners } styleBtn.isChecked = true } private fun setupMediaCount() { - val countRadio = view.dialog_radio_folder_count_holder + val countRadio = binding.dialogRadioFolderCountHolder countRadio.setOnCheckedChangeListener { group, checkedId -> updateSample() } val countBtn = when (config.showFolderMediaCount) { - FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_folder_count_line - FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_folder_count_brackets - else -> countRadio.dialog_radio_folder_count_none + FOLDER_MEDIA_CNT_LINE -> binding.dialogRadioFolderCountLine + FOLDER_MEDIA_CNT_BRACKETS -> binding.dialogRadioFolderCountBrackets + else -> binding.dialogRadioFolderCountNone } countBtn.isChecked = true @@ -65,30 +67,36 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal private fun updateSample() { val photoCount = 36 val folderName = "Camera" - view.apply { - val useRoundedCornersLayout = dialog_radio_folder_style.checkedRadioButtonId == R.id.dialog_radio_folder_rounded_corners - dialog_folder_sample_holder.removeAllViews() + binding.apply { + val useRoundedCornersLayout = binding.dialogRadioFolderStyle.checkedRadioButtonId == R.id.dialog_radio_folder_rounded_corners + binding.dialogFolderSampleHolder.removeAllViews() - val layout = if (useRoundedCornersLayout) R.layout.directory_item_grid_rounded_corners else R.layout.directory_item_grid_square - val sampleView = activity.layoutInflater.inflate(layout, null) - dialog_folder_sample_holder.addView(sampleView) + val sampleBinding = if (useRoundedCornersLayout) { + DirectoryItemGridRoundedCornersBinding.inflate(activity.layoutInflater).toItemBinding() + } else { + DirectoryItemGridSquareBinding.inflate(activity.layoutInflater).toItemBinding() + } + val sampleView = sampleBinding.root + binding.dialogFolderSampleHolder.addView(sampleView) sampleView.layoutParams.width = activity.resources.getDimension(R.dimen.sample_thumbnail_size).toInt() (sampleView.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.CENTER_HORIZONTAL) - when (dialog_radio_folder_count_holder.checkedRadioButtonId) { + when (binding.dialogRadioFolderCountHolder.checkedRadioButtonId) { R.id.dialog_radio_folder_count_line -> { - dir_name.text = folderName - photo_cnt.text = photoCount.toString() - photo_cnt.beVisible() + sampleBinding.dirName.text = folderName + sampleBinding.photoCnt.text = photoCount.toString() + sampleBinding.photoCnt.beVisible() } + R.id.dialog_radio_folder_count_brackets -> { - photo_cnt.beGone() - dir_name.text = "$folderName ($photoCount)" + sampleBinding.photoCnt.beGone() + sampleBinding.dirName.text = "$folderName ($photoCount)" } + else -> { - dir_name.text = folderName - photo_cnt?.beGone() + sampleBinding.dirName.text = folderName + sampleBinding.photoCnt.beGone() } } @@ -98,23 +106,23 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal .apply(options) if (useRoundedCornersLayout) { - val cornerRadius = resources.getDimension(R.dimen.rounded_corner_radius_big).toInt() + val cornerRadius = root.resources.getDimension(com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) - dir_name.setTextColor(activity.getProperTextColor()) - photo_cnt.setTextColor(activity.getProperTextColor()) + sampleBinding.dirName.setTextColor(activity.getProperTextColor()) + sampleBinding.photoCnt.setTextColor(activity.getProperTextColor()) } - builder.into(dir_thumbnail) + builder.into(sampleBinding.dirThumbnail) } } override fun onClick(dialog: DialogInterface, which: Int) { - val style = when (view.dialog_radio_folder_style.checkedRadioButtonId) { + val style = when (binding.dialogRadioFolderStyle.checkedRadioButtonId) { R.id.dialog_radio_folder_square -> FOLDER_STYLE_SQUARE else -> FOLDER_STYLE_ROUNDED_CORNERS } - val count = when (view.dialog_radio_folder_count_holder.checkedRadioButtonId) { + val count = when (binding.dialogRadioFolderCountHolder.checkedRadioButtonId) { R.id.dialog_radio_folder_count_line -> FOLDER_MEDIA_CNT_LINE R.id.dialog_radio_folder_count_brackets -> FOLDER_MEDIA_CNT_BRACKETS else -> FOLDER_MEDIA_CNT_NONE @@ -122,7 +130,7 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal config.folderStyle = style config.showFolderMediaCount = count - config.limitFolderTitle = view.dialog_folder_limit_title.isChecked + config.limitFolderTitle = binding.dialogFolderLimitTitle.isChecked callback() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt index 422c2c188..922046464 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeGroupingDialog.kt @@ -1,70 +1,66 @@ package com.simplemobiletools.gallery.pro.dialogs import android.content.DialogInterface -import android.view.View import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogChangeGroupingBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.dialog_change_grouping.view.* class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) : DialogInterface.OnClickListener { private var currGrouping = 0 private var config = activity.config private val pathToUse = if (path.isEmpty()) SHOW_ALL else path - private var view: View + private val binding: DialogChangeGroupingBinding init { currGrouping = config.getFolderGrouping(pathToUse) - view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply { - grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse) - grouping_dialog_radio_folder.beVisibleIf(path.isEmpty()) + binding = DialogChangeGroupingBinding.inflate(activity.layoutInflater).apply { + groupingDialogUseForThisFolder.isChecked = config.hasCustomGrouping(pathToUse) + groupingDialogRadioFolder.beVisibleIf(path.isEmpty()) } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, this) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.group_by) + activity.setupDialogStuff(binding.root, this, R.string.group_by) } setupGroupRadio() setupOrderRadio() - view.grouping_dialog_show_file_count.isChecked = currGrouping and GROUP_SHOW_FILE_COUNT != 0 + binding.groupingDialogShowFileCount.isChecked = currGrouping and GROUP_SHOW_FILE_COUNT != 0 } private fun setupGroupRadio() { - val groupingRadio = view.grouping_dialog_radio_grouping - val groupBtn = when { - currGrouping and GROUP_BY_NONE != 0 -> groupingRadio.grouping_dialog_radio_none - currGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 -> groupingRadio.grouping_dialog_radio_last_modified_daily - currGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 -> groupingRadio.grouping_dialog_radio_last_modified_monthly - currGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> groupingRadio.grouping_dialog_radio_date_taken_daily - currGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> groupingRadio.grouping_dialog_radio_date_taken_monthly - currGrouping and GROUP_BY_FILE_TYPE != 0 -> groupingRadio.grouping_dialog_radio_file_type - currGrouping and GROUP_BY_EXTENSION != 0 -> groupingRadio.grouping_dialog_radio_extension - else -> groupingRadio.grouping_dialog_radio_folder + currGrouping and GROUP_BY_NONE != 0 -> binding.groupingDialogRadioNone + currGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 -> binding.groupingDialogRadioLastModifiedDaily + currGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 -> binding.groupingDialogRadioLastModifiedMonthly + currGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> binding.groupingDialogRadioDateTakenDaily + currGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> binding.groupingDialogRadioDateTakenMonthly + currGrouping and GROUP_BY_FILE_TYPE != 0 -> binding.groupingDialogRadioFileType + currGrouping and GROUP_BY_EXTENSION != 0 -> binding.groupingDialogRadioExtension + else -> binding.groupingDialogRadioFolder } groupBtn.isChecked = true } private fun setupOrderRadio() { - val orderRadio = view.grouping_dialog_radio_order - var orderBtn = orderRadio.grouping_dialog_radio_ascending + var orderBtn = binding.groupingDialogRadioAscending if (currGrouping and GROUP_DESCENDING != 0) { - orderBtn = orderRadio.grouping_dialog_radio_descending + orderBtn = binding.groupingDialogRadioDescending } orderBtn.isChecked = true } override fun onClick(dialog: DialogInterface, which: Int) { - val groupingRadio = view.grouping_dialog_radio_grouping + val groupingRadio = binding.groupingDialogRadioGrouping var grouping = when (groupingRadio.checkedRadioButtonId) { R.id.grouping_dialog_radio_none -> GROUP_BY_NONE R.id.grouping_dialog_radio_last_modified_daily -> GROUP_BY_LAST_MODIFIED_DAILY @@ -76,15 +72,15 @@ class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = else -> GROUP_BY_FOLDER } - if (view.grouping_dialog_radio_order.checkedRadioButtonId == R.id.grouping_dialog_radio_descending) { + if (binding.groupingDialogRadioGrouping.checkedRadioButtonId == R.id.grouping_dialog_radio_descending) { grouping = grouping or GROUP_DESCENDING } - if (view.grouping_dialog_show_file_count.isChecked) { + if (binding.groupingDialogShowFileCount.isChecked) { grouping = grouping or GROUP_SHOW_FILE_COUNT } - if (view.grouping_dialog_use_for_this_folder.isChecked) { + if (binding.groupingDialogUseForThisFolder.isChecked) { config.saveFolderGrouping(pathToUse, grouping) } else { config.removeFolderGrouping(pathToUse) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt index 6a40e23c0..df07cc913 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeSortingDialog.kt @@ -1,14 +1,13 @@ package com.simplemobiletools.gallery.pro.dialogs import android.content.DialogInterface -import android.view.View import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogChangeSortingBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL -import kotlinx.android.synthetic.main.dialog_change_sorting.view.* class ChangeSortingDialog( val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean, @@ -18,27 +17,27 @@ class ChangeSortingDialog( private var currSorting = 0 private var config = activity.config private var pathToUse = if (!isDirectorySorting && path.isEmpty()) SHOW_ALL else path - private var view: View + private val binding: DialogChangeSortingBinding init { currSorting = if (isDirectorySorting) config.directorySorting else config.getFolderSorting(pathToUse) - view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply { - use_for_this_folder_divider.beVisibleIf(showFolderCheckbox || (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0)) + binding = DialogChangeSortingBinding.inflate(activity.layoutInflater).apply { + useForThisFolderDivider.beVisibleIf(showFolderCheckbox || (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0)) - sorting_dialog_numeric_sorting.beVisibleIf(showFolderCheckbox && (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0)) - sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0 + sortingDialogNumericSorting.beVisibleIf(showFolderCheckbox && (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0)) + sortingDialogNumericSorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0 - sorting_dialog_use_for_this_folder.beVisibleIf(showFolderCheckbox) - sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(pathToUse) - sorting_dialog_bottom_note.beVisibleIf(!isDirectorySorting) - sorting_dialog_radio_custom.beVisibleIf(isDirectorySorting) + sortingDialogUseForThisFolder.beVisibleIf(showFolderCheckbox) + sortingDialogUseForThisFolder.isChecked = config.hasCustomSorting(pathToUse) + sortingDialogBottomNote.beVisibleIf(!isDirectorySorting) + sortingDialogRadioCustom.beVisibleIf(isDirectorySorting) } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, this) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.sort_by) + activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by) } setupSortRadio() @@ -46,41 +45,40 @@ class ChangeSortingDialog( } private fun setupSortRadio() { - val sortingRadio = view.sorting_dialog_radio_sorting + val sortingRadio = binding.sortingDialogRadioSorting sortingRadio.setOnCheckedChangeListener { group, checkedId -> - val isSortingByNameOrPath = checkedId == sortingRadio.sorting_dialog_radio_name.id || checkedId == sortingRadio.sorting_dialog_radio_path.id - view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByNameOrPath) - view.use_for_this_folder_divider.beVisibleIf(view.sorting_dialog_numeric_sorting.isVisible() || view.sorting_dialog_use_for_this_folder.isVisible()) + val isSortingByNameOrPath = checkedId == binding.sortingDialogRadioName.id || checkedId == binding.sortingDialogRadioPath.id + binding.sortingDialogNumericSorting.beVisibleIf(isSortingByNameOrPath) + binding.useForThisFolderDivider.beVisibleIf(binding.sortingDialogNumericSorting.isVisible() || binding.sortingDialogUseForThisFolder.isVisible()) - val hideSortOrder = checkedId == sortingRadio.sorting_dialog_radio_custom.id || checkedId == sortingRadio.sorting_dialog_radio_random.id - view.sorting_dialog_radio_order.beGoneIf(hideSortOrder) - view.sorting_dialog_order_divider.beGoneIf(hideSortOrder) + val hideSortOrder = checkedId == binding.sortingDialogRadioCustom.id || checkedId == binding.sortingDialogRadioRandom.id + binding.sortingDialogRadioOrder.beGoneIf(hideSortOrder) + binding.sortingDialogOrderDivider.beGoneIf(hideSortOrder) } val sortBtn = when { - currSorting and SORT_BY_PATH != 0 -> sortingRadio.sorting_dialog_radio_path - currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size - currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified - currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken - currSorting and SORT_BY_RANDOM != 0 -> sortingRadio.sorting_dialog_radio_random - currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom - else -> sortingRadio.sorting_dialog_radio_name + currSorting and SORT_BY_PATH != 0 -> binding.sortingDialogRadioPath + currSorting and SORT_BY_SIZE != 0 -> binding.sortingDialogRadioSize + currSorting and SORT_BY_DATE_MODIFIED != 0 -> binding.sortingDialogRadioLastModified + currSorting and SORT_BY_DATE_TAKEN != 0 -> binding.sortingDialogRadioDateTaken + currSorting and SORT_BY_RANDOM != 0 -> binding.sortingDialogRadioRandom + currSorting and SORT_BY_CUSTOM != 0 -> binding.sortingDialogRadioCustom + else -> binding.sortingDialogRadioName } sortBtn.isChecked = true } private fun setupOrderRadio() { - val orderRadio = view.sorting_dialog_radio_order - var orderBtn = orderRadio.sorting_dialog_radio_ascending + var orderBtn = binding.sortingDialogRadioAscending if (currSorting and SORT_DESCENDING != 0) { - orderBtn = orderRadio.sorting_dialog_radio_descending + orderBtn = binding.sortingDialogRadioDescending } orderBtn.isChecked = true } override fun onClick(dialog: DialogInterface, which: Int) { - val sortingRadio = view.sorting_dialog_radio_sorting + val sortingRadio = binding.sortingDialogRadioSorting var sorting = when (sortingRadio.checkedRadioButtonId) { R.id.sorting_dialog_radio_name -> SORT_BY_NAME R.id.sorting_dialog_radio_path -> SORT_BY_PATH @@ -91,18 +89,18 @@ class ChangeSortingDialog( else -> SORT_BY_DATE_TAKEN } - if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) { + if (binding.sortingDialogRadioOrder.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) { sorting = sorting or SORT_DESCENDING } - if (view.sorting_dialog_numeric_sorting.isChecked) { + if (binding.sortingDialogNumericSorting.isChecked) { sorting = sorting or SORT_USE_NUMERIC_VALUE } if (isDirectorySorting) { config.directorySorting = sorting } else { - if (view.sorting_dialog_use_for_this_folder.isChecked) { + if (binding.sortingDialogUseForThisFolder.isChecked) { config.saveCustomSorting(pathToUse, sorting) } else { config.removeCustomSorting(pathToUse) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt index ebe343e48..322a0f443 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ChangeViewTypeDialog.kt @@ -1,61 +1,59 @@ package com.simplemobiletools.gallery.pro.dialogs -import android.view.View import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogChangeViewTypeBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL -import kotlinx.android.synthetic.main.dialog_change_view_type.view.* class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView: Boolean, val path: String = "", val callback: () -> Unit) { - private var view: View + private val binding = DialogChangeViewTypeBinding.inflate(activity.layoutInflater) private var config = activity.config private var pathToUse = if (path.isEmpty()) SHOW_ALL else path init { - view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply { + binding.apply { val viewToCheck = if (fromFoldersView) { if (config.viewTypeFolders == VIEW_TYPE_GRID) { - change_view_type_dialog_radio_grid.id + changeViewTypeDialogRadioGrid.id } else { - change_view_type_dialog_radio_list.id + changeViewTypeDialogRadioList.id } } else { val currViewType = config.getFolderViewType(pathToUse) if (currViewType == VIEW_TYPE_GRID) { - change_view_type_dialog_radio_grid.id + changeViewTypeDialogRadioGrid.id } else { - change_view_type_dialog_radio_list.id + changeViewTypeDialogRadioList.id } } - change_view_type_dialog_radio.check(viewToCheck) - change_view_type_dialog_group_direct_subfolders.apply { + changeViewTypeDialogRadio.check(viewToCheck) + changeViewTypeDialogGroupDirectSubfolders.apply { beVisibleIf(fromFoldersView) isChecked = config.groupDirectSubfolders } - change_view_type_dialog_use_for_this_folder.apply { + changeViewTypeDialogUseForThisFolder.apply { beVisibleIf(!fromFoldersView) isChecked = config.hasCustomViewType(pathToUse) } } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(binding.root, this) } } private fun dialogConfirmed() { - val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) { + val viewType = if (binding.changeViewTypeDialogRadio.checkedRadioButtonId == binding.changeViewTypeDialogRadioGrid.id) { VIEW_TYPE_GRID } else { VIEW_TYPE_LIST @@ -63,9 +61,9 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView if (fromFoldersView) { config.viewTypeFolders = viewType - config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked + config.groupDirectSubfolders = binding.changeViewTypeDialogGroupDirectSubfolders.isChecked } else { - if (view.change_view_type_dialog_use_for_this_folder.isChecked) { + if (binding.changeViewTypeDialogUseForThisFolder.isChecked) { config.saveFolderViewType(pathToUse, viewType) } else { config.removeFolderViewType(pathToUse) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ConfirmDeleteFolderDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ConfirmDeleteFolderDialog.kt index 5861481ed..c209e0b5d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ConfirmDeleteFolderDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ConfirmDeleteFolderDialog.kt @@ -4,22 +4,21 @@ import android.app.Activity import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_confirm_delete_folder.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogConfirmDeleteFolderBinding class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) { private var dialog: AlertDialog? = null init { - val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null) - view.message.text = message - view.message_warning.text = warningMessage + val binding = DialogConfirmDeleteFolderBinding.inflate(activity.layoutInflater) + binding.message.text = message + binding.messageWarning.text = warningMessage activity.getAlertDialogBuilder() - .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.no, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.yes) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.no, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> + activity.setupDialogStuff(binding.root, this) { alertDialog -> dialog = alertDialog } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/CustomAspectRatioDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/CustomAspectRatioDialog.kt index 874422538..020b05b8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/CustomAspectRatioDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/CustomAspectRatioDialog.kt @@ -7,27 +7,26 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.showKeyboard import com.simplemobiletools.commons.extensions.value -import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogCustomAspectRatioBinding class CustomAspectRatioDialog( val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair?, val callback: (aspectRatio: Pair) -> Unit ) { init { - val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply { - aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "") - aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "") + val binding = DialogCustomAspectRatioBinding.inflate(activity.layoutInflater).apply { + aspectRatioWidth.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "") + aspectRatioHeight.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "") } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> - alertDialog.showKeyboard(view.aspect_ratio_width) + activity.setupDialogStuff(binding.root, this) { alertDialog -> + alertDialog.showKeyboard(binding.aspectRatioWidth) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { - val width = getViewValue(view.aspect_ratio_width) - val height = getViewValue(view.aspect_ratio_height) + val width = getViewValue(binding.aspectRatioWidth) + val height = getViewValue(binding.aspectRatioHeight) callback(Pair(width, height)) alertDialog.dismiss() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/DeleteWithRememberDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/DeleteWithRememberDialog.kt index 8229668d4..fd57f69c7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/DeleteWithRememberDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/DeleteWithRememberDialog.kt @@ -5,8 +5,7 @@ import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.extensions.beGoneIf import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogDeleteWithRememberBinding class DeleteWithRememberDialog( private val activity: Activity, @@ -16,16 +15,16 @@ class DeleteWithRememberDialog( ) { private var dialog: AlertDialog? = null - val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!! + private val binding = DialogDeleteWithRememberBinding.inflate(activity.layoutInflater) init { - view.delete_remember_title.text = message - view.skip_the_recycle_bin_checkbox.beGoneIf(!showSkipRecycleBinOption) + binding.deleteRememberTitle.text = message + binding.skipTheRecycleBinCheckbox.beGoneIf(!showSkipRecycleBinOption) activity.getAlertDialogBuilder() - .setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.no, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.yes) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.no, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> + activity.setupDialogStuff(binding.root, this) { alertDialog -> dialog = alertDialog } } @@ -33,6 +32,6 @@ class DeleteWithRememberDialog( private fun dialogConfirmed() { dialog?.dismiss() - callback(view.delete_remember_checkbox.isChecked, view.skip_the_recycle_bin_checkbox.isChecked) + callback(binding.deleteRememberCheckbox.isChecked, binding.skipTheRecycleBinCheckbox.isChecked) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExcludeFolderDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExcludeFolderDialog.kt index d610b2387..dbdba0698 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExcludeFolderDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExcludeFolderDialog.kt @@ -1,31 +1,30 @@ package com.simplemobiletools.gallery.pro.dialogs import android.view.ViewGroup -import android.widget.RadioButton import android.widget.RadioGroup import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.databinding.RadioButtonBinding import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.getBasePath import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogExcludeFolderBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.dialog_exclude_folder.view.* class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: List, val callback: () -> Unit) { private val alternativePaths = getAlternativePathsList() private var radioGroup: RadioGroup? = null init { - val view = activity.layoutInflater.inflate(R.layout.dialog_exclude_folder, null).apply { - exclude_folder_parent.beVisibleIf(alternativePaths.size > 1) + val binding = DialogExcludeFolderBinding.inflate(activity.layoutInflater).apply { + excludeFolderParent.beVisibleIf(alternativePaths.size > 1) - radioGroup = exclude_folder_radio_group - exclude_folder_radio_group.beVisibleIf(alternativePaths.size > 1) + radioGroup = excludeFolderRadioGroup + excludeFolderRadioGroup.beVisibleIf(alternativePaths.size > 1) } alternativePaths.forEachIndexed { index, value -> - val radioButton = (activity.layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply { + val radioButton = RadioButtonBinding.inflate(activity.layoutInflater).root.apply { text = alternativePaths[index] isChecked = index == 0 id = index @@ -34,10 +33,10 @@ class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: L } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(binding.root, this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExportFavoritesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExportFavoritesDialog.kt index 106067063..0df365ae0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExportFavoritesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ExportFavoritesDialog.kt @@ -6,8 +6,8 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogExportFavoritesBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.dialog_export_favorites.view.* class ExportFavoritesDialog( val activity: BaseSimpleActivity, val defaultFilename: String, val hidePath: Boolean, @@ -21,17 +21,17 @@ class ExportFavoritesDialog( activity.internalStoragePath } - val view = activity.layoutInflater.inflate(R.layout.dialog_export_favorites, null).apply { - export_favorites_filename.setText(defaultFilename.removeSuffix(".txt")) + val binding = DialogExportFavoritesBinding.inflate(activity.layoutInflater).apply { + exportFavoritesFilename.setText(defaultFilename.removeSuffix(".txt")) if (hidePath) { - export_favorites_path_label.beGone() - export_favorites_path.beGone() + exportFavoritesPathLabel.beGone() + exportFavoritesPath.beGone() } else { - export_favorites_path.text = activity.humanizePath(folder) - export_favorites_path.setOnClickListener { + exportFavoritesPath.text = activity.humanizePath(folder) + exportFavoritesPath.setOnClickListener { FilePickerDialog(activity, folder, false, showFAB = true) { - export_favorites_path.text = activity.humanizePath(it) + exportFavoritesPath.text = activity.humanizePath(it) folder = it } } @@ -39,27 +39,30 @@ class ExportFavoritesDialog( } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.export_favorite_paths) { alertDialog -> + activity.setupDialogStuff(binding.root, this, R.string.export_favorite_paths) { alertDialog -> alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { - var filename = view.export_favorites_filename.value + var filename = binding.exportFavoritesFilename.value if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) + activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty) return@setOnClickListener } filename += ".txt" val newPath = "${folder.trimEnd('/')}/$filename" if (!newPath.getFilenameFromPath().isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) + activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters) return@setOnClickListener } activity.config.lastExportedFavoritesFolder = folder if (!hidePath && activity.getDoesFilePathExist(newPath)) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newPath.getFilenameFromPath()) + val title = String.format( + activity.getString(com.simplemobiletools.commons.R.string.file_already_exists_overwrite), + newPath.getFilenameFromPath() + ) ConfirmationDialog(activity, title) { callback(newPath, filename) alertDialog.dismiss() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt index f29b8020c..0d41f03ba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt @@ -4,45 +4,45 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogFilterMediaBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.dialog_filter_media.view.* class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) { - private var view = activity.layoutInflater.inflate(R.layout.dialog_filter_media, null) + private val binding = DialogFilterMediaBinding.inflate(activity.layoutInflater) init { val filterMedia = activity.config.filterMedia - view.apply { - filter_media_images.isChecked = filterMedia and TYPE_IMAGES != 0 - filter_media_videos.isChecked = filterMedia and TYPE_VIDEOS != 0 - filter_media_gifs.isChecked = filterMedia and TYPE_GIFS != 0 - filter_media_raws.isChecked = filterMedia and TYPE_RAWS != 0 - filter_media_svgs.isChecked = filterMedia and TYPE_SVGS != 0 - filter_media_portraits.isChecked = filterMedia and TYPE_PORTRAITS != 0 + binding.apply { + filterMediaImages.isChecked = filterMedia and TYPE_IMAGES != 0 + filterMediaVideos.isChecked = filterMedia and TYPE_VIDEOS != 0 + filterMediaGifs.isChecked = filterMedia and TYPE_GIFS != 0 + filterMediaRaws.isChecked = filterMedia and TYPE_RAWS != 0 + filterMediaSvgs.isChecked = filterMedia and TYPE_SVGS != 0 + filterMediaPortraits.isChecked = filterMedia and TYPE_PORTRAITS != 0 } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.filter_media) + activity.setupDialogStuff(binding.root, this, R.string.filter_media) } } private fun dialogConfirmed() { var result = 0 - if (view.filter_media_images.isChecked) + if (binding.filterMediaImages.isChecked) result += TYPE_IMAGES - if (view.filter_media_videos.isChecked) + if (binding.filterMediaVideos.isChecked) result += TYPE_VIDEOS - if (view.filter_media_gifs.isChecked) + if (binding.filterMediaGifs.isChecked) result += TYPE_GIFS - if (view.filter_media_raws.isChecked) + if (binding.filterMediaRaws.isChecked) result += TYPE_RAWS - if (view.filter_media_svgs.isChecked) + if (binding.filterMediaSvgs.isChecked) result += TYPE_SVGS - if (view.filter_media_portraits.isChecked) + if (binding.filterMediaPortraits.isChecked) result += TYPE_PORTRAITS if (result == 0) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/GrantAllFilesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/GrantAllFilesDialog.kt index 226bf5d2d..32ab21194 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/GrantAllFilesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/GrantAllFilesDialog.kt @@ -1,25 +1,23 @@ package com.simplemobiletools.gallery.pro.dialogs -import android.view.View import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.getProperTextColor import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogGrantAllFilesBinding import com.simplemobiletools.gallery.pro.extensions.launchGrantAllFilesIntent -import kotlinx.android.synthetic.main.dialog_grant_all_files.view.* class GrantAllFilesDialog(val activity: BaseSimpleActivity) { init { - val view: View = activity.layoutInflater.inflate(R.layout.dialog_grant_all_files, null) - view.grant_all_files_image.applyColorFilter(activity.getProperTextColor()) + val binding = DialogGrantAllFilesBinding.inflate(activity.layoutInflater) + binding.grantAllFilesImage.applyColorFilter(activity.getProperTextColor()) activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> activity.launchGrantAllFilesIntent() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> activity.launchGrantAllFilesIntent() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> } + activity.setupDialogStuff(binding.root, this) { alertDialog -> } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt index da86d9abd..b627aa9d2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt @@ -3,74 +3,73 @@ package com.simplemobiletools.gallery.pro.dialogs import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogManageBottomActionsBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.dialog_manage_bottom_actions.view.* class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) { - private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_bottom_actions, null) + private val binding = DialogManageBottomActionsBinding.inflate(activity.layoutInflater) init { val actions = activity.config.visibleBottomActions - view.apply { - manage_bottom_actions_toggle_favorite.isChecked = actions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 - manage_bottom_actions_edit.isChecked = actions and BOTTOM_ACTION_EDIT != 0 - manage_bottom_actions_share.isChecked = actions and BOTTOM_ACTION_SHARE != 0 - manage_bottom_actions_delete.isChecked = actions and BOTTOM_ACTION_DELETE != 0 - manage_bottom_actions_rotate.isChecked = actions and BOTTOM_ACTION_ROTATE != 0 - manage_bottom_actions_properties.isChecked = actions and BOTTOM_ACTION_PROPERTIES != 0 - manage_bottom_actions_change_orientation.isChecked = actions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0 - manage_bottom_actions_slideshow.isChecked = actions and BOTTOM_ACTION_SLIDESHOW != 0 - manage_bottom_actions_show_on_map.isChecked = actions and BOTTOM_ACTION_SHOW_ON_MAP != 0 - manage_bottom_actions_toggle_visibility.isChecked = actions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0 - manage_bottom_actions_rename.isChecked = actions and BOTTOM_ACTION_RENAME != 0 - manage_bottom_actions_set_as.isChecked = actions and BOTTOM_ACTION_SET_AS != 0 - manage_bottom_actions_copy.isChecked = actions and BOTTOM_ACTION_COPY != 0 - manage_bottom_actions_move.isChecked = actions and BOTTOM_ACTION_MOVE != 0 - manage_bottom_actions_resize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0 + binding.apply { + manageBottomActionsToggleFavorite.isChecked = actions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 + manageBottomActionsEdit.isChecked = actions and BOTTOM_ACTION_EDIT != 0 + manageBottomActionsShare.isChecked = actions and BOTTOM_ACTION_SHARE != 0 + manageBottomActionsDelete.isChecked = actions and BOTTOM_ACTION_DELETE != 0 + manageBottomActionsRotate.isChecked = actions and BOTTOM_ACTION_ROTATE != 0 + manageBottomActionsProperties.isChecked = actions and BOTTOM_ACTION_PROPERTIES != 0 + manageBottomActionsChangeOrientation.isChecked = actions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0 + manageBottomActionsSlideshow.isChecked = actions and BOTTOM_ACTION_SLIDESHOW != 0 + manageBottomActionsShowOnMap.isChecked = actions and BOTTOM_ACTION_SHOW_ON_MAP != 0 + manageBottomActionsToggleVisibility.isChecked = actions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0 + manageBottomActionsRename.isChecked = actions and BOTTOM_ACTION_RENAME != 0 + manageBottomActionsSetAs.isChecked = actions and BOTTOM_ACTION_SET_AS != 0 + manageBottomActionsCopy.isChecked = actions and BOTTOM_ACTION_COPY != 0 + manageBottomActionsMove.isChecked = actions and BOTTOM_ACTION_MOVE != 0 + manageBottomActionsResize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0 } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(binding.root, this) } } private fun dialogConfirmed() { var result = 0 - view.apply { - if (manage_bottom_actions_toggle_favorite.isChecked) + binding.apply { + if (manageBottomActionsToggleFavorite.isChecked) result += BOTTOM_ACTION_TOGGLE_FAVORITE - if (manage_bottom_actions_edit.isChecked) + if (manageBottomActionsEdit.isChecked) result += BOTTOM_ACTION_EDIT - if (manage_bottom_actions_share.isChecked) + if (manageBottomActionsShare.isChecked) result += BOTTOM_ACTION_SHARE - if (manage_bottom_actions_delete.isChecked) + if (manageBottomActionsDelete.isChecked) result += BOTTOM_ACTION_DELETE - if (manage_bottom_actions_rotate.isChecked) + if (manageBottomActionsRotate.isChecked) result += BOTTOM_ACTION_ROTATE - if (manage_bottom_actions_properties.isChecked) + if (manageBottomActionsProperties.isChecked) result += BOTTOM_ACTION_PROPERTIES - if (manage_bottom_actions_change_orientation.isChecked) + if (manageBottomActionsChangeOrientation.isChecked) result += BOTTOM_ACTION_CHANGE_ORIENTATION - if (manage_bottom_actions_slideshow.isChecked) + if (manageBottomActionsSlideshow.isChecked) result += BOTTOM_ACTION_SLIDESHOW - if (manage_bottom_actions_show_on_map.isChecked) + if (manageBottomActionsShowOnMap.isChecked) result += BOTTOM_ACTION_SHOW_ON_MAP - if (manage_bottom_actions_toggle_visibility.isChecked) + if (manageBottomActionsToggleVisibility.isChecked) result += BOTTOM_ACTION_TOGGLE_VISIBILITY - if (manage_bottom_actions_rename.isChecked) + if (manageBottomActionsRename.isChecked) result += BOTTOM_ACTION_RENAME - if (manage_bottom_actions_set_as.isChecked) + if (manageBottomActionsSetAs.isChecked) result += BOTTOM_ACTION_SET_AS - if (manage_bottom_actions_copy.isChecked) + if (manageBottomActionsCopy.isChecked) result += BOTTOM_ACTION_COPY - if (manage_bottom_actions_move.isChecked) + if (manageBottomActionsMove.isChecked) result += BOTTOM_ACTION_MOVE - if (manage_bottom_actions_resize.isChecked) + if (manageBottomActionsResize.isChecked) result += BOTTOM_ACTION_RESIZE } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageExtendedDetailsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageExtendedDetailsDialog.kt index 8e369452f..5dcbc0ab0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageExtendedDetailsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageExtendedDetailsDialog.kt @@ -3,56 +3,55 @@ package com.simplemobiletools.gallery.pro.dialogs import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogManageExtendedDetailsBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* -import kotlinx.android.synthetic.main.dialog_manage_extended_details.view.* class ManageExtendedDetailsDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) { - private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_extended_details, null) + private val binding = DialogManageExtendedDetailsBinding.inflate(activity.layoutInflater) init { val details = activity.config.extendedDetails - view.apply { - manage_extended_details_name.isChecked = details and EXT_NAME != 0 - manage_extended_details_path.isChecked = details and EXT_PATH != 0 - manage_extended_details_size.isChecked = details and EXT_SIZE != 0 - manage_extended_details_resolution.isChecked = details and EXT_RESOLUTION != 0 - manage_extended_details_last_modified.isChecked = details and EXT_LAST_MODIFIED != 0 - manage_extended_details_date_taken.isChecked = details and EXT_DATE_TAKEN != 0 - manage_extended_details_camera.isChecked = details and EXT_CAMERA_MODEL != 0 - manage_extended_details_exif.isChecked = details and EXT_EXIF_PROPERTIES != 0 - manage_extended_details_gps_coordinates.isChecked = details and EXT_GPS != 0 + binding.apply { + manageExtendedDetailsName.isChecked = details and EXT_NAME != 0 + manageExtendedDetailsPath.isChecked = details and EXT_PATH != 0 + manageExtendedDetailsSize.isChecked = details and EXT_SIZE != 0 + manageExtendedDetailsResolution.isChecked = details and EXT_RESOLUTION != 0 + manageExtendedDetailsLastModified.isChecked = details and EXT_LAST_MODIFIED != 0 + manageExtendedDetailsDateTaken.isChecked = details and EXT_DATE_TAKEN != 0 + manageExtendedDetailsCamera.isChecked = details and EXT_CAMERA_MODEL != 0 + manageExtendedDetailsExif.isChecked = details and EXT_EXIF_PROPERTIES != 0 + manageExtendedDetailsGpsCoordinates.isChecked = details and EXT_GPS != 0 } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() } + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) + activity.setupDialogStuff(binding.root, this) } } private fun dialogConfirmed() { var result = 0 - view.apply { - if (manage_extended_details_name.isChecked) + binding.apply { + if (manageExtendedDetailsName.isChecked) result += EXT_NAME - if (manage_extended_details_path.isChecked) + if (manageExtendedDetailsPath.isChecked) result += EXT_PATH - if (manage_extended_details_size.isChecked) + if (manageExtendedDetailsSize.isChecked) result += EXT_SIZE - if (manage_extended_details_resolution.isChecked) + if (manageExtendedDetailsResolution.isChecked) result += EXT_RESOLUTION - if (manage_extended_details_last_modified.isChecked) + if (manageExtendedDetailsLastModified.isChecked) result += EXT_LAST_MODIFIED - if (manage_extended_details_date_taken.isChecked) + if (manageExtendedDetailsDateTaken.isChecked) result += EXT_DATE_TAKEN - if (manage_extended_details_camera.isChecked) + if (manageExtendedDetailsCamera.isChecked) result += EXT_CAMERA_MODEL - if (manage_extended_details_exif.isChecked) + if (manageExtendedDetailsExif.isChecked) result += EXT_EXIF_PROPERTIES - if (manage_extended_details_gps_coordinates.isChecked) + if (manageExtendedDetailsGpsCoordinates.isChecked) result += EXT_GPS } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/OtherAspectRatioDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/OtherAspectRatioDialog.kt index 049184cd8..2d7649303 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/OtherAspectRatioDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/OtherAspectRatioDialog.kt @@ -4,8 +4,7 @@ import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff -import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogOtherAspectRatioBinding class OtherAspectRatioDialog( val activity: BaseSimpleActivity, @@ -15,53 +14,53 @@ class OtherAspectRatioDialog( private var dialog: AlertDialog? = null init { - val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply { - other_aspect_ratio_2_1.setOnClickListener { ratioPicked(Pair(2f, 1f)) } - other_aspect_ratio_3_2.setOnClickListener { ratioPicked(Pair(3f, 2f)) } - other_aspect_ratio_4_3.setOnClickListener { ratioPicked(Pair(4f, 3f)) } - other_aspect_ratio_5_3.setOnClickListener { ratioPicked(Pair(5f, 3f)) } - other_aspect_ratio_16_9.setOnClickListener { ratioPicked(Pair(16f, 9f)) } - other_aspect_ratio_19_9.setOnClickListener { ratioPicked(Pair(19f, 9f)) } - other_aspect_ratio_custom.setOnClickListener { customRatioPicked() } + val binding = DialogOtherAspectRatioBinding.inflate(activity.layoutInflater).apply { + otherAspectRatio21.setOnClickListener { ratioPicked(Pair(2f, 1f)) } + otherAspectRatio32.setOnClickListener { ratioPicked(Pair(3f, 2f)) } + otherAspectRatio43.setOnClickListener { ratioPicked(Pair(4f, 3f)) } + otherAspectRatio53.setOnClickListener { ratioPicked(Pair(5f, 3f)) } + otherAspectRatio169.setOnClickListener { ratioPicked(Pair(16f, 9f)) } + otherAspectRatio199.setOnClickListener { ratioPicked(Pair(19f, 9f)) } + otherAspectRatioCustom.setOnClickListener { customRatioPicked() } - other_aspect_ratio_1_2.setOnClickListener { ratioPicked(Pair(1f, 2f)) } - other_aspect_ratio_2_3.setOnClickListener { ratioPicked(Pair(2f, 3f)) } - other_aspect_ratio_3_4.setOnClickListener { ratioPicked(Pair(3f, 4f)) } - other_aspect_ratio_3_5.setOnClickListener { ratioPicked(Pair(3f, 5f)) } - other_aspect_ratio_9_16.setOnClickListener { ratioPicked(Pair(9f, 16f)) } - other_aspect_ratio_9_19.setOnClickListener { ratioPicked(Pair(9f, 19f)) } + otherAspectRatio12.setOnClickListener { ratioPicked(Pair(1f, 2f)) } + otherAspectRatio23.setOnClickListener { ratioPicked(Pair(2f, 3f)) } + otherAspectRatio34.setOnClickListener { ratioPicked(Pair(3f, 4f)) } + otherAspectRatio35.setOnClickListener { ratioPicked(Pair(3f, 5f)) } + otherAspectRatio916.setOnClickListener { ratioPicked(Pair(9f, 16f)) } + otherAspectRatio919.setOnClickListener { ratioPicked(Pair(9f, 19f)) } val radio1SelectedItemId = when (lastOtherAspectRatio) { - Pair(2f, 1f) -> other_aspect_ratio_2_1.id - Pair(3f, 2f) -> other_aspect_ratio_3_2.id - Pair(4f, 3f) -> other_aspect_ratio_4_3.id - Pair(5f, 3f) -> other_aspect_ratio_5_3.id - Pair(16f, 9f) -> other_aspect_ratio_16_9.id - Pair(19f, 9f) -> other_aspect_ratio_19_9.id + Pair(2f, 1f) -> otherAspectRatio21.id + Pair(3f, 2f) -> otherAspectRatio32.id + Pair(4f, 3f) -> otherAspectRatio43.id + Pair(5f, 3f) -> otherAspectRatio53.id + Pair(16f, 9f) -> otherAspectRatio169.id + Pair(19f, 9f) -> otherAspectRatio199.id else -> 0 } - other_aspect_ratio_dialog_radio_1.check(radio1SelectedItemId) + otherAspectRatioDialogRadio1.check(radio1SelectedItemId) val radio2SelectedItemId = when (lastOtherAspectRatio) { - Pair(1f, 2f) -> other_aspect_ratio_1_2.id - Pair(2f, 3f) -> other_aspect_ratio_2_3.id - Pair(3f, 4f) -> other_aspect_ratio_3_4.id - Pair(3f, 5f) -> other_aspect_ratio_3_5.id - Pair(9f, 16f) -> other_aspect_ratio_9_16.id - Pair(9f, 19f) -> other_aspect_ratio_9_19.id + Pair(1f, 2f) -> otherAspectRatio12.id + Pair(2f, 3f) -> otherAspectRatio23.id + Pair(3f, 4f) -> otherAspectRatio34.id + Pair(3f, 5f) -> otherAspectRatio35.id + Pair(9f, 16f) -> otherAspectRatio916.id + Pair(9f, 19f) -> otherAspectRatio919.id else -> 0 } - other_aspect_ratio_dialog_radio_2.check(radio2SelectedItemId) + otherAspectRatioDialogRadio2.check(radio2SelectedItemId) if (radio1SelectedItemId == 0 && radio2SelectedItemId == 0) { - other_aspect_ratio_dialog_radio_1.check(other_aspect_ratio_custom.id) + otherAspectRatioDialogRadio1.check(otherAspectRatioCustom.id) } } activity.getAlertDialogBuilder() - .setNegativeButton(R.string.cancel, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> + activity.setupDialogStuff(binding.root, this) { alertDialog -> dialog = alertDialog } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt index 438c005c9..53c8251c5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt @@ -2,10 +2,7 @@ package com.simplemobiletools.gallery.pro.dialogs import android.graphics.Color import android.view.KeyEvent -import android.view.View import android.view.inputmethod.EditorInfo -import android.widget.EditText -import android.widget.ImageView import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.recyclerview.widget.RecyclerView @@ -17,9 +14,9 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.commons.views.MySearchMenu import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter +import com.simplemobiletools.gallery.pro.databinding.DialogDirectoryPickerBinding import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.models.Directory -import kotlinx.android.synthetic.main.dialog_directory_picker.view.* class PickDirectoryDialog( val activity: BaseSimpleActivity, @@ -34,28 +31,28 @@ class PickDirectoryDialog( private var shownDirectories = ArrayList() private var allDirectories = ArrayList() private var openedSubfolders = arrayListOf("") - private var view = activity.layoutInflater.inflate(R.layout.dialog_directory_picker, null) + private var binding = DialogDirectoryPickerBinding.inflate(activity.layoutInflater) private var isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID private var showHidden = activity.config.shouldShowHidden private var currentPathPrefix = "" private val config = activity.config - private val searchView = view.folder_search_view - private val searchEditText = view.findViewById(R.id.top_toolbar_search) - private val searchViewAppBarLayout = view.findViewById(R.id.top_app_bar_layout) + private val searchView = binding.folderSearchView + private val searchEditText = searchView.binding.topToolbarSearch + private val searchViewAppBarLayout = searchView.binding.topAppBarLayout init { - (view.directories_grid.layoutManager as MyGridLayoutManager).apply { + (binding.directoriesGrid.layoutManager as MyGridLayoutManager).apply { orientation = if (activity.config.scrollHorizontally && isGridViewType) RecyclerView.HORIZONTAL else RecyclerView.VERTICAL spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1 } - view.directories_fastscroller.updateColors(activity.getProperPrimaryColor()) + binding.directoriesFastscroller.updateColors(activity.getProperPrimaryColor()) configureSearchView() val builder = activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .setOnKeyListener { dialogInterface, i, keyEvent -> if (keyEvent.action == KeyEvent.ACTION_UP && i == KeyEvent.KEYCODE_BACK) { backPressed() @@ -68,12 +65,12 @@ class PickDirectoryDialog( } builder.apply { - activity.setupDialogStuff(view, this, R.string.select_destination) { alertDialog -> + activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.select_destination) { alertDialog -> dialog = alertDialog - view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden) - view.directories_show_hidden.setOnClickListener { + binding.directoriesShowHidden.beVisibleIf(!context.config.shouldShowHidden) + binding.directoriesShowHidden.setOnClickListener { activity.handleHiddenFolderPasswordProtection { - view.directories_show_hidden.beGone() + binding.directoriesShowHidden.beGone() showHidden = true fetchDirectories(true) } @@ -85,7 +82,7 @@ class PickDirectoryDialog( } private fun configureSearchView() = with(searchView) { - updateHintText(context.getString(R.string.search_folders)) + updateHintText(context.getString(com.simplemobiletools.commons.R.string.search_folders)) searchEditText.imeOptions = EditorInfo.IME_ACTION_DONE toggleHideOnScroll(!config.scrollHorizontally) @@ -103,13 +100,13 @@ class PickDirectoryDialog( private fun MySearchMenu.setSearchViewListeners() { onSearchOpenListener = { - updateSearchViewLeftIcon(R.drawable.ic_cross_vector) + updateSearchViewLeftIcon(com.simplemobiletools.commons.R.drawable.ic_cross_vector) } onSearchClosedListener = { searchEditText.clearFocus() activity.hideKeyboard(searchEditText) - updateSearchViewLeftIcon(R.drawable.ic_search_vector) + updateSearchViewLeftIcon(com.simplemobiletools.commons.R.drawable.ic_search_vector) } onSearchTextChangedListener = { text -> @@ -117,14 +114,14 @@ class PickDirectoryDialog( } } - private fun updateSearchViewLeftIcon(iconResId: Int) = with(view.findViewById(R.id.top_toolbar_search_icon)) { + private fun updateSearchViewLeftIcon(iconResId: Int) = with(searchView.binding.topToolbarSearchIcon) { post { setImageResource(iconResId) } } private fun filterFolderListBySearchQuery(query: String) { - val adapter = view.directories_grid.adapter as? DirectoryAdapter + val adapter = binding.directoriesGrid.adapter as? DirectoryAdapter var dirsToShow = allDirectories if (query.isNotEmpty()) { dirsToShow = dirsToShow.filter { it.name.contains(query, true) }.toMutableList() as ArrayList @@ -136,7 +133,7 @@ class PickDirectoryDialog( if (filteredFolderListUpdated) { adapter?.updateDirs(dirsToShow) - view.directories_grid.apply { + binding.directoriesGrid.apply { post { scrollToPosition(0) } @@ -144,14 +141,14 @@ class PickDirectoryDialog( } } - private fun checkPlaceholderVisibility(dirs: ArrayList) = with(view) { - directories_empty_placeholder.beVisibleIf(dirs.isEmpty()) + private fun checkPlaceholderVisibility(dirs: ArrayList) = with(binding) { + directoriesEmptyPlaceholder.beVisibleIf(dirs.isEmpty()) - if (folder_search_view.isSearchOpen) { - directories_empty_placeholder.text = context.getString(R.string.no_items_found) + if (folderSearchView.isSearchOpen) { + directoriesEmptyPlaceholder.text = root.context.getString(com.simplemobiletools.commons.R.string.no_items_found) } - directories_fastscroller.beVisibleIf(directories_empty_placeholder.isGone()) + directoriesFastscroller.beVisibleIf(directoriesEmptyPlaceholder.isGone()) } private fun fetchDirectories(forceShowHiddenAndExcluded: Boolean) { @@ -201,15 +198,15 @@ class PickDirectoryDialog( } shownDirectories = dirs - val adapter = DirectoryAdapter(activity, dirs.clone() as ArrayList, null, view.directories_grid, true) { + val adapter = DirectoryAdapter(activity, dirs.clone() as ArrayList, null, binding.directoriesGrid, true) { val clickedDir = it as Directory val path = clickedDir.path if (clickedDir.subfoldersCount == 1 || !activity.config.groupDirectSubfolders) { if (isPickingCopyMoveDestination && path.trimEnd('/') == sourcePath) { - activity.toast(R.string.source_and_destination_same) + activity.toast(com.simplemobiletools.commons.R.string.source_and_destination_same) return@DirectoryAdapter } else if (isPickingCopyMoveDestination && activity.isRestrictedWithSAFSdk30(path) && !activity.isInDownloadDir(path)) { - activity.toast(R.string.system_folder_copy_restriction, Toast.LENGTH_LONG) + activity.toast(com.simplemobiletools.commons.R.string.system_folder_copy_restriction, Toast.LENGTH_LONG) return@DirectoryAdapter } else { activity.handleLockedFolderOpening(path) { success -> @@ -227,9 +224,9 @@ class PickDirectoryDialog( } val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType - view.apply { - directories_grid.adapter = adapter - directories_fastscroller.setScrollVertically(!scrollHorizontally) + binding.apply { + directoriesGrid.adapter = adapter + directoriesFastscroller.setScrollVertically(!scrollHorizontally) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt index 3253f79ac..5c8e14f98 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt @@ -11,6 +11,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.MediaAdapter import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask +import com.simplemobiletools.gallery.pro.databinding.DialogMediumPickerBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.getCachedMedia import com.simplemobiletools.gallery.pro.helpers.GridSpacingItemDecoration @@ -18,30 +19,29 @@ import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection -import kotlinx.android.synthetic.main.dialog_medium_picker.view.* class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) { private var dialog: AlertDialog? = null private var shownMedia = ArrayList() - private val view = activity.layoutInflater.inflate(R.layout.dialog_medium_picker, null) + private val binding = DialogMediumPickerBinding.inflate(activity.layoutInflater) private val config = activity.config private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path) private var isGridViewType = viewType == VIEW_TYPE_GRID init { - (view.media_grid.layoutManager as MyGridLayoutManager).apply { + (binding.mediaGrid.layoutManager as MyGridLayoutManager).apply { orientation = if (config.scrollHorizontally && isGridViewType) RecyclerView.HORIZONTAL else RecyclerView.VERTICAL spanCount = if (isGridViewType) config.mediaColumnCnt else 1 } - view.media_fastscroller.updateColors(activity.getProperPrimaryColor()) + binding.mediaFastscroller.updateColors(activity.getProperPrimaryColor()) activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } .apply { - activity.setupDialogStuff(view, this, R.string.select_photo) { alertDialog -> + activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.select_photo) { alertDialog -> dialog = alertDialog } } @@ -72,7 +72,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c return shownMedia = media - val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList, null, true, false, path, view.media_grid) { + val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList, null, true, false, path, binding.mediaGrid) { if (it is Medium) { callback(it.path) dialog?.dismiss() @@ -80,9 +80,9 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c } val scrollHorizontally = config.scrollHorizontally && isGridViewType - view.apply { - media_grid.adapter = adapter - media_fastscroller.setScrollVertically(!scrollHorizontally) + binding.apply { + mediaGrid.adapter = adapter + mediaFastscroller.setScrollVertically(!scrollHorizontally) } handleGridSpacing(media) } @@ -94,17 +94,17 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c val useGridPosition = media.firstOrNull() is ThumbnailSection var currentGridDecoration: GridSpacingItemDecoration? = null - if (view.media_grid.itemDecorationCount > 0) { - currentGridDecoration = view.media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration + if (binding.mediaGrid.itemDecorationCount > 0) { + currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration currentGridDecoration.items = media } val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition) if (currentGridDecoration.toString() != newGridDecoration.toString()) { if (currentGridDecoration != null) { - view.media_grid.removeItemDecoration(currentGridDecoration) + binding.mediaGrid.removeItemDecoration(currentGridDecoration) } - view.media_grid.addItemDecoration(newGridDecoration) + binding.mediaGrid.addItemDecoration(newGridDecoration) } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt index 37bb3a1bd..034104e0a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeDialog.kt @@ -6,13 +6,13 @@ import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_resize_image.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogResizeImageBinding class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) { init { - val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image, null) - val widthView = view.resize_image_width - val heightView = view.resize_image_height + val binding = DialogResizeImageBinding.inflate(activity.layoutInflater) + val widthView = binding.resizeImageWidth + val heightView = binding.resizeImageHeight widthView.setText(size.x.toString()) heightView.setText(size.y.toString()) @@ -27,7 +27,7 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba width = size.x } - if (view.keep_aspect_ratio.isChecked) { + if (binding.keepAspectRatio.isChecked) { heightView.setText((width / ratio).toInt().toString()) } } @@ -41,18 +41,18 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba height = size.y } - if (view.keep_aspect_ratio.isChecked) { + if (binding.keepAspectRatio.isChecked) { widthView.setText((height * ratio).toInt().toString()) } } } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.resize_and_save) { alertDialog -> - alertDialog.showKeyboard(view.resize_image_width) + activity.setupDialogStuff(binding.root, this, R.string.resize_and_save) { alertDialog -> + alertDialog.showKeyboard(binding.resizeImageWidth) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val width = getViewValue(widthView) val height = getViewValue(heightView) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeMultipleImagesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeMultipleImagesDialog.kt index 2ace69d41..341968fbc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeMultipleImagesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeMultipleImagesDialog.kt @@ -6,12 +6,10 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogResizeMultipleImagesBinding import com.simplemobiletools.gallery.pro.extensions.ensureWriteAccess import com.simplemobiletools.gallery.pro.extensions.rescanPathsAndUpdateLastModified import com.simplemobiletools.gallery.pro.extensions.resizeImage -import kotlinx.android.synthetic.main.dialog_resize_multiple_images.view.resize_factor_edit_text -import kotlinx.android.synthetic.main.dialog_resize_multiple_images.view.resize_factor_input_layout -import kotlinx.android.synthetic.main.dialog_resize_multiple_images.view.resize_progress import java.io.File import kotlin.math.roundToInt @@ -25,9 +23,9 @@ class ResizeMultipleImagesDialog( ) { private var dialog: AlertDialog? = null - private val view = activity.layoutInflater.inflate(R.layout.dialog_resize_multiple_images, null) - private val progressView = view.resize_progress - private val resizeFactorEditText = view.resize_factor_edit_text + private val binding = DialogResizeMultipleImagesBinding.inflate(activity.layoutInflater) + private val progressView = binding.resizeProgress + private val resizeFactorEditText = binding.resizeFactorEditText init { resizeFactorEditText.setText(DEFAULT_RESIZE_FACTOR) @@ -37,10 +35,10 @@ class ResizeMultipleImagesDialog( } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this, R.string.resize_multiple_images) { alertDialog -> + activity.setupDialogStuff(binding.root, this, R.string.resize_multiple_images) { alertDialog -> dialog = alertDialog alertDialog.showKeyboard(resizeFactorEditText) @@ -56,7 +54,7 @@ class ResizeMultipleImagesDialog( val resizeFactor = resizeFactorText.toFloat().div(100) alertDialog.setCanceledOnTouchOutside(false) - arrayOf(view.resize_factor_input_layout, positiveButton, negativeButton).forEach { + arrayOf(binding.resizeFactorInputLayout, positiveButton, negativeButton).forEach { it.isEnabled = false it.alpha = 0.6f } @@ -97,7 +95,7 @@ class ResizeMultipleImagesDialog( } } } catch (e: OutOfMemoryError) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) } catch (e: Exception) { showErrorToast(e) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt index 610082978..ce402bcb7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ResizeWithPathDialog.kt @@ -8,13 +8,13 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogResizeImageWithPathBinding import com.simplemobiletools.gallery.pro.extensions.config -import kotlinx.android.synthetic.main.dialog_resize_image_with_path.view.* class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, val path: String, val callback: (newSize: Point, newPath: String) -> Unit) { init { var realPath = path.getParentPath() - val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image_with_path, null).apply { + val binding = DialogResizeImageWithPathBinding.inflate(activity.layoutInflater).apply { folder.setText("${activity.humanizePath(realPath).trimEnd('/')}/") val fullName = path.getFilenameFromPath() @@ -24,10 +24,10 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va if (dotAt > 0) { name = fullName.substring(0, dotAt) val extension = fullName.substring(dotAt + 1) - extension_value.setText(extension) + extensionValue.setText(extension) } - filename_value.setText(name) + filenameValue.setText(name) folder.setOnClickListener { FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) { folder.setText(activity.humanizePath(it)) @@ -36,8 +36,8 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va } } - val widthView = view.resize_image_width - val heightView = view.resize_image_height + val widthView = binding.resizeImageWidth + val heightView = binding.resizeImageHeight widthView.setText(size.x.toString()) heightView.setText(size.y.toString()) @@ -69,11 +69,11 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> - alertDialog.showKeyboard(view.resize_image_width) + activity.setupDialogStuff(binding.root, this) { alertDialog -> + alertDialog.showKeyboard(binding.resizeImageWidth) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val width = getViewValue(widthView) val height = getViewValue(heightView) @@ -84,27 +84,27 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va val newSize = Point(getViewValue(widthView), getViewValue(heightView)) - val filename = view.filename_value.value - val extension = view.extension_value.value + val filename = binding.filenameValue.value + val extension = binding.extensionValue.value if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) + activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty) return@setOnClickListener } if (extension.isEmpty()) { - activity.toast(R.string.extension_cannot_be_empty) + activity.toast(com.simplemobiletools.commons.R.string.extension_cannot_be_empty) return@setOnClickListener } val newFilename = "$filename.$extension" val newPath = "${realPath.trimEnd('/')}/$newFilename" if (!newFilename.isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) + activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters) return@setOnClickListener } if (activity.getDoesFilePathExist(newPath)) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) + val title = String.format(activity.getString(com.simplemobiletools.commons.R.string.file_already_exists_overwrite), newFilename) ConfirmationDialog(activity, title) { callback(newSize, newPath) alertDialog.dismiss() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt index 77881b179..ccd170e95 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt @@ -6,8 +6,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.isRPlus -import com.simplemobiletools.gallery.pro.R -import kotlinx.android.synthetic.main.dialog_save_as.view.* +import com.simplemobiletools.gallery.pro.databinding.DialogSaveAsBinding import java.io.File class SaveAsDialog( @@ -20,8 +19,8 @@ class SaveAsDialog( realPath = activity.getPicturesDirectoryPath(realPath) } - val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply { - folder_value.setText("${activity.humanizePath(realPath).trimEnd('/')}/") + val binding = DialogSaveAsBinding.inflate(activity.layoutInflater).apply { + folderValue.setText("${activity.humanizePath(realPath).trimEnd('/')}/") val fullName = path.getFilenameFromPath() val dotAt = fullName.lastIndexOf(".") @@ -30,53 +29,53 @@ class SaveAsDialog( if (dotAt > 0) { name = fullName.substring(0, dotAt) val extension = fullName.substring(dotAt + 1) - extension_value.setText(extension) + extensionValue.setText(extension) } if (appendFilename) { name += "_1" } - filename_value.setText(name) - folder_value.setOnClickListener { - activity.hideKeyboard(folder_value) + filenameValue.setText(name) + folderValue.setOnClickListener { + activity.hideKeyboard(folderValue) FilePickerDialog(activity, realPath, false, false, true, true) { - folder_value.setText(activity.humanizePath(it)) + folderValue.setText(activity.humanizePath(it)) realPath = it } } } activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() } + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel) { dialog, which -> cancelCallback?.invoke() } .setOnCancelListener { cancelCallback?.invoke() } .apply { - activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog -> - alertDialog.showKeyboard(view.filename_value) + activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.save_as) { alertDialog -> + alertDialog.showKeyboard(binding.filenameValue) alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { - val filename = view.filename_value.value - val extension = view.extension_value.value + val filename = binding.filenameValue.value + val extension = binding.extensionValue.value if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) + activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty) return@setOnClickListener } if (extension.isEmpty()) { - activity.toast(R.string.extension_cannot_be_empty) + activity.toast(com.simplemobiletools.commons.R.string.extension_cannot_be_empty) return@setOnClickListener } val newFilename = "$filename.$extension" val newPath = "${realPath.trimEnd('/')}/$newFilename" if (!newFilename.isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) + activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters) return@setOnClickListener } if (activity.getDoesFilePathExist(newPath)) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) + val title = String.format(activity.getString(com.simplemobiletools.commons.R.string.file_already_exists_overwrite), newFilename) ConfirmationDialog(activity, title) { if ((isRPlus() && !isExternalStorageManager())) { val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity)) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt index 6468bf282..648ea26e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SlideshowDialog.kt @@ -1,6 +1,5 @@ package com.simplemobiletools.gallery.pro.dialogs -import android.view.View import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.dialogs.RadioGroupDialog @@ -10,29 +9,29 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.databinding.DialogSlideshowBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_FADE import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_NONE import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_SLIDE import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_DEFAULT_INTERVAL -import kotlinx.android.synthetic.main.dialog_slideshow.view.* class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) { - private val view: View + private val binding: DialogSlideshowBinding init { - view = activity.layoutInflater.inflate(R.layout.dialog_slideshow, null).apply { - interval_hint.hint = activity.getString(R.string.seconds_raw).replaceFirstChar { it.uppercaseChar() } - interval_value.setOnClickListener { - interval_value.selectAll() + binding = DialogSlideshowBinding.inflate(activity.layoutInflater).apply { + intervalHint.hint = activity.getString(com.simplemobiletools.commons.R.string.seconds_raw).replaceFirstChar { it.uppercaseChar() } + intervalValue.setOnClickListener { + intervalValue.selectAll() } - interval_value.setOnFocusChangeListener { v, hasFocus -> + intervalValue.setOnFocusChangeListener { v, hasFocus -> if (!hasFocus) activity.hideKeyboard(v) } - animation_holder.setOnClickListener { + animationHolder.setOnClickListener { val items = arrayListOf( RadioItem(SLIDESHOW_ANIMATION_NONE, activity.getString(R.string.no_animation)), RadioItem(SLIDESHOW_ANIMATION_SLIDE, activity.getString(R.string.slide)), @@ -41,42 +40,42 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit RadioGroupDialog(activity, items, activity.config.slideshowAnimation) { activity.config.slideshowAnimation = it as Int - animation_value.text = getAnimationText() + animationValue.text = getAnimationText() } } - include_videos_holder.setOnClickListener { - interval_value.clearFocus() - include_videos.toggle() + includeVideosHolder.setOnClickListener { + intervalValue.clearFocus() + includeVideos.toggle() } - include_gifs_holder.setOnClickListener { - interval_value.clearFocus() - include_gifs.toggle() + includeGifsHolder.setOnClickListener { + intervalValue.clearFocus() + includeGifs.toggle() } - random_order_holder.setOnClickListener { - interval_value.clearFocus() - random_order.toggle() + randomOrderHolder.setOnClickListener { + intervalValue.clearFocus() + randomOrder.toggle() } - move_backwards_holder.setOnClickListener { - interval_value.clearFocus() - move_backwards.toggle() + moveBackwardsHolder.setOnClickListener { + intervalValue.clearFocus() + moveBackwards.toggle() } - loop_slideshow_holder.setOnClickListener { - interval_value.clearFocus() - loop_slideshow.toggle() + loopSlideshowHolder.setOnClickListener { + intervalValue.clearFocus() + loopSlideshow.toggle() } } setupValues() activity.getAlertDialogBuilder() - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel, null) + .setPositiveButton(com.simplemobiletools.commons.R.string.ok, null) + .setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null) .apply { - activity.setupDialogStuff(view, this) { alertDialog -> + activity.setupDialogStuff(binding.root, this) { alertDialog -> alertDialog.hideKeyboard() alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { storeValues() @@ -89,30 +88,30 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit private fun setupValues() { val config = activity.config - view.apply { - interval_value.setText(config.slideshowInterval.toString()) - animation_value.text = getAnimationText() - include_videos.isChecked = config.slideshowIncludeVideos - include_gifs.isChecked = config.slideshowIncludeGIFs - random_order.isChecked = config.slideshowRandomOrder - move_backwards.isChecked = config.slideshowMoveBackwards - loop_slideshow.isChecked = config.loopSlideshow + binding.apply { + intervalValue.setText(config.slideshowInterval.toString()) + animationValue.text = getAnimationText() + includeVideos.isChecked = config.slideshowIncludeVideos + includeGifs.isChecked = config.slideshowIncludeGIFs + randomOrder.isChecked = config.slideshowRandomOrder + moveBackwards.isChecked = config.slideshowMoveBackwards + loopSlideshow.isChecked = config.loopSlideshow } } private fun storeValues() { - var interval = view.interval_value.text.toString() + var interval = binding.intervalValue.text.toString() if (interval.trim('0').isEmpty()) interval = SLIDESHOW_DEFAULT_INTERVAL.toString() activity.config.apply { - slideshowAnimation = getAnimationValue(view.animation_value.value) + slideshowAnimation = getAnimationValue(binding.animationValue.value) slideshowInterval = interval.toInt() - slideshowIncludeVideos = view.include_videos.isChecked - slideshowIncludeGIFs = view.include_gifs.isChecked - slideshowRandomOrder = view.random_order.isChecked - slideshowMoveBackwards = view.move_backwards.isChecked - loopSlideshow = view.loop_slideshow.isChecked + slideshowIncludeVideos = binding.includeVideos.isChecked + slideshowIncludeGIFs = binding.includeGifs.isChecked + slideshowRandomOrder = binding.randomOrder.isChecked + slideshowMoveBackwards = binding.moveBackwards.isChecked + loopSlideshow = binding.loopSlideshow.isChecked } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 3abaa9132..e0e129c38 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -99,7 +99,7 @@ fun SimpleActivity.launchAbout() { FAQItem(R.string.faq_7_title, R.string.faq_7_text), FAQItem(R.string.faq_14_title, R.string.faq_14_text), FAQItem(R.string.faq_1_title, R.string.faq_1_text), - FAQItem(R.string.faq_5_title_commons, R.string.faq_5_text_commons), + FAQItem(com.simplemobiletools.commons.R.string.faq_5_title_commons, com.simplemobiletools.commons.R.string.faq_5_text_commons), FAQItem(R.string.faq_5_title, R.string.faq_5_text), FAQItem(R.string.faq_4_title, R.string.faq_4_text), FAQItem(R.string.faq_6_title, R.string.faq_6_text), @@ -110,14 +110,14 @@ fun SimpleActivity.launchAbout() { FAQItem(R.string.faq_15_title, R.string.faq_15_text), FAQItem(R.string.faq_2_title, R.string.faq_2_text), FAQItem(R.string.faq_18_title, R.string.faq_18_text), - FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons), + FAQItem(com.simplemobiletools.commons.R.string.faq_9_title_commons, com.simplemobiletools.commons.R.string.faq_9_text_commons), ) - if (!resources.getBoolean(R.bool.hide_google_relations)) { - faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons)) - faqItems.add(FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons)) - faqItems.add(FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons)) - faqItems.add(FAQItem(R.string.faq_10_title_commons, R.string.faq_10_text_commons)) + if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) { + faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.commons.R.string.faq_2_text_commons)) + faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.commons.R.string.faq_6_text_commons)) + faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_7_title_commons, com.simplemobiletools.commons.R.string.faq_7_text_commons)) + faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_10_title_commons, com.simplemobiletools.commons.R.string.faq_10_text_commons)) } if (isRPlus() && !isExternalStorageManager()) { @@ -138,7 +138,7 @@ fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { if (Environment.isExternalStorageManager()) { callback() } else { - var messagePrompt = getString(R.string.access_storage_prompt) + var messagePrompt = getString(com.simplemobiletools.commons.R.string.access_storage_prompt) messagePrompt += if (isSPlus()) { "\n\n${getString(R.string.media_management_alternative)}" } else { @@ -214,7 +214,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) { addNoMediaIntoMediaStore(file.absolutePath) callback() } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) callback() } } @@ -225,7 +225,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) { addNoMediaIntoMediaStore(file.absolutePath) } } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } catch (e: Exception) { showErrorToast(e) @@ -296,7 +296,7 @@ fun BaseSimpleActivity.toggleFileVisibility(oldPath: String, hide: Boolean, call fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList, isCopyOperation: Boolean, callback: (destinationPath: String) -> Unit) { if (fileDirItems.isEmpty()) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return } @@ -477,10 +477,10 @@ fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) { recycleBin.deleteRecursively() mediaDB.clearRecycleBin() directoryDB.deleteRecycleBin() - toast(R.string.recycle_bin_emptied) + toast(com.simplemobiletools.commons.R.string.recycle_bin_emptied) callback?.invoke() } catch (e: Exception) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } } @@ -495,7 +495,13 @@ fun BaseSimpleActivity.emptyAndDisableTheRecycleBin(callback: () -> Unit) { } fun BaseSimpleActivity.showRecycleBinEmptyingDialog(callback: () -> Unit) { - ConfirmationDialog(this, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) { + ConfirmationDialog( + this, + "", + com.simplemobiletools.commons.R.string.empty_recycle_bin_confirmation, + com.simplemobiletools.commons.R.string.yes, + com.simplemobiletools.commons.R.string.no + ) { callback() } } @@ -611,7 +617,7 @@ fun AppCompatActivity.fixDateTaken( runOnUiThread { if (showToasts) { - toast(if (didUpdateFile) R.string.dates_fixed_successfully else R.string.unknown_error_occurred) + toast(if (didUpdateFile) R.string.dates_fixed_successfully else com.simplemobiletools.commons.R.string.unknown_error_occurred) } callback?.invoke() @@ -647,7 +653,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String, getFileOutputStream(tmpFileDirItem) { if (it == null) { if (showToasts) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } return@getFileOutputStream } @@ -672,7 +678,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String, } } catch (e: OutOfMemoryError) { if (showToasts) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) } } catch (e: Exception) { if (showToasts) { @@ -692,7 +698,7 @@ fun Activity.tryRotateByExif(path: String, degrees: Int, showToasts: Boolean, ca fileRotatedSuccessfully(path, oldLastModified) callback.invoke() if (showToasts) { - toast(R.string.file_saved) + toast(com.simplemobiletools.commons.R.string.file_saved) } true } else { @@ -801,7 +807,7 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un try { resizeImage(path, newPath, newSize) { success -> if (success) { - toast(R.string.file_saved) + toast(com.simplemobiletools.commons.R.string.file_saved) val paths = arrayListOf(file.absolutePath) rescanPathsAndUpdateLastModified(paths, pathLastModifiedMap) { @@ -814,7 +820,7 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un } } } catch (e: OutOfMemoryError) { - toast(R.string.out_of_memory_error) + toast(com.simplemobiletools.commons.R.string.out_of_memory_error) } catch (e: Exception) { showErrorToast(e) } @@ -882,7 +888,7 @@ fun Activity.getShortcutImage(tmb: String, drawable: Drawable, callback: () -> U .diskCacheStrategy(DiskCacheStrategy.NONE) .fitCenter() - val size = resources.getDimension(R.dimen.shortcut_size).toInt() + val size = resources.getDimension(com.simplemobiletools.commons.R.dimen.shortcut_size).toInt() val builder = Glide.with(this) .asDrawable() .load(tmb) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 9de742572..031917600 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -449,11 +449,11 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: fun Context.getFolderNameFromPath(path: String): String { return when (path) { - internalStoragePath -> getString(R.string.internal) - sdCardPath -> getString(R.string.sd_card) - otgPath -> getString(R.string.usb) - FAVORITES -> getString(R.string.favorites) - RECYCLE_BIN -> getString(R.string.recycle_bin) + internalStoragePath -> getString(com.simplemobiletools.commons.R.string.internal) + sdCardPath -> getString(com.simplemobiletools.commons.R.string.sd_card) + otgPath -> getString(com.simplemobiletools.commons.R.string.usb) + FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites) + RECYCLE_BIN -> getString(com.simplemobiletools.commons.R.string.recycle_bin) else -> path.getFilenameFromPath() } } @@ -550,7 +550,8 @@ fun Context.loadPng( }) if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big + val cornerSize = + if (roundCorners == ROUNDED_CORNERS_SMALL) com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small else com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) } @@ -580,7 +581,8 @@ fun Context.loadJpg( .transition(BitmapTransitionOptions.withCrossFade()) if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big + val cornerSize = + if (roundCorners == ROUNDED_CORNERS_SMALL) com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small else com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) } @@ -609,7 +611,8 @@ fun Context.loadStaticGIF( .apply(options) if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big + val cornerSize = + if (roundCorners == ROUNDED_CORNERS_SMALL) com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small else com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) } @@ -629,7 +632,8 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo .transition(DrawableTransitionOptions.withCrossFade()) if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big + val cornerSize = + if (roundCorners == ROUNDED_CORNERS_SMALL) com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small else com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) } @@ -654,7 +658,8 @@ fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThu } if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = if (roundCorners == ROUNDED_CORNERS_SMALL) R.dimen.rounded_corner_radius_small else R.dimen.rounded_corner_radius_big + val cornerSize = + if (roundCorners == ROUNDED_CORNERS_SMALL) com.simplemobiletools.commons.R.dimen.rounded_corner_radius_small else com.simplemobiletools.commons.R.dimen.rounded_corner_radius_big val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(PicassoRoundedCornersTransformation(cornerRadius.toFloat())) } @@ -893,7 +898,7 @@ fun Context.updateFavorite(path: String, isFavorite: Boolean) { favoritesDB.deleteFavoritePath(path) } } catch (e: Exception) { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt index 84da27361..1aa4e12db 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/PhotoFragment.kt @@ -48,6 +48,7 @@ import com.simplemobiletools.gallery.pro.activities.PhotoActivity import com.simplemobiletools.gallery.pro.activities.PhotoVideoActivity import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity import com.simplemobiletools.gallery.pro.adapters.PortraitPhotosAdapter +import com.simplemobiletools.gallery.pro.databinding.PagerPhotoItemBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.saveRotatedImageToFile import com.simplemobiletools.gallery.pro.extensions.sendFakeClick @@ -57,7 +58,6 @@ import com.simplemobiletools.gallery.pro.svg.SvgSoftwareLayerSetter import com.squareup.picasso.Callback import com.squareup.picasso.Picasso import it.sephiroth.android.library.exif2.ExifInterface -import kotlinx.android.synthetic.main.pager_photo_item.view.* import org.apache.sanselan.common.byteSources.ByteSourceInputStream import org.apache.sanselan.formats.jpeg.JpegImageParser import pl.droidsonroids.gif.InputSource @@ -98,6 +98,7 @@ class PhotoFragment : ViewPagerFragment() { private var mStoredExtendedDetails = 0 private lateinit var mView: ViewGroup + private lateinit var binding: PagerPhotoItemBinding private lateinit var mMedium: Medium override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { @@ -105,7 +106,8 @@ class PhotoFragment : ViewPagerFragment() { val activity = requireActivity() val arguments = requireArguments() - mView = (inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup) + binding = PagerPhotoItemBinding.inflate(inflater, container, false) + mView = binding.root if (!arguments.getBoolean(SHOULD_INIT_FRAGMENT, true)) { return mView } @@ -113,50 +115,50 @@ class PhotoFragment : ViewPagerFragment() { mMedium = arguments.getSerializable(MEDIUM) as Medium mOriginalPath = mMedium.path - mView.apply { - subsampling_view.setOnClickListener { photoClicked() } - gestures_view.setOnClickListener { photoClicked() } - gif_view.setOnClickListener { photoClicked() } - instant_prev_item.setOnClickListener { listener?.goToPrevItem() } - instant_next_item.setOnClickListener { listener?.goToNextItem() } - panorama_outline.setOnClickListener { openPanorama() } + binding.apply { + subsamplingView.setOnClickListener { photoClicked() } + gesturesView.setOnClickListener { photoClicked() } + gifView.setOnClickListener { photoClicked() } + instantPrevItem.setOnClickListener { listener?.goToPrevItem() } + instantNextItem.setOnClickListener { listener?.goToNextItem() } + panoramaOutline.setOnClickListener { openPanorama() } - instant_prev_item.parentView = container - instant_next_item.parentView = container + instantPrevItem.parentView = container + instantNextItem.parentView = container - photo_brightness_controller.initialize(activity, slide_info, true, container, singleTap = { x, y -> + photoBrightnessController.initialize(activity, slideInfo, true, container, singleTap = { x, y -> mView.apply { - if (subsampling_view.isVisible()) { - subsampling_view.sendFakeClick(x, y) + if (subsamplingView.isVisible()) { + subsamplingView.sendFakeClick(x, y) } else { - gestures_view.sendFakeClick(x, y) + gesturesView.sendFakeClick(x, y) } } }) if (context.config.allowDownGesture) { - gif_view.setOnTouchListener { v, event -> - if (gif_view_frame.controller.state.zoom == 1f) { + gifView.setOnTouchListener { v, event -> + if (gifViewFrame.controller.state.zoom == 1f) { handleEvent(event) } false } - gestures_view.controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener { + gesturesView.controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener { override fun onStateChanged(state: State) { mCurrentGestureViewZoom = state.zoom } }) - gestures_view.setOnTouchListener { v, event -> + gesturesView.setOnTouchListener { v, event -> if (mCurrentGestureViewZoom == 1f) { handleEvent(event) } false } - subsampling_view.setOnTouchListener { v, event -> - if (subsampling_view.isZoomedOut()) { + subsamplingView.setOnTouchListener { v, event -> + if (subsamplingView.isZoomedOut()) { handleEvent(event) } false @@ -195,7 +197,7 @@ class PhotoFragment : ViewPagerFragment() { rotated.compress(Bitmap.CompressFormat.JPEG, 100, out) mMedium.path = file.absolutePath } catch (e: Exception) { - requireActivity().toast(R.string.unknown_error_occurred) + requireActivity().toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) return mView } finally { out?.close() @@ -231,13 +233,13 @@ class PhotoFragment : ViewPagerFragment() { if (mWasInit) { if (config.allowZoomingImages != mStoredAllowDeepZoomableImages || config.showHighestQuality != mStoredShowHighestQuality) { mIsSubsamplingVisible = false - mView.subsampling_view.beGone() + binding.subsamplingView.beGone() loadImage() } else if (mMedium.isGIF()) { loadGif() } else if (mIsSubsamplingVisible && mShouldResetImage) { - mView.subsampling_view.onGlobalLayout { - mView.subsampling_view.resetView() + binding.subsamplingView.onGlobalLayout { + binding.subsamplingView.resetView() } } mShouldResetImage = false @@ -246,10 +248,10 @@ class PhotoFragment : ViewPagerFragment() { val allowPhotoGestures = config.allowPhotoGestures val allowInstantChange = config.allowInstantChange - mView.apply { - photo_brightness_controller.beVisibleIf(allowPhotoGestures) - instant_prev_item.beVisibleIf(allowInstantChange) - instant_next_item.beVisibleIf(allowInstantChange) + binding.apply { + photoBrightnessController.beVisibleIf(allowPhotoGestures) + instantPrevItem.beVisibleIf(allowInstantChange) + instantNextItem.beVisibleIf(allowInstantChange) } storeStateVariables() @@ -258,11 +260,11 @@ class PhotoFragment : ViewPagerFragment() { override fun onDestroyView() { super.onDestroyView() if (activity?.isDestroyed == false) { - mView.subsampling_view.recycle() + binding.subsamplingView.recycle() try { if (context != null) { - Glide.with(requireContext()).clear(mView.gestures_view) + Glide.with(requireContext()).clear(binding.gesturesView) } } catch (ignored: Exception) { } @@ -289,7 +291,7 @@ class PhotoFragment : ViewPagerFragment() { if (activity != null) { measureScreen() Handler().postDelayed({ - mView.gif_view_frame.controller.resetState() + binding.gifViewFrame.controller.resetState() loadGif() }, 50) } @@ -393,11 +395,11 @@ class PhotoFragment : ViewPagerFragment() { InputSource.FileSource(pathToLoad) } - mView.apply { - gestures_view.beGone() - gif_view_frame.beVisible() + binding.apply { + gesturesView.beGone() + gifViewFrame.beVisible() ensureBackgroundThread { - gif_view.setInputSource(source) + gifView.setInputSource(source) } } } catch (e: Exception) { @@ -413,14 +415,14 @@ class PhotoFragment : ViewPagerFragment() { .`as`(PictureDrawable::class.java) .listener(SvgSoftwareLayerSetter()) .load(mMedium.path) - .into(mView.gestures_view) + .into(binding.gesturesView) } } private fun loadAPNG() { if (context != null) { val drawable = APNGDrawable.fromFile(mMedium.path) - mView.gestures_view.setImageDrawable(drawable) + binding.gesturesView.setImageDrawable(drawable) } } @@ -436,7 +438,7 @@ class PhotoFragment : ViewPagerFragment() { loadWithGlide(path, addZoomableView) } else { drawable.setLoopLimit(0) - mView.gestures_view.setImageDrawable(drawable) + binding.gesturesView.setImageDrawable(drawable) } } else { loadWithGlide(path, addZoomableView) @@ -476,13 +478,13 @@ class PhotoFragment : ViewPagerFragment() { isFirstResource: Boolean ): Boolean { val allowZoomingImages = context?.config?.allowZoomingImages ?: true - mView.gestures_view.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || allowZoomingImages == false + binding.gesturesView.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || allowZoomingImages == false if (mIsFragmentVisible && addZoomableView) { scheduleZoomableView() } return false } - }).into(mView.gestures_view) + }).into(binding.gesturesView) } private fun tryLoadingWithPicasso(addZoomableView: Boolean) { @@ -502,9 +504,9 @@ class PhotoFragment : ViewPagerFragment() { degreesForRotation(mImageOrientation).toFloat() } - picasso.into(mView.gestures_view, object : Callback { + picasso.into(binding.gesturesView, object : Callback { override fun onSuccess() { - mView.gestures_view.controller.settings.isZoomEnabled = + binding.gesturesView.controller.settings.isZoomEnabled = mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false if (mIsFragmentVisible && addZoomableView) { scheduleZoomableView() @@ -527,7 +529,9 @@ class PhotoFragment : ViewPagerFragment() { val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList if (files != null) { val screenWidth = requireContext().realScreenSize.x - val itemWidth = resources.getDimension(R.dimen.portrait_photos_stripe_height).toInt() + resources.getDimension(R.dimen.one_dp).toInt() + val itemWidth = + resources.getDimension(R.dimen.portrait_photos_stripe_height).toInt() + resources.getDimension(com.simplemobiletools.commons.R.dimen.one_dp) + .toInt() val sideWidth = screenWidth / 2 - itemWidth / 2 val fakeItemsCnt = ceil(sideWidth / itemWidth.toDouble()).toInt() @@ -543,7 +547,7 @@ class PhotoFragment : ViewPagerFragment() { return@PortraitPhotosAdapter } - mView.photo_portrait_stripe.smoothScrollBy((x + itemWidth / 2) - screenWidth / 2, 0) + binding.photoPortraitStripe.smoothScrollBy((x + itemWidth / 2) - screenWidth / 2, 0) if (paths[position] != mCurrentPortraitPhotoPath) { mCurrentPortraitPhotoPath = paths[position] hideZoomableView() @@ -551,7 +555,7 @@ class PhotoFragment : ViewPagerFragment() { } } - mView.photo_portrait_stripe.adapter = adapter + binding.photoPortraitStripe.adapter = adapter setupStripeBottomMargin() val coverIndex = getCoverImageIndex(paths) @@ -559,12 +563,12 @@ class PhotoFragment : ViewPagerFragment() { mCurrentPortraitPhotoPath = paths[coverIndex] setupStripeUpListener(adapter, screenWidth, itemWidth) - mView.photo_portrait_stripe.onGlobalLayout { - mView.photo_portrait_stripe.scrollBy((coverIndex - fakeItemsCnt) * itemWidth, 0) + binding.photoPortraitStripe.onGlobalLayout { + binding.photoPortraitStripe.scrollBy((coverIndex - fakeItemsCnt) * itemWidth, 0) adapter.setCurrentPhoto(coverIndex) - mView.photo_portrait_stripe_wrapper.beVisible() + binding.photoPortraitStripeWrapper.beVisible() if (mIsFullscreen) { - mView.photo_portrait_stripe_wrapper.alpha = 0f + binding.photoPortraitStripeWrapper.alpha = 0f } } } @@ -588,11 +592,11 @@ class PhotoFragment : ViewPagerFragment() { } private fun setupStripeBottomMargin() { - var bottomMargin = requireContext().navigationBarHeight + resources.getDimension(R.dimen.normal_margin).toInt() + var bottomMargin = requireContext().navigationBarHeight + resources.getDimension(com.simplemobiletools.commons.R.dimen.normal_margin).toInt() if (requireContext().config.bottomActions) { bottomMargin += resources.getDimension(R.dimen.bottom_actions_height).toInt() } - (mView.photo_portrait_stripe_wrapper.layoutParams as RelativeLayout.LayoutParams).bottomMargin = bottomMargin + (binding.photoPortraitStripeWrapper.layoutParams as RelativeLayout.LayoutParams).bottomMargin = bottomMargin } private fun getCoverImageIndex(paths: ArrayList): Int { @@ -614,7 +618,7 @@ class PhotoFragment : ViewPagerFragment() { } private fun setupStripeUpListener(adapter: PortraitPhotosAdapter, screenWidth: Int, itemWidth: Int) { - mView.photo_portrait_stripe.setOnTouchListener { v, event -> + binding.photoPortraitStripe.setOnTouchListener { v, event -> if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) { var closestIndex = -1 var closestDistance = Integer.MAX_VALUE @@ -673,7 +677,7 @@ class PhotoFragment : ViewPagerFragment() { newOrientation += 360 } - mView.subsampling_view.apply { + binding.subsamplingView.apply { setMaxTileSize(if (showHighestQuality) Integer.MAX_VALUE else 4096) setMinimumTileDpi(minTileDpi) background = ColorDrawable(Color.TRANSPARENT) @@ -702,7 +706,7 @@ class PhotoFragment : ViewPagerFragment() { } override fun onImageLoadError(e: Exception) { - mView.gestures_view.controller.settings.isZoomEnabled = true + binding.gesturesView.controller.settings.isZoomEnabled = true background = ColorDrawable(Color.TRANSPARENT) mIsSubsamplingVisible = false beGone() @@ -760,9 +764,9 @@ class PhotoFragment : ViewPagerFragment() { } activity?.runOnUiThread { - mView.panorama_outline?.beVisibleIf(mIsPanorama) + binding.panoramaOutline.beVisibleIf(mIsPanorama) if (mIsFullscreen) { - mView.panorama_outline?.alpha = 0f + binding.panoramaOutline.alpha = 0f } } } @@ -818,7 +822,7 @@ class PhotoFragment : ViewPagerFragment() { fun rotateImageViewBy(degrees: Int) { if (mIsSubsamplingVisible) { - mView.subsampling_view.rotateBy(degrees) + binding.subsamplingView.rotateBy(degrees) } else { mCurrentRotationDegrees = (mCurrentRotationDegrees + degrees) % 360 mLoadZoomableViewHandler.removeCallbacksAndMessages(null) @@ -829,7 +833,7 @@ class PhotoFragment : ViewPagerFragment() { private fun initExtendedDetails() { if (requireContext().config.showExtendedDetails) { - mView.photo_details.apply { + binding.photoDetails.apply { beInvisible() // make it invisible so we can measure it, but not show yet text = getMediumExtendedDetails(mMedium) onGlobalLayout { @@ -844,15 +848,15 @@ class PhotoFragment : ViewPagerFragment() { } } } else { - mView.photo_details.beGone() + binding.photoDetails.beGone() } } private fun hideZoomableView() { if (context?.config?.allowZoomingImages == true) { mIsSubsamplingVisible = false - mView.subsampling_view.recycle() - mView.subsampling_view.beGone() + binding.subsamplingView.recycle() + binding.subsamplingView.beGone() mLoadZoomableViewHandler.removeCallbacksAndMessages(null) } } @@ -862,14 +866,14 @@ class PhotoFragment : ViewPagerFragment() { } private fun updateInstantSwitchWidths() { - mView.instant_prev_item.layoutParams.width = mScreenWidth / 7 - mView.instant_next_item.layoutParams.width = mScreenWidth / 7 + binding.instantPrevItem.layoutParams.width = mScreenWidth / 7 + binding.instantNextItem.layoutParams.width = mScreenWidth / 7 } override fun fullscreenToggled(isFullscreen: Boolean) { this.mIsFullscreen = isFullscreen - mView.apply { - photo_details.apply { + binding.apply { + photoDetails.apply { if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) { animate().y(getExtendedDetailsY(height)) @@ -880,18 +884,18 @@ class PhotoFragment : ViewPagerFragment() { } if (mIsPanorama) { - panorama_outline.animate().alpha(if (isFullscreen) 0f else 1f).start() - panorama_outline.isClickable = !isFullscreen + panoramaOutline.animate().alpha(if (isFullscreen) 0f else 1f).start() + panoramaOutline.isClickable = !isFullscreen } if (mWasInit && mMedium.isPortrait()) { - photo_portrait_stripe_wrapper.animate().alpha(if (isFullscreen) 0f else 1f).start() + photoPortraitStripeWrapper.animate().alpha(if (isFullscreen) 0f else 1f).start() } } } private fun getExtendedDetailsY(height: Int): Float { - val smallMargin = context?.resources?.getDimension(R.dimen.small_margin) ?: return 0f + val smallMargin = context?.resources?.getDimension(com.simplemobiletools.commons.R.dimen.small_margin) ?: return 0f val fullscreenOffset = smallMargin + if (mIsFullscreen) 0 else requireContext().navigationBarHeight val actionsHeight = if (requireContext().config.bottomActions && !mIsFullscreen) resources.getDimension(R.dimen.bottom_actions_height) else 0f return requireContext().realScreenSize.y - height - actionsHeight - fullscreenOffset diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index a6baa9369..1464938b6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -15,7 +15,6 @@ import android.widget.SeekBar import android.widget.TextView import androidx.media3.common.* import androidx.media3.common.util.UnstableApi -import com.bumptech.glide.Glide import androidx.media3.datasource.ContentDataSource import androidx.media3.datasource.DataSource import androidx.media3.datasource.DataSpec @@ -25,23 +24,24 @@ import androidx.media3.exoplayer.SeekParameters import androidx.media3.exoplayer.source.DefaultMediaSourceFactory import androidx.media3.exoplayer.source.MediaSource import androidx.media3.exoplayer.source.ProgressiveMediaSource +import com.bumptech.glide.Glide import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.PanoramaVideoActivity import com.simplemobiletools.gallery.pro.activities.VideoActivity +import com.simplemobiletools.gallery.pro.databinding.PagerVideoItemBinding import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.hasNavBar import com.simplemobiletools.gallery.pro.extensions.parseFileChannel import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.views.MediaSideScroll -import kotlinx.android.synthetic.main.bottom_video_time_holder.view.* -import kotlinx.android.synthetic.main.pager_video_item.view.* import java.io.File import java.io.FileInputStream -@UnstableApi class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener { +@UnstableApi +class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener { private val PROGRESS = "progress" private var mIsFullscreen = false @@ -73,6 +73,7 @@ import java.io.FileInputStream private lateinit var mTimeHolder: View private lateinit var mBrightnessSideScroll: MediaSideScroll private lateinit var mVolumeSideScroll: MediaSideScroll + private lateinit var binding: PagerVideoItemBinding private lateinit var mView: View private lateinit var mMedium: Medium private lateinit var mConfig: Config @@ -88,15 +89,15 @@ import java.io.FileInputStream mMedium = arguments.getSerializable(MEDIUM) as Medium mConfig = context.config - mView = inflater.inflate(R.layout.pager_video_item, container, false).apply { - panorama_outline.setOnClickListener { openPanorama() } - video_curr_time.setOnClickListener { skip(false) } - video_duration.setOnClickListener { skip(true) } - video_holder.setOnClickListener { toggleFullscreen() } - video_preview.setOnClickListener { toggleFullscreen() } - video_surface_frame.controller.settings.swallowDoubleTaps = true + binding = PagerVideoItemBinding.inflate(inflater, container, false).apply { + panoramaOutline.setOnClickListener { openPanorama() } + bottomVideoTimeHolder.videoCurrTime.setOnClickListener { skip(false) } + bottomVideoTimeHolder.videoDuration.setOnClickListener { skip(true) } + videoHolder.setOnClickListener { toggleFullscreen() } + videoPreview.setOnClickListener { toggleFullscreen() } + videoSurfaceFrame.controller.settings.swallowDoubleTaps = true - video_play_outline.setOnClickListener { + videoPlayOutline.setOnClickListener { if (mConfig.openVideosOnSeparateScreen) { launchVideoPlayer() } else { @@ -104,21 +105,21 @@ import java.io.FileInputStream } } - mPlayPauseButton = video_toggle_play_pause + mPlayPauseButton = bottomVideoTimeHolder.videoTogglePlayPause mPlayPauseButton.setOnClickListener { togglePlayPause() } - mSeekBar = video_seekbar + mSeekBar = bottomVideoTimeHolder.videoSeekbar mSeekBar.setOnSeekBarChangeListener(this@VideoFragment) // adding an empty click listener just to avoid ripple animation at toggling fullscreen mSeekBar.setOnClickListener { } - mTimeHolder = video_time_holder - mCurrTimeView = video_curr_time - mBrightnessSideScroll = video_brightness_controller - mVolumeSideScroll = video_volume_controller - mTextureView = video_surface + mTimeHolder = bottomVideoTimeHolder.videoTimeHolder + mCurrTimeView = bottomVideoTimeHolder.videoCurrTime + mBrightnessSideScroll = videoBrightnessController + mVolumeSideScroll = videoVolumeController + mTextureView = videoSurface mTextureView.surfaceTextureListener = this@VideoFragment val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() { @@ -128,7 +129,7 @@ import java.io.FileInputStream return true } - val viewWidth = width + val viewWidth = root.width val instantWidth = viewWidth / 7 val clickedX = e.rawX when { @@ -145,13 +146,13 @@ import java.io.FileInputStream } }) - video_preview.setOnTouchListener { view, event -> + videoPreview.setOnTouchListener { view, event -> handleEvent(event) false } - video_surface_frame.setOnTouchListener { view, event -> - if (video_surface_frame.controller.state.zoom == 1f) { + videoSurfaceFrame.setOnTouchListener { view, event -> + if (videoSurfaceFrame.controller.state.zoom == 1f) { handleEvent(event) } @@ -159,13 +160,14 @@ import java.io.FileInputStream false } } + mView = binding.root if (!arguments.getBoolean(SHOULD_INIT_FRAGMENT, true)) { return mView } storeStateVariables() - Glide.with(context).load(mMedium.path).into(mView.video_preview) + Glide.with(context).load(mMedium.path).into(binding.videoPreview) // setMenuVisibility is not called at VideoActivity (third party intent) if (!mIsFragmentVisible && activity is VideoActivity) { @@ -184,12 +186,12 @@ import java.io.FileInputStream } if (mIsPanorama) { - mView.apply { - panorama_outline.beVisible() - video_play_outline.beGone() + binding.apply { + panoramaOutline.beVisible() + videoPlayOutline.beGone() mVolumeSideScroll.beGone() mBrightnessSideScroll.beGone() - Glide.with(context).load(mMedium.path).into(video_preview) + Glide.with(context).load(mMedium.path).into(videoPreview) } } @@ -201,8 +203,8 @@ import java.io.FileInputStream mWasFragmentInit = true setVideoSize() - mView.apply { - mBrightnessSideScroll.initialize(activity, slide_info, true, container, singleTap = { x, y -> + binding.apply { + mBrightnessSideScroll.initialize(activity, slideInfo, true, container, singleTap = { x, y -> if (mConfig.allowInstantChange) { listener?.goToPrevItem() } else { @@ -212,7 +214,7 @@ import java.io.FileInputStream doSkip(false) }) - mVolumeSideScroll.initialize(activity, slide_info, false, container, singleTap = { x, y -> + mVolumeSideScroll.initialize(activity, slideInfo, false, container, singleTap = { x, y -> if (mConfig.allowInstantChange) { listener?.goToNextItem() } else { @@ -222,7 +224,7 @@ import java.io.FileInputStream doSkip(true) }) - video_surface.onGlobalLayout { + videoSurface.onGlobalLayout { if (mIsFragmentVisible && mConfig.autoplayVideos && !mConfig.openVideosOnSeparateScreen) { playVideo() } @@ -241,10 +243,10 @@ import java.io.FileInputStream override fun onResume() { super.onResume() mConfig = requireContext().config // make sure we get a new config, in case the user changed something in the app settings - requireActivity().updateTextColors(mView.video_holder) + requireActivity().updateTextColors(binding.videoHolder) val allowVideoGestures = mConfig.allowVideoGestures mTextureView.beGoneIf(mConfig.openVideosOnSeparateScreen || mIsPanorama) - mView.video_surface_frame.beGoneIf(mTextureView.isGone()) + binding.videoSurfaceFrame.beGoneIf(mTextureView.isGone()) mVolumeSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama) mBrightnessSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama) @@ -287,8 +289,8 @@ import java.io.FileInputStream setVideoSize() initTimeHolder() checkExtendedDetails() - mView.video_surface_frame.onGlobalLayout { - mView.video_surface_frame.controller.resetState() + binding.videoSurfaceFrame.onGlobalLayout { + binding.videoSurfaceFrame.controller.resetState() } } @@ -327,7 +329,7 @@ import java.io.FileInputStream private fun setupTimeHolder() { mSeekBar.max = mDuration - mView.video_duration.text = mDuration.getFormattedDuration() + binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration() setupTimer() } @@ -446,7 +448,7 @@ import java.io.FileInputStream private fun checkExtendedDetails() { if (mConfig.showExtendedDetails) { - mView.video_details.apply { + binding.videoDetails.apply { beInvisible() // make it invisible so we can measure it, but not show yet text = getMediumExtendedDetails(mMedium) onGlobalLayout { @@ -461,7 +463,7 @@ import java.io.FileInputStream } } } else { - mView.video_details.beGone() + binding.videoDetails.beGone() } } @@ -511,12 +513,16 @@ import java.io.FileInputStream } mSeekBar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) - arrayOf(mView.video_curr_time, mView.video_duration, mView.video_toggle_play_pause).forEach { + arrayOf( + binding.bottomVideoTimeHolder.videoCurrTime, + binding.bottomVideoTimeHolder.videoDuration, + binding.bottomVideoTimeHolder.videoTogglePlayPause + ).forEach { it.isClickable = !mIsFullscreen } mTimeHolder.animate().alpha(newAlpha).start() - mView.video_details.apply { + binding.videoDetails.apply { if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) { animate().y(getExtendedDetailsY(height)) @@ -528,7 +534,7 @@ import java.io.FileInputStream } private fun getExtendedDetailsY(height: Int): Float { - val smallMargin = context?.resources?.getDimension(R.dimen.small_margin) ?: return 0f + val smallMargin = context?.resources?.getDimension(com.simplemobiletools.commons.R.dimen.small_margin) ?: return 0f val fullscreenOffset = smallMargin + if (mIsFullscreen) 0 else requireContext().navigationBarHeight var actionsHeight = 0f if (!mIsFullscreen) { @@ -629,8 +635,8 @@ import java.io.FileInputStream return } - if (mView.video_preview.isVisible()) { - mView.video_preview.beGone() + if (binding.videoPreview.isVisible()) { + binding.videoPreview.beGone() initExoPlayer() } @@ -645,11 +651,11 @@ import java.io.FileInputStream } if (!wasEnded || !mConfig.loopVideos) { - mPlayPauseButton.setImageResource(R.drawable.ic_pause_outline_vector) + mPlayPauseButton.setImageResource(com.simplemobiletools.commons.R.drawable.ic_pause_outline_vector) } if (!mWasVideoStarted) { - mView.video_play_outline.beGone() + binding.videoPlayOutline.beGone() mPlayPauseButton.beVisible() } @@ -671,7 +677,7 @@ import java.io.FileInputStream mExoPlayer?.playWhenReady = false } - mPlayPauseButton.setImageResource(R.drawable.ic_play_outline_vector) + mPlayPauseButton.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector) activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) mPositionAtPause = mExoPlayer?.currentPosition ?: 0L } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt index 443346832..5c1e9ea4e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt @@ -7,7 +7,6 @@ import android.view.MotionEvent import androidx.exifinterface.media.ExifInterface import androidx.fragment.app.Fragment import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium @@ -139,6 +138,7 @@ abstract class ViewPagerFragment : Fragment() { mTouchDownX = event.rawX mTouchDownY = event.rawY } + MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { val diffX = mTouchDownX - event.rawX @@ -147,7 +147,7 @@ abstract class ViewPagerFragment : Fragment() { val downGestureDuration = System.currentTimeMillis() - mTouchDownTime if (!mIgnoreCloseDown && (Math.abs(diffY) > Math.abs(diffX)) && (diffY < -mCloseDownThreshold) && downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && context?.config?.allowDownGesture == true) { activity?.finish() - activity?.overridePendingTransition(0, R.anim.slide_down) + activity?.overridePendingTransition(0, com.simplemobiletools.commons.R.anim.slide_down) } mIgnoreCloseDown = false } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index f3a96c39a..4546d6039 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -1,9 +1,6 @@ package com.simplemobiletools.gallery.pro.helpers -import com.simplemobiletools.commons.helpers.MONTH_SECONDS -import com.simplemobiletools.commons.helpers.PERMISSION_READ_MEDIA_IMAGES -import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE -import com.simplemobiletools.commons.helpers.isTiramisuPlus +import com.simplemobiletools.commons.helpers.* // shared preferences const val DIRECTORY_SORT_ORDER = "directory_sort_order" @@ -246,3 +243,14 @@ const val FOLDER_STYLE_SQUARE = 1 const val FOLDER_STYLE_ROUNDED_CORNERS = 2 fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE + +fun getPermissionsToRequest(): Collection { + val permissions = mutableListOf(getPermissionToRequest()) + if (isRPlus()) { + permissions.add(PERMISSION_MEDIA_LOCATION) + } + if (isTiramisuPlus()) { + permissions.add(PERMISSION_READ_MEDIA_VIDEO) + } + return permissions +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/FilterThumbnailsManager.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/FilterThumbnailsManager.kt index ae043ddde..d517cf74d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/FilterThumbnailsManager.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/FilterThumbnailsManager.kt @@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.pro.helpers import android.graphics.Bitmap import com.simplemobiletools.gallery.pro.models.FilterItem -import java.util.* class FilterThumbnailsManager { private var filterThumbnails = ArrayList(10) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index 73f63eafd..d17e5f3bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -19,7 +19,8 @@ import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem import com.simplemobiletools.gallery.pro.models.ThumbnailSection import java.io.File -import java.util.* +import java.util.Calendar +import java.util.Locale class MediaFetcher(val context: Context) { var shouldStop = false @@ -777,6 +778,7 @@ class MediaFetcher(val context: Context) { o1.name.normalizeString().toLowerCase().compareTo(o2.name.normalizeString().toLowerCase()) } } + sorting and SORT_BY_PATH != 0 -> { if (sorting and SORT_USE_NUMERIC_VALUE != 0) { AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase()) @@ -784,6 +786,7 @@ class MediaFetcher(val context: Context) { o1.path.toLowerCase().compareTo(o2.path.toLowerCase()) } } + sorting and SORT_BY_SIZE != 0 -> o1.size.compareTo(o2.size) sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified) else -> o1.taken.compareTo(o2.taken) @@ -860,6 +863,7 @@ class MediaFetcher(val context: Context) { today, yesterday ) + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 || grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> formatDate(key, false) grouping and GROUP_BY_FILE_TYPE != 0 -> getFileTypeString(key) grouping and GROUP_BY_EXTENSION != 0 -> key.toUpperCase() @@ -868,7 +872,7 @@ class MediaFetcher(val context: Context) { } if (result.isEmpty()) { - result = context.getString(R.string.unknown) + result = context.getString(com.simplemobiletools.commons.R.string.unknown) } return if (grouping and GROUP_SHOW_FILE_COUNT != 0) { @@ -880,8 +884,8 @@ class MediaFetcher(val context: Context) { private fun getFinalDate(date: String, today: String, yesterday: String): String { return when (date) { - today -> context.getString(R.string.today) - yesterday -> context.getString(R.string.yesterday) + today -> context.getString(com.simplemobiletools.commons.R.string.today) + yesterday -> context.getString(com.simplemobiletools.commons.R.string.yesterday) else -> date } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/DateTaken.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/DateTaken.kt index 98171df7b..be3be7100 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/DateTaken.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/DateTaken.kt @@ -15,4 +15,5 @@ data class DateTaken( @ColumnInfo(name = "parent_path") var parentPath: String, @ColumnInfo(name = "date_taken") var taken: Long, @ColumnInfo(name = "last_fixed") var lastFixed: Int, - @ColumnInfo(name = "last_modified") var lastModified: Long) + @ColumnInfo(name = "last_modified") var lastModified: Long +) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt index 56e9d69fe..e14d97272 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Medium.kt @@ -9,7 +9,8 @@ import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.gallery.pro.helpers.* import java.io.File import java.io.Serializable -import java.util.* +import java.util.Calendar +import java.util.Locale @Entity(tableName = "media", indices = [(Index(value = ["full_path"], unique = true))]) data class Medium( diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/svg/SvgSoftwareLayerSetter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/svg/SvgSoftwareLayerSetter.kt index c766ab651..2d7444eba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/svg/SvgSoftwareLayerSetter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/svg/SvgSoftwareLayerSetter.kt @@ -17,7 +17,13 @@ class SvgSoftwareLayerSetter : RequestListener { return false } - override fun onResourceReady(resource: PictureDrawable, model: Any, target: Target, dataSource: DataSource, isFirstResource: Boolean): Boolean { + override fun onResourceReady( + resource: PictureDrawable, + model: Any, + target: Target, + dataSource: DataSource, + isFirstResource: Boolean + ): Boolean { val view = (target as ImageViewTarget<*>).view view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null) return false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/EditorDrawCanvas.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/EditorDrawCanvas.kt index 2220ef840..9439217bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/EditorDrawCanvas.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/EditorDrawCanvas.kt @@ -65,11 +65,13 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at mStartY = y actionDown(x, y) } + MotionEvent.ACTION_MOVE -> { if (event.pointerCount == 1 && !mWasMultitouch) { actionMove(x, y) } } + MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> actionUp() MotionEvent.ACTION_POINTER_DOWN -> mWasMultitouch = true } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/InstantItemSwitch.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/InstantItemSwitch.kt index 8663b177f..269a66289 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/InstantItemSwitch.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/InstantItemSwitch.kt @@ -40,6 +40,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout( mTouchDownY = event.rawY mTouchDownTime = System.currentTimeMillis() } + MotionEvent.ACTION_UP -> { val diffX = mTouchDownX - event.rawX val diffY = mTouchDownY - event.rawY @@ -47,6 +48,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout( performClick() } } + MotionEvent.ACTION_MOVE -> { if (passTouches) { return false diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/MediaSideScroll.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/MediaSideScroll.kt index 90ed9ee21..ecc251374 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/MediaSideScroll.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/views/MediaSideScroll.kt @@ -99,6 +99,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co mTouchDownValue = getCurrentVolume() } } + MotionEvent.ACTION_MOVE -> { val diffX = mTouchDownX - event.rawX val diffY = mTouchDownY - event.rawY @@ -125,6 +126,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co } mLastTouchY = event.rawY } + MotionEvent.ACTION_UP -> { if (mIsBrightnessScroll) { mTouchDownValue = mTempBrightness diff --git a/app/src/main/res/layout/activity_panorama_video.xml b/app/src/main/res/layout/activity_panorama_video.xml index a9912952b..36926a292 100644 --- a/app/src/main/res/layout/activity_panorama_video.xml +++ b/app/src/main/res/layout/activity_panorama_video.xml @@ -11,7 +11,9 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - + - + - + + - Simple Galerie - Galerie - Modifier - Ouvrir l\'appareil photo - (caché) - (exclu) - Épingler le dossier - Libérer le dossier - Épingler le dossier - Affichage Dossiers - Dossiers - Affichage Galerie - Autre dossier - Afficher sur la carte - Position inconnue - Volume - Luminosité - Verrouiller la rotation - Déverrouiller la rotation - Orientation - Forcer la vue portrait - Forcer la vue paysage - Utiliser l\'orientation par défaut - Corriger les dates de prise de vue - Correction en cours… - Dates corrigées - Aucune date de prise de vue trouvée - Partager une version redimensionnée - Basculer vers la recherche de fichiers - Dossier par défaut - Oublier le dossier - Réordonner par glisser - Réordonner par glisser (Pro) - Restauration vers « %s » - - Filtrer les médias - Images - Vidéos - GIF - Images RAW - SVG - Portraits - Aucun fichier média trouvé avec les filtres sélectionnés. - Modifier les filtres - - Cette option cache le dossier en y ajoutant un fichier .nomedia, elle cachera aussi tous les sous-dossiers. Vous pouvez afficher ces dossiers avec l\'option « Afficher les fichiers cachés » dans les paramètres. Continuer \? - La sélection sera exclue ainsi que ses sous-dossiers dans Simple Galerie uniquement. Vous pouvez gérer les dossiers exclus depuis les paramètres. - Exclure un dossier parent \? - Exclure des dossiers les cachera ainsi que leurs sous-dossiers uniquement dans Simple Galerie, ils seront toujours visibles depuis d\'autres applications. -\n -\nSi vous voulez aussi les cacher ailleurs, utilisez la fonction Cacher. - Dossiers cachés - Gérer les dossiers cachés - Il semblerait que vous n\'ayez pas de dossier caché par un fichier .nomedia. - Vous devez accorder à l\'application l\'accès à tous les fichiers pour voir les fichiers cachés, sinon elle ne peut pas fonctionner. - Si un dossier ou l'un de ses dossiers parents a un point avant son nom, il est caché et ne peut pas être affiché comme ceci. Vous devez supprimer le point en le renommant. - - Dossiers ajoutés - Gérer les dossiers ajoutés - Ajouter un dossier - Si vous avez des dossiers contenant des médias qui ne sont pas affichés dans l\'application, vous pouvez les ajouter manuellement ici. -\n -\nCet ajout n\'exclura aucun autre dossier. - Aucun fichier multimédia n\'a été trouvé. Vous pouvez ajouter manuellement des dossiers contenant des fichiers multimédia. - - Redimensionner la sélection et enregistrer - Largeur - Hauteur - Conserver le rapport d\'affichage - Veuillez entrer une résolution valide - Redimensionner plusieurs images - Facteur de redimensionnement - Redimensionner les images au pourcentage donné, la valeur doit être comprise entre 10 et 90. - Entrer un nombre entre 10 et 90 - - Échec de redimensionnement de %d image - Échec de redimensionnement de %d images - Échec de redimensionnement de %d images - - Les images ont été redimensionnées avec succès - - Éditeur - Éditeur simple - Éditeur avancé - Pivoter - Emplacement d\'image invalide - Emplacement de vidéo invalide - L\'édition de l\'image a échoué - L\'édition de la vidéo a échoué - L\'édition de l\'image a été annulée - L\'édition de la vidéo a été annulée - Le fichier a été édité avec succès - L\'image a été éditée avec succès - La vidéo a été éditée avec succès - Modifier l\'image avec : - Modifier la vidéo avec : - Aucun éditeur d\'image trouvé - Aucun éditeur de vidéo trouvé - Emplacement du fichier inconnu - Impossible de remplacer le fichier source - Pivoter à gauche - Pivoter à droite - Pivoter à 180º - Transformer - Rogner - Dessiner - Retourner - Retourner horizontalement - Retourner verticalement - Libre - - Autre - - - Fond d\'écran simple - Définir comme fond d\'écran - Échec de la définition en tant que fond d\'écran - Définir comme fond d\'écran avec : - Définition du fond d\'écran en cours… - Fond d\'écran défini - Rapport d\'affichage portrait - Rapport d\'affichage paysage - Écran d\'accueil - Écran de déverrouillage - Écran d\'accueil et écran de déverrouillage - Autoriser la modification du rapport d\'aspect - - Diaporama - Intervalle - Inclure les images - Inclure les vidéos - Inclure les GIF - Ordre aléatoire - Défilement inversé - Diaporama en boucle - Animation - Aucune - Fondu - Glissement - Diaporama terminé - Aucun média trouvé pour le diaporama - - Mode sous-dossiers - - Grouper par - Ne pas grouper les fichiers - Dossier - Date de modification - Date de modification (par jour) - Date de modification (par mois) - Date de prise de vue - Date de prise de vue (par jour) - Date de prise de vue (par mois) - Type de fichier - Extension - Afficher le nombre d\'éléments dans les entêtes - Grouper par et Trier par sont deux modes indépendants - - Dossier affiché dans le widget : - Afficher le nom du dossier - - Lecture automatique des vidéos - Mémoriser la position de lecture des vidéos - Lecture en boucle des vidéos - Animer les miniatures des GIF - Luminosité maximale - Recadrer les miniatures en carré - Afficher la durée des vidéos - Orientation de l\'affichage - Paramètres système - Rotation de l\'appareil - Rapport d\'affichage - Arrière-plan et barre d\'état noirs - Défiler les miniatures horizontalement - Masquer automatiquement l\'interface utilisateur - Supprimer les dossiers vides après avoir supprimé leur contenu - Contrôler la luminosité des images par gestes verticaux - Contrôler le volume et la luminosité des vidéos avec des gestes verticaux - Afficher le nombre de fichiers des dossiers - Afficher les informations supplémentaires du média en plein écran - Gérer les informations supplémentaires - Activer les zoom à un doigt sur les images en plein écran - Appuyer sur les cotés de l\'écran pour changer instantanément de média - Activer les options de zoom avancées - Cacher les informations supplémentaires si la barre d\'état est masquée - Afficher les boutons d\'action - Afficher la corbeille en affichage Galerie - Niveau de zoom - Afficher les images dans la meilleure qualité possible - Afficher la corbeille en fin de liste sur l\'écran principal - Fermer la vue plein écran par un geste vers le bas - Permettre un zoom avant 1:1 par double appui - Ouvrir les vidéos dans une application externe - Afficher une encoche si disponible - Pivoter les images par gestes - Priorité de chargement des fichiers - Rapide - Compromis - Éviter l\'affichage de fichiers invalides - Afficher les types d\'image - Zoomer les vidéos par un double appui - Style des miniatures des dossiers - Style des miniatures des fichiers - Marquer les éléments favoris - Espacement des miniatures - Afficher le nombre de fichiers sur une autre ligne - Afficher le nombre de fichiers entre parenthèses - Ne pas afficher le nombre de fichiers - Limiter à une ligne les noms de fichiers - Carré - Arrondi - Exporter les favoris - Importer les favoris - Favoris importés - Pour vous assurer que toutes les opérations de fichiers fonctionnent de manière fiable, veuillez faire de cette application l\'application de gestion des médias dans les paramètres de votre appareil. - Protection par mot de passe de la visibilité des dossiers exclus - Quelque chose s\'est mal passé, veuillez aller dans les paramètres de votre appareil - Applis - Accès aux applications spéciales - Applis de gestion des médias et autorisez cette application à gérer les médias. - Si la redirection ne fonctionne pas, allez dans les paramètres de votre appareil - Applis - Accès aux applications spéciales - Applis de gestion des médias et autorisez cette application à gérer les médias. - Si vous ne voulez pas le faire, vous pouvez aussi aller dans les Paramètres de votre appareil - Applis - Accès aux applications spéciales - Applis de gestion des médias et autoriser cette application à gérer les médias. - Vous pouvez également n\'autoriser que l\'accès aux fichiers multimédias. Dans ce cas, vous ne pourrez cependant pas travailler avec les fichiers cachés. - Médias uniquement - Tous les fichiers - Rechercher des fichiers au lieu des dossiers sur l\'écran principal - Afficher un bouton de menu pour afficher rapidement le contenu de tous les dossiers - - Miniatures - Plein écran - Détails supplémentaires - Barre d\'actions - - Gérer la barre d\'actions - Activer/désactiver le favori - Visibilité du fichier - - Libre - Réinitialiser - Carré - Transformer - Filtres - Aucun - Ajuster - Ombres - Exposition - Détails - Luminosité - Contraste - Saturation - Clarté - Gamma - Noirs - Blancs - Température - Netteté - Réinitialiser - Floutage - Aucun - Radial - Linéaire - Miroir - Gaussien - Ajouter un texte - Texte - Options du texte - Couleur du texte - Police - Ajouter - Éditer - Redresser - Police - Couleur - Fond - Alignement - Devant - Supprimer - Votre texte - Pinceau - Couleur - Taille - Contour - Devant - Supprimer - Couleur du pinceau - Éditeur - Fermer l\'éditeur \? - Voulez-vous vraiment abandonner les modifications \? - Oui - Non - Annuler - Accepter - Enregistrer - Exportation… - Exportation %s - Autocollant - Couleur de l\'autocollant - Options de l\'autocollant - Ajouter - Couleur - Supprimer - Devant - Redresser - Remplacer - Transparence - Contraste - Saturation - Luminosité - Téléversements - Superposition - Normal - Assombrir - Écran - Recouvrir - Alléger - Dupliquer - Brûlure de couleur - Lumière douce - Lumière forte - Aucune - Doré - Fuite légère 1 - Mosaïque - Papier - Pluie - Vintage - Symétrie H - Symétrie V - Annuler - Refaire - Sélecteur de couleur - Transparent - Blanc - Gris - Noir - Bleu clair - Bleu - Violet - Orchidée - Rose - Rouge - Orange - Or - Jaune - Olive - Vert - Aquamarin - Couleur de la pipette - Couper - - Comment faire de Simple Galerie ma galerie par défaut \? - Il faut dans un premier temps, trouver l\'application Galerie par défaut dans la section Applications des paramètres de l\'appareil, puis appuyer sur « Ouvrir par défaut », et enfin sélectionner « Réinitialiser les paramètres par défaut ». La prochaine fois que vous ouvrirez une image ou une vidéo, il vous sera proposé de choisir une application, choisissez Simple Galerie puis « Toujours ». - J\'ai verrouillé l\'application avec un mot de passe et je ne m\'en rappelle plus. Que faire \? - Il y a deux façons de procéder. Soit vous réinstallez l\'application, soit vous recherchez l\'application dans les paramètres de l\'appareil et appuyez sur « Effacer les données ». Ceci réinitialisera seulement les paramètres de l\'application et ne supprimera pas vos fichiers. - Comment faire pour qu\'un dossier soit toujours affiché tout en haut \? - Vous devez simplement effectuer un appui prolongé sur le dossier en question et choisir « Épingler en haut » dans le menu d\'actions. Vous pouvez en épingler plusieurs. Les éléments épinglés seront alors triés selon l\'ordre par défaut. - Comment avancer rapidement dans les vidéos \? - Appuyez deux fois sur le côté de l\'écran, ou appuyez sur la valeur de durée actuelle ou maximale près de la barre de recherche. Si vous activez l\'ouverture des vidéos sur un écran séparé dans les paramètres de l\'application, vous pouvez également utiliser des gestes horizontaux. - Quelle est la différence entre cacher et exclure un dossier \? - Exclure un dossier permet de ne pas l\'afficher uniquement dans Simple Galerie, alors que cacher un dossier rend le dossier invisible sur l\'ensemble de l\'appareil, y compris pour les autres applications de galerie. Dans le dernier cas, un fichier .nomedia est créé dans le dossier caché, et peut être supprimé avec n\'importe quel explorateur de fichiers. Notez que certains appareils ne permettent pas de masquer certains dossiers tels qu\'Appareil photo, Captures d\'écran et Téléchargements. - Pourquoi des dossiers avec des pochettes d\'albums musicaux ou des miniatures d\'images sont affichés \? - Il est possible que des dossiers qui ne devraient pas être affichés le soient. Vous pouvez les exclure facilement en les sélectionnant par un appui prolongé, puis en choisissant l\'option « Exclure le dossier », après quoi vous pouvez aussi sélectionner le dossier parent, ce qui devrait éviter l\'apparition de dossiers similaires. - Un dossier avec des images n\'apparaît pas. Que faire \? - Cela peut arriver pour de multiples raisons, mais c\'est facile à résoudre. Allez dans Paramètres, puis Gérer les dossiers ajoutés, appuyez sur + et sélectionnez le dossier voulu. - Comment faire apparaître uniquement certains dossiers \? - Ajouter un dossier dans les « Dossiers ajoutés » rend visible l\'ensemble du contenu du dossier. Pour exclure certains dossiers, il faut aller dans Paramètres, puis « Gérer les dossiers exclus », exclure le dossier racine /, puis ajouter les dossiers souhaités dans « Paramètres », puis « Gérer les dossiers ajoutés ». Seuls les dossiers sélectionnés seront visibles, du fait que les exclusions et inclusions sont récursives, et si un dossier est à la fois exclus et inclus, il sera affiché. - Puis-je recadrer des images avec cette application \? - Oui, vous pouvez recadrer les images dans l\'éditeur en faisant glisser les coins de l\'image. Vous pouvez accéder à l\'éditeur en appuyant longuement sur une vignette d\'image et en sélectionnant « Modifier », ou en sélectionnant « Modifier » en mode plein écran. - Puis-je regrouper les miniatures des fichiers multimédias \? - Bien sûr, il vous suffit d\'utiliser l\'option de menu « Grouper par » lorsque vous êtes dans l\'affichage des miniatures. Vous pouvez regrouper les fichiers selon plusieurs critères, y compris la date de prise de vue. Si vous utilisez la fonction « Afficher tous les contenus », vous pouvez également les regrouper par dossier. - Le tri par date de prise de vue ne semble pas fonctionner correctement, comment puis-je le corriger \? - Cela est probablement dû au fait que les fichiers ont été copiés depuis quelque part. Vous pouvez corriger cela en sélectionnant les miniatures de fichier et en sélectionnant « Corriger les dates de prise de vue ». - Je vois des bandes de couleurs sur les images. Comment puis-je améliorer la qualité \? - La solution actuelle d\'affichage des images fonctionne bien dans la grande majorité des cas, mais si vous voulez une qualité d\'image encore meilleure, vous pouvez activer l\'option « Afficher les images dans la meilleure qualité possible » dans la section « Niveau de zoom » des paramètres de l\'application. - J\'ai caché un fichier ou un dossier. Comment puis-je en rétablir l\'affichage \? - Vous pouvez soit appuyer sur l\'option « Afficher les fichiers cachés » du menu de l\'écran principal, ou appuyer sur le bouton « Afficher les fichiers cachés » dans les paramètres de l\'application. Si vous voulez rétablir leur affichage, effectuez un appui prolongé dessus et appuyez sur le symbole « Œil » permettant l\'affichage. Les dossiers sont cachés en ajoutant un fichier .nomedia à leur racine, vous pouvez également supprimer ce fichier avec n\'importe quel explorateur de fichiers. Notez que le masquage fonctionne de manière récursive, donc si vous masquez un dossier, tous les sous-dossiers seront également masqués. Donc, pour afficher les sous-dossiers, vous devez afficher le dossier parent. - Pourquoi l\'application prend-elle tant de place \? - Le cache d\'application peut prendre jusqu\'à 250 Mo pour accélérer le chargement des images. Si l\'application occupe encore plus d\'espace, c\'est probablement parce que vous avez des éléments dans la corbeille. Ces fichiers comptent pour la taille de l\'application. Vous pouvez vider la corbeille en l\'ouvrant et en supprimant tous les fichiers ou à partir des paramètres de l\'application. Chaque fichier de la corbeille est automatiquement supprimé après 30 jours. - Qu\'est ce qui se passe avec les fichiers et dossiers cachés et pourquoi je ne peux plus les voir \? - À partir d\'Android 11, vous ne pouvez plus masquer ou démasquer des fichiers ou des dossiers, et vous ne pouvez pas non plus voir ceux qui sont masqués dans les applications de la galerie. Vous devrez utiliser un gestionnaire de fichiers pour cela. - Vous pouvez également accorder à cette galerie l\'accès à tous les fichiers via les paramètres de votre appareil, ce qui nous permettra de montrer les éléments cachés et de rendre les opérations sur les fichiers plus fiables en général. - Pourquoi je ne peux plus inclure des dossiers manquants \? - Cette fonctionnalité ne fonctionne plus en raison des modifications apportées au système avec Android 11. L\'application ne peut plus parcourir les dossiers réels, elle s\'appuie sur le MediaStore pour récupérer les données. - Pourquoi des publicités apparaissent pendant la lecture d\'une vidéo \? - Nos applications ne comportent aucune publicité. Si vous en voyez pendant la lecture d\'une vidéo, vous devez sûrement utiliser le lecteur vidéo d\'une autre application. Essayez de trouver le lecteur vidéo par défaut dans les paramètres de votre appareil, puis faites « Supprimer les valeurs par défaut ». Lors du prochain lancement d\'une vidéo, une invite de sélection d\'application s\'affichera, et vous pourrez choisir l\'application que vous souhaitez utiliser. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt index 3b1cfb2d5..793f0386f 100644 --- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt +++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt @@ -66,7 +66,7 @@ class NewPhotoEditActivity : SimpleActivity() { if (it) { initEditActivity() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -214,7 +214,7 @@ class NewPhotoEditActivity : SimpleActivity() { if (success) { callback() } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) finish() } } diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt index 8650a786d..e17f22a22 100644 --- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt +++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt @@ -61,7 +61,7 @@ class NewVideoEditActivity : SimpleActivity() { if (it) { initEditActivity() } else { - toast(R.string.no_storage_permissions) + toast(com.simplemobiletools.commons.R.string.no_storage_permissions) finish() } } @@ -198,7 +198,7 @@ class NewVideoEditActivity : SimpleActivity() { if (success) { callback() } else { - toast(R.string.unknown_error_occurred) + toast(com.simplemobiletools.commons.R.string.unknown_error_occurred) finish() } } diff --git a/build.gradle b/build.gradle index e3bf57c0c..8e8e41680 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { propVersionName = '5.34.26' }*/ - ext.kotlin_version = '1.6.21' + ext.kotlin_version = '1.9.0' ext.is_proprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") } repositories { @@ -22,7 +22,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:8.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" if (is_proprietary) { classpath 'ly.img.android.pesdk:plugin:10.7.3' diff --git a/gradle.properties b/gradle.properties index f32badbfb..1b66d5d35 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ android.enableJetifier=true android.useAndroidX=true -org.gradle.jvmargs=-Xmx1536m \ No newline at end of file +org.gradle.jvmargs=-Xmx1536m +android.nonTransitiveRClass=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 135b8fe32..b9f4d06ee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip