mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2025-01-17 14:46:32 -07:00
various fixes for dialogs
This commit is contained in:
parent
dce2242386
commit
16be4da12b
@ -210,7 +210,6 @@ class OnboardingActivity : WalletOpeningActivity() {
|
||||
|
||||
val listener = object : NodeSelectionDialogListenerAdapter(
|
||||
activity = this,
|
||||
nodes = nodes,
|
||||
) {
|
||||
override fun trySelectNode(
|
||||
self: NodeSelectionBottomSheetDialog,
|
||||
|
@ -131,7 +131,6 @@ class SettingsActivity : MoneroActivity() {
|
||||
|
||||
val listener = object : NodeSelectionDialogListenerAdapter(
|
||||
activity = this,
|
||||
nodes = nodes,
|
||||
) {
|
||||
override fun trySelectNode(
|
||||
self: NodeSelectionBottomSheetDialog,
|
||||
|
@ -32,7 +32,7 @@ class AddNodeBottomSheetDialog(val listener: AddNodeListener) : BottomSheetDialo
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_add_node, null)
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_add_node, container)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -71,7 +71,7 @@ class AddNodeBottomSheetDialog(val listener: AddNodeListener) : BottomSheetDialo
|
||||
|
||||
addNodeButton.setOnClickListener {
|
||||
val name = nodeNameEditText.text.toString()
|
||||
var address = addressEditText.text.toString()
|
||||
val address = addressEditText.text.toString()
|
||||
val username = usernameEditText.text.toString().ifBlank { null }
|
||||
val password = passwordEditText.text.toString().ifBlank { null }
|
||||
val trusted = trustedDaemonCheckbox.isChecked
|
||||
|
@ -33,7 +33,7 @@ class EditNodeBottomSheetDialog(val listener: EditNodeListener, val node: Node)
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_edit_node, null)
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_edit_node, container)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -84,7 +84,7 @@ class EditNodeBottomSheetDialog(val listener: EditNodeListener, val node: Node)
|
||||
|
||||
doneEditingButton.setOnClickListener {
|
||||
val name = nodeNameEditText.text.toString()
|
||||
var address = addressEditText.text.toString()
|
||||
val address = addressEditText.text.toString()
|
||||
val username = usernameEditText.text.toString().ifBlank { null }
|
||||
val password = passwordEditText.text.toString().ifBlank { null }
|
||||
val trusted = trustedDaemonCheckbox.isChecked
|
||||
|
@ -28,7 +28,7 @@ class NodeSelectionBottomSheetDialog(
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_node_selection, null)
|
||||
return inflater.inflate(R.layout.bottom_sheet_dialog_node_selection, container)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@ -52,6 +52,8 @@ class NodeSelectionBottomSheetDialog(
|
||||
}
|
||||
}
|
||||
|
||||
fun getNodes(): List<Node> = nodes
|
||||
|
||||
fun setNodes(nodes: List<Node>) {
|
||||
this.nodes = nodes
|
||||
adapter.setNodes(nodes)
|
||||
|
@ -11,7 +11,6 @@ import timber.log.Timber
|
||||
|
||||
abstract class NodeSelectionDialogListenerAdapter(
|
||||
private val activity: FragmentActivity,
|
||||
private var nodes: List<Node>,
|
||||
) : NodeSelectionBottomSheetDialog.NodeSelectionDialogListener {
|
||||
|
||||
abstract fun trySelectNode(self: NodeSelectionBottomSheetDialog, node: Node): Boolean
|
||||
@ -23,13 +22,15 @@ abstract class NodeSelectionDialogListenerAdapter(
|
||||
}
|
||||
|
||||
final override fun onEditNode(self: NodeSelectionBottomSheetDialog, node: Node) {
|
||||
val nodeSelectionBottomSheetDialog = self
|
||||
val listener = object : EditNodeBottomSheetDialog.EditNodeListener {
|
||||
override fun onDeleteNode(self: EditNodeBottomSheetDialog, node: Node) {
|
||||
val newNodes = nodes.toMutableList()
|
||||
val newNodes = nodeSelectionBottomSheetDialog.getNodes().toMutableList()
|
||||
newNodes.remove(node)
|
||||
PreferenceUtils.setNodes(activity, newNodes).fold(
|
||||
{
|
||||
Toast.makeText(activity, "Node delete", Toast.LENGTH_SHORT).show()
|
||||
nodeSelectionBottomSheetDialog.setNodes(newNodes)
|
||||
self.dismiss()
|
||||
},
|
||||
{
|
||||
@ -44,10 +45,11 @@ abstract class NodeSelectionDialogListenerAdapter(
|
||||
oldNode: Node,
|
||||
newNode: Node,
|
||||
) {
|
||||
val newNodes = nodes.map { node -> if (node != oldNode) node else newNode }
|
||||
val newNodes = nodeSelectionBottomSheetDialog.getNodes().map { node -> if (node != oldNode) node else newNode }
|
||||
PreferenceUtils.setNodes(activity, newNodes).fold(
|
||||
{
|
||||
Toast.makeText(activity, "Node saved", Toast.LENGTH_SHORT).show()
|
||||
nodeSelectionBottomSheetDialog.setNodes(newNodes)
|
||||
self.dismiss()
|
||||
},
|
||||
{
|
||||
@ -67,6 +69,7 @@ abstract class NodeSelectionDialogListenerAdapter(
|
||||
val nodeSelectionBottomSheetDialog = self
|
||||
val addNodeDialog = AddNodeBottomSheetDialog(object : AddNodeBottomSheetDialog.AddNodeListener {
|
||||
override fun onAddNode(self: AddNodeBottomSheetDialog, node: Node) {
|
||||
val nodes = nodeSelectionBottomSheetDialog.getNodes()
|
||||
if (nodes.any { it.name == node.name }) {
|
||||
Timber.i("Failed to add nodes due to node with the same name already existing")
|
||||
Toast.makeText(activity, "Node with this name already exists", Toast.LENGTH_SHORT).show()
|
||||
@ -75,8 +78,8 @@ abstract class NodeSelectionDialogListenerAdapter(
|
||||
newNodes.add(node)
|
||||
PreferenceUtils.setNodes(activity, newNodes).fold(
|
||||
{
|
||||
nodeSelectionBottomSheetDialog.setNodes(newNodes)
|
||||
Timber.i("New node ${node.name} added successfully")
|
||||
nodeSelectionBottomSheetDialog.setNodes(newNodes)
|
||||
Toast.makeText(activity, "Node added", Toast.LENGTH_SHORT).show()
|
||||
self.dismiss()
|
||||
},
|
||||
|
@ -208,6 +208,8 @@ class WalletService : Service(), WalletListener, DefaultLifecycleObserver {
|
||||
val newHeight = org.monfluo.wallet.model.WalletManager.instance.getBlockchainHeight()
|
||||
if (newHeight > 0) {
|
||||
daemonHeight.set(newHeight)
|
||||
} else {
|
||||
Timber.w("Fetched blockchain height is 0")
|
||||
}
|
||||
forEachObserver {
|
||||
it.onBlockchainHeightFetched(newHeight)
|
||||
|
Loading…
Reference in New Issue
Block a user