move adjustAlpha to an Int extension, remove Utils class
This commit is contained in:
parent
eee184c51a
commit
d44880bed2
15 changed files with 65 additions and 69 deletions
|
@ -4,9 +4,9 @@ import android.os.Bundle
|
||||||
import android.support.v4.app.TaskStackBuilder
|
import android.support.v4.app.TaskStackBuilder
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.*
|
import com.simplemobiletools.calendar.extensions.*
|
||||||
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
@ -49,8 +49,8 @@ class SettingsActivity : SimpleActivity() {
|
||||||
val reminderType = mConfig.defaultReminderType
|
val reminderType = mConfig.defaultReminderType
|
||||||
val reminderMinutes = mConfig.defaultReminderMinutes
|
val reminderMinutes = mConfig.defaultReminderMinutes
|
||||||
settings_default_reminder.setSelection(when (reminderType) {
|
settings_default_reminder.setSelection(when (reminderType) {
|
||||||
Constants.REMINDER_OFF -> 0
|
REMINDER_OFF -> 0
|
||||||
Constants.REMINDER_AT_START -> 1
|
REMINDER_AT_START -> 1
|
||||||
else -> 2
|
else -> 2
|
||||||
})
|
})
|
||||||
custom_reminder_save.setTextColor(custom_reminder_other_val.currentTextColor)
|
custom_reminder_save.setTextColor(custom_reminder_other_val.currentTextColor)
|
||||||
|
@ -72,9 +72,9 @@ class SettingsActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
mConfig.defaultReminderType = when (itemIndex) {
|
mConfig.defaultReminderType = when (itemIndex) {
|
||||||
0 -> Constants.REMINDER_OFF
|
0 -> REMINDER_OFF
|
||||||
1 -> Constants.REMINDER_AT_START
|
1 -> REMINDER_AT_START
|
||||||
else -> Constants.REMINDER_CUSTOM
|
else -> REMINDER_CUSTOM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,13 +83,13 @@ class SettingsActivity : SimpleActivity() {
|
||||||
private fun saveReminder() {
|
private fun saveReminder() {
|
||||||
val value = custom_reminder_value.value
|
val value = custom_reminder_value.value
|
||||||
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
|
val multiplier = when (custom_reminder_other_period.selectedItemPosition) {
|
||||||
1 -> Constants.HOUR_MINS
|
1 -> HOUR_MINS
|
||||||
2 -> Constants.DAY_MINS
|
2 -> DAY_MINS
|
||||||
else -> 1
|
else -> 1
|
||||||
}
|
}
|
||||||
|
|
||||||
mConfig.defaultReminderMinutes = Integer.valueOf(value) * multiplier
|
mConfig.defaultReminderMinutes = Integer.valueOf(value) * multiplier
|
||||||
mConfig.defaultReminderType = Constants.REMINDER_CUSTOM
|
mConfig.defaultReminderType = REMINDER_CUSTOM
|
||||||
toast(R.string.reminder_saved)
|
toast(R.string.reminder_saved)
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
|
@ -98,11 +98,11 @@ class SettingsActivity : SimpleActivity() {
|
||||||
var value = mins
|
var value = mins
|
||||||
if (mins == 0) {
|
if (mins == 0) {
|
||||||
custom_reminder_other_period.setSelection(0)
|
custom_reminder_other_period.setSelection(0)
|
||||||
} else if (mins % Constants.DAY_MINS == 0) {
|
} else if (mins % DAY_MINS == 0) {
|
||||||
value = mins / Constants.DAY_MINS
|
value = mins / DAY_MINS
|
||||||
custom_reminder_other_period.setSelection(2)
|
custom_reminder_other_period.setSelection(2)
|
||||||
} else if (mins % Constants.HOUR_MINS == 0) {
|
} else if (mins % HOUR_MINS == 0) {
|
||||||
value = mins / Constants.HOUR_MINS
|
value = mins / HOUR_MINS
|
||||||
custom_reminder_other_period.setSelection(1)
|
custom_reminder_other_period.setSelection(1)
|
||||||
} else {
|
} else {
|
||||||
custom_reminder_other_period.setSelection(0)
|
custom_reminder_other_period.setSelection(0)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.SeekBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
||||||
import com.simplemobiletools.calendar.models.Day
|
import com.simplemobiletools.calendar.models.Day
|
||||||
|
@ -141,8 +142,8 @@ class WidgetConfigureActivity : AppCompatActivity(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTextColors() {
|
private fun updateTextColors() {
|
||||||
mTextColor = Utils.adjustAlpha(mTextColorWithoutTransparency, HIGH_ALPHA)
|
mTextColor = mTextColorWithoutTransparency.adjustAlpha(HIGH_ALPHA)
|
||||||
mWeakTextColor = Utils.adjustAlpha(mTextColorWithoutTransparency, LOW_ALPHA)
|
mWeakTextColor = mTextColorWithoutTransparency.adjustAlpha(LOW_ALPHA)
|
||||||
|
|
||||||
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||||
top_right_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
top_right_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||||
|
@ -153,7 +154,7 @@ class WidgetConfigureActivity : AppCompatActivity(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBgColor() {
|
private fun updateBgColor() {
|
||||||
mBgColor = Utils.adjustAlpha(mBgColorWithoutTransparency, mBgAlpha)
|
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||||
config_calendar.setBackgroundColor(mBgColor)
|
config_calendar.setBackgroundColor(mBgColor)
|
||||||
config_bg_color.setBackgroundColor(mBgColor)
|
config_bg_color.setBackgroundColor(mBgColor)
|
||||||
config_save.setBackgroundColor(mBgColor)
|
config_save.setBackgroundColor(mBgColor)
|
||||||
|
|
|
@ -5,8 +5,8 @@ import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter
|
import android.support.v4.app.FragmentStatePagerAdapter
|
||||||
import android.util.SparseArray
|
import android.util.SparseArray
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
|
||||||
import com.simplemobiletools.calendar.fragments.DayFragment
|
import com.simplemobiletools.calendar.fragments.DayFragment
|
||||||
|
import com.simplemobiletools.calendar.helpers.DAY_CODE
|
||||||
|
|
||||||
class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, private val mListener: DayFragment.DeleteListener) :
|
class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, private val mListener: DayFragment.DeleteListener) :
|
||||||
FragmentStatePagerAdapter(fm) {
|
FragmentStatePagerAdapter(fm) {
|
||||||
|
@ -21,7 +21,7 @@ class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, p
|
||||||
override fun getItem(position: Int): Fragment {
|
override fun getItem(position: Int): Fragment {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
val code = mCodes[position]
|
val code = mCodes[position]
|
||||||
bundle.putString(Constants.DAY_CODE, code)
|
bundle.putString(DAY_CODE, code)
|
||||||
|
|
||||||
if (fragments.get(position) != null)
|
if (fragments.get(position) != null)
|
||||||
return fragments[position]
|
return fragments[position]
|
||||||
|
|
|
@ -4,21 +4,18 @@ import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter
|
import android.support.v4.app.FragmentStatePagerAdapter
|
||||||
|
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
|
||||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
|
||||||
import com.simplemobiletools.calendar.fragments.MonthFragment
|
import com.simplemobiletools.calendar.fragments.MonthFragment
|
||||||
|
import com.simplemobiletools.calendar.helpers.DAY_CODE
|
||||||
|
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||||
|
|
||||||
class MyMonthPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) {
|
class MyMonthPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) {
|
||||||
|
|
||||||
override fun getCount(): Int {
|
override fun getCount() = mCodes.size
|
||||||
return mCodes.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItem(position: Int): Fragment {
|
override fun getItem(position: Int): Fragment {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
val code = mCodes[position]
|
val code = mCodes[position]
|
||||||
bundle.putString(Constants.DAY_CODE, code)
|
bundle.putString(DAY_CODE, code)
|
||||||
|
|
||||||
val fragment = MonthFragment()
|
val fragment = MonthFragment()
|
||||||
fragment.arguments = bundle
|
fragment.arguments = bundle
|
||||||
|
|
|
@ -4,8 +4,8 @@ import android.os.Bundle
|
||||||
import android.support.v4.app.Fragment
|
import android.support.v4.app.Fragment
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v4.app.FragmentStatePagerAdapter
|
import android.support.v4.app.FragmentStatePagerAdapter
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
|
||||||
import com.simplemobiletools.calendar.fragments.YearFragment
|
import com.simplemobiletools.calendar.fragments.YearFragment
|
||||||
|
import com.simplemobiletools.calendar.helpers.YEAR_LABEL
|
||||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||||
|
|
||||||
class MyYearPagerAdapter(fm: FragmentManager, private val mYears: List<Int>, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) {
|
class MyYearPagerAdapter(fm: FragmentManager, private val mYears: List<Int>, private val mListener: NavigationListener) : FragmentStatePagerAdapter(fm) {
|
||||||
|
@ -15,7 +15,7 @@ class MyYearPagerAdapter(fm: FragmentManager, private val mYears: List<Int>, pri
|
||||||
override fun getItem(position: Int): Fragment {
|
override fun getItem(position: Int): Fragment {
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
val year = mYears[position]
|
val year = mYears[position]
|
||||||
bundle.putInt(Constants.YEAR_LABEL, year)
|
bundle.putInt(YEAR_LABEL, year)
|
||||||
|
|
||||||
val fragment = YearFragment()
|
val fragment = YearFragment()
|
||||||
fragment.arguments = bundle
|
fragment.arguments = bundle
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.simplemobiletools.calendar.extensions
|
||||||
|
|
||||||
|
import android.graphics.Color
|
||||||
|
|
||||||
|
fun Int.adjustAlpha(factor: Float): Int {
|
||||||
|
val alpha = Math.round(Color.alpha(this) * factor)
|
||||||
|
val red = Color.red(this)
|
||||||
|
val green = Color.green(this)
|
||||||
|
val blue = Color.blue(this)
|
||||||
|
return Color.argb(alpha, red, green, blue)
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ import android.widget.RelativeLayout
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.activities.EventActivity
|
import com.simplemobiletools.calendar.activities.EventActivity
|
||||||
import com.simplemobiletools.calendar.adapters.EventsAdapter
|
import com.simplemobiletools.calendar.adapters.EventsAdapter
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.extensions.updateWidget
|
import com.simplemobiletools.calendar.extensions.updateWidget
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.helpers.Formatter
|
import com.simplemobiletools.calendar.helpers.Formatter
|
||||||
|
@ -68,7 +69,7 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
|
||||||
|
|
||||||
private fun setupButtons() {
|
private fun setupButtons() {
|
||||||
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
||||||
mTextColor = Utils.adjustAlpha(baseColor, HIGH_ALPHA)
|
mTextColor = baseColor.adjustAlpha(HIGH_ALPHA)
|
||||||
|
|
||||||
mHolder.apply {
|
mHolder.apply {
|
||||||
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.*
|
||||||
import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.activities.DayActivity
|
import com.simplemobiletools.calendar.activities.DayActivity
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
import com.simplemobiletools.calendar.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.calendar.helpers.*
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
||||||
|
@ -92,10 +93,10 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
|
|
||||||
private fun setupButtons() {
|
private fun setupButtons() {
|
||||||
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
val baseColor = if (mConfig.isDarkTheme) Color.WHITE else Color.BLACK
|
||||||
mTextColor = Utils.adjustAlpha(baseColor, HIGH_ALPHA)
|
mTextColor = baseColor.adjustAlpha(HIGH_ALPHA)
|
||||||
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), HIGH_ALPHA)
|
mTextColorWithEvent = mRes.getColor(R.color.colorPrimary).adjustAlpha(HIGH_ALPHA)
|
||||||
mWeakTextColor = Utils.adjustAlpha(baseColor, LOW_ALPHA)
|
mWeakTextColor = baseColor.adjustAlpha(LOW_ALPHA)
|
||||||
mWeakTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), LOW_ALPHA)
|
mWeakTextColorWithEvent = mRes.getColor(R.color.colorPrimary).adjustAlpha(LOW_ALPHA)
|
||||||
|
|
||||||
mHolder.apply {
|
mHolder.apply {
|
||||||
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
|
||||||
|
@ -149,7 +150,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLabels() {
|
private fun setupLabels() {
|
||||||
val letters = Utils.letterIDs
|
val letters = letterIDs
|
||||||
|
|
||||||
for (i in 0..6) {
|
for (i in 0..6) {
|
||||||
val dayTV = mHolder.findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName)) as TextView
|
val dayTV = mHolder.findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName)) as TextView
|
||||||
|
|
|
@ -10,9 +10,9 @@ import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.YearlyCalendarImpl
|
import com.simplemobiletools.calendar.YearlyCalendarImpl
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.helpers.Config
|
import com.simplemobiletools.calendar.helpers.Config
|
||||||
import com.simplemobiletools.calendar.helpers.HIGH_ALPHA
|
import com.simplemobiletools.calendar.helpers.HIGH_ALPHA
|
||||||
import com.simplemobiletools.calendar.helpers.Utils
|
|
||||||
import com.simplemobiletools.calendar.helpers.YEAR_LABEL
|
import com.simplemobiletools.calendar.helpers.YEAR_LABEL
|
||||||
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
import com.simplemobiletools.calendar.interfaces.NavigationListener
|
||||||
import com.simplemobiletools.calendar.interfaces.YearlyCalendar
|
import com.simplemobiletools.calendar.interfaces.YearlyCalendar
|
||||||
|
@ -75,7 +75,7 @@ class YearFragment : Fragment(), YearlyCalendar {
|
||||||
val now = DateTime()
|
val now = DateTime()
|
||||||
if (now.year == mYear) {
|
if (now.year == mYear) {
|
||||||
val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) as TextView
|
val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) as TextView
|
||||||
monthLabel.setTextColor(Utils.adjustAlpha(res.getColor(R.color.colorPrimary), HIGH_ALPHA))
|
monthLabel.setTextColor(res.getColor(R.color.colorPrimary).adjustAlpha(HIGH_ALPHA))
|
||||||
|
|
||||||
val monthView = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}", "id", activity.packageName)) as SmallMonthView
|
val monthView = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}", "id", activity.packageName)) as SmallMonthView
|
||||||
monthView.setTodaysId(now.dayOfMonth)
|
monthView.setTodaysId(now.dayOfMonth)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.simplemobiletools.calendar.helpers
|
package com.simplemobiletools.calendar.helpers
|
||||||
|
|
||||||
|
import com.simplemobiletools.calendar.R
|
||||||
|
|
||||||
val LOW_ALPHA = .2f
|
val LOW_ALPHA = .2f
|
||||||
val MEDIUM_ALPHA = .6f
|
val MEDIUM_ALPHA = .6f
|
||||||
val HIGH_ALPHA = .8f
|
val HIGH_ALPHA = .8f
|
||||||
|
@ -36,3 +38,6 @@ val REMINDER_TYPE = "reminder_type"
|
||||||
val REMINDER_MINUTES = "reminder_minutes"
|
val REMINDER_MINUTES = "reminder_minutes"
|
||||||
val WIDGET_BG_COLOR = "widget_bg_color"
|
val WIDGET_BG_COLOR = "widget_bg_color"
|
||||||
val WIDGET_TEXT_COLOR = "widget_text_color"
|
val WIDGET_TEXT_COLOR = "widget_text_color"
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.database.sqlite.SQLiteDatabase
|
||||||
import android.database.sqlite.SQLiteOpenHelper
|
import android.database.sqlite.SQLiteOpenHelper
|
||||||
import android.database.sqlite.SQLiteQueryBuilder
|
import android.database.sqlite.SQLiteQueryBuilder
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
|
||||||
import com.simplemobiletools.calendar.extensions.getIntValue
|
import com.simplemobiletools.calendar.extensions.getIntValue
|
||||||
import com.simplemobiletools.calendar.extensions.getStringValue
|
import com.simplemobiletools.calendar.extensions.getStringValue
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
|
@ -116,11 +115,11 @@ class DBHelper(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_V
|
||||||
put(COL_REPEAT_START, event.startTS)
|
put(COL_REPEAT_START, event.startTS)
|
||||||
put(COL_REPEAT_INTERVAL, repeatInterval)
|
put(COL_REPEAT_INTERVAL, repeatInterval)
|
||||||
|
|
||||||
if (repeatInterval == Constants.MONTH || repeatInterval == Constants.YEAR) {
|
if (repeatInterval == MONTH || repeatInterval == YEAR) {
|
||||||
put(COL_REPEAT_DAY, dateTime.dayOfMonth)
|
put(COL_REPEAT_DAY, dateTime.dayOfMonth)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repeatInterval == Constants.YEAR) {
|
if (repeatInterval == YEAR) {
|
||||||
put(COL_REPEAT_MONTH, dateTime.monthOfYear)
|
put(COL_REPEAT_MONTH, dateTime.monthOfYear)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.appwidget.AppWidgetProvider
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
|
@ -17,6 +16,7 @@ import com.simplemobiletools.calendar.MonthlyCalendarImpl
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.activities.DayActivity
|
import com.simplemobiletools.calendar.activities.DayActivity
|
||||||
import com.simplemobiletools.calendar.activities.MainActivity
|
import com.simplemobiletools.calendar.activities.MainActivity
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
|
||||||
import com.simplemobiletools.calendar.models.Day
|
import com.simplemobiletools.calendar.models.Day
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
@ -51,8 +51,8 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
|
||||||
|
|
||||||
val prefs = initPrefs(context)
|
val prefs = initPrefs(context)
|
||||||
val storedTextColor = prefs.getInt(WIDGET_TEXT_COLOR, Color.WHITE)
|
val storedTextColor = prefs.getInt(WIDGET_TEXT_COLOR, Color.WHITE)
|
||||||
mTextColor = Utils.adjustAlpha(storedTextColor, HIGH_ALPHA)
|
mTextColor = storedTextColor.adjustAlpha(HIGH_ALPHA)
|
||||||
mWeakTextColor = Utils.adjustAlpha(storedTextColor, LOW_ALPHA)
|
mWeakTextColor = storedTextColor.adjustAlpha(LOW_ALPHA)
|
||||||
|
|
||||||
mDayTextSize = mRes.getDimension(R.dimen.day_text_size) / mRes.displayMetrics.density
|
mDayTextSize = mRes.getDimension(R.dimen.day_text_size) / mRes.displayMetrics.density
|
||||||
mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.displayMetrics.density
|
mTodayTextSize = mRes.getDimension(R.dimen.today_text_size) / mRes.displayMetrics.density
|
||||||
|
@ -181,7 +181,7 @@ class MyWidgetProvider : AppWidgetProvider(), MonthlyCalendar {
|
||||||
private fun updateLabelColor() {
|
private fun updateLabelColor() {
|
||||||
val mSundayFirst = Config.newInstance(mContext).isSundayFirst
|
val mSundayFirst = Config.newInstance(mContext).isSundayFirst
|
||||||
val packageName = mContext.packageName
|
val packageName = mContext.packageName
|
||||||
val letters = Utils.letterIDs
|
val letters = letterIDs
|
||||||
for (i in 0..6) {
|
for (i in 0..6) {
|
||||||
val id = mRes.getIdentifier("label_" + i, "id", packageName)
|
val id = mRes.getIdentifier("label_" + i, "id", packageName)
|
||||||
mRemoteViews.setInt(id, "setTextColor", mTextColor)
|
mRemoteViews.setInt(id, "setTextColor", mTextColor)
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.simplemobiletools.calendar.helpers
|
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import com.simplemobiletools.calendar.R
|
|
||||||
|
|
||||||
object Utils {
|
|
||||||
fun adjustAlpha(color: Int, factor: Float): Int {
|
|
||||||
val alpha = Math.round(Color.alpha(color) * factor)
|
|
||||||
val red = Color.red(color)
|
|
||||||
val green = Color.green(color)
|
|
||||||
val blue = Color.blue(color)
|
|
||||||
return Color.argb(alpha, red, green, blue)
|
|
||||||
}
|
|
||||||
|
|
||||||
val letterIDs: IntArray
|
|
||||||
get() = 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)
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.simplemobiletools.calendar.models
|
package com.simplemobiletools.calendar.models
|
||||||
|
|
||||||
import com.simplemobiletools.calendar.helpers.Constants
|
import com.simplemobiletools.calendar.helpers.*
|
||||||
import com.simplemobiletools.calendar.helpers.Formatter
|
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
|
@ -18,10 +17,10 @@ class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title
|
||||||
val currStart = Formatter.getDateTimeFromTS(startTS)
|
val currStart = Formatter.getDateTimeFromTS(startTS)
|
||||||
val newStart: DateTime
|
val newStart: DateTime
|
||||||
newStart = when (repeatInterval) {
|
newStart = when (repeatInterval) {
|
||||||
Constants.DAY -> currStart.plusDays(1)
|
DAY -> currStart.plusDays(1)
|
||||||
Constants.WEEK -> currStart.plusWeeks(1)
|
WEEK -> currStart.plusWeeks(1)
|
||||||
Constants.BIWEEK -> currStart.plusWeeks(2)
|
BIWEEK -> currStart.plusWeeks(2)
|
||||||
Constants.MONTH -> currStart.plusMonths(1)
|
MONTH -> currStart.plusMonths(1)
|
||||||
else -> currStart.plusYears(1)
|
else -> currStart.plusYears(1)
|
||||||
}
|
}
|
||||||
val newStartTS = (newStart.millis / 1000).toInt()
|
val newStartTS = (newStart.millis / 1000).toInt()
|
||||||
|
|
|
@ -7,9 +7,9 @@ import android.graphics.Paint
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
|
import com.simplemobiletools.calendar.extensions.adjustAlpha
|
||||||
import com.simplemobiletools.calendar.helpers.Config
|
import com.simplemobiletools.calendar.helpers.Config
|
||||||
import com.simplemobiletools.calendar.helpers.MEDIUM_ALPHA
|
import com.simplemobiletools.calendar.helpers.MEDIUM_ALPHA
|
||||||
import com.simplemobiletools.calendar.helpers.Utils
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
|
class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(context, attrs, defStyle) {
|
||||||
|
@ -58,8 +58,8 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
||||||
}
|
}
|
||||||
|
|
||||||
val baseColor = if (Config.newInstance(context).isDarkTheme) Color.WHITE else Color.BLACK
|
val baseColor = if (Config.newInstance(context).isDarkTheme) Color.WHITE else Color.BLACK
|
||||||
mTextColor = Utils.adjustAlpha(baseColor, MEDIUM_ALPHA)
|
mTextColor = baseColor.adjustAlpha(MEDIUM_ALPHA)
|
||||||
mColoredTextColor = Utils.adjustAlpha(resources.getColor(R.color.colorPrimary), MEDIUM_ALPHA)
|
mColoredTextColor = resources.getColor(R.color.colorPrimary).adjustAlpha(MEDIUM_ALPHA)
|
||||||
|
|
||||||
mPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
mPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
color = mTextColor
|
color = mTextColor
|
||||||
|
|
Loading…
Reference in a new issue