Add settings option for weekly view day count visibility
This commit is contained in:
parent
2f7664c8b7
commit
23f0010a10
5 changed files with 49 additions and 1 deletions
|
@ -57,6 +57,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupShowGrid()
|
||||
setupWeeklyStart()
|
||||
setupMidnightSpanEvents()
|
||||
setupAllowCustomiseDayCount()
|
||||
setupVibrate()
|
||||
setupReminderSound()
|
||||
setupReminderAudioStream()
|
||||
|
@ -349,6 +350,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupAllowCustomiseDayCount() {
|
||||
settings_allow_customise_day_count.isChecked = config.allowCustomiseDayCount
|
||||
settings_allow_customise_day_count_holder.setOnClickListener {
|
||||
settings_allow_customise_day_count.toggle()
|
||||
config.allowCustomiseDayCount = settings_allow_customise_day_count.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupWeekNumbers() {
|
||||
settings_week_numbers.isChecked = config.showWeekNumbers
|
||||
settings_week_numbers_holder.setOnClickListener {
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.simplemobiletools.calendar.pro.R
|
|||
import com.simplemobiletools.calendar.pro.activities.MainActivity
|
||||
import com.simplemobiletools.calendar.pro.adapters.MyWeekPagerAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Config
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.helpers.WEEK_START_DATE_TIME
|
||||
import com.simplemobiletools.calendar.pro.interfaces.WeekFragmentListener
|
||||
|
@ -25,6 +26,9 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.WEEK_SECONDS
|
||||
import com.simplemobiletools.commons.views.MyViewPager
|
||||
import kotlinx.android.synthetic.main.fragment_week_holder.view.*
|
||||
import kotlinx.android.synthetic.main.fragment_week_holder.week_view_days_count
|
||||
import kotlinx.android.synthetic.main.fragment_week_holder.week_view_days_count_divider
|
||||
import kotlinx.android.synthetic.main.fragment_week_holder.week_view_seekbar
|
||||
import org.joda.time.DateTime
|
||||
|
||||
class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
||||
|
@ -38,6 +42,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
private var currentWeekTS = 0L
|
||||
private var isGoToTodayVisible = false
|
||||
private var weekScrollY = 0
|
||||
lateinit var mConfig: Config
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -49,7 +54,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
weekHolder = inflater.inflate(R.layout.fragment_week_holder, container, false) as ViewGroup
|
||||
weekHolder!!.background = ColorDrawable(context!!.config.backgroundColor)
|
||||
|
||||
mConfig = requireContext().config
|
||||
val itemHeight = context!!.getWeeklyViewItemHeight().toInt()
|
||||
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight)
|
||||
|
||||
|
@ -59,6 +64,13 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
return weekHolder
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
week_view_days_count_divider.beVisibleIf(mConfig.allowCustomiseDayCount)
|
||||
week_view_seekbar.beVisibleIf(mConfig.allowCustomiseDayCount)
|
||||
week_view_days_count.beVisibleIf(mConfig.allowCustomiseDayCount)
|
||||
}
|
||||
|
||||
private fun setupFragment() {
|
||||
val weekTSs = getWeekTimestamps(currentWeekTS)
|
||||
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
|
||||
|
|
|
@ -27,6 +27,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get() = prefs.getBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, true)
|
||||
set(midnightSpanning) = prefs.edit().putBoolean(SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP, midnightSpanning).apply()
|
||||
|
||||
var allowCustomiseDayCount: Boolean
|
||||
get() = prefs.getBoolean(ALLOW_CUSTOMISE_DAY_COUNT, true)
|
||||
set(allow) = prefs.edit().putBoolean(ALLOW_CUSTOMISE_DAY_COUNT, allow).apply()
|
||||
|
||||
var vibrateOnReminder: Boolean
|
||||
get() = prefs.getBoolean(VIBRATE, false)
|
||||
set(vibrate) = prefs.edit().putBoolean(VIBRATE, vibrate).apply()
|
||||
|
|
|
@ -46,6 +46,7 @@ const val YEAR = 31536000
|
|||
const val WEEK_NUMBERS = "week_numbers"
|
||||
const val START_WEEKLY_AT = "start_weekly_at"
|
||||
const val SHOW_MIDNIGHT_SPANNING_EVENTS_AT_TOP = "show_midnight_spanning_events_at_top"
|
||||
const val ALLOW_CUSTOMISE_DAY_COUNT = "allow_customise_day_count"
|
||||
const val VIBRATE = "vibrate"
|
||||
const val REMINDER_SOUND_URI = "reminder_sound_uri"
|
||||
const val REMINDER_SOUND_TITLE = "reminder_sound_title"
|
||||
|
|
|
@ -722,6 +722,28 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_allow_customise_day_count_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/normal_margin"
|
||||
android:paddingBottom="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_allow_customise_day_count"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/allow_customizing_day_count" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/monthly_view_label"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue