From cf11065223ad4b0ebca94c61ae01938d7be3de81 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 16 May 2017 20:12:13 +0200 Subject: [PATCH] add a menu item for adding holidays - move the holiday files in Raw folder --- .../calendar/activities/MainActivity.kt | 51 +++++++++++++++++++ .../calendar/helpers/IcsImporter.kt | 8 +-- app/src/main/res/menu/menu_main.xml | 4 ++ .../{assets/Algeria.ics => raw/algeria.ics} | 0 .../{assets/Belgium.ics => raw/belgium.ics} | 0 .../{assets/Bolivia.ics => raw/bolivia.ics} | 0 .../res/{assets/Brazil.ics => raw/brazil.ics} | 0 .../res/{assets/Canada.ics => raw/canada.ics} | 0 .../res/{assets/Czech.ics => raw/czech.ics} | 0 .../{assets/Estonia.ics => raw/estonia.ics} | 0 .../{assets/Finland.ics => raw/finland.ics} | 0 .../res/{assets/France.ics => raw/france.ics} | 0 .../{assets/Germany.ics => raw/germany.ics} | 0 .../res/{assets/Greece.ics => raw/greece.ics} | 0 .../{assets/Hungary.ics => raw/hungary.ics} | 0 .../{assets/Iceland.ics => raw/iceland.ics} | 0 .../{assets/Ireland.ics => raw/ireland.ics} | 0 .../res/{assets/Italy.ics => raw/italy.ics} | 0 .../res/{assets/Japan.ics => raw/japan.ics} | 0 .../Netherlands.ics => raw/netherlands.ics} | 0 .../res/{assets/Norway.ics => raw/norway.ics} | 0 .../{assets/Pakistan.ics => raw/pakistan.ics} | 0 .../res/{assets/Poland.ics => raw/poland.ics} | 0 .../{assets/Portugal.ics => raw/portugal.ics} | 0 .../res/{assets/Russia.ics => raw/russia.ics} | 0 .../{assets/Slovakia.ics => raw/slovakia.ics} | 0 .../{assets/Slovenia.ics => raw/slovenia.ics} | 0 .../South_Korea.ics => raw/southkorea.ics} | 0 .../res/{assets/Sweden.ics => raw/sweden.ics} | 0 .../Switzerland.ics => raw/switzerland.ics} | 0 .../{assets/USA.ics => raw/unitedstates.ics} | 0 31 files changed, 60 insertions(+), 3 deletions(-) rename app/src/main/res/{assets/Algeria.ics => raw/algeria.ics} (100%) rename app/src/main/res/{assets/Belgium.ics => raw/belgium.ics} (100%) rename app/src/main/res/{assets/Bolivia.ics => raw/bolivia.ics} (100%) rename app/src/main/res/{assets/Brazil.ics => raw/brazil.ics} (100%) rename app/src/main/res/{assets/Canada.ics => raw/canada.ics} (100%) rename app/src/main/res/{assets/Czech.ics => raw/czech.ics} (100%) rename app/src/main/res/{assets/Estonia.ics => raw/estonia.ics} (100%) rename app/src/main/res/{assets/Finland.ics => raw/finland.ics} (100%) rename app/src/main/res/{assets/France.ics => raw/france.ics} (100%) rename app/src/main/res/{assets/Germany.ics => raw/germany.ics} (100%) rename app/src/main/res/{assets/Greece.ics => raw/greece.ics} (100%) rename app/src/main/res/{assets/Hungary.ics => raw/hungary.ics} (100%) rename app/src/main/res/{assets/Iceland.ics => raw/iceland.ics} (100%) rename app/src/main/res/{assets/Ireland.ics => raw/ireland.ics} (100%) rename app/src/main/res/{assets/Italy.ics => raw/italy.ics} (100%) rename app/src/main/res/{assets/Japan.ics => raw/japan.ics} (100%) rename app/src/main/res/{assets/Netherlands.ics => raw/netherlands.ics} (100%) rename app/src/main/res/{assets/Norway.ics => raw/norway.ics} (100%) rename app/src/main/res/{assets/Pakistan.ics => raw/pakistan.ics} (100%) rename app/src/main/res/{assets/Poland.ics => raw/poland.ics} (100%) rename app/src/main/res/{assets/Portugal.ics => raw/portugal.ics} (100%) rename app/src/main/res/{assets/Russia.ics => raw/russia.ics} (100%) rename app/src/main/res/{assets/Slovakia.ics => raw/slovakia.ics} (100%) rename app/src/main/res/{assets/Slovenia.ics => raw/slovenia.ics} (100%) rename app/src/main/res/{assets/South_Korea.ics => raw/southkorea.ics} (100%) rename app/src/main/res/{assets/Sweden.ics => raw/sweden.ics} (100%) rename app/src/main/res/{assets/Switzerland.ics => raw/switzerland.ics} (100%) rename app/src/main/res/{assets/USA.ics => raw/unitedstates.ics} (100%) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index 51f505fab..0e092e371 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -125,6 +125,7 @@ class MainActivity : SimpleActivity(), NavigationListener { R.id.change_view -> showViewDialog() R.id.go_to_today -> goToToday() R.id.filter -> showFilterDialog() + R.id.add_holidays -> addHolidays() R.id.import_events -> tryImportEvents() R.id.export_events -> tryExportEvents() R.id.settings -> launchSettings() @@ -188,6 +189,10 @@ class MainActivity : SimpleActivity(), NavigationListener { } } + private fun addHolidays() { + val items = getHolidayRadioItems() + } + private fun updateView(view: Int) { calendar_fab.beGoneIf(view == YEARLY_VIEW) mIsMonthSelected = view == MONTHLY_VIEW @@ -509,6 +514,52 @@ class MainActivity : SimpleActivity(), NavigationListener { } } + private fun getHolidayRadioItems(): ArrayList { + val items = ArrayList() + + LinkedHashMap().apply { + put("Algeria", R.raw.algeria) + put("België", R.raw.belgium) + put("Bolivia", R.raw.bolivia) + put("Brasil", R.raw.brazil) + put("Canada", R.raw.canada) + put("Česká republika", R.raw.czech) + put("Deutschland", R.raw.germany) + put("Eesti", R.raw.estonia) + put("Éire", R.raw.ireland) + put("France", R.raw.france) + put("Hanguk", R.raw.southkorea) + put("Hellas", R.raw.greece) + put("Ísland", R.raw.iceland) + put("Italia", R.raw.italy) + put("Magyarország", R.raw.hungary) + put("Nederland", R.raw.netherlands) + put("Nihon", R.raw.japan) + put("Norge", R.raw.norway) + put("Pākistān", R.raw.pakistan) + put("Polska", R.raw.poland) + put("Portugal", R.raw.portugal) + put("Rossiya", R.raw.russia) + put("Schweiz", R.raw.switzerland) + put("Slovenija", R.raw.slovenia) + put("Slovensko", R.raw.slovakia) + put("Suomi", R.raw.finland) + put("Sverige", R.raw.sweden) + put("United States", R.raw.unitedstates) + + var i = 0 + for ((country, file) in this) { + items.add(RadioItem(i++, country, file)) + } + } + + RadioGroupDialog(this, items, -1) { + + } + + return items + } + private fun checkWhatsNewDialog() { arrayListOf().apply { add(Release(39, R.string.release_39)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index f91e3f1ee..14b4d9197 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -1,13 +1,13 @@ package com.simplemobiletools.calendar.helpers import android.content.Context +import android.util.Log import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.extensions.isXMonthlyRepetition import com.simplemobiletools.calendar.extensions.isXWeeklyRepetition import com.simplemobiletools.calendar.extensions.seconds import com.simplemobiletools.calendar.helpers.IcsImporter.ImportResult.* -import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.calendar.models.EventType import org.joda.time.DateTimeZone import org.joda.time.format.DateTimeFormat @@ -47,7 +47,9 @@ class IcsImporter { if (line.trim().isEmpty()) continue - if (line.substring(0, 1) == " ") { + Log.e("DEBUG", "line $line") + + /*if (line.substring(0, 1) == " ") { line = prevLine + line.trim() eventsFailed-- } @@ -105,7 +107,7 @@ class IcsImporter { eventsImported++ resetValues() } - prevLine = line + prevLine = line*/ } } } catch (e: Exception) { diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index ebc3a9737..a54dfef46 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -16,6 +16,10 @@ android:icon="@drawable/ic_filter" android:title="@string/filter" app:showAsAction="ifRoom"/> +