Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewing new rub3 permenantly instead of just poping it up #687

Merged
merged 17 commits into from
Oct 4, 2016
Merged

Viewing new rub3 permenantly instead of just poping it up #687

merged 17 commits into from
Oct 4, 2016

Conversation

Ahmed9914
Copy link
Contributor

@Ahmed9914 Ahmed9914 commented Sep 23, 2016

Asalamu 3alaikum,

The current situation:
When the user reaches a new rub3, a toast will pop up showing this rub3 number. If the user took some time reading the current page and wanted to know in which rub3 he was, he has to swipe left and then swipe right to show the toast again and I think that this is not user-friendly.

The suggested change:
There is a space in the top middle of the page, so why we don't show the current rub3 in this space upon reaching it.

Wa jazakum allaho khairan.

}

public void setOverlayText(String suraText, String juzText, String pageText) {
public void setOverlayText(String suraText, String juzText, String pageText,String rub3Text) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space

Copy link
Contributor

@ozbek ozbek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the code style and adhere to the rules used in existing code.

@@ -178,6 +181,7 @@ public void setOverlayText(String suraText, String juzText, String pageText) {
mOverlayParams.suraText = suraText;
mOverlayParams.juzText = juzText;
mOverlayParams.pageText = pageText;
mOverlayParams.rub3Text=rub3Text;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space

canvas.drawText(mOverlayParams.rub3Text,
getWidth() / 2.0f, mOverlayParams.topBaseline,
mOverlayParams.paint);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space: does not seem to align with other lines

@@ -39,6 +39,29 @@ public static Response getQuranPage(OkHttpClient okHttpClient,
return response;
}

// same logic used in displayMarkerPopup method
public static String displayRub3(Context context, int page)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same line as method declaration for opening bracket

@@ -39,6 +39,29 @@ public static Response getQuranPage(OkHttpClient okHttpClient,
return response;
}

// same logic used in displayMarkerPopup method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, for this comment to make sense, displayRub3() needs to come below/after displayMarkerPopup()

@@ -319,16 +320,18 @@ protected void onPostExecute(RectF[] rect) {
if (mRightImageView != null && mLeftImageView != null) {
mRightImageView.setPageBounds(rect[0]);
mLeftImageView.setPageBounds(rect[1]);
Context context = getContext();
if (mOverlayText && context != null) {
Copy link
Contributor

@ozbek ozbek Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1!
There is no point in checking if context is null. If it is null, then something is seriously broken beyond repair.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i intentionally added that null check because we were having crashes due to this, so please re-add this back.

because this is in onPostExecute, we can easily have a case where the fragment is killed before the AsyncTask finishes - when the AsyncTask is done, there is no context because the Fragment is gone, so we should just bail - by not doing this check, we'll crash in the next few lines where we try to use the context to get sura names, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

I think, for that scenario, checking if fragment is being removed (isRemoving()) or if it is visible (isVisible()) would fit better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, i agree. in QuranPageFragment, we're checking isAdded() and that seems to be working fine (no crash there), so am good with wrapping the entire block with an isAdded() check.

@ahmedre
Copy link
Contributor

ahmedre commented Sep 23, 2016

i am not against this patch conceptually, but have a few suggestions (aside from addressing the comments) - i think this will look strange in the top middle. my suggestion instead is either:
a. merge it with the juz' text at the top right or
b. move the page number to the left (or right, depending on the side of the page the page is on), and on the opposite side, put the hizb info.

@ahmedre
Copy link
Contributor

ahmedre commented Sep 23, 2016

(oh, and most importantly, jazakumAllah khairan for doing this!)

@Ahmed9914
Copy link
Contributor Author

First, I'm sorry about not following some styling rules.
Second, @ahmedre I think option "a" is better and I'm working on it.
JazkomoAllah Khairan.

@Ahmed9914 Ahmed9914 closed this Sep 23, 2016
@Ahmed9914 Ahmed9914 reopened this Sep 23, 2016
Copy link
Contributor Author

@Ahmed9914 Ahmed9914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes done

Copy link
Contributor Author

@Ahmed9914 Ahmed9914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing change done

Copy link
Contributor Author

@Ahmed9914 Ahmed9914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary duplicate and clarified more on the comment

@@ -319,16 +320,18 @@ protected void onPostExecute(RectF[] rect) {
if (mRightImageView != null && mLeftImageView != null) {
mRightImageView.setPageBounds(rect[0]);
mLeftImageView.setPageBounds(rect[1]);
Context context = getContext();
if (mOverlayText && context != null) {
if (mOverlayText) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add isAdded() check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, sorry I totally forgot that.
now added.

int hizb = (rub3 / 4) + 1;
StringBuilder sb = new StringBuilder();
sb.append(" , ");
if (rub3 == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this check earlier (right after line 78)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (rub3 == -1) {
return "";
}
int remainder = rub3 % 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of readability (just a suggestion):

switch(rub3%4) {
    case 1:
        sb.append(context.getString(R.string.quran_rob3)).append(' ');
        break;
    case 2:
        sb.append(context.getString(R.string.quran_nos)).append(' ');
        break;
    case 3:
        sb.append(context.getString(R.string.quran_talt_arb3)).append(' ');
        break;
    default: // case 0
        // do nothing
}

Ahmed Abdelaal added 4 commits September 27, 2016 19:32
No need for this check, as it's already checked in 'QuranDisplayHelper.displayRub3' method
Copy link
Contributor Author

@Ahmed9914 Ahmed9914 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edited

sb.append(context.getString(R.string.quran_nos)).append(' ');
} else if (remainder == 3) {
sb.append(context.getString(R.string.quran_talt_arb3)).append(' ');
}
Copy link
Contributor

@hakimrie hakimrie Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it has too many magic number here, it will be better and more readable if we define 1, 2, 3 as constant variable.

@@ -320,15 +321,17 @@ protected void onPostExecute(RectF[] rect) {
mRightImageView.setPageBounds(rect[0]);
mLeftImageView.setPageBounds(rect[1]);
Context context = getContext();
if (mOverlayText && context != null) {
if (mOverlayText && isAdded()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1! Now, since context is not used outside, you could move Context context = getContext(); to inside the brackets (your original change). Sorry for sounding like nitpicking :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May Allah rewards you for your great effort in improving this app.

@@ -178,6 +181,7 @@ public void setOverlayText(String suraText, String juzText, String pageText) {
mOverlayParams.suraText = suraText;
mOverlayParams.juzText = juzText;
mOverlayParams.pageText = pageText;
mOverlayParams.rub3Text=rub3Text;
Copy link
Contributor

@ozbek ozbek Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing is not fixed yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now fixed

@ahmedre ahmedre merged commit 415569b into quran:master Oct 4, 2016
@ahmedre
Copy link
Contributor

ahmedre commented Oct 4, 2016

merging to unblock, jazakAllah khairan.
if you get a chance, please also do @hakimrie's suggestion (in a new patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants