mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-01-31 10:44:52 +01:00
adding some settings to the Timer tab
This commit is contained in:
parent
a043529ddf
commit
3fb0d57527
@ -6,6 +6,7 @@ import android.support.v7.app.AlertDialog
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.activities.SimpleActivity
|
import com.simplemobiletools.clock.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.clock.extensions.colorLeftDrawable
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.clock.extensions.dbHelper
|
import com.simplemobiletools.clock.extensions.dbHelper
|
||||||
import com.simplemobiletools.clock.extensions.formatAlarmTime
|
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()
|
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.text = alarm.soundTitle
|
||||||
edit_alarm_sound.setOnClickListener {
|
edit_alarm_sound.setOnClickListener {
|
||||||
SelectAlarmSoundDialog(activity, alarm.soundUri) {
|
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.isChecked = alarm.vibrate
|
||||||
edit_alarm_vibrate_holder.setOnClickListener {
|
edit_alarm_vibrate_holder.setOnClickListener {
|
||||||
edit_alarm_vibrate.toggle()
|
edit_alarm_vibrate.toggle()
|
||||||
@ -110,12 +111,6 @@ class EditAlarmDialog(val activity: SimpleActivity, val alarm: Alarm, val callba
|
|||||||
callback()
|
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 {
|
private fun getProperDayDrawable(selected: Boolean): Drawable {
|
||||||
val drawableId = if (selected) R.drawable.circle_background_filled else R.drawable.circle_background_stroke
|
val drawableId = if (selected) R.drawable.circle_background_filled else R.drawable.circle_background_stroke
|
||||||
val drawable = activity.resources.getDrawable(drawableId)
|
val drawable = activity.resources.getDrawable(drawableId)
|
||||||
|
@ -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)
|
||||||
|
}
|
@ -9,6 +9,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
|
import com.simplemobiletools.clock.extensions.colorLeftDrawable
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import kotlinx.android.synthetic.main.fragment_timer.view.*
|
import kotlinx.android.synthetic.main.fragment_timer.view.*
|
||||||
@ -38,6 +39,18 @@ class TimerFragment : Fragment() {
|
|||||||
timer_reset.setOnClickListener {
|
timer_reset.setOnClickListener {
|
||||||
resetTimer()
|
resetTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer_initial_time.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_vibrate_holder.setOnClickListener {
|
||||||
|
timer_vibrate.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_sound.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initialSecs = context!!.config.lastTimerSeconds
|
initialSecs = context!!.config.lastTimerSeconds
|
||||||
@ -57,10 +70,14 @@ class TimerFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupViews() {
|
private fun setupViews() {
|
||||||
|
val textColor = context!!.config.textColor
|
||||||
view.apply {
|
view.apply {
|
||||||
context!!.updateTextColors(timer_fragment)
|
context!!.updateTextColors(timer_fragment)
|
||||||
timer_play_pause.background = resources.getColoredDrawableWithColor(R.drawable.circle_background_filled, context!!.getAdjustedPrimaryColor())
|
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()
|
updateIcons()
|
||||||
|
@ -21,6 +21,52 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="00:00"/>
|
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
|
<ImageView
|
||||||
android:id="@+id/timer_reset"
|
android:id="@+id/timer_reset"
|
||||||
style="@style/MyBorderlessBackgroundStyle"
|
style="@style/MyBorderlessBackgroundStyle"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user