Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -17,12 +17,12 @@ import android.net.Uri
import android.os.Build
import androidx.annotation.RequiresApi
import com.omega_r.libs.omegaintentbuilder.builders.*
import com.omega_r.libs.omegaintentbuilder.builders.alarm.AlarmBuilder
import com.omega_r.libs.omegaintentbuilder.builders.pick.PickBuilder
import com.omega_r.libs.omegaintentbuilder.builders.share.EmailIntentBuilder
import com.omega_r.libs.omegaintentbuilder.builders.share.ShareIntentBuilder
import com.omega_r.libs.omegaintentbuilder.types.CalendarActionTypes
import com.omega_r.libs.omegaintentbuilder.types.MapTypes
import com.omega_r.libs.omegaintentbuilder.types.ShowType

/**
* OmegaIntentBuilder class for creating supports createdIntent builders.
Expand Down Expand Up @@ -158,28 +158,14 @@ object OmegaIntentBuilder {
fun searchWeb() = SearchWebIntentBuilder()

/**
* @return AlarmIntentBuilder
*/
@JvmStatic
@RequiresApi(Build.VERSION_CODES.KITKAT)
fun createAlarm() = AlarmIntentBuilder()

/**
* @return ShowAlarmsTimersIntentBuilder
*/
@JvmStatic
fun showTimers() = ShowAlarmsTimersIntentBuilder(ShowType.TIMERS)

/**
* @return ShowAlarmsTimersIntentBuilder
* @return VideoRecordBuilder
*/
@JvmStatic
fun showAlarms() = ShowAlarmsTimersIntentBuilder(ShowType.ALARMS)
fun recordVideo() = VideoRecordBuilder()

/**
* @return VideoRecordBuilder
*/
@JvmStatic
fun recordVideo() = VideoRecordBuilder()

fun alarm() = AlarmBuilder
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.omega_r.libs.omegaintentbuilder.builders.alarm

import android.os.Build
import androidx.annotation.RequiresApi

