add vibrations on button press at the stopwatch tab
This commit is contained in:
parent
5570de136e
commit
610892230b
4 changed files with 64 additions and 2 deletions
|
@ -41,7 +41,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.15.8'
|
||||
implementation 'com.simplemobiletools:commons:3.15.9'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
}
|
||||
|
|
|
@ -24,13 +24,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupDisplayOtherTimeZones()
|
||||
setupUseSameSnooze()
|
||||
setupSnoozeTime()
|
||||
setupVibrate()
|
||||
updateTextColors(settings_holder)
|
||||
setupSectionColors()
|
||||
}
|
||||
|
||||
private fun setupSectionColors() {
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
arrayListOf(clock_tab_label, alarm_tab_label).forEach {
|
||||
arrayListOf(clock_tab_label, alarm_tab_label, stopwatch_tab_label).forEach {
|
||||
it.setTextColor(adjustedPrimaryColor)
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +104,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupVibrate() {
|
||||
settings_vibrate.isChecked = config.vibrateOnButtonPress
|
||||
settings_vibrate_holder.setOnClickListener {
|
||||
settings_vibrate.toggle()
|
||||
config.vibrateOnButtonPress = settings_vibrate.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSnoozeText() {
|
||||
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
||||
}
|
||||
|
|
|
@ -45,26 +45,32 @@ class StopwatchFragment : Fragment() {
|
|||
view = (inflater.inflate(R.layout.fragment_stopwatch, container, false) as ViewGroup).apply {
|
||||
stopwatch_time.setOnClickListener {
|
||||
togglePlayPause()
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_play_pause.setOnClickListener {
|
||||
togglePlayPause()
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_reset.setOnClickListener {
|
||||
resetStopwatch()
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_1.setOnClickListener {
|
||||
changeSorting(SORT_BY_LAP)
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_2.setOnClickListener {
|
||||
changeSorting(SORT_BY_LAP_TIME)
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_sorting_indicator_3.setOnClickListener {
|
||||
changeSorting(SORT_BY_TOTAL_TIME)
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatch_lap.setOnClickListener {
|
||||
|
@ -73,6 +79,7 @@ class StopwatchFragment : Fragment() {
|
|||
laps.add(0, lap)
|
||||
lapTicks = 0
|
||||
updateLaps()
|
||||
checkHaptic(this)
|
||||
}
|
||||
|
||||
stopwatchAdapter = StopwatchAdapter(activity as SimpleActivity, ArrayList(), stopwatch_list) {
|
||||
|
@ -204,6 +211,12 @@ class StopwatchFragment : Fragment() {
|
|||
stopwatchAdapter.updateItems(laps)
|
||||
}
|
||||
|
||||
private fun checkHaptic(view: View) {
|
||||
if (context!!.config.vibrateOnButtonPress) {
|
||||
view.performHapticFeedback()
|
||||
}
|
||||
}
|
||||
|
||||
private val updateRunnable = object : Runnable {
|
||||
override fun run() {
|
||||
if (isRunning) {
|
||||
|
|
|
@ -241,5 +241,45 @@
|
|||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/stopwatch_tab_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/stopwatch_tab_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/bigger_margin"
|
||||
android:layout_marginStart="@dimen/bigger_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin"
|
||||
android:text="@string/stopwatch_tab"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_vibrate_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_vibrate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/vibrate_on_button_press"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in a new issue