Esempio n. 1
0
 private QuranRow createRow(Activity activity, long tagId, Bookmark bookmark) {
   QuranRow row;
   if (bookmark.mSura == null) {
     int sura = QuranInfo.getSuraNumberFromPage(bookmark.mPage);
     row =
         new QuranRow(
             QuranInfo.getSuraNameString(activity, bookmark.mPage),
             QuranInfo.getPageSubtitle(activity, bookmark.mPage),
             QuranRow.PAGE_BOOKMARK,
             sura,
             bookmark.mPage,
             R.drawable.bookmark_page);
   } else {
     row =
         new QuranRow(
             QuranInfo.getAyahString(bookmark.mSura, bookmark.mAyah, getActivity()),
             QuranInfo.getPageSubtitle(activity, bookmark.mPage),
             QuranRow.AYAH_BOOKMARK,
             bookmark.mSura,
             bookmark.mAyah,
             bookmark.mPage,
             R.drawable.bookmark_ayah);
   }
   row.tagId = tagId;
   row.bookmarkId = bookmark.mId;
   return row;
 }
Esempio n. 2
0
 @Override
 protected void onPostExecute(RectF[] rect) {
   if (rect != null && rect.length == 1 && isAdded()) {
     mImageView.setPageBounds(rect[0]);
     if (overlayText) {
       int page = pageNumber;
       Context context = getContext();
       String suraText = QuranInfo.getSuraNameFromPage(context, page, true);
       String juzText = QuranInfo.getJuzString(context, page);
       String pageText = QuranUtils.getLocalizedNumber(context, page);
       String rub3Text = QuranDisplayHelper.displayRub3(context, page);
       mImageView.setOverlayText(suraText, juzText, pageText, rub3Text);
     }
   }
 }
 @Override
 protected void onPostExecute(String ayah) {
   Activity activity = getActivity();
   if (ayah != null && activity != null) {
     ayah =
         "("
             + ayah
             + ")"
             + " "
             + "["
             + QuranInfo.getSuraName(activity, this.sura, true)
             + " : "
             + this.ayah
             + "]"
             + activity.getString(R.string.via_string);
     if (copy) {
       ClipboardManager cm =
           (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
       cm.setText(ayah);
       Toast.makeText(
               activity, activity.getString(R.string.ayah_copied_popup), Toast.LENGTH_SHORT)
           .show();
     } else {
       final Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(Intent.EXTRA_TEXT, ayah);
       startActivity(Intent.createChooser(intent, activity.getString(R.string.share_ayah)));
     }
   }
   mCurrentTask = null;
 }
  public void displayMarkerPopup() {
    if (System.currentTimeMillis() - lastPopupTime < 3000) return;
    int rub3 = QuranInfo.getRub3FromPage(mCurrentPageNumber);
    if (rub3 == -1) return;
    int hizb = (rub3 / 4) + 1;
    StringBuilder sb = new StringBuilder();

    if (rub3 % 8 == 0) {
      sb.append(mContext.getString(R.string.quran_juz2)).append(' ').append((hizb / 2) + 1);
    } else {
      int remainder = rub3 % 4;
      if (remainder == 1) sb.append(mContext.getString(R.string.quran_rob3)).append(' ');
      else if (remainder == 2) sb.append(mContext.getString(R.string.quran_nos)).append(' ');
      else if (remainder == 3) sb.append(mContext.getString(R.string.quran_talt_arb3)).append(' ');
      sb.append(mContext.getString(R.string.quran_hizb)).append(' ').append(hizb);
    }
    Toast.makeText(mContext, ArabicStyle.reshape(sb.toString()), Toast.LENGTH_SHORT).show();
    lastPopupTime = System.currentTimeMillis();
  }
  private void showAyahMenu(final int sura, final int ayah, final int page, boolean bookmarked) {
    final Activity activity = getActivity();
    if (activity == null) {
      return;
    }

    int[] optionIds = {
      bookmarked ? R.string.unbookmark_ayah : R.string.bookmark_ayah,
      R.string.tag_ayah,
      R.string.translation_ayah,
      R.string.share_ayah,
      R.string.share_ayah_text,
      R.string.copy_ayah,
      R.string.play_from_here
      /*, R.string.ayah_notes*/ }; // TODO Enable notes
    CharSequence[] options = new CharSequence[optionIds.length];
    for (int i = 0; i < optionIds.length; i++) {
      options[i] = activity.getString(optionIds[i]);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(QuranInfo.getAyahString(sura, ayah, activity));
    builder
        .setItems(
            options,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int selection) {
                if (selection == 0) {
                  if (activity != null && activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    pagerActivity.toggleBookmark(sura, ayah, page);
                  }
                } else if (selection == 1) {
                  if (activity != null && activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    FragmentManager fm = pagerActivity.getSupportFragmentManager();
                    TagBookmarkDialog tagBookmarkDialog = new TagBookmarkDialog(sura, ayah, page);
                    tagBookmarkDialog.show(fm, TagBookmarkDialog.TAG);
                  }
                } else if (selection == 2) {
                  mCurrentTask = new ShowTafsirTask(sura, ayah).execute();
                } else if (selection == 3) {
                  mCurrentTask = new ShareQuranApp().execute(sura, ayah);
                } else if (selection == 4) {
                  mCurrentTask = new ShareAyahTask(sura, ayah, false).execute();
                } else if (selection == 5) {
                  mCurrentTask = new ShareAyahTask(sura, ayah, true).execute();
                } else if (selection == 6) {
                  if (activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    pagerActivity.playFromAyah(mPageNumber, sura, ayah);
                  }
                }
                /* else if (selection == 5) {
                             new ShowNotesTask(sura, ayah).execute();
                } */
              }
            })
        .setOnCancelListener(
            new DialogInterface.OnCancelListener() {
              @Override
              public void onCancel(DialogInterface dialogInterface) {
                dialogInterface.dismiss();
                mTranslationDialog = null;
              }
            });

    mTranslationDialog = builder.create();
    mTranslationDialog.show();
  }