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

Added the feature to display the external link in the warning dialog box #3193

Merged
merged 7 commits into from Feb 3, 2023

Conversation

shankarpriyank
Copy link
Contributor

@shankarpriyank shankarpriyank commented Jan 7, 2023

Fixes #2966
Fixes #2965

Made changes to files related to Dialog Boxes, to show the URL of external link in the warning dialog box

Screenshots

Light mode Dark mode
image image

@kelson42
Copy link
Collaborator

kelson42 commented Jan 7, 2023

Few remarks:

  • I would remove the "Link - "
  • Buttons should be better aligned, "Yes" and "no" aligned left and on a first ligne, the "Don't ask anymore" left aligned on a second lign

@shankarpriyank
Copy link
Contributor Author

Okay, willl remove "Link-"
Sorry but I cannot comprehend what do you mean by

"Yes" and "no" aligned left and on a first ligne, the "Don't ask anymore" left aligned on a second lign

I guess all there buttons are on three different lines, also I did not did not change anything related to the buttons.

This is how the dialog box looks on the develop branch

image

@kelson42
Copy link
Collaborator

kelson42 commented Jan 7, 2023

@shankarpriyank Don't remove the link, remove "Link -" label. We know this is a lonk, not needed to explain it.

@shankarpriyank
Copy link
Contributor Author

Hey @kelson42 I have removed the label, and also fixed the failing tests.
Thought the lint checks will still fail, the error I am getting is this
This expression contains a magic number. Consider defining it to a well named constant. [MagicNumber]
This is thrown at a line where I am assigning a value to a variable, I am unable to understand how to fix this.

@kelson42
Copy link
Collaborator

kelson42 commented Jan 7, 2023

@shankarpriyank Thank you, @gouri-panda will review your work. Give him a few days.

@shankarpriyank
Copy link
Contributor Author

Updated Screenshot
image

@gouri-panda
Copy link
Collaborator

This expression contains a magic number. Consider defining it to a well named constant. [MagicNumber]
This is thrown at a line where I am assigning a value to a variable, I am unable to understand how to fix this.

@shankarpriyank You can suppress this by annotating method supress warnings or make a constant value.

@shankarpriyank
Copy link
Contributor Author

shankarpriyank commented Jan 7, 2023

This expression contains a magic number. Consider defining it to a well named constant. [MagicNumber]
This is thrown at a line where I am assigning a value to a variable, I am unable to understand how to fix this.

@shankarpriyank You can suppress this by annotating method supress warnings or make a constant value.

Thanks, I understand the supressing alternative, but what do you mean by " make a constant value?"

Also can you please help me with the failing tests, I don't have much experience in testing,but after having a look at the log it seems to me like that the mock objects in some ways different to the real one.

@gouri-panda
Copy link
Collaborator

what do you mean by > make a constant value

Constant value means create a constant variable. The error is simply means you can't put only numbers in arguments. By doing that we can put different number in different locations by mistake. In order to not make this mistake we can put a constant variable and use it everywhere else.

@shankarpriyank
Copy link
Contributor Author

I guess I have done that same thing

private val viewSpacingLeftForLink = 0
  private val viewSpacingRightForLink = 0
  private val viewSpacingTopForLink = 10
  private val viewSpacingBottomForLink = 0

I declared these variables and then passed them as arguments in this function

         setView(
            textView,
            viewSpacingLeftForLink,
            viewSpacingTopForLink,
            viewSpacingRightForLink,
            viewSpacingBottomForLink
          )

@gouri-panda
Copy link
Collaborator

@kelson42 Are you ok with the UI?

@kelson42
Copy link
Collaborator

kelson42 commented Jan 8, 2023

@gouri-panda AFAIK the UI has not been fixed, so would like to see a proper UI, the current one buttons are not properly aligned.

@gouri-panda
Copy link
Collaborator

