Merge pull request #2943 from esensar/viewbinding-migration

Migrate to viewbinding and SDK 34
This commit is contained in:
Tibor Kaputa 2023-08-30 13:54:51 +02:00 committed by GitHub
commit b7c4fd1c4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 2349 additions and 1957 deletions

View file

@ -1,152 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.simplemobiletools.gallery.pro"
minSdkVersion 23
targetSdkVersion 33
versionCode 394
versionName "6.27.2"
setProperty("archivesBaseName", "gallery-$versionCode")
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
}
buildTypes {
debug {
// we cannot change the original package name, else PhotoEditorSDK won't work
//applicationIdSuffix ".debug"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (keystorePropertiesFile.exists()) {
signingConfig signingConfigs.release
}
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
if (is_proprietary) {
main.java.srcDirs += 'src/proprietary/kotlin'
}
}
flavorDimensions "licensing"
productFlavors {
proprietary {}
foss {}
prepaid {}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/library_release.kotlin_module'
}
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0'
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'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.media3:media3-exoplayer:1.1.0'
implementation 'com.google.vr:sdk-panowidget:1.180.0'
implementation 'com.google.vr:sdk-videowidget:1.180.0'
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
implementation 'info.androidhive:imagefilters:1.0.7'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'com.github.tibbi:gestureviews:a8e8fa8d27'
implementation 'com.github.tibbi:subsampling-scale-image-view:80efdaa570'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.penfeizhou.android.animation:awebp:2.25.0'
implementation 'com.github.penfeizhou.android.animation:apng:2.25.0'
implementation 'com.squareup.okio:okio:3.0.0'
implementation('com.squareup.picasso:picasso:2.71828') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compileOnly 'com.squareup.okhttp3:okhttp:4.9.0'
kapt 'com.github.bumptech.glide:compiler:4.15.1'
kapt 'androidx.room:room-compiler:2.5.2'
implementation 'androidx.room:room-runtime:2.5.2'
annotationProcessor 'androidx.room:room-compiler:2.5.2'
//implementation project(':commons')
}
// Apply the PESDKPlugin
if (is_proprietary) {
apply plugin: 'ly.img.android.sdk'
imglyConfig {
vesdk {
enabled true
licensePath 'vesdk_android_license'
}
pesdk {
enabled true
licensePath 'pesdk_android_license'
}
modules {
include 'ui:video-trim'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:video-composition'
include 'backend:serializer'
include 'backend:sticker-smart'
include 'backend:sticker-animated'
include 'assets:font-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
include 'assets:sticker-animated'
}
}
}

135
app/build.gradle.kts Normal file
View file

@ -0,0 +1,135 @@
import java.io.FileInputStream
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.properties.Properties
val isProprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") }
plugins {
alias(libs.plugins.android)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.imgly).apply(false)
}
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
defaultConfig {
applicationId = libs.versions.app.version.appId.get()
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
versionName = project.libs.versions.app.version.versionName.get()
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
setProperty("archivesBaseName", "gallery-$versionCode")
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
register("release") {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
}
buildFeatures {
viewBinding = true
buildConfig = true
}
buildTypes {
debug {
// we cannot change the original package name, else PhotoEditorSDK won't work
//applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
if (keystorePropertiesFile.exists()) {
signingConfig = signingConfigs.getByName("release")
}
}
}
flavorDimensions.add("licensing")
productFlavors {
register("proprietary")
register("foss")
register("prepaid")
}
sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
if (isProprietary) {
getByName("main").java.srcDirs("src/proprietary/kotlin")
}
}
compileOptions {
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
sourceCompatibility = currentJavaVersionFromLibs
targetCompatibility = currentJavaVersionFromLibs
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
}
namespace = libs.versions.app.version.appId.get()
lint {
checkReleaseBuilds = false
abortOnError = false
}
packaging {
resources {
excludes += "META-INF/library_release.kotlin_module"
}
}
}
dependencies {
implementation(libs.simple.tools.commons)
implementation(libs.android.image.cropper)
implementation(libs.exif)
implementation(libs.android.gif.drawable)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.media3.exoplayer)
implementation(libs.sdk.panowidget)
implementation(libs.sdk.videowidget)
implementation(libs.sanselan)
implementation(libs.imagefilters)
implementation(libs.androidsvg.aar)
implementation(libs.gestureviews)
implementation(libs.subsamplingscaleimageview)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.awebp)
implementation(libs.apng)
implementation(libs.okio)
implementation(libs.picasso) {
exclude(group = "com.squareup.okhttp3", module = "okhttp")
}
compileOnly(libs.okhttp)
ksp(libs.glide.compiler)
implementation(libs.bundles.room)
ksp(libs.androidx.room.compiler)
}
// Apply the PESDKPlugin
if (isProprietary) {
apply(from = "../gradle/imglysdk.gradle")
}

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.simplemobiletools.gallery.pro"
android:installLocation="auto">
<!-- override the android:maxSdkVersion="28" from PhotoEditorSDK with some higher number -->

