private async void ImageDoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
        {
            if (sender != null && !string.IsNullOrEmpty(ViewModel.TranslationFile))
            {
                if (!await FileUtils.HaveAyaPositionFile())
                {
                    await ViewModel.DownloadAyahPositionFile();
                }

                var cachedImage = sender as CachedImage;
                if (cachedImage == null)
                {
                    return;
                }

                var ayah = await CachedImage.GetAyahFromGesture(e.GetPosition(cachedImage.Image),
                                                                ViewModel.CurrentPageNumber,
                                                                cachedImage.ActualWidth);

                var currentPage = ViewModel.CurrentPage;
                if (currentPage != null)
                {
                    ViewModel.SelectedAyah = ayah;
                    if (await ViewModel.HasTranslationFile())
                    {
                        ViewModel.ShowTranslation = !ViewModel.ShowTranslation;
                        SettingsUtils.Set(Constants.PREF_SHOW_TRANSLATION, ViewModel.ShowTranslation);
                    }
                }
            }
        }
        public async void Delete()
        {
            if (await FileUtils.FileExists(LocalPath))
            {
                try
                {
                    await FileUtils.SafeFileDelete(LocalPath);
                }
                catch (Exception ex)
                {
                    QuranApp.NativeProvider.Log("error deleting file " + LocalPath);
                    telemetry.TrackException(ex, new Dictionary <string, string> {
                        { "Scenario", "DeletingTranslationFile" }
                    });
                }
            }
            else
            {
                // Sometimes downloaded translation is kind of corrupted, need a way to delete this
                // corrupted item.
            }

            if (DeleteComplete != null)
            {
                DeleteComplete(this, null);
            }

            if (SettingsUtils.Get <string>(Constants.PREF_ACTIVE_TRANSLATION).StartsWith(Path.GetFileName(LocalPath),
                                                                                         StringComparison.Ordinal))
            {
                SettingsUtils.Set <string>(Constants.PREF_ACTIVE_TRANSLATION, string.Empty);
            }
        }
Example #3
0
        public async void Delete()
        {
            if (await FileUtils.DirectoryExists(BaseFolder, this.LocalFolderName))
            {
                try
                {
                    await FileUtils.DeleteFolder(BaseFolder, this.LocalFolderName);
                }
                catch (Exception ex)
                {
                    QuranApp.NativeProvider.Log("error deleting file " + this.LocalFolderName);
                    telemetry.TrackException(ex, new Dictionary <string, string> {
                        { "Scenario", "DeletingReciterFile" }
                    });
                }
            }
            else
            {
                // Sometimes downloaded translation is kind of corrupted, need a way to delete this
                // corrupted item.
            }

            if (DeleteComplete != null)
            {
                DeleteComplete(this, null);
            }

            if (SettingsUtils.Get <string>(Constants.PREF_ACTIVE_QARI) == this.Name)
            {
                SettingsUtils.Set <string>(Constants.PREF_ACTIVE_QARI, string.Empty);
            }
        }
Example #4
0
        private async Task ShowWelcomeMessage()
        {
            var versionFromConfig   = new Version(SettingsUtils.Get <string>(Constants.PREF_CURRENT_VERSION));
            var nameHelper          = SystemInfo.ApplicationName;
            var versionFromAssembly = new Version(SystemInfo.ApplicationVersion);

            if (versionFromAssembly > versionFromConfig)
            {
                var message =
                    @"Assalamu Aleikum,

Thank you for downloading Quran Windows. Please note that this is a BETA release and is still work in progress (especially audio support). 
New in Version 1.3.0:
* Added persistence of state to the main view
* Improved Arabic text above translation
* Updated Arabic localization by Saeed Hubaishan
* Added 'bismillah' to translations
* Misc. fixes and improvements

If you find any issues with the app or would like to provide suggestions, please use Contact Us option available via the menu. 

Jazzakum Allahu Kheiran,
Quran Windows Team";
                await QuranApp.NativeProvider.ShowInfoMessageBox(message, "Welcome");

                SettingsUtils.Set(Constants.PREF_CURRENT_VERSION, versionFromAssembly.ToString());
            }
        }
