Skip to content

Commit

Permalink
SonicOPT
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalsonic committed Jan 7, 2025
1 parent fc53ffd commit 5808ea2
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 67 deletions.
47 changes: 39 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ val prayerTimeManager = PrayerTimeManager()
---

### Fetching Prayer Times

Prayer times are calculated based on the provided latitude, longitude, high latitude adjustment, Asr juristic method, prayer time convention, and time format.

- **Manual Corrections**: You can adjust prayer times manually within a range of -59 to +59 minutes. If the adjustment exceeds this range, it defaults to 0 (no correction).
- **Custom Angles**: When the `PrayerTimeConvention` is set to CUSTOM, you can define specific angles for Fajr and Isha prayers. The default custom angles are:
- **Fajr**: 9.0°
- **Isha**: 14.0°

By utilizing these features, you can calculate accurate and tailored prayer times for any location and customize them to meet your specific needs.


#### Fetch Today Prayer Times
```kotlin
prayerTimeManager.fetchTodayPrayerTimes(
Expand All @@ -87,7 +96,9 @@ prayerTimeManager.fetchTodayPrayerTimes(
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
asrJuristicMethod = AsrJuristicMethod.HANAFI,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0, zuhrMinute = 0, asrMinute = 0, maghribMinute = 0, ishaMinute = 2),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { prayerItem ->
val date = Date(prayerItem.date)
Expand All @@ -109,7 +120,9 @@ prayerTimeManager.fetchCurrentMonthPrayerTimes(
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
asrJuristicMethod = AsrJuristicMethod.HANAFI,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0, zuhrMinute = 0, asrMinute = 0, maghribMinute = 0, ishaMinute = 2),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { prayerItems ->
prayerItems.forEachIndexed { index, prayerItem ->
Expand All @@ -133,7 +146,9 @@ prayerTimeManager.fetchCurrentYearPrayerTimes(
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
asrJuristicMethod = AsrJuristicMethod.HANAFI,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0, zuhrMinute = 0, asrMinute = 0, maghribMinute = 0, ishaMinute = 2),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { prayerItems ->
prayerItems.forEachIndexed { monthIndex, monthlyPrayerItems ->
Expand All @@ -154,9 +169,19 @@ prayerTimeManager.fetchCurrentYearPrayerTimes(

---


## Fetching Fasting Times
Fasting times are calculated based on Fajr and Maghrib prayers, Sehri ends at Fajr start time, and Iftar begins at Maghrib time. To calculate these times, provide the latitude, longitude, high latitude adjustment, and prayer time convention.

Fasting times are calculated based on the Fajr and Maghrib prayer times. Sehri ends at the start time of the Fajr prayer, and Iftar begins at the start time of the Maghrib prayer. To calculate these times, provide the latitude, longitude, high latitude adjustment, and prayer time convention.

- **Fasting Times**:
- **Sehri (Pre-Dawn Meal)**: Ends at the start time of the Fajr prayer.
- **Iftar (Breaking Fast)**: Begins at the start time of the Maghrib prayer.

- **Manual Corrections**: Fasting times can be adjusted using manual corrections within a range of -59 to +59 minutes. If the adjustment exceeds this range, it defaults to 0 (no correction).

- **Custom Angles**: When `PrayerTimeConvention` is set to CUSTOM, specific angles for Fajr and Isha prayers can be defined. The default custom angles are:
- **Fajr**: 9.0°
- **Isha**: 14.0°

#### Fetch Today Fasting Times
```kotlin
Expand All @@ -165,7 +190,9 @@ prayerTimeManager.fetchTodayFastingTimes(
longitude = 73.0722461, // Example longitude (Islamabad, Pakistan)
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingItem ->
val date = Date(fastingItem.date)
Expand All @@ -184,7 +211,9 @@ prayerTimeManager.fetchCurrentMonthFastingTimes(
longitude = 73.0722461, // Example longitude (Islamabad, Pakistan)
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingTimes ->
fastingTimes.forEachIndexed { index, fastingItem ->
Expand All @@ -204,7 +233,9 @@ prayerTimeManager.fetchCurrentYearFastingTimes(
longitude = 73.0722461, // Example longitude (Islamabad, Pakistan)
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingTimes ->
fastingTimes.forEachIndexed { monthIndex, monthlyFastingList ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -47,17 +48,28 @@ class DailyFastingTimeFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

/**
* Fetch current yearly fasting times.
* Fasting times are calculated based on Fajr and Maghrib prayers,
* Sehri ends at Fajr start time, and Iftar begins at Maghrib time.
* Fetch today's fasting times.
*
* - **Fasting Times**: Fasting times are derived from the Fajr and Maghrib prayer times.
* - **Sehri (Pre-Dawn Meal)**: Ends at the start time of the Fajr prayer.
* - **Iftar (Breaking Fast)**: Begins at the start time of the Maghrib prayer.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchTodayFastingTimes(
latitude = latitude,
longitude = longitude,
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0)
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingItem ->
val formattedDate = dateFormatter.format(Date(fastingItem.date))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -47,17 +48,28 @@ class MonthlyFastingTimeFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

/**
* Fetch current yearly fasting times.
* Fasting times are calculated based on Fajr and Maghrib prayers,
* Sehri ends at Fajr start time, and Iftar begins at Maghrib time.
* Fetch current month fasting times.
*
* - **Fasting Times**: Fasting times are derived from the Fajr and Maghrib prayer times.
* - **Sehri (Pre-Dawn Meal)**: Ends at the start time of the Fajr prayer.
* - **Iftar (Breaking Fast)**: Begins at the start time of the Maghrib prayer.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchCurrentMonthFastingTimes(
latitude = latitude,
longitude = longitude,
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0)
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingTimes ->
logBuilder.appendLine("----Monthly Fasting Times----")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -47,17 +48,28 @@ class YearlyFastingTimeFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)

/**
* Fetch current yearly fasting times.
* Fasting times are calculated based on Fajr and Maghrib prayers,
* Sehri ends at Fajr start time, and Iftar begins at Maghrib time.
* Fetch current year fasting times.
*
* - **Fasting Times**: Fasting times are derived from the Fajr and Maghrib prayer times.
* - **Sehri (Pre-Dawn Meal)**: Ends at the start time of the Fajr prayer.
* - **Iftar (Breaking Fast)**: Begins at the start time of the Maghrib prayer.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchCurrentYearFastingTimes(
latitude = latitude,
longitude = longitude,
highLatitudeAdjustment = HighLatitudeAdjustment.NO_ADJUSTMENT,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0)
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0,maghribMinute = 0),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { fastingTimes ->
logBuilder.appendLine("----Yearly Fasting Times----")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -48,9 +49,15 @@ class DailyPrayerTimeFragment : Fragment() {


/**
* Fetch and display daily prayer times
* Only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, set it to 0 (no correction).
* Fetch Today prayer times.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchTodayPrayerTimes(
latitude = latitude,
Expand All @@ -59,13 +66,8 @@ class DailyPrayerTimeFragment : Fragment() {
asrJuristicMethod = AsrJuristicMethod.HANAFI,
prayerTimeConvention = PrayerTimeConvention.KARACHI,
timeFormat = TimeFormat.HOUR_12,
prayerManualCorrection = PrayerManualCorrection(
fajrMinute = 0,
zuhrMinute = 0,
asrMinute = 0,
maghribMinute = 0,
ishaMinute = 2
)
prayerManualCorrection = PrayerManualCorrection(fajrMinute = 0, zuhrMinute = 0, asrMinute = 0, maghribMinute = 0, ishaMinute = 2),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { prayerItem ->
val formattedDate = dateFormatter.format(Date(prayerItem.date))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -46,7 +47,17 @@ class MonthlyPrayerTimeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// Fetch and display monthly prayer times
/**
* Fetch current month prayer times.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchCurrentMonthPrayerTimes(
latitude = latitude,
longitude = longitude,
Expand All @@ -60,7 +71,8 @@ class MonthlyPrayerTimeFragment : Fragment() {
asrMinute = 0,
maghribMinute = 0,
ishaMinute = 0
)
),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { prayerItems ->
logBuilder.appendLine("----Monthly Prayer Times----")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.orbitalsonic.sonicopt.enums.AsrJuristicMethod
import com.orbitalsonic.sonicopt.enums.PrayerTimeConvention
import com.orbitalsonic.sonicopt.enums.TimeFormat
import com.orbitalsonic.sonicopt.manager.PrayerTimeManager
import com.orbitalsonic.sonicopt.models.PrayerCustomAngle
import com.orbitalsonic.sonicopt.models.PrayerManualCorrection
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -46,7 +47,17 @@ class YearlyPrayerTimeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

// Fetch and display yearly prayer times
/**
* Fetch current year prayer times.
*
* - **Manual Corrections**: For `PrayerManualCorrection`, only allow manual corrections within the range of -59 to 59 minutes.
* If the correction is outside this range, it will default to 0 (no correction).
*
* - **Custom Angles**: If `PrayerTimeConvention` is set to CUSTOM, the method will use custom angles for Fajr and Isha prayers.
* The default custom angles are:
* - Fajr: 9.0°
* - Isha: 14.0°
*/
prayerTimeManager.fetchCurrentYearPrayerTimes(
latitude = latitude,
longitude = longitude,
Expand All @@ -60,7 +71,8 @@ class YearlyPrayerTimeFragment : Fragment() {
asrMinute = 0,
maghribMinute = 0,
ishaMinute = 0
)
),
prayerCustomAngle = PrayerCustomAngle(fajrAngle = 9.0, ishaAngle = 14.0)
) { result ->
result.onSuccess { yearlyPrayerItems ->
logBuilder.appendLine("----Yearly Prayer Times----")
Expand Down
Loading

0 comments on commit 5808ea2

Please sign in to comment.