View file

@ -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,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
private var oldExif: ExifInterface? = null
private var filterInitialBitmap: Bitmap? = null
private var originalUri: Uri? = null
private val binding by viewBinding(ActivityEditBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_edit)
setContentView(binding.root)
if (checkAppSideloading()) {
return
@ -104,7 +102,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 +112,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 +124,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 +170,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 +189,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 +230,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 +239,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 +260,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 +294,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 +315,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 +333,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 +347,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 +371,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 +382,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 +430,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 +445,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 +493,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 +565,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 +576,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 +655,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 +665,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 +690,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 +698,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 +716,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 +751,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 +780,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 +875,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 +903,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 +943,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()
}
}

View file

@ -2,42 +2,41 @@ package com.simplemobiletools.gallery.pro.activities
import android.os.Bundle
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.internalStoragePath
import com.simplemobiletools.commons.extensions.isExternalStorageManager
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.NavigationIcon
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 val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manage_folders)
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<String>()
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 +47,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

View file

@ -4,52 +4,54 @@ import android.os.Bundle
import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
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 val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manage_folders)
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

View file

@ -3,47 +3,50 @@ package com.simplemobiletools.gallery.pro.activities
import android.os.Bundle
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.viewBinding
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 val binding by viewBinding(ActivityManageFoldersBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_manage_folders)
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<String>()
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

View file

@ -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,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private var mStoredTextColor = 0
private var mStoredPrimaryColor = 0
private var mStoredStyleString = ""
private val binding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID)
if (savedInstanceState == null) {
@ -111,9 +114,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,14 +154,14 @@ 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()
}
}
@ -200,7 +208,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
if (mStoredScrollHorizontally != config.scrollHorizontally) {
mLoadedInitialPhotos = false
directories_grid.adapter = null
binding.directoriesGrid.adapter = null
getDirectories()
}
@ -218,20 +226,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 +257,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 +305,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 +353,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 +377,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()
@ -421,10 +429,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 +459,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 +511,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 +532,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 +559,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 +582,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 +607,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
ChangeViewTypeDialog(this, true) {
refreshMenuItems()
setupLayoutManager()
directories_grid.adapter = null
binding.directoriesGrid.adapter = null
setupAdapter(getRecyclerAdapter()?.dirs ?: mDirs)
}
}
@ -614,7 +629,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 +647,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 +659,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 +696,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 +733,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 +796,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun changeColumnCount() {
val items = ArrayList<RadioItem>()
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 +820,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 +971,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 +985,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 +1132,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 +1160,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
runOnUiThread {
directories_refresh_layout.isRefreshing = false
binding.directoriesRefreshLayout.isRefreshing = false
checkPlaceholderVisibility(dirs)
}
@ -1201,41 +1219,41 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) {
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<Directory>, textToSearch: String = main_menu.getCurrentQuery(), forceRecreate: Boolean = false) {
val currAdapter = directories_grid.adapter
private fun setupAdapter(dirs: ArrayList<Directory>, textToSearch: String = binding.mainMenu.getCurrentQuery(), forceRecreate: Boolean = false) {
val currAdapter = binding.directoriesGrid.adapter
val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList<Directory>
val sortedDirs = getSortedDirectories(distinctDirs)
var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList<Directory>
@ -1247,9 +1265,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 +1283,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 +1299,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<Directory>) {

View file

@ -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 val binding by viewBinding(ActivityMediaBinding::inflate)
companion object {
var mMedia = ArrayList<ThumbnailItem>()
}
@ -77,7 +79,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_media)
setContentView(binding.root)
intent.apply {
mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false)
@ -86,7 +88,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 +100,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 +142,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
if (mStoredScrollHorizontally != config.scrollHorizontally) {
mLoadedInitialPhotos = false
media_grid.adapter = null
binding.mediaGrid.adapter = null
getMedia()
}
@ -155,22 +164,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 +201,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 +238,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 +258,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 +284,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 +338,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private fun updateMenuColors() {
updateStatusbarColor(getProperBackgroundColor())
media_menu.updateColors()
binding.mediaMenu.updateColors()
}
private fun storeStateVariables() {
@ -355,12 +364,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, 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 +384,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 +407,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<ThumbnailItem>, 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 +455,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 +484,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 +492,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 +540,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
ChangeViewTypeDialog(this, false, mPath) {
refreshMenuItems()
setupLayoutManager()
media_grid.adapter = null
binding.mediaGrid.adapter = null
setupAdapter()
}
}
@ -539,7 +548,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private fun showGroupByDialog() {
ChangeGroupingDialog(this, mPath) {
mLoadedInitialPhotos = false
media_grid.adapter = null
binding.mediaGrid.adapter = null
getMedia()
}
}
@ -569,7 +578,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 +631,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 +690,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 +713,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 +728,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 +746,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 +770,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private fun changeColumnCount() {
val items = ArrayList<RadioItem>()
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 +794,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 +872,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 +903,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<String>) {
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 +925,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
deleteFiles(filtered) {
if (!it) {
toast(R.string.unknown_error_occurred)
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
return@deleteFiles
}
@ -961,8 +970,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
}
}

View file

@ -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,25 @@ open class PanoramaPhotoActivity : SimpleActivity() {
private var isExploreEnabled = true
private var isRendering = false
private val binding by viewBinding(ActivityPanoramaPhotoBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
requestWindowFeature(Window.FEATURE_NO_TITLE)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panorama_photo)
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 +59,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 +76,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 +108,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 +166,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
}

View file

@ -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,13 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
private var mCurrTime = 0
private var mTimerHandler = Handler()
private val binding by viewBinding(ActivityPanoramaVideoBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
requestWindowFeature(Window.FEATURE_NO_TITLE)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_panorama_video)
setContentView(binding.root)
checkNotchSupport()
checkIntent()
@ -56,7 +56,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 +73,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 +104,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 +116,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
Uri.fromFile(File(path))
}
vr_video_view.apply {
binding.vrVideoView.apply {
loadVideo(uri, options)
pauseVideo()
@ -149,9 +149,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 +160,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
})
}
video_toggle_play_pause.setOnClickListener {
binding.bottomVideoTimeHolder.videoTogglePlayPause.setOnClickListener {
togglePlayPause()
}
} catch (e: Exception) {
@ -175,8 +175,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 +184,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 +204,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 +249,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 +310,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 +328,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
}
override fun onStartTrackingTouch(seekBar: SeekBar?) {
vr_video_view.pauseVideo()
binding.vrVideoView.pauseVideo()
mIsDragged = true
}

View file

@ -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,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
var mIsVideo = false
private val binding by viewBinding(FragmentHolderBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_holder)
setContentView(binding.root)
if (checkAppSideloading()) {
return
}
@ -50,7 +51,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 +75,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 +97,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 +122,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
return@setOnMenuItemClickListener true
}
fragment_viewer_toolbar.setNavigationOnClickListener {
binding.fragmentViewerToolbar.setNavigationOnClickListener {
finish()
}
}
@ -162,7 +163,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 +177,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 +190,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 +200,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 +223,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("<font color='${Color.WHITE.toHex()}'>${mMedium!!.name}</font>")
binding.fragmentViewerToolbar.title = Html.fromHtml("<font color='${Color.WHITE.toHex()}'>${mMedium!!.name}</font>")
bundle.putSerializable(MEDIUM, mMedium)
if (savedInstanceState == null) {
@ -233,7 +234,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 +254,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 +357,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 +418,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()
}

View file

