-
-
Notifications
You must be signed in to change notification settings - Fork 37
FEAT: added alarm and timer export and import functionality #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b4503fc
FEAT: added alram export and import functionality
ronniedroid 2a381a3
moved to registerForActivityResult and added timers to exports
ronniedroid 34dfd03
Fixed data importing and made code more robust
ronniedroid e253c56
Updated strings and remove action aborted toast messages
ronniedroid eded923
fixed doublicate alarms and replacing timers when importing
ronniedroid f66488e
fixed timers not importing when list of timers is empty
ronniedroid 8c08994
fixed code formatting
ronniedroid 4c67e2b
changed toast messages for importing
ronniedroid 849b8c8
Merge branch 'master' into export_alarms
naveensingh b6e5820
Use proper style for setting item
naveensingh f5b0c31
Add kotlin serialization
naveensingh 3512577
Use kotlin serialization and simplify code
naveensingh c4f429a
Fix lint errors
naveensingh 5a50092
Remove unnecessary toast
naveensingh 6feb093
Allow exporting timers alarms or timers
naveensingh 4fef367
Remove unnecessary widgets from export dialog
naveensingh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
app/src/main/kotlin/org/fossify/clock/dialogs/ExportDataDialog.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package org.fossify.clock.dialogs | ||
|
|
||
| import androidx.appcompat.app.AlertDialog | ||
| import org.fossify.commons.activities.BaseSimpleActivity | ||
| import org.fossify.commons.dialogs.FilePickerDialog | ||
| import org.fossify.commons.extensions.* | ||
| import org.fossify.commons.helpers.ensureBackgroundThread | ||
| import org.fossify.clock.R | ||
| import org.fossify.clock.databinding.DialogExportDataBinding | ||
| import org.fossify.clock.extensions.config | ||
| import org.fossify.clock.helpers.DATA_EXPORT_EXTENSION | ||
| import java.io.File | ||
|
|
||
| class ExportDataDialog( | ||
| val activity: BaseSimpleActivity, | ||
| val path: String, | ||
| val hidePath: Boolean, | ||
| callback: (file: File) -> Unit, | ||
| ) { | ||
| private var realPath = path.ifEmpty { activity.internalStoragePath } | ||
| private val config = activity.config | ||
|
|
||
| init { | ||
| val view = DialogExportDataBinding.inflate(activity.layoutInflater, null, false).apply { | ||
| exportDataFolder.text = activity.humanizePath(realPath) | ||
| exportDataFilename.setText("${activity.getString(R.string.settings_export_data)}_${activity.getCurrentFormattedDateTime()}") | ||
|
|
||
| if (hidePath) { | ||
| exportDataFolderLabel.beGone() | ||
| exportDataFolder.beGone() | ||
| } else { | ||
| exportDataFolder.setOnClickListener { | ||
| FilePickerDialog(activity, realPath, false, showFAB = true) { | ||
| exportDataFolder.text = activity.humanizePath(it) | ||
| realPath = it | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| activity.getAlertDialogBuilder() | ||
| .setPositiveButton(org.fossify.commons.R.string.ok, null) | ||
| .setNegativeButton(org.fossify.commons.R.string.cancel, null) | ||
| .apply { | ||
| activity.setupDialogStuff(view.root, this, R.string.settings_export_data) { alertDialog -> | ||
| alertDialog.showKeyboard(view.exportDataFilename) | ||
| alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { | ||
| val filename = view.exportDataFilename.value | ||
| when { | ||
| filename.isEmpty() -> activity.toast(org.fossify.commons.R.string.empty_name) | ||
| filename.isAValidFilename() -> { | ||
| val file = File(realPath, "$filename$DATA_EXPORT_EXTENSION") | ||
| if (!hidePath && file.exists()) { | ||
| activity.toast(org.fossify.commons.R.string.name_taken) | ||
| return@setOnClickListener | ||
| } | ||
|
|
||
| ensureBackgroundThread { | ||
| config.lastDataExportPath = file.absolutePath.getParentPath() | ||
| callback(file) | ||
| alertDialog.dismiss() | ||
| } | ||
| } | ||
|
|
||
| else -> activity.toast(org.fossify.commons.R.string.invalid_name) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.