@kelson42 Ok. @shankarpriyank Please change the UI as @kelson42 mentioned. Then I'll review the other parts :) Also, the other errors haven't been fixed yet.

@kelson42
Copy link
Collaborator

If the alignment problen can not be fixed, please open a dedicated ticket. Then we could finally review and merge this PR.

@kelson42
Copy link
Collaborator

It should be also confirmed that #2966 has been fixed.

@gouri-panda
Copy link
Collaborator

@shankarpriyank This test is failing.

ExternalLinkOpenerTest > alertDialogShower does not open link if negative-button is clicked$core_debug() FAILED
io.mockk.MockKException at ExternalLinkOpenerTest.kt:68

The ExternalLinkOpener has changed. If the change is intentional then you can modify these tests. If you want more tests that you have changed you can add more 🙂

@kelson42
Copy link
Collaborator

@MohitMaliDeveloper Can you please complete the work here so we can move ahead?

@shankarpriyank
Copy link
Contributor Author

Hey @kelson42 I am still working on modifying the tests so that they pass. I donot have much experience in testing and this is the first time I am encountering mocks so its a bit challenging. I could use some help to fix the tests.

@kelson42
Copy link
Collaborator

@shankarpriyank Sorry, my bad, I had the feeling you were in a dead-end.

).show()
true
}
textView.text = Html.fromHtml("</br><a href=$url> <b>$url</b>")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Instead of converting a link to html text, you can always use spannable string, and implement a custom click behaviour here, instead of leaving it to OS.

@kelson42
Copy link
Collaborator

What is the status here?

@shankarpriyank
Copy link
Contributor Author

The functionality has been implemented, but I am unable to modify the tests so that they pass. Took some help from @4shutosh but still no success.

@kelson42
Copy link
Collaborator

@MohitMaliDeveloper Any chance you can complete and review his PR?

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliDeveloper Any chance you can complete and review his PR?

ok

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft January 28, 2023 12:23
@codecov
Copy link

codecov bot commented Jan 28, 2023

Codecov Report

Base: 49.68% // Head: 49.63% // Decreases project coverage by -0.05% ⚠️

Coverage data is based on head (44a8892) compared to base (cafd6d7).
Patch coverage: 65.71% of modified lines in pull request are covered.

❗ Current head 44a8892 differs from pull request most recent head 4af50e3. Consider uploading reports for the commit 4af50e3 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3193      +/-   ##
=============================================
- Coverage      49.68%   49.63%   -0.05%     
  Complexity        25       25              
=============================================
  Files            290      291       +1     
  Lines           9800     9834      +34     
  Branches        1309     1311       +2     