Example #5
0
        private async Task LoadCurrentPage()
        {
            await LoadPage(CurrentPage);

            if (CurrentPageIndex - 1 > 0)
            {
                LoadPage(Pages[CurrentPageIndex - 1]);
            }

            if (CurrentPageIndex + 1 < Pages.Count)
            {
                LoadPage(Pages[CurrentPageIndex + 1]);
            }

            var pageNumber = GetPageNumberFromIndex(CurrentPageIndex);

            CurrentSurahName   = QuranUtils.GetSurahNameFromPage(pageNumber, false);
            CurrentSurahNumber = QuranUtils.GetSurahNumberFromPage(pageNumber);
            var rub = QuranUtils.GetRub3FromPage(pageNumber);

            CurrentJuzName = string.Format("{0} {1}{2} {3} {4}", QuranUtils.GetJuzTitle(),
                                           QuranUtils.GetJuzFromPage(pageNumber),
                                           getJuzPart(rub), Resources.quran_rub3, rub + 1);
            CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);

            if (!IsLoading)
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, pageNumber);
            }
        }
        private async void TranslationClick()
        {
            int pageNumber = ViewModel.CurrentPageNumber;

            if (await ViewModel.HasTranslationFile())
            {
                ViewModel.ShowTranslation = !ViewModel.ShowTranslation;
                SettingsUtils.Set(Constants.PREF_SHOW_TRANSLATION, ViewModel.ShowTranslation);
            }
            else
            {
                Frame.Navigate(typeof(TranslationListView), null, new DrillInNavigationTransitionInfo());
            }
        }
Example #7
0
        private void NavigateLink(object sender, TappedRoutedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            var list = sender as ListView;

            if (e.OriginalSource == null || !(e.OriginalSource is FrameworkElement))
            {
                return;
            }

            var selectedItem = ((FrameworkElement)e.OriginalSource).DataContext as ItemViewModel;

            if (selectedItem == null)
            {
                return;
            }

            try
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, selectedItem.PageNumber);

                // Navigate to the new page
                if (selectedItem.SelectedAyah == null)
                {
                    Frame.Navigate(typeof(DetailsView));
                }
                else
                {
                    Frame.Navigate(typeof(DetailsView),
                                   new NavigationData
                    {
                        Surah = selectedItem.SelectedAyah.Surah,
                        Ayah  = selectedItem.SelectedAyah.Ayah
                    });
                }
            }
            catch (Exception ex)
            {
                telemetry.TrackException(ex, new Dictionary <string, string> {
                    { "Scenario", "NavigateFromMainView" }
                });
                // Navigation exception - ignore
            }

            // Reset selected item to null (no selection)
            list.SelectedItem = null;
        }
        private void NavigationBackRequested(object sender, TappedRoutedEventArgs e)
        {
            var list = sender as FrameworkElement;

            if (list == null || list.DataContext == null)
            {
                return;
            }

            var qari = (ObservableReciterItem)list.DataContext;

            if (qari == null)
            {
                return;
            }

            SettingsUtils.Set(Constants.PREF_ACTIVE_QARI, qari.Name);
            Frame.GoBack();
        }