@ -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,17 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private var mCurrAsyncTask: GetMediaAsynctask? = null
private var mAllMedia = ArrayList<ThumbnailItem>()
private val binding by viewBinding(ActivitySearchBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_search)
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 +55,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 +86,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private fun updateMenuColors() {
updateStatusbarColor(getProperBackgroundColor())
search_menu.updateColors()
binding.searchMenu.updateColors()
}
private fun textChanged(text: String) {
@ -95,10 +97,10 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, "")
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 +112,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 +136,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private fun handleGridSpacing(media: ArrayList<ThumbnailItem>) {
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 +177,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 +200,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 +208,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 +246,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<String>) {
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 +266,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
deleteFiles(filtered) {
if (!it) {
toast(R.string.unknown_error_occurred)
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
return@deleteFiles
}

View file

@ -10,15 +10,13 @@ import com.canhub.cropper.CropImageView
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.checkAppSideloading
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon
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 +30,11 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
lateinit var uri: Uri
lateinit var wallpaperManager: WallpaperManager
private val binding by viewBinding(ActivitySetWallpaperBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_set_wallpaper)
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()

View file

@ -13,35 +13,39 @@ 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 val binding by viewBinding(ActivitySettingsBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
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 +98,7 @@ class SettingsActivity : SimpleActivity() {
setupShowRecycleBin()
setupShowRecycleBinLast()
setupEmptyRecycleBin()
updateTextColors(settings_holder)
updateTextColors(binding.settingsHolder)
setupClearCache()
setupExportFavorites()
setupImportFavorites()
@ -102,19 +106,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 +139,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 +180,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 +195,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 +211,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 +219,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 +229,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 +250,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 +363,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 +386,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 +408,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 +430,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 +501,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 +610,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 +624,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 +647,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 +676,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 +697,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 +718,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 +744,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 +767,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 +780,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 +793,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 +816,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 +837,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<String, Any>().apply {
put(IS_USING_SHARED_THEME, config.isUsingSharedTheme)
put(TEXT_COLOR, config.textColor)
@ -930,7 +936,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 +959,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 +993,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 +1087,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()
}

View file

@ -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,12 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
private var mIgnoreCloseDown = false
private val binding by viewBinding(ActivityVideoPlayerBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_video_player)
setContentView(binding.root)
setupOptionsMenu()
setupOrientation()
checkNotchSupport()
@ -70,11 +72,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 +85,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 +107,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 +134,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
return@setOnMenuItemClickListener true
}
video_toolbar.setNavigationOnClickListener {
binding.videoToolbar.setNavigationOnClickListener {
finish()
}
}
@ -141,16 +143,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 +168,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 +177,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 +196,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 +269,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 +291,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 +304,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 +319,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 +336,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 +360,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 +378,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 +412,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 +420,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 +458,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 +499,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 +512,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 +550,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 +581,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 +589,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 +668,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) {}

View file

@ -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,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private var mFavoritePaths = ArrayList<String>()
private var mIgnoredPaths = ArrayList<String>()
private val binding by viewBinding(ActivityMediumBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_medium)
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<ThumbnailItem>).filterIsInstanceTo(mMediaFiles, Medium::class.java)
@ -99,7 +100,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 +133,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 +163,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 +210,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 +256,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
return@setOnMenuItemClickListener true
}
medium_viewer_toolbar.setNavigationOnClickListener {
binding.mediumViewerToolbar.setNavigationOnClickListener {
finish()
}
}
@ -280,7 +281,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 +315,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 +369,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<ThumbnailItem>, refetchViewPagerPosition = true)
@ -390,14 +391,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 +470,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 +495,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 +514,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 +560,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 +573,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 +592,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 +666,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 +688,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 +728,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 +746,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 +815,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 +824,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 +890,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 +915,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 +951,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 +992,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 +1076,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 +1131,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 +1189,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 +1323,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 +1343,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 +1369,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 +1391,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()
}
}
}

View file

@ -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,13 @@ class WidgetConfigureActivity : SimpleActivity() {
private var mFolderPath = ""
private var mDirectories = ArrayList<Directory>()
private val binding by viewBinding(ActivityWidgetConfigBinding::inflate)
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(RESULT_CANCELED)
setContentView(R.layout.activity_widget_config)
setContentView(binding.root)
initVariables()
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
@ -43,21 +45,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 +77,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 +88,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 +99,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 +130,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 +169,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 +178,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)
}
}

View file

@ -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<Directory>, 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()
}
}
}

View file

@ -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)

View file

