New menu, organizing settings to its separate categories
This commit is contained in:
parent
cba93c6069
commit
663463cd38
12 changed files with 398 additions and 246 deletions
|
@ -0,0 +1,12 @@
|
|||
package partisan.weforge.xyz.pulse
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class AboutActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// placeholder until real UI is added
|
||||
setContentView(androidx.appcompat.R.layout.abc_action_bar_title_item)
|
||||
}
|
||||
}
|
|
@ -1,161 +1,63 @@
|
|||
package partisan.weforge.xyz.pulse
|
||||
|
||||
import android.Manifest
|
||||
import android.app.role.RoleManager
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import java.lang.NumberFormatException
|
||||
import android.text.InputType
|
||||
import android.widget.CheckBox
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import partisan.weforge.xyz.pulse.getServicePriority
|
||||
import partisan.weforge.xyz.pulse.setServicePriority
|
||||
import partisan.weforge.xyz.pulse.isServiceEnabled
|
||||
import partisan.weforge.xyz.pulse.setServiceEnabled
|
||||
import partisan.weforge.xyz.pulse.databinding.ActivityMainBinding
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle
|
||||
import partisan.weforge.xyz.pulse.REQUIRED_PERMISSIONS
|
||||
import partisan.weforge.xyz.pulse.hasCallRedirectionRole
|
||||
import partisan.weforge.xyz.pulse.hasDrawOverlays
|
||||
import partisan.weforge.xyz.pulse.hasGeneralPermissions
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
private lateinit var prefs: Preferences
|
||||
private lateinit var window: PopupWindow
|
||||
private var roleManager: RoleManager? = null
|
||||
|
||||
private val registerForCallRedirectionRole =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {}
|
||||
|
||||
private val registerForGeneralPermissions =
|
||||
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {}
|
||||
|
||||
private val registerForDrawOverlays =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
init()
|
||||
setup()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
window.cancel()
|
||||
}
|
||||
setSupportActionBar(binding.topAppBar)
|
||||
|
||||
private fun init() {
|
||||
prefs = Preferences(this)
|
||||
window = PopupWindow(this, null)
|
||||
roleManager = getSystemService(RoleManager::class.java)
|
||||
binding.apply {
|
||||
redirectionDelay.value = (prefs.redirectionDelay / 1000).toFloat()
|
||||
popupPosition.editText?.setText(prefs.popupPosition.toString())
|
||||
toggle.isChecked = prefs.isEnabled
|
||||
}
|
||||
}
|
||||
|
||||
private fun setup() {
|
||||
binding.apply {
|
||||
redirectionDelay.setLabelFormatter {
|
||||
String.format("%.1f", it)
|
||||
}
|
||||
redirectionDelay.addOnChangeListener { _, value, _ ->
|
||||
prefs.redirectionDelay = (value * 1000).toLong()
|
||||
}
|
||||
popupPosition.setEndIconOnClickListener {
|
||||
window.preview()
|
||||
}
|
||||
popupPosition.editText?.doAfterTextChanged {
|
||||
try {
|
||||
prefs.popupPosition = it?.toString()?.toInt() ?: return@doAfterTextChanged
|
||||
} catch (exc: NumberFormatException) {}
|
||||
}
|
||||
toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked && !hasPermissions()) {
|
||||
toggle.isChecked = false
|
||||
requestPermissions()
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
prefs.isEnabled = isChecked
|
||||
}
|
||||
val services = listOf(
|
||||
ServiceEntry("vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call", R.string.destination_signal, this@MainActivity.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, this@MainActivity.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, this@MainActivity.isServiceEnabled("vnd.android.cursor.item/vnd.ch.threema.app.call")),
|
||||
ServiceEntry("vnd.android.cursor.item/vnd.com.whatsapp.voip.call", R.string.destination_whatsapp, this@MainActivity.isServiceEnabled("vnd.android.cursor.item/vnd.com.whatsapp.voip.call")),
|
||||
val drawerToggle = ActionBarDrawerToggle(
|
||||
this,
|
||||
binding.drawerLayout,
|
||||
binding.topAppBar,
|
||||
R.string.navigation_drawer_open,
|
||||
R.string.navigation_drawer_close
|
||||
)
|
||||
binding.drawerLayout.addDrawerListener(drawerToggle)
|
||||
drawerToggle.syncState()
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, MainFragment())
|
||||
.commit()
|
||||
|
||||
val adapter = ServiceAdapter(
|
||||
context = this@MainActivity,
|
||||
services = services.toMutableList(),
|
||||
onReordered = { updatedList ->
|
||||
updatedList.forEachIndexed { index, entry ->
|
||||
setServicePriority(entry.mimetype, index)
|
||||
binding.navigationView.setNavigationItemSelectedListener { item ->
|
||||
when (item.itemId) {
|
||||
R.id.action_popup_settings -> {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, PopupSettingsFragment())
|
||||
.commit()
|
||||
true
|
||||
}
|
||||
R.id.action_settings -> {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
true
|
||||
}
|
||||
)
|
||||
binding.serviceRecycler.adapter = adapter
|
||||
binding.serviceRecycler.layoutManager = LinearLayoutManager(this@MainActivity)
|
||||
|
||||
val touchHelper = ItemTouchHelper(adapter.dragHelper)
|
||||
touchHelper.attachToRecyclerView(binding.serviceRecycler)
|
||||
|
||||
adapter.setDragStartListener { viewHolder ->
|
||||
touchHelper.startDrag(viewHolder)
|
||||
R.id.action_about -> {
|
||||
startActivity(Intent(this, AboutActivity::class.java))
|
||||
true
|
||||
}
|
||||
|
||||
// binding.serviceConfigList.removeAllViews()
|
||||
// for ((mimetype, labelRes) in mimetypes) {
|
||||
// val checkbox = CheckBox(this@MainActivity).apply {
|
||||
// text = getString(labelRes)
|
||||
// isChecked = this@MainActivity.isServiceEnabled(mimetype)
|
||||
// setOnCheckedChangeListener { _, checked ->
|
||||
// this@MainActivity.setServiceEnabled(mimetype, checked)
|
||||
// }
|
||||
// }
|
||||
|
||||
// val priorityInput = EditText(this@MainActivity).apply {
|
||||
// inputType = InputType.TYPE_CLASS_NUMBER
|
||||
// setEms(4)
|
||||
// hint = "Priority"
|
||||
// setText(this@MainActivity.getServicePriority(mimetype).toString())
|
||||
// setOnFocusChangeListener { _, hasFocus ->
|
||||
// if (!hasFocus) {
|
||||
// val value = text.toString().toIntOrNull()
|
||||
// if (value != null) this@MainActivity.setServicePriority(mimetype, value)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// val row = LinearLayout(this@MainActivity).apply {
|
||||
// orientation = LinearLayout.HORIZONTAL
|
||||
// setPadding(0, 16, 0, 16)
|
||||
// addView(checkbox, LinearLayout.LayoutParams(0, WRAP_CONTENT, 1f))
|
||||
// addView(priorityInput, LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT))
|
||||
// }
|
||||
|
||||
// binding.serviceConfigList.addView(row)
|
||||
// }
|
||||
else -> false
|
||||
}.also {
|
||||
binding.drawerLayout.closeDrawers()
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestPermissions() {
|
||||
when {
|
||||
!hasGeneralPermissions(this) -> registerForGeneralPermissions.launch(REQUIRED_PERMISSIONS)
|
||||
!hasDrawOverlays() -> requestDrawOverlays()
|
||||
!hasCallRedirectionRole() -> requestCallRedirectionRole()
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasPermissions(): Boolean {
|
||||
|
@ -163,21 +65,4 @@ class MainActivity : AppCompatActivity() {
|
|||
hasDrawOverlays(this) &&
|
||||
hasCallRedirectionRole(this)
|
||||
}
|
||||
|
||||
private fun requestDrawOverlays() {
|
||||
registerForDrawOverlays.launch(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION))
|
||||
}
|
||||
|
||||
private fun hasDrawOverlays(): Boolean {
|
||||
return Settings.canDrawOverlays(this)
|
||||
}
|
||||
|
||||
private fun requestCallRedirectionRole() {
|
||||
registerForCallRedirectionRole
|
||||
.launch(roleManager?.createRequestRoleIntent(RoleManager.ROLE_CALL_REDIRECTION))
|
||||
}
|
||||
|
||||
private fun hasCallRedirectionRole(): Boolean {
|
||||
return roleManager?.isRoleHeld(RoleManager.ROLE_CALL_REDIRECTION) ?: false
|
||||
}
|
||||
}
|
||||
|
|
29
app/src/main/java/partisan/weforge/xyz/pulse/MainFragment.kt
Normal file
29
app/src/main/java/partisan/weforge/xyz/pulse/MainFragment.kt
Normal file
|
@ -0,0 +1,29 @@
|
|||
package partisan.weforge.xyz.pulse
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ToggleButton
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class MainFragment : Fragment() {
|
||||
|
||||
private lateinit var prefs: Preferences
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val view = inflater.inflate(R.layout.fragment_main, container, false)
|
||||
prefs = Preferences(requireContext())
|
||||
|
||||
val toggle = view.findViewById<ToggleButton>(R.id.toggle)
|
||||
toggle.isChecked = prefs.isEnabled
|
||||
toggle.setOnCheckedChangeListener { _, isChecked ->
|
||||
prefs.isEnabled = isChecked
|
||||
}
|
||||
|
||||
return view
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package partisan.weforge.xyz.pulse
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
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.FragmentPopupSettingsBinding
|
||||
|
||||
class PopupSettingsFragment : Fragment() {
|
||||
|
||||
private var _binding: FragmentPopupSettingsBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private lateinit var prefs: Preferences
|
||||
private lateinit var window: PopupWindow
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentPopupSettingsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
prefs = Preferences(requireContext())
|
||||
window = PopupWindow(requireContext(), null)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
serviceRecycler.adapter = adapter
|
||||
serviceRecycler.layoutManager = LinearLayoutManager(requireContext())
|
||||
|
||||
val touchHelper = ItemTouchHelper(adapter.dragHelper)
|
||||
touchHelper.attachToRecyclerView(serviceRecycler)
|
||||
|
||||
adapter.setDragStartListener { viewHolder ->
|
||||
touchHelper.startDrag(viewHolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getScreenHeightPx(): Int {
|
||||
val metrics = DisplayMetrics()
|
||||
requireActivity().windowManager.defaultDisplay.getMetrics(metrics)
|
||||
return metrics.heightPixels
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
}
|
|
@ -13,8 +13,9 @@ class Preferences(ctx: Context) {
|
|||
private const val DEFAULT_REDIRECTION_DELAY = 2000L
|
||||
private const val DEFAULT_POPUP_POSITION = 333
|
||||
|
||||
// migration
|
||||
private const val SERVICE_ENABLED = "service_enabled"
|
||||
|
||||
private const val POPUP_ENABLED = "popup_enabled"
|
||||
}
|
||||
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
|
@ -23,6 +24,10 @@ class Preferences(ctx: Context) {
|
|||
get() = prefs.getBoolean(ENABLED, prefs.getBoolean(SERVICE_ENABLED, false))
|
||||
set(value) = prefs.edit { putBoolean(ENABLED, value) }
|
||||
|
||||
var popupEnabled: Boolean
|
||||
get() = prefs.getBoolean(POPUP_ENABLED, true)
|
||||
set(value) = prefs.edit { putBoolean(POPUP_ENABLED, value) }
|
||||
|
||||
var redirectionDelay: Long
|
||||
get() = prefs.getLong(REDIRECTION_DELAY, DEFAULT_REDIRECTION_DELAY)
|
||||
set(value) = prefs.edit { putLong(REDIRECTION_DELAY, value) }
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package partisan.weforge.xyz.pulse
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// placeholder until real UI is added
|
||||
setContentView(androidx.appcompat.R.layout.abc_action_bar_title_item)
|
||||
}
|
||||
}
|
10
app/src/main/res/drawable/tooltip_24px.xml
Normal file
10
app/src/main/res/drawable/tooltip_24px.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,880L373,720L160,720Q127,720 103.5,696.5Q80,673 80,640L80,160Q80,127 103.5,103.5Q127,80 160,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,640Q880,673 856.5,696.5Q833,720 800,720L587,720L480,880ZM480,736L544,640L800,640Q800,640 800,640Q800,640 800,640L800,160Q800,160 800,160Q800,160 800,160L160,160Q160,160 160,160Q160,160 160,160L160,640Q160,640 160,640Q160,640 160,640L416,640L480,736ZM480,400L480,400L480,400Q480,400 480,400Q480,400 480,400L480,400Q480,400 480,400Q480,400 480,400L480,400Q480,400 480,400Q480,400 480,400L480,400Q480,400 480,400Q480,400 480,400L480,400Z"/>
|
||||
</vector>
|
|
@ -1,100 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<androidx.drawerlayout.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="32dp"
|
||||
tools:context=".MainActivity">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
<!-- Main content -->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/topAppBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/description"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorSurface"
|
||||
app:titleTextColor="?attr/colorOnSurface"
|
||||
app:navigationIconTint="?attr/colorOnSurface"
|
||||
app:title="@string/app_name"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
<FrameLayout
|
||||
android:id="@+id/fragmentContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:padding="16dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/description"
|
||||
app:layout_constraintBottom_toTopOf="@id/toggle"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/redirectionDelay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stepSize="0.5"
|
||||
android:valueFrom="2"
|
||||
android:valueTo="4"
|
||||
android:contentDescription="@string/redirection_delay_description" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/redirection_delay_description"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="8dp" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/popupPosition"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:endIconMode="custom"
|
||||
app:endIconDrawable="@drawable/ic_baseline_check_circle_24"
|
||||
android:hint="@string/popup_position">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="8dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/serviceRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:scrollbars="vertical" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/toggle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingVertical="12dp"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintTop_toBottomOf="@id/topAppBar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- Sliding menu -->
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
android:id="@+id/navigationView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:menu="@menu/main_menu" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
||||
|
|
12
app/src/main/res/layout/fragment_main.xml
Normal file
12
app/src/main/res/layout/fragment_main.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/toggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp" />
|
||||
</FrameLayout>
|
107
app/src/main/res/layout/fragment_popup_settings.xml
Normal file
107
app/src/main/res/layout/fragment_popup_settings.xml
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="32dp"
|
||||
tools:context=".PopupSettingsFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/popup_settings_description"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/popupEnabledCheckbox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/popup_enabled"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/description"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/popupPreview" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/popupPreview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/test"
|
||||
app:layout_constraintTop_toTopOf="@id/popupEnabledCheckbox"
|
||||
app:layout_constraintBottom_toBottomOf="@id/popupEnabledCheckbox"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginStart="8dp" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/popupEnabledCheckbox"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/redirectionDelay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stepSize="0.5"
|
||||
android:valueFrom="2"
|
||||
android:valueTo="4"
|
||||
android:layout_marginTop="8dp"
|
||||
android:contentDescription="@string/redirection_delay_description" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delayDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/redirection_delay_description"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/popupHeightSlider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:valueFrom="0"
|
||||
android:valueTo="100"
|
||||
android:stepSize="1"
|
||||
android:layout_marginTop="16dp"
|
||||
android:contentDescription="@string/popup_position" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/heightDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/popup_position"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/serviceRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_marginTop="8dp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
14
app/src/main/res/menu/main_menu.xml
Normal file
14
app/src/main/res/menu/main_menu.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:title="Settings" />
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:title="About" />
|
||||
<item
|
||||
android:id="@+id/action_popup_settings"
|
||||
android:title="Popup Settings"
|
||||
android:icon="@drawable/tooltip_24px"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
|
@ -12,4 +12,9 @@
|
|||
<string name="fallback">Fallback</string>
|
||||
<string name="activate_description">To start, grant the required permissions and tap the Activate button.</string>
|
||||
<string name="activate">Activate</string>
|
||||
<string name="navigation_drawer_open">Open menu</string>
|
||||
<string name="navigation_drawer_close">Close menu</string>
|
||||
<string name="popup_settings_description">Configure popup behavior, position, and delay.</string>
|
||||
<string name="popup_enabled">Popup enabled</string>
|
||||
<string name="test">Test</string>
|
||||
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue