mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-26 00:17:42 +01:00
use the proper default event color at google events
This commit is contained in:
parent
dc5846f268
commit
890a7f34a6
@ -6,6 +6,7 @@ import android.app.Activity
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
|
import android.graphics.Color
|
||||||
import android.media.RingtoneManager
|
import android.media.RingtoneManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -25,6 +26,7 @@ import com.simplemobiletools.calendar.extensions.*
|
|||||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
|
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
|
||||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
|
||||||
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
|
||||||
|
import com.simplemobiletools.calendar.helpers.PRIMARY
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
@ -354,6 +356,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
private fun fetchEventsIfHasPermissions() {
|
private fun fetchEventsIfHasPermissions() {
|
||||||
try {
|
try {
|
||||||
getGoogleSyncService().colors().get().execute() // just checking if we have the permission for fetching user data
|
getGoogleSyncService().colors().get().execute() // just checking if we have the permission for fetching user data
|
||||||
|
storeCalendarData()
|
||||||
config.googleSync = true
|
config.googleSync = true
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
settings_google_sync.isChecked = true
|
settings_google_sync.isChecked = true
|
||||||
@ -372,6 +375,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
settings_google_sync.isChecked = false
|
settings_google_sync.isChecked = false
|
||||||
config.googleSync = false
|
config.googleSync = false
|
||||||
config.syncAccountName = ""
|
config.syncAccountName = ""
|
||||||
|
config.googleDefaultEventColor = config.primaryColor
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun storeCalendarData() {
|
||||||
|
Thread({
|
||||||
|
val calendar = getGoogleSyncService().calendarList().get(PRIMARY).execute()
|
||||||
|
config.googleDefaultEventColor = Color.parseColor(calendar.backgroundColor)
|
||||||
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
|
@ -186,7 +186,7 @@ class FetchGoogleEventsTask(val context: Context, val googleSyncListener: Google
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eventTypeId == -1) {
|
if (eventTypeId == -1) {
|
||||||
val newColor = if (eventColors[colorId] != 0) eventColors[colorId] else context.config.primaryColor
|
val newColor = if (eventColors[colorId] != 0) eventColors[colorId] else context.config.googleDefaultEventColor
|
||||||
val newEventType = EventType(0, eventType, newColor)
|
val newEventType = EventType(0, eventType, newColor)
|
||||||
eventTypeId = dbHelper.insertEventType(newEventType)
|
eventTypeId = dbHelper.insertEventType(newEventType)
|
||||||
eventTypes.add(newEventType)
|
eventTypes.add(newEventType)
|
||||||
|
@ -86,6 +86,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getString(SYNC_ACCOUNT_NAME, "")
|
get() = prefs.getString(SYNC_ACCOUNT_NAME, "")
|
||||||
set(syncAccountName) = prefs.edit().putString(SYNC_ACCOUNT_NAME, syncAccountName).apply()
|
set(syncAccountName) = prefs.edit().putString(SYNC_ACCOUNT_NAME, syncAccountName).apply()
|
||||||
|
|
||||||
|
var googleDefaultEventColor: Int
|
||||||
|
get() = prefs.getInt(GOOGLE_DEFAULT_EVENT_COLOR, primaryColor)
|
||||||
|
set(color) = prefs.edit().putInt(GOOGLE_DEFAULT_EVENT_COLOR, color).apply()
|
||||||
|
|
||||||
fun addDisplayEventType(type: String) {
|
fun addDisplayEventType(type: String) {
|
||||||
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
|
addDisplayEventTypes(HashSet<String>(Arrays.asList(type)))
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ val GOOGLE_SYNC = "google_sync"
|
|||||||
val SYNC_ACCOUNT_NAME = "sync_account_name"
|
val SYNC_ACCOUNT_NAME = "sync_account_name"
|
||||||
val SNOOZE_DELAY = "snooze_delay"
|
val SNOOZE_DELAY = "snooze_delay"
|
||||||
val DISPLAY_PAST_EVENTS = "display_past_events"
|
val DISPLAY_PAST_EVENTS = "display_past_events"
|
||||||
|
val GOOGLE_DEFAULT_EVENT_COLOR = "google_default_event_color"
|
||||||
|
|
||||||
val letterIDs = intArrayOf(R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
val letterIDs = intArrayOf(R.string.sunday_letter, R.string.monday_letter, R.string.tuesday_letter, R.string.wednesday_letter,
|
||||||
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter)
|
R.string.thursday_letter, R.string.friday_letter, R.string.saturday_letter)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user