private static QuranAyah GetLastAyahToPlayForSura(QuranAyah startAyah) { int surah = startAyah.Surah; int lastAyah = QuranUtils.GetSurahNumberOfAyah(surah); return(new QuranAyah(surah, lastAyah)); }
public static async Task <HashSet <string> > GetMissingFiles(QuranAudioTrack request) { HashSet <string> missingFiles = new HashSet <string>(); var reciter = request.GetReciter(); var baseDirectory = await request.GetReciter().GetStorageFolder(); if (await ShouldDownloadBismillah(baseDirectory, request)) { missingFiles.Add(BismillahFile); } var fileQuery = baseDirectory.CreateFileQueryWithOptions(new QueryOptions { UserSearchFilter = string.Format(CultureInfo.InvariantCulture, "{0:000}*.mp3", request.Surah), FolderDepth = FolderDepth.Shallow }); if ((uint)QuranUtils.GetSurahNumberOfAyah(request.Surah) != await fileQuery.GetItemCountAsync()) { var existingFiles = new HashSet <string>((await fileQuery.GetFilesAsync()).Select(f => f.Name)); for (int i = 1; i <= QuranUtils.GetSurahNumberOfAyah(request.Surah); i++) { var fileName = GetFileName(new QuranAyah(request.Surah, i), reciter); if (!existingFiles.Contains(fileName)) { missingFiles.Add(fileName); } } } return(missingFiles); }
public static int[] GetPreviousAyah(int[] currentAyah, bool includeBismillah) { var newAyah = new[] { currentAyah[0], currentAyah[1] }; // Check if not the beginning of surah if (currentAyah[1] > 1) { newAyah[1]--; } else { // If need to include bismillah and not surah Tawba set currentAyah to 0 if (currentAyah[1] == 1 && includeBismillah && newAyah[0] != Constants.SURA_TAWBA && newAyah[0] != Constants.SURA_FIRST) { newAyah[1] = 0; } else { // If the beginning of surah check if also the beginning of Quran if (currentAyah[0] > Constants.SURA_FIRST) { newAyah[0]--; } else { newAyah[0] = Constants.SURA_LAST; } newAyah[1] = QuranUtils.GetSurahNumberOfAyah(newAyah[0]); } } return(newAyah); }
public static int[] GetNextAyah(int[] currentAyah, bool includeBismillah) { var currentSurahPages = QuranUtils.GetSurahNumberOfAyah(currentAyah[0]); var newAyah = new[] { currentAyah[0], currentAyah[1] }; // Check if not the end of surah if (currentAyah[1] < currentSurahPages) { newAyah[1]++; } else { // If the end of surah check if also the end of Quran if (currentAyah[0] < Constants.SURA_LAST) { newAyah[0]++; } else { newAyah[0] = Constants.SURA_FIRST; } // If need to include bismillah and not surah Tawba set currentAyah to 0 if (includeBismillah && newAyah[0] != Constants.SURA_TAWBA && newAyah[0] != Constants.SURA_FIRST) { newAyah[1] = 0; } else { newAyah[1] = 1; } } return(newAyah); }
public static string GetNotificationTitle(QuranAyah minVerse, QuranAyah maxVerse) { int minSura = minVerse.Surah; int maxSura = maxVerse.Surah; int maxAyah = maxVerse.Ayah; if (maxAyah == 0) { maxSura--; maxAyah = QuranUtils.GetSurahNumberOfAyah(maxSura); } string notificationTitle = QuranUtils.GetSurahName(minSura, true); if (minSura == maxSura) { if (minVerse.Ayah == maxAyah) { notificationTitle += " (" + maxAyah + ")"; } else { notificationTitle += " (" + minVerse.Ayah + "-" + maxAyah + ")"; } } else { notificationTitle += " (" + minVerse.Ayah + ") - " + QuranUtils.GetSurahName(maxSura, true) + " (" + maxAyah + ")"; } return(notificationTitle); }