@ -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<FilterItem>, val itemClick: (Int) -> Unit) :
RecyclerView.Adapter<FiltersAdapter.ViewHolder>() {
@ -20,8 +20,8 @@ class FiltersAdapter(val context: Context, val filterItems: ArrayList<FilterItem
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.editor_filter_item, parent, false)
return ViewHolder(view)
val binding = EditorFilterItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}
override fun getItemCount() = filterItems.size
@ -37,18 +37,18 @@ class FiltersAdapter(val context: Context, val filterItems: ArrayList<FilterItem
}
}
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
inner class ViewHolder(private val binding: EditorFilterItemBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindView(filterItem: FilterItem): View {
itemView.apply {
editor_filter_item_label.text = filterItem.filter.name
editor_filter_item_thumbnail.setImageBitmap(filterItem.bitmap)
editor_filter_item_thumbnail.background = if (getCurrentFilter() == filterItem) {
binding.apply {
editorFilterItemLabel.text = filterItem.filter.name
editorFilterItemThumbnail.setImageBitmap(filterItem.bitmap)
editorFilterItemThumbnail.background = if (getCurrentFilter() == filterItem) {
strokeBackground
} else {
null
}
setOnClickListener {
root.setOnClickListener {
setCurrentFilter(adapterPosition)
}
}

View file

@ -9,9 +9,8 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
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.config
import kotlinx.android.synthetic.main.item_manage_folder.view.*
class ManageFoldersAdapter(
activity: BaseSimpleActivity, var folders: ArrayList<String>, 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<String>
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()
}

View file

@ -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<String>, 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<String>
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())
}

View file

@ -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<ThumbnailItem>, 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<String>, 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()
}
}
}
}

View file

@ -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)

View file

@ -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<String>, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) :
RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
@ -27,8 +27,8 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
}
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<String>,
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<String>,
.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

View file

@ -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<TextView>(R.id.message).text = message
activity.getAlertDialogBuilder().setPositiveButton(R.string.all_files) { dialog, which -> positivePressed() }

View file

@ -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"
}
}

View file

@ -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()
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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
}
}

View file

@ -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<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> 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()
}

View file

@ -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)
}
}

View file

@ -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<String>, 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)
}
}

View file

@ -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()

View file

@ -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) {

View file

@ -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 -> }
}
}
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}
}

View file

@ -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<Directory>()
private var allDirectories = ArrayList<Directory>()
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<EditText>(R.id.top_toolbar_search)
private val searchViewAppBarLayout = view.findViewById<View>(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<ImageView>(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<Directory>) = with(view) {
directories_empty_placeholder.beVisibleIf(dirs.isEmpty())
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) = 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<Directory>, null, view.directories_grid, true) {
val adapter = DirectoryAdapter(activity, dirs.clone() as ArrayList<Directory>, 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)
}
}

View file

@ -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<ThumbnailItem>()
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<ThumbnailItem>, null, true, false, path, view.media_grid) {
val adapter = MediaAdapter(activity, shownMedia.clone() as ArrayList<ThumbnailItem>, 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)
}
}
}

View file

@ -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)

View file

@ -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)
}

View file

@ -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()

View file

@ -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))

View file

@ -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
}
}

View file

@ -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<FileDirItem>, 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)

View file

@ -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)
}
}

View file

@ -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)
}
}
@ -435,7 +437,7 @@ class PhotoFragment : ViewPagerFragment() {
if (drawable.intrinsicWidth == 0) {
loadWithGlide(path, addZoomableView)
} else {
mView.gestures_view.setImageDrawable(drawable)
binding.gesturesView.setImageDrawable(drawable)
}
} else {
loadWithGlide(path, addZoomableView)
@ -475,13 +477,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) {
@ -501,9 +503,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()
@ -526,7 +528,9 @@ class PhotoFragment : ViewPagerFragment() {
val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList<File>
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()
@ -542,7 +546,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()
@ -550,7 +554,7 @@ class PhotoFragment : ViewPagerFragment() {
}
}
mView.photo_portrait_stripe.adapter = adapter
binding.photoPortraitStripe.adapter = adapter
setupStripeBottomMargin()
val coverIndex = getCoverImageIndex(paths)
@ -558,12 +562,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
}
}
}
@ -587,11 +591,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<String>): Int {
@ -613,7 +617,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
@ -672,7 +676,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)
@ -701,7 +705,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()
@ -759,9 +763,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
}
}
}
@ -817,7 +821,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)
@ -828,7 +832,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 {
@ -843,15 +847,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)
}
}
@ -861,14 +865,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))
@ -879,18 +883,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

