diff --git a/app/src/main/java/de/westnordost/streetcomplete/Prefs.kt b/app/src/main/java/de/westnordost/streetcomplete/Prefs.kt index c4576d7896..fbf9fb338b 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/Prefs.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/Prefs.kt @@ -79,6 +79,7 @@ object Prefs { const val SHOW_SOLVED_ANIMATION = "show_solved_animation" const val PREFER_EXTERNAL_SD = "prefer_external_sd" const val SHOW_NEXT_QUEST_IMMEDIATELY = "show_next_quest_immediately" + const val MAIN_MENU_FULL_GRID = "main_menu_full_grid" enum class Autosync { ON, WIFI, OFF diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuButtonFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuButtonFragment.kt index 14935fb547..da1f6b0637 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuButtonFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuButtonFragment.kt @@ -1,6 +1,7 @@ package de.westnordost.streetcomplete.screens.main.controls import android.content.Intent +import android.content.SharedPreferences import android.net.ConnectivityManager import android.os.Bundle import android.view.KeyEvent @@ -8,6 +9,7 @@ import android.view.View import androidx.appcompat.app.AlertDialog import androidx.core.content.getSystemService import androidx.fragment.app.Fragment +import de.westnordost.streetcomplete.Prefs import de.westnordost.streetcomplete.R import de.westnordost.streetcomplete.data.download.DownloadController import de.westnordost.streetcomplete.data.osm.mapdata.BoundingBox @@ -28,6 +30,7 @@ class MainMenuButtonFragment : Fragment(R.layout.fragment_main_menu_button) { private val teamModeQuestFilter: TeamModeQuestFilter by inject() private val downloadController: DownloadController by inject() + private val prefs: SharedPreferences by inject() interface Listener { fun getDownloadArea(): BoundingBox? @@ -69,14 +72,24 @@ class MainMenuButtonFragment : Fragment(R.layout.fragment_main_menu_button) { /* ------------------------------------------------------------------------------------------ */ internal fun onClickMainMenu() { - val d = MainMenuDialog( - requireContext(), - if (teamModeQuestFilter.isEnabled) teamModeQuestFilter.indexInTeam else null, - this::onClickDownload, - teamModeQuestFilter::enableTeamMode, - teamModeQuestFilter::disableTeamMode, - this::onClickOverlays, - ) + val d = if (prefs.getBoolean(Prefs.MAIN_MENU_FULL_GRID, false)) + MainMenuGridDialog( + requireContext(), + if (teamModeQuestFilter.isEnabled) teamModeQuestFilter.indexInTeam else null, + this::onClickDownload, + teamModeQuestFilter::enableTeamMode, + teamModeQuestFilter::disableTeamMode, + this::onClickOverlays, + ) + else + MainMenuDialog( + requireContext(), + if (teamModeQuestFilter.isEnabled) teamModeQuestFilter.indexInTeam else null, + this::onClickDownload, + teamModeQuestFilter::enableTeamMode, + teamModeQuestFilter::disableTeamMode, + this::onClickOverlays, + ) d.setOnKeyListener { _, _, keyEvent -> if (keyEvent.keyCode == KeyEvent.KEYCODE_MENU && keyEvent.action == KeyEvent.ACTION_UP) { val intent = Intent(requireContext(), SettingsActivity::class.java) diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuGridDialog.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuGridDialog.kt new file mode 100644 index 0000000000..9446c9efc8 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/controls/MainMenuGridDialog.kt @@ -0,0 +1,74 @@ +package de.westnordost.streetcomplete.screens.main.controls + +import android.content.Context +import android.content.Intent +import android.view.LayoutInflater +import androidx.appcompat.app.AlertDialog +import androidx.core.view.doOnPreDraw +import de.westnordost.streetcomplete.databinding.DialogMainMenuGridBinding +import de.westnordost.streetcomplete.screens.about.AboutActivity +import de.westnordost.streetcomplete.screens.main.teammode.TeamModeDialog +import de.westnordost.streetcomplete.screens.settings.SettingsActivity +import de.westnordost.streetcomplete.screens.user.UserActivity + +/** Shows a dialog containing the main menu items. + * This is an almost exact copy of MainMenuDialog, because the compiler doesn't like being able to select + * the binding on init. */ +class MainMenuGridDialog( + context: Context, + indexInTeam: Int?, + onClickDownload: () -> Unit, + onEnableTeamMode: (Int, Int) -> Unit, + onDisableTeamMode: () -> Unit, + onClickOverlays: () -> Unit, +) : AlertDialog(context) { + init { + val binding = DialogMainMenuGridBinding.inflate(LayoutInflater.from(context)) + + binding.profileButton.setOnClickListener { + val intent = Intent(context, UserActivity::class.java) + context.startActivity(intent) + dismiss() + } + binding.enableTeamModeButton.setOnClickListener { + TeamModeDialog(context, onEnableTeamMode).show() + dismiss() + } + binding.disableTeamModeButton.setOnClickListener { + onDisableTeamMode() + dismiss() + } + binding.settingsButton.setOnClickListener { + val intent = Intent(context, SettingsActivity::class.java) + context.startActivity(intent) + dismiss() + } + binding.aboutButton.setOnClickListener { + val intent = Intent(context, AboutActivity::class.java) + context.startActivity(intent) + dismiss() + } + binding.downloadButton.setOnClickListener { + onClickDownload() + dismiss() + } + + binding.overlaysButton.setOnClickListener { + onClickOverlays() + dismiss() + } + + if (indexInTeam != null) { + binding.teamModeColorCircle.setIndexInTeam(indexInTeam) + binding.bigMenuItemsContainer.removeView(binding.enableTeamModeButton) + } else { + binding.bigMenuItemsContainer.removeView(binding.disableTeamModeButton) + } + + binding.root.doOnPreDraw { + binding.bigMenuItemsContainer.columnCount = binding.root.width / binding.profileButton.width + } + + setView(binding.root) + } +} diff --git a/app/src/main/res/drawable/ic_team_mode_48dp.xml b/app/src/main/res/drawable/ic_team_mode_48dp.xml new file mode 100644 index 0000000000..8dd9ad2f14 --- /dev/null +++ b/app/src/main/res/drawable/ic_team_mode_48dp.xml @@ -0,0 +1,12 @@ + + + diff --git a/app/src/main/res/layout/dialog_main_menu_grid.xml b/app/src/main/res/layout/dialog_main_menu_grid.xml new file mode 100644 index 0000000000..30c82228bd --- /dev/null +++ b/app/src/main/res/layout/dialog_main_menu_grid.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings_ee.xml b/app/src/main/res/values/strings_ee.xml index 8b02158d2f..4a5ba9b4c7 100644 --- a/app/src/main/res/values/strings_ee.xml +++ b/app/src/main/res/values/strings_ee.xml @@ -256,5 +256,6 @@ This version lets you access your user statistics, but any quests solved using t Moving tiles… Show next quest immediately Display further quest for same element right after solving + Show all main menu items as grid diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index dfe08c2b15..f418d72191 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -139,6 +139,12 @@ android:positiveButtonText="@android:string/ok" android:negativeButtonText="@android:string/cancel" /> + +