Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ object Map3DQuickSettingsDialog {
val cbPanV = view.findViewById<MaterialCheckBox>(R.id.cb_control_pan_v)
val cbPanH = view.findViewById<MaterialCheckBox>(R.id.cb_control_pan_h)
val btnReset = view.findViewById<Button>(R.id.btn_reset_settings)
val btnDone = view.findViewById<Button>(R.id.btn_done_settings)

var isUpdatingUi = false

Expand Down Expand Up @@ -121,7 +122,8 @@ object Map3DQuickSettingsDialog {
R.id.rb_mode_roadmap -> Map3DMode.ROADMAP
else -> Map3DMode.HYBRID
}
controller.setMapMode(newMode)
val updated = controller.setMapMode(newMode)
googleMap3D?.let { updated.applyTo(it) }
}

// Listen for Color Scheme changes
Expand All @@ -132,14 +134,16 @@ object Map3DQuickSettingsDialog {
R.id.rb_scheme_dark -> Map3DColorScheme.DARK
else -> Map3DColorScheme.FOLLOW_SYSTEM
}
controller.setColorScheme(newScheme)
val updated = controller.setColorScheme(newScheme)
googleMap3D?.let { updated.applyTo(it) }
}

// Master switch toggle
switchAll.setOnCheckedChangeListener { _, isChecked ->
if (isUpdatingUi) return@setOnCheckedChangeListener
val updated = controller.setAllUiControls(isChecked)
syncCheckboxes(updated.uiControls)
googleMap3D?.let { updated.applyTo(it) }
}

// Helper for individual checkboxes
Expand All @@ -156,6 +160,7 @@ object Map3DQuickSettingsDialog {
isUpdatingUi = true
switchAll.isChecked = updated.uiControls.allEnabled
isUpdatingUi = false
googleMap3D?.let { updated.applyTo(it) }
}

cbZoom.setOnCheckedChangeListener { _, _ -> onIndividualControlToggled() }
Expand All @@ -168,19 +173,21 @@ object Map3DQuickSettingsDialog {
btnReset?.setOnClickListener {
val resetSettings = controller.reset(sampleDefaultMapMode)
syncAllControls(resetSettings)
googleMap3D?.let { resetSettings.applyTo(it) }
}

val dialog = MaterialAlertDialogBuilder(context)
.setTitle(R.string.map3d_settings_title)
.setView(view)
.setPositiveButton(R.string.map3d_settings_done) { d, _ ->
d.dismiss()
}
.setOnDismissListener {
onDismiss?.invoke()
}
.create()

btnDone?.setOnClickListener {
dialog.dismiss()
}

dialog.window?.setFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Checkbox
Expand Down Expand Up @@ -247,7 +249,11 @@ fun Map3DQuickSettingsWidget(
)
},
text = {
Column(Modifier.verticalScroll(rememberScrollState())) {
Column(
Modifier
.heightIn(max = 360.dp)
.verticalScroll(rememberScrollState()),
) {
// Map Mode Section
Text(
text = stringResource(id = R.string.map3d_mode_section),
Expand All @@ -266,7 +272,7 @@ fun Map3DQuickSettingsWidget(
Row(
modifier = Modifier
.fillMaxWidth()
.height(40.dp)
.height(38.dp)
.selectable(
selected = (settings.mapMode == mode),
onClick = {
Expand All @@ -290,7 +296,7 @@ fun Map3DQuickSettingsWidget(
}
}

HorizontalDivider(modifier = Modifier.padding(vertical = 12.dp))
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))

// Color Scheme Section
Text(
Expand All @@ -310,7 +316,7 @@ fun Map3DQuickSettingsWidget(
Row(
modifier = Modifier
.fillMaxWidth()
.height(40.dp)
.height(38.dp)
.selectable(
selected = (settings.colorScheme == scheme),
onClick = {
Expand All @@ -334,13 +340,13 @@ fun Map3DQuickSettingsWidget(
}
}

HorizontalDivider(modifier = Modifier.padding(vertical = 12.dp))
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))

// UI Controls Section
Row(
modifier = Modifier
.fillMaxWidth()
.height(40.dp),
.height(38.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Expand Down Expand Up @@ -389,12 +395,17 @@ fun Map3DQuickSettingsWidget(
Row(
modifier = Modifier
.fillMaxWidth()
.height(40.dp),
.height(38.dp)
.toggleable(
value = isChecked,
onValueChange = onToggle,
role = Role.Checkbox,
),
verticalAlignment = Alignment.CenterVertically,
) {
Checkbox(
checked = isChecked,
onCheckedChange = onToggle,
onCheckedChange = null,
)
Text(
text = label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,17 @@ data class Map3DSettings(
fun applyTo(googleMap3D: GoogleMap3D) {
googleMap3D.setMapMode(mapMode)

// Apply dark / light mode via AppCompatDelegate
// Apply dark / light mode via AppCompatDelegate only when explicitly changed
val currentNightMode = AppCompatDelegate.getDefaultNightMode()
val nightMode = when (colorScheme) {
Map3DColorScheme.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
Map3DColorScheme.DARK -> AppCompatDelegate.MODE_NIGHT_YES
Map3DColorScheme.FOLLOW_SYSTEM -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
}
if (AppCompatDelegate.getDefaultNightMode() != nightMode) {
val isRedundantSystemDefault =
colorScheme == Map3DColorScheme.FOLLOW_SYSTEM &&
currentNightMode == AppCompatDelegate.MODE_NIGHT_UNSPECIFIED
if (!isRedundantSystemDefault && currentNightMode != nightMode) {
AppCompatDelegate.setDefaultNightMode(nightMode)
}

Expand Down
Loading
Loading