Skip to content

a customizable library that provides offline prayer times for Android users based on the current date.

License

Notifications You must be signed in to change notification settings

hypersoftdev/OfflinePrayerTimes

Repository files navigation

OfflinePrayerTimes

OfflinePrayerTimes is a powerful, flexible and customizable Offline Prayer Times library used to get current day Prayer Timings.

Gradle Integration

Step A: Add Maven Repository

In your project-level build.gradle or settings.gradle file, add the JitPack repository:

repositories {
    google()
    mavenCentral()
    maven { url "https://jitpack.io" }
}

Step B: Add Dependencies

Next, include the library in your app-level build.gradle file. Replace x.x.x with the latest version

implementation com.github.hypersoftdev:OfflinePrayerTimes:x.x.x'

Implementation

Requirements:

  • Things app must have before starting implementation
    • App must have latitude and longitude value in order to pass these in below code.

Kotlin Example

class MainActivity : AppCompatActivity() {

    private var prayerTimeCoroutine: Job? = null
    private var sharedPrefManager: SharedPrefManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        
        //Use Below Functions
        setPrayerAttributes()
        getTodayPrayerTimes()
		
    }

     private fun setPrayerAttributes() {

        sharedPrefManager = SharedPrefManager(
            getSharedPreferences(
                "prayer_preferences",
                MODE_PRIVATE
            )
        )

        sharedPrefManager?.prayerLatitude = 33.601921.toBits() //Put your own Latitude value here
        sharedPrefManager?.prayerLongitude = 73.038078.toBits() //Put your own Longitude value here

    }

    private fun getTodayPrayerTimes() {

        prayerTimeCoroutine = object : PrayerTimeCoroutine(
            sharedPrefManager!!
        ) {

            override fun onPreExecute() {
                super.onPreExecute()
            }

            override fun onPostExecute(
                prayerTimeList: ArrayList<PrayerTimeModel>?,
                nextDayFajrTime: String?
            ) {
                super.onPostExecute(prayerTimeList, nextDayFajrTime)

                if (!prayerTimeList.isNullOrEmpty() && nextDayFajrTime?.isNotEmpty() == true) {
                    //Write your own logic here
                }

                clearPrayerResources() //Optional
                cancelCoroutine()      //Optional
            }

        }.executeCoroutine()

    }
    
    private fun cancelCoroutine() {
        if (prayerTimeCoroutine != null && prayerTimeCoroutine?.isActive == true) {
            prayerTimeCoroutine?.cancel("coroutineCanceled", null)
        }
        prayerTimeCoroutine = null
    }
    
    //Optional
    override fun onDestroy() {
        cancelCoroutine()
        super.onDestroy()
    }
	
}

Attribute Summary

AttributeFormatDescription
prayerLatitudelongSet latitude (e.g, 33.601921.toBits())
prayerLongitudelongSet longitude (e.g, 73.038078.toBits())
prayerTimeFormatIntSet Prayer Time Format.
1 = 12Hour (Default)
0 = 24Hour
prayerCalMethodIntSet Prayer Calculation Method
0 = JAFARI
1 = University of Islamic Sciences, KARACHI (Default)
2 = Islamic Society of North America (ISNA)
3 = Muslim World League (MWL)
4 = Umm al-Qura, MAKKAH
5 = Egyptian General Authority of Survey
6 = Institute of Geophysics, University of TEHRAN
asrJuristicIntSet Asr Juristic.
1 = Hanfi (Default)
0 = Shafi
prayerHighLatsIntAdjustment for Higher Altitudes areas.
0 = No Adjustment
1 = Middle of Night
2 = 1/7th of Night
3 = Angle/60th of Night (Default)

Features

  • Offline Prayer Times
    • Get All Prayer Timings (Online/Offline).
    • Customizable attributes so user can get accurate prayer times based on their location.
    • Get next day Fajr prayer time in advance to show it to user for better user experience.

Screen Demo

Demo

Acknowledgements

This work would not have been possible without the invaluable contributions of M. Ali Khan. His expertise, dedication, and unwavering support have been instrumental in bringing this project to fruition.

screenshot

We are deeply grateful for M. Ali Khan's involvement and his belief in the importance of this work. His contributions have made a significant impact, and we are honored to have had the opportunity to collaborate with him.

LICENSE

Copyright 2023 Hypersoft Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

a customizable library that provides offline prayer times for Android users based on the current date.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages