Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Create release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ steps.get_version.outputs.version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import androidx.fragment.app.setFragmentResultListener
Expand All @@ -35,7 +34,7 @@ class FolderPickerDialogFragment : DialogFragment(), FolderPickerAdapter.Listene

fun newInstance(path: String?): FolderPickerDialogFragment =
FolderPickerDialogFragment().apply {
arguments = bundleOf(ARG_PATH to path)
arguments = Bundle().apply { putString(ARG_PATH, path) }
}
}

Expand Down Expand Up @@ -111,10 +110,10 @@ class FolderPickerDialogFragment : DialogFragment(), FolderPickerAdapter.Listene
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)

setFragmentResult(tag!!, bundleOf(
RESULT_SUCCESS to success,
RESULT_PATH to viewModel.state.value.shortCwd.toString(),
))
setFragmentResult(tag!!, Bundle().apply {
putBoolean(RESULT_SUCCESS, success)
putString(RESULT_PATH, viewModel.state.value.shortCwd.toString())
})
}

override fun onNameSelected(position: Int, name: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import android.app.Dialog
import android.content.ClipData
import android.content.ClipboardManager
import android.os.Bundle
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder

Expand All @@ -22,10 +21,10 @@ class MessageDialogFragment : DialogFragment() {

fun newInstance(title: String?, message: String?): MessageDialogFragment =
MessageDialogFragment().apply {
arguments = bundleOf(
ARG_TITLE to title,
ARG_MESSAGE to message,
)
arguments = Bundle().apply {
putString(ARG_TITLE, title)
putString(ARG_MESSAGE, message)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class MinBatteryLevelDialogFragment : TextInputDialogFragment<Int>() {
null
}

override fun updateResult(result: Bundle) {
if (result.getBoolean(RESULT_SUCCESS)) {
override fun updateResult(result: Bundle, value: Int?) {
value?.let {
val prefs = Preferences(requireContext())
prefs.minBatteryLevel = result.getInt(RESULT_VALUE)
prefs.minBatteryLevel = it
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
package com.chiller3.basicsync.dialog

import android.content.Context
import android.os.Bundle
import com.chiller3.basicsync.R

class NewFolderDialogFragment : TextInputDialogFragment<String>() {
companion object {
val TAG: String = NewFolderDialogFragment::class.java.simpleName

const val RESULT_SUCCESS = TextInputDialogFragment.RESULT_SUCCESS
const val RESULT_NAME = RESULT_VALUE
const val RESULT_NAME = "name"

fun newInstance(context: Context, cwd: String) =
NewFolderDialogFragment().apply {
Expand All @@ -32,4 +33,8 @@ class NewFolderDialogFragment : TextInputDialogFragment<String>() {
} else {
null
}

override fun updateResult(result: Bundle, value: String?) {
result.putString(RESULT_NAME, value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.chiller3.basicsync.dialog

import android.content.Context
import android.os.Bundle
import com.chiller3.basicsync.R
import com.chiller3.basicsync.settings.ImportExportMode

Expand All @@ -14,7 +15,7 @@ class PasswordDialogFragment : TextInputDialogFragment<String>() {
val TAG: String = PasswordDialogFragment::class.java.simpleName

const val RESULT_SUCCESS = TextInputDialogFragment.RESULT_SUCCESS
const val RESULT_PASSWORD = RESULT_VALUE
const val RESULT_PASSWORD = "password"

fun newInstance(context: Context, mode: ImportExportMode) =
PasswordDialogFragment().apply {
Expand Down Expand Up @@ -48,4 +49,8 @@ class PasswordDialogFragment : TextInputDialogFragment<String>() {
}

override fun translateInput(input: String): String = input

override fun updateResult(result: Bundle, value: String?) {
result.putString(RESULT_PASSWORD, value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.content.DialogInterface
import android.os.Bundle
import android.text.InputType
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.DialogFragment
Expand Down Expand Up @@ -126,7 +125,7 @@ class SyncScheduleDialogFragment : DialogFragment() {
prefs.scheduleSyncMs = syncMs!!
}

setFragmentResult(tag!!, bundleOf(RESULT_SUCCESS to success))
setFragmentResult(tag!!, Bundle().apply { putBoolean(RESULT_SUCCESS, success) })
}

private fun refreshOkButtonEnabledState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import android.content.DialogInterface
import android.os.Bundle
import android.text.InputType
import androidx.appcompat.app.AlertDialog
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener
import androidx.fragment.app.DialogFragment
Expand Down Expand Up @@ -48,21 +47,20 @@ data class TextInputParams(
origValue = args.getString(ARG_ORIG_VALUE),
)

fun toArgs() = bundleOf(
ARG_INPUT_TYPE to inputType.ordinal,
ARG_TITLE to title,
ARG_MESSAGE to message,
ARG_HINT to hint,
ARG_CONFIRM_HINT to confirmHint,
ARG_ORIG_VALUE to origValue,
)
fun toArgs() = Bundle().apply {
putInt(ARG_INPUT_TYPE, inputType.ordinal)
putString(ARG_TITLE, title)
putString(ARG_MESSAGE, message)
putString(ARG_HINT, hint)
putString(ARG_CONFIRM_HINT, confirmHint)
putString(ARG_ORIG_VALUE, origValue)
}
}

abstract class TextInputDialogFragment<T> : DialogFragment() {
companion object {
protected const val RESULT_SUCCESS = "success"
protected const val RESULT_ORIG_VALUE = "orig_value"
protected const val RESULT_VALUE = "value"
}

private lateinit var binding: DialogTextInputBinding
Expand Down Expand Up @@ -121,11 +119,10 @@ abstract class TextInputDialogFragment<T> : DialogFragment() {
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)

setFragmentResult(tag!!, bundleOf(
RESULT_SUCCESS to success,
RESULT_ORIG_VALUE to params.origValue,
RESULT_VALUE to value,
).also(::updateResult))
setFragmentResult(tag!!, Bundle().apply {
putBoolean(RESULT_SUCCESS, success)
putString(RESULT_ORIG_VALUE, params.origValue)
}.also { updateResult(it, value) })
}

private fun refreshOkButtonEnabledState() {
Expand All @@ -136,5 +133,5 @@ abstract class TextInputDialogFragment<T> : DialogFragment() {

abstract fun translateInput(input: String): T?

open fun updateResult(result: Bundle) {}
abstract fun updateResult(result: Bundle, value: T?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package com.chiller3.basicsync.dialog

import android.content.Context
import android.os.Bundle
import com.chiller3.basicsync.R

class WifiNetworkDialogFragment : TextInputDialogFragment<String>() {
Expand All @@ -14,7 +15,7 @@ class WifiNetworkDialogFragment : TextInputDialogFragment<String>() {

const val RESULT_SUCCESS = TextInputDialogFragment.RESULT_SUCCESS
const val RESULT_OLD_NAME = RESULT_ORIG_VALUE
const val RESULT_NAME = RESULT_VALUE
const val RESULT_NAME = "name"

fun newInstance(context: Context, origName: String?) =
WifiNetworkDialogFragment().apply {
Expand All @@ -29,4 +30,8 @@ class WifiNetworkDialogFragment : TextInputDialogFragment<String>() {
}

override fun translateInput(input: String): String? = input.ifEmpty { null }

override fun updateResult(result: Bundle, value: String?) {
result.putString(RESULT_NAME, value)
}
}
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
activity-ktx = "1.12.4"
activity-ktx = "1.13.0"
android-gradle-plugin = "9.1.0"
appcompat = "1.7.1"
camera = "1.5.3"
core-ktx = "1.17.0"
jgit = "7.5.0.202512021534-r"
core-ktx = "1.18.0"
jgit = "7.6.0.202603022253-r"
fragment-ktx = "1.8.9"
material = "1.13.0"
preference-ktx = "1.2.1"
Expand Down
Loading