object AlarmBuilder {
/**
* @return CreateAlarmIntentBuilder for creating intent to set alarm
*/
@RequiresApi(Build.VERSION_CODES.KITKAT)
fun create() = CreateAlarmIntentBuilder()

/**
* @return DismissAlarmIntentBuilder for creating intent to dismiss alarm
*/
@RequiresApi(Build.VERSION_CODES.M)
fun dismiss() = DismissAlarmIntentBuilder()

/**
* @return ShowAlarmsIntentBuilder for creating intent to show alarm
*/
@RequiresApi(Build.VERSION_CODES.KITKAT)
fun show() = ShowAlarmsIntentBuilder()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.omega_r.libs.omegaintentbuilder.builders
package com.omega_r.libs.omegaintentbuilder.builders.alarm

import android.content.Context
import android.content.Intent
import android.os.Build
import android.provider.AlarmClock.*
import androidx.annotation.RequiresApi
import com.omega_r.libs.omegaintentbuilder.builders.BaseActivityBuilder

class AlarmIntentBuilder : BaseActivityBuilder() {
class CreateAlarmIntentBuilder : BaseActivityBuilder() {
private var message: String? = null
private var hour: Int? = null
private var minutes: Int? = null
Expand All @@ -22,7 +25,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
* @param message String
* @return This AlarmIntentBuilder for method chaining
*/
fun message(message: String): AlarmIntentBuilder {
fun message(message: String): CreateAlarmIntentBuilder {
this.message = message
return this
}
Expand All @@ -36,7 +39,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
* @param hour String
* @return This AlarmIntentBuilder for method chaining
*/
fun hour(hour: Int): AlarmIntentBuilder {
fun hour(hour: Int): CreateAlarmIntentBuilder {
this.hour = hour
return this
}
Expand All @@ -47,7 +50,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
* @param minutes String
* @return This AlarmIntentBuilder for method chaining
*/
fun minutes(minutes: Int): AlarmIntentBuilder {
fun minutes(minutes: Int): CreateAlarmIntentBuilder {
this.minutes = minutes
return this
}
Expand All @@ -62,7 +65,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
* @param ringtone String
* @return This AlarmIntentBuilder for method chaining
*/
fun ringtone(ringtone: String): AlarmIntentBuilder {
fun ringtone(ringtone: String): CreateAlarmIntentBuilder {
this.ringtone = ringtone
return this
}
Expand All @@ -73,7 +76,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
*
* @return This AlarmIntentBuilder for method chaining
*/
fun skipUI(): AlarmIntentBuilder {
fun skipUI(): CreateAlarmIntentBuilder {
skipUI = true
return this
}
Expand All @@ -86,7 +89,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
* @return This AlarmIntentBuilder for method chaining
*/
@JvmOverloads
fun vibrate(vibrate: Boolean = true): AlarmIntentBuilder {
fun vibrate(vibrate: Boolean = true): CreateAlarmIntentBuilder {
this.vibrate = vibrate
return this
}
Expand All @@ -96,7 +99,7 @@ class AlarmIntentBuilder : BaseActivityBuilder() {
*
* @return This AlarmIntentBuilder for method chaining
*/
fun ringtoneSilent(): AlarmIntentBuilder {
fun ringtoneSilent(): CreateAlarmIntentBuilder {
ringtoneSilent = true
return this
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.omega_r.libs.omegaintentbuilder.builders.alarm

import android.content.Context
import android.content.Intent
import android.provider.AlarmClock.*
import com.omega_r.libs.omegaintentbuilder.builders.BaseActivityBuilder

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 {
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)
}


}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.omega_r.libs.omegaintentbuilder.builders.alarm

import android.content.Context
import android.content.Intent
import android.provider.AlarmClock
import com.omega_r.libs.omegaintentbuilder.builders.BaseActivityBuilder

class ShowAlarmsIntentBuilder() : BaseActivityBuilder() {

override fun createIntent(context: Context): Intent {
return Intent(AlarmClock.ACTION_SHOW_ALARMS)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.button_show_timers).setOnClickListener(this);
findViewById(R.id.button_show_alarms).setOnClickListener(this);
findViewById(R.id.button_record_video).setOnClickListener(this);
findViewById(R.id.button_dismiss_alarm).setOnClickListener(this);
}

@Override
Expand Down Expand Up @@ -121,6 +122,9 @@ public void onClick(View v) {
case R.id.button_record_video:
onRecordVideoClicked();
break;
case R.id.button_dismiss_alarm:
onDismissAlarmClicked();
break;
}
}

Expand Down Expand Up @@ -272,7 +276,8 @@ private void onExtrasToFragmentClicked() {

private void onCreateAlarmClicked() {
OmegaIntentBuilder
.createAlarm()
.alarm()
.create()
.message("It's your alarm")
.hour(15)
.vibrate()
Expand Down Expand Up @@ -326,14 +331,15 @@ private void onCreateTimerClicked() {
}

private void onShowTimersClicked() {
OmegaIntentBuilder
/* OmegaIntentBuilder
.showTimers()
.startActivity(this);
.startActivity(this);*/
}

private void onShowAlarmsClicked() {
OmegaIntentBuilder
.showAlarms()
.alarm()
.show()
.startActivity(this);
}

Expand All @@ -343,4 +349,20 @@ private void onRecordVideoClicked() {
.startActivity(this);
}

private void onDismissAlarmClicked() {
OmegaIntentBuilder
.alarm()
.dismiss()
//BY LABEL
//.label("It's your alarm")
//or BY TIME
//.hour(0)
//.minute(0)
//.isPM(true)
//or DISMISS NEXT
//.next()
//or SEARCH ALL
.startActivity(this);
}

}
7 changes: 7 additions & 0 deletions examples/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
android:theme="@style/ButtonStyle"
android:text="@string/record_video"/>

<Button
android:id="@+id/button_dismiss_alarm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ButtonStyle"
android:text="@string/dismiss_alarm"/>

</LinearLayout>

</androidx.core.widget.NestedScrollView>
1 change: 1 addition & 0 deletions examples/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<string name="show_alarms">Show Alarms</string>
<string name="open_camera_to_record">Open Camera To Record</string>
<string name="record_video">Record Video</string>
<string name="dismiss_alarm">Dismiss Alarm</string>
</resources>