-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/dismiss alarm #128
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
Open
Just-D-A
wants to merge
8
commits into
develop
Choose a base branch
from
feature/dismiss_alarm
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4beacff
add DismissAlarmIntentBuilder
just-d-aa 2ca14c8
add SearchMode Label
just-d-aa dd8c082
add dismiss alarm feature
just-d-aa 1af5061
add Search Modes
just-d-aa 709f54f
Merge branches 'develop' and 'feature/dismiss_alarm' of https://githu…
just-d-aa 5f3a20b
merge
just-d-aa d06b954
change annotation place
just-d-aa 8fe82e4
change show fun comment
just-d-aa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
core/src/main/java/com/omega_r/libs/omegaintentbuilder/builders/DismissAlarmIntentBuilder.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| package com.omega_r.libs.omegaintentbuilder.builders | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.provider.AlarmClock.* | ||
|
|
||
| class DismissAlarmIntentBuilder : BaseActivityBuilder() { | ||
|
|
||
| private var hour: Int? = null | ||
| private var minute: Int? = null | ||
| private var isPM: Boolean? = null | ||
| private var label: String? = null | ||
| private var next: Boolean? = null | ||
|
|
||
| /** | ||
| * </p><p> | ||
| * The value is an {@link Integer} and ranges from 0 to 23. | ||
| * </p> | ||
| * | ||
| * @param hour Integer | ||
| * @return This DismissAlarmIntentBuilder for method chaining | ||
| */ | ||
| fun hour(hour: Int): DismissAlarmIntentBuilder { | ||
| label = null | ||
| next = null | ||
| this.hour = hour | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * <p> | ||
| * The value is an {@link Integer} and ranges from 0 to 59. If not provided, it defaults to 0. | ||
| * </p> | ||
| * | ||
| * @param minute Integer | ||
| * @return This DismissAlarmIntentBuilder for method chaining | ||
| */ | ||
| fun minute(minute: Int): DismissAlarmIntentBuilder { | ||
| label = null | ||
| next = null | ||
| this.minute = minute | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * <p> | ||
| * The value is an {@link Integer} and ranges from 0 to 59. If not provided, it defaults to 0. | ||
| * </p> | ||
| * | ||
| * @param isPM Integer | ||
| * @return This DismissAlarmIntentBuilder for method chaining | ||
| */ | ||
| fun isPM(isPM: Boolean): DismissAlarmIntentBuilder { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isPm |
||
| label = null | ||
| next = null | ||
| this.isPM = isPM | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * Search alarm by label | ||
| * | ||
| * @param label String | ||
| * @return This DismissAlarmIntentBuilder for method chaining | ||
| */ | ||
| fun label(label: String): DismissAlarmIntentBuilder { | ||
| hour = null | ||
| minute = null | ||
| isPM = null | ||
| next = null | ||
| this.label = label | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * For activate search mode NEXT | ||
| * Search next alarm | ||
| * | ||
| * @return This DismissAlarmIntentBuilder for method chaining | ||
| */ | ||
| fun next(): DismissAlarmIntentBuilder { | ||
| next = true | ||
| return this | ||
| } | ||
|
|
||
| /** | ||
| * <li>If exactly one active alarm exists, it is dismissed. | ||
| * <li>If more than one active alarm exists, the user is prompted to choose the alarm to | ||
| * dismiss. | ||
| */ | ||
| override fun createIntent(context: Context): Intent { | ||
| return Intent(ACTION_DISMISS_ALARM).apply { | ||
| if (hour != null && minute != null && isPM != null) { | ||
| putExtra(EXTRA_ALARM_SEARCH_MODE, ALARM_SEARCH_MODE_TIME) | ||
|
|
||
| hour?.let { | ||
| putExtra(EXTRA_HOUR, it) | ||
| } | ||
|
|
||
| minute?.let { | ||
| putExtra(EXTRA_MINUTES, it) | ||
| } | ||
|
|
||
| isPM?.let { | ||
| putExtra(EXTRA_IS_PM, it) | ||
| } | ||
| } else if (label != null) { | ||
| putExtra(EXTRA_ALARM_SEARCH_MODE, ALARM_SEARCH_MODE_LABEL) | ||
| putExtra(EXTRA_MESSAGE, label) | ||
| } else if (next != null) { | ||
| putExtra(EXTRA_ALARM_SEARCH_MODE, ALARM_SEARCH_MODE_NEXT) | ||
| } else { | ||
| putExtra(EXTRA_ALARM_SEARCH_MODE, ALARM_SEARCH_MODE_ALL) | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alarm(): AlarmIntentBuilder