Merge pull request #2943 from esensar/viewbinding-migration
Migrate to viewbinding and SDK 34
This commit is contained in:
commit
b7c4fd1c4e
77 changed files with 2349 additions and 1957 deletions
152
app/build.gradle
152
app/build.gradle
|
@ -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
135
app/build.gradle.kts
Normal 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")
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.simplemobiletools.gallery.pro"
|
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<!-- override the android:maxSdkVersion="28" from PhotoEditorSDK with some higher number -->
|
<!-- override the android:maxSdkVersion="28" from PhotoEditorSDK with some higher number -->
|
||||||
|
|
|
@ -36,6 +36,7 @@ import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.BuildConfig
|
import com.simplemobiletools.gallery.pro.BuildConfig
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
|
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.OtherAspectRatioDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.ResizeDialog
|
import com.simplemobiletools.gallery.pro.dialogs.ResizeDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
|
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.simplemobiletools.gallery.pro.models.FilterItem
|
||||||
import com.zomato.photofilters.FilterPack
|
import com.zomato.photofilters.FilterPack
|
||||||
import com.zomato.photofilters.imageprocessors.Filter
|
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 java.io.*
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||||
companion object {
|
companion object {
|
||||||
init {
|
init {
|
||||||
System.loadLibrary("NativeImageProcessor")
|
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 lateinit var saveUri: Uri
|
||||||
private var uri: Uri? = null
|
private var uri: Uri? = null
|
||||||
|
@ -92,10 +89,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
private var oldExif: ExifInterface? = null
|
private var oldExif: ExifInterface? = null
|
||||||
private var filterInitialBitmap: Bitmap? = null
|
private var filterInitialBitmap: Bitmap? = null
|
||||||
private var originalUri: Uri? = null
|
private var originalUri: Uri? = null
|
||||||
|
private val binding by viewBinding(ActivityEditBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_edit)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
|
@ -104,7 +102,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
handlePermission(getPermissionToRequest()) {
|
handlePermission(getPermissionToRequest()) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
initEditActivity()
|
initEditActivity()
|
||||||
|
@ -114,8 +112,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
isEditingWithThirdParty = false
|
isEditingWithThirdParty = false
|
||||||
bottom_draw_width.setColors(getProperTextColor(), getProperPrimaryColor(), getProperBackgroundColor())
|
binding.bottomEditorDrawActions.bottomDrawWidth.setColors(getProperTextColor(), getProperPrimaryColor(), getProperBackgroundColor())
|
||||||
setupToolbar(editor_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.editorToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
@ -126,7 +124,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
editor_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.editorToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.save_as -> saveImage()
|
R.id.save_as -> saveImage()
|
||||||
R.id.edit -> editWith()
|
R.id.edit -> editWith()
|
||||||
|
@ -172,8 +170,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
isCropIntent = intent.extras?.get(CROP) == "true"
|
isCropIntent = intent.extras?.get(CROP) == "true"
|
||||||
if (isCropIntent) {
|
if (isCropIntent) {
|
||||||
bottom_editor_primary_actions.beGone()
|
binding.bottomEditorPrimaryActions.root.beGone()
|
||||||
(bottom_editor_crop_rotate_actions.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1)
|
(binding.bottomEditorCropRotateActions.root.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadDefaultImageView()
|
loadDefaultImageView()
|
||||||
|
@ -191,14 +189,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
lastOtherAspectRatio = Pair(config.lastEditorCropOtherAspectRatioX, config.lastEditorCropOtherAspectRatioY)
|
lastOtherAspectRatio = Pair(config.lastEditorCropOtherAspectRatioX, config.lastEditorCropOtherAspectRatioY)
|
||||||
}
|
}
|
||||||
updateAspectRatio(config.lastEditorCropAspectRatio)
|
updateAspectRatio(config.lastEditorCropAspectRatio)
|
||||||
crop_image_view.guidelines = CropImageView.Guidelines.ON
|
binding.cropImageView.guidelines = CropImageView.Guidelines.ON
|
||||||
bottom_aspect_ratios.beVisible()
|
binding.bottomAspectRatios.root.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDefaultImageView() {
|
private fun loadDefaultImageView() {
|
||||||
default_image_view.beVisible()
|
binding.defaultImageView.beVisible()
|
||||||
crop_image_view.beGone()
|
binding.cropImageView.beGone()
|
||||||
editor_draw_canvas.beGone()
|
binding.editorDrawCanvas.beGone()
|
||||||
|
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.skipMemoryCache(true)
|
.skipMemoryCache(true)
|
||||||
|
@ -232,8 +230,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
bottomCropRotateClicked()
|
bottomCropRotateClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterInitialBitmap != null && currentFilter != null && currentFilter.filter.name != getString(R.string.none)) {
|
if (filterInitialBitmap != null && currentFilter != null && currentFilter.filter.name != getString(com.simplemobiletools.commons.R.string.none)) {
|
||||||
default_image_view.onGlobalLayout {
|
binding.defaultImageView.onGlobalLayout {
|
||||||
applyFilter(currentFilter)
|
applyFilter(currentFilter)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,19 +239,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCropIntent) {
|
if (isCropIntent) {
|
||||||
bottom_primary_filter.beGone()
|
binding.bottomEditorPrimaryActions.bottomPrimaryFilter.beGone()
|
||||||
bottom_primary_draw.beGone()
|
binding.bottomEditorPrimaryActions.bottomPrimaryDraw.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}).into(default_image_view)
|
}).into(binding.defaultImageView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadCropImageView() {
|
private fun loadCropImageView() {
|
||||||
default_image_view.beGone()
|
binding.defaultImageView.beGone()
|
||||||
editor_draw_canvas.beGone()
|
binding.editorDrawCanvas.beGone()
|
||||||
crop_image_view.apply {
|
binding.cropImageView.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
setOnCropImageCompleteListener(this@EditActivity)
|
setOnCropImageCompleteListener(this@EditActivity)
|
||||||
setImageUriAsync(uri)
|
setImageUriAsync(uri)
|
||||||
|
@ -262,19 +260,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
if (isCropIntent && shouldCropSquare()) {
|
if (isCropIntent && shouldCropSquare()) {
|
||||||
currAspectRatio = ASPECT_RATIO_ONE_ONE
|
currAspectRatio = ASPECT_RATIO_ONE_ONE
|
||||||
setFixedAspectRatio(true)
|
setFixedAspectRatio(true)
|
||||||
bottom_aspect_ratio.beGone()
|
binding.bottomEditorCropRotateActions.bottomAspectRatio.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDrawCanvas() {
|
private fun loadDrawCanvas() {
|
||||||
default_image_view.beGone()
|
binding.defaultImageView.beGone()
|
||||||
crop_image_view.beGone()
|
binding.cropImageView.beGone()
|
||||||
editor_draw_canvas.beVisible()
|
binding.editorDrawCanvas.beVisible()
|
||||||
|
|
||||||
if (!wasDrawCanvasPositioned) {
|
if (!wasDrawCanvasPositioned) {
|
||||||
wasDrawCanvasPositioned = true
|
wasDrawCanvasPositioned = true
|
||||||
editor_draw_canvas.onGlobalLayout {
|
binding.editorDrawCanvas.onGlobalLayout {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
fillCanvasBackground()
|
fillCanvasBackground()
|
||||||
}
|
}
|
||||||
|
@ -296,11 +294,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(uri)
|
.load(uri)
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.into(editor_draw_canvas.width, editor_draw_canvas.height)
|
.into(binding.editorDrawCanvas.width, binding.editorDrawCanvas.height)
|
||||||
|
|
||||||
val bitmap = builder.get()
|
val bitmap = builder.get()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
editor_draw_canvas.apply {
|
binding.editorDrawCanvas.apply {
|
||||||
updateBackgroundBitmap(bitmap)
|
updateBackgroundBitmap(bitmap)
|
||||||
layoutParams.width = bitmap.width
|
layoutParams.width = bitmap.width
|
||||||
layoutParams.height = bitmap.height
|
layoutParams.height = bitmap.height
|
||||||
|
@ -317,10 +315,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
private fun saveImage() {
|
private fun saveImage() {
|
||||||
setOldExif()
|
setOldExif()
|
||||||
|
|
||||||
if (crop_image_view.isVisible()) {
|
if (binding.cropImageView.isVisible()) {
|
||||||
crop_image_view.croppedImageAsync()
|
binding.cropImageView.croppedImageAsync()
|
||||||
} else if (editor_draw_canvas.isVisible()) {
|
} else if (binding.editorDrawCanvas.isVisible()) {
|
||||||
val bitmap = editor_draw_canvas.getBitmap()
|
val bitmap = binding.editorDrawCanvas.getBitmap()
|
||||||
if (saveUri.scheme == "file") {
|
if (saveUri.scheme == "file") {
|
||||||
SaveAsDialog(this, saveUri.path!!, true) {
|
SaveAsDialog(this, saveUri.path!!, true) {
|
||||||
saveBitmapToFile(bitmap, it, true)
|
saveBitmapToFile(bitmap, it, true)
|
||||||
|
@ -335,13 +333,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
val currentFilter = getFiltersAdapter()?.getCurrentFilter() ?: return
|
val currentFilter = getFiltersAdapter()?.getCurrentFilter() ?: return
|
||||||
val filePathGetter = getNewFilePath()
|
val filePathGetter = getNewFilePath()
|
||||||
SaveAsDialog(this, filePathGetter.first, filePathGetter.second) {
|
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
|
// clean up everything to free as much memory as possible
|
||||||
default_image_view.setImageResource(0)
|
binding.defaultImageView.setImageResource(0)
|
||||||
crop_image_view.setImageBitmap(null)
|
binding.cropImageView.setImageBitmap(null)
|
||||||
bottom_actions_filter_list.adapter = null
|
binding.bottomEditorFilterActions.bottomActionsFilterList.adapter = null
|
||||||
bottom_actions_filter_list.beGone()
|
binding.bottomEditorFilterActions.bottomActionsFilterList.beGone()
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
try {
|
try {
|
||||||
|
@ -349,7 +347,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
currentFilter.filter.processFilter(originalBitmap)
|
currentFilter.filter.processFilter(originalBitmap)
|
||||||
saveBitmapToFile(originalBitmap, it, false)
|
saveBitmapToFile(originalBitmap, it, false)
|
||||||
} catch (e: OutOfMemoryError) {
|
} 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() {
|
private fun shareImage() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
when {
|
when {
|
||||||
default_image_view.isVisible() -> {
|
binding.defaultImageView.isVisible() -> {
|
||||||
val currentFilter = getFiltersAdapter()?.getCurrentFilter()
|
val currentFilter = getFiltersAdapter()?.getCurrentFilter()
|
||||||
if (currentFilter == null) {
|
if (currentFilter == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return@ensureBackgroundThread
|
return@ensureBackgroundThread
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,13 +382,15 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
currentFilter.filter.processFilter(originalBitmap)
|
currentFilter.filter.processFilter(originalBitmap)
|
||||||
shareBitmap(originalBitmap)
|
shareBitmap(originalBitmap)
|
||||||
}
|
}
|
||||||
crop_image_view.isVisible() -> {
|
|
||||||
|
binding.cropImageView.isVisible() -> {
|
||||||
isSharingBitmap = true
|
isSharingBitmap = true
|
||||||
runOnUiThread {
|
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) {
|
if (it != null) {
|
||||||
sharePathIntent(it, BuildConfig.APPLICATION_ID)
|
sharePathIntent(it, BuildConfig.APPLICATION_ID)
|
||||||
} else {
|
} 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() {
|
private fun setupBottomActions() {
|
||||||
setupPrimaryActionButtons()
|
setupPrimaryActionButtons()
|
||||||
|
@ -445,18 +445,22 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPrimaryActionButtons() {
|
private fun setupPrimaryActionButtons() {
|
||||||
bottom_primary_filter.setOnClickListener {
|
binding.bottomEditorPrimaryActions.bottomPrimaryFilter.setOnClickListener {
|
||||||
bottomFilterClicked()
|
bottomFilterClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_primary_crop_rotate.setOnClickListener {
|
binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate.setOnClickListener {
|
||||||
bottomCropRotateClicked()
|
bottomCropRotateClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_primary_draw.setOnClickListener {
|
binding.bottomEditorPrimaryActions.bottomPrimaryDraw.setOnClickListener {
|
||||||
bottomDrawClicked()
|
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)
|
setupLongPress(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,59 +493,65 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCropRotateActionButtons() {
|
private fun setupCropRotateActionButtons() {
|
||||||
bottom_rotate.setOnClickListener {
|
binding.bottomEditorCropRotateActions.bottomRotate.setOnClickListener {
|
||||||
crop_image_view.rotateImage(90)
|
binding.cropImageView.rotateImage(90)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_resize.beGoneIf(isCropIntent)
|
binding.bottomEditorCropRotateActions.bottomResize.beGoneIf(isCropIntent)
|
||||||
bottom_resize.setOnClickListener {
|
binding.bottomEditorCropRotateActions.bottomResize.setOnClickListener {
|
||||||
resizeImage()
|
resizeImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_flip_horizontally.setOnClickListener {
|
binding.bottomEditorCropRotateActions.bottomFlipHorizontally.setOnClickListener {
|
||||||
crop_image_view.flipImageHorizontally()
|
binding.cropImageView.flipImageHorizontally()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_flip_vertically.setOnClickListener {
|
binding.bottomEditorCropRotateActions.bottomFlipVertically.setOnClickListener {
|
||||||
crop_image_view.flipImageVertically()
|
binding.cropImageView.flipImageVertically()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_aspect_ratio.setOnClickListener {
|
binding.bottomEditorCropRotateActions.bottomAspectRatio.setOnClickListener {
|
||||||
currCropRotateAction = if (currCropRotateAction == CROP_ROTATE_ASPECT_RATIO) {
|
currCropRotateAction = if (currCropRotateAction == CROP_ROTATE_ASPECT_RATIO) {
|
||||||
crop_image_view.guidelines = CropImageView.Guidelines.OFF
|
binding.cropImageView.guidelines = CropImageView.Guidelines.OFF
|
||||||
bottom_aspect_ratios.beGone()
|
binding.bottomAspectRatios.root.beGone()
|
||||||
CROP_ROTATE_NONE
|
CROP_ROTATE_NONE
|
||||||
} else {
|
} else {
|
||||||
crop_image_view.guidelines = CropImageView.Guidelines.ON
|
binding.cropImageView.guidelines = CropImageView.Guidelines.ON
|
||||||
bottom_aspect_ratios.beVisible()
|
binding.bottomAspectRatios.root.beVisible()
|
||||||
CROP_ROTATE_ASPECT_RATIO
|
CROP_ROTATE_ASPECT_RATIO
|
||||||
}
|
}
|
||||||
updateCropRotateActionButtons()
|
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)
|
setupLongPress(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAspectRatioButtons() {
|
private fun setupAspectRatioButtons() {
|
||||||
bottom_aspect_ratio_free.setOnClickListener {
|
binding.bottomAspectRatios.bottomAspectRatioFree.setOnClickListener {
|
||||||
updateAspectRatio(ASPECT_RATIO_FREE)
|
updateAspectRatio(ASPECT_RATIO_FREE)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_aspect_ratio_one_one.setOnClickListener {
|
binding.bottomAspectRatios.bottomAspectRatioOneOne.setOnClickListener {
|
||||||
updateAspectRatio(ASPECT_RATIO_ONE_ONE)
|
updateAspectRatio(ASPECT_RATIO_ONE_ONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_aspect_ratio_four_three.setOnClickListener {
|
binding.bottomAspectRatios.bottomAspectRatioFourThree.setOnClickListener {
|
||||||
updateAspectRatio(ASPECT_RATIO_FOUR_THREE)
|
updateAspectRatio(ASPECT_RATIO_FOUR_THREE)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_aspect_ratio_sixteen_nine.setOnClickListener {
|
binding.bottomAspectRatios.bottomAspectRatioSixteenNine.setOnClickListener {
|
||||||
updateAspectRatio(ASPECT_RATIO_SIXTEEN_NINE)
|
updateAspectRatio(ASPECT_RATIO_SIXTEEN_NINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_aspect_ratio_other.setOnClickListener {
|
binding.bottomAspectRatios.bottomAspectRatioOther.setOnClickListener {
|
||||||
OtherAspectRatioDialog(this, lastOtherAspectRatio) {
|
OtherAspectRatioDialog(this, lastOtherAspectRatio) {
|
||||||
lastOtherAspectRatio = it
|
lastOtherAspectRatio = it
|
||||||
config.lastEditorCropOtherAspectRatioX = it.first
|
config.lastEditorCropOtherAspectRatioX = it.first
|
||||||
|
@ -555,10 +565,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
private fun setupDrawButtons() {
|
private fun setupDrawButtons() {
|
||||||
updateDrawColor(config.lastEditorDrawColor)
|
updateDrawColor(config.lastEditorDrawColor)
|
||||||
bottom_draw_width.progress = config.lastEditorBrushSize
|
binding.bottomEditorDrawActions.bottomDrawWidth.progress = config.lastEditorBrushSize
|
||||||
updateBrushSize(config.lastEditorBrushSize)
|
updateBrushSize(config.lastEditorBrushSize)
|
||||||
|
|
||||||
bottom_draw_color_clickable.setOnClickListener {
|
binding.bottomEditorDrawActions.bottomDrawColorClickable.setOnClickListener {
|
||||||
ColorPickerDialog(this, drawColor) { wasPositivePressed, color ->
|
ColorPickerDialog(this, drawColor) { wasPositivePressed, color ->
|
||||||
if (wasPositivePressed) {
|
if (wasPositivePressed) {
|
||||||
updateDrawColor(color)
|
updateDrawColor(color)
|
||||||
|
@ -566,49 +576,53 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_draw_width.onSeekBarChangeListener {
|
binding.bottomEditorDrawActions.bottomDrawWidth.onSeekBarChangeListener {
|
||||||
config.lastEditorBrushSize = it
|
config.lastEditorBrushSize = it
|
||||||
updateBrushSize(it)
|
updateBrushSize(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_draw_undo.setOnClickListener {
|
binding.bottomEditorDrawActions.bottomDrawUndo.setOnClickListener {
|
||||||
editor_draw_canvas.undo()
|
binding.editorDrawCanvas.undo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBrushSize(percent: Int) {
|
private fun updateBrushSize(percent: Int) {
|
||||||
editor_draw_canvas.updateBrushSize(percent)
|
binding.editorDrawCanvas.updateBrushSize(percent)
|
||||||
val scale = Math.max(0.03f, percent / 100f)
|
val scale = max(0.03f, percent / 100f)
|
||||||
bottom_draw_color.scaleX = scale
|
binding.bottomEditorDrawActions.bottomDrawColor.scaleX = scale
|
||||||
bottom_draw_color.scaleY = scale
|
binding.bottomEditorDrawActions.bottomDrawColor.scaleY = scale
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePrimaryActionButtons() {
|
private fun updatePrimaryActionButtons() {
|
||||||
if (crop_image_view.isGone() && currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) {
|
if (binding.cropImageView.isGone() && currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) {
|
||||||
loadCropImageView()
|
loadCropImageView()
|
||||||
} else if (default_image_view.isGone() && currPrimaryAction == PRIMARY_ACTION_FILTER) {
|
} else if (binding.defaultImageView.isGone() && currPrimaryAction == PRIMARY_ACTION_FILTER) {
|
||||||
loadDefaultImageView()
|
loadDefaultImageView()
|
||||||
} else if (editor_draw_canvas.isGone() && currPrimaryAction == PRIMARY_ACTION_DRAW) {
|
} else if (binding.editorDrawCanvas.isGone() && currPrimaryAction == PRIMARY_ACTION_DRAW) {
|
||||||
loadDrawCanvas()
|
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)
|
it.applyColorFilter(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentPrimaryActionButton = when (currPrimaryAction) {
|
val currentPrimaryActionButton = when (currPrimaryAction) {
|
||||||
PRIMARY_ACTION_FILTER -> bottom_primary_filter
|
PRIMARY_ACTION_FILTER -> binding.bottomEditorPrimaryActions.bottomPrimaryFilter
|
||||||
PRIMARY_ACTION_CROP_ROTATE -> bottom_primary_crop_rotate
|
PRIMARY_ACTION_CROP_ROTATE -> binding.bottomEditorPrimaryActions.bottomPrimaryCropRotate
|
||||||
PRIMARY_ACTION_DRAW -> bottom_primary_draw
|
PRIMARY_ACTION_DRAW -> binding.bottomEditorPrimaryActions.bottomPrimaryDraw
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPrimaryActionButton?.applyColorFilter(getProperPrimaryColor())
|
currentPrimaryActionButton?.applyColorFilter(getProperPrimaryColor())
|
||||||
bottom_editor_filter_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER)
|
binding.bottomEditorFilterActions.root.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_FILTER)
|
||||||
bottom_editor_crop_rotate_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE)
|
binding.bottomEditorCropRotateActions.root.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE)
|
||||||
bottom_editor_draw_actions.beVisibleIf(currPrimaryAction == PRIMARY_ACTION_DRAW)
|
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 {
|
ensureBackgroundThread {
|
||||||
val thumbnailSize = resources.getDimension(R.dimen.bottom_filters_thumbnail_size).toInt()
|
val thumbnailSize = resources.getDimension(R.dimen.bottom_filters_thumbnail_size).toInt()
|
||||||
|
|
||||||
|
@ -641,7 +655,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
val filterThumbnailsManager = FilterThumbnailsManager()
|
val filterThumbnailsManager = FilterThumbnailsManager()
|
||||||
filterThumbnailsManager.clearThumbs()
|
filterThumbnailsManager.clearThumbs()
|
||||||
|
|
||||||
val noFilter = Filter(getString(R.string.none))
|
val noFilter = Filter(getString(com.simplemobiletools.commons.R.string.none))
|
||||||
filterThumbnailsManager.addThumb(FilterItem(bitmap, noFilter))
|
filterThumbnailsManager.addThumb(FilterItem(bitmap, noFilter))
|
||||||
|
|
||||||
FilterPack.getFilterPack(this).forEach {
|
FilterPack.getFilterPack(this).forEach {
|
||||||
|
@ -651,24 +665,24 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
val filterItems = filterThumbnailsManager.processThumbs()
|
val filterItems = filterThumbnailsManager.processThumbs()
|
||||||
val adapter = FiltersAdapter(applicationContext, filterItems) {
|
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])
|
applyFilter(filterItems[it])
|
||||||
|
|
||||||
if (it == layoutManager.findLastCompletelyVisibleItemPosition() || it == layoutManager.findLastVisibleItemPosition()) {
|
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()) {
|
} 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()
|
adapter.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currPrimaryAction != PRIMARY_ACTION_CROP_ROTATE) {
|
if (currPrimaryAction != PRIMARY_ACTION_CROP_ROTATE) {
|
||||||
bottom_aspect_ratios.beGone()
|
binding.bottomAspectRatios.root.beGone()
|
||||||
currCropRotateAction = CROP_ROTATE_NONE
|
currCropRotateAction = CROP_ROTATE_NONE
|
||||||
}
|
}
|
||||||
updateCropRotateActionButtons()
|
updateCropRotateActionButtons()
|
||||||
|
@ -676,7 +690,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
private fun applyFilter(filterItem: FilterItem) {
|
private fun applyFilter(filterItem: FilterItem) {
|
||||||
val newBitmap = Bitmap.createBitmap(filterInitialBitmap!!)
|
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) {
|
private fun updateAspectRatio(aspectRatio: Int) {
|
||||||
|
@ -684,7 +698,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
config.lastEditorCropAspectRatio = aspectRatio
|
config.lastEditorCropAspectRatio = aspectRatio
|
||||||
updateAspectRatioButtons()
|
updateAspectRatioButtons()
|
||||||
|
|
||||||
crop_image_view.apply {
|
binding.cropImageView.apply {
|
||||||
if (aspectRatio == ASPECT_RATIO_FREE) {
|
if (aspectRatio == ASPECT_RATIO_FREE) {
|
||||||
setFixedAspectRatio(false)
|
setFixedAspectRatio(false)
|
||||||
} else {
|
} else {
|
||||||
|
@ -702,33 +716,33 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
private fun updateAspectRatioButtons() {
|
private fun updateAspectRatioButtons() {
|
||||||
arrayOf(
|
arrayOf(
|
||||||
bottom_aspect_ratio_free,
|
binding.bottomAspectRatios.bottomAspectRatioFree,
|
||||||
bottom_aspect_ratio_one_one,
|
binding.bottomAspectRatios.bottomAspectRatioOneOne,
|
||||||
bottom_aspect_ratio_four_three,
|
binding.bottomAspectRatios.bottomAspectRatioFourThree,
|
||||||
bottom_aspect_ratio_sixteen_nine,
|
binding.bottomAspectRatios.bottomAspectRatioSixteenNine,
|
||||||
bottom_aspect_ratio_other
|
binding.bottomAspectRatios.bottomAspectRatioOther,
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextColor(Color.WHITE)
|
it.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentAspectRatioButton = when (currAspectRatio) {
|
val currentAspectRatioButton = when (currAspectRatio) {
|
||||||
ASPECT_RATIO_FREE -> bottom_aspect_ratio_free
|
ASPECT_RATIO_FREE -> binding.bottomAspectRatios.bottomAspectRatioFree
|
||||||
ASPECT_RATIO_ONE_ONE -> bottom_aspect_ratio_one_one
|
ASPECT_RATIO_ONE_ONE -> binding.bottomAspectRatios.bottomAspectRatioOneOne
|
||||||
ASPECT_RATIO_FOUR_THREE -> bottom_aspect_ratio_four_three
|
ASPECT_RATIO_FOUR_THREE -> binding.bottomAspectRatios.bottomAspectRatioFourThree
|
||||||
ASPECT_RATIO_SIXTEEN_NINE -> bottom_aspect_ratio_sixteen_nine
|
ASPECT_RATIO_SIXTEEN_NINE -> binding.bottomAspectRatios.bottomAspectRatioSixteenNine
|
||||||
else -> bottom_aspect_ratio_other
|
else -> binding.bottomAspectRatios.bottomAspectRatioOther
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAspectRatioButton.setTextColor(getProperPrimaryColor())
|
currentAspectRatioButton.setTextColor(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateCropRotateActionButtons() {
|
private fun updateCropRotateActionButtons() {
|
||||||
arrayOf(bottom_aspect_ratio).forEach {
|
arrayOf(binding.bottomEditorCropRotateActions.bottomAspectRatio).forEach {
|
||||||
it.applyColorFilter(Color.WHITE)
|
it.applyColorFilter(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
val primaryActionView = when (currCropRotateAction) {
|
val primaryActionView = when (currCropRotateAction) {
|
||||||
CROP_ROTATE_ASPECT_RATIO -> bottom_aspect_ratio
|
CROP_ROTATE_ASPECT_RATIO -> binding.bottomEditorCropRotateActions.bottomAspectRatio
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,22 +751,22 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
|
|
||||||
private fun updateDrawColor(color: Int) {
|
private fun updateDrawColor(color: Int) {
|
||||||
drawColor = color
|
drawColor = color
|
||||||
bottom_draw_color.applyColorFilter(color)
|
binding.bottomEditorDrawActions.bottomDrawColor.applyColorFilter(color)
|
||||||
config.lastEditorDrawColor = color
|
config.lastEditorDrawColor = color
|
||||||
editor_draw_canvas.updateColor(color)
|
binding.editorDrawCanvas.updateColor(color)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resizeImage() {
|
private fun resizeImage() {
|
||||||
val point = getAreaSize()
|
val point = getAreaSize()
|
||||||
if (point == null) {
|
if (point == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ResizeDialog(this, point) {
|
ResizeDialog(this, point) {
|
||||||
resizeWidth = it.x
|
resizeWidth = it.x
|
||||||
resizeHeight = it.y
|
resizeHeight = it.y
|
||||||
crop_image_view.croppedImageAsync()
|
binding.cropImageView.croppedImageAsync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,8 +780,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAreaSize(): Point? {
|
private fun getAreaSize(): Point? {
|
||||||
val rect = crop_image_view.cropRect ?: return null
|
val rect = binding.cropImageView.cropRect ?: return null
|
||||||
val rotation = crop_image_view.rotatedDegrees
|
val rotation = binding.cropImageView.rotatedDegrees
|
||||||
return if (rotation == 0 || rotation == 180) {
|
return if (rotation == 0 || rotation == 180) {
|
||||||
Point(rect.width(), rect.height())
|
Point(rect.width(), rect.height())
|
||||||
} else {
|
} else {
|
||||||
|
@ -861,7 +875,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
val label =
|
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()
|
"sknahT .moc.slootelibomelpmis.www morf eno lanigiro eht daolnwod ytefas nwo ruoy roF .ppa eht fo noisrev ekaf a gnisu era uoY".reversed()
|
||||||
runOnUiThread {
|
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())
|
launchViewIntent("6629852208836920709=di?ved/sppa/erots/moc.elgoog.yalp//:sptth".reversed())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -889,14 +903,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
} catch (e: OutOfMemoryError) {
|
} 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)
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) {
|
private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) {
|
||||||
if (showSavingToast) {
|
if (showSavingToast) {
|
||||||
toast(R.string.saving)
|
toast(com.simplemobiletools.commons.R.string.saving)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resizeWidth > 0 && resizeHeight > 0) {
|
if (resizeWidth > 0 && resizeHeight > 0) {
|
||||||
|
@ -929,7 +943,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
rescanPaths(paths) {
|
rescanPaths(paths) {
|
||||||
fixDateTaken(paths, false)
|
fixDateTaken(paths, false)
|
||||||
setResult(Activity.RESULT_OK, intent)
|
setResult(Activity.RESULT_OK, intent)
|
||||||
toast(R.string.file_saved)
|
toast(com.simplemobiletools.commons.R.string.file_saved)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,42 +2,41 @@ package com.simplemobiletools.gallery.pro.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
|
||||||
import com.simplemobiletools.commons.extensions.internalStoragePath
|
|
||||||
import com.simplemobiletools.commons.extensions.isExternalStorageManager
|
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter
|
import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.ActivityManageFoldersBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
|
||||||
|
|
||||||
class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_manage_folders)
|
setContentView(binding.root)
|
||||||
updateFolders()
|
updateFolders()
|
||||||
setupOptionsMenu()
|
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)
|
updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar)
|
setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFolders() {
|
private fun updateFolders() {
|
||||||
val folders = ArrayList<String>()
|
val folders = ArrayList<String>()
|
||||||
config.excludedFolders.mapTo(folders) { it }
|
config.excludedFolders.mapTo(folders) { it }
|
||||||
var placeholderText = getString(R.string.excluded_activity_placeholder)
|
var placeholderText = getString(R.string.excluded_activity_placeholder)
|
||||||
manage_folders_placeholder.apply {
|
binding.manageFoldersPlaceholder.apply {
|
||||||
beVisibleIf(folders.isEmpty())
|
beVisibleIf(folders.isEmpty())
|
||||||
setTextColor(getProperTextColor())
|
setTextColor(getProperTextColor())
|
||||||
|
|
||||||
|
@ -48,12 +47,12 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
text = placeholderText
|
text = placeholderText
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = ManageFoldersAdapter(this, folders, true, this, manage_folders_list) {}
|
val adapter = ManageFoldersAdapter(this, folders, true, this, binding.manageFoldersList) {}
|
||||||
manage_folders_list.adapter = adapter
|
binding.manageFoldersList.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
manage_folders_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.add_folder -> addFolder()
|
R.id.add_folder -> addFolder()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
|
|
@ -4,52 +4,54 @@ import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
|
import com.simplemobiletools.commons.extensions.viewBinding
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.ManageHiddenFoldersAdapter
|
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.addNoMedia
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.getNoMediaFolders
|
import com.simplemobiletools.gallery.pro.extensions.getNoMediaFolders
|
||||||
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
|
||||||
|
|
||||||
class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class HiddenFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_manage_folders)
|
setContentView(binding.root)
|
||||||
updateFolders()
|
updateFolders()
|
||||||
setupOptionsMenu()
|
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)
|
updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar)
|
setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFolders() {
|
private fun updateFolders() {
|
||||||
getNoMediaFolders {
|
getNoMediaFolders {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
manage_folders_placeholder.apply {
|
binding.manageFoldersPlaceholder.apply {
|
||||||
text = getString(R.string.hidden_folders_placeholder)
|
text = getString(R.string.hidden_folders_placeholder)
|
||||||
beVisibleIf(it.isEmpty())
|
beVisibleIf(it.isEmpty())
|
||||||
setTextColor(getProperTextColor())
|
setTextColor(getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = ManageHiddenFoldersAdapter(this, it, this, manage_folders_list) {}
|
val adapter = ManageHiddenFoldersAdapter(this, it, this, binding.manageFoldersList) {}
|
||||||
manage_folders_list.adapter = adapter
|
binding.manageFoldersList.adapter = adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
manage_folders_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.add_folder -> addFolder()
|
R.id.add_folder -> addFolder()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
|
|
@ -3,47 +3,50 @@ package com.simplemobiletools.gallery.pro.activities
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
|
import com.simplemobiletools.commons.extensions.viewBinding
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter
|
import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.ActivityManageFoldersBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_manage_folders.*
|
|
||||||
|
|
||||||
class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityManageFoldersBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_manage_folders)
|
setContentView(binding.root)
|
||||||
updateFolders()
|
updateFolders()
|
||||||
setupOptionsMenu()
|
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)
|
updateMaterialActivityViews(binding.manageFoldersCoordinator, binding.manageFoldersList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(manage_folders_list, manage_folders_toolbar)
|
setupMaterialScrollListener(binding.manageFoldersList, binding.manageFoldersToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_folders_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageFoldersToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFolders() {
|
private fun updateFolders() {
|
||||||
val folders = ArrayList<String>()
|
val folders = ArrayList<String>()
|
||||||
config.includedFolders.mapTo(folders) { it }
|
config.includedFolders.mapTo(folders) { it }
|
||||||
manage_folders_placeholder.apply {
|
binding.manageFoldersPlaceholder.apply {
|
||||||
text = getString(R.string.included_activity_placeholder)
|
text = getString(R.string.included_activity_placeholder)
|
||||||
beVisibleIf(folders.isEmpty())
|
beVisibleIf(folders.isEmpty())
|
||||||
setTextColor(getProperTextColor())
|
setTextColor(getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = ManageFoldersAdapter(this, folders, false, this, manage_folders_list) {}
|
val adapter = ManageFoldersAdapter(this, folders, false, this, binding.manageFoldersList) {}
|
||||||
manage_folders_list.adapter = adapter
|
binding.manageFoldersList.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
manage_folders_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.manageFoldersToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.add_folder -> addFolder()
|
R.id.add_folder -> addFolder()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.pro.BuildConfig
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter
|
import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter
|
||||||
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
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.ChangeSortingDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog
|
import com.simplemobiletools.gallery.pro.dialogs.ChangeViewTypeDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.FilterMediaDialog
|
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.jobs.NewPhotoFetcher
|
||||||
import com.simplemobiletools.gallery.pro.models.Directory
|
import com.simplemobiletools.gallery.pro.models.Directory
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private val PICK_MEDIA = 2
|
companion object {
|
||||||
private val PICK_WALLPAPER = 3
|
private const val PICK_MEDIA = 2
|
||||||
private val LAST_MEDIA_CHECK_PERIOD = 3000L
|
private const val PICK_WALLPAPER = 3
|
||||||
|
private const val LAST_MEDIA_CHECK_PERIOD = 3000L
|
||||||
|
}
|
||||||
|
|
||||||
private var mIsPickImageIntent = false
|
private var mIsPickImageIntent = false
|
||||||
private var mIsPickVideoIntent = false
|
private var mIsPickVideoIntent = false
|
||||||
|
@ -81,11 +83,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private var mStoredTextColor = 0
|
private var mStoredTextColor = 0
|
||||||
private var mStoredPrimaryColor = 0
|
private var mStoredPrimaryColor = 0
|
||||||
private var mStoredStyleString = ""
|
private var mStoredStyleString = ""
|
||||||
|
private val binding by viewBinding(ActivityMainBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
@ -111,9 +114,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
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()
|
storeStateVariables()
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
|
|
||||||
|
@ -146,14 +154,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
updateWidgets()
|
updateWidgets()
|
||||||
registerFileUpdateListener()
|
registerFileUpdateListener()
|
||||||
|
|
||||||
directories_switch_searching.setOnClickListener {
|
binding.directoriesSwitchSearching.setOnClickListener {
|
||||||
launchSearchActivity()
|
launchSearchActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
// just request the permission, tryLoadGallery will then trigger in onResume
|
// just request the permission, tryLoadGallery will then trigger in onResume
|
||||||
handleMediaPermissions { success ->
|
handleMediaPermissions { success ->
|
||||||
if (!success) {
|
if (!success) {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +208,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
directories_grid.adapter = null
|
binding.directoriesGrid.adapter = null
|
||||||
getDirectories()
|
getDirectories()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,20 +226,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
setupAdapter(mDirs, forceRecreate = true)
|
setupAdapter(mDirs, forceRecreate = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
directories_fastscroller.updateColors(primaryColor)
|
binding.directoriesFastscroller.updateColors(primaryColor)
|
||||||
directories_refresh_layout.isEnabled = config.enablePullToRefresh
|
binding.directoriesRefreshLayout.isEnabled = config.enablePullToRefresh
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
dateFormat = config.dateFormat
|
dateFormat = config.dateFormat
|
||||||
timeFormat = getTimeFormat()
|
timeFormat = getTimeFormat()
|
||||||
}
|
}
|
||||||
|
|
||||||
directories_empty_placeholder.setTextColor(getProperTextColor())
|
binding.directoriesEmptyPlaceholder.setTextColor(getProperTextColor())
|
||||||
directories_empty_placeholder_2.setTextColor(primaryColor)
|
binding.directoriesEmptyPlaceholder2.setTextColor(primaryColor)
|
||||||
directories_switch_searching.setTextColor(primaryColor)
|
binding.directoriesSwitchSearching.setTextColor(primaryColor)
|
||||||
directories_switch_searching.underlineText()
|
binding.directoriesSwitchSearching.underlineText()
|
||||||
directories_empty_placeholder_2.bringToFront()
|
binding.directoriesEmptyPlaceholder2.bringToFront()
|
||||||
|
|
||||||
if (!main_menu.isSearchOpen) {
|
if (!binding.mainMenu.isSearchOpen) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
|
if (mIsPasswordProtectionPending && !mWasProtectionHandled) {
|
||||||
handleAppPasswordProtection {
|
handleAppPasswordProtection {
|
||||||
|
@ -249,15 +257,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.searchAllFilesByDefault) {
|
if (config.searchAllFilesByDefault) {
|
||||||
main_menu.updateHintText(getString(R.string.search_files))
|
binding.mainMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_files))
|
||||||
} else {
|
} else {
|
||||||
main_menu.updateHintText(getString(R.string.search_folders))
|
binding.mainMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_folders))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
directories_refresh_layout.isRefreshing = false
|
binding.directoriesRefreshLayout.isRefreshing = false
|
||||||
mIsGettingDirs = false
|
mIsGettingDirs = false
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -297,8 +305,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
} else if (config.groupDirectSubfolders) {
|
} else if (config.groupDirectSubfolders) {
|
||||||
if (mCurrentPathPrefix.isEmpty()) {
|
if (mCurrentPathPrefix.isEmpty()) {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
@ -345,15 +353,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
if (!mIsThirdPartyIntent) {
|
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.column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
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.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.temporarily_show_hidden).isVisible = !config.shouldShowHidden
|
||||||
findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
|
findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden
|
||||||
|
|
||||||
|
@ -369,23 +377,23 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
R.menu.menu_main
|
R.menu.menu_main
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.getToolbar().inflateMenu(menuId)
|
binding.mainMenu.getToolbar().inflateMenu(menuId)
|
||||||
main_menu.toggleHideOnScroll(!config.scrollHorizontally)
|
binding.mainMenu.toggleHideOnScroll(!config.scrollHorizontally)
|
||||||
main_menu.setupMenu()
|
binding.mainMenu.setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchOpenListener = {
|
binding.mainMenu.onSearchOpenListener = {
|
||||||
if (config.searchAllFilesByDefault) {
|
if (config.searchAllFilesByDefault) {
|
||||||
launchSearchActivity()
|
launchSearchActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.onSearchTextChangedListener = { text ->
|
binding.mainMenu.onSearchTextChangedListener = { text ->
|
||||||
setupAdapter(mDirsIgnoringSearch, text)
|
setupAdapter(mDirsIgnoringSearch, text)
|
||||||
directories_refresh_layout.isEnabled = text.isEmpty() && config.enablePullToRefresh
|
binding.directoriesRefreshLayout.isEnabled = text.isEmpty() && config.enablePullToRefresh
|
||||||
directories_switch_searching.beVisibleIf(text.isNotEmpty())
|
binding.directoriesSwitchSearching.beVisibleIf(text.isNotEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
binding.mainMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.filter -> showFilterMediaDialog()
|
R.id.filter -> showFilterMediaDialog()
|
||||||
|
@ -421,10 +429,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
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() {
|
private fun storeStateVariables() {
|
||||||
mStoredTextColor = getProperTextColor()
|
mStoredTextColor = getProperTextColor()
|
||||||
|
@ -451,7 +459,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
val newFolder = File(config.tempFolderPath)
|
val newFolder = File(config.tempFolderPath)
|
||||||
if (getDoesFilePathExist(newFolder.absolutePath) && newFolder.isDirectory) {
|
if (getDoesFilePathExist(newFolder.absolutePath) && newFolder.isDirectory) {
|
||||||
if (newFolder.getProperSize(true) == 0L && newFolder.getFileCount(true) == 0 && newFolder.list()?.isEmpty() == true) {
|
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)
|
tryDeleteFileDirItem(newFolder.toFileDirItem(applicationContext), true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,7 +511,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPackageInstalled("com.simplemobiletools.gallery")) {
|
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()
|
checkOTGPath()
|
||||||
|
@ -517,7 +532,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,14 +559,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.postDelayed({
|
binding.mainMenu.postDelayed({
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showSortingDialog() {
|
private fun showSortingDialog() {
|
||||||
ChangeSortingDialog(this, true, false) {
|
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) {
|
if (config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || config.directorySorting and SORT_BY_DATE_TAKEN != 0) {
|
||||||
getDirectories()
|
getDirectories()
|
||||||
} else {
|
} else {
|
||||||
|
@ -567,8 +582,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun showFilterMediaDialog() {
|
private fun showFilterMediaDialog() {
|
||||||
FilterMediaDialog(this) {
|
FilterMediaDialog(this) {
|
||||||
mShouldStopFetching = true
|
mShouldStopFetching = true
|
||||||
directories_refresh_layout.isRefreshing = true
|
binding.directoriesRefreshLayout.isRefreshing = true
|
||||||
directories_grid.adapter = null
|
binding.directoriesGrid.adapter = null
|
||||||
getDirectories()
|
getDirectories()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +607,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
ChangeViewTypeDialog(this, true) {
|
ChangeViewTypeDialog(this, true) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
directories_grid.adapter = null
|
binding.directoriesGrid.adapter = null
|
||||||
setupAdapter(getRecyclerAdapter()?.dirs ?: mDirs)
|
setupAdapter(getRecyclerAdapter()?.dirs ?: mDirs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -614,7 +629,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun toggleTemporarilyShowHidden(show: Boolean) {
|
private fun toggleTemporarilyShowHidden(show: Boolean) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
config.temporarilyShowHidden = show
|
config.temporarilyShowHidden = show
|
||||||
directories_grid.adapter = null
|
binding.directoriesGrid.adapter = null
|
||||||
getDirectories()
|
getDirectories()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
@ -632,7 +647,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun toggleTemporarilyShowExcluded(show: Boolean) {
|
private fun toggleTemporarilyShowExcluded(show: Boolean) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
config.temporarilyShowExcluded = show
|
config.temporarilyShowExcluded = show
|
||||||
directories_grid.adapter = null
|
binding.directoriesGrid.adapter = null
|
||||||
getDirectories()
|
getDirectories()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
@ -644,14 +659,15 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
fileDirItems.isEmpty() -> return
|
fileDirItems.isEmpty() -> return
|
||||||
fileDirItems.size == 1 -> {
|
fileDirItems.size == 1 -> {
|
||||||
try {
|
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) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
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)
|
val deletingItems = resources.getQuantityString(baseString, fileDirItems.size, fileDirItems.size)
|
||||||
toast(deletingItems)
|
toast(deletingItems)
|
||||||
}
|
}
|
||||||
|
@ -680,7 +696,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (it) {
|
if (it) {
|
||||||
deleteFilteredFileDirItems(itemsToDelete, folders)
|
deleteFilteredFileDirItems(itemsToDelete, folders)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -717,33 +733,35 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
setupListLayoutManager()
|
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() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = RecyclerView.HORIZONTAL
|
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 {
|
} else {
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
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
|
layoutManager.spanCount = config.dirColumnCnt
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
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
|
mZoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initZoomListener() {
|
private fun initZoomListener() {
|
||||||
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.directoriesGrid.layoutManager as MyGridLayoutManager
|
||||||
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -778,10 +796,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
private fun changeColumnCount() {
|
private fun changeColumnCount() {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in 1..MAX_COLUMN_COUNT) {
|
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) {
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
val newColumnCount = it as Int
|
val newColumnCount = it as Int
|
||||||
if (currentColumnCount != newColumnCount) {
|
if (currentColumnCount != newColumnCount) {
|
||||||
|
@ -802,7 +820,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
private fun columnCountChanged() {
|
||||||
(directories_grid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt
|
(binding.directoriesGrid.layoutManager as MyGridLayoutManager).spanCount = config.dirColumnCnt
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, dirs.size)
|
notifyItemRangeChanged(0, dirs.size)
|
||||||
|
@ -953,7 +971,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (mediaDB.getDeletedMediaCount() > 0) {
|
if (mediaDB.getDeletedMediaCount() > 0) {
|
||||||
val recycleBin = Directory().apply {
|
val recycleBin = Directory().apply {
|
||||||
path = RECYCLE_BIN
|
path = RECYCLE_BIN
|
||||||
name = getString(R.string.recycle_bin)
|
name = getString(com.simplemobiletools.commons.R.string.recycle_bin)
|
||||||
location = LOCATION_INTERNAL
|
location = LOCATION_INTERNAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +985,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (mediaDB.getFavoritesCount() > 0) {
|
if (mediaDB.getFavoritesCount() > 0) {
|
||||||
val favorites = Directory().apply {
|
val favorites = Directory().apply {
|
||||||
path = FAVORITES
|
path = FAVORITES
|
||||||
name = getString(R.string.favorites)
|
name = getString(com.simplemobiletools.commons.R.string.favorites)
|
||||||
location = LOCATION_INTERNAL
|
location = LOCATION_INTERNAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,9 +1132,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (isPlaceholderVisible) {
|
if (isPlaceholderVisible) {
|
||||||
isPlaceholderVisible = false
|
isPlaceholderVisible = false
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
directories_empty_placeholder.beGone()
|
binding.directoriesEmptyPlaceholder.beGone()
|
||||||
directories_empty_placeholder_2.beGone()
|
binding.directoriesEmptyPlaceholder2.beGone()
|
||||||
directories_fastscroller.beVisible()
|
binding.directoriesFastscroller.beVisible()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,7 +1160,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
directories_refresh_layout.isRefreshing = false
|
binding.directoriesRefreshLayout.isRefreshing = false
|
||||||
checkPlaceholderVisibility(dirs)
|
checkPlaceholderVisibility(dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,41 +1219,41 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) {
|
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) {
|
||||||
directories_empty_placeholder.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos)
|
binding.directoriesEmptyPlaceholder.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos)
|
||||||
directories_empty_placeholder_2.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos)
|
binding.directoriesEmptyPlaceholder2.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos)
|
||||||
|
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
binding.directoriesEmptyPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
directories_empty_placeholder_2.beGone()
|
binding.directoriesEmptyPlaceholder2.beGone()
|
||||||
} else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) {
|
} else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) {
|
||||||
if (isRPlus() && !isExternalStorageManager()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_items_found)
|
binding.directoriesEmptyPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
directories_empty_placeholder_2.beGone()
|
binding.directoriesEmptyPlaceholder2.beGone()
|
||||||
} else {
|
} else {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_media_add_included)
|
binding.directoriesEmptyPlaceholder.text = getString(R.string.no_media_add_included)
|
||||||
directories_empty_placeholder_2.text = getString(R.string.add_folder)
|
binding.directoriesEmptyPlaceholder2.text = getString(R.string.add_folder)
|
||||||
}
|
}
|
||||||
|
|
||||||
directories_empty_placeholder_2.setOnClickListener {
|
binding.directoriesEmptyPlaceholder2.setOnClickListener {
|
||||||
showAddIncludedFolderDialog {
|
showAddIncludedFolderDialog {
|
||||||
refreshItems()
|
refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
directories_empty_placeholder.text = getString(R.string.no_media_with_filters)
|
binding.directoriesEmptyPlaceholder.text = getString(R.string.no_media_with_filters)
|
||||||
directories_empty_placeholder_2.text = getString(R.string.change_filters_underlined)
|
binding.directoriesEmptyPlaceholder2.text = getString(R.string.change_filters_underlined)
|
||||||
|
|
||||||
directories_empty_placeholder_2.setOnClickListener {
|
binding.directoriesEmptyPlaceholder2.setOnClickListener {
|
||||||
showFilterMediaDialog()
|
showFilterMediaDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
directories_empty_placeholder_2.underlineText()
|
binding.directoriesEmptyPlaceholder2.underlineText()
|
||||||
directories_fastscroller.beVisibleIf(directories_empty_placeholder.isGone())
|
binding.directoriesFastscroller.beVisibleIf(binding.directoriesEmptyPlaceholder.isGone())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAdapter(dirs: ArrayList<Directory>, textToSearch: String = main_menu.getCurrentQuery(), forceRecreate: Boolean = false) {
|
private fun setupAdapter(dirs: ArrayList<Directory>, textToSearch: String = binding.mainMenu.getCurrentQuery(), forceRecreate: Boolean = false) {
|
||||||
val currAdapter = directories_grid.adapter
|
val currAdapter = binding.directoriesGrid.adapter
|
||||||
val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList<Directory>
|
val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList<Directory>
|
||||||
val sortedDirs = getSortedDirectories(distinctDirs)
|
val sortedDirs = getSortedDirectories(distinctDirs)
|
||||||
var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList<Directory>
|
var dirsToShow = getDirsToShow(sortedDirs, mDirs, mCurrentPathPrefix).clone() as ArrayList<Directory>
|
||||||
|
@ -1247,9 +1265,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
this,
|
this,
|
||||||
dirsToShow,
|
dirsToShow,
|
||||||
this,
|
this,
|
||||||
directories_grid,
|
binding.directoriesGrid,
|
||||||
isPickIntent(intent) || isGetAnyContentIntent(intent),
|
isPickIntent(intent) || isGetAnyContentIntent(intent),
|
||||||
directories_refresh_layout
|
binding.directoriesRefreshLayout
|
||||||
) {
|
) {
|
||||||
val clickedDir = it as Directory
|
val clickedDir = it as Directory
|
||||||
val path = clickedDir.path
|
val path = clickedDir.path
|
||||||
|
@ -1265,11 +1283,11 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}.apply {
|
}.apply {
|
||||||
setupZoomListener(mZoomListener)
|
setupZoomListener(mZoomListener)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
directories_grid.adapter = this
|
binding.directoriesGrid.adapter = this
|
||||||
setupScrollDirection()
|
setupScrollDirection()
|
||||||
|
|
||||||
if (config.viewTypeFolders == VIEW_TYPE_LIST && areSystemAnimationsEnabled) {
|
if (config.viewTypeFolders == VIEW_TYPE_LIST && areSystemAnimationsEnabled) {
|
||||||
directories_grid.scheduleLayoutAnimation()
|
binding.directoriesGrid.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1281,19 +1299,19 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
checkPlaceholderVisibility(dirsToShow)
|
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
|
// recyclerview sometimes becomes empty at init/update, triggering an invisible refresh like this seems to work fine
|
||||||
directories_grid.postDelayed({
|
binding.directoriesGrid.postDelayed({
|
||||||
directories_grid.scrollBy(0, 0)
|
binding.directoriesGrid.scrollBy(0, 0)
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupScrollDirection() {
|
private fun setupScrollDirection() {
|
||||||
val scrollHorizontally = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID
|
val scrollHorizontally = config.scrollHorizontally && config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
directories_fastscroller.setScrollVertically(!scrollHorizontally)
|
binding.directoriesFastscroller.setScrollVertically(!scrollHorizontally)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkInvalidDirectories(dirs: ArrayList<Directory>) {
|
private fun checkInvalidDirectories(dirs: ArrayList<Directory>) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||||
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
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.dialogs.*
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
||||||
import kotlinx.android.synthetic.main.activity_media.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private var mStoredPrimaryColor = 0
|
private var mStoredPrimaryColor = 0
|
||||||
private var mStoredThumbnailSpacing = 0
|
private var mStoredThumbnailSpacing = 0
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityMediaBinding::inflate)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var mMedia = ArrayList<ThumbnailItem>()
|
var mMedia = ArrayList<ThumbnailItem>()
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_media)
|
setContentView(binding.root)
|
||||||
|
|
||||||
intent.apply {
|
intent.apply {
|
||||||
mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false)
|
mIsGetImageIntent = getBooleanExtra(GET_IMAGE_INTENT, false)
|
||||||
|
@ -86,7 +88,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
mAllowPickingMultiple = getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
mAllowPickingMultiple = getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
media_refresh_layout.setOnRefreshListener { getMedia() }
|
binding.mediaRefreshLayout.setOnRefreshListener { getMedia() }
|
||||||
try {
|
try {
|
||||||
mPath = intent.getStringExtra(DIRECTORY) ?: ""
|
mPath = intent.getStringExtra(DIRECTORY) ?: ""
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -98,17 +100,24 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
updateMaterialActivityViews(media_coordinator, media_grid, useTransparentNavigation = !config.scrollHorizontally, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.mediaCoordinator, binding.mediaGrid, useTransparentNavigation = !config.scrollHorizontally, useTopSearchMenu = true)
|
||||||
|
|
||||||
if (mShowAll) {
|
if (mShowAll) {
|
||||||
registerFileUpdateListener()
|
registerFileUpdateListener()
|
||||||
|
|
||||||
if (isPackageInstalled("com.simplemobiletools.gallery")) {
|
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()
|
showFilterMediaDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +142,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
|
||||||
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
getMedia()
|
getMedia()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,22 +164,22 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|| mStoredRoundedCorners != config.fileRoundedCorners
|
|| mStoredRoundedCorners != config.fileRoundedCorners
|
||||||
|| mStoredMarkFavoriteItems != config.markFavoriteItems
|
|| mStoredMarkFavoriteItems != config.markFavoriteItems
|
||||||
) {
|
) {
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
media_fastscroller.updateColors(primaryColor)
|
binding.mediaFastscroller.updateColors(primaryColor)
|
||||||
media_refresh_layout.isEnabled = config.enablePullToRefresh
|
binding.mediaRefreshLayout.isEnabled = config.enablePullToRefresh
|
||||||
getMediaAdapter()?.apply {
|
getMediaAdapter()?.apply {
|
||||||
dateFormat = config.dateFormat
|
dateFormat = config.dateFormat
|
||||||
timeFormat = getTimeFormat()
|
timeFormat = getTimeFormat()
|
||||||
}
|
}
|
||||||
|
|
||||||
media_empty_text_placeholder.setTextColor(getProperTextColor())
|
binding.mediaEmptyTextPlaceholder.setTextColor(getProperTextColor())
|
||||||
media_empty_text_placeholder_2.setTextColor(getProperPrimaryColor())
|
binding.mediaEmptyTextPlaceholder2.setTextColor(getProperPrimaryColor())
|
||||||
media_empty_text_placeholder_2.bringToFront()
|
binding.mediaEmptyTextPlaceholder2.bringToFront()
|
||||||
|
|
||||||
// do not refresh Random sorted files after opening a fullscreen image and going Back
|
// do not refresh Random sorted files after opening a fullscreen image and going Back
|
||||||
val isRandomSorting = config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0
|
val isRandomSorting = config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0
|
||||||
|
@ -192,7 +201,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
mIsGettingMedia = false
|
mIsGettingMedia = false
|
||||||
media_refresh_layout.isRefreshing = false
|
binding.mediaRefreshLayout.isRefreshing = false
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
|
@ -229,8 +238,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (media_menu.isSearchOpen) {
|
if (binding.mediaMenu.isSearchOpen) {
|
||||||
media_menu.closeSearch()
|
binding.mediaMenu.closeSearch()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -249,7 +258,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val isDefaultFolder = !config.defaultFolder.isEmpty() && File(config.defaultFolder).compareTo(File(mPath)) == 0
|
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.group).isVisible = !config.scrollHorizontally
|
||||||
|
|
||||||
findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
||||||
|
@ -275,17 +284,17 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
media_menu.getToolbar().inflateMenu(R.menu.menu_media)
|
binding.mediaMenu.getToolbar().inflateMenu(R.menu.menu_media)
|
||||||
media_menu.toggleHideOnScroll(!config.scrollHorizontally)
|
binding.mediaMenu.toggleHideOnScroll(!config.scrollHorizontally)
|
||||||
media_menu.setupMenu()
|
binding.mediaMenu.setupMenu()
|
||||||
|
|
||||||
media_menu.onSearchTextChangedListener = { text ->
|
binding.mediaMenu.onSearchTextChangedListener = { text ->
|
||||||
mLastSearchedText = text
|
mLastSearchedText = text
|
||||||
searchQueryChanged(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) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.filter -> showFilterMediaDialog()
|
R.id.filter -> showFilterMediaDialog()
|
||||||
|
@ -329,7 +338,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
media_menu.updateColors()
|
binding.mediaMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
|
@ -355,12 +364,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, mPath)
|
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, mPath)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (grouped.isEmpty()) {
|
if (grouped.isEmpty()) {
|
||||||
media_empty_text_placeholder.text = getString(R.string.no_items_found)
|
binding.mediaEmptyTextPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
media_empty_text_placeholder.beVisible()
|
binding.mediaEmptyTextPlaceholder.beVisible()
|
||||||
media_fastscroller.beGone()
|
binding.mediaFastscroller.beGone()
|
||||||
} else {
|
} else {
|
||||||
media_empty_text_placeholder.beGone()
|
binding.mediaEmptyTextPlaceholder.beGone()
|
||||||
media_fastscroller.beVisible()
|
binding.mediaFastscroller.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGridSpacing(grouped)
|
handleGridSpacing(grouped)
|
||||||
|
@ -375,22 +384,22 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
handlePermission(getPermissionToRequest()) {
|
handlePermission(getPermissionToRequest()) {
|
||||||
if (it) {
|
if (it) {
|
||||||
val dirName = when {
|
val dirName = when {
|
||||||
mPath == FAVORITES -> getString(R.string.favorites)
|
mPath == FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites)
|
||||||
mPath == RECYCLE_BIN -> getString(R.string.recycle_bin)
|
mPath == RECYCLE_BIN -> getString(com.simplemobiletools.commons.R.string.recycle_bin)
|
||||||
mPath == config.OTGPath -> getString(R.string.usb)
|
mPath == config.OTGPath -> getString(com.simplemobiletools.commons.R.string.usb)
|
||||||
else -> getHumanizedFilename(mPath)
|
else -> getHumanizedFilename(mPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
val searchHint = if (mShowAll) {
|
val searchHint = if (mShowAll) {
|
||||||
getString(R.string.search_files)
|
getString(com.simplemobiletools.commons.R.string.search_files)
|
||||||
} else {
|
} 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) {
|
if (!mShowAll) {
|
||||||
media_menu.toggleForceArrowBackIcon(true)
|
binding.mediaMenu.toggleForceArrowBackIcon(true)
|
||||||
media_menu.onNavigateBackClickListener = {
|
binding.mediaMenu.onNavigateBackClickListener = {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,37 +407,37 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
getMedia()
|
getMedia()
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMediaAdapter() = media_grid.adapter as? MediaAdapter
|
private fun getMediaAdapter() = binding.mediaGrid.adapter as? MediaAdapter
|
||||||
|
|
||||||
private fun setupAdapter() {
|
private fun setupAdapter() {
|
||||||
if (!mShowAll && isDirEmpty()) {
|
if (!mShowAll && isDirEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val currAdapter = media_grid.adapter
|
val currAdapter = binding.mediaGrid.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
MediaAdapter(
|
MediaAdapter(
|
||||||
this, mMedia.clone() as ArrayList<ThumbnailItem>, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent,
|
this, mMedia.clone() as ArrayList<ThumbnailItem>, this, mIsGetImageIntent || mIsGetVideoIntent || mIsGetAnyIntent,
|
||||||
mAllowPickingMultiple, mPath, media_grid
|
mAllowPickingMultiple, mPath, binding.mediaGrid
|
||||||
) {
|
) {
|
||||||
if (it is Medium && !isFinishing) {
|
if (it is Medium && !isFinishing) {
|
||||||
itemClicked(it.path)
|
itemClicked(it.path)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
setupZoomListener(mZoomListener)
|
setupZoomListener(mZoomListener)
|
||||||
media_grid.adapter = this
|
binding.mediaGrid.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
||||||
if (viewType == VIEW_TYPE_LIST && areSystemAnimationsEnabled) {
|
if (viewType == VIEW_TYPE_LIST && areSystemAnimationsEnabled) {
|
||||||
media_grid.scheduleLayoutAnimation()
|
binding.mediaGrid.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
|
@ -446,7 +455,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun setupScrollDirection() {
|
private fun setupScrollDirection() {
|
||||||
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
||||||
val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID
|
val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID
|
||||||
media_fastscroller.setScrollVertically(!scrollHorizontally)
|
binding.mediaFastscroller.setScrollVertically(!scrollHorizontally)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLastMediaChanged() {
|
private fun checkLastMediaChanged() {
|
||||||
|
@ -475,7 +484,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun showSortingDialog() {
|
private fun showSortingDialog() {
|
||||||
ChangeSortingDialog(this, false, true, mPath) {
|
ChangeSortingDialog(this, false, true, mPath) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
getMedia()
|
getMedia()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,8 +492,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun showFilterMediaDialog() {
|
private fun showFilterMediaDialog() {
|
||||||
FilterMediaDialog(this) {
|
FilterMediaDialog(this) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
media_refresh_layout.isRefreshing = true
|
binding.mediaRefreshLayout.isRefreshing = true
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
getMedia()
|
getMedia()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +540,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
ChangeViewTypeDialog(this, false, mPath) {
|
ChangeViewTypeDialog(this, false, mPath) {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -539,7 +548,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun showGroupByDialog() {
|
private fun showGroupByDialog() {
|
||||||
ChangeGroupingDialog(this, mPath) {
|
ChangeGroupingDialog(this, mPath) {
|
||||||
mLoadedInitialPhotos = false
|
mLoadedInitialPhotos = false
|
||||||
media_grid.adapter = null
|
binding.mediaGrid.adapter = null
|
||||||
getMedia()
|
getMedia()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,7 +578,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent) {
|
getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent) {
|
||||||
if (it.isEmpty()) {
|
if (it.isEmpty()) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
media_refresh_layout.isRefreshing = true
|
binding.mediaRefreshLayout.isRefreshing = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gotMedia(it, true)
|
gotMedia(it, true)
|
||||||
|
@ -622,9 +631,9 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPath == RECYCLE_BIN) {
|
if (mPath == RECYCLE_BIN) {
|
||||||
media_empty_text_placeholder.setText(R.string.no_items_found)
|
binding.mediaEmptyTextPlaceholder.setText(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
media_empty_text_placeholder.beVisible()
|
binding.mediaEmptyTextPlaceholder.beVisible()
|
||||||
media_empty_text_placeholder_2.beGone()
|
binding.mediaEmptyTextPlaceholder2.beGone()
|
||||||
} else {
|
} else {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
@ -681,13 +690,13 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = RecyclerView.HORIZONTAL
|
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 {
|
} else {
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
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
|
layoutManager.spanCount = config.mediaColumnCnt
|
||||||
|
@ -704,10 +713,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
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
|
mZoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,17 +728,17 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
val useGridPosition = media.firstOrNull() is ThumbnailSection
|
val useGridPosition = media.firstOrNull() is ThumbnailSection
|
||||||
|
|
||||||
var currentGridDecoration: GridSpacingItemDecoration? = null
|
var currentGridDecoration: GridSpacingItemDecoration? = null
|
||||||
if (media_grid.itemDecorationCount > 0) {
|
if (binding.mediaGrid.itemDecorationCount > 0) {
|
||||||
currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
||||||
currentGridDecoration.items = media
|
currentGridDecoration.items = media
|
||||||
}
|
}
|
||||||
|
|
||||||
val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition)
|
val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition)
|
||||||
if (currentGridDecoration.toString() != newGridDecoration.toString()) {
|
if (currentGridDecoration.toString() != newGridDecoration.toString()) {
|
||||||
if (currentGridDecoration != null) {
|
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() {
|
private fun initZoomListener() {
|
||||||
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
||||||
if (viewType == VIEW_TYPE_GRID) {
|
if (viewType == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mediaGrid.layoutManager as MyGridLayoutManager
|
||||||
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
mZoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -761,10 +770,10 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun changeColumnCount() {
|
private fun changeColumnCount() {
|
||||||
val items = ArrayList<RadioItem>()
|
val items = ArrayList<RadioItem>()
|
||||||
for (i in 1..MAX_COLUMN_COUNT) {
|
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) {
|
RadioGroupDialog(this, items, currentColumnCount) {
|
||||||
val newColumnCount = it as Int
|
val newColumnCount = it as Int
|
||||||
if (currentColumnCount != newColumnCount) {
|
if (currentColumnCount != newColumnCount) {
|
||||||
|
@ -785,7 +794,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun columnCountChanged() {
|
private fun columnCountChanged() {
|
||||||
(media_grid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt
|
(binding.mediaGrid.layoutManager as MyGridLayoutManager).spanCount = config.mediaColumnCnt
|
||||||
handleGridSpacing()
|
handleGridSpacing()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
getMediaAdapter()?.apply {
|
getMediaAdapter()?.apply {
|
||||||
|
@ -863,14 +872,14 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
mMedia = media
|
mMedia = media
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
media_refresh_layout.isRefreshing = false
|
binding.mediaRefreshLayout.isRefreshing = false
|
||||||
media_empty_text_placeholder.beVisibleIf(media.isEmpty() && !isFromCache)
|
binding.mediaEmptyTextPlaceholder.beVisibleIf(media.isEmpty() && !isFromCache)
|
||||||
media_empty_text_placeholder_2.beVisibleIf(media.isEmpty() && !isFromCache)
|
binding.mediaEmptyTextPlaceholder2.beVisibleIf(media.isEmpty() && !isFromCache)
|
||||||
|
|
||||||
if (media_empty_text_placeholder.isVisible()) {
|
if (binding.mediaEmptyTextPlaceholder.isVisible()) {
|
||||||
media_empty_text_placeholder.text = getString(R.string.no_media_with_filters)
|
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()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,18 +903,18 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.useRecycleBin && !skipRecycleBin && !filtered.first().path.startsWith(recycleBinPath)) {
|
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)
|
toast(movingItems)
|
||||||
|
|
||||||
movePathsInRecycleBin(filtered.map { it.path } as ArrayList<String>) {
|
movePathsInRecycleBin(filtered.map { it.path } as ArrayList<String>) {
|
||||||
if (it) {
|
if (it) {
|
||||||
deleteFilteredFiles(filtered)
|
deleteFilteredFiles(filtered)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
toast(deletingItems)
|
||||||
deleteFilteredFiles(filtered)
|
deleteFilteredFiles(filtered)
|
||||||
}
|
}
|
||||||
|
@ -916,7 +925,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
||||||
deleteFiles(filtered) {
|
deleteFiles(filtered) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return@deleteFiles
|
return@deleteFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,8 +970,8 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (media_grid.itemDecorationCount > 0) {
|
if (binding.mediaGrid.itemDecorationCount > 0) {
|
||||||
val currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
val currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
||||||
currentGridDecoration.items = media
|
currentGridDecoration.items = media
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.hideSystemUI
|
import com.simplemobiletools.gallery.pro.extensions.hideSystemUI
|
||||||
import com.simplemobiletools.gallery.pro.extensions.showSystemUI
|
import com.simplemobiletools.gallery.pro.extensions.showSystemUI
|
||||||
import com.simplemobiletools.gallery.pro.helpers.PATH
|
import com.simplemobiletools.gallery.pro.helpers.PATH
|
||||||
import kotlinx.android.synthetic.main.activity_panorama_photo.*
|
|
||||||
|
|
||||||
open class PanoramaPhotoActivity : SimpleActivity() {
|
open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
private val CARDBOARD_DISPLAY_MODE = 3
|
private val CARDBOARD_DISPLAY_MODE = 3
|
||||||
|
@ -29,23 +29,25 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
private var isExploreEnabled = true
|
private var isExploreEnabled = true
|
||||||
private var isRendering = false
|
private var isRendering = false
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityPanoramaPhotoBinding::inflate)
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_panorama_photo)
|
setContentView(binding.root)
|
||||||
|
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
setupButtonMargins()
|
setupButtonMargins()
|
||||||
|
|
||||||
cardboard.setOnClickListener {
|
binding.cardboard.setOnClickListener {
|
||||||
panorama_view.displayMode = CARDBOARD_DISPLAY_MODE
|
binding.panoramaView.displayMode = CARDBOARD_DISPLAY_MODE
|
||||||
}
|
}
|
||||||
|
|
||||||
explore.setOnClickListener {
|
binding.explore.setOnClickListener {
|
||||||
isExploreEnabled = !isExploreEnabled
|
isExploreEnabled = !isExploreEnabled
|
||||||
panorama_view.setPureTouchTracking(isExploreEnabled)
|
binding.panoramaView.setPureTouchTracking(isExploreEnabled)
|
||||||
explore.setImageResource(if (isExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector)
|
binding.explore.setImageResource(if (isExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkIntent()
|
checkIntent()
|
||||||
|
@ -57,7 +59,7 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
panorama_view.resumeRendering()
|
binding.panoramaView.resumeRendering()
|
||||||
isRendering = true
|
isRendering = true
|
||||||
if (config.blackBackground) {
|
if (config.blackBackground) {
|
||||||
updateStatusbarColor(Color.BLACK)
|
updateStatusbarColor(Color.BLACK)
|
||||||
|
@ -74,14 +76,14 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
panorama_view.pauseRendering()
|
binding.panoramaView.pauseRendering()
|
||||||
isRendering = false
|
isRendering = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (isRendering) {
|
if (isRendering) {
|
||||||
panorama_view.shutdown()
|
binding.panoramaView.shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +108,7 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val bitmap = getBitmapToLoad(path)
|
val bitmap = getBitmapToLoad(path)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
panorama_view.apply {
|
binding.panoramaView.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
loadImageFromBitmap(bitmap, options)
|
loadImageFromBitmap(bitmap, options)
|
||||||
setFlingingEnabled(true)
|
setFlingingEnabled(true)
|
||||||
|
@ -164,20 +166,20 @@ open class PanoramaPhotoActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupButtonMargins() {
|
private fun setupButtonMargins() {
|
||||||
val navBarHeight = navigationBarHeight
|
val navBarHeight = navigationBarHeight
|
||||||
(cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
(binding.cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
rightMargin = navigationBarWidth
|
rightMargin = navigationBarWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight
|
(binding.explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = navigationBarHeight
|
||||||
|
|
||||||
cardboard.onGlobalLayout {
|
binding.cardboard.onGlobalLayout {
|
||||||
panorama_gradient_background.layoutParams.height = navBarHeight + cardboard.height
|
binding.panoramaGradientBackground.layoutParams.height = navBarHeight + binding.cardboard.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleButtonVisibility() {
|
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.animate().alpha(if (isFullscreen) 0f else 1f)
|
||||||
it.isClickable = !isFullscreen
|
it.isClickable = !isFullscreen
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,13 @@ import com.google.vr.sdk.widgets.video.VrVideoView
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.hasNavBar
|
import com.simplemobiletools.gallery.pro.extensions.hasNavBar
|
||||||
import com.simplemobiletools.gallery.pro.extensions.hideSystemUI
|
import com.simplemobiletools.gallery.pro.extensions.hideSystemUI
|
||||||
import com.simplemobiletools.gallery.pro.extensions.showSystemUI
|
import com.simplemobiletools.gallery.pro.extensions.showSystemUI
|
||||||
import com.simplemobiletools.gallery.pro.helpers.MIN_SKIP_LENGTH
|
import com.simplemobiletools.gallery.pro.helpers.MIN_SKIP_LENGTH
|
||||||
import com.simplemobiletools.gallery.pro.helpers.PATH
|
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
|
import java.io.File
|
||||||
|
|
||||||
open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
||||||
|
@ -39,12 +38,13 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
private var mCurrTime = 0
|
private var mCurrTime = 0
|
||||||
|
|
||||||
private var mTimerHandler = Handler()
|
private var mTimerHandler = Handler()
|
||||||
|
private val binding by viewBinding(ActivityPanoramaVideoBinding::inflate)
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_panorama_video)
|
setContentView(binding.root)
|
||||||
|
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
checkIntent()
|
checkIntent()
|
||||||
|
@ -56,7 +56,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
vr_video_view.resumeRendering()
|
binding.vrVideoView.resumeRendering()
|
||||||
mIsRendering = true
|
mIsRendering = true
|
||||||
if (config.blackBackground) {
|
if (config.blackBackground) {
|
||||||
updateStatusbarColor(Color.BLACK)
|
updateStatusbarColor(Color.BLACK)
|
||||||
|
@ -73,14 +73,14 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
vr_video_view.pauseRendering()
|
binding.vrVideoView.pauseRendering()
|
||||||
mIsRendering = false
|
mIsRendering = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (mIsRendering) {
|
if (mIsRendering) {
|
||||||
vr_video_view.shutdown()
|
binding.vrVideoView.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChangingConfigurations) {
|
if (!isChangingConfigurations) {
|
||||||
|
@ -104,8 +104,8 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
setupButtons()
|
setupButtons()
|
||||||
intent.removeExtra(PATH)
|
intent.removeExtra(PATH)
|
||||||
|
|
||||||
video_curr_time.setOnClickListener { skip(false) }
|
binding.bottomVideoTimeHolder.videoCurrTime.setOnClickListener { skip(false) }
|
||||||
video_duration.setOnClickListener { skip(true) }
|
binding.bottomVideoTimeHolder.videoDuration.setOnClickListener { skip(true) }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val options = VrVideoView.Options()
|
val options = VrVideoView.Options()
|
||||||
|
@ -116,7 +116,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
Uri.fromFile(File(path))
|
Uri.fromFile(File(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
vr_video_view.apply {
|
binding.vrVideoView.apply {
|
||||||
loadVideo(uri, options)
|
loadVideo(uri, options)
|
||||||
pauseVideo()
|
pauseVideo()
|
||||||
|
|
||||||
|
@ -149,9 +149,9 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
mIsPlaying = true
|
mIsPlaying = true
|
||||||
resumeVideo()
|
resumeVideo()
|
||||||
} else {
|
} 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() {
|
override fun onCompletion() {
|
||||||
|
@ -160,7 +160,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
video_toggle_play_pause.setOnClickListener {
|
binding.bottomVideoTimeHolder.videoTogglePlayPause.setOnClickListener {
|
||||||
togglePlayPause()
|
togglePlayPause()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -175,8 +175,8 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
|
|
||||||
private fun setupDuration(duration: Long) {
|
private fun setupDuration(duration: Long) {
|
||||||
mDuration = (duration / 1000).toInt()
|
mDuration = (duration / 1000).toInt()
|
||||||
video_seekbar.max = mDuration
|
binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration
|
||||||
video_duration.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration()
|
||||||
setVideoProgress(0)
|
setVideoProgress(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,9 +184,9 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
runOnUiThread(object : Runnable {
|
runOnUiThread(object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (mIsPlaying && !mIsDragged) {
|
if (mIsPlaying && !mIsDragged) {
|
||||||
mCurrTime = (vr_video_view!!.currentPosition / 1000).toInt()
|
mCurrTime = (binding.vrVideoView.currentPosition / 1000).toInt()
|
||||||
video_seekbar.progress = mCurrTime
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = mCurrTime
|
||||||
video_curr_time.text = mCurrTime.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimerHandler.postDelayed(this, 1000)
|
mTimerHandler.postDelayed(this, 1000)
|
||||||
|
@ -204,35 +204,35 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resumeVideo() {
|
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) {
|
if (mCurrTime == mDuration) {
|
||||||
setVideoProgress(0)
|
setVideoProgress(0)
|
||||||
mPlayOnReady = true
|
mPlayOnReady = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
vr_video_view.playVideo()
|
binding.vrVideoView.playVideo()
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseVideo() {
|
private fun pauseVideo() {
|
||||||
vr_video_view.pauseVideo()
|
binding.vrVideoView.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)
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setVideoProgress(seconds: Int) {
|
private fun setVideoProgress(seconds: Int) {
|
||||||
vr_video_view.seekTo(seconds * 1000L)
|
binding.vrVideoView.seekTo(seconds * 1000L)
|
||||||
video_seekbar.progress = seconds
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = seconds
|
||||||
mCurrTime = seconds
|
mCurrTime = seconds
|
||||||
video_curr_time.text = seconds.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = seconds.getFormattedDuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun videoCompleted() {
|
private fun videoCompleted() {
|
||||||
mIsPlaying = false
|
mIsPlaying = false
|
||||||
mCurrTime = (vr_video_view.duration / 1000).toInt()
|
mCurrTime = (binding.vrVideoView.duration / 1000).toInt()
|
||||||
video_seekbar.progress = video_seekbar.max
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = binding.bottomVideoTimeHolder.videoSeekbar.max
|
||||||
video_curr_time.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = mDuration.getFormattedDuration()
|
||||||
pauseVideo()
|
pauseVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,44 +249,50 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
video_time_holder.setPadding(0, 0, right, bottom)
|
binding.bottomVideoTimeHolder.root.setPadding(0, 0, right, bottom)
|
||||||
video_time_holder.background = resources.getDrawable(R.drawable.gradient_background)
|
binding.bottomVideoTimeHolder.root.background = resources.getDrawable(R.drawable.gradient_background)
|
||||||
video_time_holder.onGlobalLayout {
|
binding.bottomVideoTimeHolder.root.onGlobalLayout {
|
||||||
val newBottomMargin = video_time_holder.height - resources.getDimension(R.dimen.video_player_play_pause_size)
|
val newBottomMargin = binding.bottomVideoTimeHolder.root.height - resources.getDimension(R.dimen.video_player_play_pause_size)
|
||||||
.toInt() - resources.getDimension(R.dimen.activity_margin).toInt()
|
.toInt() - resources.getDimension(com.simplemobiletools.commons.R.dimen.activity_margin).toInt()
|
||||||
(explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = newBottomMargin
|
(binding.explore.layoutParams as RelativeLayout.LayoutParams).bottomMargin = newBottomMargin
|
||||||
|
|
||||||
(cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
(binding.cardboard.layoutParams as RelativeLayout.LayoutParams).apply {
|
||||||
bottomMargin = newBottomMargin
|
bottomMargin = newBottomMargin
|
||||||
rightMargin = navigationBarWidth
|
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 {
|
binding.cardboard.setOnClickListener {
|
||||||
vr_video_view.displayMode = CARDBOARD_DISPLAY_MODE
|
binding.vrVideoView.displayMode = CARDBOARD_DISPLAY_MODE
|
||||||
}
|
}
|
||||||
|
|
||||||
explore.setOnClickListener {
|
binding.explore.setOnClickListener {
|
||||||
mIsExploreEnabled = !mIsExploreEnabled
|
mIsExploreEnabled = !mIsExploreEnabled
|
||||||
vr_video_view.setPureTouchTracking(mIsExploreEnabled)
|
binding.vrVideoView.setPureTouchTracking(mIsExploreEnabled)
|
||||||
explore.setImageResource(if (mIsExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector)
|
binding.explore.setImageResource(if (mIsExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleButtonVisibility() {
|
private fun toggleButtonVisibility() {
|
||||||
val newAlpha = if (mIsFullscreen) 0f else 1f
|
val newAlpha = if (mIsFullscreen) 0f else 1f
|
||||||
arrayOf(cardboard, explore).forEach {
|
arrayOf(binding.cardboard, binding.explore).forEach {
|
||||||
it.animate().alpha(newAlpha)
|
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
|
it.isClickable = !mIsFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
video_seekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this)
|
binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this)
|
||||||
video_time_holder.animate().alpha(newAlpha).start()
|
binding.bottomVideoTimeHolder.videoTimeHolder.animate().alpha(newAlpha).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleClick() {
|
private fun handleClick() {
|
||||||
|
@ -304,11 +310,11 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val curr = vr_video_view.currentPosition
|
val curr = binding.vrVideoView.currentPosition
|
||||||
val twoPercents = Math.max((vr_video_view.duration / 50).toInt(), MIN_SKIP_LENGTH)
|
val twoPercents = Math.max((binding.vrVideoView.duration / 50).toInt(), MIN_SKIP_LENGTH)
|
||||||
val newProgress = if (forward) curr + twoPercents else curr - twoPercents
|
val newProgress = if (forward) curr + twoPercents else curr - twoPercents
|
||||||
val roundProgress = Math.round(newProgress / 1000f)
|
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)
|
setVideoProgress(limitedProgress)
|
||||||
if (!mIsPlaying) {
|
if (!mIsPlaying) {
|
||||||
togglePlayPause()
|
togglePlayPause()
|
||||||
|
@ -322,7 +328,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {
|
override fun onStartTrackingTouch(seekBar: SeekBar?) {
|
||||||
vr_video_view.pauseVideo()
|
binding.vrVideoView.pauseVideo()
|
||||||
mIsDragged = true
|
mIsDragged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,13 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.BuildConfig
|
import com.simplemobiletools.gallery.pro.BuildConfig
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.FragmentHolderBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.fragments.PhotoFragment
|
import com.simplemobiletools.gallery.pro.fragments.PhotoFragment
|
||||||
import com.simplemobiletools.gallery.pro.fragments.VideoFragment
|
import com.simplemobiletools.gallery.pro.fragments.VideoFragment
|
||||||
import com.simplemobiletools.gallery.pro.fragments.ViewPagerFragment
|
import com.simplemobiletools.gallery.pro.fragments.ViewPagerFragment
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
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.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
|
||||||
|
@ -35,11 +34,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
|
|
||||||
var mIsVideo = false
|
var mIsVideo = false
|
||||||
|
|
||||||
|
private val binding by viewBinding(FragmentHolderBinding::inflate)
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
showTransparentTop = true
|
showTransparentTop = true
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.fragment_holder)
|
setContentView(binding.root)
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -50,7 +51,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
if (it) {
|
if (it) {
|
||||||
checkIntent(savedInstanceState)
|
checkIntent(savedInstanceState)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,19 +75,19 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
initBottomActionsLayout()
|
initBottomActionsLayout()
|
||||||
|
|
||||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||||
(fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.fragmentViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.fragmentViewerToolbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} else {
|
||||||
fragment_viewer_toolbar.setPadding(0, 0, 0, 0)
|
binding.fragmentViewerToolbar.setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshMenuItems() {
|
fun refreshMenuItems() {
|
||||||
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
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_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_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
|
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() {
|
private fun setupOptionsMenu() {
|
||||||
(fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.fragmentViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
fragment_viewer_toolbar.apply {
|
binding.fragmentViewerToolbar.apply {
|
||||||
setTitleTextColor(Color.WHITE)
|
setTitleTextColor(Color.WHITE)
|
||||||
overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE)
|
overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE)
|
||||||
navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE)
|
navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMenuItemColors(fragment_viewer_toolbar.menu, forceWhiteIcons = true)
|
updateMenuItemColors(binding.fragmentViewerToolbar.menu, forceWhiteIcons = true)
|
||||||
fragment_viewer_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.fragmentViewerToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
if (mMedium == null || mUri == null) {
|
if (mMedium == null || mUri == null) {
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_viewer_toolbar.setNavigationOnClickListener {
|
binding.fragmentViewerToolbar.setNavigationOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
if (!preventShowingHiddenFile) {
|
if (!preventShowingHiddenFile) {
|
||||||
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
if (realPath.getFilenameFromPath().contains('.') || filename.contains('.')) {
|
||||||
if (isFileTypeVisible(realPath)) {
|
if (isFileTypeVisible(realPath)) {
|
||||||
bottom_actions.beGone()
|
binding.bottomActions.root.beGone()
|
||||||
sendViewPagerIntent(realPath)
|
sendViewPagerIntent(realPath)
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
|
@ -176,7 +177,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
|
|
||||||
if (mUri!!.scheme == "file") {
|
if (mUri!!.scheme == "file") {
|
||||||
if (filename.contains('.')) {
|
if (filename.contains('.')) {
|
||||||
bottom_actions.beGone()
|
binding.bottomActions.root.beGone()
|
||||||
rescanPaths(arrayListOf(mUri!!.path!!))
|
rescanPaths(arrayListOf(mUri!!.path!!))
|
||||||
sendViewPagerIntent(mUri!!.path!!)
|
sendViewPagerIntent(mUri!!.path!!)
|
||||||
finish()
|
finish()
|
||||||
|
@ -189,7 +190,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
if (!preventShowingHiddenFile) {
|
if (!preventShowingHiddenFile) {
|
||||||
if (realPath != mUri.toString() && realPath.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(realPath)) {
|
if (realPath != mUri.toString() && realPath.isNotEmpty() && mUri!!.authority != "mms" && filename.contains('.') && getDoesFilePathExist(realPath)) {
|
||||||
if (isFileTypeVisible(realPath)) {
|
if (isFileTypeVisible(realPath)) {
|
||||||
bottom_actions.beGone()
|
binding.bottomActions.root.beGone()
|
||||||
rescanPaths(arrayListOf(mUri!!.path!!))
|
rescanPaths(arrayListOf(mUri!!.path!!))
|
||||||
sendViewPagerIntent(realPath)
|
sendViewPagerIntent(realPath)
|
||||||
finish()
|
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) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.fragmentViewerToolbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} else {
|
||||||
fragment_viewer_toolbar.setPadding(0, 0, 0, 0)
|
binding.fragmentViewerToolbar.setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
|
@ -222,7 +223,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
|
|
||||||
mIsVideo = type == TYPE_VIDEOS
|
mIsVideo = type == TYPE_VIDEOS
|
||||||
mMedium = Medium(null, filename, mUri.toString(), mUri!!.path!!.getParentPath(), 0, 0, file.length(), type, 0, false, 0L, 0)
|
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)
|
bundle.putSerializable(MEDIUM, mMedium)
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
@ -233,7 +234,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.blackBackground) {
|
if (config.blackBackground) {
|
||||||
fragment_holder.background = ColorDrawable(Color.BLACK)
|
binding.fragmentHolder.background = ColorDrawable(Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.maxBrightness) {
|
if (config.maxBrightness) {
|
||||||
|
@ -253,7 +254,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
private fun launchVideoPlayer() {
|
private fun launchVideoPlayer() {
|
||||||
val newUri = getFinalUriFromPath(mUri.toString(), BuildConfig.APPLICATION_ID)
|
val newUri = getFinalUriFromPath(mUri.toString(), BuildConfig.APPLICATION_ID)
|
||||||
if (newUri == null) {
|
if (newUri == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,44 +357,54 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initBottomActionsLayout() {
|
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) {
|
if (config.bottomActions) {
|
||||||
bottom_actions.beVisible()
|
binding.bottomActions.root.beVisible()
|
||||||
} else {
|
} else {
|
||||||
bottom_actions.beGone()
|
binding.bottomActions.root.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initBottomActionButtons() {
|
private fun initBottomActionButtons() {
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
bottom_favorite, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, bottom_slideshow, bottom_show_on_map,
|
binding.bottomActions.bottomFavorite,
|
||||||
bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move, bottom_resize
|
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 {
|
).forEach {
|
||||||
it.beGone()
|
it.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
||||||
bottom_edit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && mMedium?.isImage() == true)
|
binding.bottomActions.bottomEdit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && mMedium?.isImage() == true)
|
||||||
bottom_edit.setOnClickListener {
|
binding.bottomActions.bottomEdit.setOnClickListener {
|
||||||
if (mUri != null && bottom_actions.alpha == 1f) {
|
if (mUri != null && binding.bottomActions.root.alpha == 1f) {
|
||||||
openEditor(mUri!!.toString())
|
openEditor(mUri!!.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_share.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0)
|
binding.bottomActions.bottomShare.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0)
|
||||||
bottom_share.setOnClickListener {
|
binding.bottomActions.bottomShare.setOnClickListener {
|
||||||
if (mUri != null && bottom_actions.alpha == 1f) {
|
if (mUri != null && binding.bottomActions.root.alpha == 1f) {
|
||||||
sharePath(mUri!!.toString())
|
sharePath(mUri!!.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_set_as.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0 && mMedium?.isImage() == true)
|
binding.bottomActions.bottomSetAs.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0 && mMedium?.isImage() == true)
|
||||||
bottom_set_as.setOnClickListener {
|
binding.bottomActions.bottomSetAs.setOnClickListener {
|
||||||
setAs(mUri!!.toString())
|
setAs(mUri!!.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_show_on_map.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0)
|
binding.bottomActions.bottomShowOnMap.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0)
|
||||||
bottom_show_on_map.setOnClickListener {
|
binding.bottomActions.bottomShowOnMap.setOnClickListener {
|
||||||
showFileOnMap(mUri!!.toString())
|
showFileOnMap(mUri!!.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,15 +418,15 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
}
|
}
|
||||||
|
|
||||||
val newAlpha = if (mIsFullScreen) 0f else 1f
|
val newAlpha = if (mIsFullScreen) 0f else 1f
|
||||||
top_shadow.animate().alpha(newAlpha).start()
|
binding.topShadow.animate().alpha(newAlpha).start()
|
||||||
if (!bottom_actions.isGone()) {
|
if (!binding.bottomActions.root.isGone()) {
|
||||||
bottom_actions.animate().alpha(newAlpha).start()
|
binding.bottomActions.root.animate().alpha(newAlpha).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment_viewer_toolbar.animate().alpha(newAlpha).withStartAction {
|
binding.fragmentViewerToolbar.animate().alpha(newAlpha).withStartAction {
|
||||||
fragment_viewer_toolbar.beVisible()
|
binding.fragmentViewerToolbar.beVisible()
|
||||||
}.withEndAction {
|
}.withEndAction {
|
||||||
fragment_viewer_toolbar.beVisibleIf(newAlpha == 1f)
|
binding.fragmentViewerToolbar.beVisibleIf(newAlpha == 1f)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
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.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.GridSpacingItemDecoration
|
import com.simplemobiletools.gallery.pro.helpers.GridSpacingItemDecoration
|
||||||
import com.simplemobiletools.gallery.pro.helpers.MediaFetcher
|
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.interfaces.MediaOperationsListener
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||||
import kotlinx.android.synthetic.main.activity_search.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
@ -31,15 +31,17 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
private var mCurrAsyncTask: GetMediaAsynctask? = null
|
||||||
private var mAllMedia = ArrayList<ThumbnailItem>()
|
private var mAllMedia = ArrayList<ThumbnailItem>()
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivitySearchBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_search)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
updateMaterialActivityViews(search_coordinator, search_grid, useTransparentNavigation = true, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.searchCoordinator, binding.searchGrid, useTransparentNavigation = true, useTopSearchMenu = true)
|
||||||
search_empty_text_placeholder.setTextColor(getProperTextColor())
|
binding.searchEmptyTextPlaceholder.setTextColor(getProperTextColor())
|
||||||
getAllMedia()
|
getAllMedia()
|
||||||
search_fastscroller.updateColors(getProperPrimaryColor())
|
binding.searchFastscroller.updateColors(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -53,27 +55,27 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
search_menu.getToolbar().inflateMenu(R.menu.menu_search)
|
binding.searchMenu.getToolbar().inflateMenu(R.menu.menu_search)
|
||||||
search_menu.toggleHideOnScroll(true)
|
binding.searchMenu.toggleHideOnScroll(true)
|
||||||
search_menu.setupMenu()
|
binding.searchMenu.setupMenu()
|
||||||
search_menu.toggleForceArrowBackIcon(true)
|
binding.searchMenu.toggleForceArrowBackIcon(true)
|
||||||
search_menu.focusView()
|
binding.searchMenu.focusView()
|
||||||
search_menu.updateHintText(getString(R.string.search_files))
|
binding.searchMenu.updateHintText(getString(com.simplemobiletools.commons.R.string.search_files))
|
||||||
|
|
||||||
search_menu.onNavigateBackClickListener = {
|
binding.searchMenu.onNavigateBackClickListener = {
|
||||||
if (search_menu.getCurrentQuery().isEmpty()) {
|
if (binding.searchMenu.getCurrentQuery().isEmpty()) {
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
search_menu.closeSearch()
|
binding.searchMenu.closeSearch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
search_menu.onSearchTextChangedListener = { text ->
|
binding.searchMenu.onSearchTextChangedListener = { text ->
|
||||||
mLastSearchedText = text
|
mLastSearchedText = text
|
||||||
textChanged(text)
|
textChanged(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
search_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
binding.searchMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
@ -84,7 +86,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
search_menu.updateColors()
|
binding.searchMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun textChanged(text: String) {
|
private fun textChanged(text: String) {
|
||||||
|
@ -95,10 +97,10 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, "")
|
val grouped = MediaFetcher(applicationContext).groupMedia(filtered as ArrayList<Medium>, "")
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (grouped.isEmpty()) {
|
if (grouped.isEmpty()) {
|
||||||
search_empty_text_placeholder.text = getString(R.string.no_items_found)
|
binding.searchEmptyTextPlaceholder.text = getString(com.simplemobiletools.commons.R.string.no_items_found)
|
||||||
search_empty_text_placeholder.beVisible()
|
binding.searchEmptyTextPlaceholder.beVisible()
|
||||||
} else {
|
} else {
|
||||||
search_empty_text_placeholder.beGone()
|
binding.searchEmptyTextPlaceholder.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGridSpacing(grouped)
|
handleGridSpacing(grouped)
|
||||||
|
@ -110,14 +112,14 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAdapter() {
|
private fun setupAdapter() {
|
||||||
val currAdapter = search_grid.adapter
|
val currAdapter = binding.searchGrid.adapter
|
||||||
if (currAdapter == null) {
|
if (currAdapter == null) {
|
||||||
MediaAdapter(this, mAllMedia, this, false, false, "", search_grid) {
|
MediaAdapter(this, mAllMedia, this, false, false, "", binding.searchGrid) {
|
||||||
if (it is Medium) {
|
if (it is Medium) {
|
||||||
itemClicked(it.path)
|
itemClicked(it.path)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
search_grid.adapter = this
|
binding.searchGrid.adapter = this
|
||||||
}
|
}
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
handleGridSpacing(mAllMedia)
|
handleGridSpacing(mAllMedia)
|
||||||
|
@ -134,18 +136,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun handleGridSpacing(media: ArrayList<ThumbnailItem>) {
|
private fun handleGridSpacing(media: ArrayList<ThumbnailItem>) {
|
||||||
val viewType = config.getFolderViewType(SHOW_ALL)
|
val viewType = config.getFolderViewType(SHOW_ALL)
|
||||||
if (viewType == VIEW_TYPE_GRID) {
|
if (viewType == VIEW_TYPE_GRID) {
|
||||||
if (search_grid.itemDecorationCount > 0) {
|
if (binding.searchGrid.itemDecorationCount > 0) {
|
||||||
search_grid.removeItemDecorationAt(0)
|
binding.searchGrid.removeItemDecorationAt(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
val spanCount = config.mediaColumnCnt
|
val spanCount = config.mediaColumnCnt
|
||||||
val spacing = config.thumbnailSpacing
|
val spacing = config.thumbnailSpacing
|
||||||
val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, true)
|
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() {
|
private fun toggleFilenameVisibility() {
|
||||||
config.displayFileNames = !config.displayFileNames
|
config.displayFileNames = !config.displayFileNames
|
||||||
|
@ -175,13 +177,13 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = search_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.searchGrid.layoutManager as MyGridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = RecyclerView.HORIZONTAL
|
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 {
|
} else {
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
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
|
layoutManager.spanCount = config.mediaColumnCnt
|
||||||
|
@ -198,7 +200,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = search_grid.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.searchGrid.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
layoutManager.orientation = RecyclerView.VERTICAL
|
layoutManager.orientation = RecyclerView.VERTICAL
|
||||||
}
|
}
|
||||||
|
@ -206,7 +208,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun setupScrollDirection() {
|
private fun setupScrollDirection() {
|
||||||
val viewType = config.getFolderViewType(SHOW_ALL)
|
val viewType = config.getFolderViewType(SHOW_ALL)
|
||||||
val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID
|
val scrollHorizontally = config.scrollHorizontally && viewType == VIEW_TYPE_GRID
|
||||||
search_fastscroller.setScrollVertically(!scrollHorizontally)
|
binding.searchFastscroller.setScrollVertically(!scrollHorizontally)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllMedia() {
|
private fun getAllMedia() {
|
||||||
|
@ -244,18 +246,18 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.useRecycleBin && !skipRecycleBin && !filtered.first().path.startsWith(recycleBinPath)) {
|
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)
|
toast(movingItems)
|
||||||
|
|
||||||
movePathsInRecycleBin(filtered.map { it.path } as ArrayList<String>) {
|
movePathsInRecycleBin(filtered.map { it.path } as ArrayList<String>) {
|
||||||
if (it) {
|
if (it) {
|
||||||
deleteFilteredFiles(filtered)
|
deleteFilteredFiles(filtered)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
toast(deletingItems)
|
||||||
deleteFilteredFiles(filtered)
|
deleteFilteredFiles(filtered)
|
||||||
}
|
}
|
||||||
|
@ -264,7 +266,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
private fun deleteFilteredFiles(filtered: ArrayList<FileDirItem>) {
|
||||||
deleteFiles(filtered) {
|
deleteFiles(filtered) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return@deleteFiles
|
return@deleteFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,13 @@ import com.canhub.cropper.CropImageView
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.checkAppSideloading
|
import com.simplemobiletools.commons.extensions.checkAppSideloading
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
|
import com.simplemobiletools.commons.extensions.viewBinding
|
||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.isNougatPlus
|
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import kotlinx.android.synthetic.main.activity_set_wallpaper.crop_image_view
|
import com.simplemobiletools.gallery.pro.databinding.ActivitySetWallpaperBinding
|
||||||
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
|
|
||||||
|
|
||||||
class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
|
||||||
private val RATIO_PORTRAIT = 0
|
private val RATIO_PORTRAIT = 0
|
||||||
|
@ -32,9 +30,11 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
lateinit var uri: Uri
|
lateinit var uri: Uri
|
||||||
lateinit var wallpaperManager: WallpaperManager
|
lateinit var wallpaperManager: WallpaperManager
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivitySetWallpaperBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_set_wallpaper)
|
setContentView(binding.root)
|
||||||
setupBottomActions()
|
setupBottomActions()
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
|
@ -55,7 +55,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(set_wallpaper_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.setWallpaperToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
|
@ -70,10 +70,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
set_wallpaper_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.setWallpaperToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.save -> confirmWallpaper()
|
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
|
else -> return@setOnMenuItemClickListener false
|
||||||
}
|
}
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
|
@ -89,7 +89,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
wallpaperManager = WallpaperManager.getInstance(applicationContext)
|
wallpaperManager = WallpaperManager.getInstance(applicationContext)
|
||||||
crop_image_view.apply {
|
binding.cropImageView.apply {
|
||||||
setOnCropImageCompleteListener(this@SetWallpaperActivity)
|
setOnCropImageCompleteListener(this@SetWallpaperActivity)
|
||||||
setImageUriAsync(uri)
|
setImageUriAsync(uri)
|
||||||
}
|
}
|
||||||
|
@ -98,12 +98,12 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupBottomActions() {
|
private fun setupBottomActions() {
|
||||||
bottom_set_wallpaper_aspect_ratio.setOnClickListener {
|
binding.bottomSetWallpaperActions.bottomSetWallpaperAspectRatio.setOnClickListener {
|
||||||
changeAspectRatio()
|
changeAspectRatio()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_set_wallpaper_rotate.setOnClickListener {
|
binding.bottomSetWallpaperActions.bottomSetWallpaperRotate.setOnClickListener {
|
||||||
crop_image_view.rotateImage(90)
|
binding.cropImageView.rotateImage(90)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
|
|
||||||
when (aspectRatio) {
|
when (aspectRatio) {
|
||||||
RATIO_PORTRAIT -> crop_image_view.setAspectRatio(heightToUse, widthToUse)
|
RATIO_PORTRAIT -> binding.cropImageView.setAspectRatio(heightToUse, widthToUse)
|
||||||
RATIO_LANDSCAPE -> crop_image_view.setAspectRatio(widthToUse, heightToUse)
|
RATIO_LANDSCAPE -> binding.cropImageView.setAspectRatio(widthToUse, heightToUse)
|
||||||
else -> crop_image_view.setAspectRatio(widthToUse, widthToUse)
|
else -> binding.cropImageView.setAspectRatio(widthToUse, widthToUse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
|
|
||||||
RadioGroupDialog(this, items) {
|
RadioGroupDialog(this, items) {
|
||||||
wallpaperFlag = it as Int
|
wallpaperFlag = it as Int
|
||||||
crop_image_view.croppedImageAsync()
|
binding.cropImageView.croppedImageAsync()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
crop_image_view.croppedImageAsync()
|
binding.cropImageView.croppedImageAsync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
|
||||||
}
|
}
|
||||||
setResult(Activity.RESULT_OK)
|
setResult(Activity.RESULT_OK)
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
toast(R.string.out_of_memory_error)
|
toast(com.simplemobiletools.commons.R.string.out_of_memory_error)
|
||||||
setResult(Activity.RESULT_CANCELED)
|
setResult(Activity.RESULT_CANCELED)
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
|
|
|
@ -13,35 +13,39 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.*
|
import com.simplemobiletools.gallery.pro.dialogs.*
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
import java.util.*
|
import java.util.Locale
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
private val PICK_IMPORT_SOURCE_INTENT = 1
|
companion object {
|
||||||
private val SELECT_EXPORT_FAVORITES_FILE_INTENT = 2
|
private const val PICK_IMPORT_SOURCE_INTENT = 1
|
||||||
private val SELECT_IMPORT_FAVORITES_FILE_INTENT = 3
|
private const val SELECT_EXPORT_FAVORITES_FILE_INTENT = 2
|
||||||
|
private const val SELECT_IMPORT_FAVORITES_FILE_INTENT = 3
|
||||||
|
}
|
||||||
|
|
||||||
private var mRecycleBinContentSize = 0L
|
private var mRecycleBinContentSize = 0L
|
||||||
|
private val binding by viewBinding(ActivitySettingsBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(binding.root)
|
||||||
|
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
setupSettingItems()
|
setupSettingItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +98,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupShowRecycleBin()
|
setupShowRecycleBin()
|
||||||
setupShowRecycleBinLast()
|
setupShowRecycleBinLast()
|
||||||
setupEmptyRecycleBin()
|
setupEmptyRecycleBin()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(binding.settingsHolder)
|
||||||
setupClearCache()
|
setupClearCache()
|
||||||
setupExportFavorites()
|
setupExportFavorites()
|
||||||
setupImportFavorites()
|
setupImportFavorites()
|
||||||
|
@ -102,19 +106,19 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupImportSettings()
|
setupImportSettings()
|
||||||
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
settings_color_customization_section_label,
|
binding.settingsColorCustomizationSectionLabel,
|
||||||
settings_general_settings_label,
|
binding.settingsGeneralSettingsLabel,
|
||||||
settings_videos_label,
|
binding.settingsVideosLabel,
|
||||||
settings_thumbnails_label,
|
binding.settingsThumbnailsLabel,
|
||||||
settings_scrolling_label,
|
binding.settingsScrollingLabel,
|
||||||
settings_fullscreen_media_label,
|
binding.settingsFullscreenMediaLabel,
|
||||||
settings_deep_zoomable_images_label,
|
binding.settingsDeepZoomableImagesLabel,
|
||||||
settings_extended_details_label,
|
binding.settingsExtendedDetailsLabel,
|
||||||
settings_security_label,
|
binding.settingsSecurityLabel,
|
||||||
settings_file_operations_label,
|
binding.settingsFileOperationsLabel,
|
||||||
settings_bottom_actions_label,
|
binding.settingsBottomActionsLabel,
|
||||||
settings_recycle_bin_label,
|
binding.settingsRecycleBinLabel,
|
||||||
settings_migrating_label
|
binding.settingsMigratingLabel
|
||||||
).forEach {
|
).forEach {
|
||||||
it.setTextColor(getProperPrimaryColor())
|
it.setTextColor(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
@ -135,39 +139,39 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
startCustomizationActivity()
|
startCustomizationActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english.isChecked = config.useEnglish
|
binding.settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english_holder.setOnClickListener {
|
binding.settingsUseEnglishHolder.setOnClickListener {
|
||||||
settings_use_english.toggle()
|
binding.settingsUseEnglish.toggle()
|
||||||
config.useEnglish = settings_use_english.isChecked
|
config.useEnglish = binding.settingsUseEnglish.isChecked
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
binding.settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
settings_language_holder.setOnClickListener {
|
binding.settingsLanguageHolder.setOnClickListener {
|
||||||
launchChangeAppLanguageIntent()
|
launchChangeAppLanguageIntent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupChangeDateTimeFormat() {
|
private fun setupChangeDateTimeFormat() {
|
||||||
settings_change_date_time_format_holder.setOnClickListener {
|
binding.settingsChangeDateTimeFormatHolder.setOnClickListener {
|
||||||
ChangeDateTimeFormatDialog(this) {}
|
ChangeDateTimeFormatDialog(this) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFileLoadingPriority() {
|
private fun setupFileLoadingPriority() {
|
||||||
settings_file_loading_priority_holder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
binding.settingsFileLoadingPriorityHolder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
||||||
settings_file_loading_priority.text = getFileLoadingPriorityText()
|
binding.settingsFileLoadingPriority.text = getFileLoadingPriorityText()
|
||||||
settings_file_loading_priority_holder.setOnClickListener {
|
binding.settingsFileLoadingPriorityHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(PRIORITY_SPEED, getString(R.string.speed)),
|
RadioItem(PRIORITY_SPEED, getString(R.string.speed)),
|
||||||
RadioItem(PRIORITY_COMPROMISE, getString(R.string.compromise)),
|
RadioItem(PRIORITY_COMPROMISE, getString(R.string.compromise)),
|
||||||
|
@ -176,7 +180,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.fileLoadingPriority) {
|
RadioGroupDialog(this@SettingsActivity, items, config.fileLoadingPriority) {
|
||||||
config.fileLoadingPriority = it as Int
|
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() {
|
private fun setupManageIncludedFolders() {
|
||||||
if (isRPlus() && !isExternalStorageManager()) {
|
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 {
|
} 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()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
GrantAllFilesDialog(this)
|
GrantAllFilesDialog(this)
|
||||||
} else {
|
} else {
|
||||||
|
@ -206,7 +211,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageExcludedFolders() {
|
private fun setupManageExcludedFolders() {
|
||||||
settings_manage_excluded_folders_holder.setOnClickListener {
|
binding.settingsManageExcludedFoldersHolder.setOnClickListener {
|
||||||
handleExcludedFolderPasswordProtection {
|
handleExcludedFolderPasswordProtection {
|
||||||
startActivity(Intent(this, ExcludedFoldersActivity::class.java))
|
startActivity(Intent(this, ExcludedFoldersActivity::class.java))
|
||||||
}
|
}
|
||||||
|
@ -214,8 +219,8 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageHiddenFolders() {
|
private fun setupManageHiddenFolders() {
|
||||||
settings_manage_hidden_folders_holder.beGoneIf(isQPlus())
|
binding.settingsManageHiddenFoldersHolder.beGoneIf(isQPlus())
|
||||||
settings_manage_hidden_folders_holder.setOnClickListener {
|
binding.settingsManageHiddenFoldersHolder.setOnClickListener {
|
||||||
handleHiddenFolderPasswordProtection {
|
handleHiddenFolderPasswordProtection {
|
||||||
startActivity(Intent(this, HiddenFoldersActivity::class.java))
|
startActivity(Intent(this, HiddenFoldersActivity::class.java))
|
||||||
}
|
}
|
||||||
|
@ -224,13 +229,14 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupShowHiddenItems() {
|
private fun setupShowHiddenItems() {
|
||||||
if (isRPlus() && !isExternalStorageManager()) {
|
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 {
|
} 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
|
binding.settingsShowHiddenItems.isChecked = config.showHiddenMedia
|
||||||
settings_show_hidden_items_holder.setOnClickListener {
|
binding.settingsShowHiddenItemsHolder.setOnClickListener {
|
||||||
if (isRPlus() && !isExternalStorageManager()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
GrantAllFilesDialog(this)
|
GrantAllFilesDialog(this)
|
||||||
} else if (config.showHiddenMedia) {
|
} else if (config.showHiddenMedia) {
|
||||||
|
@ -244,112 +250,112 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleHiddenItems() {
|
private fun toggleHiddenItems() {
|
||||||
settings_show_hidden_items.toggle()
|
binding.settingsShowHiddenItems.toggle()
|
||||||
config.showHiddenMedia = settings_show_hidden_items.isChecked
|
config.showHiddenMedia = binding.settingsShowHiddenItems.isChecked
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSearchAllFiles() {
|
private fun setupSearchAllFiles() {
|
||||||
settings_search_all_files.isChecked = config.searchAllFilesByDefault
|
binding.settingsSearchAllFiles.isChecked = config.searchAllFilesByDefault
|
||||||
settings_search_all_files_holder.setOnClickListener {
|
binding.settingsSearchAllFilesHolder.setOnClickListener {
|
||||||
settings_search_all_files.toggle()
|
binding.settingsSearchAllFiles.toggle()
|
||||||
config.searchAllFilesByDefault = settings_search_all_files.isChecked
|
config.searchAllFilesByDefault = binding.settingsSearchAllFiles.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAutoplayVideos() {
|
private fun setupAutoplayVideos() {
|
||||||
settings_autoplay_videos.isChecked = config.autoplayVideos
|
binding.settingsAutoplayVideos.isChecked = config.autoplayVideos
|
||||||
settings_autoplay_videos_holder.setOnClickListener {
|
binding.settingsAutoplayVideosHolder.setOnClickListener {
|
||||||
settings_autoplay_videos.toggle()
|
binding.settingsAutoplayVideos.toggle()
|
||||||
config.autoplayVideos = settings_autoplay_videos.isChecked
|
config.autoplayVideos = binding.settingsAutoplayVideos.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupRememberLastVideo() {
|
private fun setupRememberLastVideo() {
|
||||||
settings_remember_last_video_position.isChecked = config.rememberLastVideoPosition
|
binding.settingsRememberLastVideoPosition.isChecked = config.rememberLastVideoPosition
|
||||||
settings_remember_last_video_position_holder.setOnClickListener {
|
binding.settingsRememberLastVideoPositionHolder.setOnClickListener {
|
||||||
settings_remember_last_video_position.toggle()
|
binding.settingsRememberLastVideoPosition.toggle()
|
||||||
config.rememberLastVideoPosition = settings_remember_last_video_position.isChecked
|
config.rememberLastVideoPosition = binding.settingsRememberLastVideoPosition.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLoopVideos() {
|
private fun setupLoopVideos() {
|
||||||
settings_loop_videos.isChecked = config.loopVideos
|
binding.settingsLoopVideos.isChecked = config.loopVideos
|
||||||
settings_loop_videos_holder.setOnClickListener {
|
binding.settingsLoopVideosHolder.setOnClickListener {
|
||||||
settings_loop_videos.toggle()
|
binding.settingsLoopVideos.toggle()
|
||||||
config.loopVideos = settings_loop_videos.isChecked
|
config.loopVideos = binding.settingsLoopVideos.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOpenVideosOnSeparateScreen() {
|
private fun setupOpenVideosOnSeparateScreen() {
|
||||||
settings_open_videos_on_separate_screen.isChecked = config.openVideosOnSeparateScreen
|
binding.settingsOpenVideosOnSeparateScreen.isChecked = config.openVideosOnSeparateScreen
|
||||||
settings_open_videos_on_separate_screen_holder.setOnClickListener {
|
binding.settingsOpenVideosOnSeparateScreenHolder.setOnClickListener {
|
||||||
settings_open_videos_on_separate_screen.toggle()
|
binding.settingsOpenVideosOnSeparateScreen.toggle()
|
||||||
config.openVideosOnSeparateScreen = settings_open_videos_on_separate_screen.isChecked
|
config.openVideosOnSeparateScreen = binding.settingsOpenVideosOnSeparateScreen.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMaxBrightness() {
|
private fun setupMaxBrightness() {
|
||||||
settings_max_brightness.isChecked = config.maxBrightness
|
binding.settingsMaxBrightness.isChecked = config.maxBrightness
|
||||||
settings_max_brightness_holder.setOnClickListener {
|
binding.settingsMaxBrightnessHolder.setOnClickListener {
|
||||||
settings_max_brightness.toggle()
|
binding.settingsMaxBrightness.toggle()
|
||||||
config.maxBrightness = settings_max_brightness.isChecked
|
config.maxBrightness = binding.settingsMaxBrightness.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCropThumbnails() {
|
private fun setupCropThumbnails() {
|
||||||
settings_crop_thumbnails.isChecked = config.cropThumbnails
|
binding.settingsCropThumbnails.isChecked = config.cropThumbnails
|
||||||
settings_crop_thumbnails_holder.setOnClickListener {
|
binding.settingsCropThumbnailsHolder.setOnClickListener {
|
||||||
settings_crop_thumbnails.toggle()
|
binding.settingsCropThumbnails.toggle()
|
||||||
config.cropThumbnails = settings_crop_thumbnails.isChecked
|
config.cropThumbnails = binding.settingsCropThumbnails.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDarkBackground() {
|
private fun setupDarkBackground() {
|
||||||
settings_black_background.isChecked = config.blackBackground
|
binding.settingsBlackBackground.isChecked = config.blackBackground
|
||||||
settings_black_background_holder.setOnClickListener {
|
binding.settingsBlackBackgroundHolder.setOnClickListener {
|
||||||
settings_black_background.toggle()
|
binding.settingsBlackBackground.toggle()
|
||||||
config.blackBackground = settings_black_background.isChecked
|
config.blackBackground = binding.settingsBlackBackground.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupScrollHorizontally() {
|
private fun setupScrollHorizontally() {
|
||||||
settings_scroll_horizontally.isChecked = config.scrollHorizontally
|
binding.settingsScrollHorizontally.isChecked = config.scrollHorizontally
|
||||||
settings_scroll_horizontally_holder.setOnClickListener {
|
binding.settingsScrollHorizontallyHolder.setOnClickListener {
|
||||||
settings_scroll_horizontally.toggle()
|
binding.settingsScrollHorizontally.toggle()
|
||||||
config.scrollHorizontally = settings_scroll_horizontally.isChecked
|
config.scrollHorizontally = binding.settingsScrollHorizontally.isChecked
|
||||||
|
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
config.enablePullToRefresh = false
|
config.enablePullToRefresh = false
|
||||||
settings_enable_pull_to_refresh.isChecked = false
|
binding.settingsEnablePullToRefresh.isChecked = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHideSystemUI() {
|
private fun setupHideSystemUI() {
|
||||||
settings_hide_system_ui.isChecked = config.hideSystemUI
|
binding.settingsHideSystemUi.isChecked = config.hideSystemUI
|
||||||
settings_hide_system_ui_holder.setOnClickListener {
|
binding.settingsHideSystemUiHolder.setOnClickListener {
|
||||||
settings_hide_system_ui.toggle()
|
binding.settingsHideSystemUi.toggle()
|
||||||
config.hideSystemUI = settings_hide_system_ui.isChecked
|
config.hideSystemUI = binding.settingsHideSystemUi.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHiddenItemPasswordProtection() {
|
private fun setupHiddenItemPasswordProtection() {
|
||||||
settings_hidden_item_password_protection_holder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
binding.settingsHiddenItemPasswordProtectionHolder.beGoneIf(isRPlus() && !isExternalStorageManager())
|
||||||
settings_hidden_item_password_protection.isChecked = config.isHiddenPasswordProtectionOn
|
binding.settingsHiddenItemPasswordProtection.isChecked = config.isHiddenPasswordProtectionOn
|
||||||
settings_hidden_item_password_protection_holder.setOnClickListener {
|
binding.settingsHiddenItemPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isHiddenPasswordProtectionOn
|
val hasPasswordProtection = config.isHiddenPasswordProtectionOn
|
||||||
settings_hidden_item_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsHiddenItemPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isHiddenPasswordProtectionOn = !hasPasswordProtection
|
config.isHiddenPasswordProtectionOn = !hasPasswordProtection
|
||||||
config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash
|
config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.hiddenProtectionType = type
|
config.hiddenProtectionType = type
|
||||||
|
|
||||||
if (config.isHiddenPasswordProtectionOn) {
|
if (config.isHiddenPasswordProtectionOn) {
|
||||||
val confirmationTextId = if (config.hiddenProtectionType == PROTECTION_FINGERPRINT)
|
val confirmationTextId = if (config.hiddenProtectionType == PROTECTION_FINGERPRINT)
|
||||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully
|
||||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,22 +363,22 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupExcludedItemPasswordProtection() {
|
private fun setupExcludedItemPasswordProtection() {
|
||||||
settings_excluded_item_password_protection_holder.beGoneIf(settings_hidden_item_password_protection_holder.isVisible())
|
binding.settingsExcludedItemPasswordProtectionHolder.beGoneIf(binding.settingsHiddenItemPasswordProtectionHolder.isVisible())
|
||||||
settings_excluded_item_password_protection.isChecked = config.isExcludedPasswordProtectionOn
|
binding.settingsExcludedItemPasswordProtection.isChecked = config.isExcludedPasswordProtectionOn
|
||||||
settings_excluded_item_password_protection_holder.setOnClickListener {
|
binding.settingsExcludedItemPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isExcludedPasswordProtectionOn) config.excludedProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isExcludedPasswordProtectionOn) config.excludedProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.excludedPasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.excludedPasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isExcludedPasswordProtectionOn
|
val hasPasswordProtection = config.isExcludedPasswordProtectionOn
|
||||||
settings_excluded_item_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsExcludedItemPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isExcludedPasswordProtectionOn = !hasPasswordProtection
|
config.isExcludedPasswordProtectionOn = !hasPasswordProtection
|
||||||
config.excludedPasswordHash = if (hasPasswordProtection) "" else hash
|
config.excludedPasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.excludedProtectionType = type
|
config.excludedProtectionType = type
|
||||||
|
|
||||||
if (config.isExcludedPasswordProtectionOn) {
|
if (config.isExcludedPasswordProtectionOn) {
|
||||||
val confirmationTextId = if (config.excludedProtectionType == PROTECTION_FINGERPRINT)
|
val confirmationTextId = if (config.excludedProtectionType == PROTECTION_FINGERPRINT)
|
||||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully
|
||||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,21 +386,21 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAppPasswordProtection() {
|
private fun setupAppPasswordProtection() {
|
||||||
settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn
|
binding.settingsAppPasswordProtection.isChecked = config.isAppPasswordProtectionOn
|
||||||
settings_app_password_protection_holder.setOnClickListener {
|
binding.settingsAppPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isAppPasswordProtectionOn
|
val hasPasswordProtection = config.isAppPasswordProtectionOn
|
||||||
settings_app_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsAppPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isAppPasswordProtectionOn = !hasPasswordProtection
|
config.isAppPasswordProtectionOn = !hasPasswordProtection
|
||||||
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.appProtectionType = type
|
config.appProtectionType = type
|
||||||
|
|
||||||
if (config.isAppPasswordProtectionOn) {
|
if (config.isAppPasswordProtectionOn) {
|
||||||
val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT)
|
val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT)
|
||||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully
|
||||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,21 +408,21 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFileDeletionPasswordProtection() {
|
private fun setupFileDeletionPasswordProtection() {
|
||||||
settings_file_deletion_password_protection.isChecked = config.isDeletePasswordProtectionOn
|
binding.settingsFileDeletionPasswordProtection.isChecked = config.isDeletePasswordProtectionOn
|
||||||
settings_file_deletion_password_protection_holder.setOnClickListener {
|
binding.settingsFileDeletionPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isDeletePasswordProtectionOn
|
val hasPasswordProtection = config.isDeletePasswordProtectionOn
|
||||||
settings_file_deletion_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsFileDeletionPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isDeletePasswordProtectionOn = !hasPasswordProtection
|
config.isDeletePasswordProtectionOn = !hasPasswordProtection
|
||||||
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
|
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.deleteProtectionType = type
|
config.deleteProtectionType = type
|
||||||
|
|
||||||
if (config.isDeletePasswordProtectionOn) {
|
if (config.isDeletePasswordProtectionOn) {
|
||||||
val confirmationTextId = if (config.deleteProtectionType == PROTECTION_FINGERPRINT)
|
val confirmationTextId = if (config.deleteProtectionType == PROTECTION_FINGERPRINT)
|
||||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
com.simplemobiletools.commons.R.string.fingerprint_setup_successfully else com.simplemobiletools.commons.R.string.protection_setup_successfully
|
||||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
ConfirmationDialog(this, "", confirmationTextId, com.simplemobiletools.commons.R.string.ok, 0) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,65 +430,65 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDeleteEmptyFolders() {
|
private fun setupDeleteEmptyFolders() {
|
||||||
settings_delete_empty_folders.isChecked = config.deleteEmptyFolders
|
binding.settingsDeleteEmptyFolders.isChecked = config.deleteEmptyFolders
|
||||||
settings_delete_empty_folders_holder.setOnClickListener {
|
binding.settingsDeleteEmptyFoldersHolder.setOnClickListener {
|
||||||
settings_delete_empty_folders.toggle()
|
binding.settingsDeleteEmptyFolders.toggle()
|
||||||
config.deleteEmptyFolders = settings_delete_empty_folders.isChecked
|
config.deleteEmptyFolders = binding.settingsDeleteEmptyFolders.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowPhotoGestures() {
|
private fun setupAllowPhotoGestures() {
|
||||||
settings_allow_photo_gestures.isChecked = config.allowPhotoGestures
|
binding.settingsAllowPhotoGestures.isChecked = config.allowPhotoGestures
|
||||||
settings_allow_photo_gestures_holder.setOnClickListener {
|
binding.settingsAllowPhotoGesturesHolder.setOnClickListener {
|
||||||
settings_allow_photo_gestures.toggle()
|
binding.settingsAllowPhotoGestures.toggle()
|
||||||
config.allowPhotoGestures = settings_allow_photo_gestures.isChecked
|
config.allowPhotoGestures = binding.settingsAllowPhotoGestures.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowVideoGestures() {
|
private fun setupAllowVideoGestures() {
|
||||||
settings_allow_video_gestures.isChecked = config.allowVideoGestures
|
binding.settingsAllowVideoGestures.isChecked = config.allowVideoGestures
|
||||||
settings_allow_video_gestures_holder.setOnClickListener {
|
binding.settingsAllowVideoGesturesHolder.setOnClickListener {
|
||||||
settings_allow_video_gestures.toggle()
|
binding.settingsAllowVideoGestures.toggle()
|
||||||
config.allowVideoGestures = settings_allow_video_gestures.isChecked
|
config.allowVideoGestures = binding.settingsAllowVideoGestures.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowDownGesture() {
|
private fun setupAllowDownGesture() {
|
||||||
settings_allow_down_gesture.isChecked = config.allowDownGesture
|
binding.settingsAllowDownGesture.isChecked = config.allowDownGesture
|
||||||
settings_allow_down_gesture_holder.setOnClickListener {
|
binding.settingsAllowDownGestureHolder.setOnClickListener {
|
||||||
settings_allow_down_gesture.toggle()
|
binding.settingsAllowDownGesture.toggle()
|
||||||
config.allowDownGesture = settings_allow_down_gesture.isChecked
|
config.allowDownGesture = binding.settingsAllowDownGesture.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowRotatingWithGestures() {
|
private fun setupAllowRotatingWithGestures() {
|
||||||
settings_allow_rotating_with_gestures.isChecked = config.allowRotatingWithGestures
|
binding.settingsAllowRotatingWithGestures.isChecked = config.allowRotatingWithGestures
|
||||||
settings_allow_rotating_with_gestures_holder.setOnClickListener {
|
binding.settingsAllowRotatingWithGesturesHolder.setOnClickListener {
|
||||||
settings_allow_rotating_with_gestures.toggle()
|
binding.settingsAllowRotatingWithGestures.toggle()
|
||||||
config.allowRotatingWithGestures = settings_allow_rotating_with_gestures.isChecked
|
config.allowRotatingWithGestures = binding.settingsAllowRotatingWithGestures.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowNotch() {
|
private fun setupShowNotch() {
|
||||||
settings_show_notch_holder.beVisibleIf(isPiePlus())
|
binding.settingsShowNotchHolder.beVisibleIf(isPiePlus())
|
||||||
settings_show_notch.isChecked = config.showNotch
|
binding.settingsShowNotch.isChecked = config.showNotch
|
||||||
settings_show_notch_holder.setOnClickListener {
|
binding.settingsShowNotchHolder.setOnClickListener {
|
||||||
settings_show_notch.toggle()
|
binding.settingsShowNotch.toggle()
|
||||||
config.showNotch = settings_show_notch.isChecked
|
config.showNotch = binding.settingsShowNotch.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFileThumbnailStyle() {
|
private fun setupFileThumbnailStyle() {
|
||||||
settings_file_thumbnail_style_holder.setOnClickListener {
|
binding.settingsFileThumbnailStyleHolder.setOnClickListener {
|
||||||
ChangeFileThumbnailStyleDialog(this)
|
ChangeFileThumbnailStyleDialog(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFolderThumbnailStyle() {
|
private fun setupFolderThumbnailStyle() {
|
||||||
settings_folder_thumbnail_style.text = getFolderStyleText()
|
binding.settingsFolderThumbnailStyle.text = getFolderStyleText()
|
||||||
settings_folder_thumbnail_style_holder.setOnClickListener {
|
binding.settingsFolderThumbnailStyleHolder.setOnClickListener {
|
||||||
ChangeFolderThumbnailStyleDialog(this) {
|
ChangeFolderThumbnailStyleDialog(this) {
|
||||||
settings_folder_thumbnail_style.text = getFolderStyleText()
|
binding.settingsFolderThumbnailStyle.text = getFolderStyleText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,107 +501,107 @@ class SettingsActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupKeepLastModified() {
|
private fun setupKeepLastModified() {
|
||||||
settings_keep_last_modified.isChecked = config.keepLastModified
|
binding.settingsKeepLastModified.isChecked = config.keepLastModified
|
||||||
settings_keep_last_modified_holder.setOnClickListener {
|
binding.settingsKeepLastModifiedHolder.setOnClickListener {
|
||||||
handleMediaManagementPrompt {
|
handleMediaManagementPrompt {
|
||||||
settings_keep_last_modified.toggle()
|
binding.settingsKeepLastModified.toggle()
|
||||||
config.keepLastModified = settings_keep_last_modified.isChecked
|
config.keepLastModified = binding.settingsKeepLastModified.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEnablePullToRefresh() {
|
private fun setupEnablePullToRefresh() {
|
||||||
settings_enable_pull_to_refresh.isChecked = config.enablePullToRefresh
|
binding.settingsEnablePullToRefresh.isChecked = config.enablePullToRefresh
|
||||||
settings_enable_pull_to_refresh_holder.setOnClickListener {
|
binding.settingsEnablePullToRefreshHolder.setOnClickListener {
|
||||||
settings_enable_pull_to_refresh.toggle()
|
binding.settingsEnablePullToRefresh.toggle()
|
||||||
config.enablePullToRefresh = settings_enable_pull_to_refresh.isChecked
|
config.enablePullToRefresh = binding.settingsEnablePullToRefresh.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowZoomingImages() {
|
private fun setupAllowZoomingImages() {
|
||||||
settings_allow_zooming_images.isChecked = config.allowZoomingImages
|
binding.settingsAllowZoomingImages.isChecked = config.allowZoomingImages
|
||||||
updateDeepZoomToggleButtons()
|
updateDeepZoomToggleButtons()
|
||||||
settings_allow_zooming_images_holder.setOnClickListener {
|
binding.settingsAllowZoomingImagesHolder.setOnClickListener {
|
||||||
settings_allow_zooming_images.toggle()
|
binding.settingsAllowZoomingImages.toggle()
|
||||||
config.allowZoomingImages = settings_allow_zooming_images.isChecked
|
config.allowZoomingImages = binding.settingsAllowZoomingImages.isChecked
|
||||||
updateDeepZoomToggleButtons()
|
updateDeepZoomToggleButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDeepZoomToggleButtons() {
|
private fun updateDeepZoomToggleButtons() {
|
||||||
settings_allow_rotating_with_gestures_holder.beVisibleIf(config.allowZoomingImages)
|
binding.settingsAllowRotatingWithGesturesHolder.beVisibleIf(config.allowZoomingImages)
|
||||||
settings_show_highest_quality_holder.beVisibleIf(config.allowZoomingImages)
|
binding.settingsShowHighestQualityHolder.beVisibleIf(config.allowZoomingImages)
|
||||||
settings_allow_one_to_one_zoom_holder.beVisibleIf(config.allowZoomingImages)
|
binding.settingsAllowOneToOneZoomHolder.beVisibleIf(config.allowZoomingImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowHighestQuality() {
|
private fun setupShowHighestQuality() {
|
||||||
settings_show_highest_quality.isChecked = config.showHighestQuality
|
binding.settingsShowHighestQuality.isChecked = config.showHighestQuality
|
||||||
settings_show_highest_quality_holder.setOnClickListener {
|
binding.settingsShowHighestQualityHolder.setOnClickListener {
|
||||||
settings_show_highest_quality.toggle()
|
binding.settingsShowHighestQuality.toggle()
|
||||||
config.showHighestQuality = settings_show_highest_quality.isChecked
|
config.showHighestQuality = binding.settingsShowHighestQuality.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowOneToOneZoom() {
|
private fun setupAllowOneToOneZoom() {
|
||||||
settings_allow_one_to_one_zoom.isChecked = config.allowOneToOneZoom
|
binding.settingsAllowOneToOneZoom.isChecked = config.allowOneToOneZoom
|
||||||
settings_allow_one_to_one_zoom_holder.setOnClickListener {
|
binding.settingsAllowOneToOneZoomHolder.setOnClickListener {
|
||||||
settings_allow_one_to_one_zoom.toggle()
|
binding.settingsAllowOneToOneZoom.toggle()
|
||||||
config.allowOneToOneZoom = settings_allow_one_to_one_zoom.isChecked
|
config.allowOneToOneZoom = binding.settingsAllowOneToOneZoom.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAllowInstantChange() {
|
private fun setupAllowInstantChange() {
|
||||||
settings_allow_instant_change.isChecked = config.allowInstantChange
|
binding.settingsAllowInstantChange.isChecked = config.allowInstantChange
|
||||||
settings_allow_instant_change_holder.setOnClickListener {
|
binding.settingsAllowInstantChangeHolder.setOnClickListener {
|
||||||
settings_allow_instant_change.toggle()
|
binding.settingsAllowInstantChange.toggle()
|
||||||
config.allowInstantChange = settings_allow_instant_change.isChecked
|
config.allowInstantChange = binding.settingsAllowInstantChange.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowExtendedDetails() {
|
private fun setupShowExtendedDetails() {
|
||||||
settings_show_extended_details.isChecked = config.showExtendedDetails
|
binding.settingsShowExtendedDetails.isChecked = config.showExtendedDetails
|
||||||
updateExtendedDetailsButtons()
|
updateExtendedDetailsButtons()
|
||||||
settings_show_extended_details_holder.setOnClickListener {
|
binding.settingsShowExtendedDetailsHolder.setOnClickListener {
|
||||||
settings_show_extended_details.toggle()
|
binding.settingsShowExtendedDetails.toggle()
|
||||||
config.showExtendedDetails = settings_show_extended_details.isChecked
|
config.showExtendedDetails = binding.settingsShowExtendedDetails.isChecked
|
||||||
updateExtendedDetailsButtons()
|
updateExtendedDetailsButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHideExtendedDetails() {
|
private fun setupHideExtendedDetails() {
|
||||||
settings_hide_extended_details.isChecked = config.hideExtendedDetails
|
binding.settingsHideExtendedDetails.isChecked = config.hideExtendedDetails
|
||||||
settings_hide_extended_details_holder.setOnClickListener {
|
binding.settingsHideExtendedDetailsHolder.setOnClickListener {
|
||||||
settings_hide_extended_details.toggle()
|
binding.settingsHideExtendedDetails.toggle()
|
||||||
config.hideExtendedDetails = settings_hide_extended_details.isChecked
|
config.hideExtendedDetails = binding.settingsHideExtendedDetails.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageExtendedDetails() {
|
private fun setupManageExtendedDetails() {
|
||||||
settings_manage_extended_details_holder.setOnClickListener {
|
binding.settingsManageExtendedDetailsHolder.setOnClickListener {
|
||||||
ManageExtendedDetailsDialog(this) {
|
ManageExtendedDetailsDialog(this) {
|
||||||
if (config.extendedDetails == 0) {
|
if (config.extendedDetails == 0) {
|
||||||
settings_show_extended_details_holder.callOnClick()
|
binding.settingsShowExtendedDetailsHolder.callOnClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateExtendedDetailsButtons() {
|
private fun updateExtendedDetailsButtons() {
|
||||||
settings_manage_extended_details_holder.beVisibleIf(config.showExtendedDetails)
|
binding.settingsManageExtendedDetailsHolder.beVisibleIf(config.showExtendedDetails)
|
||||||
settings_hide_extended_details_holder.beVisibleIf(config.showExtendedDetails)
|
binding.settingsHideExtendedDetailsHolder.beVisibleIf(config.showExtendedDetails)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSkipDeleteConfirmation() {
|
private fun setupSkipDeleteConfirmation() {
|
||||||
settings_skip_delete_confirmation.isChecked = config.skipDeleteConfirmation
|
binding.settingsSkipDeleteConfirmation.isChecked = config.skipDeleteConfirmation
|
||||||
settings_skip_delete_confirmation_holder.setOnClickListener {
|
binding.settingsSkipDeleteConfirmationHolder.setOnClickListener {
|
||||||
settings_skip_delete_confirmation.toggle()
|
binding.settingsSkipDeleteConfirmation.toggle()
|
||||||
config.skipDeleteConfirmation = settings_skip_delete_confirmation.isChecked
|
config.skipDeleteConfirmation = binding.settingsSkipDeleteConfirmation.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupScreenRotation() {
|
private fun setupScreenRotation() {
|
||||||
settings_screen_rotation.text = getScreenRotationText()
|
binding.settingsScreenRotation.text = getScreenRotationText()
|
||||||
settings_screen_rotation_holder.setOnClickListener {
|
binding.settingsScreenRotationHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(ROTATE_BY_SYSTEM_SETTING, getString(R.string.screen_rotation_system_setting)),
|
RadioItem(ROTATE_BY_SYSTEM_SETTING, getString(R.string.screen_rotation_system_setting)),
|
||||||
RadioItem(ROTATE_BY_DEVICE_ROTATION, getString(R.string.screen_rotation_device_rotation)),
|
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) {
|
RadioGroupDialog(this@SettingsActivity, items, config.screenRotation) {
|
||||||
config.screenRotation = it as Int
|
config.screenRotation = it as Int
|
||||||
settings_screen_rotation.text = getScreenRotationText()
|
binding.settingsScreenRotation.text = getScreenRotationText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,20 +624,20 @@ class SettingsActivity : SimpleActivity() {
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun setupBottomActions() {
|
private fun setupBottomActions() {
|
||||||
settings_bottom_actions_checkbox.isChecked = config.bottomActions
|
binding.settingsBottomActionsCheckbox.isChecked = config.bottomActions
|
||||||
settings_manage_bottom_actions_holder.beVisibleIf(config.bottomActions)
|
binding.settingsManageBottomActionsHolder.beVisibleIf(config.bottomActions)
|
||||||
settings_bottom_actions_checkbox_holder.setOnClickListener {
|
binding.settingsBottomActionsCheckboxHolder.setOnClickListener {
|
||||||
settings_bottom_actions_checkbox.toggle()
|
binding.settingsBottomActionsCheckbox.toggle()
|
||||||
config.bottomActions = settings_bottom_actions_checkbox.isChecked
|
config.bottomActions = binding.settingsBottomActionsCheckbox.isChecked
|
||||||
settings_manage_bottom_actions_holder.beVisibleIf(config.bottomActions)
|
binding.settingsManageBottomActionsHolder.beVisibleIf(config.bottomActions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageBottomActions() {
|
private fun setupManageBottomActions() {
|
||||||
settings_manage_bottom_actions_holder.setOnClickListener {
|
binding.settingsManageBottomActionsHolder.setOnClickListener {
|
||||||
ManageBottomActionsDialog(this) {
|
ManageBottomActionsDialog(this) {
|
||||||
if (config.visibleBottomActions == 0) {
|
if (config.visibleBottomActions == 0) {
|
||||||
settings_bottom_actions_checkbox_holder.callOnClick()
|
binding.settingsBottomActionsCheckboxHolder.callOnClick()
|
||||||
config.bottomActions = false
|
config.bottomActions = false
|
||||||
config.visibleBottomActions = DEFAULT_BOTTOM_ACTIONS
|
config.visibleBottomActions = DEFAULT_BOTTOM_ACTIONS
|
||||||
}
|
}
|
||||||
|
@ -641,28 +647,28 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupUseRecycleBin() {
|
private fun setupUseRecycleBin() {
|
||||||
updateRecycleBinButtons()
|
updateRecycleBinButtons()
|
||||||
settings_use_recycle_bin.isChecked = config.useRecycleBin
|
binding.settingsUseRecycleBin.isChecked = config.useRecycleBin
|
||||||
settings_use_recycle_bin_holder.setOnClickListener {
|
binding.settingsUseRecycleBinHolder.setOnClickListener {
|
||||||
settings_use_recycle_bin.toggle()
|
binding.settingsUseRecycleBin.toggle()
|
||||||
config.useRecycleBin = settings_use_recycle_bin.isChecked
|
config.useRecycleBin = binding.settingsUseRecycleBin.isChecked
|
||||||
updateRecycleBinButtons()
|
updateRecycleBinButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowRecycleBin() {
|
private fun setupShowRecycleBin() {
|
||||||
settings_show_recycle_bin.isChecked = config.showRecycleBinAtFolders
|
binding.settingsShowRecycleBin.isChecked = config.showRecycleBinAtFolders
|
||||||
settings_show_recycle_bin_holder.setOnClickListener {
|
binding.settingsShowRecycleBinHolder.setOnClickListener {
|
||||||
settings_show_recycle_bin.toggle()
|
binding.settingsShowRecycleBin.toggle()
|
||||||
config.showRecycleBinAtFolders = settings_show_recycle_bin.isChecked
|
config.showRecycleBinAtFolders = binding.settingsShowRecycleBin.isChecked
|
||||||
updateRecycleBinButtons()
|
updateRecycleBinButtons()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowRecycleBinLast() {
|
private fun setupShowRecycleBinLast() {
|
||||||
settings_show_recycle_bin_last.isChecked = config.showRecycleBinLast
|
binding.settingsShowRecycleBinLast.isChecked = config.showRecycleBinLast
|
||||||
settings_show_recycle_bin_last_holder.setOnClickListener {
|
binding.settingsShowRecycleBinLastHolder.setOnClickListener {
|
||||||
settings_show_recycle_bin_last.toggle()
|
binding.settingsShowRecycleBinLast.toggle()
|
||||||
config.showRecycleBinLast = settings_show_recycle_bin_last.isChecked
|
config.showRecycleBinLast = binding.settingsShowRecycleBinLast.isChecked
|
||||||
if (config.showRecycleBinLast) {
|
if (config.showRecycleBinLast) {
|
||||||
config.removePinnedFolders(setOf(RECYCLE_BIN))
|
config.removePinnedFolders(setOf(RECYCLE_BIN))
|
||||||
}
|
}
|
||||||
|
@ -670,9 +676,9 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRecycleBinButtons() {
|
private fun updateRecycleBinButtons() {
|
||||||
settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders)
|
binding.settingsShowRecycleBinLastHolder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders)
|
||||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
binding.settingsEmptyRecycleBinHolder.beVisibleIf(config.useRecycleBin)
|
||||||
settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
binding.settingsShowRecycleBinHolder.beVisibleIf(config.useRecycleBin)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmptyRecycleBin() {
|
private fun setupEmptyRecycleBin() {
|
||||||
|
@ -691,18 +697,18 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
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) {
|
if (mRecycleBinContentSize == 0L) {
|
||||||
toast(R.string.recycle_bin_empty)
|
toast(com.simplemobiletools.commons.R.string.recycle_bin_empty)
|
||||||
} else {
|
} else {
|
||||||
showRecycleBinEmptyingDialog {
|
showRecycleBinEmptyingDialog {
|
||||||
emptyTheRecycleBin()
|
emptyTheRecycleBin()
|
||||||
mRecycleBinContentSize = 0L
|
mRecycleBinContentSize = 0L
|
||||||
settings_empty_recycle_bin_size.text = 0L.formatSize()
|
binding.settingsEmptyRecycleBinSize.text = 0L.formatSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -712,22 +718,22 @@ class SettingsActivity : SimpleActivity() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val size = cacheDir.getProperSize(true).formatSize()
|
val size = cacheDir.getProperSize(true).formatSize()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
settings_clear_cache_size.text = size
|
binding.settingsClearCacheSize.text = size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_clear_cache_holder.setOnClickListener {
|
binding.settingsClearCacheHolder.setOnClickListener {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
cacheDir.deleteRecursively()
|
cacheDir.deleteRecursively()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
settings_clear_cache_size.text = cacheDir.getProperSize(true).formatSize()
|
binding.settingsClearCacheSize.text = cacheDir.getProperSize(true).formatSize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupExportFavorites() {
|
private fun setupExportFavorites() {
|
||||||
settings_export_favorites_holder.setOnClickListener {
|
binding.settingsExportFavoritesHolder.setOnClickListener {
|
||||||
if (isQPlus()) {
|
if (isQPlus()) {
|
||||||
ExportFavoritesDialog(this, getExportFavoritesFilename(), true) { path, filename ->
|
ExportFavoritesDialog(this, getExportFavoritesFilename(), true) { path, filename ->
|
||||||
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
|
||||||
|
@ -738,7 +744,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
try {
|
try {
|
||||||
startActivityForResult(this, SELECT_EXPORT_FAVORITES_FILE_INTENT)
|
startActivityForResult(this, SELECT_EXPORT_FAVORITES_FILE_INTENT)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} 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) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -761,7 +767,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun exportFavoritesTo(outputStream: OutputStream?) {
|
private fun exportFavoritesTo(outputStream: OutputStream?) {
|
||||||
if (outputStream == null) {
|
if (outputStream == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,9 +780,9 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toast(R.string.exporting_successful)
|
toast(com.simplemobiletools.commons.R.string.exporting_successful)
|
||||||
} else {
|
} 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() {
|
private fun setupImportFavorites() {
|
||||||
settings_import_favorites_holder.setOnClickListener {
|
binding.settingsImportFavoritesHolder.setOnClickListener {
|
||||||
if (isQPlus()) {
|
if (isQPlus()) {
|
||||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
@ -810,7 +816,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun importFavorites(inputStream: InputStream?) {
|
private fun importFavorites(inputStream: InputStream?) {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
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() {
|
private fun setupExportSettings() {
|
||||||
settings_export_holder.setOnClickListener {
|
binding.settingsExportHolder.setOnClickListener {
|
||||||
val configItems = LinkedHashMap<String, Any>().apply {
|
val configItems = LinkedHashMap<String, Any>().apply {
|
||||||
put(IS_USING_SHARED_THEME, config.isUsingSharedTheme)
|
put(IS_USING_SHARED_THEME, config.isUsingSharedTheme)
|
||||||
put(TEXT_COLOR, config.textColor)
|
put(TEXT_COLOR, config.textColor)
|
||||||
|
@ -930,7 +936,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupImportSettings() {
|
private fun setupImportSettings() {
|
||||||
settings_import_holder.setOnClickListener {
|
binding.settingsImportHolder.setOnClickListener {
|
||||||
if (isQPlus()) {
|
if (isQPlus()) {
|
||||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||||
addCategory(Intent.CATEGORY_OPENABLE)
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
@ -953,7 +959,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun parseFile(inputStream: InputStream?) {
|
private fun parseFile(inputStream: InputStream?) {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,6 +993,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
checkAppIconColor()
|
checkAppIconColor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
USE_ENGLISH -> config.useEnglish = value.toBoolean()
|
USE_ENGLISH -> config.useEnglish = value.toBoolean()
|
||||||
WAS_USE_ENGLISH_TOGGLED -> config.wasUseEnglishToggled = value.toBoolean()
|
WAS_USE_ENGLISH_TOGGLED -> config.wasUseEnglishToggled = value.toBoolean()
|
||||||
WIDGET_BG_COLOR -> config.widgetBgColor = value.toInt()
|
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 {
|
runOnUiThread {
|
||||||
setupSettingItems()
|
setupSettingItems()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,12 @@ import androidx.media3.exoplayer.source.MediaSource
|
||||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.ActivityVideoPlayerBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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 val PLAY_WHEN_READY_DRAG_DELAY = 100L
|
||||||
|
|
||||||
private var mIsFullscreen = false
|
private var mIsFullscreen = false
|
||||||
|
@ -58,10 +58,12 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
private var mIgnoreCloseDown = false
|
private var mIgnoreCloseDown = false
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityVideoPlayerBinding::inflate)
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
showTransparentTop = true
|
showTransparentTop = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_video_player)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
setupOrientation()
|
setupOrientation()
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
|
@ -70,11 +72,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||||
window.statusBarColor = Color.TRANSPARENT
|
window.statusBarColor = Color.TRANSPARENT
|
||||||
window.navigationBarColor = Color.TRANSPARENT
|
window.navigationBarColor = Color.TRANSPARENT
|
||||||
if (config.blackBackground) {
|
if (config.blackBackground) {
|
||||||
video_player_holder.background = ColorDrawable(Color.BLACK)
|
binding.videoPlayerHolder.background = ColorDrawable(Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.maxBrightness) {
|
if (config.maxBrightness) {
|
||||||
|
@ -83,12 +85,12 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
window.attributes = attributes
|
window.attributes = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextColors(video_player_holder)
|
updateTextColors(binding.videoPlayerHolder)
|
||||||
|
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
video_toolbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.videoToolbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} 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()
|
super.onDestroy()
|
||||||
if (!isChangingConfigurations) {
|
if (!isChangingConfigurations) {
|
||||||
pauseVideo()
|
pauseVideo()
|
||||||
video_curr_time.text = 0.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = 0.getFormattedDuration()
|
||||||
releaseExoPlayer()
|
releaseExoPlayer()
|
||||||
video_seekbar.progress = 0
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = 0
|
||||||
mTimerHandler.removeCallbacksAndMessages(null)
|
mTimerHandler.removeCallbacksAndMessages(null)
|
||||||
mPlayWhenReadyHandler.removeCallbacksAndMessages(null)
|
mPlayWhenReadyHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
(video_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.videoAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
video_toolbar.apply {
|
binding.videoToolbar.apply {
|
||||||
setTitleTextColor(Color.WHITE)
|
setTitleTextColor(Color.WHITE)
|
||||||
overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE)
|
overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE)
|
||||||
navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE)
|
navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMenuItemColors(video_toolbar.menu, forceWhiteIcons = true)
|
updateMenuItemColors(binding.videoToolbar.menu, forceWhiteIcons = true)
|
||||||
video_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.videoToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.menu_change_orientation -> changeOrientation()
|
R.id.menu_change_orientation -> changeOrientation()
|
||||||
R.id.menu_open_with -> openPath(mUri!!.toString(), true)
|
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
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
video_toolbar.setNavigationOnClickListener {
|
binding.videoToolbar.setNavigationOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,16 +143,16 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
initTimeHolder()
|
initTimeHolder()
|
||||||
video_surface_frame.onGlobalLayout {
|
binding.videoSurfaceFrame.onGlobalLayout {
|
||||||
video_surface_frame.controller.resetState()
|
binding.videoSurfaceFrame.controller.resetState()
|
||||||
}
|
}
|
||||||
|
|
||||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||||
(video_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.videoAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
video_toolbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.videoToolbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} 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() {
|
private fun initPlayer() {
|
||||||
mUri = intent.data ?: return
|
mUri = intent.data ?: return
|
||||||
video_toolbar.title = getFilenameFromUri(mUri!!)
|
binding.videoToolbar.title = getFilenameFromUri(mUri!!)
|
||||||
initTimeHolder()
|
initTimeHolder()
|
||||||
|
|
||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
|
@ -175,17 +177,17 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
fullscreenToggled(isFullscreen)
|
fullscreenToggled(isFullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
video_curr_time.setOnClickListener { doSkip(false) }
|
binding.bottomVideoTimeHolder.videoCurrTime.setOnClickListener { doSkip(false) }
|
||||||
video_duration.setOnClickListener { doSkip(true) }
|
binding.bottomVideoTimeHolder.videoDuration.setOnClickListener { doSkip(true) }
|
||||||
video_toggle_play_pause.setOnClickListener { togglePlayPause() }
|
binding.bottomVideoTimeHolder.videoTogglePlayPause.setOnClickListener { togglePlayPause() }
|
||||||
video_surface_frame.setOnClickListener { toggleFullscreen() }
|
binding.videoSurfaceFrame.setOnClickListener { toggleFullscreen() }
|
||||||
video_surface_frame.controller.settings.swallowDoubleTaps = true
|
binding.videoSurfaceFrame.controller.settings.swallowDoubleTaps = true
|
||||||
|
|
||||||
video_next_file.beVisibleIf(intent.getBooleanExtra(SHOW_NEXT_ITEM, false))
|
binding.bottomVideoTimeHolder.videoNextFile.beVisibleIf(intent.getBooleanExtra(SHOW_NEXT_ITEM, false))
|
||||||
video_next_file.setOnClickListener { handleNextFile() }
|
binding.bottomVideoTimeHolder.videoNextFile.setOnClickListener { handleNextFile() }
|
||||||
|
|
||||||
video_prev_file.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false))
|
binding.bottomVideoTimeHolder.videoPrevFile.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false))
|
||||||
video_prev_file.setOnClickListener { handlePrevFile() }
|
binding.bottomVideoTimeHolder.videoPrevFile.setOnClickListener { handlePrevFile() }
|
||||||
|
|
||||||
val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() {
|
val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() {
|
||||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
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)
|
handleEvent(event)
|
||||||
gestureDetector.onTouchEvent(event)
|
gestureDetector.onTouchEvent(event)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
initExoPlayer()
|
initExoPlayer()
|
||||||
video_surface.surfaceTextureListener = this
|
binding.videoSurface.surfaceTextureListener = this
|
||||||
|
|
||||||
if (config.allowVideoGestures) {
|
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()
|
toggleFullscreen()
|
||||||
}, doubleTap = { x, y ->
|
}, doubleTap = { x, y ->
|
||||||
doSkip(false)
|
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()
|
toggleFullscreen()
|
||||||
}, doubleTap = { x, y ->
|
}, doubleTap = { x, y ->
|
||||||
doSkip(true)
|
doSkip(true)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
video_brightness_controller.beGone()
|
binding.videoBrightnessController.beGone()
|
||||||
video_volume_controller.beGone()
|
binding.videoVolumeController.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hideSystemUI) {
|
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) {
|
override fun onPositionDiscontinuity(oldPosition: Player.PositionInfo, newPosition: Player.PositionInfo, @Player.DiscontinuityReason reason: Int) {
|
||||||
// Reset progress views when video loops.
|
// Reset progress views when video loops.
|
||||||
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
|
if (reason == Player.DISCONTINUITY_REASON_AUTO_TRANSITION) {
|
||||||
video_seekbar.progress = 0
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = 0
|
||||||
video_curr_time.text = 0.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = 0.getFormattedDuration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,10 +291,10 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
private fun videoPrepared() {
|
private fun videoPrepared() {
|
||||||
if (!mWasVideoStarted) {
|
if (!mWasVideoStarted) {
|
||||||
video_toggle_play_pause.beVisible()
|
binding.bottomVideoTimeHolder.videoTogglePlayPause.beVisible()
|
||||||
mDuration = (mExoPlayer!!.duration / 1000).toInt()
|
mDuration = (mExoPlayer!!.duration / 1000).toInt()
|
||||||
video_seekbar.max = mDuration
|
binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration
|
||||||
video_duration.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration()
|
||||||
setPosition(mCurrTime)
|
setPosition(mCurrTime)
|
||||||
|
|
||||||
if (config.rememberLastVideoPosition) {
|
if (config.rememberLastVideoPosition) {
|
||||||
|
@ -302,7 +304,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
if (config.autoplayVideos) {
|
if (config.autoplayVideos) {
|
||||||
resumeVideo()
|
resumeVideo()
|
||||||
} else {
|
} 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() {
|
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) {
|
if (mExoPlayer == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -334,7 +336,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pauseVideo() {
|
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) {
|
if (mExoPlayer == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -358,8 +360,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
private fun setPosition(seconds: Int) {
|
private fun setPosition(seconds: Int) {
|
||||||
mExoPlayer?.seekTo(seconds * 1000L)
|
mExoPlayer?.seekTo(seconds * 1000L)
|
||||||
video_seekbar.progress = seconds
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = seconds
|
||||||
video_curr_time.text = seconds.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = seconds.getFormattedDuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setLastVideoSavedPosition() {
|
private fun setLastVideoSavedPosition() {
|
||||||
|
@ -376,8 +378,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
clearLastVideoSavedProgress()
|
clearLastVideoSavedProgress()
|
||||||
mCurrTime = (mExoPlayer!!.duration / 1000).toInt()
|
mCurrTime = (mExoPlayer!!.duration / 1000).toInt()
|
||||||
video_seekbar.progress = video_seekbar.max
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = binding.bottomVideoTimeHolder.videoSeekbar.max
|
||||||
video_curr_time.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = mDuration.getFormattedDuration()
|
||||||
pauseVideo()
|
pauseVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +412,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
|
|
||||||
val screenProportion = screenWidth.toFloat() / screenHeight.toFloat()
|
val screenProportion = screenWidth.toFloat() / screenHeight.toFloat()
|
||||||
|
|
||||||
video_surface.layoutParams.apply {
|
binding.videoSurface.layoutParams.apply {
|
||||||
if (videoProportion > screenProportion) {
|
if (videoProportion > screenProportion) {
|
||||||
width = screenWidth
|
width = screenWidth
|
||||||
height = (screenWidth.toFloat() / videoProportion).toInt()
|
height = (screenWidth.toFloat() / videoProportion).toInt()
|
||||||
|
@ -418,7 +420,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
width = (videoProportion * screenHeight.toFloat()).toInt()
|
width = (videoProportion * screenHeight.toFloat()).toInt()
|
||||||
height = screenHeight
|
height = screenHeight
|
||||||
}
|
}
|
||||||
video_surface.layoutParams = this
|
binding.videoSurface.layoutParams = this
|
||||||
}
|
}
|
||||||
|
|
||||||
val multiplier = if (screenWidth > screenHeight) 0.5 else 0.8
|
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
|
val newAlpha = if (isFullScreen) 0f else 1f
|
||||||
arrayOf(
|
arrayOf(
|
||||||
video_prev_file,
|
binding.bottomVideoTimeHolder.videoPrevFile,
|
||||||
video_toggle_play_pause,
|
binding.bottomVideoTimeHolder.videoTogglePlayPause,
|
||||||
video_next_file,
|
binding.bottomVideoTimeHolder.videoNextFile,
|
||||||
video_curr_time,
|
binding.bottomVideoTimeHolder.videoCurrTime,
|
||||||
video_seekbar,
|
binding.bottomVideoTimeHolder.videoSeekbar,
|
||||||
video_duration,
|
binding.bottomVideoTimeHolder.videoDuration,
|
||||||
top_shadow,
|
binding.topShadow,
|
||||||
video_bottom_gradient
|
binding.videoBottomGradient
|
||||||
).forEach {
|
).forEach {
|
||||||
it.animate().alpha(newAlpha).start()
|
it.animate().alpha(newAlpha).start()
|
||||||
}
|
}
|
||||||
video_seekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this)
|
binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this)
|
||||||
arrayOf(video_prev_file, video_next_file, video_curr_time, video_duration).forEach {
|
arrayOf(
|
||||||
|
binding.bottomVideoTimeHolder.videoPrevFile,
|
||||||
|
binding.bottomVideoTimeHolder.videoNextFile,
|
||||||
|
binding.bottomVideoTimeHolder.videoCurrTime,
|
||||||
|
binding.bottomVideoTimeHolder.videoDuration,
|
||||||
|
).forEach {
|
||||||
it.isClickable = !mIsFullscreen
|
it.isClickable = !mIsFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
video_appbar.animate().alpha(newAlpha).withStartAction {
|
binding.videoAppbar.animate().alpha(newAlpha).withStartAction {
|
||||||
video_appbar.beVisible()
|
binding.videoAppbar.beVisible()
|
||||||
}.withEndAction {
|
}.withEndAction {
|
||||||
video_appbar.beVisibleIf(newAlpha == 1f)
|
binding.videoAppbar.beVisibleIf(newAlpha == 1f)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,11 +499,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
video_time_holder.setPadding(0, 0, right, bottom)
|
binding.bottomVideoTimeHolder.videoTimeHolder.setPadding(0, 0, right, bottom)
|
||||||
video_seekbar.setOnSeekBarChangeListener(this)
|
binding.bottomVideoTimeHolder.videoSeekbar.setOnSeekBarChangeListener(this)
|
||||||
video_seekbar.max = mDuration
|
binding.bottomVideoTimeHolder.videoSeekbar.max = mDuration
|
||||||
video_duration.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration()
|
||||||
video_curr_time.text = mCurrTime.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration()
|
||||||
setupTimer()
|
setupTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,8 +512,8 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (mExoPlayer != null && !mIsDragged && mIsPlaying) {
|
if (mExoPlayer != null && !mIsDragged && mIsPlaying) {
|
||||||
mCurrTime = (mExoPlayer!!.currentPosition / 1000).toInt()
|
mCurrTime = (mExoPlayer!!.currentPosition / 1000).toInt()
|
||||||
video_seekbar.progress = mCurrTime
|
binding.bottomVideoTimeHolder.videoSeekbar.progress = mCurrTime
|
||||||
video_curr_time.text = mCurrTime.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoCurrTime.text = mCurrTime.getFormattedDuration()
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimerHandler.postDelayed(this, 1000)
|
mTimerHandler.postDelayed(this, 1000)
|
||||||
|
@ -543,9 +550,13 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
val diffX = event.rawX - mTouchDownX
|
val diffX = event.rawX - mTouchDownX
|
||||||
val diffY = event.rawY - mTouchDownY
|
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) {
|
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()
|
it.animate().alpha(1f).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +581,7 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
||||||
if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold &&
|
if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold &&
|
||||||
downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION &&
|
downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION &&
|
||||||
video_surface_frame.controller.state.zoom == 1f
|
binding.videoSurfaceFrame.controller.state.zoom == 1f
|
||||||
) {
|
) {
|
||||||
supportFinishAfterTransition()
|
supportFinishAfterTransition()
|
||||||
}
|
}
|
||||||
|
@ -578,7 +589,11 @@ import kotlinx.android.synthetic.main.bottom_video_time_holder.*
|
||||||
mIgnoreCloseDown = false
|
mIgnoreCloseDown = false
|
||||||
if (mIsDragged) {
|
if (mIsDragged) {
|
||||||
if (mIsFullscreen) {
|
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()
|
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 onSurfaceTextureDestroyed(surface: SurfaceTexture) = false
|
||||||
|
|
||||||
override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) {
|
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) {}
|
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.simplemobiletools.gallery.pro.BuildConfig
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.MyPagerAdapter
|
import com.simplemobiletools.gallery.pro.adapters.MyPagerAdapter
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
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.DeleteWithRememberDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
|
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.SlideshowDialog
|
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.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
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 java.io.File
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -83,15 +82,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private var mFavoritePaths = ArrayList<String>()
|
private var mFavoritePaths = ArrayList<String>()
|
||||||
private var mIgnoredPaths = ArrayList<String>()
|
private var mIgnoredPaths = ArrayList<String>()
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityMediumBinding::inflate)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
showTransparentTop = true
|
showTransparentTop = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_medium)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
window.decorView.setBackgroundColor(getProperBackgroundColor())
|
window.decorView.setBackgroundColor(getProperBackgroundColor())
|
||||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
binding.topShadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
(MediaActivity.mMedia.clone() as ArrayList<ThumbnailItem>).filterIsInstanceTo(mMediaFiles, Medium::class.java)
|
(MediaActivity.mMedia.clone() as ArrayList<ThumbnailItem>).filterIsInstanceTo(mMediaFiles, Medium::class.java)
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (it) {
|
if (it) {
|
||||||
initViewPager()
|
initViewPager()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
|
|
||||||
val filename = getCurrentMedium()?.name ?: mPath.getFilenameFromPath()
|
val filename = getCurrentMedium()?.name ?: mPath.getFilenameFromPath()
|
||||||
medium_viewer_toolbar.title = filename
|
binding.mediumViewerToolbar.title = filename
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
@ -162,7 +163,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val rotationDegrees = getCurrentPhotoFragment()?.mCurrentRotationDegrees ?: 0
|
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_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_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0
|
||||||
findItem(R.id.menu_properties).isVisible = visibleBottomActions and BOTTOM_ACTION_PROPERTIES == 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() {
|
private fun setupOptionsMenu() {
|
||||||
(medium_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.mediumViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
medium_viewer_toolbar.apply {
|
binding.mediumViewerToolbar.apply {
|
||||||
setTitleTextColor(Color.WHITE)
|
setTitleTextColor(Color.WHITE)
|
||||||
overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE)
|
overflowIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_three_dots_vector, Color.WHITE)
|
||||||
navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE)
|
navigationIcon = resources.getColoredDrawableWithColor(com.simplemobiletools.commons.R.drawable.ic_arrow_left_vector, Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMenuItemColors(medium_viewer_toolbar.menu, forceWhiteIcons = true)
|
updateMenuItemColors(binding.mediumViewerToolbar.menu, forceWhiteIcons = true)
|
||||||
medium_viewer_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.mediumViewerToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
if (getCurrentMedium() == null) {
|
if (getCurrentMedium() == null) {
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
@ -255,7 +256,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
medium_viewer_toolbar.setNavigationOnClickListener {
|
binding.mediumViewerToolbar.setNavigationOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +281,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
initBottomActionsLayout()
|
initBottomActionsLayout()
|
||||||
(medium_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.mediumViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViewPager() {
|
private fun initViewPager() {
|
||||||
|
@ -314,7 +315,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPath.isEmpty()) {
|
if (mPath.isEmpty()) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -368,9 +369,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
isShowingRecycleBin -> RECYCLE_BIN
|
isShowingRecycleBin -> RECYCLE_BIN
|
||||||
else -> mPath.getParentPath()
|
else -> mPath.getParentPath()
|
||||||
}
|
}
|
||||||
medium_viewer_toolbar.title = mPath.getFilenameFromPath()
|
binding.mediumViewerToolbar.title = mPath.getFilenameFromPath()
|
||||||
|
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
if (!isDestroyed) {
|
if (!isDestroyed) {
|
||||||
if (mMediaFiles.isNotEmpty()) {
|
if (mMediaFiles.isNotEmpty()) {
|
||||||
gotMedia(mMediaFiles as ArrayList<ThumbnailItem>, refetchViewPagerPosition = true)
|
gotMedia(mMediaFiles as ArrayList<ThumbnailItem>, refetchViewPagerPosition = true)
|
||||||
|
@ -390,14 +391,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshViewPager(true)
|
refreshViewPager(true)
|
||||||
view_pager.offscreenPageLimit = 2
|
binding.viewPager.offscreenPageLimit = 2
|
||||||
|
|
||||||
if (config.blackBackground) {
|
if (config.blackBackground) {
|
||||||
view_pager.background = ColorDrawable(Color.BLACK)
|
binding.viewPager.background = ColorDrawable(Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hideSystemUI) {
|
if (config.hideSystemUI) {
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
fragmentClicked()
|
fragmentClicked()
|
||||||
}, HIDE_SYSTEM_UI_DELAY)
|
}, HIDE_SYSTEM_UI_DELAY)
|
||||||
|
@ -469,7 +470,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
||||||
if (!isDestroyed) {
|
if (!isDestroyed) {
|
||||||
pagerAdapter.shouldInitFragment = mPos < 5
|
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
|
// must remove the listener before changing adapter, otherwise it might cause `mPos` to be set to 0
|
||||||
removeOnPageChangeListener(this@ViewPagerActivity)
|
removeOnPageChangeListener(this@ViewPagerActivity)
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
|
@ -494,10 +495,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun startSlideshow() {
|
private fun startSlideshow() {
|
||||||
if (getMediaForSlideshow()) {
|
if (getMediaForSlideshow()) {
|
||||||
view_pager.onGlobalLayout {
|
binding.viewPager.onGlobalLayout {
|
||||||
if (!isDestroyed) {
|
if (!isDestroyed) {
|
||||||
if (config.slideshowAnimation == SLIDESHOW_ANIMATION_FADE) {
|
if (config.slideshowAnimation == SLIDESHOW_ANIMATION_FADE) {
|
||||||
view_pager.setPageTransformer(false, FadePageTransformer())
|
binding.viewPager.setPageTransformer(false, FadePageTransformer())
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSystemUI(true)
|
hideSystemUI(true)
|
||||||
|
@ -513,35 +514,35 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun goToNextMedium(forward: Boolean) {
|
private fun goToNextMedium(forward: Boolean) {
|
||||||
val oldPosition = view_pager.currentItem
|
val oldPosition = binding.viewPager.currentItem
|
||||||
val newPosition = if (forward) oldPosition + 1 else oldPosition - 1
|
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)
|
slideshowEnded(forward)
|
||||||
} else {
|
} else {
|
||||||
view_pager.setCurrentItem(newPosition, false)
|
binding.viewPager.setCurrentItem(newPosition, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun animatePagerTransition(forward: Boolean) {
|
private fun animatePagerTransition(forward: Boolean) {
|
||||||
val oldPosition = view_pager.currentItem
|
val oldPosition = binding.viewPager.currentItem
|
||||||
val animator = ValueAnimator.ofInt(0, view_pager.width)
|
val animator = ValueAnimator.ofInt(0, binding.viewPager.width)
|
||||||
animator.addListener(object : Animator.AnimatorListener {
|
animator.addListener(object : Animator.AnimatorListener {
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
if (view_pager.isFakeDragging) {
|
if (binding.viewPager.isFakeDragging) {
|
||||||
try {
|
try {
|
||||||
view_pager.endFakeDrag()
|
binding.viewPager.endFakeDrag()
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
stopSlideshow()
|
stopSlideshow()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view_pager.currentItem == oldPosition) {
|
if (binding.viewPager.currentItem == oldPosition) {
|
||||||
slideshowEnded(forward)
|
slideshowEnded(forward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationCancel(animation: Animator) {
|
override fun onAnimationCancel(animation: Animator) {
|
||||||
view_pager.endFakeDrag()
|
binding.viewPager.endFakeDrag()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAnimationStart(animation: Animator) {}
|
override fun onAnimationStart(animation: Animator) {}
|
||||||
|
@ -559,12 +560,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
animator.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener {
|
animator.addUpdateListener(object : ValueAnimator.AnimatorUpdateListener {
|
||||||
var oldDragPosition = 0
|
var oldDragPosition = 0
|
||||||
override fun onAnimationUpdate(animation: ValueAnimator) {
|
override fun onAnimationUpdate(animation: ValueAnimator) {
|
||||||
if (view_pager?.isFakeDragging == true) {
|
if (binding.viewPager?.isFakeDragging == true) {
|
||||||
val dragPosition = animation.animatedValue as Int
|
val dragPosition = animation.animatedValue as Int
|
||||||
val dragOffset = dragPosition - oldDragPosition
|
val dragOffset = dragPosition - oldDragPosition
|
||||||
oldDragPosition = dragPosition
|
oldDragPosition = dragPosition
|
||||||
try {
|
try {
|
||||||
view_pager.fakeDragBy(dragOffset * (if (forward) -1f else 1f))
|
binding.viewPager.fakeDragBy(dragOffset * (if (forward) -1f else 1f))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
stopSlideshow()
|
stopSlideshow()
|
||||||
}
|
}
|
||||||
|
@ -572,16 +573,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
view_pager.beginFakeDrag()
|
binding.viewPager.beginFakeDrag()
|
||||||
animator.start()
|
animator.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun slideshowEnded(forward: Boolean) {
|
private fun slideshowEnded(forward: Boolean) {
|
||||||
if (config.loopSlideshow) {
|
if (config.loopSlideshow) {
|
||||||
if (forward) {
|
if (forward) {
|
||||||
view_pager.setCurrentItem(0, false)
|
binding.viewPager.setCurrentItem(0, false)
|
||||||
} else {
|
} else {
|
||||||
view_pager.setCurrentItem(view_pager.adapter!!.count - 1, false)
|
binding.viewPager.setCurrentItem(binding.viewPager.adapter!!.count - 1, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stopSlideshow()
|
stopSlideshow()
|
||||||
|
@ -591,7 +592,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun stopSlideshow() {
|
private fun stopSlideshow() {
|
||||||
if (mIsSlideshowActive) {
|
if (mIsSlideshowActive) {
|
||||||
view_pager.setPageTransformer(false, DefaultPageTransformer())
|
binding.viewPager.setPageTransformer(false, DefaultPageTransformer())
|
||||||
mIsSlideshowActive = false
|
mIsSlideshowActive = false
|
||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
mSlideshowHandler.removeCallbacksAndMessages(null)
|
mSlideshowHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -665,7 +666,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val currPath = getCurrentPath()
|
val currPath = getCurrentPath()
|
||||||
if (!isCopyOperation && currPath.startsWith(recycleBinPath)) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +688,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun toggleFileVisibility(hide: Boolean, callback: (() -> Unit)? = null) {
|
private fun toggleFileVisibility(hide: Boolean, callback: (() -> Unit)? = null) {
|
||||||
toggleFileVisibility(getCurrentPath(), hide) {
|
toggleFileVisibility(getCurrentPath(), hide) {
|
||||||
val newFileName = it.getFilenameFromPath()
|
val newFileName = it.getFilenameFromPath()
|
||||||
medium_viewer_toolbar.title = newFileName
|
binding.mediumViewerToolbar.title = newFileName
|
||||||
|
|
||||||
getCurrentMedium()!!.apply {
|
getCurrentMedium()!!.apply {
|
||||||
name = newFileName
|
name = newFileName
|
||||||
|
@ -727,12 +728,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun getChangeOrientationIcon(): Int {
|
private fun getChangeOrientationIcon(): Int {
|
||||||
return if (mIsOrientationLocked) {
|
return if (mIsOrientationLocked) {
|
||||||
if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
||||||
R.drawable.ic_orientation_portrait_vector
|
com.simplemobiletools.commons.R.drawable.ic_orientation_portrait_vector
|
||||||
} else {
|
} else {
|
||||||
R.drawable.ic_orientation_landscape_vector
|
com.simplemobiletools.commons.R.drawable.ic_orientation_landscape_vector
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
return@handleSAFDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
toast(R.string.saving)
|
toast(com.simplemobiletools.commons.R.string.saving)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val photoFragment = getCurrentPhotoFragment() ?: return@ensureBackgroundThread
|
val photoFragment = getCurrentPhotoFragment() ?: return@ensureBackgroundThread
|
||||||
saveRotatedImageToFile(currPath, newPath, photoFragment.mCurrentRotationDegrees, true) {
|
saveRotatedImageToFile(currPath, newPath, photoFragment.mCurrentRotationDegrees, true) {
|
||||||
toast(R.string.file_saved)
|
toast(com.simplemobiletools.commons.R.string.file_saved)
|
||||||
getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0
|
getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
@ -814,7 +815,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return false
|
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() {
|
private fun showProperties() {
|
||||||
if (getCurrentMedium() != null) {
|
if (getCurrentMedium() != null) {
|
||||||
|
@ -823,63 +824,63 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initBottomActionsLayout() {
|
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) {
|
if (config.bottomActions) {
|
||||||
bottom_actions.beVisible()
|
binding.bottomActions.root.beVisible()
|
||||||
} else {
|
} else {
|
||||||
bottom_actions.beGone()
|
binding.bottomActions.root.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
medium_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.mediumViewerToolbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} else {
|
||||||
medium_viewer_toolbar.setPadding(0, 0, 0, 0)
|
binding.mediumViewerToolbar.setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initBottomActionButtons() {
|
private fun initBottomActionButtons() {
|
||||||
val currentMedium = getCurrentMedium()
|
val currentMedium = getCurrentMedium()
|
||||||
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
|
||||||
bottom_favorite.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 && currentMedium?.getIsInRecycleBin() == false)
|
binding.bottomActions.bottomFavorite.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0 && currentMedium?.getIsInRecycleBin() == false)
|
||||||
bottom_favorite.setOnLongClickListener { toast(R.string.toggle_favorite); true }
|
binding.bottomActions.bottomFavorite.setOnLongClickListener { toast(R.string.toggle_favorite); true }
|
||||||
bottom_favorite.setOnClickListener {
|
binding.bottomActions.bottomFavorite.setOnClickListener {
|
||||||
toggleFavorite()
|
toggleFavorite()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_edit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && currentMedium?.isSVG() == false)
|
binding.bottomActions.bottomEdit.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_EDIT != 0 && currentMedium?.isSVG() == false)
|
||||||
bottom_edit.setOnLongClickListener { toast(R.string.edit); true }
|
binding.bottomActions.bottomEdit.setOnLongClickListener { toast(R.string.edit); true }
|
||||||
bottom_edit.setOnClickListener {
|
binding.bottomActions.bottomEdit.setOnClickListener {
|
||||||
openEditor(getCurrentPath())
|
openEditor(getCurrentPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_share.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0)
|
binding.bottomActions.bottomShare.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHARE != 0)
|
||||||
bottom_share.setOnLongClickListener { toast(R.string.share); true }
|
binding.bottomActions.bottomShare.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.share); true }
|
||||||
bottom_share.setOnClickListener {
|
binding.bottomActions.bottomShare.setOnClickListener {
|
||||||
shareMediumPath(getCurrentPath())
|
shareMediumPath(getCurrentPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_delete.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_DELETE != 0)
|
binding.bottomActions.bottomDelete.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_DELETE != 0)
|
||||||
bottom_delete.setOnLongClickListener { toast(R.string.delete); true }
|
binding.bottomActions.bottomDelete.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.delete); true }
|
||||||
bottom_delete.setOnClickListener {
|
binding.bottomActions.bottomDelete.setOnClickListener {
|
||||||
checkDeleteConfirmation()
|
checkDeleteConfirmation()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_rotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true)
|
binding.bottomActions.bottomRotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true)
|
||||||
bottom_rotate.setOnLongClickListener { toast(R.string.rotate); true }
|
binding.bottomActions.bottomRotate.setOnLongClickListener { toast(R.string.rotate); true }
|
||||||
bottom_rotate.setOnClickListener {
|
binding.bottomActions.bottomRotate.setOnClickListener {
|
||||||
rotateImage(90)
|
rotateImage(90)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_properties.applyColorFilter(Color.WHITE)
|
binding.bottomActions.bottomProperties.applyColorFilter(Color.WHITE)
|
||||||
bottom_properties.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_PROPERTIES != 0)
|
binding.bottomActions.bottomProperties.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_PROPERTIES != 0)
|
||||||
bottom_properties.setOnLongClickListener { toast(R.string.properties); true }
|
binding.bottomActions.bottomProperties.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.properties); true }
|
||||||
bottom_properties.setOnClickListener {
|
binding.bottomActions.bottomProperties.setOnClickListener {
|
||||||
showProperties()
|
showProperties()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_change_orientation.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0)
|
binding.bottomActions.bottomChangeOrientation.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0)
|
||||||
bottom_change_orientation.setOnLongClickListener { toast(R.string.change_orientation); true }
|
binding.bottomActions.bottomChangeOrientation.setOnLongClickListener { toast(R.string.change_orientation); true }
|
||||||
bottom_change_orientation.setOnClickListener {
|
binding.bottomActions.bottomChangeOrientation.setOnClickListener {
|
||||||
requestedOrientation = when (requestedOrientation) {
|
requestedOrientation = when (requestedOrientation) {
|
||||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||||
|
@ -889,24 +890,24 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
updateBottomActionIcons(currentMedium)
|
updateBottomActionIcons(currentMedium)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_slideshow.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SLIDESHOW != 0)
|
binding.bottomActions.bottomSlideshow.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SLIDESHOW != 0)
|
||||||
bottom_slideshow.setOnLongClickListener { toast(R.string.slideshow); true }
|
binding.bottomActions.bottomSlideshow.setOnLongClickListener { toast(R.string.slideshow); true }
|
||||||
bottom_slideshow.setOnClickListener {
|
binding.bottomActions.bottomSlideshow.setOnClickListener {
|
||||||
initSlideshow()
|
initSlideshow()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_show_on_map.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0)
|
binding.bottomActions.bottomShowOnMap.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP != 0)
|
||||||
bottom_show_on_map.setOnLongClickListener { toast(R.string.show_on_map); true }
|
binding.bottomActions.bottomShowOnMap.setOnLongClickListener { toast(R.string.show_on_map); true }
|
||||||
bottom_show_on_map.setOnClickListener {
|
binding.bottomActions.bottomShowOnMap.setOnClickListener {
|
||||||
showFileOnMap(getCurrentPath())
|
showFileOnMap(getCurrentPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_toggle_file_visibility.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0)
|
binding.bottomActions.bottomToggleFileVisibility.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0)
|
||||||
bottom_toggle_file_visibility.setOnLongClickListener {
|
binding.bottomActions.bottomToggleFileVisibility.setOnLongClickListener {
|
||||||
toast(if (currentMedium?.isHidden() == true) R.string.unhide else R.string.hide); true
|
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 {
|
currentMedium?.apply {
|
||||||
toggleFileVisibility(!isHidden()) {
|
toggleFileVisibility(!isHidden()) {
|
||||||
updateBottomActionIcons(currentMedium)
|
updateBottomActionIcons(currentMedium)
|
||||||
|
@ -914,33 +915,33 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_rename.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RENAME != 0 && currentMedium?.getIsInRecycleBin() == false)
|
binding.bottomActions.bottomRename.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RENAME != 0 && currentMedium?.getIsInRecycleBin() == false)
|
||||||
bottom_rename.setOnLongClickListener { toast(R.string.rename); true }
|
binding.bottomActions.bottomRename.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.rename); true }
|
||||||
bottom_rename.setOnClickListener {
|
binding.bottomActions.bottomRename.setOnClickListener {
|
||||||
checkMediaManagementAndRename()
|
checkMediaManagementAndRename()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_set_as.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0)
|
binding.bottomActions.bottomSetAs.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_SET_AS != 0)
|
||||||
bottom_set_as.setOnLongClickListener { toast(R.string.set_as); true }
|
binding.bottomActions.bottomSetAs.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.set_as); true }
|
||||||
bottom_set_as.setOnClickListener {
|
binding.bottomActions.bottomSetAs.setOnClickListener {
|
||||||
setAs(getCurrentPath())
|
setAs(getCurrentPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_copy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0)
|
binding.bottomActions.bottomCopy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0)
|
||||||
bottom_copy.setOnLongClickListener { toast(R.string.copy); true }
|
binding.bottomActions.bottomCopy.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.copy); true }
|
||||||
bottom_copy.setOnClickListener {
|
binding.bottomActions.bottomCopy.setOnClickListener {
|
||||||
checkMediaManagementAndCopy(true)
|
checkMediaManagementAndCopy(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_move.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_MOVE != 0)
|
binding.bottomActions.bottomMove.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_MOVE != 0)
|
||||||
bottom_move.setOnLongClickListener { toast(R.string.move); true }
|
binding.bottomActions.bottomMove.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.move); true }
|
||||||
bottom_move.setOnClickListener {
|
binding.bottomActions.bottomMove.setOnClickListener {
|
||||||
moveFileTo()
|
moveFileTo()
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom_resize.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RESIZE != 0 && currentMedium?.isImage() == true)
|
binding.bottomActions.bottomResize.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RESIZE != 0 && currentMedium?.isImage() == true)
|
||||||
bottom_resize.setOnLongClickListener { toast(R.string.resize); true }
|
binding.bottomActions.bottomResize.setOnLongClickListener { toast(com.simplemobiletools.commons.R.string.resize); true }
|
||||||
bottom_resize.setOnClickListener {
|
binding.bottomActions.bottomResize.setOnClickListener {
|
||||||
resizeImage()
|
resizeImage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -950,14 +951,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val favoriteIcon = if (medium.isFavorite) R.drawable.ic_star_vector else R.drawable.ic_star_outline_vector
|
val favoriteIcon =
|
||||||
bottom_favorite.setImageResource(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
|
val hideIcon =
|
||||||
bottom_toggle_file_visibility.setImageResource(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)
|
binding.bottomActions.bottomRotate.beVisibleIf(config.visibleBottomActions and BOTTOM_ACTION_ROTATE != 0 && getCurrentMedium()?.isImage() == true)
|
||||||
bottom_change_orientation.setImageResource(getChangeOrientationIcon())
|
binding.bottomActions.bottomChangeOrientation.setImageResource(getChangeOrientationIcon())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFavorite() {
|
private fun toggleFavorite() {
|
||||||
|
@ -989,7 +992,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
try {
|
try {
|
||||||
val resolution = path.getImageResolution(this)
|
val resolution = path.getImageResolution(this)
|
||||||
if (resolution == null) {
|
if (resolution == null) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,9 +1076,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val isInRecycleBin = getCurrentMedium()!!.getIsInRecycleBin()
|
val isInRecycleBin = getCurrentMedium()!!.getIsInRecycleBin()
|
||||||
|
|
||||||
val baseString = if (config.useRecycleBin && !config.tempSkipRecycleBin && !isInRecycleBin) {
|
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 {
|
} else {
|
||||||
R.string.deletion_confirmation
|
com.simplemobiletools.commons.R.string.deletion_confirmation
|
||||||
}
|
}
|
||||||
|
|
||||||
val message = String.format(resources.getString(baseString), filenameAndSize)
|
val message = String.format(resources.getString(baseString), filenameAndSize)
|
||||||
|
@ -1128,7 +1131,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
val isSDOrOtgRootFolder = isAStorageRootFolder(oldPath.getParentPath()) && !oldPath.startsWith(internalStoragePath)
|
||||||
if (isRPlus() && isSDOrOtgRootFolder && !isExternalStorageManager()) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,12 +1323,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
override fun isSlideShowActive() = mIsSlideshowActive
|
override fun isSlideShowActive() = mIsSlideshowActive
|
||||||
|
|
||||||
override fun goToPrevItem() {
|
override fun goToPrevItem() {
|
||||||
view_pager.setCurrentItem(view_pager.currentItem - 1, false)
|
binding.viewPager.setCurrentItem(binding.viewPager.currentItem - 1, false)
|
||||||
checkOrientation()
|
checkOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun goToNextItem() {
|
override fun goToNextItem() {
|
||||||
view_pager.setCurrentItem(view_pager.currentItem + 1, false)
|
binding.viewPager.setCurrentItem(binding.viewPager.currentItem + 1, false)
|
||||||
checkOrientation()
|
checkOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1340,14 +1343,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
putExtra(IS_FROM_GALLERY, true)
|
putExtra(IS_FROM_GALLERY, true)
|
||||||
putExtra(REAL_FILE_PATH, path)
|
putExtra(REAL_FILE_PATH, path)
|
||||||
putExtra(SHOW_PREV_ITEM, view_pager.currentItem != 0)
|
putExtra(SHOW_PREV_ITEM, binding.viewPager.currentItem != 0)
|
||||||
putExtra(SHOW_NEXT_ITEM, view_pager.currentItem != mMediaFiles.lastIndex)
|
putExtra(SHOW_NEXT_ITEM, binding.viewPager.currentItem != mMediaFiles.lastIndex)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startActivityForResult(this, REQUEST_VIEW_VIDEO)
|
startActivityForResult(this, REQUEST_VIEW_VIDEO)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
if (!tryGenericMimeType(this, mimeType, newUri)) {
|
if (!tryGenericMimeType(this, mimeType, newUri)) {
|
||||||
toast(R.string.no_app_found)
|
toast(com.simplemobiletools.commons.R.string.no_app_found)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
|
@ -1366,20 +1369,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fullscreenToggled() {
|
private fun fullscreenToggled() {
|
||||||
view_pager.adapter?.let {
|
binding.viewPager.adapter?.let {
|
||||||
(it as MyPagerAdapter).toggleFullscreen(mIsFullScreen)
|
(it as MyPagerAdapter).toggleFullscreen(mIsFullScreen)
|
||||||
val newAlpha = if (mIsFullScreen) 0f else 1f
|
val newAlpha = if (mIsFullScreen) 0f else 1f
|
||||||
top_shadow.animate().alpha(newAlpha).start()
|
binding.topShadow.animate().alpha(newAlpha).start()
|
||||||
bottom_actions.animate().alpha(newAlpha).withStartAction {
|
binding.bottomActions.root.animate().alpha(newAlpha).withStartAction {
|
||||||
bottom_actions.beVisible()
|
binding.bottomActions.root.beVisible()
|
||||||
}.withEndAction {
|
}.withEndAction {
|
||||||
bottom_actions.beVisibleIf(newAlpha == 1f)
|
binding.bottomActions.root.beVisibleIf(newAlpha == 1f)
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
medium_viewer_appbar.animate().alpha(newAlpha).withStartAction {
|
binding.mediumViewerAppbar.animate().alpha(newAlpha).withStartAction {
|
||||||
medium_viewer_appbar.beVisible()
|
binding.mediumViewerAppbar.beVisible()
|
||||||
}.withEndAction {
|
}.withEndAction {
|
||||||
medium_viewer_appbar.beVisibleIf(newAlpha == 1f)
|
binding.mediumViewerAppbar.beVisibleIf(newAlpha == 1f)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1391,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val medium = getCurrentMedium()
|
val medium = getCurrentMedium()
|
||||||
if (medium != null) {
|
if (medium != null) {
|
||||||
medium_viewer_toolbar.title = medium.path.getFilenameFromPath()
|
binding.mediumViewerToolbar.title = medium.path.getFilenameFromPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.dialogs.PickDirectoryDialog
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.MyWidgetProvider
|
import com.simplemobiletools.gallery.pro.helpers.MyWidgetProvider
|
||||||
import com.simplemobiletools.gallery.pro.helpers.ROUNDED_CORNERS_NONE
|
import com.simplemobiletools.gallery.pro.helpers.ROUNDED_CORNERS_NONE
|
||||||
import com.simplemobiletools.gallery.pro.models.Directory
|
import com.simplemobiletools.gallery.pro.models.Directory
|
||||||
import com.simplemobiletools.gallery.pro.models.Widget
|
import com.simplemobiletools.gallery.pro.models.Widget
|
||||||
import kotlinx.android.synthetic.main.activity_widget_config.*
|
|
||||||
|
|
||||||
class WidgetConfigureActivity : SimpleActivity() {
|
class WidgetConfigureActivity : SimpleActivity() {
|
||||||
private var mBgAlpha = 0f
|
private var mBgAlpha = 0f
|
||||||
|
@ -30,11 +30,13 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
private var mFolderPath = ""
|
private var mFolderPath = ""
|
||||||
private var mDirectories = ArrayList<Directory>()
|
private var mDirectories = ArrayList<Directory>()
|
||||||
|
|
||||||
|
private val binding by viewBinding(ActivityWidgetConfigBinding::inflate)
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
useDynamicTheme = false
|
useDynamicTheme = false
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setResult(RESULT_CANCELED)
|
setResult(RESULT_CANCELED)
|
||||||
setContentView(R.layout.activity_widget_config)
|
setContentView(binding.root)
|
||||||
initVariables()
|
initVariables()
|
||||||
|
|
||||||
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
||||||
|
@ -43,21 +45,21 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
config_save.setOnClickListener { saveConfig() }
|
binding.configSave.setOnClickListener { saveConfig() }
|
||||||
config_bg_color.setOnClickListener { pickBackgroundColor() }
|
binding.configBgColor.setOnClickListener { pickBackgroundColor() }
|
||||||
config_text_color.setOnClickListener { pickTextColor() }
|
binding.configTextColor.setOnClickListener { pickTextColor() }
|
||||||
folder_picker_value.setOnClickListener { changeSelectedFolder() }
|
binding.folderPickerValue.setOnClickListener { changeSelectedFolder() }
|
||||||
config_image_holder.setOnClickListener { changeSelectedFolder() }
|
binding.configImageHolder.setOnClickListener { changeSelectedFolder() }
|
||||||
|
|
||||||
updateTextColors(folder_picker_holder)
|
updateTextColors(binding.folderPickerHolder)
|
||||||
val primaryColor = getProperPrimaryColor()
|
val primaryColor = getProperPrimaryColor()
|
||||||
config_bg_seekbar.setColors(mTextColor, primaryColor, primaryColor)
|
binding.configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
|
||||||
folder_picker_holder.background = ColorDrawable(getProperBackgroundColor())
|
binding.folderPickerHolder.background = ColorDrawable(getProperBackgroundColor())
|
||||||
|
|
||||||
folder_picker_show_folder_name.isChecked = config.showWidgetFolderName
|
binding.folderPickerShowFolderName.isChecked = config.showWidgetFolderName
|
||||||
handleFolderNameDisplay()
|
handleFolderNameDisplay()
|
||||||
folder_picker_show_folder_name_holder.setOnClickListener {
|
binding.folderPickerShowFolderNameHolder.setOnClickListener {
|
||||||
folder_picker_show_folder_name.toggle()
|
binding.folderPickerShowFolderName.toggle()
|
||||||
handleFolderNameDisplay()
|
handleFolderNameDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
mBgAlpha = Color.alpha(mBgColor) / 255f
|
mBgAlpha = Color.alpha(mBgColor) / 255f
|
||||||
|
|
||||||
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor))
|
||||||
config_bg_seekbar.apply {
|
binding.configBgSeekbar.apply {
|
||||||
progress = (mBgAlpha * 100).toInt()
|
progress = (mBgAlpha * 100).toInt()
|
||||||
|
|
||||||
onSeekBarChangeListener { progress ->
|
onSeekBarChangeListener { progress ->
|
||||||
|
@ -86,8 +88,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
updateBackgroundColor()
|
updateBackgroundColor()
|
||||||
|
|
||||||
mTextColor = config.widgetTextColor
|
mTextColor = config.widgetTextColor
|
||||||
if (mTextColor == resources.getColor(R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
if (mTextColor == resources.getColor(com.simplemobiletools.commons.R.color.default_widget_text_color) && config.isUsingSystemTheme) {
|
||||||
mTextColor = resources.getColor(R.color.you_primary_color, theme)
|
mTextColor = resources.getColor(com.simplemobiletools.commons.R.color.you_primary_color, theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextColor()
|
updateTextColor()
|
||||||
|
@ -97,7 +99,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
val views = RemoteViews(packageName, R.layout.widget)
|
val views = RemoteViews(packageName, R.layout.widget)
|
||||||
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
||||||
AppWidgetManager.getInstance(this)?.updateAppWidget(mWidgetId, views) ?: return
|
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)
|
val widget = Widget(null, mWidgetId, mFolderPath)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
widgetsDB.insertOrUpdate(widget)
|
widgetsDB.insertOrUpdate(widget)
|
||||||
|
@ -128,16 +130,16 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTextColor() {
|
private fun updateTextColor() {
|
||||||
config_folder_name.setTextColor(mTextColor)
|
binding.configFolderName.setTextColor(mTextColor)
|
||||||
config_text_color.setFillWithStroke(mTextColor, mTextColor)
|
binding.configTextColor.setFillWithStroke(mTextColor, mTextColor)
|
||||||
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
|
binding.configSave.setTextColor(getProperPrimaryColor().getContrastColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBackgroundColor() {
|
private fun updateBackgroundColor() {
|
||||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||||
config_image_holder.background.applyColorFilter(mBgColor)
|
binding.configImageHolder.background.applyColorFilter(mBgColor)
|
||||||
config_bg_color.setFillWithStroke(mBgColor, mBgColor)
|
binding.configBgColor.setFillWithStroke(mBgColor, mBgColor)
|
||||||
config_save.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
binding.configSave.backgroundTintList = ColorStateList.valueOf(getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pickBackgroundColor() {
|
private fun pickBackgroundColor() {
|
||||||
|
@ -167,8 +169,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
private fun updateFolderImage(folderPath: String) {
|
private fun updateFolderImage(folderPath: String) {
|
||||||
mFolderPath = folderPath
|
mFolderPath = folderPath
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
folder_picker_value.text = getFolderNameFromPath(folderPath)
|
binding.folderPickerValue.text = getFolderNameFromPath(folderPath)
|
||||||
config_folder_name.text = getFolderNameFromPath(folderPath)
|
binding.configFolderName.text = getFolderNameFromPath(folderPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
|
@ -176,14 +178,14 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val signature = ObjectKey(System.currentTimeMillis().toString())
|
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() {
|
private fun handleFolderNameDisplay() {
|
||||||
val showFolderName = folder_picker_show_folder_name.isChecked
|
val showFolderName = binding.folderPickerShowFolderName.isChecked
|
||||||
config_folder_name.beVisibleIf(showFolderName)
|
binding.configFolderName.beVisibleIf(showFolderName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.MediaActivity
|
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.ConfirmDeleteFolderDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog
|
import com.simplemobiletools.gallery.pro.dialogs.ExcludeFolderDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.PickMediumDialog
|
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.interfaces.DirectoryOperationsListener
|
||||||
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
import com.simplemobiletools.gallery.pro.models.AlbumCover
|
||||||
import com.simplemobiletools.gallery.pro.models.Directory
|
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.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
|
|
||||||
class DirectoryAdapter(
|
class DirectoryAdapter(
|
||||||
activity: BaseSimpleActivity, var dirs: ArrayList<Directory>, val listener: DirectoryOperationsListener?, recyclerView: MyRecyclerView,
|
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 getActionMenuId() = R.menu.cab_directories
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layoutType = when {
|
val binding = when {
|
||||||
isListViewType -> R.layout.directory_item_list
|
isListViewType -> DirectoryItemListBinding.inflate(layoutInflater, parent, false)
|
||||||
folderStyle == FOLDER_STYLE_SQUARE -> R.layout.directory_item_grid_square
|
folderStyle == FOLDER_STYLE_SQUARE -> DirectoryItemGridSquareBinding.inflate(layoutInflater, parent, false)
|
||||||
else -> R.layout.directory_item_grid_rounded_corners
|
else -> DirectoryItemGridRoundedCornersBinding.inflate(layoutInflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return createViewHolder(layoutType, parent)
|
return createViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
|
@ -188,7 +179,7 @@ class DirectoryAdapter(
|
||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
if (!activity.isDestroyed) {
|
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 sourcePath = firstDir.path
|
||||||
val dir = File(sourcePath)
|
val dir = File(sourcePath)
|
||||||
if (activity.isAStorageRootFolder(dir.absolutePath)) {
|
if (activity.isAStorageRootFolder(dir.absolutePath)) {
|
||||||
activity.toast(R.string.rename_folder_root)
|
activity.toast(com.simplemobiletools.commons.R.string.rename_folder_root)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +297,7 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (selectedPaths.any { it.isThisOrParentFolderHidden() }) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +593,13 @@ class DirectoryAdapter(
|
||||||
else -> {
|
else -> {
|
||||||
val itemsCnt = selectedKeys.size
|
val itemsCnt = selectedKeys.size
|
||||||
if (itemsCnt == 1 && getSelectedItems().first().isRecycleBin()) {
|
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()
|
deleteFolders()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -612,18 +609,18 @@ class DirectoryAdapter(
|
||||||
val folder = getSelectedPaths().first().getFilenameFromPath()
|
val folder = getSelectedPaths().first().getFilenameFromPath()
|
||||||
"\"$folder\""
|
"\"$folder\""
|
||||||
} else {
|
} 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 fileDirItem = getFirstSelectedItem() ?: return
|
||||||
val baseString = if (!config.useRecycleBin || config.tempSkipRecycleBin || (isOneItemSelected() && fileDirItem.areFavorites())) {
|
val baseString = if (!config.useRecycleBin || config.tempSkipRecycleBin || (isOneItemSelected() && fileDirItem.areFavorites())) {
|
||||||
R.string.deletion_confirmation
|
com.simplemobiletools.commons.R.string.deletion_confirmation
|
||||||
} else {
|
} 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 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) {
|
ConfirmDeleteFolderDialog(activity, question, warning) {
|
||||||
deleteFolders()
|
deleteFolders()
|
||||||
}
|
}
|
||||||
|
@ -772,8 +769,8 @@ class DirectoryAdapter(
|
||||||
|
|
||||||
private fun setupView(view: View, directory: Directory, holder: ViewHolder) {
|
private fun setupView(view: View, directory: Directory, holder: ViewHolder) {
|
||||||
val isSelected = selectedKeys.contains(directory.path.hashCode())
|
val isSelected = selectedKeys.contains(directory.path.hashCode())
|
||||||
view.apply {
|
bindItem(view).apply {
|
||||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
dirPath?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||||
val thumbnailType = when {
|
val thumbnailType = when {
|
||||||
directory.tmb.isVideoFast() -> TYPE_VIDEOS
|
directory.tmb.isVideoFast() -> TYPE_VIDEOS
|
||||||
directory.tmb.isGif() -> TYPE_GIFS
|
directory.tmb.isGif() -> TYPE_GIFS
|
||||||
|
@ -782,25 +779,25 @@ class DirectoryAdapter(
|
||||||
else -> TYPE_IMAGES
|
else -> TYPE_IMAGES
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_check?.beVisibleIf(isSelected)
|
dirCheck.beVisibleIf(isSelected)
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
dir_check.background?.applyColorFilter(properPrimaryColor)
|
dirCheck.background?.applyColorFilter(properPrimaryColor)
|
||||||
dir_check.applyColorFilter(contrastColor)
|
dirCheck.applyColorFilter(contrastColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListViewType) {
|
if (isListViewType) {
|
||||||
dir_holder.isSelected = isSelected
|
dirHolder.isSelected = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollHorizontally && !isListViewType && folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
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 photoCntParams = (photoCnt.layoutParams as RelativeLayout.LayoutParams)
|
||||||
val nameParams = (dir_name.layoutParams as RelativeLayout.LayoutParams)
|
val nameParams = (dirName.layoutParams as RelativeLayout.LayoutParams)
|
||||||
nameParams.removeRule(RelativeLayout.BELOW)
|
nameParams.removeRule(RelativeLayout.BELOW)
|
||||||
|
|
||||||
if (config.showFolderMediaCount == FOLDER_MEDIA_CNT_LINE) {
|
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)
|
nameParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM)
|
||||||
|
|
||||||
photoCntParams.removeRule(RelativeLayout.BELOW)
|
photoCntParams.removeRule(RelativeLayout.BELOW)
|
||||||
|
@ -811,11 +808,11 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockedFolderPaths.contains(directory.path)) {
|
if (lockedFolderPaths.contains(directory.path)) {
|
||||||
dir_lock.beVisible()
|
dirLock.beVisible()
|
||||||
dir_lock.background = ColorDrawable(context.getProperBackgroundColor())
|
dirLock.background = ColorDrawable(root.context.getProperBackgroundColor())
|
||||||
dir_lock.applyColorFilter(context.getProperBackgroundColor().getContrastColor())
|
dirLock.applyColorFilter(root.context.getProperBackgroundColor().getContrastColor())
|
||||||
} else {
|
} else {
|
||||||
dir_lock.beGone()
|
dirLock.beGone()
|
||||||
val roundedCorners = when {
|
val roundedCorners = when {
|
||||||
isListViewType -> ROUNDED_CORNERS_SMALL
|
isListViewType -> ROUNDED_CORNERS_SMALL
|
||||||
folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE
|
folderStyle == FOLDER_STYLE_SQUARE -> ROUNDED_CORNERS_NONE
|
||||||
|
@ -825,7 +822,7 @@ class DirectoryAdapter(
|
||||||
activity.loadImage(
|
activity.loadImage(
|
||||||
thumbnailType,
|
thumbnailType,
|
||||||
directory.tmb,
|
directory.tmb,
|
||||||
dir_thumbnail,
|
dirThumbnail,
|
||||||
scrollHorizontally,
|
scrollHorizontally,
|
||||||
animateGifs,
|
animateGifs,
|
||||||
cropThumbnails,
|
cropThumbnails,
|
||||||
|
@ -834,18 +831,18 @@ class DirectoryAdapter(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_pin.beVisibleIf(pinnedFolders.contains(directory.path))
|
dirPin.beVisibleIf(pinnedFolders.contains(directory.path))
|
||||||
dir_location.beVisibleIf(directory.location != LOCATION_INTERNAL)
|
dirLocation.beVisibleIf(directory.location != LOCATION_INTERNAL)
|
||||||
if (dir_location.isVisible()) {
|
if (dirLocation.isVisible()) {
|
||||||
dir_location.setImageResource(if (directory.location == LOCATION_SD) R.drawable.ic_sd_card_vector else R.drawable.ic_usb_vector)
|
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()
|
photoCnt.text = directory.subfoldersMediaCount.toString()
|
||||||
photo_cnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE)
|
photoCnt.beVisibleIf(showMediaCount == FOLDER_MEDIA_CNT_LINE)
|
||||||
|
|
||||||
if (limitFolderTitle) {
|
if (limitFolderTitle) {
|
||||||
dir_name.setSingleLine()
|
dirName.setSingleLine()
|
||||||
dir_name.ellipsize = TextUtils.TruncateAt.MIDDLE
|
dirName.ellipsize = TextUtils.TruncateAt.MIDDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
var nameCount = directory.name
|
var nameCount = directory.name
|
||||||
|
@ -859,26 +856,26 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir_name.text = nameCount
|
dirName.text = nameCount
|
||||||
|
|
||||||
if (isListViewType || folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
if (isListViewType || folderStyle == FOLDER_STYLE_ROUNDED_CORNERS) {
|
||||||
photo_cnt.setTextColor(textColor)
|
photoCnt.setTextColor(textColor)
|
||||||
dir_name.setTextColor(textColor)
|
dirName.setTextColor(textColor)
|
||||||
dir_location.applyColorFilter(textColor)
|
dirLocation.applyColorFilter(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListViewType) {
|
if (isListViewType) {
|
||||||
dir_path.setTextColor(textColor)
|
dirPath?.setTextColor(textColor)
|
||||||
dir_pin.applyColorFilter(textColor)
|
dirPin.applyColorFilter(textColor)
|
||||||
dir_location.applyColorFilter(textColor)
|
dirLocation.applyColorFilter(textColor)
|
||||||
dir_drag_handle.beVisibleIf(isDragAndDropping)
|
dirDragHandle.beVisibleIf(isDragAndDropping)
|
||||||
} else {
|
} else {
|
||||||
dir_drag_handle_wrapper.beVisibleIf(isDragAndDropping)
|
dirDragHandleWrapper?.beVisibleIf(isDragAndDropping)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDragAndDropping) {
|
if (isDragAndDropping) {
|
||||||
dir_drag_handle.applyColorFilter(textColor)
|
dirDragHandle.applyColorFilter(textColor)
|
||||||
dir_drag_handle.setOnTouchListener { v, event ->
|
dirDragHandle.setOnTouchListener { v, event ->
|
||||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||||
startReorderDragListener?.requestDrag(holder)
|
startReorderDragListener?.requestDrag(holder)
|
||||||
}
|
}
|
||||||
|
@ -911,4 +908,12 @@ class DirectoryAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChange(position: Int) = dirs.getOrNull(position)?.getBubbleText(directorySorting, activity, dateFormat, timeFormat) ?: ""
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
|
@ -6,8 +6,8 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.EditorFilterItemBinding
|
||||||
import com.simplemobiletools.gallery.pro.models.FilterItem
|
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) :
|
class FiltersAdapter(val context: Context, val filterItems: ArrayList<FilterItem>, val itemClick: (Int) -> Unit) :
|
||||||
RecyclerView.Adapter<FiltersAdapter.ViewHolder>() {
|
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 {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.editor_filter_item, parent, false)
|
val binding = EditorFilterItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
return ViewHolder(view)
|
return ViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = filterItems.size
|
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 {
|
fun bindView(filterItem: FilterItem): View {
|
||||||
itemView.apply {
|
binding.apply {
|
||||||
editor_filter_item_label.text = filterItem.filter.name
|
editorFilterItemLabel.text = filterItem.filter.name
|
||||||
editor_filter_item_thumbnail.setImageBitmap(filterItem.bitmap)
|
editorFilterItemThumbnail.setImageBitmap(filterItem.bitmap)
|
||||||
editor_filter_item_thumbnail.background = if (getCurrentFilter() == filterItem) {
|
editorFilterItemThumbnail.background = if (getCurrentFilter() == filterItem) {
|
||||||
strokeBackground
|
strokeBackground
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
setCurrentFilter(adapterPosition)
|
setCurrentFilter(adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,8 @@ import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.setupViewBackground
|
import com.simplemobiletools.commons.extensions.setupViewBackground
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
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 com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
|
||||||
|
|
||||||
class ManageFoldersAdapter(
|
class ManageFoldersAdapter(
|
||||||
activity: BaseSimpleActivity, var folders: ArrayList<String>, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?,
|
activity: BaseSimpleActivity, var folders: ArrayList<String>, val isShowingExcludedFolders: Boolean, val listener: RefreshRecyclerViewListener?,
|
||||||
|
@ -24,13 +23,13 @@ class ManageFoldersAdapter(
|
||||||
setupDragListener(true)
|
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 prepareActionMode(menu: Menu) {}
|
||||||
|
|
||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
when (id) {
|
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 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) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val folder = folders[position]
|
val folder = folders[position]
|
||||||
|
@ -61,21 +62,21 @@ class ManageFoldersAdapter(
|
||||||
private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<String>
|
private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<String>
|
||||||
|
|
||||||
private fun setupView(view: View, folder: String) {
|
private fun setupView(view: View, folder: String) {
|
||||||
view.apply {
|
ItemManageFolderBinding.bind(view).apply {
|
||||||
setupViewBackground(activity)
|
root.setupViewBackground(activity)
|
||||||
manage_folder_holder?.isSelected = selectedKeys.contains(folder.hashCode())
|
manageFolderHolder.isSelected = selectedKeys.contains(folder.hashCode())
|
||||||
manage_folder_title.apply {
|
manageFolderTitle.apply {
|
||||||
text = folder
|
text = folder
|
||||||
setTextColor(context.getProperTextColor())
|
setTextColor(context.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
overflow_menu_icon.drawable.apply {
|
overflowMenuIcon.drawable.apply {
|
||||||
mutate()
|
mutate()
|
||||||
setTint(activity.getProperTextColor())
|
setTint(activity.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
overflow_menu_icon.setOnClickListener {
|
overflowMenuIcon.setOnClickListener {
|
||||||
showPopupMenu(overflow_menu_anchor, folder)
|
showPopupMenu(overflowMenuAnchor, folder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +91,7 @@ class ManageFoldersAdapter(
|
||||||
setOnMenuItemClickListener { item ->
|
setOnMenuItemClickListener { item ->
|
||||||
val eventTypeId = folder.hashCode()
|
val eventTypeId = folder.hashCode()
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.cab_remove -> {
|
com.simplemobiletools.commons.R.id.cab_remove -> {
|
||||||
executeItemMenuOperation(eventTypeId) {
|
executeItemMenuOperation(eventTypeId) {
|
||||||
removeSelection()
|
removeSelection()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import com.simplemobiletools.commons.extensions.setupViewBackground
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.ItemManageFolderBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.removeNoMedia
|
import com.simplemobiletools.gallery.pro.extensions.removeNoMedia
|
||||||
import kotlinx.android.synthetic.main.item_manage_folder.view.*
|
|
||||||
|
|
||||||
class ManageHiddenFoldersAdapter(
|
class ManageHiddenFoldersAdapter(
|
||||||
activity: BaseSimpleActivity, var folders: ArrayList<String>, val listener: RefreshRecyclerViewListener?,
|
activity: BaseSimpleActivity, var folders: ArrayList<String>, val listener: RefreshRecyclerViewListener?,
|
||||||
|
@ -45,7 +45,9 @@ class ManageHiddenFoldersAdapter(
|
||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
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) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val folder = folders[position]
|
val folder = folders[position]
|
||||||
|
@ -60,10 +62,10 @@ class ManageHiddenFoldersAdapter(
|
||||||
private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<String>
|
private fun getSelectedItems() = folders.filter { selectedKeys.contains(it.hashCode()) } as ArrayList<String>
|
||||||
|
|
||||||
private fun setupView(view: View, folder: String) {
|
private fun setupView(view: View, folder: String) {
|
||||||
view.apply {
|
ItemManageFolderBinding.bind(view).apply {
|
||||||
setupViewBackground(activity)
|
root.setupViewBackground(activity)
|
||||||
manage_folder_holder?.isSelected = selectedKeys.contains(folder.hashCode())
|
manageFolderHolder.isSelected = selectedKeys.contains(folder.hashCode())
|
||||||
manage_folder_title.apply {
|
manageFolderTitle.apply {
|
||||||
text = folder
|
text = folder
|
||||||
setTextColor(context.getProperTextColor())
|
setTextColor(context.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.allViews
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
import com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
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.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity
|
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.dialogs.DeleteWithRememberDialog
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
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(
|
class MediaAdapter(
|
||||||
activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
|
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 getActionMenuId() = R.menu.cab_media
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layoutType = if (viewType == ITEM_SECTION) {
|
val binding = if (viewType == ITEM_SECTION) {
|
||||||
R.layout.thumbnail_section
|
ThumbnailSectionBinding.inflate(layoutInflater, parent, false)
|
||||||
} else {
|
} else {
|
||||||
if (isListViewType) {
|
if (isListViewType) {
|
||||||
if (viewType == ITEM_MEDIUM_PHOTO) {
|
if (viewType == ITEM_MEDIUM_PHOTO) {
|
||||||
R.layout.photo_item_list
|
PhotoItemListBinding.inflate(layoutInflater, parent, false)
|
||||||
} else {
|
} else {
|
||||||
R.layout.video_item_list
|
VideoItemListBinding.inflate(layoutInflater, parent, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (viewType == ITEM_MEDIUM_PHOTO) {
|
if (viewType == ITEM_MEDIUM_PHOTO) {
|
||||||
R.layout.photo_item_grid
|
PhotoItemGridBinding.inflate(layoutInflater, parent, false)
|
||||||
} else {
|
} 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) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
|
@ -196,8 +195,8 @@ class MediaAdapter(
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
if (!activity.isDestroyed) {
|
if (!activity.isDestroyed) {
|
||||||
val itemView = holder.itemView
|
val itemView = holder.itemView
|
||||||
visibleItemPaths.remove(itemView.medium_name?.tag)
|
visibleItemPaths.remove(itemView.allViews.firstOrNull { it.id == R.id.medium_name }?.tag)
|
||||||
val tmb = itemView.medium_thumbnail
|
val tmb = itemView.allViews.firstOrNull { it.id == R.id.medium_thumbnail }
|
||||||
if (tmb != null) {
|
if (tmb != null) {
|
||||||
Glide.with(activity).clear(tmb)
|
Glide.with(activity).clear(tmb)
|
||||||
}
|
}
|
||||||
|
@ -242,7 +241,7 @@ class MediaAdapter(
|
||||||
|
|
||||||
val isSDOrOtgRootFolder = activity.isAStorageRootFolder(firstPath.getParentPath()) && !firstPath.startsWith(activity.internalStoragePath)
|
val isSDOrOtgRootFolder = activity.isAStorageRootFolder(firstPath.getParentPath()) && !firstPath.startsWith(activity.internalStoragePath)
|
||||||
if (isRPlus() && isSDOrOtgRootFolder && !isExternalStorageManager()) {
|
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()
|
finishActMode()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -354,7 +353,7 @@ class MediaAdapter(
|
||||||
private fun handleRotate(paths: List<String>, degrees: Int) {
|
private fun handleRotate(paths: List<String>, degrees: Int) {
|
||||||
var fileCnt = paths.size
|
var fileCnt = paths.size
|
||||||
rotatedImagePaths.clear()
|
rotatedImagePaths.clear()
|
||||||
activity.toast(R.string.saving)
|
activity.toast(com.simplemobiletools.commons.R.string.saving)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
paths.forEach {
|
paths.forEach {
|
||||||
rotatedImagePaths.add(it)
|
rotatedImagePaths.add(it)
|
||||||
|
@ -406,7 +405,7 @@ class MediaAdapter(
|
||||||
}.toMutableList() as ArrayList
|
}.toMutableList() as ArrayList
|
||||||
|
|
||||||
if (!isCopyOperation && paths.any { it.startsWith(recycleBinPath) }) {
|
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()) {
|
if (fileDirItems.isEmpty()) {
|
||||||
|
@ -500,13 +499,13 @@ class MediaAdapter(
|
||||||
fileDirItems.add(curFileDirItem)
|
fileDirItems.add(curFileDirItem)
|
||||||
}
|
}
|
||||||
val fileSize = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
|
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)"
|
"$deleteItemsString ($fileSize)"
|
||||||
}
|
}
|
||||||
|
|
||||||
val isRecycleBin = firstPath.startsWith(activity.recycleBinPath)
|
val isRecycleBin = firstPath.startsWith(activity.recycleBinPath)
|
||||||
val baseString =
|
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 question = String.format(resources.getString(baseString), itemsAndSize)
|
||||||
val showSkipRecycleBinOption = config.useRecycleBin && !isRecycleBin
|
val showSkipRecycleBinOption = config.useRecycleBin && !isRecycleBin
|
||||||
|
|
||||||
|
@ -607,62 +606,62 @@ class MediaAdapter(
|
||||||
|
|
||||||
private fun setupThumbnail(view: View, medium: Medium) {
|
private fun setupThumbnail(view: View, medium: Medium) {
|
||||||
val isSelected = selectedKeys.contains(medium.path.hashCode())
|
val isSelected = selectedKeys.contains(medium.path.hashCode())
|
||||||
view.apply {
|
bindItem(view, medium).apply {
|
||||||
val padding = if (config.thumbnailSpacing <= 1) {
|
val padding = if (config.thumbnailSpacing <= 1) {
|
||||||
config.thumbnailSpacing
|
config.thumbnailSpacing
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
media_item_holder.setPadding(padding, padding, padding, padding)
|
mediaItemHolder.setPadding(padding, padding, padding, padding)
|
||||||
|
|
||||||
favorite.beVisibleIf(medium.isFavorite && config.markFavoriteItems)
|
favorite.beVisibleIf(medium.isFavorite && config.markFavoriteItems)
|
||||||
|
|
||||||
play_portrait_outline?.beVisibleIf(medium.isVideo() || medium.isPortrait())
|
playPortraitOutline?.beVisibleIf(medium.isVideo() || medium.isPortrait())
|
||||||
if (medium.isVideo()) {
|
if (medium.isVideo()) {
|
||||||
play_portrait_outline?.setImageResource(R.drawable.ic_play_outline_vector)
|
playPortraitOutline?.setImageResource(com.simplemobiletools.commons.R.drawable.ic_play_outline_vector)
|
||||||
play_portrait_outline?.beVisible()
|
playPortraitOutline?.beVisible()
|
||||||
} else if (medium.isPortrait()) {
|
} else if (medium.isPortrait()) {
|
||||||
play_portrait_outline?.setImageResource(R.drawable.ic_portrait_photo_vector)
|
playPortraitOutline?.setImageResource(R.drawable.ic_portrait_photo_vector)
|
||||||
play_portrait_outline?.beVisibleIf(showFileTypes)
|
playPortraitOutline?.beVisibleIf(showFileTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showFileTypes && (medium.isGIF() || medium.isRaw() || medium.isSVG())) {
|
if (showFileTypes && (medium.isGIF() || medium.isRaw() || medium.isSVG())) {
|
||||||
file_type.setText(
|
fileType?.setText(
|
||||||
when (medium.type) {
|
when (medium.type) {
|
||||||
TYPE_GIFS -> R.string.gif
|
TYPE_GIFS -> R.string.gif
|
||||||
TYPE_RAWS -> R.string.raw
|
TYPE_RAWS -> R.string.raw
|
||||||
else -> R.string.svg
|
else -> R.string.svg
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
file_type.beVisible()
|
fileType?.beVisible()
|
||||||
} else {
|
} else {
|
||||||
file_type?.beGone()
|
fileType?.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
medium_name.beVisibleIf(displayFilenames || isListViewType)
|
mediumName.beVisibleIf(displayFilenames || isListViewType)
|
||||||
medium_name.text = medium.name
|
mediumName.text = medium.name
|
||||||
medium_name.tag = medium.path
|
mediumName.tag = medium.path
|
||||||
|
|
||||||
val showVideoDuration = medium.isVideo() && config.showThumbnailVideoDuration
|
val showVideoDuration = medium.isVideo() && config.showThumbnailVideoDuration
|
||||||
if (showVideoDuration) {
|
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) {
|
if (isSelected) {
|
||||||
medium_check?.background?.applyColorFilter(properPrimaryColor)
|
mediumCheck.background?.applyColorFilter(properPrimaryColor)
|
||||||
medium_check.applyColorFilter(contrastColor)
|
mediumCheck.applyColorFilter(contrastColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListViewType) {
|
if (isListViewType) {
|
||||||
media_item_holder.isSelected = isSelected
|
mediaItemHolder.isSelected = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = medium.path
|
var path = medium.path
|
||||||
if (hasOTGConnected && context.isPathOnOTG(path)) {
|
if (hasOTGConnected && root.context.isPathOnOTG(path)) {
|
||||||
path = path.getOTGPublicPath(context)
|
path = path.getOTGPublicPath(root.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
val roundedCorners = when {
|
val roundedCorners = when {
|
||||||
|
@ -673,16 +672,16 @@ class MediaAdapter(
|
||||||
|
|
||||||
if (loadImageInstantly) {
|
if (loadImageInstantly) {
|
||||||
activity.loadImage(
|
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 {
|
} else {
|
||||||
medium_thumbnail.setImageDrawable(null)
|
mediumThumbnail.setImageDrawable(null)
|
||||||
medium_thumbnail.isHorizontalScrolling = scrollHorizontally
|
mediumThumbnail.isHorizontalScrolling = scrollHorizontally
|
||||||
delayHandler.postDelayed({
|
delayHandler.postDelayed({
|
||||||
val isVisible = visibleItemPaths.contains(medium.path)
|
val isVisible = visibleItemPaths.contains(medium.path)
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
activity.loadImage(
|
activity.loadImage(
|
||||||
medium.type, path, medium_thumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners,
|
medium.type, path, mediumThumbnail, scrollHorizontally, animateGifs, cropThumbnails, roundedCorners,
|
||||||
medium.getKey(), rotatedImagePaths
|
medium.getKey(), rotatedImagePaths
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -690,16 +689,16 @@ class MediaAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isListViewType) {
|
if (isListViewType) {
|
||||||
medium_name.setTextColor(textColor)
|
mediumName.setTextColor(textColor)
|
||||||
play_portrait_outline?.applyColorFilter(textColor)
|
playPortraitOutline?.applyColorFilter(textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSection(view: View, section: ThumbnailSection) {
|
private fun setupSection(view: View, section: ThumbnailSection) {
|
||||||
view.apply {
|
ThumbnailSectionBinding.bind(view).apply {
|
||||||
thumbnail_section.text = section.title
|
thumbnailSection.text = section.title
|
||||||
thumbnail_section.setTextColor(textColor)
|
thumbnailSection.setTextColor(textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,4 +710,20 @@ class MediaAdapter(
|
||||||
|
|
||||||
return (media[realIndex] as? Medium)?.getBubbleText(sorting, activity, dateFormat, timeFormat) ?: ""
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
|
@ -12,7 +12,7 @@ import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
import com.simplemobiletools.commons.extensions.getFileKey
|
import com.simplemobiletools.commons.extensions.getFileKey
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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) :
|
class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>, val sideElementWidth: Int, val itemClick: (Int, Int) -> Unit) :
|
||||||
RecyclerView.Adapter<PortraitPhotosAdapter.ViewHolder>() {
|
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 {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.portrait_photo_item, parent, false)
|
val binding = PortraitPhotoItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
return ViewHolder(view)
|
return ViewHolder(binding.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount() = photos.size
|
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) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(photo: String, position: Int): View {
|
fun bindView(photo: String, position: Int): View {
|
||||||
itemView.apply {
|
PortraitPhotoItemBinding.bind(itemView).apply {
|
||||||
portrait_photo_item_thumbnail.layoutParams.width = if (position == 0 || position == photos.lastIndex) {
|
portraitPhotoItemThumbnail.layoutParams.width = if (position == 0 || position == photos.lastIndex) {
|
||||||
sideElementWidth
|
sideElementWidth
|
||||||
} else {
|
} else {
|
||||||
itemWidth
|
itemWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
portrait_photo_item_thumbnail.background = if (photo.isEmpty() || position != currentSelectionIndex) {
|
portraitPhotoItemThumbnail.background = if (photo.isEmpty() || position != currentSelectionIndex) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
strokeBackground
|
strokeBackground
|
||||||
|
@ -68,17 +68,17 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
|
||||||
.load(photo)
|
.load(photo)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.into(portrait_photo_item_thumbnail)
|
.into(portraitPhotoItemThumbnail)
|
||||||
|
|
||||||
if (photo.isNotEmpty()) {
|
if (photo.isNotEmpty()) {
|
||||||
isClickable = true
|
root.isClickable = true
|
||||||
views[position] = this
|
views[position] = root
|
||||||
setOnClickListener {
|
root.setOnClickListener {
|
||||||
itemClick(position, x.toInt())
|
itemClick(position, root.x.toInt())
|
||||||
setCurrentPhoto(position)
|
setCurrentPhoto(position)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isClickable = false
|
root.isClickable = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return itemView
|
return itemView
|
||||||
|
|
|
@ -13,7 +13,7 @@ class AllFilesPermissionDialog(
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
|
|
||||||
init {
|
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
|
view.findViewById<TextView>(R.id.message).text = message
|
||||||
|
|
||||||
activity.getAlertDialogBuilder().setPositiveButton(R.string.all_files) { dialog, which -> positivePressed() }
|
activity.getAlertDialogBuilder().setPositiveButton(R.string.all_files) { dialog, which -> positivePressed() }
|
||||||
|
|
|
@ -1,36 +1,34 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
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 com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_file_thumbnail_style.view.*
|
|
||||||
|
|
||||||
class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogInterface.OnClickListener {
|
class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogInterface.OnClickListener {
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var view: View
|
private val binding: DialogChangeFileThumbnailStyleBinding
|
||||||
private var thumbnailSpacing = config.thumbnailSpacing
|
private var thumbnailSpacing = config.thumbnailSpacing
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_file_thumbnail_style, null).apply {
|
binding = DialogChangeFileThumbnailStyleBinding.inflate(activity.layoutInflater).apply {
|
||||||
dialog_file_style_rounded_corners.isChecked = config.fileRoundedCorners
|
dialogFileStyleRoundedCorners.isChecked = config.fileRoundedCorners
|
||||||
dialog_file_style_animate_gifs.isChecked = config.animateGifs
|
dialogFileStyleAnimateGifs.isChecked = config.animateGifs
|
||||||
dialog_file_style_show_thumbnail_video_duration.isChecked = config.showThumbnailVideoDuration
|
dialogFileStyleShowThumbnailVideoDuration.isChecked = config.showThumbnailVideoDuration
|
||||||
dialog_file_style_show_thumbnail_file_types.isChecked = config.showThumbnailFileTypes
|
dialogFileStyleShowThumbnailFileTypes.isChecked = config.showThumbnailFileTypes
|
||||||
dialog_file_style_mark_favorite_items.isChecked = config.markFavoriteItems
|
dialogFileStyleMarkFavoriteItems.isChecked = config.markFavoriteItems
|
||||||
|
|
||||||
dialog_file_style_rounded_corners_holder.setOnClickListener { dialog_file_style_rounded_corners.toggle() }
|
dialogFileStyleRoundedCornersHolder.setOnClickListener { dialogFileStyleRoundedCorners.toggle() }
|
||||||
dialog_file_style_animate_gifs_holder.setOnClickListener { dialog_file_style_animate_gifs.toggle() }
|
dialogFileStyleAnimateGifsHolder.setOnClickListener { dialogFileStyleAnimateGifs.toggle() }
|
||||||
dialog_file_style_show_thumbnail_video_duration_holder.setOnClickListener { dialog_file_style_show_thumbnail_video_duration.toggle() }
|
dialogFileStyleShowThumbnailVideoDurationHolder.setOnClickListener { dialogFileStyleShowThumbnailVideoDuration.toggle() }
|
||||||
dialog_file_style_show_thumbnail_file_types_holder.setOnClickListener { dialog_file_style_show_thumbnail_file_types.toggle() }
|
dialogFileStyleShowThumbnailFileTypesHolder.setOnClickListener { dialogFileStyleShowThumbnailFileTypes.toggle() }
|
||||||
dialog_file_style_mark_favorite_items_holder.setOnClickListener { dialog_file_style_mark_favorite_items.toggle() }
|
dialogFileStyleMarkFavoriteItemsHolder.setOnClickListener { dialogFileStyleMarkFavoriteItems.toggle() }
|
||||||
|
|
||||||
dialog_file_style_spacing_holder.setOnClickListener {
|
dialogFileStyleSpacingHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(0, "0x"),
|
RadioItem(0, "0x"),
|
||||||
RadioItem(1, "1x"),
|
RadioItem(1, "1x"),
|
||||||
|
@ -52,23 +50,23 @@ class ChangeFileThumbnailStyleDialog(val activity: BaseSimpleActivity) : DialogI
|
||||||
updateThumbnailSpacingText()
|
updateThumbnailSpacingText()
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, this)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, this)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
config.fileRoundedCorners = view.dialog_file_style_rounded_corners.isChecked
|
config.fileRoundedCorners = binding.dialogFileStyleRoundedCorners.isChecked
|
||||||
config.animateGifs = view.dialog_file_style_animate_gifs.isChecked
|
config.animateGifs = binding.dialogFileStyleAnimateGifs.isChecked
|
||||||
config.showThumbnailVideoDuration = view.dialog_file_style_show_thumbnail_video_duration.isChecked
|
config.showThumbnailVideoDuration = binding.dialogFileStyleShowThumbnailVideoDuration.isChecked
|
||||||
config.showThumbnailFileTypes = view.dialog_file_style_show_thumbnail_file_types.isChecked
|
config.showThumbnailFileTypes = binding.dialogFileStyleShowThumbnailFileTypes.isChecked
|
||||||
config.markFavoriteItems = view.dialog_file_style_mark_favorite_items.isChecked
|
config.markFavoriteItems = binding.dialogFileStyleMarkFavoriteItems.isChecked
|
||||||
config.thumbnailSpacing = thumbnailSpacing
|
config.thumbnailSpacing = thumbnailSpacing
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateThumbnailSpacingText() {
|
private fun updateThumbnailSpacingText() {
|
||||||
view.dialog_file_style_spacing.text = "${thumbnailSpacing}x"
|
binding.dialogFileStyleSpacing.text = "${thumbnailSpacing}x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,23 +9,25 @@ import com.bumptech.glide.request.RequestOptions
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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 {
|
class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) : DialogInterface.OnClickListener {
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_folder_thumbnail_style, null).apply {
|
private val binding = DialogChangeFolderThumbnailStyleBinding.inflate(activity.layoutInflater).apply {
|
||||||
dialog_folder_limit_title.isChecked = config.limitFolderTitle
|
dialogFolderLimitTitle.isChecked = config.limitFolderTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, this)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, this)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) {
|
activity.setupDialogStuff(binding.root, this) {
|
||||||
setupStyle()
|
setupStyle()
|
||||||
setupMediaCount()
|
setupMediaCount()
|
||||||
updateSample()
|
updateSample()
|
||||||
|
@ -34,29 +36,29 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStyle() {
|
private fun setupStyle() {
|
||||||
val styleRadio = view.dialog_radio_folder_style
|
val styleRadio = binding.dialogRadioFolderStyle
|
||||||
styleRadio.setOnCheckedChangeListener { group, checkedId ->
|
styleRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
updateSample()
|
updateSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
val styleBtn = when (config.folderStyle) {
|
val styleBtn = when (config.folderStyle) {
|
||||||
FOLDER_STYLE_SQUARE -> styleRadio.dialog_radio_folder_square
|
FOLDER_STYLE_SQUARE -> binding.dialogRadioFolderSquare
|
||||||
else -> styleRadio.dialog_radio_folder_rounded_corners
|
else -> binding.dialogRadioFolderRoundedCorners
|
||||||
}
|
}
|
||||||
|
|
||||||
styleBtn.isChecked = true
|
styleBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMediaCount() {
|
private fun setupMediaCount() {
|
||||||
val countRadio = view.dialog_radio_folder_count_holder
|
val countRadio = binding.dialogRadioFolderCountHolder
|
||||||
countRadio.setOnCheckedChangeListener { group, checkedId ->
|
countRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
updateSample()
|
updateSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
val countBtn = when (config.showFolderMediaCount) {
|
val countBtn = when (config.showFolderMediaCount) {
|
||||||
FOLDER_MEDIA_CNT_LINE -> countRadio.dialog_radio_folder_count_line
|
FOLDER_MEDIA_CNT_LINE -> binding.dialogRadioFolderCountLine
|
||||||
FOLDER_MEDIA_CNT_BRACKETS -> countRadio.dialog_radio_folder_count_brackets
|
FOLDER_MEDIA_CNT_BRACKETS -> binding.dialogRadioFolderCountBrackets
|
||||||
else -> countRadio.dialog_radio_folder_count_none
|
else -> binding.dialogRadioFolderCountNone
|
||||||
}
|
}
|
||||||
|
|
||||||
countBtn.isChecked = true
|
countBtn.isChecked = true
|
||||||
|
@ -65,30 +67,36 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal
|
||||||
private fun updateSample() {
|
private fun updateSample() {
|
||||||
val photoCount = 36
|
val photoCount = 36
|
||||||
val folderName = "Camera"
|
val folderName = "Camera"
|
||||||
view.apply {
|
binding.apply {
|
||||||
val useRoundedCornersLayout = dialog_radio_folder_style.checkedRadioButtonId == R.id.dialog_radio_folder_rounded_corners
|
val useRoundedCornersLayout = binding.dialogRadioFolderStyle.checkedRadioButtonId == R.id.dialog_radio_folder_rounded_corners
|
||||||
dialog_folder_sample_holder.removeAllViews()
|
binding.dialogFolderSampleHolder.removeAllViews()
|
||||||
|
|
||||||
val layout = if (useRoundedCornersLayout) R.layout.directory_item_grid_rounded_corners else R.layout.directory_item_grid_square
|
val sampleBinding = if (useRoundedCornersLayout) {
|
||||||
val sampleView = activity.layoutInflater.inflate(layout, null)
|
DirectoryItemGridRoundedCornersBinding.inflate(activity.layoutInflater).toItemBinding()
|
||||||
dialog_folder_sample_holder.addView(sampleView)
|
} 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.width = activity.resources.getDimension(R.dimen.sample_thumbnail_size).toInt()
|
||||||
(sampleView.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.CENTER_HORIZONTAL)
|
(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 -> {
|
R.id.dialog_radio_folder_count_line -> {
|
||||||
dir_name.text = folderName
|
sampleBinding.dirName.text = folderName
|
||||||
photo_cnt.text = photoCount.toString()
|
sampleBinding.photoCnt.text = photoCount.toString()
|
||||||
photo_cnt.beVisible()
|
sampleBinding.photoCnt.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.dialog_radio_folder_count_brackets -> {
|
R.id.dialog_radio_folder_count_brackets -> {
|
||||||
photo_cnt.beGone()
|
sampleBinding.photoCnt.beGone()
|
||||||
dir_name.text = "$folderName ($photoCount)"
|
sampleBinding.dirName.text = "$folderName ($photoCount)"
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
dir_name.text = folderName
|
sampleBinding.dirName.text = folderName
|
||||||
photo_cnt?.beGone()
|
sampleBinding.photoCnt.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,23 +106,23 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal
|
||||||
.apply(options)
|
.apply(options)
|
||||||
|
|
||||||
if (useRoundedCornersLayout) {
|
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))
|
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
dir_name.setTextColor(activity.getProperTextColor())
|
sampleBinding.dirName.setTextColor(activity.getProperTextColor())
|
||||||
photo_cnt.setTextColor(activity.getProperTextColor())
|
sampleBinding.photoCnt.setTextColor(activity.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.into(dir_thumbnail)
|
builder.into(sampleBinding.dirThumbnail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
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
|
R.id.dialog_radio_folder_square -> FOLDER_STYLE_SQUARE
|
||||||
else -> FOLDER_STYLE_ROUNDED_CORNERS
|
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_line -> FOLDER_MEDIA_CNT_LINE
|
||||||
R.id.dialog_radio_folder_count_brackets -> FOLDER_MEDIA_CNT_BRACKETS
|
R.id.dialog_radio_folder_count_brackets -> FOLDER_MEDIA_CNT_BRACKETS
|
||||||
else -> FOLDER_MEDIA_CNT_NONE
|
else -> FOLDER_MEDIA_CNT_NONE
|
||||||
|
@ -122,7 +130,7 @@ class ChangeFolderThumbnailStyleDialog(val activity: BaseSimpleActivity, val cal
|
||||||
|
|
||||||
config.folderStyle = style
|
config.folderStyle = style
|
||||||
config.showFolderMediaCount = count
|
config.showFolderMediaCount = count
|
||||||
config.limitFolderTitle = view.dialog_folder_limit_title.isChecked
|
config.limitFolderTitle = binding.dialogFolderLimitTitle.isChecked
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +1,66 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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) :
|
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) :
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
private var currGrouping = 0
|
private var currGrouping = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||||
private var view: View
|
private val binding: DialogChangeGroupingBinding
|
||||||
|
|
||||||
init {
|
init {
|
||||||
currGrouping = config.getFolderGrouping(pathToUse)
|
currGrouping = config.getFolderGrouping(pathToUse)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply {
|
binding = DialogChangeGroupingBinding.inflate(activity.layoutInflater).apply {
|
||||||
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse)
|
groupingDialogUseForThisFolder.isChecked = config.hasCustomGrouping(pathToUse)
|
||||||
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
|
groupingDialogRadioFolder.beVisibleIf(path.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, this)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, this)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.group_by)
|
activity.setupDialogStuff(binding.root, this, R.string.group_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupGroupRadio()
|
setupGroupRadio()
|
||||||
setupOrderRadio()
|
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() {
|
private fun setupGroupRadio() {
|
||||||
val groupingRadio = view.grouping_dialog_radio_grouping
|
|
||||||
|
|
||||||
val groupBtn = when {
|
val groupBtn = when {
|
||||||
currGrouping and GROUP_BY_NONE != 0 -> groupingRadio.grouping_dialog_radio_none
|
currGrouping and GROUP_BY_NONE != 0 -> binding.groupingDialogRadioNone
|
||||||
currGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 -> groupingRadio.grouping_dialog_radio_last_modified_daily
|
currGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 -> binding.groupingDialogRadioLastModifiedDaily
|
||||||
currGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 -> groupingRadio.grouping_dialog_radio_last_modified_monthly
|
currGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 -> binding.groupingDialogRadioLastModifiedMonthly
|
||||||
currGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> groupingRadio.grouping_dialog_radio_date_taken_daily
|
currGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 -> binding.groupingDialogRadioDateTakenDaily
|
||||||
currGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> groupingRadio.grouping_dialog_radio_date_taken_monthly
|
currGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> binding.groupingDialogRadioDateTakenMonthly
|
||||||
currGrouping and GROUP_BY_FILE_TYPE != 0 -> groupingRadio.grouping_dialog_radio_file_type
|
currGrouping and GROUP_BY_FILE_TYPE != 0 -> binding.groupingDialogRadioFileType
|
||||||
currGrouping and GROUP_BY_EXTENSION != 0 -> groupingRadio.grouping_dialog_radio_extension
|
currGrouping and GROUP_BY_EXTENSION != 0 -> binding.groupingDialogRadioExtension
|
||||||
else -> groupingRadio.grouping_dialog_radio_folder
|
else -> binding.groupingDialogRadioFolder
|
||||||
}
|
}
|
||||||
groupBtn.isChecked = true
|
groupBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrderRadio() {
|
private fun setupOrderRadio() {
|
||||||
val orderRadio = view.grouping_dialog_radio_order
|
var orderBtn = binding.groupingDialogRadioAscending
|
||||||
var orderBtn = orderRadio.grouping_dialog_radio_ascending
|
|
||||||
|
|
||||||
if (currGrouping and GROUP_DESCENDING != 0) {
|
if (currGrouping and GROUP_DESCENDING != 0) {
|
||||||
orderBtn = orderRadio.grouping_dialog_radio_descending
|
orderBtn = binding.groupingDialogRadioDescending
|
||||||
}
|
}
|
||||||
orderBtn.isChecked = true
|
orderBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
val groupingRadio = view.grouping_dialog_radio_grouping
|
val groupingRadio = binding.groupingDialogRadioGrouping
|
||||||
var grouping = when (groupingRadio.checkedRadioButtonId) {
|
var grouping = when (groupingRadio.checkedRadioButtonId) {
|
||||||
R.id.grouping_dialog_radio_none -> GROUP_BY_NONE
|
R.id.grouping_dialog_radio_none -> GROUP_BY_NONE
|
||||||
R.id.grouping_dialog_radio_last_modified_daily -> GROUP_BY_LAST_MODIFIED_DAILY
|
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
|
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
|
grouping = grouping or GROUP_DESCENDING
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.grouping_dialog_show_file_count.isChecked) {
|
if (binding.groupingDialogShowFileCount.isChecked) {
|
||||||
grouping = grouping or GROUP_SHOW_FILE_COUNT
|
grouping = grouping or GROUP_SHOW_FILE_COUNT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.grouping_dialog_use_for_this_folder.isChecked) {
|
if (binding.groupingDialogUseForThisFolder.isChecked) {
|
||||||
config.saveFolderGrouping(pathToUse, grouping)
|
config.saveFolderGrouping(pathToUse, grouping)
|
||||||
} else {
|
} else {
|
||||||
config.removeFolderGrouping(pathToUse)
|
config.removeFolderGrouping(pathToUse)
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL
|
import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
|
||||||
|
|
||||||
class ChangeSortingDialog(
|
class ChangeSortingDialog(
|
||||||
val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean,
|
val activity: BaseSimpleActivity, val isDirectorySorting: Boolean, val showFolderCheckbox: Boolean,
|
||||||
|
@ -18,27 +17,27 @@ class ChangeSortingDialog(
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var pathToUse = if (!isDirectorySorting && path.isEmpty()) SHOW_ALL else path
|
private var pathToUse = if (!isDirectorySorting && path.isEmpty()) SHOW_ALL else path
|
||||||
private var view: View
|
private val binding: DialogChangeSortingBinding
|
||||||
|
|
||||||
init {
|
init {
|
||||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFolderSorting(pathToUse)
|
currSorting = if (isDirectorySorting) config.directorySorting else config.getFolderSorting(pathToUse)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
binding = DialogChangeSortingBinding.inflate(activity.layoutInflater).apply {
|
||||||
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox || (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0))
|
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))
|
sortingDialogNumericSorting.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.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
||||||
|
|
||||||
sorting_dialog_use_for_this_folder.beVisibleIf(showFolderCheckbox)
|
sortingDialogUseForThisFolder.beVisibleIf(showFolderCheckbox)
|
||||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(pathToUse)
|
sortingDialogUseForThisFolder.isChecked = config.hasCustomSorting(pathToUse)
|
||||||
sorting_dialog_bottom_note.beVisibleIf(!isDirectorySorting)
|
sortingDialogBottomNote.beVisibleIf(!isDirectorySorting)
|
||||||
sorting_dialog_radio_custom.beVisibleIf(isDirectorySorting)
|
sortingDialogRadioCustom.beVisibleIf(isDirectorySorting)
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, this)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, this)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.sort_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSortRadio()
|
setupSortRadio()
|
||||||
|
@ -46,41 +45,40 @@ class ChangeSortingDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSortRadio() {
|
private fun setupSortRadio() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
||||||
val isSortingByNameOrPath = checkedId == sortingRadio.sorting_dialog_radio_name.id || checkedId == sortingRadio.sorting_dialog_radio_path.id
|
val isSortingByNameOrPath = checkedId == binding.sortingDialogRadioName.id || checkedId == binding.sortingDialogRadioPath.id
|
||||||
view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByNameOrPath)
|
binding.sortingDialogNumericSorting.beVisibleIf(isSortingByNameOrPath)
|
||||||
view.use_for_this_folder_divider.beVisibleIf(view.sorting_dialog_numeric_sorting.isVisible() || view.sorting_dialog_use_for_this_folder.isVisible())
|
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
|
val hideSortOrder = checkedId == binding.sortingDialogRadioCustom.id || checkedId == binding.sortingDialogRadioRandom.id
|
||||||
view.sorting_dialog_radio_order.beGoneIf(hideSortOrder)
|
binding.sortingDialogRadioOrder.beGoneIf(hideSortOrder)
|
||||||
view.sorting_dialog_order_divider.beGoneIf(hideSortOrder)
|
binding.sortingDialogOrderDivider.beGoneIf(hideSortOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortBtn = when {
|
val sortBtn = when {
|
||||||
currSorting and SORT_BY_PATH != 0 -> sortingRadio.sorting_dialog_radio_path
|
currSorting and SORT_BY_PATH != 0 -> binding.sortingDialogRadioPath
|
||||||
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
|
currSorting and SORT_BY_SIZE != 0 -> binding.sortingDialogRadioSize
|
||||||
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
|
currSorting and SORT_BY_DATE_MODIFIED != 0 -> binding.sortingDialogRadioLastModified
|
||||||
currSorting and SORT_BY_DATE_TAKEN != 0 -> sortingRadio.sorting_dialog_radio_date_taken
|
currSorting and SORT_BY_DATE_TAKEN != 0 -> binding.sortingDialogRadioDateTaken
|
||||||
currSorting and SORT_BY_RANDOM != 0 -> sortingRadio.sorting_dialog_radio_random
|
currSorting and SORT_BY_RANDOM != 0 -> binding.sortingDialogRadioRandom
|
||||||
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
|
currSorting and SORT_BY_CUSTOM != 0 -> binding.sortingDialogRadioCustom
|
||||||
else -> sortingRadio.sorting_dialog_radio_name
|
else -> binding.sortingDialogRadioName
|
||||||
}
|
}
|
||||||
sortBtn.isChecked = true
|
sortBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrderRadio() {
|
private fun setupOrderRadio() {
|
||||||
val orderRadio = view.sorting_dialog_radio_order
|
var orderBtn = binding.sortingDialogRadioAscending
|
||||||
var orderBtn = orderRadio.sorting_dialog_radio_ascending
|
|
||||||
|
|
||||||
if (currSorting and SORT_DESCENDING != 0) {
|
if (currSorting and SORT_DESCENDING != 0) {
|
||||||
orderBtn = orderRadio.sorting_dialog_radio_descending
|
orderBtn = binding.sortingDialogRadioDescending
|
||||||
}
|
}
|
||||||
orderBtn.isChecked = true
|
orderBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
||||||
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
||||||
R.id.sorting_dialog_radio_path -> SORT_BY_PATH
|
R.id.sorting_dialog_radio_path -> SORT_BY_PATH
|
||||||
|
@ -91,18 +89,18 @@ class ChangeSortingDialog(
|
||||||
else -> SORT_BY_DATE_TAKEN
|
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
|
sorting = sorting or SORT_DESCENDING
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_numeric_sorting.isChecked) {
|
if (binding.sortingDialogNumericSorting.isChecked) {
|
||||||
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDirectorySorting) {
|
if (isDirectorySorting) {
|
||||||
config.directorySorting = sorting
|
config.directorySorting = sorting
|
||||||
} else {
|
} else {
|
||||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
if (binding.sortingDialogUseForThisFolder.isChecked) {
|
||||||
config.saveCustomSorting(pathToUse, sorting)
|
config.saveCustomSorting(pathToUse, sorting)
|
||||||
} else {
|
} else {
|
||||||
config.removeCustomSorting(pathToUse)
|
config.removeCustomSorting(pathToUse)
|
||||||
|
|
|
@ -1,61 +1,59 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SHOW_ALL
|
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) {
|
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 config = activity.config
|
||||||
private var pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
private var pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply {
|
binding.apply {
|
||||||
val viewToCheck = if (fromFoldersView) {
|
val viewToCheck = if (fromFoldersView) {
|
||||||
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||||
change_view_type_dialog_radio_grid.id
|
changeViewTypeDialogRadioGrid.id
|
||||||
} else {
|
} else {
|
||||||
change_view_type_dialog_radio_list.id
|
changeViewTypeDialogRadioList.id
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val currViewType = config.getFolderViewType(pathToUse)
|
val currViewType = config.getFolderViewType(pathToUse)
|
||||||
if (currViewType == VIEW_TYPE_GRID) {
|
if (currViewType == VIEW_TYPE_GRID) {
|
||||||
change_view_type_dialog_radio_grid.id
|
changeViewTypeDialogRadioGrid.id
|
||||||
} else {
|
} else {
|
||||||
change_view_type_dialog_radio_list.id
|
changeViewTypeDialogRadioList.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_radio.check(viewToCheck)
|
changeViewTypeDialogRadio.check(viewToCheck)
|
||||||
change_view_type_dialog_group_direct_subfolders.apply {
|
changeViewTypeDialogGroupDirectSubfolders.apply {
|
||||||
beVisibleIf(fromFoldersView)
|
beVisibleIf(fromFoldersView)
|
||||||
isChecked = config.groupDirectSubfolders
|
isChecked = config.groupDirectSubfolders
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_use_for_this_folder.apply {
|
changeViewTypeDialogUseForThisFolder.apply {
|
||||||
beVisibleIf(!fromFoldersView)
|
beVisibleIf(!fromFoldersView)
|
||||||
isChecked = config.hasCustomViewType(pathToUse)
|
isChecked = config.hasCustomViewType(pathToUse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
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
|
VIEW_TYPE_GRID
|
||||||
} else {
|
} else {
|
||||||
VIEW_TYPE_LIST
|
VIEW_TYPE_LIST
|
||||||
|
@ -63,9 +61,9 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val fromFoldersView
|
||||||
|
|
||||||
if (fromFoldersView) {
|
if (fromFoldersView) {
|
||||||
config.viewTypeFolders = viewType
|
config.viewTypeFolders = viewType
|
||||||
config.groupDirectSubfolders = view.change_view_type_dialog_group_direct_subfolders.isChecked
|
config.groupDirectSubfolders = binding.changeViewTypeDialogGroupDirectSubfolders.isChecked
|
||||||
} else {
|
} else {
|
||||||
if (view.change_view_type_dialog_use_for_this_folder.isChecked) {
|
if (binding.changeViewTypeDialogUseForThisFolder.isChecked) {
|
||||||
config.saveFolderViewType(pathToUse, viewType)
|
config.saveFolderViewType(pathToUse, viewType)
|
||||||
} else {
|
} else {
|
||||||
config.removeFolderViewType(pathToUse)
|
config.removeFolderViewType(pathToUse)
|
||||||
|
|
|
@ -4,22 +4,21 @@ import android.app.Activity
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.databinding.DialogConfirmDeleteFolderBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_confirm_delete_folder.view.*
|
|
||||||
|
|
||||||
class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) {
|
class ConfirmDeleteFolderDialog(activity: Activity, message: String, warningMessage: String, val callback: () -> Unit) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_confirm_delete_folder, null)
|
val binding = DialogConfirmDeleteFolderBinding.inflate(activity.layoutInflater)
|
||||||
view.message.text = message
|
binding.message.text = message
|
||||||
view.message_warning.text = warningMessage
|
binding.messageWarning.text = warningMessage
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.yes) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.no, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,27 +7,26 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||||
import com.simplemobiletools.commons.extensions.value
|
import com.simplemobiletools.commons.extensions.value
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.databinding.DialogCustomAspectRatioBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_custom_aspect_ratio.view.*
|
|
||||||
|
|
||||||
class CustomAspectRatioDialog(
|
class CustomAspectRatioDialog(
|
||||||
val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit
|
val activity: BaseSimpleActivity, val defaultCustomAspectRatio: Pair<Float, Float>?, val callback: (aspectRatio: Pair<Float, Float>) -> Unit
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_custom_aspect_ratio, null).apply {
|
val binding = DialogCustomAspectRatioBinding.inflate(activity.layoutInflater).apply {
|
||||||
aspect_ratio_width.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "")
|
aspectRatioWidth.setText(defaultCustomAspectRatio?.first?.toInt()?.toString() ?: "")
|
||||||
aspect_ratio_height.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "")
|
aspectRatioHeight.setText(defaultCustomAspectRatio?.second?.toInt()?.toString() ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.aspect_ratio_width)
|
alertDialog.showKeyboard(binding.aspectRatioWidth)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val width = getViewValue(view.aspect_ratio_width)
|
val width = getViewValue(binding.aspectRatioWidth)
|
||||||
val height = getViewValue(view.aspect_ratio_height)
|
val height = getViewValue(binding.aspectRatioHeight)
|
||||||
callback(Pair(width, height))
|
callback(Pair(width, height))
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.databinding.DialogDeleteWithRememberBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.*
|
|
||||||
|
|
||||||
class DeleteWithRememberDialog(
|
class DeleteWithRememberDialog(
|
||||||
private val activity: Activity,
|
private val activity: Activity,
|
||||||
|
@ -16,16 +15,16 @@ class DeleteWithRememberDialog(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var dialog: AlertDialog? = null
|
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 {
|
init {
|
||||||
view.delete_remember_title.text = message
|
binding.deleteRememberTitle.text = message
|
||||||
view.skip_the_recycle_bin_checkbox.beGoneIf(!showSkipRecycleBinOption)
|
binding.skipTheRecycleBinCheckbox.beGoneIf(!showSkipRecycleBinOption)
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.yes) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.yes) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.no, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +32,6 @@ class DeleteWithRememberDialog(
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
callback(view.delete_remember_checkbox.isChecked, view.skip_the_recycle_bin_checkbox.isChecked)
|
callback(binding.deleteRememberCheckbox.isChecked, binding.skipTheRecycleBinCheckbox.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.RadioButton
|
|
||||||
import android.widget.RadioGroup
|
import android.widget.RadioGroup
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.databinding.RadioButtonBinding
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.getBasePath
|
import com.simplemobiletools.commons.extensions.getBasePath
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
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 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) {
|
class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: List<String>, val callback: () -> Unit) {
|
||||||
private val alternativePaths = getAlternativePathsList()
|
private val alternativePaths = getAlternativePathsList()
|
||||||
private var radioGroup: RadioGroup? = null
|
private var radioGroup: RadioGroup? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_exclude_folder, null).apply {
|
val binding = DialogExcludeFolderBinding.inflate(activity.layoutInflater).apply {
|
||||||
exclude_folder_parent.beVisibleIf(alternativePaths.size > 1)
|
excludeFolderParent.beVisibleIf(alternativePaths.size > 1)
|
||||||
|
|
||||||
radioGroup = exclude_folder_radio_group
|
radioGroup = excludeFolderRadioGroup
|
||||||
exclude_folder_radio_group.beVisibleIf(alternativePaths.size > 1)
|
excludeFolderRadioGroup.beVisibleIf(alternativePaths.size > 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
alternativePaths.forEachIndexed { index, value ->
|
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]
|
text = alternativePaths[index]
|
||||||
isChecked = index == 0
|
isChecked = index == 0
|
||||||
id = index
|
id = index
|
||||||
|
@ -34,10 +33,10 @@ class ExcludeFolderDialog(val activity: BaseSimpleActivity, val selectedPaths: L
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.DialogExportFavoritesBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_export_favorites.view.*
|
|
||||||
|
|
||||||
class ExportFavoritesDialog(
|
class ExportFavoritesDialog(
|
||||||
val activity: BaseSimpleActivity, val defaultFilename: String, val hidePath: Boolean,
|
val activity: BaseSimpleActivity, val defaultFilename: String, val hidePath: Boolean,
|
||||||
|
@ -21,17 +21,17 @@ class ExportFavoritesDialog(
|
||||||
activity.internalStoragePath
|
activity.internalStoragePath
|
||||||
}
|
}
|
||||||
|
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_export_favorites, null).apply {
|
val binding = DialogExportFavoritesBinding.inflate(activity.layoutInflater).apply {
|
||||||
export_favorites_filename.setText(defaultFilename.removeSuffix(".txt"))
|
exportFavoritesFilename.setText(defaultFilename.removeSuffix(".txt"))
|
||||||
|
|
||||||
if (hidePath) {
|
if (hidePath) {
|
||||||
export_favorites_path_label.beGone()
|
exportFavoritesPathLabel.beGone()
|
||||||
export_favorites_path.beGone()
|
exportFavoritesPath.beGone()
|
||||||
} else {
|
} else {
|
||||||
export_favorites_path.text = activity.humanizePath(folder)
|
exportFavoritesPath.text = activity.humanizePath(folder)
|
||||||
export_favorites_path.setOnClickListener {
|
exportFavoritesPath.setOnClickListener {
|
||||||
FilePickerDialog(activity, folder, false, showFAB = true) {
|
FilePickerDialog(activity, folder, false, showFAB = true) {
|
||||||
export_favorites_path.text = activity.humanizePath(it)
|
exportFavoritesPath.text = activity.humanizePath(it)
|
||||||
folder = it
|
folder = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,27 +39,30 @@ class ExportFavoritesDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.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 {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
var filename = view.export_favorites_filename.value
|
var filename = binding.exportFavoritesFilename.value
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
filename += ".txt"
|
filename += ".txt"
|
||||||
val newPath = "${folder.trimEnd('/')}/$filename"
|
val newPath = "${folder.trimEnd('/')}/$filename"
|
||||||
if (!newPath.getFilenameFromPath().isAValidFilename()) {
|
if (!newPath.getFilenameFromPath().isAValidFilename()) {
|
||||||
activity.toast(R.string.filename_invalid_characters)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.config.lastExportedFavoritesFolder = folder
|
activity.config.lastExportedFavoritesFolder = folder
|
||||||
if (!hidePath && activity.getDoesFilePathExist(newPath)) {
|
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) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newPath, filename)
|
callback(newPath, filename)
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
|
|
|
@ -4,45 +4,45 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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) {
|
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 {
|
init {
|
||||||
val filterMedia = activity.config.filterMedia
|
val filterMedia = activity.config.filterMedia
|
||||||
view.apply {
|
binding.apply {
|
||||||
filter_media_images.isChecked = filterMedia and TYPE_IMAGES != 0
|
filterMediaImages.isChecked = filterMedia and TYPE_IMAGES != 0
|
||||||
filter_media_videos.isChecked = filterMedia and TYPE_VIDEOS != 0
|
filterMediaVideos.isChecked = filterMedia and TYPE_VIDEOS != 0
|
||||||
filter_media_gifs.isChecked = filterMedia and TYPE_GIFS != 0
|
filterMediaGifs.isChecked = filterMedia and TYPE_GIFS != 0
|
||||||
filter_media_raws.isChecked = filterMedia and TYPE_RAWS != 0
|
filterMediaRaws.isChecked = filterMedia and TYPE_RAWS != 0
|
||||||
filter_media_svgs.isChecked = filterMedia and TYPE_SVGS != 0
|
filterMediaSvgs.isChecked = filterMedia and TYPE_SVGS != 0
|
||||||
filter_media_portraits.isChecked = filterMedia and TYPE_PORTRAITS != 0
|
filterMediaPortraits.isChecked = filterMedia and TYPE_PORTRAITS != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
activity.setupDialogStuff(binding.root, this, R.string.filter_media)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
if (view.filter_media_images.isChecked)
|
if (binding.filterMediaImages.isChecked)
|
||||||
result += TYPE_IMAGES
|
result += TYPE_IMAGES
|
||||||
if (view.filter_media_videos.isChecked)
|
if (binding.filterMediaVideos.isChecked)
|
||||||
result += TYPE_VIDEOS
|
result += TYPE_VIDEOS
|
||||||
if (view.filter_media_gifs.isChecked)
|
if (binding.filterMediaGifs.isChecked)
|
||||||
result += TYPE_GIFS
|
result += TYPE_GIFS
|
||||||
if (view.filter_media_raws.isChecked)
|
if (binding.filterMediaRaws.isChecked)
|
||||||
result += TYPE_RAWS
|
result += TYPE_RAWS
|
||||||
if (view.filter_media_svgs.isChecked)
|
if (binding.filterMediaSvgs.isChecked)
|
||||||
result += TYPE_SVGS
|
result += TYPE_SVGS
|
||||||
if (view.filter_media_portraits.isChecked)
|
if (binding.filterMediaPortraits.isChecked)
|
||||||
result += TYPE_PORTRAITS
|
result += TYPE_PORTRAITS
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
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 com.simplemobiletools.gallery.pro.extensions.launchGrantAllFilesIntent
|
||||||
import kotlinx.android.synthetic.main.dialog_grant_all_files.view.*
|
|
||||||
|
|
||||||
class GrantAllFilesDialog(val activity: BaseSimpleActivity) {
|
class GrantAllFilesDialog(val activity: BaseSimpleActivity) {
|
||||||
init {
|
init {
|
||||||
val view: View = activity.layoutInflater.inflate(R.layout.dialog_grant_all_files, null)
|
val binding = DialogGrantAllFilesBinding.inflate(activity.layoutInflater)
|
||||||
view.grant_all_files_image.applyColorFilter(activity.getProperTextColor())
|
binding.grantAllFilesImage.applyColorFilter(activity.getProperTextColor())
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> activity.launchGrantAllFilesIntent() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> activity.launchGrantAllFilesIntent() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog -> }
|
activity.setupDialogStuff(binding.root, this) { alertDialog -> }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,74 +3,73 @@ package com.simplemobiletools.gallery.pro.dialogs
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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) {
|
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 {
|
init {
|
||||||
val actions = activity.config.visibleBottomActions
|
val actions = activity.config.visibleBottomActions
|
||||||
view.apply {
|
binding.apply {
|
||||||
manage_bottom_actions_toggle_favorite.isChecked = actions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0
|
manageBottomActionsToggleFavorite.isChecked = actions and BOTTOM_ACTION_TOGGLE_FAVORITE != 0
|
||||||
manage_bottom_actions_edit.isChecked = actions and BOTTOM_ACTION_EDIT != 0
|
manageBottomActionsEdit.isChecked = actions and BOTTOM_ACTION_EDIT != 0
|
||||||
manage_bottom_actions_share.isChecked = actions and BOTTOM_ACTION_SHARE != 0
|
manageBottomActionsShare.isChecked = actions and BOTTOM_ACTION_SHARE != 0
|
||||||
manage_bottom_actions_delete.isChecked = actions and BOTTOM_ACTION_DELETE != 0
|
manageBottomActionsDelete.isChecked = actions and BOTTOM_ACTION_DELETE != 0
|
||||||
manage_bottom_actions_rotate.isChecked = actions and BOTTOM_ACTION_ROTATE != 0
|
manageBottomActionsRotate.isChecked = actions and BOTTOM_ACTION_ROTATE != 0
|
||||||
manage_bottom_actions_properties.isChecked = actions and BOTTOM_ACTION_PROPERTIES != 0
|
manageBottomActionsProperties.isChecked = actions and BOTTOM_ACTION_PROPERTIES != 0
|
||||||
manage_bottom_actions_change_orientation.isChecked = actions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0
|
manageBottomActionsChangeOrientation.isChecked = actions and BOTTOM_ACTION_CHANGE_ORIENTATION != 0
|
||||||
manage_bottom_actions_slideshow.isChecked = actions and BOTTOM_ACTION_SLIDESHOW != 0
|
manageBottomActionsSlideshow.isChecked = actions and BOTTOM_ACTION_SLIDESHOW != 0
|
||||||
manage_bottom_actions_show_on_map.isChecked = actions and BOTTOM_ACTION_SHOW_ON_MAP != 0
|
manageBottomActionsShowOnMap.isChecked = actions and BOTTOM_ACTION_SHOW_ON_MAP != 0
|
||||||
manage_bottom_actions_toggle_visibility.isChecked = actions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0
|
manageBottomActionsToggleVisibility.isChecked = actions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0
|
||||||
manage_bottom_actions_rename.isChecked = actions and BOTTOM_ACTION_RENAME != 0
|
manageBottomActionsRename.isChecked = actions and BOTTOM_ACTION_RENAME != 0
|
||||||
manage_bottom_actions_set_as.isChecked = actions and BOTTOM_ACTION_SET_AS != 0
|
manageBottomActionsSetAs.isChecked = actions and BOTTOM_ACTION_SET_AS != 0
|
||||||
manage_bottom_actions_copy.isChecked = actions and BOTTOM_ACTION_COPY != 0
|
manageBottomActionsCopy.isChecked = actions and BOTTOM_ACTION_COPY != 0
|
||||||
manage_bottom_actions_move.isChecked = actions and BOTTOM_ACTION_MOVE != 0
|
manageBottomActionsMove.isChecked = actions and BOTTOM_ACTION_MOVE != 0
|
||||||
manage_bottom_actions_resize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0
|
manageBottomActionsResize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
view.apply {
|
binding.apply {
|
||||||
if (manage_bottom_actions_toggle_favorite.isChecked)
|
if (manageBottomActionsToggleFavorite.isChecked)
|
||||||
result += BOTTOM_ACTION_TOGGLE_FAVORITE
|
result += BOTTOM_ACTION_TOGGLE_FAVORITE
|
||||||
if (manage_bottom_actions_edit.isChecked)
|
if (manageBottomActionsEdit.isChecked)
|
||||||
result += BOTTOM_ACTION_EDIT
|
result += BOTTOM_ACTION_EDIT
|
||||||
if (manage_bottom_actions_share.isChecked)
|
if (manageBottomActionsShare.isChecked)
|
||||||
result += BOTTOM_ACTION_SHARE
|
result += BOTTOM_ACTION_SHARE
|
||||||
if (manage_bottom_actions_delete.isChecked)
|
if (manageBottomActionsDelete.isChecked)
|
||||||
result += BOTTOM_ACTION_DELETE
|
result += BOTTOM_ACTION_DELETE
|
||||||
if (manage_bottom_actions_rotate.isChecked)
|
if (manageBottomActionsRotate.isChecked)
|
||||||
result += BOTTOM_ACTION_ROTATE
|
result += BOTTOM_ACTION_ROTATE
|
||||||
if (manage_bottom_actions_properties.isChecked)
|
if (manageBottomActionsProperties.isChecked)
|
||||||
result += BOTTOM_ACTION_PROPERTIES
|
result += BOTTOM_ACTION_PROPERTIES
|
||||||
if (manage_bottom_actions_change_orientation.isChecked)
|
if (manageBottomActionsChangeOrientation.isChecked)
|
||||||
result += BOTTOM_ACTION_CHANGE_ORIENTATION
|
result += BOTTOM_ACTION_CHANGE_ORIENTATION
|
||||||
if (manage_bottom_actions_slideshow.isChecked)
|
if (manageBottomActionsSlideshow.isChecked)
|
||||||
result += BOTTOM_ACTION_SLIDESHOW
|
result += BOTTOM_ACTION_SLIDESHOW
|
||||||
if (manage_bottom_actions_show_on_map.isChecked)
|
if (manageBottomActionsShowOnMap.isChecked)
|
||||||
result += BOTTOM_ACTION_SHOW_ON_MAP
|
result += BOTTOM_ACTION_SHOW_ON_MAP
|
||||||
if (manage_bottom_actions_toggle_visibility.isChecked)
|
if (manageBottomActionsToggleVisibility.isChecked)
|
||||||
result += BOTTOM_ACTION_TOGGLE_VISIBILITY
|
result += BOTTOM_ACTION_TOGGLE_VISIBILITY
|
||||||
if (manage_bottom_actions_rename.isChecked)
|
if (manageBottomActionsRename.isChecked)
|
||||||
result += BOTTOM_ACTION_RENAME
|
result += BOTTOM_ACTION_RENAME
|
||||||
if (manage_bottom_actions_set_as.isChecked)
|
if (manageBottomActionsSetAs.isChecked)
|
||||||
result += BOTTOM_ACTION_SET_AS
|
result += BOTTOM_ACTION_SET_AS
|
||||||
if (manage_bottom_actions_copy.isChecked)
|
if (manageBottomActionsCopy.isChecked)
|
||||||
result += BOTTOM_ACTION_COPY
|
result += BOTTOM_ACTION_COPY
|
||||||
if (manage_bottom_actions_move.isChecked)
|
if (manageBottomActionsMove.isChecked)
|
||||||
result += BOTTOM_ACTION_MOVE
|
result += BOTTOM_ACTION_MOVE
|
||||||
if (manage_bottom_actions_resize.isChecked)
|
if (manageBottomActionsResize.isChecked)
|
||||||
result += BOTTOM_ACTION_RESIZE
|
result += BOTTOM_ACTION_RESIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,56 +3,55 @@ package com.simplemobiletools.gallery.pro.dialogs
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
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) {
|
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 {
|
init {
|
||||||
val details = activity.config.extendedDetails
|
val details = activity.config.extendedDetails
|
||||||
view.apply {
|
binding.apply {
|
||||||
manage_extended_details_name.isChecked = details and EXT_NAME != 0
|
manageExtendedDetailsName.isChecked = details and EXT_NAME != 0
|
||||||
manage_extended_details_path.isChecked = details and EXT_PATH != 0
|
manageExtendedDetailsPath.isChecked = details and EXT_PATH != 0
|
||||||
manage_extended_details_size.isChecked = details and EXT_SIZE != 0
|
manageExtendedDetailsSize.isChecked = details and EXT_SIZE != 0
|
||||||
manage_extended_details_resolution.isChecked = details and EXT_RESOLUTION != 0
|
manageExtendedDetailsResolution.isChecked = details and EXT_RESOLUTION != 0
|
||||||
manage_extended_details_last_modified.isChecked = details and EXT_LAST_MODIFIED != 0
|
manageExtendedDetailsLastModified.isChecked = details and EXT_LAST_MODIFIED != 0
|
||||||
manage_extended_details_date_taken.isChecked = details and EXT_DATE_TAKEN != 0
|
manageExtendedDetailsDateTaken.isChecked = details and EXT_DATE_TAKEN != 0
|
||||||
manage_extended_details_camera.isChecked = details and EXT_CAMERA_MODEL != 0
|
manageExtendedDetailsCamera.isChecked = details and EXT_CAMERA_MODEL != 0
|
||||||
manage_extended_details_exif.isChecked = details and EXT_EXIF_PROPERTIES != 0
|
manageExtendedDetailsExif.isChecked = details and EXT_EXIF_PROPERTIES != 0
|
||||||
manage_extended_details_gps_coordinates.isChecked = details and EXT_GPS != 0
|
manageExtendedDetailsGpsCoordinates.isChecked = details and EXT_GPS != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
view.apply {
|
binding.apply {
|
||||||
if (manage_extended_details_name.isChecked)
|
if (manageExtendedDetailsName.isChecked)
|
||||||
result += EXT_NAME
|
result += EXT_NAME
|
||||||
if (manage_extended_details_path.isChecked)
|
if (manageExtendedDetailsPath.isChecked)
|
||||||
result += EXT_PATH
|
result += EXT_PATH
|
||||||
if (manage_extended_details_size.isChecked)
|
if (manageExtendedDetailsSize.isChecked)
|
||||||
result += EXT_SIZE
|
result += EXT_SIZE
|
||||||
if (manage_extended_details_resolution.isChecked)
|
if (manageExtendedDetailsResolution.isChecked)
|
||||||
result += EXT_RESOLUTION
|
result += EXT_RESOLUTION
|
||||||
if (manage_extended_details_last_modified.isChecked)
|
if (manageExtendedDetailsLastModified.isChecked)
|
||||||
result += EXT_LAST_MODIFIED
|
result += EXT_LAST_MODIFIED
|
||||||
if (manage_extended_details_date_taken.isChecked)
|
if (manageExtendedDetailsDateTaken.isChecked)
|
||||||
result += EXT_DATE_TAKEN
|
result += EXT_DATE_TAKEN
|
||||||
if (manage_extended_details_camera.isChecked)
|
if (manageExtendedDetailsCamera.isChecked)
|
||||||
result += EXT_CAMERA_MODEL
|
result += EXT_CAMERA_MODEL
|
||||||
if (manage_extended_details_exif.isChecked)
|
if (manageExtendedDetailsExif.isChecked)
|
||||||
result += EXT_EXIF_PROPERTIES
|
result += EXT_EXIF_PROPERTIES
|
||||||
if (manage_extended_details_gps_coordinates.isChecked)
|
if (manageExtendedDetailsGpsCoordinates.isChecked)
|
||||||
result += EXT_GPS
|
result += EXT_GPS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.databinding.DialogOtherAspectRatioBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.*
|
|
||||||
|
|
||||||
class OtherAspectRatioDialog(
|
class OtherAspectRatioDialog(
|
||||||
val activity: BaseSimpleActivity,
|
val activity: BaseSimpleActivity,
|
||||||
|
@ -15,53 +14,53 @@ class OtherAspectRatioDialog(
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply {
|
val binding = DialogOtherAspectRatioBinding.inflate(activity.layoutInflater).apply {
|
||||||
other_aspect_ratio_2_1.setOnClickListener { ratioPicked(Pair(2f, 1f)) }
|
otherAspectRatio21.setOnClickListener { ratioPicked(Pair(2f, 1f)) }
|
||||||
other_aspect_ratio_3_2.setOnClickListener { ratioPicked(Pair(3f, 2f)) }
|
otherAspectRatio32.setOnClickListener { ratioPicked(Pair(3f, 2f)) }
|
||||||
other_aspect_ratio_4_3.setOnClickListener { ratioPicked(Pair(4f, 3f)) }
|
otherAspectRatio43.setOnClickListener { ratioPicked(Pair(4f, 3f)) }
|
||||||
other_aspect_ratio_5_3.setOnClickListener { ratioPicked(Pair(5f, 3f)) }
|
otherAspectRatio53.setOnClickListener { ratioPicked(Pair(5f, 3f)) }
|
||||||
other_aspect_ratio_16_9.setOnClickListener { ratioPicked(Pair(16f, 9f)) }
|
otherAspectRatio169.setOnClickListener { ratioPicked(Pair(16f, 9f)) }
|
||||||
other_aspect_ratio_19_9.setOnClickListener { ratioPicked(Pair(19f, 9f)) }
|
otherAspectRatio199.setOnClickListener { ratioPicked(Pair(19f, 9f)) }
|
||||||
other_aspect_ratio_custom.setOnClickListener { customRatioPicked() }
|
otherAspectRatioCustom.setOnClickListener { customRatioPicked() }
|
||||||
|
|
||||||
other_aspect_ratio_1_2.setOnClickListener { ratioPicked(Pair(1f, 2f)) }
|
otherAspectRatio12.setOnClickListener { ratioPicked(Pair(1f, 2f)) }
|
||||||
other_aspect_ratio_2_3.setOnClickListener { ratioPicked(Pair(2f, 3f)) }
|
otherAspectRatio23.setOnClickListener { ratioPicked(Pair(2f, 3f)) }
|
||||||
other_aspect_ratio_3_4.setOnClickListener { ratioPicked(Pair(3f, 4f)) }
|
otherAspectRatio34.setOnClickListener { ratioPicked(Pair(3f, 4f)) }
|
||||||
other_aspect_ratio_3_5.setOnClickListener { ratioPicked(Pair(3f, 5f)) }
|
otherAspectRatio35.setOnClickListener { ratioPicked(Pair(3f, 5f)) }
|
||||||
other_aspect_ratio_9_16.setOnClickListener { ratioPicked(Pair(9f, 16f)) }
|
otherAspectRatio916.setOnClickListener { ratioPicked(Pair(9f, 16f)) }
|
||||||
other_aspect_ratio_9_19.setOnClickListener { ratioPicked(Pair(9f, 19f)) }
|
otherAspectRatio919.setOnClickListener { ratioPicked(Pair(9f, 19f)) }
|
||||||
|
|
||||||
val radio1SelectedItemId = when (lastOtherAspectRatio) {
|
val radio1SelectedItemId = when (lastOtherAspectRatio) {
|
||||||
Pair(2f, 1f) -> other_aspect_ratio_2_1.id
|
Pair(2f, 1f) -> otherAspectRatio21.id
|
||||||
Pair(3f, 2f) -> other_aspect_ratio_3_2.id
|
Pair(3f, 2f) -> otherAspectRatio32.id
|
||||||
Pair(4f, 3f) -> other_aspect_ratio_4_3.id
|
Pair(4f, 3f) -> otherAspectRatio43.id
|
||||||
Pair(5f, 3f) -> other_aspect_ratio_5_3.id
|
Pair(5f, 3f) -> otherAspectRatio53.id
|
||||||
Pair(16f, 9f) -> other_aspect_ratio_16_9.id
|
Pair(16f, 9f) -> otherAspectRatio169.id
|
||||||
Pair(19f, 9f) -> other_aspect_ratio_19_9.id
|
Pair(19f, 9f) -> otherAspectRatio199.id
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
other_aspect_ratio_dialog_radio_1.check(radio1SelectedItemId)
|
otherAspectRatioDialogRadio1.check(radio1SelectedItemId)
|
||||||
|
|
||||||
val radio2SelectedItemId = when (lastOtherAspectRatio) {
|
val radio2SelectedItemId = when (lastOtherAspectRatio) {
|
||||||
Pair(1f, 2f) -> other_aspect_ratio_1_2.id
|
Pair(1f, 2f) -> otherAspectRatio12.id
|
||||||
Pair(2f, 3f) -> other_aspect_ratio_2_3.id
|
Pair(2f, 3f) -> otherAspectRatio23.id
|
||||||
Pair(3f, 4f) -> other_aspect_ratio_3_4.id
|
Pair(3f, 4f) -> otherAspectRatio34.id
|
||||||
Pair(3f, 5f) -> other_aspect_ratio_3_5.id
|
Pair(3f, 5f) -> otherAspectRatio35.id
|
||||||
Pair(9f, 16f) -> other_aspect_ratio_9_16.id
|
Pair(9f, 16f) -> otherAspectRatio916.id
|
||||||
Pair(9f, 19f) -> other_aspect_ratio_9_19.id
|
Pair(9f, 19f) -> otherAspectRatio919.id
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
other_aspect_ratio_dialog_radio_2.check(radio2SelectedItemId)
|
otherAspectRatioDialogRadio2.check(radio2SelectedItemId)
|
||||||
|
|
||||||
if (radio1SelectedItemId == 0 && radio2SelectedItemId == 0) {
|
if (radio1SelectedItemId == 0 && radio2SelectedItemId == 0) {
|
||||||
other_aspect_ratio_dialog_radio_1.check(other_aspect_ratio_custom.id)
|
otherAspectRatioDialogRadio1.check(otherAspectRatioCustom.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,7 @@ package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -17,9 +14,9 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.commons.views.MySearchMenu
|
import com.simplemobiletools.commons.views.MySearchMenu
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.DirectoryAdapter
|
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.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Directory
|
import com.simplemobiletools.gallery.pro.models.Directory
|
||||||
import kotlinx.android.synthetic.main.dialog_directory_picker.view.*
|
|
||||||
|
|
||||||
class PickDirectoryDialog(
|
class PickDirectoryDialog(
|
||||||
val activity: BaseSimpleActivity,
|
val activity: BaseSimpleActivity,
|
||||||
|
@ -34,28 +31,28 @@ class PickDirectoryDialog(
|
||||||
private var shownDirectories = ArrayList<Directory>()
|
private var shownDirectories = ArrayList<Directory>()
|
||||||
private var allDirectories = ArrayList<Directory>()
|
private var allDirectories = ArrayList<Directory>()
|
||||||
private var openedSubfolders = arrayListOf("")
|
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 isGridViewType = activity.config.viewTypeFolders == VIEW_TYPE_GRID
|
||||||
private var showHidden = activity.config.shouldShowHidden
|
private var showHidden = activity.config.shouldShowHidden
|
||||||
private var currentPathPrefix = ""
|
private var currentPathPrefix = ""
|
||||||
private val config = activity.config
|
private val config = activity.config
|
||||||
private val searchView = view.folder_search_view
|
private val searchView = binding.folderSearchView
|
||||||
private val searchEditText = view.findViewById<EditText>(R.id.top_toolbar_search)
|
private val searchEditText = searchView.binding.topToolbarSearch
|
||||||
private val searchViewAppBarLayout = view.findViewById<View>(R.id.top_app_bar_layout)
|
private val searchViewAppBarLayout = searchView.binding.topAppBarLayout
|
||||||
|
|
||||||
init {
|
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
|
orientation = if (activity.config.scrollHorizontally && isGridViewType) RecyclerView.HORIZONTAL else RecyclerView.VERTICAL
|
||||||
spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1
|
spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1
|
||||||
}
|
}
|
||||||
|
|
||||||
view.directories_fastscroller.updateColors(activity.getProperPrimaryColor())
|
binding.directoriesFastscroller.updateColors(activity.getProperPrimaryColor())
|
||||||
|
|
||||||
configureSearchView()
|
configureSearchView()
|
||||||
|
|
||||||
val builder = activity.getAlertDialogBuilder()
|
val builder = activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.setOnKeyListener { dialogInterface, i, keyEvent ->
|
.setOnKeyListener { dialogInterface, i, keyEvent ->
|
||||||
if (keyEvent.action == KeyEvent.ACTION_UP && i == KeyEvent.KEYCODE_BACK) {
|
if (keyEvent.action == KeyEvent.ACTION_UP && i == KeyEvent.KEYCODE_BACK) {
|
||||||
backPressed()
|
backPressed()
|
||||||
|
@ -68,12 +65,12 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.apply {
|
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
|
dialog = alertDialog
|
||||||
view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden)
|
binding.directoriesShowHidden.beVisibleIf(!context.config.shouldShowHidden)
|
||||||
view.directories_show_hidden.setOnClickListener {
|
binding.directoriesShowHidden.setOnClickListener {
|
||||||
activity.handleHiddenFolderPasswordProtection {
|
activity.handleHiddenFolderPasswordProtection {
|
||||||
view.directories_show_hidden.beGone()
|
binding.directoriesShowHidden.beGone()
|
||||||
showHidden = true
|
showHidden = true
|
||||||
fetchDirectories(true)
|
fetchDirectories(true)
|
||||||
}
|
}
|
||||||
|
@ -85,7 +82,7 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun configureSearchView() = with(searchView) {
|
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
|
searchEditText.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||||
|
|
||||||
toggleHideOnScroll(!config.scrollHorizontally)
|
toggleHideOnScroll(!config.scrollHorizontally)
|
||||||
|
@ -103,13 +100,13 @@ class PickDirectoryDialog(
|
||||||
|
|
||||||
private fun MySearchMenu.setSearchViewListeners() {
|
private fun MySearchMenu.setSearchViewListeners() {
|
||||||
onSearchOpenListener = {
|
onSearchOpenListener = {
|
||||||
updateSearchViewLeftIcon(R.drawable.ic_cross_vector)
|
updateSearchViewLeftIcon(com.simplemobiletools.commons.R.drawable.ic_cross_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchClosedListener = {
|
onSearchClosedListener = {
|
||||||
searchEditText.clearFocus()
|
searchEditText.clearFocus()
|
||||||
activity.hideKeyboard(searchEditText)
|
activity.hideKeyboard(searchEditText)
|
||||||
updateSearchViewLeftIcon(R.drawable.ic_search_vector)
|
updateSearchViewLeftIcon(com.simplemobiletools.commons.R.drawable.ic_search_vector)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearchTextChangedListener = { text ->
|
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 {
|
post {
|
||||||
setImageResource(iconResId)
|
setImageResource(iconResId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun filterFolderListBySearchQuery(query: String) {
|
private fun filterFolderListBySearchQuery(query: String) {
|
||||||
val adapter = view.directories_grid.adapter as? DirectoryAdapter
|
val adapter = binding.directoriesGrid.adapter as? DirectoryAdapter
|
||||||
var dirsToShow = allDirectories
|
var dirsToShow = allDirectories
|
||||||
if (query.isNotEmpty()) {
|
if (query.isNotEmpty()) {
|
||||||
dirsToShow = dirsToShow.filter { it.name.contains(query, true) }.toMutableList() as ArrayList
|
dirsToShow = dirsToShow.filter { it.name.contains(query, true) }.toMutableList() as ArrayList
|
||||||
|
@ -136,7 +133,7 @@ class PickDirectoryDialog(
|
||||||
if (filteredFolderListUpdated) {
|
if (filteredFolderListUpdated) {
|
||||||
adapter?.updateDirs(dirsToShow)
|
adapter?.updateDirs(dirsToShow)
|
||||||
|
|
||||||
view.directories_grid.apply {
|
binding.directoriesGrid.apply {
|
||||||
post {
|
post {
|
||||||
scrollToPosition(0)
|
scrollToPosition(0)
|
||||||
}
|
}
|
||||||
|
@ -144,14 +141,14 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) = with(view) {
|
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) = with(binding) {
|
||||||
directories_empty_placeholder.beVisibleIf(dirs.isEmpty())
|
directoriesEmptyPlaceholder.beVisibleIf(dirs.isEmpty())
|
||||||
|
|
||||||
if (folder_search_view.isSearchOpen) {
|
if (folderSearchView.isSearchOpen) {
|
||||||
directories_empty_placeholder.text = context.getString(R.string.no_items_found)
|
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) {
|
private fun fetchDirectories(forceShowHiddenAndExcluded: Boolean) {
|
||||||
|
@ -201,15 +198,15 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
shownDirectories = dirs
|
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 clickedDir = it as Directory
|
||||||
val path = clickedDir.path
|
val path = clickedDir.path
|
||||||
if (clickedDir.subfoldersCount == 1 || !activity.config.groupDirectSubfolders) {
|
if (clickedDir.subfoldersCount == 1 || !activity.config.groupDirectSubfolders) {
|
||||||
if (isPickingCopyMoveDestination && path.trimEnd('/') == sourcePath) {
|
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
|
return@DirectoryAdapter
|
||||||
} else if (isPickingCopyMoveDestination && activity.isRestrictedWithSAFSdk30(path) && !activity.isInDownloadDir(path)) {
|
} 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
|
return@DirectoryAdapter
|
||||||
} else {
|
} else {
|
||||||
activity.handleLockedFolderOpening(path) { success ->
|
activity.handleLockedFolderOpening(path) { success ->
|
||||||
|
@ -227,9 +224,9 @@ class PickDirectoryDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType
|
val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType
|
||||||
view.apply {
|
binding.apply {
|
||||||
directories_grid.adapter = adapter
|
directoriesGrid.adapter = adapter
|
||||||
directories_fastscroller.setScrollVertically(!scrollHorizontally)
|
directoriesFastscroller.setScrollVertically(!scrollHorizontally)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
import com.simplemobiletools.gallery.pro.adapters.MediaAdapter
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.getCachedMedia
|
import com.simplemobiletools.gallery.pro.extensions.getCachedMedia
|
||||||
import com.simplemobiletools.gallery.pro.helpers.GridSpacingItemDecoration
|
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.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
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) {
|
class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val callback: (path: String) -> Unit) {
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private var shownMedia = ArrayList<ThumbnailItem>()
|
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 config = activity.config
|
||||||
private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path)
|
private val viewType = config.getFolderViewType(if (config.showAll) SHOW_ALL else path)
|
||||||
private var isGridViewType = viewType == VIEW_TYPE_GRID
|
private var isGridViewType = viewType == VIEW_TYPE_GRID
|
||||||
|
|
||||||
init {
|
init {
|
||||||
(view.media_grid.layoutManager as MyGridLayoutManager).apply {
|
(binding.mediaGrid.layoutManager as MyGridLayoutManager).apply {
|
||||||
orientation = if (config.scrollHorizontally && isGridViewType) RecyclerView.HORIZONTAL else RecyclerView.VERTICAL
|
orientation = if (config.scrollHorizontally && isGridViewType) RecyclerView.HORIZONTAL else RecyclerView.VERTICAL
|
||||||
spanCount = if (isGridViewType) config.mediaColumnCnt else 1
|
spanCount = if (isGridViewType) config.mediaColumnCnt else 1
|
||||||
}
|
}
|
||||||
|
|
||||||
view.media_fastscroller.updateColors(activity.getProperPrimaryColor())
|
binding.mediaFastscroller.updateColors(activity.getProperPrimaryColor())
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() }
|
.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() }
|
||||||
.apply {
|
.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
|
dialog = alertDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
||||||
return
|
return
|
||||||
|
|
||||||
shownMedia = media
|
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) {
|
if (it is Medium) {
|
||||||
callback(it.path)
|
callback(it.path)
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
|
@ -80,9 +80,9 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
||||||
}
|
}
|
||||||
|
|
||||||
val scrollHorizontally = config.scrollHorizontally && isGridViewType
|
val scrollHorizontally = config.scrollHorizontally && isGridViewType
|
||||||
view.apply {
|
binding.apply {
|
||||||
media_grid.adapter = adapter
|
mediaGrid.adapter = adapter
|
||||||
media_fastscroller.setScrollVertically(!scrollHorizontally)
|
mediaFastscroller.setScrollVertically(!scrollHorizontally)
|
||||||
}
|
}
|
||||||
handleGridSpacing(media)
|
handleGridSpacing(media)
|
||||||
}
|
}
|
||||||
|
@ -94,17 +94,17 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
||||||
val useGridPosition = media.firstOrNull() is ThumbnailSection
|
val useGridPosition = media.firstOrNull() is ThumbnailSection
|
||||||
|
|
||||||
var currentGridDecoration: GridSpacingItemDecoration? = null
|
var currentGridDecoration: GridSpacingItemDecoration? = null
|
||||||
if (view.media_grid.itemDecorationCount > 0) {
|
if (binding.mediaGrid.itemDecorationCount > 0) {
|
||||||
currentGridDecoration = view.media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
currentGridDecoration = binding.mediaGrid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
||||||
currentGridDecoration.items = media
|
currentGridDecoration.items = media
|
||||||
}
|
}
|
||||||
|
|
||||||
val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition)
|
val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, media, useGridPosition)
|
||||||
if (currentGridDecoration.toString() != newGridDecoration.toString()) {
|
if (currentGridDecoration.toString() != newGridDecoration.toString()) {
|
||||||
if (currentGridDecoration != null) {
|
if (currentGridDecoration != null) {
|
||||||
view.media_grid.removeItemDecoration(currentGridDecoration)
|
binding.mediaGrid.removeItemDecoration(currentGridDecoration)
|
||||||
}
|
}
|
||||||
view.media_grid.addItemDecoration(newGridDecoration)
|
binding.mediaGrid.addItemDecoration(newGridDecoration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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) {
|
class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callback: (newSize: Point) -> Unit) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_resize_image, null)
|
val binding = DialogResizeImageBinding.inflate(activity.layoutInflater)
|
||||||
val widthView = view.resize_image_width
|
val widthView = binding.resizeImageWidth
|
||||||
val heightView = view.resize_image_height
|
val heightView = binding.resizeImageHeight
|
||||||
|
|
||||||
widthView.setText(size.x.toString())
|
widthView.setText(size.x.toString())
|
||||||
heightView.setText(size.y.toString())
|
heightView.setText(size.y.toString())
|
||||||
|
@ -27,7 +27,7 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
|
||||||
width = size.x
|
width = size.x
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.keep_aspect_ratio.isChecked) {
|
if (binding.keepAspectRatio.isChecked) {
|
||||||
heightView.setText((width / ratio).toInt().toString())
|
heightView.setText((width / ratio).toInt().toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,18 +41,18 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
|
||||||
height = size.y
|
height = size.y
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.keep_aspect_ratio.isChecked) {
|
if (binding.keepAspectRatio.isChecked) {
|
||||||
widthView.setText((height * ratio).toInt().toString())
|
widthView.setText((height * ratio).toInt().toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.resize_and_save) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.resize_and_save) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.resize_image_width)
|
alertDialog.showKeyboard(binding.resizeImageWidth)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val width = getViewValue(widthView)
|
val width = getViewValue(widthView)
|
||||||
val height = getViewValue(heightView)
|
val height = getViewValue(heightView)
|
||||||
|
|
|
@ -6,12 +6,10 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.ensureWriteAccess
|
||||||
import com.simplemobiletools.gallery.pro.extensions.rescanPathsAndUpdateLastModified
|
import com.simplemobiletools.gallery.pro.extensions.rescanPathsAndUpdateLastModified
|
||||||
import com.simplemobiletools.gallery.pro.extensions.resizeImage
|
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 java.io.File
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
@ -25,9 +23,9 @@ class ResizeMultipleImagesDialog(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var dialog: AlertDialog? = null
|
private var dialog: AlertDialog? = null
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_resize_multiple_images, null)
|
private val binding = DialogResizeMultipleImagesBinding.inflate(activity.layoutInflater)
|
||||||
private val progressView = view.resize_progress
|
private val progressView = binding.resizeProgress
|
||||||
private val resizeFactorEditText = view.resize_factor_edit_text
|
private val resizeFactorEditText = binding.resizeFactorEditText
|
||||||
|
|
||||||
init {
|
init {
|
||||||
resizeFactorEditText.setText(DEFAULT_RESIZE_FACTOR)
|
resizeFactorEditText.setText(DEFAULT_RESIZE_FACTOR)
|
||||||
|
@ -37,10 +35,10 @@ class ResizeMultipleImagesDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.resize_multiple_images) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.resize_multiple_images) { alertDialog ->
|
||||||
dialog = alertDialog
|
dialog = alertDialog
|
||||||
alertDialog.showKeyboard(resizeFactorEditText)
|
alertDialog.showKeyboard(resizeFactorEditText)
|
||||||
|
|
||||||
|
@ -56,7 +54,7 @@ class ResizeMultipleImagesDialog(
|
||||||
val resizeFactor = resizeFactorText.toFloat().div(100)
|
val resizeFactor = resizeFactorText.toFloat().div(100)
|
||||||
|
|
||||||
alertDialog.setCanceledOnTouchOutside(false)
|
alertDialog.setCanceledOnTouchOutside(false)
|
||||||
arrayOf(view.resize_factor_input_layout, positiveButton, negativeButton).forEach {
|
arrayOf(binding.resizeFactorInputLayout, positiveButton, negativeButton).forEach {
|
||||||
it.isEnabled = false
|
it.isEnabled = false
|
||||||
it.alpha = 0.6f
|
it.alpha = 0.6f
|
||||||
}
|
}
|
||||||
|
@ -97,7 +95,7 @@ class ResizeMultipleImagesDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
toast(R.string.out_of_memory_error)
|
toast(com.simplemobiletools.commons.R.string.out_of_memory_error)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import com.simplemobiletools.gallery.pro.databinding.DialogResizeImageWithPathBinding
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
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) {
|
class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, val path: String, val callback: (newSize: Point, newPath: String) -> Unit) {
|
||||||
init {
|
init {
|
||||||
var realPath = path.getParentPath()
|
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('/')}/")
|
folder.setText("${activity.humanizePath(realPath).trimEnd('/')}/")
|
||||||
|
|
||||||
val fullName = path.getFilenameFromPath()
|
val fullName = path.getFilenameFromPath()
|
||||||
|
@ -24,10 +24,10 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
|
||||||
if (dotAt > 0) {
|
if (dotAt > 0) {
|
||||||
name = fullName.substring(0, dotAt)
|
name = fullName.substring(0, dotAt)
|
||||||
val extension = fullName.substring(dotAt + 1)
|
val extension = fullName.substring(dotAt + 1)
|
||||||
extension_value.setText(extension)
|
extensionValue.setText(extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_value.setText(name)
|
filenameValue.setText(name)
|
||||||
folder.setOnClickListener {
|
folder.setOnClickListener {
|
||||||
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) {
|
FilePickerDialog(activity, realPath, false, activity.config.shouldShowHidden, true, true) {
|
||||||
folder.setText(activity.humanizePath(it))
|
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 widthView = binding.resizeImageWidth
|
||||||
val heightView = view.resize_image_height
|
val heightView = binding.resizeImageHeight
|
||||||
|
|
||||||
widthView.setText(size.x.toString())
|
widthView.setText(size.x.toString())
|
||||||
heightView.setText(size.y.toString())
|
heightView.setText(size.y.toString())
|
||||||
|
@ -69,11 +69,11 @@ class ResizeWithPathDialog(val activity: BaseSimpleActivity, val size: Point, va
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.resize_image_width)
|
alertDialog.showKeyboard(binding.resizeImageWidth)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val width = getViewValue(widthView)
|
val width = getViewValue(widthView)
|
||||||
val height = getViewValue(heightView)
|
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 newSize = Point(getViewValue(widthView), getViewValue(heightView))
|
||||||
|
|
||||||
val filename = view.filename_value.value
|
val filename = binding.filenameValue.value
|
||||||
val extension = view.extension_value.value
|
val extension = binding.extensionValue.value
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.isEmpty()) {
|
if (extension.isEmpty()) {
|
||||||
activity.toast(R.string.extension_cannot_be_empty)
|
activity.toast(com.simplemobiletools.commons.R.string.extension_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFilename = "$filename.$extension"
|
val newFilename = "$filename.$extension"
|
||||||
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
||||||
if (!newFilename.isAValidFilename()) {
|
if (!newFilename.isAValidFilename()) {
|
||||||
activity.toast(R.string.filename_invalid_characters)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getDoesFilePathExist(newPath)) {
|
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) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newSize, newPath)
|
callback(newSize, newPath)
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
|
|
|
@ -6,8 +6,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.databinding.DialogSaveAsBinding
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SaveAsDialog(
|
class SaveAsDialog(
|
||||||
|
@ -20,8 +19,8 @@ class SaveAsDialog(
|
||||||
realPath = activity.getPicturesDirectoryPath(realPath)
|
realPath = activity.getPicturesDirectoryPath(realPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
val binding = DialogSaveAsBinding.inflate(activity.layoutInflater).apply {
|
||||||
folder_value.setText("${activity.humanizePath(realPath).trimEnd('/')}/")
|
folderValue.setText("${activity.humanizePath(realPath).trimEnd('/')}/")
|
||||||
|
|
||||||
val fullName = path.getFilenameFromPath()
|
val fullName = path.getFilenameFromPath()
|
||||||
val dotAt = fullName.lastIndexOf(".")
|
val dotAt = fullName.lastIndexOf(".")
|
||||||
|
@ -30,53 +29,53 @@ class SaveAsDialog(
|
||||||
if (dotAt > 0) {
|
if (dotAt > 0) {
|
||||||
name = fullName.substring(0, dotAt)
|
name = fullName.substring(0, dotAt)
|
||||||
val extension = fullName.substring(dotAt + 1)
|
val extension = fullName.substring(dotAt + 1)
|
||||||
extension_value.setText(extension)
|
extensionValue.setText(extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appendFilename) {
|
if (appendFilename) {
|
||||||
name += "_1"
|
name += "_1"
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_value.setText(name)
|
filenameValue.setText(name)
|
||||||
folder_value.setOnClickListener {
|
folderValue.setOnClickListener {
|
||||||
activity.hideKeyboard(folder_value)
|
activity.hideKeyboard(folderValue)
|
||||||
FilePickerDialog(activity, realPath, false, false, true, true) {
|
FilePickerDialog(activity, realPath, false, false, true, true) {
|
||||||
folder_value.setText(activity.humanizePath(it))
|
folderValue.setText(activity.humanizePath(it))
|
||||||
realPath = it
|
realPath = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() }
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel) { dialog, which -> cancelCallback?.invoke() }
|
||||||
.setOnCancelListener { cancelCallback?.invoke() }
|
.setOnCancelListener { cancelCallback?.invoke() }
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, com.simplemobiletools.commons.R.string.save_as) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.filename_value)
|
alertDialog.showKeyboard(binding.filenameValue)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.filename_value.value
|
val filename = binding.filenameValue.value
|
||||||
val extension = view.extension_value.value
|
val extension = binding.extensionValue.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.isEmpty()) {
|
if (extension.isEmpty()) {
|
||||||
activity.toast(R.string.extension_cannot_be_empty)
|
activity.toast(com.simplemobiletools.commons.R.string.extension_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFilename = "$filename.$extension"
|
val newFilename = "$filename.$extension"
|
||||||
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
||||||
if (!newFilename.isAValidFilename()) {
|
if (!newFilename.isAValidFilename()) {
|
||||||
activity.toast(R.string.filename_invalid_characters)
|
activity.toast(com.simplemobiletools.commons.R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getDoesFilePathExist(newPath)) {
|
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) {
|
ConfirmationDialog(activity, title) {
|
||||||
if ((isRPlus() && !isExternalStorageManager())) {
|
if ((isRPlus() && !isExternalStorageManager())) {
|
||||||
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
|
val fileDirItem = arrayListOf(File(newPath).toFileDirItem(activity))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.simplemobiletools.gallery.pro.dialogs
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
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.extensions.value
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.gallery.pro.R
|
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.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_FADE
|
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_NONE
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_SLIDE
|
import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_ANIMATION_SLIDE
|
||||||
import com.simplemobiletools.gallery.pro.helpers.SLIDESHOW_DEFAULT_INTERVAL
|
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) {
|
class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit) {
|
||||||
private val view: View
|
private val binding: DialogSlideshowBinding
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_slideshow, null).apply {
|
binding = DialogSlideshowBinding.inflate(activity.layoutInflater).apply {
|
||||||
interval_hint.hint = activity.getString(R.string.seconds_raw).replaceFirstChar { it.uppercaseChar() }
|
intervalHint.hint = activity.getString(com.simplemobiletools.commons.R.string.seconds_raw).replaceFirstChar { it.uppercaseChar() }
|
||||||
interval_value.setOnClickListener {
|
intervalValue.setOnClickListener {
|
||||||
interval_value.selectAll()
|
intervalValue.selectAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
interval_value.setOnFocusChangeListener { v, hasFocus ->
|
intervalValue.setOnFocusChangeListener { v, hasFocus ->
|
||||||
if (!hasFocus)
|
if (!hasFocus)
|
||||||
activity.hideKeyboard(v)
|
activity.hideKeyboard(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
animation_holder.setOnClickListener {
|
animationHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(SLIDESHOW_ANIMATION_NONE, activity.getString(R.string.no_animation)),
|
RadioItem(SLIDESHOW_ANIMATION_NONE, activity.getString(R.string.no_animation)),
|
||||||
RadioItem(SLIDESHOW_ANIMATION_SLIDE, activity.getString(R.string.slide)),
|
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) {
|
RadioGroupDialog(activity, items, activity.config.slideshowAnimation) {
|
||||||
activity.config.slideshowAnimation = it as Int
|
activity.config.slideshowAnimation = it as Int
|
||||||
animation_value.text = getAnimationText()
|
animationValue.text = getAnimationText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include_videos_holder.setOnClickListener {
|
includeVideosHolder.setOnClickListener {
|
||||||
interval_value.clearFocus()
|
intervalValue.clearFocus()
|
||||||
include_videos.toggle()
|
includeVideos.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
include_gifs_holder.setOnClickListener {
|
includeGifsHolder.setOnClickListener {
|
||||||
interval_value.clearFocus()
|
intervalValue.clearFocus()
|
||||||
include_gifs.toggle()
|
includeGifs.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
random_order_holder.setOnClickListener {
|
randomOrderHolder.setOnClickListener {
|
||||||
interval_value.clearFocus()
|
intervalValue.clearFocus()
|
||||||
random_order.toggle()
|
randomOrder.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
move_backwards_holder.setOnClickListener {
|
moveBackwardsHolder.setOnClickListener {
|
||||||
interval_value.clearFocus()
|
intervalValue.clearFocus()
|
||||||
move_backwards.toggle()
|
moveBackwards.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_slideshow_holder.setOnClickListener {
|
loopSlideshowHolder.setOnClickListener {
|
||||||
interval_value.clearFocus()
|
intervalValue.clearFocus()
|
||||||
loop_slideshow.toggle()
|
loopSlideshow.toggle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupValues()
|
setupValues()
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(com.simplemobiletools.commons.R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(com.simplemobiletools.commons.R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this) { alertDialog ->
|
||||||
alertDialog.hideKeyboard()
|
alertDialog.hideKeyboard()
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
storeValues()
|
storeValues()
|
||||||
|
@ -89,30 +88,30 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
|
||||||
|
|
||||||
private fun setupValues() {
|
private fun setupValues() {
|
||||||
val config = activity.config
|
val config = activity.config
|
||||||
view.apply {
|
binding.apply {
|
||||||
interval_value.setText(config.slideshowInterval.toString())
|
intervalValue.setText(config.slideshowInterval.toString())
|
||||||
animation_value.text = getAnimationText()
|
animationValue.text = getAnimationText()
|
||||||
include_videos.isChecked = config.slideshowIncludeVideos
|
includeVideos.isChecked = config.slideshowIncludeVideos
|
||||||
include_gifs.isChecked = config.slideshowIncludeGIFs
|
includeGifs.isChecked = config.slideshowIncludeGIFs
|
||||||
random_order.isChecked = config.slideshowRandomOrder
|
randomOrder.isChecked = config.slideshowRandomOrder
|
||||||
move_backwards.isChecked = config.slideshowMoveBackwards
|
moveBackwards.isChecked = config.slideshowMoveBackwards
|
||||||
loop_slideshow.isChecked = config.loopSlideshow
|
loopSlideshow.isChecked = config.loopSlideshow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeValues() {
|
private fun storeValues() {
|
||||||
var interval = view.interval_value.text.toString()
|
var interval = binding.intervalValue.text.toString()
|
||||||
if (interval.trim('0').isEmpty())
|
if (interval.trim('0').isEmpty())
|
||||||
interval = SLIDESHOW_DEFAULT_INTERVAL.toString()
|
interval = SLIDESHOW_DEFAULT_INTERVAL.toString()
|
||||||
|
|
||||||
activity.config.apply {
|
activity.config.apply {
|
||||||
slideshowAnimation = getAnimationValue(view.animation_value.value)
|
slideshowAnimation = getAnimationValue(binding.animationValue.value)
|
||||||
slideshowInterval = interval.toInt()
|
slideshowInterval = interval.toInt()
|
||||||
slideshowIncludeVideos = view.include_videos.isChecked
|
slideshowIncludeVideos = binding.includeVideos.isChecked
|
||||||
slideshowIncludeGIFs = view.include_gifs.isChecked
|
slideshowIncludeGIFs = binding.includeGifs.isChecked
|
||||||
slideshowRandomOrder = view.random_order.isChecked
|
slideshowRandomOrder = binding.randomOrder.isChecked
|
||||||
slideshowMoveBackwards = view.move_backwards.isChecked
|
slideshowMoveBackwards = binding.moveBackwards.isChecked
|
||||||
loopSlideshow = view.loop_slideshow.isChecked
|
loopSlideshow = binding.loopSlideshow.isChecked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ fun SimpleActivity.launchAbout() {
|
||||||
FAQItem(R.string.faq_7_title, R.string.faq_7_text),
|
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_14_title, R.string.faq_14_text),
|
||||||
FAQItem(R.string.faq_1_title, R.string.faq_1_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_5_title, R.string.faq_5_text),
|
||||||
FAQItem(R.string.faq_4_title, R.string.faq_4_text),
|
FAQItem(R.string.faq_4_title, R.string.faq_4_text),
|
||||||
FAQItem(R.string.faq_6_title, R.string.faq_6_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_15_title, R.string.faq_15_text),
|
||||||
FAQItem(R.string.faq_2_title, R.string.faq_2_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_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)) {
|
if (!resources.getBoolean(com.simplemobiletools.commons.R.bool.hide_google_relations)) {
|
||||||
faqItems.add(FAQItem(R.string.faq_2_title_commons, R.string.faq_2_text_commons))
|
faqItems.add(FAQItem(com.simplemobiletools.commons.R.string.faq_2_title_commons, com.simplemobiletools.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(com.simplemobiletools.commons.R.string.faq_6_title_commons, com.simplemobiletools.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(com.simplemobiletools.commons.R.string.faq_7_title_commons, com.simplemobiletools.commons.R.string.faq_7_text_commons))
|
||||||
faqItems.add(FAQItem(R.string.faq_10_title_commons, R.string.faq_10_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()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
|
@ -138,7 +138,7 @@ fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) {
|
||||||
if (Environment.isExternalStorageManager()) {
|
if (Environment.isExternalStorageManager()) {
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
var messagePrompt = getString(R.string.access_storage_prompt)
|
var messagePrompt = getString(com.simplemobiletools.commons.R.string.access_storage_prompt)
|
||||||
messagePrompt += if (isSPlus()) {
|
messagePrompt += if (isSPlus()) {
|
||||||
"\n\n${getString(R.string.media_management_alternative)}"
|
"\n\n${getString(R.string.media_management_alternative)}"
|
||||||
} else {
|
} else {
|
||||||
|
@ -214,7 +214,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
addNoMediaIntoMediaStore(file.absolutePath)
|
addNoMediaIntoMediaStore(file.absolutePath)
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
addNoMediaIntoMediaStore(file.absolutePath)
|
addNoMediaIntoMediaStore(file.absolutePath)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
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) {
|
fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList<FileDirItem>, isCopyOperation: Boolean, callback: (destinationPath: String) -> Unit) {
|
||||||
if (fileDirItems.isEmpty()) {
|
if (fileDirItems.isEmpty()) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,10 +477,10 @@ fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) {
|
||||||
recycleBin.deleteRecursively()
|
recycleBin.deleteRecursively()
|
||||||
mediaDB.clearRecycleBin()
|
mediaDB.clearRecycleBin()
|
||||||
directoryDB.deleteRecycleBin()
|
directoryDB.deleteRecycleBin()
|
||||||
toast(R.string.recycle_bin_emptied)
|
toast(com.simplemobiletools.commons.R.string.recycle_bin_emptied)
|
||||||
callback?.invoke()
|
callback?.invoke()
|
||||||
} catch (e: Exception) {
|
} 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) {
|
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()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,7 +617,7 @@ fun AppCompatActivity.fixDateTaken(
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
if (showToasts) {
|
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()
|
callback?.invoke()
|
||||||
|
@ -647,7 +653,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String,
|
||||||
getFileOutputStream(tmpFileDirItem) {
|
getFileOutputStream(tmpFileDirItem) {
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
if (showToasts) {
|
if (showToasts) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
return@getFileOutputStream
|
return@getFileOutputStream
|
||||||
}
|
}
|
||||||
|
@ -672,7 +678,7 @@ fun BaseSimpleActivity.saveRotatedImageToFile(oldPath: String, newPath: String,
|
||||||
}
|
}
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
if (showToasts) {
|
if (showToasts) {
|
||||||
toast(R.string.out_of_memory_error)
|
toast(com.simplemobiletools.commons.R.string.out_of_memory_error)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (showToasts) {
|
if (showToasts) {
|
||||||
|
@ -692,7 +698,7 @@ fun Activity.tryRotateByExif(path: String, degrees: Int, showToasts: Boolean, ca
|
||||||
fileRotatedSuccessfully(path, oldLastModified)
|
fileRotatedSuccessfully(path, oldLastModified)
|
||||||
callback.invoke()
|
callback.invoke()
|
||||||
if (showToasts) {
|
if (showToasts) {
|
||||||
toast(R.string.file_saved)
|
toast(com.simplemobiletools.commons.R.string.file_saved)
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -801,7 +807,7 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un
|
||||||
try {
|
try {
|
||||||
resizeImage(path, newPath, newSize) { success ->
|
resizeImage(path, newPath, newSize) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
toast(R.string.file_saved)
|
toast(com.simplemobiletools.commons.R.string.file_saved)
|
||||||
|
|
||||||
val paths = arrayListOf(file.absolutePath)
|
val paths = arrayListOf(file.absolutePath)
|
||||||
rescanPathsAndUpdateLastModified(paths, pathLastModifiedMap) {
|
rescanPathsAndUpdateLastModified(paths, pathLastModifiedMap) {
|
||||||
|
@ -814,7 +820,7 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
toast(R.string.out_of_memory_error)
|
toast(com.simplemobiletools.commons.R.string.out_of_memory_error)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
@ -882,7 +888,7 @@ fun Activity.getShortcutImage(tmb: String, drawable: Drawable, callback: () -> U
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
.fitCenter()
|
.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)
|
val builder = Glide.with(this)
|
||||||
.asDrawable()
|
.asDrawable()
|
||||||
.load(tmb)
|
.load(tmb)
|
||||||
|
|
|
@ -449,11 +449,11 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders:
|
||||||
|
|
||||||
fun Context.getFolderNameFromPath(path: String): String {
|
fun Context.getFolderNameFromPath(path: String): String {
|
||||||
return when (path) {
|
return when (path) {
|
||||||
internalStoragePath -> getString(R.string.internal)
|
internalStoragePath -> getString(com.simplemobiletools.commons.R.string.internal)
|
||||||
sdCardPath -> getString(R.string.sd_card)
|
sdCardPath -> getString(com.simplemobiletools.commons.R.string.sd_card)
|
||||||
otgPath -> getString(R.string.usb)
|
otgPath -> getString(com.simplemobiletools.commons.R.string.usb)
|
||||||
FAVORITES -> getString(R.string.favorites)
|
FAVORITES -> getString(com.simplemobiletools.commons.R.string.favorites)
|
||||||
RECYCLE_BIN -> getString(R.string.recycle_bin)
|
RECYCLE_BIN -> getString(com.simplemobiletools.commons.R.string.recycle_bin)
|
||||||
else -> path.getFilenameFromPath()
|
else -> path.getFilenameFromPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -550,7 +550,8 @@ fun Context.loadPng(
|
||||||
})
|
})
|
||||||
|
|
||||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
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()
|
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
}
|
}
|
||||||
|
@ -580,7 +581,8 @@ fun Context.loadJpg(
|
||||||
.transition(BitmapTransitionOptions.withCrossFade())
|
.transition(BitmapTransitionOptions.withCrossFade())
|
||||||
|
|
||||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
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()
|
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
}
|
}
|
||||||
|
@ -609,7 +611,8 @@ fun Context.loadStaticGIF(
|
||||||
.apply(options)
|
.apply(options)
|
||||||
|
|
||||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
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()
|
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
}
|
}
|
||||||
|
@ -629,7 +632,8 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
|
|
||||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
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()
|
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||||
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius))
|
||||||
}
|
}
|
||||||
|
@ -654,7 +658,8 @@ fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThu
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundCorners != ROUNDED_CORNERS_NONE) {
|
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()
|
val cornerRadius = resources.getDimension(cornerSize).toInt()
|
||||||
builder = builder.transform(PicassoRoundedCornersTransformation(cornerRadius.toFloat()))
|
builder = builder.transform(PicassoRoundedCornersTransformation(cornerRadius.toFloat()))
|
||||||
}
|
}
|
||||||
|
@ -893,7 +898,7 @@ fun Context.updateFavorite(path: String, isFavorite: Boolean) {
|
||||||
favoritesDB.deleteFavoritePath(path)
|
favoritesDB.deleteFavoritePath(path)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import com.simplemobiletools.gallery.pro.activities.PhotoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.PhotoVideoActivity
|
import com.simplemobiletools.gallery.pro.activities.PhotoVideoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity
|
import com.simplemobiletools.gallery.pro.activities.ViewPagerActivity
|
||||||
import com.simplemobiletools.gallery.pro.adapters.PortraitPhotosAdapter
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.saveRotatedImageToFile
|
import com.simplemobiletools.gallery.pro.extensions.saveRotatedImageToFile
|
||||||
import com.simplemobiletools.gallery.pro.extensions.sendFakeClick
|
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.Callback
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import it.sephiroth.android.library.exif2.ExifInterface
|
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.common.byteSources.ByteSourceInputStream
|
||||||
import org.apache.sanselan.formats.jpeg.JpegImageParser
|
import org.apache.sanselan.formats.jpeg.JpegImageParser
|
||||||
import pl.droidsonroids.gif.InputSource
|
import pl.droidsonroids.gif.InputSource
|
||||||
|
@ -98,6 +98,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
private var mStoredExtendedDetails = 0
|
private var mStoredExtendedDetails = 0
|
||||||
|
|
||||||
private lateinit var mView: ViewGroup
|
private lateinit var mView: ViewGroup
|
||||||
|
private lateinit var binding: PagerPhotoItemBinding
|
||||||
private lateinit var mMedium: Medium
|
private lateinit var mMedium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
|
@ -105,7 +106,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val activity = requireActivity()
|
val activity = requireActivity()
|
||||||
val arguments = requireArguments()
|
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)) {
|
if (!arguments.getBoolean(SHOULD_INIT_FRAGMENT, true)) {
|
||||||
return mView
|
return mView
|
||||||
}
|
}
|
||||||
|
@ -113,50 +115,50 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
mMedium = arguments.getSerializable(MEDIUM) as Medium
|
mMedium = arguments.getSerializable(MEDIUM) as Medium
|
||||||
mOriginalPath = mMedium.path
|
mOriginalPath = mMedium.path
|
||||||
|
|
||||||
mView.apply {
|
binding.apply {
|
||||||
subsampling_view.setOnClickListener { photoClicked() }
|
subsamplingView.setOnClickListener { photoClicked() }
|
||||||
gestures_view.setOnClickListener { photoClicked() }
|
gesturesView.setOnClickListener { photoClicked() }
|
||||||
gif_view.setOnClickListener { photoClicked() }
|
gifView.setOnClickListener { photoClicked() }
|
||||||
instant_prev_item.setOnClickListener { listener?.goToPrevItem() }
|
instantPrevItem.setOnClickListener { listener?.goToPrevItem() }
|
||||||
instant_next_item.setOnClickListener { listener?.goToNextItem() }
|
instantNextItem.setOnClickListener { listener?.goToNextItem() }
|
||||||
panorama_outline.setOnClickListener { openPanorama() }
|
panoramaOutline.setOnClickListener { openPanorama() }
|
||||||
|
|
||||||
instant_prev_item.parentView = container
|
instantPrevItem.parentView = container
|
||||||
instant_next_item.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 {
|
mView.apply {
|
||||||
if (subsampling_view.isVisible()) {
|
if (subsamplingView.isVisible()) {
|
||||||
subsampling_view.sendFakeClick(x, y)
|
subsamplingView.sendFakeClick(x, y)
|
||||||
} else {
|
} else {
|
||||||
gestures_view.sendFakeClick(x, y)
|
gesturesView.sendFakeClick(x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (context.config.allowDownGesture) {
|
if (context.config.allowDownGesture) {
|
||||||
gif_view.setOnTouchListener { v, event ->
|
gifView.setOnTouchListener { v, event ->
|
||||||
if (gif_view_frame.controller.state.zoom == 1f) {
|
if (gifViewFrame.controller.state.zoom == 1f) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
gestures_view.controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener {
|
gesturesView.controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener {
|
||||||
override fun onStateChanged(state: State) {
|
override fun onStateChanged(state: State) {
|
||||||
mCurrentGestureViewZoom = state.zoom
|
mCurrentGestureViewZoom = state.zoom
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
gestures_view.setOnTouchListener { v, event ->
|
gesturesView.setOnTouchListener { v, event ->
|
||||||
if (mCurrentGestureViewZoom == 1f) {
|
if (mCurrentGestureViewZoom == 1f) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
subsampling_view.setOnTouchListener { v, event ->
|
subsamplingView.setOnTouchListener { v, event ->
|
||||||
if (subsampling_view.isZoomedOut()) {
|
if (subsamplingView.isZoomedOut()) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
@ -195,7 +197,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
||||||
mMedium.path = file.absolutePath
|
mMedium.path = file.absolutePath
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
requireActivity().toast(R.string.unknown_error_occurred)
|
requireActivity().toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
return mView
|
return mView
|
||||||
} finally {
|
} finally {
|
||||||
out?.close()
|
out?.close()
|
||||||
|
@ -231,13 +233,13 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if (mWasInit) {
|
if (mWasInit) {
|
||||||
if (config.allowZoomingImages != mStoredAllowDeepZoomableImages || config.showHighestQuality != mStoredShowHighestQuality) {
|
if (config.allowZoomingImages != mStoredAllowDeepZoomableImages || config.showHighestQuality != mStoredShowHighestQuality) {
|
||||||
mIsSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
mView.subsampling_view.beGone()
|
binding.subsamplingView.beGone()
|
||||||
loadImage()
|
loadImage()
|
||||||
} else if (mMedium.isGIF()) {
|
} else if (mMedium.isGIF()) {
|
||||||
loadGif()
|
loadGif()
|
||||||
} else if (mIsSubsamplingVisible && mShouldResetImage) {
|
} else if (mIsSubsamplingVisible && mShouldResetImage) {
|
||||||
mView.subsampling_view.onGlobalLayout {
|
binding.subsamplingView.onGlobalLayout {
|
||||||
mView.subsampling_view.resetView()
|
binding.subsamplingView.resetView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mShouldResetImage = false
|
mShouldResetImage = false
|
||||||
|
@ -246,10 +248,10 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val allowPhotoGestures = config.allowPhotoGestures
|
val allowPhotoGestures = config.allowPhotoGestures
|
||||||
val allowInstantChange = config.allowInstantChange
|
val allowInstantChange = config.allowInstantChange
|
||||||
|
|
||||||
mView.apply {
|
binding.apply {
|
||||||
photo_brightness_controller.beVisibleIf(allowPhotoGestures)
|
photoBrightnessController.beVisibleIf(allowPhotoGestures)
|
||||||
instant_prev_item.beVisibleIf(allowInstantChange)
|
instantPrevItem.beVisibleIf(allowInstantChange)
|
||||||
instant_next_item.beVisibleIf(allowInstantChange)
|
instantNextItem.beVisibleIf(allowInstantChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
|
@ -258,11 +260,11 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
if (activity?.isDestroyed == false) {
|
if (activity?.isDestroyed == false) {
|
||||||
mView.subsampling_view.recycle()
|
binding.subsamplingView.recycle()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
Glide.with(requireContext()).clear(mView.gestures_view)
|
Glide.with(requireContext()).clear(binding.gesturesView)
|
||||||
}
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
|
@ -289,7 +291,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
measureScreen()
|
measureScreen()
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
mView.gif_view_frame.controller.resetState()
|
binding.gifViewFrame.controller.resetState()
|
||||||
loadGif()
|
loadGif()
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
|
@ -393,11 +395,11 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
InputSource.FileSource(pathToLoad)
|
InputSource.FileSource(pathToLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
mView.apply {
|
binding.apply {
|
||||||
gestures_view.beGone()
|
gesturesView.beGone()
|
||||||
gif_view_frame.beVisible()
|
gifViewFrame.beVisible()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
gif_view.setInputSource(source)
|
gifView.setInputSource(source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -413,14 +415,14 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
.`as`(PictureDrawable::class.java)
|
.`as`(PictureDrawable::class.java)
|
||||||
.listener(SvgSoftwareLayerSetter())
|
.listener(SvgSoftwareLayerSetter())
|
||||||
.load(mMedium.path)
|
.load(mMedium.path)
|
||||||
.into(mView.gestures_view)
|
.into(binding.gesturesView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadAPNG() {
|
private fun loadAPNG() {
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
val drawable = APNGDrawable.fromFile(mMedium.path)
|
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) {
|
if (drawable.intrinsicWidth == 0) {
|
||||||
loadWithGlide(path, addZoomableView)
|
loadWithGlide(path, addZoomableView)
|
||||||
} else {
|
} else {
|
||||||
mView.gestures_view.setImageDrawable(drawable)
|
binding.gesturesView.setImageDrawable(drawable)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loadWithGlide(path, addZoomableView)
|
loadWithGlide(path, addZoomableView)
|
||||||
|
@ -475,13 +477,13 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
isFirstResource: Boolean
|
isFirstResource: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val allowZoomingImages = context?.config?.allowZoomingImages ?: true
|
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) {
|
if (mIsFragmentVisible && addZoomableView) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}).into(mView.gestures_view)
|
}).into(binding.gesturesView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
|
private fun tryLoadingWithPicasso(addZoomableView: Boolean) {
|
||||||
|
@ -501,9 +503,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
degreesForRotation(mImageOrientation).toFloat()
|
degreesForRotation(mImageOrientation).toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
picasso.into(mView.gestures_view, object : Callback {
|
picasso.into(binding.gesturesView, object : Callback {
|
||||||
override fun onSuccess() {
|
override fun onSuccess() {
|
||||||
mView.gestures_view.controller.settings.isZoomEnabled =
|
binding.gesturesView.controller.settings.isZoomEnabled =
|
||||||
mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false
|
mMedium.isRaw() || mCurrentRotationDegrees != 0 || context?.config?.allowZoomingImages == false
|
||||||
if (mIsFragmentVisible && addZoomableView) {
|
if (mIsFragmentVisible && addZoomableView) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
|
@ -526,7 +528,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList<File>
|
val files = File(mMedium.parentPath).listFiles()?.toMutableList() as? ArrayList<File>
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
val screenWidth = requireContext().realScreenSize.x
|
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 sideWidth = screenWidth / 2 - itemWidth / 2
|
||||||
val fakeItemsCnt = ceil(sideWidth / itemWidth.toDouble()).toInt()
|
val fakeItemsCnt = ceil(sideWidth / itemWidth.toDouble()).toInt()
|
||||||
|
|
||||||
|
@ -542,7 +546,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
return@PortraitPhotosAdapter
|
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) {
|
if (paths[position] != mCurrentPortraitPhotoPath) {
|
||||||
mCurrentPortraitPhotoPath = paths[position]
|
mCurrentPortraitPhotoPath = paths[position]
|
||||||
hideZoomableView()
|
hideZoomableView()
|
||||||
|
@ -550,7 +554,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mView.photo_portrait_stripe.adapter = adapter
|
binding.photoPortraitStripe.adapter = adapter
|
||||||
setupStripeBottomMargin()
|
setupStripeBottomMargin()
|
||||||
|
|
||||||
val coverIndex = getCoverImageIndex(paths)
|
val coverIndex = getCoverImageIndex(paths)
|
||||||
|
@ -558,12 +562,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
mCurrentPortraitPhotoPath = paths[coverIndex]
|
mCurrentPortraitPhotoPath = paths[coverIndex]
|
||||||
setupStripeUpListener(adapter, screenWidth, itemWidth)
|
setupStripeUpListener(adapter, screenWidth, itemWidth)
|
||||||
|
|
||||||
mView.photo_portrait_stripe.onGlobalLayout {
|
binding.photoPortraitStripe.onGlobalLayout {
|
||||||
mView.photo_portrait_stripe.scrollBy((coverIndex - fakeItemsCnt) * itemWidth, 0)
|
binding.photoPortraitStripe.scrollBy((coverIndex - fakeItemsCnt) * itemWidth, 0)
|
||||||
adapter.setCurrentPhoto(coverIndex)
|
adapter.setCurrentPhoto(coverIndex)
|
||||||
mView.photo_portrait_stripe_wrapper.beVisible()
|
binding.photoPortraitStripeWrapper.beVisible()
|
||||||
if (mIsFullscreen) {
|
if (mIsFullscreen) {
|
||||||
mView.photo_portrait_stripe_wrapper.alpha = 0f
|
binding.photoPortraitStripeWrapper.alpha = 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -587,11 +591,11 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStripeBottomMargin() {
|
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) {
|
if (requireContext().config.bottomActions) {
|
||||||
bottomMargin += resources.getDimension(R.dimen.bottom_actions_height).toInt()
|
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 {
|
private fun getCoverImageIndex(paths: ArrayList<String>): Int {
|
||||||
|
@ -613,7 +617,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupStripeUpListener(adapter: PortraitPhotosAdapter, screenWidth: Int, itemWidth: Int) {
|
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) {
|
if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) {
|
||||||
var closestIndex = -1
|
var closestIndex = -1
|
||||||
var closestDistance = Integer.MAX_VALUE
|
var closestDistance = Integer.MAX_VALUE
|
||||||
|
@ -672,7 +676,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
newOrientation += 360
|
newOrientation += 360
|
||||||
}
|
}
|
||||||
|
|
||||||
mView.subsampling_view.apply {
|
binding.subsamplingView.apply {
|
||||||
setMaxTileSize(if (showHighestQuality) Integer.MAX_VALUE else 4096)
|
setMaxTileSize(if (showHighestQuality) Integer.MAX_VALUE else 4096)
|
||||||
setMinimumTileDpi(minTileDpi)
|
setMinimumTileDpi(minTileDpi)
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
|
@ -701,7 +705,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageLoadError(e: Exception) {
|
override fun onImageLoadError(e: Exception) {
|
||||||
mView.gestures_view.controller.settings.isZoomEnabled = true
|
binding.gesturesView.controller.settings.isZoomEnabled = true
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
mIsSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
beGone()
|
beGone()
|
||||||
|
@ -759,9 +763,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
mView.panorama_outline?.beVisibleIf(mIsPanorama)
|
binding.panoramaOutline.beVisibleIf(mIsPanorama)
|
||||||
if (mIsFullscreen) {
|
if (mIsFullscreen) {
|
||||||
mView.panorama_outline?.alpha = 0f
|
binding.panoramaOutline.alpha = 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -817,7 +821,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
fun rotateImageViewBy(degrees: Int) {
|
fun rotateImageViewBy(degrees: Int) {
|
||||||
if (mIsSubsamplingVisible) {
|
if (mIsSubsamplingVisible) {
|
||||||
mView.subsampling_view.rotateBy(degrees)
|
binding.subsamplingView.rotateBy(degrees)
|
||||||
} else {
|
} else {
|
||||||
mCurrentRotationDegrees = (mCurrentRotationDegrees + degrees) % 360
|
mCurrentRotationDegrees = (mCurrentRotationDegrees + degrees) % 360
|
||||||
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
|
@ -828,7 +832,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun initExtendedDetails() {
|
private fun initExtendedDetails() {
|
||||||
if (requireContext().config.showExtendedDetails) {
|
if (requireContext().config.showExtendedDetails) {
|
||||||
mView.photo_details.apply {
|
binding.photoDetails.apply {
|
||||||
beInvisible() // make it invisible so we can measure it, but not show yet
|
beInvisible() // make it invisible so we can measure it, but not show yet
|
||||||
text = getMediumExtendedDetails(mMedium)
|
text = getMediumExtendedDetails(mMedium)
|
||||||
onGlobalLayout {
|
onGlobalLayout {
|
||||||
|
@ -843,15 +847,15 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mView.photo_details.beGone()
|
binding.photoDetails.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideZoomableView() {
|
private fun hideZoomableView() {
|
||||||
if (context?.config?.allowZoomingImages == true) {
|
if (context?.config?.allowZoomingImages == true) {
|
||||||
mIsSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
mView.subsampling_view.recycle()
|
binding.subsamplingView.recycle()
|
||||||
mView.subsampling_view.beGone()
|
binding.subsamplingView.beGone()
|
||||||
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,14 +865,14 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateInstantSwitchWidths() {
|
private fun updateInstantSwitchWidths() {
|
||||||
mView.instant_prev_item.layoutParams.width = mScreenWidth / 7
|
binding.instantPrevItem.layoutParams.width = mScreenWidth / 7
|
||||||
mView.instant_next_item.layoutParams.width = mScreenWidth / 7
|
binding.instantNextItem.layoutParams.width = mScreenWidth / 7
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||||
this.mIsFullscreen = isFullscreen
|
this.mIsFullscreen = isFullscreen
|
||||||
mView.apply {
|
binding.apply {
|
||||||
photo_details.apply {
|
photoDetails.apply {
|
||||||
if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) {
|
if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) {
|
||||||
animate().y(getExtendedDetailsY(height))
|
animate().y(getExtendedDetailsY(height))
|
||||||
|
|
||||||
|
@ -879,18 +883,18 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsPanorama) {
|
if (mIsPanorama) {
|
||||||
panorama_outline.animate().alpha(if (isFullscreen) 0f else 1f).start()
|
panoramaOutline.animate().alpha(if (isFullscreen) 0f else 1f).start()
|
||||||
panorama_outline.isClickable = !isFullscreen
|
panoramaOutline.isClickable = !isFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mWasInit && mMedium.isPortrait()) {
|
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 {
|
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 fullscreenOffset = smallMargin + if (mIsFullscreen) 0 else requireContext().navigationBarHeight
|
||||||
val actionsHeight = if (requireContext().config.bottomActions && !mIsFullscreen) resources.getDimension(R.dimen.bottom_actions_height) else 0f
|
val actionsHeight = if (requireContext().config.bottomActions && !mIsFullscreen) resources.getDimension(R.dimen.bottom_actions_height) else 0f
|
||||||
return requireContext().realScreenSize.y - height - actionsHeight - fullscreenOffset
|
return requireContext().realScreenSize.y - height - actionsHeight - fullscreenOffset
|
||||||
|
|
|
@ -15,7 +15,6 @@ import android.widget.SeekBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.media3.common.*
|
import androidx.media3.common.*
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import androidx.media3.datasource.ContentDataSource
|
import androidx.media3.datasource.ContentDataSource
|
||||||
import androidx.media3.datasource.DataSource
|
import androidx.media3.datasource.DataSource
|
||||||
import androidx.media3.datasource.DataSpec
|
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.DefaultMediaSourceFactory
|
||||||
import androidx.media3.exoplayer.source.MediaSource
|
import androidx.media3.exoplayer.source.MediaSource
|
||||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.PanoramaVideoActivity
|
import com.simplemobiletools.gallery.pro.activities.PanoramaVideoActivity
|
||||||
import com.simplemobiletools.gallery.pro.activities.VideoActivity
|
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.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.hasNavBar
|
import com.simplemobiletools.gallery.pro.extensions.hasNavBar
|
||||||
import com.simplemobiletools.gallery.pro.extensions.parseFileChannel
|
import com.simplemobiletools.gallery.pro.extensions.parseFileChannel
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
import com.simplemobiletools.gallery.pro.views.MediaSideScroll
|
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.File
|
||||||
import java.io.FileInputStream
|
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 val PROGRESS = "progress"
|
||||||
|
|
||||||
private var mIsFullscreen = false
|
private var mIsFullscreen = false
|
||||||
|
@ -73,6 +73,7 @@ import java.io.FileInputStream
|
||||||
private lateinit var mTimeHolder: View
|
private lateinit var mTimeHolder: View
|
||||||
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
||||||
private lateinit var mVolumeSideScroll: MediaSideScroll
|
private lateinit var mVolumeSideScroll: MediaSideScroll
|
||||||
|
private lateinit var binding: PagerVideoItemBinding
|
||||||
private lateinit var mView: View
|
private lateinit var mView: View
|
||||||
private lateinit var mMedium: Medium
|
private lateinit var mMedium: Medium
|
||||||
private lateinit var mConfig: Config
|
private lateinit var mConfig: Config
|
||||||
|
@ -88,15 +89,15 @@ import java.io.FileInputStream
|
||||||
|
|
||||||
mMedium = arguments.getSerializable(MEDIUM) as Medium
|
mMedium = arguments.getSerializable(MEDIUM) as Medium
|
||||||
mConfig = context.config
|
mConfig = context.config
|
||||||
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
binding = PagerVideoItemBinding.inflate(inflater, container, false).apply {
|
||||||
panorama_outline.setOnClickListener { openPanorama() }
|
panoramaOutline.setOnClickListener { openPanorama() }
|
||||||
video_curr_time.setOnClickListener { skip(false) }
|
bottomVideoTimeHolder.videoCurrTime.setOnClickListener { skip(false) }
|
||||||
video_duration.setOnClickListener { skip(true) }
|
bottomVideoTimeHolder.videoDuration.setOnClickListener { skip(true) }
|
||||||
video_holder.setOnClickListener { toggleFullscreen() }
|
videoHolder.setOnClickListener { toggleFullscreen() }
|
||||||
video_preview.setOnClickListener { toggleFullscreen() }
|
videoPreview.setOnClickListener { toggleFullscreen() }
|
||||||
video_surface_frame.controller.settings.swallowDoubleTaps = true
|
videoSurfaceFrame.controller.settings.swallowDoubleTaps = true
|
||||||
|
|
||||||
video_play_outline.setOnClickListener {
|
videoPlayOutline.setOnClickListener {
|
||||||
if (mConfig.openVideosOnSeparateScreen) {
|
if (mConfig.openVideosOnSeparateScreen) {
|
||||||
launchVideoPlayer()
|
launchVideoPlayer()
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,21 +105,21 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPlayPauseButton = video_toggle_play_pause
|
mPlayPauseButton = bottomVideoTimeHolder.videoTogglePlayPause
|
||||||
mPlayPauseButton.setOnClickListener {
|
mPlayPauseButton.setOnClickListener {
|
||||||
togglePlayPause()
|
togglePlayPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
mSeekBar = video_seekbar
|
mSeekBar = bottomVideoTimeHolder.videoSeekbar
|
||||||
mSeekBar.setOnSeekBarChangeListener(this@VideoFragment)
|
mSeekBar.setOnSeekBarChangeListener(this@VideoFragment)
|
||||||
// adding an empty click listener just to avoid ripple animation at toggling fullscreen
|
// adding an empty click listener just to avoid ripple animation at toggling fullscreen
|
||||||
mSeekBar.setOnClickListener { }
|
mSeekBar.setOnClickListener { }
|
||||||
|
|
||||||
mTimeHolder = video_time_holder
|
mTimeHolder = bottomVideoTimeHolder.videoTimeHolder
|
||||||
mCurrTimeView = video_curr_time
|
mCurrTimeView = bottomVideoTimeHolder.videoCurrTime
|
||||||
mBrightnessSideScroll = video_brightness_controller
|
mBrightnessSideScroll = videoBrightnessController
|
||||||
mVolumeSideScroll = video_volume_controller
|
mVolumeSideScroll = videoVolumeController
|
||||||
mTextureView = video_surface
|
mTextureView = videoSurface
|
||||||
mTextureView.surfaceTextureListener = this@VideoFragment
|
mTextureView.surfaceTextureListener = this@VideoFragment
|
||||||
|
|
||||||
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@ -128,7 +129,7 @@ import java.io.FileInputStream
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
val viewWidth = width
|
val viewWidth = root.width
|
||||||
val instantWidth = viewWidth / 7
|
val instantWidth = viewWidth / 7
|
||||||
val clickedX = e.rawX
|
val clickedX = e.rawX
|
||||||
when {
|
when {
|
||||||
|
@ -145,13 +146,13 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
video_preview.setOnTouchListener { view, event ->
|
videoPreview.setOnTouchListener { view, event ->
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
video_surface_frame.setOnTouchListener { view, event ->
|
videoSurfaceFrame.setOnTouchListener { view, event ->
|
||||||
if (video_surface_frame.controller.state.zoom == 1f) {
|
if (videoSurfaceFrame.controller.state.zoom == 1f) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +160,14 @@ import java.io.FileInputStream
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mView = binding.root
|
||||||
|
|
||||||
if (!arguments.getBoolean(SHOULD_INIT_FRAGMENT, true)) {
|
if (!arguments.getBoolean(SHOULD_INIT_FRAGMENT, true)) {
|
||||||
return mView
|
return mView
|
||||||
}
|
}
|
||||||
|
|
||||||
storeStateVariables()
|
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)
|
// setMenuVisibility is not called at VideoActivity (third party intent)
|
||||||
if (!mIsFragmentVisible && activity is VideoActivity) {
|
if (!mIsFragmentVisible && activity is VideoActivity) {
|
||||||
|
@ -184,12 +186,12 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsPanorama) {
|
if (mIsPanorama) {
|
||||||
mView.apply {
|
binding.apply {
|
||||||
panorama_outline.beVisible()
|
panoramaOutline.beVisible()
|
||||||
video_play_outline.beGone()
|
videoPlayOutline.beGone()
|
||||||
mVolumeSideScroll.beGone()
|
mVolumeSideScroll.beGone()
|
||||||
mBrightnessSideScroll.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
|
mWasFragmentInit = true
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
|
|
||||||
mView.apply {
|
binding.apply {
|
||||||
mBrightnessSideScroll.initialize(activity, slide_info, true, container, singleTap = { x, y ->
|
mBrightnessSideScroll.initialize(activity, slideInfo, true, container, singleTap = { x, y ->
|
||||||
if (mConfig.allowInstantChange) {
|
if (mConfig.allowInstantChange) {
|
||||||
listener?.goToPrevItem()
|
listener?.goToPrevItem()
|
||||||
} else {
|
} else {
|
||||||
|
@ -212,7 +214,7 @@ import java.io.FileInputStream
|
||||||
doSkip(false)
|
doSkip(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
mVolumeSideScroll.initialize(activity, slide_info, false, container, singleTap = { x, y ->
|
mVolumeSideScroll.initialize(activity, slideInfo, false, container, singleTap = { x, y ->
|
||||||
if (mConfig.allowInstantChange) {
|
if (mConfig.allowInstantChange) {
|
||||||
listener?.goToNextItem()
|
listener?.goToNextItem()
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,7 +224,7 @@ import java.io.FileInputStream
|
||||||
doSkip(true)
|
doSkip(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
video_surface.onGlobalLayout {
|
videoSurface.onGlobalLayout {
|
||||||
if (mIsFragmentVisible && mConfig.autoplayVideos && !mConfig.openVideosOnSeparateScreen) {
|
if (mIsFragmentVisible && mConfig.autoplayVideos && !mConfig.openVideosOnSeparateScreen) {
|
||||||
playVideo()
|
playVideo()
|
||||||
}
|
}
|
||||||
|
@ -241,10 +243,10 @@ import java.io.FileInputStream
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
mConfig = requireContext().config // make sure we get a new config, in case the user changed something in the app settings
|
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
|
val allowVideoGestures = mConfig.allowVideoGestures
|
||||||
mTextureView.beGoneIf(mConfig.openVideosOnSeparateScreen || mIsPanorama)
|
mTextureView.beGoneIf(mConfig.openVideosOnSeparateScreen || mIsPanorama)
|
||||||
mView.video_surface_frame.beGoneIf(mTextureView.isGone())
|
binding.videoSurfaceFrame.beGoneIf(mTextureView.isGone())
|
||||||
|
|
||||||
mVolumeSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
mVolumeSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
mBrightnessSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
mBrightnessSideScroll.beVisibleIf(allowVideoGestures && !mIsPanorama)
|
||||||
|
@ -287,8 +289,8 @@ import java.io.FileInputStream
|
||||||
setVideoSize()
|
setVideoSize()
|
||||||
initTimeHolder()
|
initTimeHolder()
|
||||||
checkExtendedDetails()
|
checkExtendedDetails()
|
||||||
mView.video_surface_frame.onGlobalLayout {
|
binding.videoSurfaceFrame.onGlobalLayout {
|
||||||
mView.video_surface_frame.controller.resetState()
|
binding.videoSurfaceFrame.controller.resetState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +329,7 @@ import java.io.FileInputStream
|
||||||
|
|
||||||
private fun setupTimeHolder() {
|
private fun setupTimeHolder() {
|
||||||
mSeekBar.max = mDuration
|
mSeekBar.max = mDuration
|
||||||
mView.video_duration.text = mDuration.getFormattedDuration()
|
binding.bottomVideoTimeHolder.videoDuration.text = mDuration.getFormattedDuration()
|
||||||
setupTimer()
|
setupTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +448,7 @@ import java.io.FileInputStream
|
||||||
|
|
||||||
private fun checkExtendedDetails() {
|
private fun checkExtendedDetails() {
|
||||||
if (mConfig.showExtendedDetails) {
|
if (mConfig.showExtendedDetails) {
|
||||||
mView.video_details.apply {
|
binding.videoDetails.apply {
|
||||||
beInvisible() // make it invisible so we can measure it, but not show yet
|
beInvisible() // make it invisible so we can measure it, but not show yet
|
||||||
text = getMediumExtendedDetails(mMedium)
|
text = getMediumExtendedDetails(mMedium)
|
||||||
onGlobalLayout {
|
onGlobalLayout {
|
||||||
|
@ -461,7 +463,7 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mView.video_details.beGone()
|
binding.videoDetails.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,12 +513,16 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
mSeekBar.setOnSeekBarChangeListener(if (mIsFullscreen) null else this)
|
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
|
it.isClickable = !mIsFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimeHolder.animate().alpha(newAlpha).start()
|
mTimeHolder.animate().alpha(newAlpha).start()
|
||||||
mView.video_details.apply {
|
binding.videoDetails.apply {
|
||||||
if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) {
|
if (mStoredShowExtendedDetails && isVisible() && context != null && resources != null) {
|
||||||
animate().y(getExtendedDetailsY(height))
|
animate().y(getExtendedDetailsY(height))
|
||||||
|
|
||||||
|
@ -528,7 +534,7 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getExtendedDetailsY(height: Int): Float {
|
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 fullscreenOffset = smallMargin + if (mIsFullscreen) 0 else requireContext().navigationBarHeight
|
||||||
var actionsHeight = 0f
|
var actionsHeight = 0f
|
||||||
if (!mIsFullscreen) {
|
if (!mIsFullscreen) {
|
||||||
|
@ -629,8 +635,8 @@ import java.io.FileInputStream
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mView.video_preview.isVisible()) {
|
if (binding.videoPreview.isVisible()) {
|
||||||
mView.video_preview.beGone()
|
binding.videoPreview.beGone()
|
||||||
initExoPlayer()
|
initExoPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,11 +651,11 @@ import java.io.FileInputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasEnded || !mConfig.loopVideos) {
|
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) {
|
if (!mWasVideoStarted) {
|
||||||
mView.video_play_outline.beGone()
|
binding.videoPlayOutline.beGone()
|
||||||
mPlayPauseButton.beVisible()
|
mPlayPauseButton.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +677,7 @@ import java.io.FileInputStream
|
||||||
mExoPlayer?.playWhenReady = false
|
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)
|
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
mPositionAtPause = mExoPlayer?.currentPosition ?: 0L
|
mPositionAtPause = mExoPlayer?.currentPosition ?: 0L
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.view.MotionEvent
|
||||||
import androidx.exifinterface.media.ExifInterface
|
import androidx.exifinterface.media.ExifInterface
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import com.simplemobiletools.gallery.pro.models.Medium
|
import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
|
@ -139,6 +138,7 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
mTouchDownX = event.rawX
|
mTouchDownX = event.rawX
|
||||||
mTouchDownY = event.rawY
|
mTouchDownY = event.rawY
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
val diffX = mTouchDownX - event.rawX
|
val diffX = mTouchDownX - event.rawX
|
||||||
|
@ -147,7 +147,7 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
val downGestureDuration = System.currentTimeMillis() - mTouchDownTime
|
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) {
|
if (!mIgnoreCloseDown && (Math.abs(diffY) > Math.abs(diffX)) && (diffY < -mCloseDownThreshold) && downGestureDuration < MAX_CLOSE_DOWN_GESTURE_DURATION && context?.config?.allowDownGesture == true) {
|
||||||
activity?.finish()
|
activity?.finish()
|
||||||
activity?.overridePendingTransition(0, R.anim.slide_down)
|
activity?.overridePendingTransition(0, com.simplemobiletools.commons.R.anim.slide_down)
|
||||||
}
|
}
|
||||||
mIgnoreCloseDown = false
|
mIgnoreCloseDown = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package com.simplemobiletools.gallery.pro.helpers
|
package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
import com.simplemobiletools.commons.helpers.MONTH_SECONDS
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_MEDIA_IMAGES
|
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
|
||||||
import com.simplemobiletools.commons.helpers.isTiramisuPlus
|
|
||||||
|
|
||||||
// shared preferences
|
// shared preferences
|
||||||
const val DIRECTORY_SORT_ORDER = "directory_sort_order"
|
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
|
const val FOLDER_STYLE_ROUNDED_CORNERS = 2
|
||||||
|
|
||||||
fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.pro.helpers
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import com.simplemobiletools.gallery.pro.models.FilterItem
|
import com.simplemobiletools.gallery.pro.models.FilterItem
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class FilterThumbnailsManager {
|
class FilterThumbnailsManager {
|
||||||
private var filterThumbnails = ArrayList<FilterItem>(10)
|
private var filterThumbnails = ArrayList<FilterItem>(10)
|
||||||
|
|
|
@ -19,7 +19,8 @@ import com.simplemobiletools.gallery.pro.models.Medium
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||||
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
import com.simplemobiletools.gallery.pro.models.ThumbnailSection
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class MediaFetcher(val context: Context) {
|
class MediaFetcher(val context: Context) {
|
||||||
var shouldStop = false
|
var shouldStop = false
|
||||||
|
@ -777,6 +778,7 @@ class MediaFetcher(val context: Context) {
|
||||||
o1.name.normalizeString().toLowerCase().compareTo(o2.name.normalizeString().toLowerCase())
|
o1.name.normalizeString().toLowerCase().compareTo(o2.name.normalizeString().toLowerCase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sorting and SORT_BY_PATH != 0 -> {
|
sorting and SORT_BY_PATH != 0 -> {
|
||||||
if (sorting and SORT_USE_NUMERIC_VALUE != 0) {
|
if (sorting and SORT_USE_NUMERIC_VALUE != 0) {
|
||||||
AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase())
|
AlphanumericComparator().compare(o1.path.toLowerCase(), o2.path.toLowerCase())
|
||||||
|
@ -784,6 +786,7 @@ class MediaFetcher(val context: Context) {
|
||||||
o1.path.toLowerCase().compareTo(o2.path.toLowerCase())
|
o1.path.toLowerCase().compareTo(o2.path.toLowerCase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sorting and SORT_BY_SIZE != 0 -> o1.size.compareTo(o2.size)
|
sorting and SORT_BY_SIZE != 0 -> o1.size.compareTo(o2.size)
|
||||||
sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified)
|
sorting and SORT_BY_DATE_MODIFIED != 0 -> o1.modified.compareTo(o2.modified)
|
||||||
else -> o1.taken.compareTo(o2.taken)
|
else -> o1.taken.compareTo(o2.taken)
|
||||||
|
@ -860,6 +863,7 @@ class MediaFetcher(val context: Context) {
|
||||||
today,
|
today,
|
||||||
yesterday
|
yesterday
|
||||||
)
|
)
|
||||||
|
|
||||||
grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 || grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 -> formatDate(key, false)
|
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_FILE_TYPE != 0 -> getFileTypeString(key)
|
||||||
grouping and GROUP_BY_EXTENSION != 0 -> key.toUpperCase()
|
grouping and GROUP_BY_EXTENSION != 0 -> key.toUpperCase()
|
||||||
|
@ -868,7 +872,7 @@ class MediaFetcher(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isEmpty()) {
|
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) {
|
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 {
|
private fun getFinalDate(date: String, today: String, yesterday: String): String {
|
||||||
return when (date) {
|
return when (date) {
|
||||||
today -> context.getString(R.string.today)
|
today -> context.getString(com.simplemobiletools.commons.R.string.today)
|
||||||
yesterday -> context.getString(R.string.yesterday)
|
yesterday -> context.getString(com.simplemobiletools.commons.R.string.yesterday)
|
||||||
else -> date
|
else -> date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,5 @@ data class DateTaken(
|
||||||
@ColumnInfo(name = "parent_path") var parentPath: String,
|
@ColumnInfo(name = "parent_path") var parentPath: String,
|
||||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||||
@ColumnInfo(name = "last_fixed") var lastFixed: Int,
|
@ColumnInfo(name = "last_fixed") var lastFixed: Int,
|
||||||
@ColumnInfo(name = "last_modified") var lastModified: Long)
|
@ColumnInfo(name = "last_modified") var lastModified: Long
|
||||||
|
)
|
||||||
|
|
|
@ -9,7 +9,8 @@ import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.Serializable
|
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))])
|
@Entity(tableName = "media", indices = [(Index(value = ["full_path"], unique = true))])
|
||||||
data class Medium(
|
data class Medium(
|
||||||
|
|
|
@ -17,7 +17,13 @@ class SvgSoftwareLayerSetter : RequestListener<PictureDrawable> {
|
||||||
return false
|
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
|
val view = (target as ImageViewTarget<*>).view
|
||||||
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
|
view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -65,11 +65,13 @@ class EditorDrawCanvas(context: Context, attrs: AttributeSet) : View(context, at
|
||||||
mStartY = y
|
mStartY = y
|
||||||
actionDown(x, y)
|
actionDown(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
if (event.pointerCount == 1 && !mWasMultitouch) {
|
if (event.pointerCount == 1 && !mWasMultitouch) {
|
||||||
actionMove(x, y)
|
actionMove(x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> actionUp()
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> actionUp()
|
||||||
MotionEvent.ACTION_POINTER_DOWN -> mWasMultitouch = true
|
MotionEvent.ACTION_POINTER_DOWN -> mWasMultitouch = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
||||||
mTouchDownY = event.rawY
|
mTouchDownY = event.rawY
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
val diffX = mTouchDownX - event.rawX
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.rawY
|
val diffY = mTouchDownY - event.rawY
|
||||||
|
@ -47,6 +48,7 @@ class InstantItemSwitch(context: Context, attrs: AttributeSet) : RelativeLayout(
|
||||||
performClick()
|
performClick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
if (passTouches) {
|
if (passTouches) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -99,6 +99,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
mTouchDownValue = getCurrentVolume()
|
mTouchDownValue = getCurrentVolume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val diffX = mTouchDownX - event.rawX
|
val diffX = mTouchDownX - event.rawX
|
||||||
val diffY = mTouchDownY - event.rawY
|
val diffY = mTouchDownY - event.rawY
|
||||||
|
@ -125,6 +126,7 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
}
|
}
|
||||||
mLastTouchY = event.rawY
|
mLastTouchY = event.rawY
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
if (mIsBrightnessScroll) {
|
if (mIsBrightnessScroll) {
|
||||||
mTouchDownValue = mTempBrightness
|
mTouchDownValue = mTempBrightness
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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
|
<ImageView
|
||||||
android:id="@+id/explore"
|
android:id="@+id/explore"
|
||||||
|
|
|
@ -46,7 +46,9 @@
|
||||||
android:background="@drawable/gradient_background"
|
android:background="@drawable/gradient_background"
|
||||||
tools:ignore="UnknownIdInLayout" />
|
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
|
<TextView
|
||||||
android:id="@+id/slide_info"
|
android:id="@+id/slide_info"
|
||||||
|
|
|
@ -66,7 +66,9 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:text="My video\nAnother line" />
|
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
|
<TextView
|
||||||
android:id="@+id/slide_info"
|
android:id="@+id/slide_info"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.simplemobiletools.gallery.pro"
|
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|
|
@ -66,7 +66,7 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
if (it) {
|
if (it) {
|
||||||
initEditActivity()
|
initEditActivity()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
if (success) {
|
if (success) {
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,9 +296,9 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val theme = if (isUsingSystemDarkTheme()) {
|
val theme = if (isUsingSystemDarkTheme()) {
|
||||||
R.style.Theme_Imgly_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
|
||||||
} else {
|
} else {
|
||||||
R.style.Theme_Imgly_Light_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
||||||
|
|
|
@ -61,7 +61,7 @@ class NewVideoEditActivity : SimpleActivity() {
|
||||||
if (it) {
|
if (it) {
|
||||||
initEditActivity()
|
initEditActivity()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.no_storage_permissions)
|
toast(com.simplemobiletools.commons.R.string.no_storage_permissions)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ class NewVideoEditActivity : SimpleActivity() {
|
||||||
if (success) {
|
if (success) {
|
||||||
callback()
|
callback()
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,9 +274,9 @@ class NewVideoEditActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val theme = if (isUsingSystemDarkTheme()) {
|
val theme = if (isUsingSystemDarkTheme()) {
|
||||||
R.style.Theme_Imgly_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
|
||||||
} else {
|
} else {
|
||||||
R.style.Theme_Imgly_Light_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
||||||
|
|
49
build.gradle
49
build.gradle
|
@ -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
6
build.gradle.kts
Normal 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)
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx1536m
|
||||||
|
|
42
gradle/imglysdk.gradle
Normal file
42
gradle/imglysdk.gradle
Normal 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
84
gradle/libs.versions.toml
Normal 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" }
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
include ':app'
|
|
||||||
//include ':commons'
|
|
||||||
//project(':commons').projectDir = new File('../Simple-Commons/commons')
|
|
20
settings.gradle.kts
Normal file
20
settings.gradle.kts
Normal 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")
|
Loading…
Reference in a new issue