show the list widget configuration activity from settings when requested

This commit is contained in:
tibbi 2018-05-02 09:30:06 +02:00
parent 4c4ac0bc03
commit de0e8daaca
3 changed files with 12 additions and 16 deletions

View File

@ -8,10 +8,7 @@ import android.text.TextUtils
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.SelectCalendarsDialog
import com.simplemobiletools.calendar.extensions.*
import com.simplemobiletools.calendar.helpers.CalDAVHandler
import com.simplemobiletools.calendar.helpers.FONT_SIZE_LARGE
import com.simplemobiletools.calendar.helpers.FONT_SIZE_MEDIUM
import com.simplemobiletools.calendar.helpers.FONT_SIZE_SMALL
import com.simplemobiletools.calendar.helpers.*
import com.simplemobiletools.calendar.models.EventType
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.CustomIntervalPickerDialog
@ -392,7 +389,10 @@ class SettingsActivity : SimpleActivity() {
private fun setupCustomizeWidgetColors() {
settings_customize_widget_colors_holder.setOnClickListener {
Intent(this, WidgetListConfigureActivity::class.java).apply {
putExtra(IS_CUSTOMIZING_COLORS, true)
startActivity(this)
}
}
}

View File

@ -3,7 +3,6 @@ package com.simplemobiletools.calendar.activities
import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.content.res.Resources
import android.graphics.Color
import android.os.Bundle
import android.widget.SeekBar
@ -12,6 +11,7 @@ import com.simplemobiletools.calendar.adapters.EventListAdapter
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.extensions.seconds
import com.simplemobiletools.calendar.helpers.Formatter
import com.simplemobiletools.calendar.helpers.IS_CUSTOMIZING_COLORS
import com.simplemobiletools.calendar.helpers.MyWidgetListProvider
import com.simplemobiletools.calendar.models.ListEvent
import com.simplemobiletools.calendar.models.ListItem
@ -24,9 +24,6 @@ import org.joda.time.DateTime
import java.util.*
class WidgetListConfigureActivity : SimpleActivity() {
lateinit var mRes: Resources
private var mPackageName = ""
private var mBgAlpha = 0f
private var mWidgetId = 0
private var mBgColorWithoutTransparency = 0
@ -35,21 +32,21 @@ class WidgetListConfigureActivity : SimpleActivity() {
private var mTextColor = 0
private var mEventsAdapter: EventListAdapter? = null
private var mIsCustomizingColors = false
public override fun onCreate(savedInstanceState: Bundle?) {
useDynamicTheme = false
super.onCreate(savedInstanceState)
setResult(Activity.RESULT_CANCELED)
setContentView(R.layout.widget_config_list)
mPackageName = packageName
initVariables()
val extras = intent.extras
if (extras != null)
mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
mIsCustomizingColors = intent.extras?.getBoolean(IS_CUSTOMIZING_COLORS) ?: false
mWidgetId = intent.extras?.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID) ?: AppWidgetManager.INVALID_APPWIDGET_ID
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID && !mIsCustomizingColors) {
finish()
}
mEventsAdapter = EventListAdapter(this, getListItems(), false, null, config_events_list) {}
mEventsAdapter!!.updateTextColor(mTextColor)
@ -69,8 +66,6 @@ class WidgetListConfigureActivity : SimpleActivity() {
}
private fun initVariables() {
mRes = resources
mTextColorWithoutTransparency = config.widgetTextColor
updateColors()

View File

@ -51,6 +51,7 @@ const val LAST_USED_CALDAV_CALENDAR = "last_used_caldav_calendar"
const val DISPLAY_PAST_EVENTS = "display_past_events"
const val REPLACE_DESCRIPTION = "replace_description"
const val SHOW_GRID = "show_grid"
const val IS_CUSTOMIZING_COLORS = "is_customizing_colors"
// repeat_rule for monthly repetition
const val REPEAT_MONTH_SAME_DAY = 1 // ie 25th every month