Compare commits
11 Commits
0.1a-rc3
...
01dab6aa30
Author | SHA1 | Date | |
---|---|---|---|
|
01dab6aa30 | ||
|
bafd3cea14 | ||
|
ec52574ae3 | ||
|
923404ebc5
|
||
|
32ba5e0b07 | ||
|
72b2148e4b | ||
|
513660b3a4 | ||
|
443d62b6df
|
||
|
a360c7496b
|
||
|
3fe83cff2e
|
||
|
71acf04f20 |
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
@@ -48,17 +48,17 @@ jobs:
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Build APK
|
||||
run: ./gradlew assemble
|
||||
|
||||
# - name: Upload APK
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: app.apk
|
||||
# path: app/build/outputs/apk/release/app-release.apk
|
||||
run: ./gradlew assembleSignedRelease
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
app/build/outputs/apk/release/app-release.apk
|
||||
app/build/outputs/apk/signedRelease/app-signedRelease.apk
|
||||
prerelease: |
|
||||
if [[ ${{ github.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+[a-z]+$ ]]; then
|
||||
echo "false"
|
||||
else
|
||||
echo "true"
|
||||
fi
|
@@ -5,9 +5,6 @@ plugins {
|
||||
id 'com.mikepenz.aboutlibraries.plugin' version '11.1.1'
|
||||
}
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("app/keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
|
||||
android {
|
||||
namespace 'net.helcel.beans'
|
||||
@@ -20,22 +17,37 @@ android {
|
||||
versionCode 1
|
||||
versionName "0.1a"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
try {
|
||||
def keystorePropertiesFile = rootProject.file("app/keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
} catch (FileNotFoundException e) {
|
||||
println("File not found: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
shrinkResources false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
signedRelease {
|
||||
minifyEnabled true
|
||||
shrinkResources false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
|
@@ -1896,7 +1896,7 @@ MAR_FB|MAR|Fès-Boulemane|19366
|
||||
MAR_GB|MAR|Gharb-Chrarda-Béni Hssen|8782
|
||||
MAR_GC|MAR|Grand Casablanca|879
|
||||
MAR_GE|MAR|Guelmim-Es-Semara|64701
|
||||
MAR_LB|MAR|Laâyoune-Boujdour-Sakia El H|5763
|
||||
MAR_LB|MAR|Laâyoune-Boujdour-Sakia El Hamra|5763
|
||||
MAR_MK|MAR|Marrakech-Tensift-Al Haouz|32483
|
||||
MAR_MT|MAR|Meknès-Tafilalet|60303
|
||||
MAR_OR|MAR|Oriental|59914
|
||||
@@ -3293,9 +3293,9 @@ ARE_RK|ARE|Ras Al-Khaimah|2442
|
||||
ARE_SH|ARE|Sharjah|2529
|
||||
ARE_UQ|ARE|Ummal-Qaywayn|746
|
||||
GBR_NIR|GBR|Northern Ireland|14134
|
||||
GBR_SCT|GBR|Scotland|78704
|
||||
GBR_SCT|GBR|Scotland|79121
|
||||
GBR_WLS|GBR|Wales|20818
|
||||
GBR_NA|GBR|NA|130659
|
||||
GBR_NA|GBR|England|130659
|
||||
USA_AL|USA|Alabama|133995
|
||||
USA_AK|USA|Alaska|1501231
|
||||
USA_AZ|USA|Arizona|296082
|
||||
@@ -3532,4 +3532,3 @@ Z05_UT|IND|Uttarakhand|259
|
||||
Z09_UT|IND|Uttarakhand|987
|
||||
Z06_JK|PAK|Azad Kashmir|13931
|
||||
Z06_NA|PAK|Gilgit-Baltistan|68053
|
||||
GBR_EN|GBR|England|417
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 6.5 MiB After Width: | Height: | Size: 6.5 MiB |
@@ -13,12 +13,15 @@ import net.helcel.beans.activity.fragment.EditPlaceColorFragment
|
||||
import net.helcel.beans.activity.fragment.EditPlaceFragment
|
||||
import net.helcel.beans.countries.GeoLoc
|
||||
import net.helcel.beans.databinding.ItemListGeolocBinding
|
||||
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 net.helcel.beans.helper.Theme.colorWrapper
|
||||
|
||||
class GeolocListAdapter(
|
||||
private val ctx: EditPlaceFragment, private val l: GeoLoc, private val pager: ViewPagerAdapter
|
||||
private val ctx: EditPlaceFragment, private val l: GeoLoc, private val pager: ViewPagerAdapter,
|
||||
private val parentHolder: FoldingListViewHolder?
|
||||
) : RecyclerView.Adapter<GeolocListAdapter.FoldingListViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): FoldingListViewHolder {
|
||||
@@ -27,7 +30,7 @@ class GeolocListAdapter(
|
||||
viewGroup,
|
||||
false
|
||||
)
|
||||
return FoldingListViewHolder(ctx.requireActivity(), binding)
|
||||
return FoldingListViewHolder(ctx.requireActivity(), binding, parentHolder, l)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FoldingListViewHolder, position: Int) {
|
||||
@@ -35,7 +38,7 @@ class GeolocListAdapter(
|
||||
holder.bind(el)
|
||||
holder.addListeners(el) {
|
||||
if (el.children.isNotEmpty())
|
||||
pager.addFragment(ctx, EditPlaceFragment(el, pager))
|
||||
pager.addFragment(ctx, EditPlaceFragment(el, pager, holder))
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -46,21 +49,13 @@ class GeolocListAdapter(
|
||||
|
||||
class FoldingListViewHolder(
|
||||
private val ctx: FragmentActivity,
|
||||
private val _binding: ItemListGeolocBinding
|
||||
private val _binding: ItemListGeolocBinding,
|
||||
private val _parentHolder: FoldingListViewHolder? = null,
|
||||
private val _parentGeoLoc: GeoLoc,
|
||||
) : RecyclerView.ViewHolder(_binding.root) {
|
||||
|
||||
private fun bindGroup(el: GeoLoc) {
|
||||
val numerator = el.children.map { Data.visits.getVisited(it) != 0 }.count { it }
|
||||
val denominator = el.children.size
|
||||
|
||||
_binding.count.text = when (Settings.getStatPref(ctx)) {
|
||||
ctx.getString(R.string.percentages) -> ctx.getString(
|
||||
R.string.percentage,
|
||||
(100 * (numerator.toFloat() / denominator.toFloat())).toInt()
|
||||
)
|
||||
|
||||
else -> ctx.getString(R.string.rate, numerator, denominator)
|
||||
}
|
||||
refreshCount(el)
|
||||
_binding.textView.setTypeface(null, Typeface.BOLD)
|
||||
_binding.textView.backgroundTintList = ColorStateList.valueOf(
|
||||
colorWrapper(
|
||||
@@ -104,16 +99,17 @@ class GeolocListAdapter(
|
||||
"AddColorDialogFragment"
|
||||
)
|
||||
}
|
||||
_parentHolder?.refresh(_parentGeoLoc)
|
||||
}
|
||||
}
|
||||
|
||||
fun onColorDialogDismiss(clear: Boolean) {
|
||||
if (clear) {
|
||||
Data.visits.setVisited(Data.selected_geoloc, 0)
|
||||
Data.visits.setVisited(Data.selected_geoloc, NO_GROUP)
|
||||
Data.saveData()
|
||||
}
|
||||
if (Data.selected_group != null && Data.selected_geoloc != null) {
|
||||
Data.visits.setVisited(Data.selected_geoloc, Data.selected_group?.key ?: 0)
|
||||
Data.visits.setVisited(Data.selected_geoloc, Data.selected_group?.key ?: NO_GROUP)
|
||||
Data.saveData()
|
||||
}
|
||||
Data.selected_geoloc?.let { refreshCheck(it) }
|
||||
@@ -122,6 +118,24 @@ class GeolocListAdapter(
|
||||
}
|
||||
|
||||
private fun refreshCheck(geoLoc: GeoLoc) {
|
||||
_binding.checkBox.checkedState =
|
||||
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 }) {
|
||||
Data.visits.setVisited(geoLoc, AUTO_GROUP)
|
||||
MaterialCheckBox.STATE_CHECKED
|
||||
}
|
||||
else if (geoLoc.children.any { Data.visits.getVisited(it) != NO_GROUP }) {
|
||||
Data.visits.setVisited(geoLoc, AUTO_GROUP)
|
||||
MaterialCheckBox.STATE_INDETERMINATE
|
||||
}
|
||||
else {
|
||||
Data.visits.setVisited(geoLoc, NO_GROUP)
|
||||
MaterialCheckBox.STATE_UNCHECKED
|
||||
}
|
||||
Data.saveData()
|
||||
|
||||
var col = Data.groups.getGroupFromKey(Data.visits.getVisited(geoLoc)).color
|
||||
if (col.color == Color.TRANSPARENT) {
|
||||
col = colorWrapper(
|
||||
@@ -130,13 +144,29 @@ class GeolocListAdapter(
|
||||
)
|
||||
col.alpha = 64
|
||||
}
|
||||
_binding.checkBox.checkedState =
|
||||
if (Data.visits.getVisited(geoLoc) != 0) MaterialCheckBox.STATE_CHECKED
|
||||
else if (geoLoc.children.any { Data.visits.getVisited(it) != 0 }) MaterialCheckBox.STATE_INDETERMINATE
|
||||
else MaterialCheckBox.STATE_UNCHECKED
|
||||
|
||||
_binding.checkBox.buttonTintList = ColorStateList.valueOf(col.color)
|
||||
}
|
||||
|
||||
private fun refreshCount(geoLoc: GeoLoc) {
|
||||
val numerator = geoLoc.children.map { Data.visits.getVisited(it) != NO_GROUP }.count { it }
|
||||
val denominator = geoLoc.children.size
|
||||
_binding.count.text = when (Settings.getStatPref(ctx)) {
|
||||
ctx.getString(R.string.percentages) -> ctx.getString(
|
||||
R.string.percentage,
|
||||
(100 * (numerator.toFloat() / denominator.toFloat())).toInt()
|
||||
)
|
||||
else -> ctx.getString(R.string.rate, numerator, denominator)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refresh(geoLoc: GeoLoc) {
|
||||
// Refresh
|
||||
refreshCheck(geoLoc)
|
||||
refreshCount(geoLoc)
|
||||
|
||||
// Recursively refresh parent
|
||||
_parentHolder?.refresh(_parentGeoLoc)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -8,11 +8,12 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import net.helcel.beans.activity.adapter.GeolocListAdapter
|
||||
import net.helcel.beans.activity.adapter.GeolocListAdapter.FoldingListViewHolder
|
||||
import net.helcel.beans.activity.adapter.ViewPagerAdapter
|
||||
import net.helcel.beans.countries.GeoLoc
|
||||
import net.helcel.beans.databinding.FragmentEditPlacesBinding
|
||||
|
||||
class EditPlaceFragment(val loc: GeoLoc, private val pager: ViewPagerAdapter) : Fragment() {
|
||||
class EditPlaceFragment(val loc: GeoLoc, private val pager: ViewPagerAdapter, private val holder: FoldingListViewHolder? = null) : Fragment() {
|
||||
private lateinit var _binding: FragmentEditPlacesBinding
|
||||
|
||||
override fun onCreateView(
|
||||
@@ -26,7 +27,7 @@ class EditPlaceFragment(val loc: GeoLoc, private val pager: ViewPagerAdapter) :
|
||||
_binding.list.setHasFixedSize(true)
|
||||
_binding.list.layoutManager =
|
||||
LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)
|
||||
_binding.list.adapter = GeolocListAdapter(this, loc, pager)
|
||||
_binding.list.adapter = GeolocListAdapter(this, loc, pager, holder)
|
||||
return _binding.root
|
||||
}
|
||||
}
|
@@ -17,8 +17,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
findPreference<Preference>(getString(R.string.key_regional))?.setOnPreferenceChangeListener { _, key ->
|
||||
when (key as String) {
|
||||
ctx.getString(R.string.off) -> GeoLocImporter.clearStates()
|
||||
ctx.getString(R.string.on) -> GeoLocImporter.importStates(ctx)
|
||||
else -> GeoLocImporter.clearStates()
|
||||
ctx.getString(R.string.on) -> GeoLocImporter.importStates(ctx, true)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
@@ -8,8 +8,6 @@ enum class Country(
|
||||
HKG("Hong Kong", 1104),
|
||||
MAC("Macao", 32),
|
||||
ANT("Netherlands Antilles", 800),
|
||||
|
||||
|
||||
AFG("Afghanistan", 645487),
|
||||
XAD("Akrotiri and Dhekelia", 234),
|
||||
ALA("Åland", 1483),
|
||||
@@ -217,7 +215,7 @@ enum class Country(
|
||||
SLB("Solomon Islands", 28686),
|
||||
SOM("Somalia", 637672),
|
||||
ZAF("South Africa", 1224059),
|
||||
SGS("South Georgia and the South Sand", 4085),
|
||||
SGS("South Georgia and the South Sandwich Islands", 4085),
|
||||
KOR("South Korea", 100721),
|
||||
SSD("South Sudan", 632186),
|
||||
ESP("Spain", 506617),
|
||||
@@ -248,7 +246,7 @@ enum class Country(
|
||||
ARE("United Arab Emirates", 71429),
|
||||
GBR("United Kingdom", 244732),
|
||||
USA("United States", 9477483),
|
||||
UMI("United States Minor Outlying Isl", 47),
|
||||
UMI("United States Minor Outlying Islands", 47),
|
||||
URY("Uruguay", 178103),
|
||||
UZB("Uzbekistan", 447894),
|
||||
VUT("Vanuatu", 12384),
|
||||
|
@@ -7,8 +7,8 @@ import java.io.InputStreamReader
|
||||
|
||||
object GeoLocImporter {
|
||||
|
||||
fun importStates(ctx: Context) {
|
||||
if (!Settings.isRegional(ctx)) {
|
||||
fun importStates(ctx: Context, force: Boolean = false) {
|
||||
if (!Settings.isRegional(ctx) and !force) {
|
||||
return
|
||||
}
|
||||
val fs = BufferedReader(InputStreamReader(ctx.assets.open("geoloc_state.txt")))
|
||||
|
@@ -6,6 +6,8 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
|
||||
EEE(
|
||||
"Europe", listOf(
|
||||
XAD,
|
||||
ALA,// Åland Islands: an autonomous region of Finland, but not a member of the EU or UN
|
||||
ALB,
|
||||
AND,
|
||||
AUT,
|
||||
@@ -18,14 +20,19 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
CZE,
|
||||
DNK,
|
||||
EST,
|
||||
FRO, // Faroe Islands: an autonomous region of Denmark
|
||||
FIN,
|
||||
FRA,
|
||||
DEU,
|
||||
GIB, // Gibraltar: a British overseas territory located at the southern tip of the Iberian Peninsula
|
||||
GRC,
|
||||
GGY, // Guernsey: a British Crown dependency in the English Channel
|
||||
HUN,
|
||||
ISL,
|
||||
IRL,
|
||||
IMN, // Isle of Man: a British Crown dependency located in the Irish Sea
|
||||
ITA,
|
||||
JEY, // Jersey: a British Crown dependency located in the English Channel
|
||||
KAZ,
|
||||
XKO,
|
||||
LVA,
|
||||
@@ -48,12 +55,12 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
SVK,
|
||||
SVN,
|
||||
ESP,
|
||||
SJM, // Svalbard and Jan Mayen: an archipelago administered by Norway
|
||||
SWE,
|
||||
CHE,
|
||||
UKR,
|
||||
GBR,
|
||||
VAT,
|
||||
XAD,
|
||||
)
|
||||
),
|
||||
ABB(
|
||||
@@ -64,9 +71,12 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
BHR,
|
||||
BGD,
|
||||
BTN,
|
||||
IOT, // British Indian Ocean Territory: a British overseas territory in the Indian Ocean
|
||||
BRN,
|
||||
KHM,
|
||||
CCK, // Cocos (Keeling) Islands: an Australian external territory in the Indian Ocean
|
||||
CHN,
|
||||
CXR, // Christmas Island: an Australian external territory in the Indian Ocean
|
||||
GEO,
|
||||
HKG,
|
||||
IND,
|
||||
@@ -131,8 +141,8 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
EGY,
|
||||
GNQ,
|
||||
ERI,
|
||||
SWZ,
|
||||
ETH,
|
||||
ATF, // French Southern and Antarctic Lands: a territory of France located in the southern Indian Ocean
|
||||
GAB,
|
||||
GMB,
|
||||
GHA,
|
||||
@@ -165,6 +175,7 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
SSD,
|
||||
SHN,
|
||||
SDN,
|
||||
SWZ,
|
||||
TZA,
|
||||
TGO,
|
||||
TUN,
|
||||
@@ -184,9 +195,11 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
BRB,
|
||||
BLZ,
|
||||
BMU,
|
||||
BES, // Bonaire, Sint Eustatius and Saba: special municipalities of the Netherlands in the Caribbean
|
||||
VGB,
|
||||
CAN,
|
||||
CYM,
|
||||
XCL,
|
||||
CRI,
|
||||
CUB,
|
||||
CUW,
|
||||
@@ -208,15 +221,18 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
NIC,
|
||||
PAN,
|
||||
PRI,
|
||||
BLM, // Saint Barthélemy: an overseas collectivity of France in the Caribbean
|
||||
KNA,
|
||||
LCA,
|
||||
MAF,
|
||||
SPM,
|
||||
VCT,
|
||||
SXM, // Sint Maarten: a constituent country of the Kingdom of the Netherlands in the Caribbean
|
||||
TTO,
|
||||
TCA,
|
||||
USA,
|
||||
XCL,
|
||||
UMI, // United States Minor Outlying Islands: a collection of nine insular areas of the United States
|
||||
VIR, // United States Virgin Islands: an unincorporated territory of the United States in the Caribbean
|
||||
)
|
||||
),
|
||||
SRR(
|
||||
@@ -257,6 +273,7 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
PLW,
|
||||
PNG,
|
||||
PCN,
|
||||
WSM, // Samoa: an independent island nation in the South Pacific
|
||||
SLB,
|
||||
TKL,
|
||||
TON,
|
||||
@@ -269,26 +286,9 @@ enum class Group(override val fullName: String, override val children: List<GeoL
|
||||
XXX(
|
||||
"Others", listOf(
|
||||
ATA, // Antarctica: not in any other region
|
||||
ALA,// Åland Islands: an autonomous region of Finland, but not a member of the EU or UN
|
||||
BES,// Bonaire, Sint Eustatius and Saba: special municipalities of the Netherlands in the Caribbean
|
||||
BVT, // Bouvet Island: an uninhabited territory of Norway in the South Atlantic
|
||||
IOT,// British Indian Ocean Territory: a British overseas territory in the Indian Ocean
|
||||
CXR,// Christmas Island: an Australian external territory in the Indian Ocean
|
||||
CCK,// Cocos (Keeling) Islands: an Australian external territory in the Indian Ocean
|
||||
FRO,// Faroe Islands: an autonomous region of Denmark
|
||||
ATF,// French Southern and Antarctic Lands: a territory of France located in the southern Indian Ocean
|
||||
GIB,// Gibraltar: a British overseas territory located at the southern tip of the Iberian Peninsula
|
||||
GGY,// Guernsey: a British Crown dependency in the English Channel
|
||||
HMD, // Heard Island and McDonald Islands: an uninhabited Australian external territory in the southern Indian Ocean
|
||||
IMN,// Isle of Man: a British Crown dependency located in the Irish Sea
|
||||
JEY,// Jersey: a British Crown dependency located in the English Channel
|
||||
BLM,// Saint Barthélemy: an overseas collectivity of France in the Caribbean
|
||||
WSM, // Samoa: an independent island nation in the South Pacific
|
||||
SXM, // Sint Maarten: a constituent country of the Kingdom of the Netherlands in the Caribbean
|
||||
SGS, // South Georgia and the South Sandwich Islands: a British overseas territory in the southern Atlantic Ocean
|
||||
SJM, // Svalbard and Jan Mayen: an archipelago administered by Norway
|
||||
UMI, // United States Minor Outlying Islands: a collection of nine insular areas of the United States
|
||||
VIR, // United States Virgin Islands: an unincorporated territory of the United States in the Caribbean
|
||||
)
|
||||
),
|
||||
|
||||
|
@@ -34,7 +34,7 @@ fun loadData(ctx: Context, id:Int) {
|
||||
|
||||
// Add default group "Visited" with app's color if there is no group already
|
||||
if (groups.size() == 0) {
|
||||
groups.setGroup(1, "Visited", ColorDrawable(ContextCompat.getColor(ctx, R.color.blue)))
|
||||
groups.setGroup(DEFAULT_GROUP, "Visited", ColorDrawable(ContextCompat.getColor(ctx, R.color.blue)))
|
||||
saveData()
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,10 @@ import kotlin.random.Random
|
||||
private const val randSeed = 0
|
||||
private val rnd = Random(randSeed)
|
||||
|
||||
const val NO_GROUP = 0
|
||||
const val DEFAULT_GROUP = 1
|
||||
const val AUTO_GROUP = -1
|
||||
|
||||
@Serializable
|
||||
class Groups(val id: Int, private val grps: HashMap<Int, Group>) {
|
||||
|
||||
@@ -30,7 +34,7 @@ class Groups(val id: Int, private val grps: HashMap<Int, Group>) {
|
||||
|
||||
fun genKey(): Int {
|
||||
val key = rnd.nextInt()
|
||||
if (grps.containsKey(key) || key == 0) return genKey()
|
||||
if (grps.containsKey(key) || key in listOf(NO_GROUP, DEFAULT_GROUP, AUTO_GROUP)) return genKey()
|
||||
return key
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ class Visits(val id: Int, private val locs: HashMap<String, Int>) {
|
||||
}
|
||||
|
||||
fun getVisited(key: GeoLoc): Int {
|
||||
return locs.getOrDefault(key.code, 0)
|
||||
return getVisited(key.code)
|
||||
}
|
||||
|
||||
private fun getVisited(key: String): Int {
|
||||
|
@@ -4,47 +4,55 @@ import android.content.Context
|
||||
import net.helcel.beans.countries.World
|
||||
import net.helcel.beans.helper.Data.groups
|
||||
import net.helcel.beans.helper.Data.visits
|
||||
import net.helcel.beans.helper.Settings
|
||||
import net.helcel.beans.helper.Theme.colorToHex6
|
||||
import net.helcel.beans.helper.Theme.colorWrapper
|
||||
|
||||
class CSSWrapper(ctx: Context) {
|
||||
class CSSWrapper(private val ctx: Context) {
|
||||
|
||||
private val colorForeground: String =
|
||||
colorToHex6(colorWrapper(ctx, android.R.attr.panelColorBackground))
|
||||
private val colorBackground: String =
|
||||
colorToHex6(colorWrapper(ctx, android.R.attr.colorBackground))
|
||||
|
||||
private val baseCSS: String
|
||||
private val continents: String = World.WWW.children.joinToString(",") { "#${it.code}2" }
|
||||
private val countries: String = World.WWW.children.joinToString(",") { itt ->
|
||||
itt.children.joinToString(",") { "#${it.code}2" }
|
||||
}
|
||||
private val regional: String = World.WWW.children.joinToString(",") { itt ->
|
||||
itt.children.joinToString(",") { "#${it.code}1" }
|
||||
}
|
||||
private val countryOnlyCSS: String =
|
||||
"svg{fill:$colorForeground;stroke:$colorBackground;stroke-width:0.1;}" +
|
||||
"${regional}{display:none;}"
|
||||
private val countryRegionalCSS: String =
|
||||
"svg{fill:$colorForeground;stroke:$colorBackground;stroke-width:0.01;}" +
|
||||
"$continents,$countries{fill:none;stroke:$colorBackground;stroke-width:0.1;}"
|
||||
private var customCSS: String = ""
|
||||
|
||||
init {
|
||||
val www = World.WWW.children.joinToString(",") { "#${it.code}2" }
|
||||
val ccc = World.WWW.children.joinToString(",") { itt ->
|
||||
itt.children.joinToString(",") { "#${it.code}2" }
|
||||
}
|
||||
baseCSS = "svg{fill:$colorForeground;stroke:$colorBackground;stroke-width:0.01;}" +
|
||||
"$www,$ccc{stroke:$colorBackground;stroke-width:0.1;fill:none}"
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
private fun refresh() {
|
||||
val id = if (Settings.isRegional(ctx)) "1" else "2"
|
||||
customCSS = visits.getVisitedByValue().map { (k, v) ->
|
||||
if (groups.getGroupFromKey(k).key == 0)
|
||||
""
|
||||
else
|
||||
v.joinToString(",") { "#${it}1,#${it}" } + "{fill:${
|
||||
colorToHex6(
|
||||
groups.getGroupFromKey(
|
||||
k
|
||||
).color
|
||||
)
|
||||
v.joinToString(",") { "#${it}$id,#${it}" } + "{fill:${
|
||||
colorToHex6(groups.getGroupFromKey(k).color)
|
||||
};}"
|
||||
}.joinToString("")
|
||||
}
|
||||
|
||||
fun get(): String {
|
||||
refresh()
|
||||
return baseCSS + customCSS
|
||||
return if (Settings.isRegional(ctx)) {
|
||||
countryRegionalCSS + customCSS
|
||||
} else {
|
||||
countryOnlyCSS + customCSS
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user