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

Fixed, Hitting back on the DWDS app exits it. #3512

Merged
merged 5 commits into from
Nov 16, 2023
Merged

Fixed, Hitting back on the DWDS app exits it. #3512

merged 5 commits into from
Nov 16, 2023

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Oct 23, 2023

Fixes #3507

We removed the activity finishing triggered by pressing the back button in the reader fragment. We initially added this when we were converting CustomReader to a fragment, as we encountered crashing issues at the time. However, it was quite some time ago, and we have since refactored our code. Now, it no longer crashes and functions smoothly without terminating the activity when the back button is pressed. We also made this change for when a user presses the back button from the download screen. This back button press is within the CustomReaderFragment, so it does not impact the functionality of the DownloadFragment.

backpressedissuefixed.mp4
  • Moved openSearchItem, and findInPage functionality to our CoreReaderFragment as we used the same code twice for these methods in the app and custom module.

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (3716b72) 48.98% compared to head (51ce43b) 49.05%.
Report is 3 commits behind head on develop.

❗ Current head 51ce43b differs from pull request most recent head 4a96824. Consider uploading reports for the commit 4a96824 to get more accurate results

Files Patch % Lines
.../kiwix/kiwixmobile/core/main/CoreReaderFragment.kt 73.33% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3512      +/-   ##
=============================================
+ Coverage      48.98%   49.05%   +0.07%     
- Complexity      1076     1079       +3     
=============================================
  Files            285      285              
  Lines          10422    10421       -1     
  Branches        1396     1395       -1     
=============================================
+ Hits            5105     5112       +7     
+ Misses          4493     4480      -13     
- Partials         824      829       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

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

Please follow instructions at #3507 (comment)

requireActivity().finish()
return super.onBackPressed(activity)
}

private fun openSearchItem(item: SearchItemToOpen) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this method is overriden?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kelson42 This method was overridden to handle the backPressed event in Custom Apps, it is specially overridden for if the user back presses in custom apps and he is on the Reader screen then we were closing the application.

Copy link
Collaborator

Choose a reason for hiding this comment

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

talking about opensearchItem() and the question is why it need to be doffetent in a custom app?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kelson42 Thanks for highlighting this, We are observing the seachedItem in both modules(app, custom) and this method for opening the searched item, but we have written this method twice in both reader fragments so it would be better to move this code CoreReaderFragment.

Copy link
Collaborator Author

@MohitMaliFtechiz MohitMaliFtechiz Oct 30, 2023

Choose a reason for hiding this comment

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

Done.

#3507 (comment)

It does not make sense to me to override a method and just calling "super". Just remove overriding and it should take parent version.

Apart from this change, i have checked in the code there are no other method which is just calling super after overrrding.

@kelson42
Copy link
Collaborator

kelson42 commented Nov 1, 2023

@MohitMaliDeveloper You still don't have put the code comments as already requested twice on the parent class methods which are overriden for custom app. This is the only solution we have that a future modification on parent class goes applied as well (if necessary) on the custom class.

@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42 Sorry I missed adding the comments, now I have added the necessary comments on methods that are override in CustomReaderFragment with the explanation what are the working of those methods.

@kelson42
Copy link
Collaborator

kelson42 commented Nov 1, 2023

@MohitMaliFtechiz What I requested on paretn class is atill missing

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft November 2, 2023 13:13
@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review November 2, 2023 14:18
@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz What I requested on paretn class is atill missing

I have added the comments in the parent class(CoreReaderFragment).

@kelson42
Copy link
Collaborator

kelson42 commented Nov 7, 2023

@MohitMaliFtechiz What I requested on paretn class is atill missing

I have added the comments in the parent class(CoreReaderFragment).

It’s not what I was asking for! You still don’t have followed my instructions. Why you don’t just read accurately why I write?! #3507 (comment) #3512 (comment)

@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42 Can you please point out which parent class you want those comments or remove the unnecessary code?

@kelson42
Copy link
Collaborator

kelson42 commented Nov 9, 2023

@MohitMaliFtechiz Attempt number #5: write a comment on each method of corereaderfragment, wich is superseeded/overriden in the customapp fragment, that way - in the future - the dev is invited to look to the customapp fragment too if it modify this custom app method as well.

This will avoid the kind of bug this PR fixes!

@kelson42 kelson42 force-pushed the Issue#3507 branch 2 times, most recently from ed8391e to 3391a5d Compare November 12, 2023 17:03
@kelson42
Copy link
Collaborator

@MohitMaliFtechiz Please rebase on main (and fix conflicts)

@gouri-panda
Copy link
Collaborator

I believe it hasn't yet implemented the request @kelson42 made. I'll come back after it has done.

@MohitMaliFtechiz MohitMaliFtechiz force-pushed the Issue#3507 branch 2 times, most recently from ae93d73 to 51ce43b Compare November 16, 2023 10:30
@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz Attempt number #5: write a comment on each method of corereaderfragment, wich is superseeded/overriden in the customapp fragment, that way - in the future - the dev is invited to look to the customapp fragment too if it modify this custom app method as well.
This will avoid the kind of bug this PR fixes!

@MohitMaliFtechiz Please rebase on main (and fix conflicts)

@kelson42 Done.

I believe it hasn't yet implemented the request @kelson42 made. I'll come back after it has done.

@gouri-panda I have make the changes can you please review this PR.

@gouri-panda
Copy link
Collaborator

@MohitMaliFtechiz Sure! Thanks!

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz red CI

@MohitMaliFtechiz
Copy link
Collaborator Author

@MohitMaliFtechiz red CI

CI is green now.

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz sorry, you havr to rebase again

* We removed the activity finishing triggered by pressing the back button in the reader fragment. We initially added this when we were converting CustomReader to a fragment, as we encountered crashing issues at the time. However, it was quite some time ago, and we have since refactored our code. Now, it no longer crashes and functions smoothly without terminating the activity when the back button is pressed. We also made this change for when a user presses the back button from the download screen. This back button press is within the CustomReaderFragment, so it does not impact the functionality of the DownloadFragment.
…ment` as we were using same code twice for these methods in app and custom module.
…idden these methods and describe their functionality.
@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42, @gouri-panda Conflicts are resolved, @gouri-panda you can review this now.

@kelson42 kelson42 merged commit 252d846 into develop Nov 16, 2023
7 of 8 checks passed
@kelson42 kelson42 deleted the Issue#3507 branch November 16, 2023 20:35
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.

Hitting back on the DWDS app exits it
4 participants