adding some settings to the Timer tab

This commit is contained in:
tibbi 2018-03-08 23:02:15 +01:00
parent a043529ddf
commit 3fb0d57527
4 changed files with 77 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import android.support.v7.app.AlertDialog
import android.widget.TextView
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.activities.SimpleActivity
import com.simplemobiletools.clock.extensions.colorLeftDrawable
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.dbHelper
import com.simplemobiletools.clock.extensions.formatAlarmTime
@ -25,7 +26,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
TimePickerDialog(context, context.getDialogTheme(), timeSetListener, alarm.timeInMinutes / 60, alarm.timeInMinutes % 60, context.config.use24hourFormat).show()
}
colorLeftDrawable(edit_alarm_sound)
edit_alarm_sound.colorLeftDrawable(textColor)
edit_alarm_sound.text = alarm.soundTitle
edit_alarm_sound.setOnClickListener {
SelectAlarmSoundDialog(activity, alarm.soundUri) {
@ -35,7 +36,7 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
}
}
colorLeftDrawable(edit_alarm_vibrate)
edit_alarm_vibrate.colorLeftDrawable(textColor)
edit_alarm_vibrate.isChecked = alarm.vibrate
edit_alarm_vibrate_holder.setOnClickListener {
edit_alarm_vibrate.toggle()
@ -110,12 +111,6 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
callback()
}
private fun colorLeftDrawable(textView: TextView) {
val leftImage = textView.compoundDrawables.first()
leftImage.applyColorFilter(textColor)
textView.setCompoundDrawables(leftImage, null, null, null)
}
private fun getProperDayDrawable(selected: Boolean): Drawable {
val drawableId = if (selected) R.drawable.circle_background_filled else R.drawable.circle_background_stroke
val drawable = activity.resources.getDrawable(drawableId)

View File

@ -0,0 +1,10 @@
package com.simplemobiletools.clock.extensions
import android.widget.TextView
import com.simplemobiletools.commons.extensions.applyColorFilter
fun TextView.colorLeftDrawable(color: Int) {
val leftImage = compoundDrawables.first()
leftImage.applyColorFilter(color)
setCompoundDrawables(leftImage, null, null, null)
}

View File

@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.colorLeftDrawable
import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.fragment_timer.view.*
@ -38,6 +39,18 @@ class TimerFragment : Fragment() {
timer_reset.setOnClickListener {
resetTimer()
}
timer_initial_time.setOnClickListener {
}
timer_vibrate_holder.setOnClickListener {
timer_vibrate.toggle()
}
timer_sound.setOnClickListener {
}
}
initialSecs = context!!.config.lastTimerSeconds
@ -57,10 +70,14 @@ class TimerFragment : Fragment() {
}
private fun setupViews() {
val textColor = context!!.config.textColor
view.apply {
context!!.updateTextColors(timer_fragment)
timer_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, context!!.getAdjustedPrimaryColor())
timer_reset.applyColorFilter(context!!.config.textColor)
timer_reset.applyColorFilter(textColor)
timer_initial_time.colorLeftDrawable(textColor)
timer_vibrate.colorLeftDrawable(textColor)
timer_sound.colorLeftDrawable(textColor)
}
updateIcons()

View File

@ -21,6 +21,52 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="00:00"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/timer_initial_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin"
android:background="?attr/selectableItemBackground"
android:drawableLeft="@drawable/ic_timer"
android:drawablePadding="@dimen/normal_margin"
android:padding="@dimen/activity_margin"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintTop_toBottomOf="@+id/timer_time"
tools:text="05:00"/>
<RelativeLayout
android:id="@+id/timer_vibrate_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/activity_margin"
app:layout_constraintTop_toBottomOf="@+id/timer_initial_time">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/timer_vibrate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:drawableLeft="@drawable/ic_vibrate"
android:drawablePadding="@dimen/normal_margin"
android:text="@string/vibrate"
android:textSize="@dimen/bigger_text_size"/>
</RelativeLayout>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/timer_sound"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:drawableLeft="@drawable/ic_bell"
android:drawablePadding="@dimen/normal_margin"
android:padding="@dimen/activity_margin"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintTop_toBottomOf="@+id/timer_vibrate_holder"
tools:text="Default alarm"/>
<ImageView
android:id="@+id/timer_reset"
style="@style/MyBorderlessBackgroundStyle"