mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Swapped locator alert dialog for a dedicated dialog fragment
This commit is contained in:
1 parent
6400d1d395
commit
9d6dbc8d31
4 files changed
+148
-14
No files matched your search
@@ -0,0 +1,42 @@
|
||||
package com.rtbishop.look4sat.presentation.settingsScreen
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.appcompat.app.AppCompatDialogFragment
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.data.ISettingsHandler
|
||||
import com.rtbishop.look4sat.databinding.DialogLocatorBinding
|
||||
import com.rtbishop.look4sat.presentation.setNavResult
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class LocatorDialog : AppCompatDialogFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: ISettingsHandler
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, group: ViewGroup?, state: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.dialog_locator, group, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, state: Bundle?) {
|
||||
super.onViewCreated(view, state)
|
||||
DialogLocatorBinding.bind(view).run {
|
||||
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
|
||||
dialog?.window?.setLayout(
|
||||
(resources.displayMetrics.widthPixels * 0.94).toInt(),
|
||||
WindowManager.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
// locatorEdit.setText(preferences.getQthLocator())
|
||||
locatorPosBtn.setOnClickListener {
|
||||
setNavResult("locator", locatorEdit.text.toString())
|
||||
dismiss()
|
||||
}
|
||||
locatorNegBtn.setOnClickListener { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-14
@@ -23,10 +23,8 @@ import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -41,7 +39,6 @@ import com.rtbishop.look4sat.domain.predict.GeoPos
|
||||
import com.rtbishop.look4sat.presentation.getNavResult
|
||||
import com.rtbishop.look4sat.presentation.isValidIPv4
|
||||
import com.rtbishop.look4sat.presentation.isValidPort
|
||||
import com.rtbishop.look4sat.presentation.setEditText
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -115,17 +112,11 @@ class SettingsFragment : Fragment(R.layout.fragment_settings) {
|
||||
locationRequest.launch(arrayOf(locationFine, locationCoarse))
|
||||
}
|
||||
binding.settingsLocation.locationBtnQth.setOnClickListener {
|
||||
val editText = EditText(requireActivity())
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setTitle("Title")
|
||||
.setEditText(editText)
|
||||
.setPositiveButton("OK") { _, _ ->
|
||||
val editTextInput = editText.text.toString()
|
||||
viewModel.setPositionFromQth(editTextInput)
|
||||
}
|
||||
.setNeutralButton("Cancel", null)
|
||||
.create()
|
||||
.show()
|
||||
val action = SettingsFragmentDirections.actionPrefsToLocator()
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
getNavResult<String>(R.id.nav_settings, "locator") { locator ->
|
||||
viewModel.setPositionFromQth(locator)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/SurfaceCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locator_title"
|
||||
style="@style/DialogTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:minHeight="48dp"
|
||||
android:text="@string/dialog_filter_passes"
|
||||
app:layout_constraintBottom_toTopOf="@+id/locator_text"
|
||||
app:layout_constraintEnd_toEndOf="@+id/locator_pos_btn"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/locator_neg_btn"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/locator_text"
|
||||
style="@style/DialogText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="@string/pref_hours_ahead_summary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/locator_layout"
|
||||
app:layout_constraintEnd_toEndOf="@+id/locator_title"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/locator_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/locator_title" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/locator_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/pref_hours_ahead_hint"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="number"
|
||||
android:minHeight="48dp"
|
||||
app:endIconMode="clear_text"
|
||||
app:layout_constraintBottom_toTopOf="@+id/locator_neg_btn"
|
||||
app:layout_constraintEnd_toEndOf="@+id/locator_text"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="@+id/locator_text"
|
||||
app:layout_constraintTop_toBottomOf="@+id/locator_text">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/locator_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="textUri" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/locator_neg_btn"
|
||||
style="@style/NormalButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/btn_cancel"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/locator_pos_btn"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/locator_layout" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/locator_pos_btn"
|
||||
style="@style/NormalButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:text="@string/btn_accept"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/locator_neg_btn"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/locator_neg_btn" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -53,6 +53,9 @@
|
||||
<action
|
||||
android:id="@+id/action_prefs_to_sources"
|
||||
app:destination="@id/nav_sources" />
|
||||
<action
|
||||
android:id="@+id/action_prefs_to_locator"
|
||||
app:destination="@id/nav_locator" />
|
||||
</fragment>
|
||||
<dialog
|
||||
android:id="@+id/nav_sources"
|
||||
@@ -62,6 +65,10 @@
|
||||
android:id="@+id/nav_modes"
|
||||
android:name="com.rtbishop.look4sat.presentation.entriesScreen.ModesDialog"
|
||||
tools:layout="@layout/dialog_modes" />
|
||||
<dialog
|
||||
android:id="@+id/nav_locator"
|
||||
android:name="com.rtbishop.look4sat.presentation.settingsScreen.LocatorDialog"
|
||||
tools:layout="@layout/dialog_locator" />
|
||||
<action
|
||||
android:id="@+id/action_global_entriesFragment"
|
||||
app:destination="@id/nav_entries" />
|
||||
|
||||
Reference in new issue
Block a user