mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
adding some boilerplate related to importing settings
This commit is contained in:
parent
7382546e2c
commit
596edde553
2 changed files with 24 additions and 1 deletions
|
@ -61,7 +61,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.7.0'
|
implementation 'com.simplemobiletools:commons:5.7.1'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.dialogs.SecurityDialog
|
import com.simplemobiletools.commons.dialogs.SecurityDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
@ -18,6 +19,7 @@ import com.simplemobiletools.gallery.pro.extensions.galleryDB
|
||||||
import com.simplemobiletools.gallery.pro.extensions.showRecycleBinEmptyingDialog
|
import com.simplemobiletools.gallery.pro.extensions.showRecycleBinEmptyingDialog
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
@ -657,7 +659,28 @@ class SettingsActivity : SimpleActivity() {
|
||||||
|
|
||||||
private fun setupImportSettings() {
|
private fun setupImportSettings() {
|
||||||
settings_import_holder.setOnClickListener {
|
settings_import_holder.setOnClickListener {
|
||||||
|
FilePickerDialog(this) {
|
||||||
|
Thread {
|
||||||
|
parseFile(it)
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseFile(path: String) {
|
||||||
|
val inputStream = File(path).inputStream()
|
||||||
|
inputStream.bufferedReader().use {
|
||||||
|
var importedItems = 0
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
var line = it.readLine() ?: break
|
||||||
|
importedItems++
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toast(if (importedItems > 0) R.string.settings_imported_successfully else R.string.no_entries_for_importing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue