diff --git a/app/src/main/java/partisan/weforge/xyz/pulse/MainActivity.kt b/app/src/main/java/partisan/weforge/xyz/pulse/MainActivity.kt
index 10d060c..91749d7 100644
--- a/app/src/main/java/partisan/weforge/xyz/pulse/MainActivity.kt
+++ b/app/src/main/java/partisan/weforge/xyz/pulse/MainActivity.kt
@@ -54,6 +54,13 @@ class MainActivity : AppCompatActivity() {
.commit()
true
}
+ R.id.action_services -> {
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.fragmentContainer, ServiceSettingsFragment())
+ .addToBackStack(null)
+ .commit()
+ true
+ }
R.id.action_contacts -> {
supportFragmentManager.beginTransaction()
.replace(R.id.fragmentContainer, ContactsFragment())
diff --git a/app/src/main/java/partisan/weforge/xyz/pulse/PopupSettingsFragment.kt b/app/src/main/java/partisan/weforge/xyz/pulse/PopupSettingsFragment.kt
index 9c084af..ac4b0f4 100644
--- a/app/src/main/java/partisan/weforge/xyz/pulse/PopupSettingsFragment.kt
+++ b/app/src/main/java/partisan/weforge/xyz/pulse/PopupSettingsFragment.kt
@@ -30,78 +30,47 @@ class PopupSettingsFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
- prefs = Preferences(requireContext())
- window = PopupWindow(requireContext(), null)
+ val services = listOf(
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call",
+ R.string.destination_signal,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.org.telegram.messenger.android.call",
+ R.string.destination_telegram,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.telegram.messenger.android.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.ch.threema.app.call",
+ R.string.destination_threema,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.ch.threema.app.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.com.whatsapp.voip.call",
+ R.string.destination_whatsapp,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.com.whatsapp.voip.call")
+ ),
+ )
- val screenHeight = getScreenHeightPx()
-
- binding.apply {
- redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
- redirectionDelay.setLabelFormatter {
- String.format("%.1f", it)
- }
- redirectionDelay.addOnChangeListener { _, value, _ ->
- prefs.redirectionDelay = (value * 1000).toLong()
- }
-
- popupEnabledCheckbox.isChecked = prefs.popupEnabled
- popupEnabledCheckbox.setOnCheckedChangeListener { _, isChecked ->
- prefs.popupEnabled = isChecked
- }
-
- popupPreview.setOnClickListener {
- window.preview()
- }
-
- popupHeightSlider.valueFrom = 0f
- popupHeightSlider.valueTo = screenHeight.toFloat()
- popupHeightSlider.value = prefs.popupPosition.toFloat()
- popupHeightSlider.addOnChangeListener { _, value, _ ->
- prefs.popupPosition = value.toInt().coerceIn(0, screenHeight)
- }
-
- val services = listOf(
- ServiceEntry(
- "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call",
- R.string.destination_signal,
- requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call")
- ),
- ServiceEntry(
- "vnd.android.cursor.item/vnd.org.telegram.messenger.android.call",
- R.string.destination_telegram,
- requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.telegram.messenger.android.call")
- ),
- ServiceEntry(
- "vnd.android.cursor.item/vnd.ch.threema.app.call",
- R.string.destination_threema,
- requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.ch.threema.app.call")
- ),
- ServiceEntry(
- "vnd.android.cursor.item/vnd.com.whatsapp.voip.call",
- R.string.destination_whatsapp,
- requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.com.whatsapp.voip.call")
- ),
- )
-
- val adapter = ServiceAdapter(
- context = requireContext(),
- services = services.toMutableList(),
- onReordered = { updatedList ->
- updatedList.forEachIndexed { index, entry ->
- requireContext().setServicePriority(entry.mimetype, index)
- }
+ val adapter = ServiceAdapter(
+ context = requireContext(),
+ services = services.toMutableList(),
+ onReordered = { updatedList ->
+ updatedList.forEachIndexed { index, entry ->
+ requireContext().setServicePriority(entry.mimetype, index)
}
- )
-
- serviceRecycler.adapter = adapter
- serviceRecycler.layoutManager = LinearLayoutManager(requireContext())
-
- val touchHelper = ItemTouchHelper(adapter.dragHelper)
- touchHelper.attachToRecyclerView(serviceRecycler)
-
- adapter.setDragStartListener { viewHolder ->
- touchHelper.startDrag(viewHolder)
}
+ )
+
+ binding.serviceRecycler.adapter = adapter
+ binding.serviceRecycler.layoutManager = LinearLayoutManager(requireContext())
+
+ val touchHelper = ItemTouchHelper(adapter.dragHelper)
+ touchHelper.attachToRecyclerView(binding.serviceRecycler)
+
+ adapter.setDragStartListener { viewHolder ->
+ touchHelper.startDrag(viewHolder)
}
}
diff --git a/app/src/main/java/partisan/weforge/xyz/pulse/ServicesFragment.kt b/app/src/main/java/partisan/weforge/xyz/pulse/ServicesFragment.kt
new file mode 100644
index 0000000..104ceeb
--- /dev/null
+++ b/app/src/main/java/partisan/weforge/xyz/pulse/ServicesFragment.kt
@@ -0,0 +1,77 @@
+package partisan.weforge.xyz.pulse
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import androidx.recyclerview.widget.ItemTouchHelper
+import androidx.recyclerview.widget.LinearLayoutManager
+import partisan.weforge.xyz.pulse.databinding.FragmentServiceSettingsBinding
+
+class ServiceSettingsFragment : Fragment() {
+
+ private var _binding: FragmentServiceSettingsBinding? = null
+ private val binding get() = _binding!!
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View {
+ _binding = FragmentServiceSettingsBinding.inflate(inflater, container, false)
+ return binding.root
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ super.onViewCreated(view, savedInstanceState)
+
+ val services = listOf(
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call",
+ R.string.destination_signal,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.org.telegram.messenger.android.call",
+ R.string.destination_telegram,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.org.telegram.messenger.android.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.ch.threema.app.call",
+ R.string.destination_threema,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.ch.threema.app.call")
+ ),
+ ServiceEntry(
+ "vnd.android.cursor.item/vnd.com.whatsapp.voip.call",
+ R.string.destination_whatsapp,
+ requireContext().isServiceEnabled("vnd.android.cursor.item/vnd.com.whatsapp.voip.call")
+ ),
+ )
+
+ val adapter = ServiceAdapter(
+ context = requireContext(),
+ services = services.toMutableList(),
+ onReordered = { updatedList ->
+ updatedList.forEachIndexed { index, entry ->
+ requireContext().setServicePriority(entry.mimetype, index)
+ }
+ }
+ )
+
+ binding.serviceRecycler.adapter = adapter
+ binding.serviceRecycler.layoutManager = LinearLayoutManager(requireContext())
+
+ val touchHelper = ItemTouchHelper(adapter.dragHelper)
+ touchHelper.attachToRecyclerView(binding.serviceRecycler)
+
+ adapter.setDragStartListener { viewHolder ->
+ touchHelper.startDrag(viewHolder)
+ }
+ }
+
+ override fun onDestroyView() {
+ super.onDestroyView()
+ _binding = null
+ }
+}
diff --git a/app/src/main/res/drawable/heart_24.xml b/app/src/main/res/drawable/heart_24.xml
new file mode 100644
index 0000000..3edfe1d
--- /dev/null
+++ b/app/src/main/res/drawable/heart_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/services_24.xml b/app/src/main/res/drawable/services_24.xml
new file mode 100644
index 0000000..5bbe6bf
--- /dev/null
+++ b/app/src/main/res/drawable/services_24.xml
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/settings_24.xml b/app/src/main/res/drawable/settings_24.xml
new file mode 100644
index 0000000..41a82ed
--- /dev/null
+++ b/app/src/main/res/drawable/settings_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/fragment_popup_settings.xml b/app/src/main/res/layout/fragment_popup_settings.xml
index c9cec7c..2afe2ae 100644
--- a/app/src/main/res/layout/fragment_popup_settings.xml
+++ b/app/src/main/res/layout/fragment_popup_settings.xml
@@ -20,88 +20,70 @@
+ app:layout_constraintEnd_toEndOf="parent" />
-
-
+ app:layout_constraintEnd_toEndOf="parent" />
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
+
diff --git a/app/src/main/res/layout/fragment_service_settings.xml b/app/src/main/res/layout/fragment_service_settings.xml
new file mode 100644
index 0000000..a5dce49
--- /dev/null
+++ b/app/src/main/res/layout/fragment_service_settings.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml
index b8a1808..8cd0dd4 100644
--- a/app/src/main/res/menu/main_menu.xml
+++ b/app/src/main/res/menu/main_menu.xml
@@ -6,16 +6,21 @@
android:id="@+id/section_settings"
android:title="Settings"
android:enabled="false" />
-
+
+
- Popup position
Fallback
To start, grant the required permissions by tapping the Activate button.
+ Service Preferences
Activate
Open menu
Close menu