Merge pull request #1445 from KryptKode/feat/weekly-view-slider-setting
Add settings option for weekly view day count visibility
This commit is contained in:
commit
1088660b80
|
@ -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_customize_day_count.isChecked = config.allowCustomizeDayCount
|
||||
settings_allow_customize_day_count_holder.setOnClickListener {
|
||||
settings_allow_customize_day_count.toggle()
|
||||
config.allowCustomizeDayCount = settings_allow_customize_day_count.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupWeekNumbers() {
|
||||
settings_week_numbers.isChecked = config.showWeekNumbers
|
||||
settings_week_numbers_holder.setOnClickListener {
|
||||
|
|
|
@ -59,6 +59,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
return weekHolder
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
context?.config?.allowCustomizeDayCount?.let { allow ->
|
||||
weekHolder!!.week_view_days_count.beVisibleIf(allow)
|
||||
weekHolder!!.week_view_seekbar.beVisibleIf(allow)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFragment() {
|
||||
val weekTSs = getWeekTimestamps(currentWeekTS)
|
||||
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
|
||||
|
@ -109,9 +117,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
|
|||
|
||||
// avoid seekbar width changing if the days count changes to 1, 10 etc
|
||||
weekHolder!!.week_view_days_count.onGlobalLayout {
|
||||
if (weekHolder!!.week_view_seekbar.isVisible()) {
|
||||
weekHolder!!.week_view_seekbar.layoutParams.width = weekHolder!!.week_view_seekbar.width
|
||||
(weekHolder!!.week_view_seekbar.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.START_OF)
|
||||
}
|
||||
}
|
||||
|
||||
updateDaysCount(context?.config?.weeklyViewDays ?: 7)
|
||||
updateActionBarTitle()
|
||||
|
|
|
@ -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 allowCustomizeDayCount: Boolean
|
||||
get() = prefs.getBoolean(ALLOW_CUSTOMIZE_DAY_COUNT, true)
|
||||
set(allow) = prefs.edit().putBoolean(ALLOW_CUSTOMIZE_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_CUSTOMIZE_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_customize_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_customize_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"
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
layout="@layout/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_above="@+id/week_view_seekbar" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MySeekBar
|
||||
|
|
Loading…
Reference in New Issue