Ejemplo n.º 1
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Activity activity = getActivity();
    if (activity instanceof PagerActivity) {
      final PagerActivity pagerActivity = (PagerActivity) activity;

      downloadImage();

      handler.postDelayed(
          () -> new QueryPageCoordinatesTask(pagerActivity).execute(pageNumber), 1000);

      if (QuranSettings.getInstance(activity).shouldHighlightBookmarks()) {
        // Observable.timer by default runs on Schedulers.computation()
        compositeDisposable.add(
            Completable.timer(250, TimeUnit.MILLISECONDS)
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribeWith(
                    new DisposableCompletableObserver() {
                      @Override
                      public void onComplete() {
                        highlightTagsTask();
                      }

                      @Override
                      public void onError(Throwable e) {}
                    }));
      }
    }
  }
 @Override
 public void onPageFlipEnd(QuranPageCurlView pageView, int flipDirection) {
   if (flipDirection == OnPageFlipListener.NEXT_PAGE) {
     loadNextPage(pageView);
   } else if (flipDirection == OnPageFlipListener.PREVIOUS_PAGE) {
     loadPreviousPage(pageView);
   }
   QuranSettings.getInstance().setLastPage(mCurrentPageNumber);
   QuranSettings.save(mContext.prefs);
 }
Ejemplo n.º 3
0
 private BookmarkPresenter(Context context) {
   mAppContext = context.getApplicationContext();
   mQuranSettings = QuranSettings.getInstance(context);
   mBookmarkModel = BookmarkModel.getInstance(context);
   mSortOrder = mQuranSettings.getBookmarksSortOrder();
   mGroupByTags = mQuranSettings.getBookmarksGroupedByTags();
   try {
     mArabicDatabaseUtils = ArabicDatabaseUtils.getInstance(context);
   } catch (Exception e) {
     mArabicDatabaseUtils = null;
   }
   subscribeToChanges();
 }
Ejemplo n.º 4
0
  public void updateView(boolean nightMode, boolean useNewBackground, int pagesVisible) {
    if (rightGradient == null || gradientForNumberOfPages != pagesVisible) {
      final WindowManager mgr =
          (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
      Display display = mgr.getDefaultDisplay();
      int width =
          Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
              ? QuranDisplayHelper.getWidthKitKat(display)
              : display.getWidth();
      width = width / pagesVisible;
      leftGradient = QuranDisplayHelper.getPaintDrawable(width, 0);
      rightGradient = QuranDisplayHelper.getPaintDrawable(0, width);
      gradientForNumberOfPages = pagesVisible;
    }

    isNightMode = nightMode;
    int lineColor = Color.BLACK;
    final int nightModeTextBrightness =
        nightMode
            ? QuranSettings.getInstance(context).getNightModeTextBrightness()
            : Constants.DEFAULT_NIGHT_MODE_TEXT_BRIGHTNESS;
    if (nightMode) {
      lineColor = Color.argb(nightModeTextBrightness, 255, 255, 255);
    }

    if (pageNumber % 2 == 0) {
      leftBorder = nightMode ? BorderMode.DARK : BorderMode.LIGHT;
      rightBorder = BorderMode.HIDDEN;
    } else {
      rightBorder = nightMode ? BorderMode.DARK : BorderMode.LIGHT;
      if (QuranPageLayout.lineColor != lineColor) {
        QuranPageLayout.lineColor = lineColor;
        lineDrawable.getPaint().setColor(lineColor);
      }
      leftBorder = BorderMode.LINE;
    }
    setContentNightMode(nightMode, nightModeTextBrightness);

    if (nightMode) {
      setBackgroundColor(Color.BLACK);
    } else if (useNewBackground) {
      setBackgroundDrawable((pageNumber % 2 == 0 ? leftGradient : rightGradient));
    } else {
      setBackgroundColor(ContextCompat.getColor(context, R.color.page_background));
    }

    if (errorText != null) {
      updateErrorTextColor();
    }
  }
Ejemplo n.º 5
0
  public static String getLocalizedNumber(Context context, int number) {
    if (QuranSettings.getInstance(context).isArabicNames()) {
      if (mNumberFormatter == null || !mIsArabicFormatter) {
        mIsArabicFormatter = true;
        mNumberFormatter = DecimalFormat.getIntegerInstance(new Locale("ar"));
      }
    } else {
      if (mNumberFormatter == null || mIsArabicFormatter) {
        mIsArabicFormatter = false;
        mNumberFormatter = DecimalFormat.getIntegerInstance();
      }
    }

    return mNumberFormatter.format(number);
  }
 public void highlightAyah(int sura, int ayah) {
   View v = mQuranPage.getCurrentPage();
   HighlightingImageView iv = (HighlightingImageView) v.findViewById(R.id.page_image);
   if (iv != null) {
     HighlightingImageView hi = (HighlightingImageView) iv;
     hi.highlightAyah(sura, ayah);
     if (QuranSettings.getInstance().isAutoScroll()
         && v.getResources().getConfiguration().orientation
             == Configuration.ORIENTATION_LANDSCAPE) {
       AyahBounds yBounds = hi.getYBoundsForCurrentHighlight();
       if (yBounds != null) mQuranPage.scrollToAyah(R.id.page_scroller, yBounds);
     }
     mQuranPage.invalidate();
   }
 }
Ejemplo n.º 7
0
  @Override
  public void updateView() {
    Context context = getActivity();
    if (context == null || !isAdded()) {
      return;
    }

    final QuranSettings settings = QuranSettings.getInstance(context);
    final boolean useNewBackground = settings.useNewBackground();
    final boolean isNightMode = settings.isNightMode();
    overlayText = settings.shouldOverlayPageInfo();
    mQuranPageLayout.updateView(isNightMode, useNewBackground, 1);
    if (!settings.highlightBookmarks()) {
      mImageView.unHighlight(HighlightType.BOOKMARK);
    }
  }
    public void run() {
      ImageView iv = (ImageView) v.findViewById(R.id.page_image);
      if (bitmap == null) {
        Log.d(TAG, "Page not found: " + index);
        updateViewForUser(v, false, true);
      } else {
        iv.setImageBitmap(bitmap);
        mQuranPage.refresh();
        updateViewForUser(v, false, false);
        if (QuranSettings.getInstance().isDisplayMarkerPopup()) displayMarkerPopup();
      }

      // clear for GC
      iv = null;
      bitmap = null;
      v = null;
    }
  protected void updateViewForUser(View v, boolean loading, boolean pageNotFound) {
    TextView tv = (TextView) v.findViewById(R.id.txtPageNotFound);
    HighlightingImageView iv = (HighlightingImageView) v.findViewById(R.id.page_image);

    if ((loading) || (pageNotFound)) {
      if (QuranSettings.getInstance().isNightMode()) {
        tv.setTextColor(Color.WHITE);
      }
      tv.setText(loading ? R.string.pageLoading : R.string.pageNotFound);
      if (!loading && mHasBeenOutOfMemory != null && mHasBeenOutOfMemory)
        tv.setText(R.string.couldNotLoadPage);
      tv.setVisibility(View.VISIBLE);
      iv.setVisibility(View.GONE);
    } else {
      iv.adjustNightMode();
      tv.setVisibility(View.GONE);
      iv.setVisibility(View.VISIBLE);
    }
  }
 public void jumpToPage(int page) {
   if (page <= ApplicationConstants.PAGES_FIRST) {
     page = ApplicationConstants.PAGES_FIRST;
     mQuranPage.addNextPage(null);
     mQuranPage.addNextPage(createPage(page));
     mQuranPage.addNextPage(createPage(page + 1));
   } else if (page >= ApplicationConstants.PAGES_LAST) {
     page = ApplicationConstants.PAGES_LAST;
     mQuranPage.addPreviousPage(null);
     mQuranPage.addPreviousPage(createPage(page));
     mQuranPage.addPreviousPage(createPage(page - 1));
   } else {
     mQuranPage.addNextPage(createPage(page - 1));
     mQuranPage.addNextPage(createPage(page));
     mQuranPage.addNextPage(createPage(page + 1));
   }
   mCurrentPageNumber = page;
   QuranSettings.getInstance().setLastPage(page);
   QuranSettings.save(mContext.prefs);
   mQuranPage.refresh(true);
 }
Ejemplo n.º 11
0
  @WorkerThread
  public static String getDebugInfo(Context context) {
    StringBuilder builder = new StringBuilder();
    builder.append("Android SDK Version: ").append(Build.VERSION.SDK_INT);
    String location = QuranSettings.getInstance(context).getAppCustomLocation();
    builder.append("\nApp Location:").append(location);
    try {
      File file = new File(location);
      builder
          .append("\n App Location Directory ")
          .append(file.exists() ? "exists" : "doesn't exist")
          .append("\n   Image zip files:");
      String[] list = file.list();
      for (String fileName : list) {
        if (fileName.contains("images_")) {
          File f = new File(fileName);
          builder.append("\n   file: ").append(fileName).append("\tlength: ").append(f.length());
        }
      }
    } catch (Exception e) {
      builder.append("Exception trying to list files").append(e);
    }

    QuranScreenInfo info = QuranScreenInfo.getInstance();
    if (info != null) {
      builder.append("\nDisplay: ").append(info.getWidthParam());
      if (info.isTablet(context)) {
        builder.append(", tablet width: ").append(info.getWidthParam());
      }
      builder.append("\n");
    }

    int memClass =
        ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    builder.append("memory class: ").append(memClass).append("\n\n");
    return builder.toString();
  }