View file

@ -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
}

View file

@ -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
}

View file

@ -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,18 @@ 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 getRequiredPermission() = if (isUpsideDownCakePlus()) PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED else getPermissionToRequest()
fun getPermissionsToRequest(): Collection<Int> {
val permissions = mutableListOf(getPermissionToRequest())
if (isRPlus()) {
permissions.add(PERMISSION_MEDIA_LOCATION)
}
if (isTiramisuPlus()) {
permissions.add(PERMISSION_READ_MEDIA_VIDEO)
}
return permissions
}

View file

@ -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<FilterItem>(10)

View file

@ -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
}
}

View file

@ -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
)

View file

@ -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(

View file

@ -17,7 +17,13 @@ class SvgSoftwareLayerSetter : RequestListener<PictureDrawable> {
return false
}
override fun onResourceReady(resource: PictureDrawable, model: Any, target: Target<PictureDrawable>, dataSource: DataSource, isFirstResource: Boolean): Boolean {
override fun onResourceReady(
resource: PictureDrawable,
model: Any,
target: Target<PictureDrawable>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
val view = (target as ImageViewTarget<*>).view
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
return false

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -11,7 +11,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<include layout="@layout/bottom_video_time_holder"/>
<include
android:id="@+id/bottom_video_time_holder"
layout="@layout/bottom_video_time_holder"/>
<ImageView
android:id="@+id/explore"

View file

@ -46,7 +46,9 @@
android:background="@drawable/gradient_background"
tools:ignore="UnknownIdInLayout" />
<include layout="@layout/bottom_video_time_holder" />
<include
android:id="@+id/bottom_video_time_holder"
layout="@layout/bottom_video_time_holder" />
<TextView
android:id="@+id/slide_info"

View file

@ -66,7 +66,9 @@
android:visibility="gone"
tools:text="My video\nAnother line" />
<include layout="@layout/bottom_video_time_holder" />
<include
android:id="@+id/bottom_video_time_holder"
layout="@layout/bottom_video_time_holder" />
<TextView
android:id="@+id/slide_info"

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simplemobiletools.gallery.pro"
android:installLocation="auto">
<application

View file

@ -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()
}
}
@ -296,9 +296,9 @@ class NewPhotoEditActivity : SimpleActivity() {
}
val theme = if (isUsingSystemDarkTheme()) {
R.style.Theme_Imgly_NoFullscreen
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
} else {
R.style.Theme_Imgly_Light_NoFullscreen
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
}
getSettingsModel(UiConfigTheme::class.java).theme = theme

View file

@ -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()
}
}
@ -274,9 +274,9 @@ class NewVideoEditActivity : SimpleActivity() {
}
val theme = if (isUsingSystemDarkTheme()) {
R.style.Theme_Imgly_NoFullscreen
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
} else {
R.style.Theme_Imgly_Light_NoFullscreen
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
}
getSettingsModel(UiConfigTheme::class.java).theme = theme

View file

