Port regional assignments to parent country if turned off
This commit is contained in:
parent
a3f81c95a0
commit
59a72e0544
@ -119,7 +119,10 @@ class GeolocListAdapter(
|
||||
|
||||
private fun refreshCheck(geoLoc: GeoLoc) {
|
||||
_binding.checkBox.checkedState =
|
||||
if (Data.visits.getVisited(geoLoc) !in listOf(NO_GROUP, AUTO_GROUP)) {
|
||||
if (Data.visits.getVisited(geoLoc) == AUTO_GROUP && !Settings.isRegional(ctx) && geoLoc.type == GeoLoc.LocType.COUNTRY) {
|
||||
MaterialCheckBox.STATE_CHECKED
|
||||
}
|
||||
else if (Data.visits.getVisited(geoLoc) !in listOf(NO_GROUP, AUTO_GROUP)) {
|
||||
MaterialCheckBox.STATE_CHECKED
|
||||
}
|
||||
else if (geoLoc.children.isNotEmpty() && geoLoc.children.all { Data.visits.getVisited(it) != NO_GROUP }) {
|
||||
@ -137,11 +140,11 @@ class GeolocListAdapter(
|
||||
Data.saveData()
|
||||
|
||||
var col = Data.groups.getGroupFromKey(Data.visits.getVisited(geoLoc)).color
|
||||
if (col.color == Color.TRANSPARENT) {
|
||||
col = colorWrapper(
|
||||
ctx,
|
||||
android.R.attr.panelColorBackground
|
||||
)
|
||||
if (Data.visits.getVisited(geoLoc) == AUTO_GROUP) {
|
||||
col = colorWrapper(ctx, android.R.attr.colorPrimary)
|
||||
}
|
||||
else if (col.color == Color.TRANSPARENT) {
|
||||
col = colorWrapper(ctx, android.R.attr.panelColorBackground)
|
||||
col.alpha = 64
|
||||
}
|
||||
_binding.checkBox.buttonTintList = ColorStateList.valueOf(col.color)
|
||||
|
@ -1,6 +1,9 @@
|
||||
package net.helcel.beans.countries
|
||||
|
||||
import android.content.Context
|
||||
import net.helcel.beans.helper.AUTO_GROUP
|
||||
import net.helcel.beans.helper.Data
|
||||
import net.helcel.beans.helper.NO_GROUP
|
||||
import net.helcel.beans.helper.Settings
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
@ -20,6 +23,19 @@ object GeoLocImporter {
|
||||
}
|
||||
|
||||
fun clearStates() {
|
||||
Country.entries.forEach { it.children.clear() }
|
||||
Country.entries.forEach { country ->
|
||||
if (country.children.any { region ->
|
||||
Data.visits.getVisited(region) != NO_GROUP
|
||||
}) {
|
||||
if (Data.visits.getVisited(country) == NO_GROUP) {
|
||||
Data.visits.setVisited(country, AUTO_GROUP)
|
||||
}
|
||||
country.children.forEach { region ->
|
||||
Data.visits.setVisited(region, NO_GROUP)
|
||||
}
|
||||
Data.saveData()
|
||||
}
|
||||
country.children.clear()
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,11 @@ package net.helcel.beans.svg
|
||||
|
||||
import android.content.Context
|
||||
import net.helcel.beans.countries.World
|
||||
import net.helcel.beans.helper.AUTO_GROUP
|
||||
import net.helcel.beans.helper.Data
|
||||
import net.helcel.beans.helper.Data.groups
|
||||
import net.helcel.beans.helper.Data.visits
|
||||
import net.helcel.beans.helper.NO_GROUP
|
||||
import net.helcel.beans.helper.Settings
|
||||
import net.helcel.beans.helper.Theme.colorToHex6
|
||||
import net.helcel.beans.helper.Theme.colorWrapper
|
||||
@ -37,7 +40,12 @@ class CSSWrapper(private val ctx: Context) {
|
||||
private fun refresh() {
|
||||
val id = if (Settings.isRegional(ctx)) "1" else "2"
|
||||
customCSS = visits.getVisitedByValue().map { (k, v) ->
|
||||
if (groups.getGroupFromKey(k).key == 0)
|
||||
if (!Settings.isRegional(ctx) && k == AUTO_GROUP) {
|
||||
v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${
|
||||
colorToHex6(colorWrapper(ctx, android.R.attr.colorPrimary))
|
||||
};}"
|
||||
}
|
||||
else if (groups.getGroupFromKey(k).key == NO_GROUP)
|
||||
""
|
||||
else
|
||||
v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${
|
||||
|
Loading…
x
Reference in New Issue
Block a user