Example #9
0
        private async Task LoadCurrentPage()
        {
            var tempCurrentPageIndex = CurrentPageIndex;
            var _currentPage         = GetPageFromIndex(tempCurrentPageIndex);

            if (_currentPage == null)
            {
                return;
            }

            await _currentPage.Load(this.TranslationFile, _bismillahTranslation);

            var pageNumber = GetPageNumberFromIndex(tempCurrentPageIndex);

            CurrentSurahName   = QuranUtils.GetSurahNameFromPage(pageNumber, false);
            CurrentSurahNumber = QuranUtils.GetSurahNumberFromPage(pageNumber);
            var rub = QuranUtils.GetRub3FromPage(pageNumber);

            CurrentJuzName = string.Format("{0} {1}{2} {3} {4}", QuranUtils.GetJuzTitle(),
                                           QuranUtils.GetJuzFromPage(pageNumber),
                                           getJuzPart(rub), Resources.quran_rub3, rub + 1);
            CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(pageNumber);

            // Load previous and next pages
            var _previousPage = GetPageFromIndex(tempCurrentPageIndex - 1);

            if (_previousPage != null)
            {
                await _previousPage.Load(this.TranslationFile, _bismillahTranslation);
            }
            var _nextPage = GetPageFromIndex(tempCurrentPageIndex + 1);

            if (_nextPage != null)
            {
                await _nextPage.Load(this.TranslationFile, _bismillahTranslation);
            }

            if (!IsLoading)
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, pageNumber);
            }
        }
        private async void ListViewDoubleTap(object sender, RoutedEventArgs e)
        {
            if (e.OriginalSource != null && e.OriginalSource is FrameworkElement)
            {
                if (!await FileUtils.HaveAyaPositionFile())
                {
                    await ViewModel.DownloadAyahPositionFile();
                }

                var selectedVerse = ((FrameworkElement)e.OriginalSource).DataContext as VerseViewModel;
                if (selectedVerse != null)
                {
                    ViewModel.SelectedAyah = new QuranAyah(selectedVerse.Surah, selectedVerse.Ayah);
                }

                if (await ViewModel.HasTranslationFile())
                {
                    ViewModel.ShowTranslation = !ViewModel.ShowTranslation;
                    SettingsUtils.Set(Constants.PREF_SHOW_TRANSLATION, ViewModel.ShowTranslation);
                }
            }
        }
Example #11
0
 // Build a localized ApplicationBar
 private void BuildLocalizedMenu()
 {
     NavigationLinks.Add(new NavigationLink
     {
         Label  = Quran.Core.Properties.Resources.search,
         Symbol = Symbol.Find,
         Action = () => { MainPivot.SelectedItem = SearchPivotItem; }
     });
     NavigationLinks.Add(new NavigationLink
     {
         Label  = Quran.Core.Properties.Resources.go_to,
         Symbol = Symbol.NewWindow,
         Action = async() =>
         {
             JumpContentDialog dialog = new JumpContentDialog();
             await dialog.ShowAsync();
             if (dialog.Page != null)
             {
                 SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, dialog.Page.Value);
                 NavigationData navData = null;
                 if (dialog.Ayah != null)
                 {
                     navData = new NavigationData
                     {
                         Surah = dialog.Ayah.Surah,
                         Ayah  = dialog.Ayah.Ayah
                     };
                 }
                 Frame.Navigate(typeof(DetailsView), navData);
             }
         }
     });
     NavigationLinks.Add(new NavigationLink
     {
         Label  = Quran.Core.Properties.Resources.contact_us,
         Symbol = Symbol.MailForward,
         Action = () => { QuranApp.NativeProvider.LaunchWebBrowser("https://github.com/stankovski/quran-phone/issues"); }
     });
 }
        private void NavigationRequested(object sender, TappedRoutedEventArgs e)
        {
            var list = sender as FrameworkElement;

            if (list == null || list.DataContext == null)
            {
                return;
            }

            var translation = (ObservableTranslationItem)list.DataContext;

            if (translation == null)
            {
                return;
            }

            if (translation.Exists)
            {
                SettingsUtils.Set(Constants.PREF_ACTIVE_TRANSLATION, string.Join("|",
                                                                                 Path.GetFileName(translation.LocalPath), translation.Name));
                SettingsUtils.Set(Constants.PREF_SHOW_TRANSLATION, true);
                Frame.GoBack();
            }
        }
 public void SaveSettings()
 {
     SettingsUtils.Set(Constants.PREF_TRANSLATION_TEXT_SIZE, TextSize);
     SettingsUtils.Set(Constants.PREF_ARABIC_TEXT_SIZE, ArabicTextSize);
 }