Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implements customizable alarm vibration #613

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class AlarmDetailsFragment : Fragment() {
onCreateRingtoneView()
onCreateDeleteOnDismissView()
onCreatePrealarmView()
onCreateVibrateView()
onCreateBottomView()

if (editedAlarm?.isNew == true) {
Expand Down Expand Up @@ -265,6 +266,23 @@ class AlarmDetailsFragment : Fragment() {
.addTo(disposables)
}

private fun onCreateVibrateView() {
val mVibrateRow by lazy {
fragmentView.findViewById(R.id.details_vibrate_row) as LinearLayout
}

val mVibrateCheckBox by lazy {
fragmentView.findViewById(R.id.details_vibration_checkbox) as CheckBox
}

// pre-alarm
mVibrateRow.setOnClickListener {
modify("Vibrate") { value -> value.copy(isVibrate = !value.isVibrate, isEnabled = true) }
}

observeEditor { value -> mVibrateCheckBox.isChecked = value.isVibrate }
}

private fun onCreateRingtoneView() {
fragmentView.findViewById<LinearLayout>(R.id.details_ringtone_row).setOnClickListener {
editor.takeFirst { value ->
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/res/layout/details_fragment_lower.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,43 @@
</LinearLayout>
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/dividerHorizontal" />

<LinearLayout
android:id="@+id/details_vibrate_row"
android:layout_width="match_parent"
android:layout_height="68dip"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|left"
android:text="@string/vibrate"
android:textColor="?android:attr/textColorPrimary"
android:textAppearance="?android:attr/textAppearanceMedium" />

<LinearLayout
android:layout_width="68dip"
android:layout_height="match_parent"
android:gravity="center">

<CheckBox
android:id="@+id/details_vibration_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false" />

</LinearLayout>
</LinearLayout>


<View
android:layout_width="match_parent"
android:layout_height="1dip"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,5 @@
<string name="app_default_ringtone">App default (%s)</string>
<string name="set_exact_alarm_permission_title">Permission to set exact alarm time</string>
<string name="set_exact_alarm_permission_text">To set an alarm at the exact time, permission to set exact alarm time is required.</string>
<string name="vibrate">Vibrate</string>
</resources>