=============================================
+ Hits            4869     4881      +12     
- Misses          4266     4282      +16     
- Partials         665      671       +6     
Impacted Files Coverage Δ
...kiwix/kiwixmobile/core/utils/ExternalLinkOpener.kt 36.66% <50.00%> (-32.30%) ⬇️
...iwix/kiwixmobile/core/utils/dialog/DialogShower.kt 50.00% <50.00%> (ø)
...kiwixmobile/core/utils/dialog/AlertDialogShower.kt 73.68% <67.74%> (-8.46%) ⬇️
.../org/kiwix/kiwixmobile/language/viewmodel/State.kt 93.54% <0.00%> (-3.23%) ⬇️
...rg/kiwix/kiwixmobile/core/search/SearchFragment.kt 62.22% <0.00%> (-1.12%) ⬇️
.../kiwix/kiwixmobile/core/main/CoreReaderFragment.kt 30.48% <0.00%> (-0.12%) ⬇️
...x/kiwixmobile/core/extensions/ContextExtensions.kt 50.00% <0.00%> (+13.63%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Have you finished the necessary work? Shoukd you remove the draft mode?

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz Have you finished the necessary work? Shoukd you remove the draft mode?

@kelson42 ,
I have fixed test and lint failures.

AFAIK the UI has not been fixed, so would like to see a proper UI, the current one buttons are not properly aligned.

Ui changes are left.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz OK, who will do that?

@MohitMaliFtechiz
Copy link
Collaborator

MohitMaliFtechiz commented Jan 28, 2023

@MohitMaliFtechiz OK, who will do that?

@kelson42 , I'm working on it.

@MohitMaliFtechiz
Copy link
Collaborator

MohitMaliFtechiz commented Jan 28, 2023

@kelson42 ,
I'm testing the UI. this is a AlertDialog and it's button automatically changed according to every screen size and how many space left in screen.

Example :-

In Portrait Mode

Screenshot_2023-01-28-18-35-02-293_org kiwix kiwixmobile 1

In Landscape Mode

Screenshot_2023-01-28-18-35-12-701_org kiwix kiwixmobile 1

If we want to change the UI then we need to use a custom layout with Custom Dialog instead of Android AlertDialog (which we are currently using).

@kelson42
Copy link
Collaborator

@MohitMaliDeveloper Not too bad, can we reduce the big white space? Please rebase the PR as well.

@MohitMaliFtechiz
Copy link
Collaborator

MohitMaliFtechiz commented Jan 30, 2023

@MohitMaliDeveloper Not too bad, can we reduce the big white space?

@kelson42 , unfortunately not, it's automatically takes height according to it's views (when we call setView method of alertDialog for adding additional view to it. in this case we are adding url text view).

Please rebase the PR as well.

I have re base the PR and resolved the conflicts.

@kelson42
Copy link
Collaborator

kelson42 commented Feb 1, 2023

@MohitMaliDeveloper Is that ready to review (please rebase and fix conflicts)?

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliDeveloper Is that ready to review (please rebase and fix conflicts)?

@kelson42 , i'm waiting for your feedback on above comment. that's why this PR in draft, if that is okay for you then this PR is ready for review.

@kelson42
Copy link
Collaborator

kelson42 commented Feb 1, 2023

@MohitMaliFtechiz LGTM. If you request something from me, please specificaly ask with a question mark.

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review February 2, 2023 07:00
@MohitMaliFtechiz
Copy link
Collaborator

@kelson42 , I have resolved the conflicts. @gouri-panda this PR is ready for review.

@gouri-panda
Copy link
Collaborator

@MohitMaliDeveloper Thanks! Will do!

Copy link
Collaborator

@gouri-panda gouri-panda left a comment

Choose a reason for hiding this comment

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

@MohitMaliDeveloper @shankarpriyank I overviewed the PR. I leave some comments about this. The external link colour doesn't look good on the dark theme. Just a small friendly reminder, please don't change the unrelated code to tickets as you did here, changing the licence and renaming the function names.

@MohitMaliFtechiz
Copy link
Collaborator

MohitMaliFtechiz commented Feb 3, 2023

@gouri-panda , thanks for your feedback.

The external link colour doesn't look good on the dark theme.

  • Good catch. I have changed the color of link and update the new UI screenshots on PR description.

changing the licence

  • It's automatically changed when we move file to another package. I'm reverting the Copyright (c) to 2020.

renaming the function names

  • Now ExternalLinkOpenerTest file is in androidTest package, here these function names are not allowed that's why i had changed it.

Screenshot from 2023-02-03 11-51-02

@gouri-panda
Copy link
Collaborator

@MohitMaliDeveloper Did you push it? I don't see recent changes.

@MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliDeveloper Did you push it? I don't see recent changes.

hi @gouri-panda ,
I have just push the all latest changes(as you requested).

Copy link
Collaborator

@gouri-panda gouri-panda left a comment

Choose a reason for hiding this comment

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

@shankarpriyank @MohitMaliDeveloper Thanks for the work 🎉 !

@kelson42 kelson42 merged commit 0d1593f into kiwix:develop Feb 3, 2023
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.

Ability to copy the URL of an external link URL in the external link warning window
6 participants