@ -1,49 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// needed only if we are including commons locally from our pc, not via Jitpack
/*ext {
propCompileSdkVersion = 33
propMinSdkVersion = 23
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.34.26'
}*/
ext.kotlin_version = '1.6.21'
ext.is_proprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") }
repositories {
google()
jcenter()
if (is_proprietary) {
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
if (is_proprietary) {
classpath 'ly.img.android.pesdk:plugin:10.7.3'
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
if (is_proprietary) {
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

6
build.gradle.kts Normal file
View file

@ -0,0 +1,6 @@
plugins {
alias(libs.plugins.android).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.imgly).apply(false)
}

View file

@ -1,3 +1,4 @@
android.enableJetifier=true
android.nonTransitiveRClass=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx1536m

42
gradle/imglysdk.gradle Normal file
View file

@ -0,0 +1,42 @@
// This file had to stay in Groovy
// Since just converting it to Kotlin will not work
// There needs to be a way to conditinally apply this plugin
// But that results in missing references for `imglyConfig`
apply plugin: 'ly.img.android.sdk'
imglyConfig {
vesdk {
enabled true
licensePath 'vesdk_android_license'
}
pesdk {
enabled true
licensePath 'pesdk_android_license'
}
modules {
include 'ui:video-trim'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:video-composition'
include 'backend:serializer'
include 'backend:sticker-smart'
include 'backend:sticker-animated'
include 'assets:font-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
include 'assets:sticker-animated'
}
}

84
gradle/libs.versions.toml Normal file
View file

@ -0,0 +1,84 @@
[versions]
#imgly
imgly = "10.7.3"
#jetbrains
kotlin = "1.8.22"
#KSP
ksp = "1.8.22-1.0.11"
#AndroidX
androidx-swiperefreshlayout = "1.1.0"
androidx-constraintlayout = "2.1.4"
#exif
exif = "1.0.1"
#Room
room = "2.6.0-beta01"
#Simple tools
simple-commons = "687fa225a8"
#Gradle
gradlePlugins-agp = "8.1.0"
#Other
androidGifDrawable = "1.2.25"
androidImageCropper = "4.5.0"
apng = "2.25.0"
awebp = "2.25.0"
glideCompiler = "4.15.1"
gestureviews = "a8e8fa8d27"
androidsvgAar = "1.4"
imagefilters = "1.0.7"
sanselan = "0.97-incubator"
sdkVideowidget = "1.180.0"
sdkPanowidget = "1.180.0"
media3Exoplayer = "1.1.0"
okhttp = "4.9.0"
okio = "3.0.0"
picasso = "2.71828"
#build
app-build-compileSDKVersion = "34"
app-build-targetSDK = "33"
app-build-minimumSDK = "23"
app-build-javaVersion = "VERSION_17"
app-build-kotlinJVMTarget = "17"
#versioning
app-version-appId = "com.simplemobiletools.gallery.pro"
app-version-versionCode = "394"
app-version-versionName = "6.27.2"
subsamplingScaleImageView = "80efdaa570"
[libraries]
#AndroidX
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3Exoplayer" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
#exif
exif = { module = "it.sephiroth.android.exif:library", version.ref = "exif" }
#Room
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
#Simple Mobile Tools
simple-tools-commons = { module = "com.github.esensar:Simple-Commons", version.ref = "simple-commons" }
#Other
android-gif-drawable = { module = "pl.droidsonroids.gif:android-gif-drawable", version.ref = "androidGifDrawable" }
android-image-cropper = { module = "com.vanniktech:android-image-cropper", version.ref = "androidImageCropper" }
subsamplingscaleimageview = { module = "com.github.tibbi:subsampling-scale-image-view", version.ref = "subsamplingScaleImageView" }
androidsvg-aar = { module = "com.caverock:androidsvg-aar", version.ref = "androidsvgAar" }
gestureviews = { module = "com.github.tibbi:gestureviews", version.ref = "gestureviews" }
imagefilters = { module = "info.androidhive:imagefilters", version.ref = "imagefilters" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
sanselan = { module = "org.apache.sanselan:sanselan", version.ref = "sanselan" }
sdk-videowidget = { module = "com.google.vr:sdk-videowidget", version.ref = "sdkVideowidget" }
sdk-panowidget = { module = "com.google.vr:sdk-panowidget", version.ref = "sdkPanowidget" }
apng = { module = "com.github.penfeizhou.android.animation:apng", version.ref = "apng" }
awebp = { module = "com.github.penfeizhou.android.animation:awebp", version.ref = "awebp" }
glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "glideCompiler" }
picasso = { module = "com.squareup.picasso:picasso", version.ref = "picasso" }
[bundles]
room = [
"androidx-room-ktx",
"androidx-room-runtime",
]
[plugins]
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
imgly = { id = "ly.img.android.sdk", version.ref = "imgly" }

View file

@ -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

View file

@ -1,3 +0,0 @@
include ':app'
//include ':commons'
//project(':commons').projectDir = new File('../Simple-Commons/commons')

20
settings.gradle.kts Normal file
View file

@ -0,0 +1,20 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven(url = "https://artifactory.img.ly/artifactory/imgly")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
jcenter()
mavenCentral()
maven { setUrl("https://jitpack.io") }
maven(url = "https://artifactory.img.ly/artifactory/imgly")
}
}
include(":app")