Skip to content

Satellite tracker and pass predictor for Android, inspired by Gpredict

Add notification button and dialog on Radar Fragment

Kamil Wargula5c5f08afc0c7
diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt
index 040a54ff..df90d1b4 100644
--- a/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt
+++ b/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt
@@ -19,11 +19,13 @@ package com.rtbishop.look4sat.presentation.radarScreen
import android.os.Bundle
import android.view.View
+import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.SimpleItemAnimator
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.rtbishop.look4sat.R
import com.rtbishop.look4sat.databinding.FragmentRadarBinding
import com.rtbishop.look4sat.framework.PreferencesSource
@@ -105,6 +107,30 @@ class RadarFragment : Fragment(R.layout.fragment_radar) {
)
})
}
+
+ binding.addNotificationButtton.setOnClickListener {
+ this.context?.let { context ->
+
+ val choicesList = arrayOf(
+ getString(R.string.notification_on_start_pass),
+ getString(R.string.notification_5_min_before),
+ getString(R.string.notification_10_min_before),
+ getString(R.string.notification_15_min_before),
+ )
+
+ MaterialAlertDialogBuilder(context)
+ .setTitle(getString(R.string.notification_title))
+ .setSingleChoiceItems(choicesList, -1) { dialog, which ->
+ // TODO in this place should set a notification by NotificationBuilder
+ Toast.makeText(context, "Reminder was saved", Toast.LENGTH_SHORT).show()
+ dialog.dismiss()
+ }
+ .setNegativeButton(getString(R.string.btn_cancel)) { _, _ ->
+ // noop
+ }
+ .show()
+ }
+ }
}
private fun setPassText(satPass: SatPass, satPos: SatPos, binding: FragmentRadarBinding) {
diff --git a/app/src/main/res/drawable/ic_notification.xml b/app/src/main/res/drawable/ic_notification.xml
new file mode 100644
index 00000000..3a49fa67
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notification.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@color/themeLight"
+ android:pathData="M21,19V20H3V19L5,17V11C5,7.9 7.03,5.17 10,4.29C10,4.19 10,4.1 10,4A2,2 0 0,1 12,2A2,2 0 0,1 14,4C14,4.1 14,4.19 14,4.29C16.97,5.17 19,7.9 19,11V17L21,19M14,21A2,2 0 0,1 12,23A2,2 0 0,1 10,21" />
+</vector>
diff --git a/app/src/main/res/layout/fragment_radar.xml b/app/src/main/res/layout/fragment_radar.xml
index 92ce4551..95feb21f 100644
--- a/app/src/main/res/layout/fragment_radar.xml
+++ b/app/src/main/res/layout/fragment_radar.xml
@@ -75,6 +75,18 @@
app:layout_constraintBottom_toBottomOf="@+id/radar_frame"
app:layout_constraintEnd_toEndOf="@+id/radar_frame" />
+ <ImageButton
+ android:id="@+id/add_notification_buttton"
+ android:layout_width="64dp"
+ android:layout_height="48dp"
+ android:layout_marginEnd="4dp"
+ android:backgroundTint="@color/greyDark"
+ android:contentDescription="@string/placeholder"
+ android:elevation="4dp"
+ android:src="@drawable/ic_notification"
+ app:layout_constraintEnd_toEndOf="@+id/radar_bar"
+ app:layout_constraintLeft_toLeftOf="parent" />
+
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/radar_recycler"
android:layout_width="0dp"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1d7edf68..88968108 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -14,6 +14,12 @@
<string name="menu_prefs">Settings</string>
<string name="menu_about">Info</string>
+ <string name="notification_title">Set notification to incoming pass</string>
+ <string name="notification_on_start_pass">on start pass</string>
+ <string name="notification_5_min_before">5 minutes before pass</string>
+ <string name="notification_10_min_before">10 minutes before pass</string>
+ <string name="notification_15_min_before">15 minutes before pass</string>
+
<string name="sources_title">Manage TLE sources</string>
<string name="sources_hint">Source URL</string>
<string name="sources_https">Protocol HTTPS only</string>