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

Replace the System.exit calls with getActivity.finishAffinity() #6495

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

danielmbutler
Copy link
Contributor

Replaced System.exit call with finishAffinity() and start MainActivity call, tested by changing some settings values, exporting my configuration, reversing the changes, and then reimporting the settings, once the MainActivity was restarted I could then see my chosen settings imported.

Also updated ExitActivity.java to remove System.Exit call and replace with start MainActivity

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Replaced System.Exit calls with getActivity.finishAffinity() in the below 2 files

NewPipe/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java
src/main/java/org/schabi/newpipe/ExitActivity.java

Fixes the following issue(s)

APK testing

I ran the APK on an emulator and went through the settings flow and ensured that my changes persisted after the importing task had finished and the app was restarted.

Due diligence

@triallax
Copy link
Contributor

Thanks for making a PR! Please avoid putting the issue number in the PR title.

@triallax triallax changed the title Fix for issue #6428 "Replace the System.exit calls with getActivity.finishAffinity()" Replace the System.exit calls with getActivity.finishAffinity() Jun 15, 2021
@triallax triallax added the codequality Improvements to the codebase to improve the code quality label Jun 15, 2021
@triallax
Copy link
Contributor

Note that the "APK testing" section is for putting a link to the APK (from the "Checks" tab of the PR; the APK isn't there currently because you're a first-time contributor so a maintainer has to manually approve the checks to be run), not for how you tested it yourself.

@danielmbutler
Copy link
Contributor Author

Apologies for "Apk Testing" section I will remember this in future :)

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thank you!

app/src/main/java/org/schabi/newpipe/ExitActivity.java Outdated Show resolved Hide resolved
Copy link
Contributor

@triallax triallax left a comment

Choose a reason for hiding this comment

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

LGTM, just a bunch of minor nits.

Copy link
Collaborator

@XiangRongLin XiangRongLin left a comment

Choose a reason for hiding this comment

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

Can you also rewrite the commit messages to have a short summary with less than 70 characters followed by an optinal body with further descriptions/explanations.

If you look at the commits on github, you can see that they are cut off. https://github.com/TeamNewPipe/NewPipe/pull/6495/commits

@Redirion
Copy link
Member

@XiangRongLin I think we can just squash the commits when we merge this and add our own summary, so no worries there

@XiangRongLin
Copy link
Collaborator

That would need to be done by him, because otherwise i think it counts the contribution towards the one squashing and merging it and not the PR opener

@Redirion
Copy link
Member

oh I just noticed, the context param is not required. Activity and FragmentActivity(returned from requireActivity) are derived from Context

java.lang.Object
↳ | android.content.Context
  | ↳ | android.content.ContextWrapper
  |   | ↳ | android.view.ContextThemeWrapper
  |   |   | ↳ | android.app.Activity

java.lang.Object
↳ | android.content.Context
  | ↳ | android.content.ContextWrapper
  |   | ↳ | android.view.ContextThemeWrapper
  |   |   | ↳ | android.app.Activity
  |   |   |   | ↳ | androidx.activity.ComponentActivity
  |   |   |   |   | ↳ | androidx.fragment.app.FragmentActivity

Redirion
Redirion previously approved these changes Jun 16, 2021
Copy link
Member

@Redirion Redirion left a comment

Choose a reason for hiding this comment

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

lgtm

@danielmbutler
Copy link
Contributor Author

let me know if all is good then I will squash the commit messages.

@Redirion
Copy link
Member

yes, all good, go ahead please

@danielmbutler
Copy link
Contributor Author

Should be sorted now

@XiangRongLin
Copy link
Collaborator

@Stypox @mhmdanas You two have to approve it, because you requested changes

@Redirion
Copy link
Member

I still see 9 commits. Looks like the squashing did not work. Can you try again @danielmbutler ?

triallax
triallax previously approved these changes Jun 17, 2021
@danielmbutler
Copy link
Contributor Author

Hi Guys I've been trying to squash my previous commits but it seems to merge them all together and then commit the merge on top of previous commits, not sure what I'm doing wrong

Implemented "RestartApp" method defined in NavigationHelper.java.
 This method is used in ExitActivity.java and ContentSettingsFragment.java
@danielmbutler
Copy link
Contributor Author

After multiple tries, I figured it out lol

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Perfect, thank you!

@Stypox Stypox merged commit 841fb4c into TeamNewPipe:dev Jun 17, 2021
This was referenced Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace the System.exit calls with getActivity.finishAffinity()
5 participants