-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from MrStahlfelge/workbranch
P2S, configurable API urls, Telegram help group, version bump
- Loading branch information
Showing
11 changed files
with
256 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
66 changes: 66 additions & 0 deletions
66
app/src/main/java/org/ergoplatform/android/settings/ConnectionSettingsDialogFragment.kt
This file contains 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,66 @@ | ||
package org.ergoplatform.android.settings | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import org.ergoplatform.android.* | ||
import org.ergoplatform.android.databinding.FragmentConnectionSettingsBinding | ||
|
||
/** | ||
* | ||
* Shows connection settings for Explorer API URL and Node URL | ||
*/ | ||
class ConnectionSettingsDialogFragment : BottomSheetDialogFragment() { | ||
|
||
private var _binding: FragmentConnectionSettingsBinding? = null | ||
|
||
// This property is only valid between onCreateView and | ||
// onDestroyView. | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
|
||
_binding = FragmentConnectionSettingsBinding.inflate(inflater, container, false) | ||
return binding.root | ||
|
||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.editNodeUrl.editText?.setText(getPrefNodeUrl(requireContext())) | ||
binding.editExplorerApiUrl.editText?.setText(getPrefExplorerApiUrl(requireContext())) | ||
binding.buttonApply.setOnClickListener { buttonApply() } | ||
binding.editNodeUrl.editText?.setOnEditorActionListener { _, _, _ -> | ||
buttonApply() | ||
true | ||
} | ||
binding.buttonDefaults.setOnClickListener { | ||
binding.editNodeUrl.editText?.setText(StageConstants.NODE_API_ADDRESS) | ||
binding.editExplorerApiUrl.editText?.setText(StageConstants.EXPLORER_API_ADDRESS) | ||
} | ||
} | ||
|
||
private fun buttonApply() { | ||
val nodeUrl = binding.editNodeUrl.editText?.text?.toString() ?: "" | ||
val explorerApiUrl = binding.editExplorerApiUrl.editText?.text?.toString() ?: "" | ||
|
||
saveExplorerApiUrl(requireContext(), explorerApiUrl) | ||
saveNodeUrl(requireContext(), nodeUrl) | ||
|
||
// reset api service of NodeConnector to load new settings | ||
NodeConnector.getInstance().resetApiService() | ||
|
||
dismiss() | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
This file contains 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 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 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 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,79 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
tools:background="?attr/colorSurface"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/activity_vertical_margin" | ||
android:orientation="vertical" | ||
tools:ignore="UselessParent"> | ||
|
||
<TextView | ||
style="@style/TextAppearance.App.Body1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="@dimen/activity_vertical_margin" | ||
android:text="@string/button_connection_settings" /> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/edit_explorer_api_url" | ||
style="@style/Widget.App.TextInputLayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="@dimen/activity_vertical_margin" | ||
android:hint="@string/label_explorer_api_url"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:imeOptions="actionNext" | ||
android:inputType="textUri" | ||
android:maxLines="1" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/edit_node_url" | ||
style="@style/Widget.App.TextInputLayout" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="@dimen/activity_vertical_margin" | ||
android:hint="@string/label_node_url"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:imeOptions="actionDone" | ||
android:inputType="textUri" | ||
android:maxLines="1" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end"> | ||
|
||
<Button | ||
android:id="@+id/button_defaults" | ||
style="@style/Widget.App.Button.PrimaryTint" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginEnd="@dimen/margin_and_half" | ||
android:elegantTextHeight="true" | ||
android:text="@string/button_reset_defaults" /> | ||
|
||
<Button | ||
android:id="@+id/button_apply" | ||
style="@style/Widget.App.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:elegantTextHeight="true" | ||
android:text="@string/button_apply" /> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</FrameLayout> |
Oops, something went wrong.