allow setting when to start and end the day at weekly view

This commit is contained in:
tibbi 2017-01-20 23:36:48 +01:00
parent 606e227bad
commit 7b6c4dde34
16 changed files with 153 additions and 1 deletions

View File

@ -32,7 +32,7 @@ android {
}
dependencies {
compile 'com.simplemobiletools:commons:2.4.3'
compile 'com.simplemobiletools:commons:2.4.4'
compile 'joda-time:joda-time:2.9.1'
compile 'com.facebook.stetho:stetho:1.4.1'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'

View File

@ -8,6 +8,7 @@ import android.os.Bundle
import android.os.Parcelable
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.helpers.*
@ -27,6 +28,8 @@ class SettingsActivity : SimpleActivity() {
setupCustomizeColors()
setupSundayFirst()
setupWeeklyStart()
setupWeeklyEnd()
setupWeekNumbers()
setupVibrate()
setupReminderSound()
@ -48,6 +51,46 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupWeeklyStart() {
settings_start_weekly_at.apply {
adapter = getWeeklyAdapter()
setSelection(config.startWeeklyAt)
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
if (selectedItemPosition >= config.endWeeklyAt) {
toast(R.string.day_end_before_start)
setSelection(config.startWeeklyAt)
} else {
config.startWeeklyAt = selectedItemPosition
}
}
override fun onNothingSelected(parent: AdapterView<*>?) {
}
}
}
}
private fun setupWeeklyEnd() {
settings_end_weekly_at.apply {
adapter = getWeeklyAdapter()
setSelection(config.endWeeklyAt)
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
if (selectedItemPosition <= config.startWeeklyAt) {
toast(R.string.day_end_before_start)
setSelection(config.endWeeklyAt)
} else {
config.endWeeklyAt = selectedItemPosition
}
}
override fun onNothingSelected(parent: AdapterView<*>?) {
}
}
}
}
private fun setupWeekNumbers() {
settings_week_numbers.isChecked = config.displayWeekNumbers
settings_week_numbers_holder.setOnClickListener {
@ -160,6 +203,15 @@ class SettingsActivity : SimpleActivity() {
custom_reminder_value.setText(value.toString())
}
private fun getWeeklyAdapter(): ArrayAdapter<String> {
val adapter = ArrayAdapter<String>(this, android.R.layout.simple_spinner_item)
for (i in 0..24) {
adapter.add("$i:00")
}
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
return adapter
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
if (resultCode == Activity.RESULT_OK && requestCode == GET_RINGTONE_URI) {
val uri = resultData?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)

View File

@ -21,6 +21,14 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(WEEK_NUMBERS, false)
set(displayWeekNumbers) = prefs.edit().putBoolean(WEEK_NUMBERS, displayWeekNumbers).apply()
var startWeeklyAt: Int
get() = prefs.getInt(START_WEEKLY_AT, 7)
set(startWeeklyAt) = prefs.edit().putInt(START_WEEKLY_AT, startWeeklyAt).apply()
var endWeeklyAt: Int
get() = prefs.getInt(END_WEEKLY_AT, 24)
set(endWeeklyAt) = prefs.edit().putInt(END_WEEKLY_AT, endWeeklyAt).apply()
var vibrateOnReminder: Boolean
get() = prefs.getBoolean(VIBRATE, false)
set(vibrate) = prefs.edit().putBoolean(VIBRATE, vibrate).apply()

View File

@ -31,6 +31,8 @@ val DAY_MINS = 1440
// Shared Preferences
val SUNDAY_FIRST = "sunday_first"
val WEEK_NUMBERS = "week_numbers"
val START_WEEKLY_AT = "start_weekly_at"
val END_WEEKLY_AT = "end_weekly_at"
val VIBRATE = "vibrate"
val REMINDER_SOUND = "reminder_sound"
val VIEW = "view"

View File

@ -50,6 +50,62 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_start_weekly_at_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/medium_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_start_weekly_at_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/start_weekly_at"/>
<com.simplemobiletools.commons.views.MyAppCompatSpinner
android:id="@+id/settings_start_weekly_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_end_weekly_at_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/medium_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_end_weekly_at_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/end_weekly_at"/>
<com.simplemobiletools.commons.views.MyAppCompatSpinner
android:id="@+id/settings_end_weekly_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_week_numbers_holder"
android:layout_width="match_parent"
@ -164,6 +220,7 @@
android:id="@+id/custom_reminder_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginLeft="@dimen/activity_margin"
android:layout_marginStart="@dimen/activity_margin"
android:digits="0123456789"

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Sonntag als erster Wochentag</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Zeige Kalenderwoche an</string>
<string name="vibrate">Vibration ein bei Errinerung</string>
<string name="reminder_sound">Erinnerungs Ton</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Benachrichtigungs Ton</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 Termin gelöscht</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Domingo como primer día</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Mostrar los números de la semana</string>
<string name="vibrate">Vibrate on reminder notification</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 evento borrado</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Dimanche en premier jour</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Afficher les numéros de semaine</string>
<string name="vibrate">Vibrer à la notification de rappel</string>
<string name="reminder_sound">Son de rappel</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Son de notification</string>
<string name="no_ringtone_picker">Aucune application capable de configurer la sonnerie trouvée</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 événement supprimé</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">रविवार पहला दिन हैं</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">सफ्ताह क्रमांक दिखाए</string>
<string name="vibrate">Vibrate on reminder notification</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 इवेंट डिलीट किया गया</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Vasárnap a hét első napja</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Hetek sorszámának mutatása</string>
<string name="vibrate">Emlékeztetőnél rezgés</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 bejegyzés törölve</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Sunday as first day</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Show week numbers in monthy view</string>
<string name="vibrate">Vibrate on reminder notification</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 evento eliminato</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">日曜日が最初</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">週番号を表示</string>
<string name="vibrate">リマインダー通知で振動</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 イベントを削除しました</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Domingo como primeiro dia</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Mostrar número das semanas</string>
<string name="vibrate">Vibrar ao notificar sobre o lembrete</string>
<string name="reminder_sound">Som do lembrete</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Som da notificação</string>
<string name="no_ringtone_picker">Não foi encontrada qualquer aplicação capaz de definir o som</string>
<string name="no_ringtone_selected">Nenhum</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 evento apagado</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Воскресенье - начало недели</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Отображать номера недель</string>
<string name="vibrate">Вибрация при напоминании</string>
<string name="reminder_sound">Звук напоминания</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Звук уведомления</string>
<string name="no_ringtone_picker">Не найдено приложение для выбора рингтона</string>
<string name="no_ringtone_selected">Нет</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 событие удалено</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Sunday as first day</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Show week numbers in monthy view</string>
<string name="vibrate">Vibrate on reminder notification</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 händelse borttagen</item>

View File

@ -54,6 +54,8 @@
<!-- Settings -->
<string name="sunday_first">Sunday as first day</string>
<string name="start_weekly_at">Start weekly view day at</string>
<string name="end_weekly_at">End weekly view day at</string>
<string name="week_numbers">Show week numbers in monthy view</string>
<string name="vibrate">Vibrate on reminder notification</string>
<string name="reminder_sound">Reminder sound</string>
@ -62,6 +64,7 @@
<string name="notification_sound">Notification sound</string>
<string name="no_ringtone_picker">No app capable of setting ringtone found</string>
<string name="no_ringtone_selected">None</string>
<string name="day_end_before_start">The day cannot end earlier than it starts</string>
<plurals name="events_deleted">
<item quantity="one">1 event deleted</item>