Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

exit on double back pressing added #66

Merged
merged 5 commits into from
May 30, 2021
Merged

exit on double back pressing added #66

merged 5 commits into from
May 30, 2021

Conversation

yasin459
Copy link
Contributor

@yasin459 yasin459 commented May 15, 2021

Checklist

Common

  • implement exit on double back pressed

UI

  • visuals work fine
  • I added a Toast to inform the user to press back again(for double click) after the user pressed once

Logic

  • I tested app functionality.

Changes

Describe all changes here:

  • First; deleted appBackClick usage in mainActivity
  • Second; added a new method "waitForDoubleBackPressed"

Comments

I checked it and it works good but I would really appreciate any critic or advice

@fartem fartem assigned fartem and yasin459 and unassigned fartem May 15, 2021
@fartem fartem linked an issue May 15, 2021 that may be closed by this pull request
@fartem fartem self-requested a review May 15, 2021 17:06
}

private void waitForDoubleBackPressed() {
if (doubleBackToExitPressedOnce) {
Copy link
Member

Choose a reason for hiding this comment

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

What for are you starting new activity instance after single back click?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i read somewhere that in order to save app state should make a new activity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you have a better suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

You should just show toast. If you re-run an activity, the state changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made some changes, i think it's fine now

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to start a new activity. Just show the dialog for user. If you start new activity, all user's data is erased.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where am I making a new activity????
are u sure you are checking my last commit?
i do NOT make a new activity in my last comit

Copy link
Member

Choose a reason for hiding this comment

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

In your last commit all fine but can you move this implementation to HashCalculatorFragment? This needs because HashCalculatorFragment is a "main" fragment of the app and user can exit by double click just only from it. Thanks.

build.gradle Outdated Show resolved Hide resolved
gradle.properties Outdated Show resolved Hide resolved
@fartem fartem added the enhancement New feature or request label May 23, 2021
}

private void waitForDoubleBackPressed() {
if (doubleBackToExitPressedOnce) {
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to start a new activity. Just show the dialog for user. If you start new activity, all user's data is erased.

@fartem
Copy link
Member

fartem commented May 23, 2021

@yasin459 Also, please check Checkstyle issues. You can do this by running next command from a shell:

./gradlew checkstyle

@fartem
Copy link
Member

fartem commented May 23, 2021

@yasin459 You can find example here.

}

private void waitForDoubleBackPressed() {
if (doubleBackToExitPressedOnce) {
Copy link
Member

Choose a reason for hiding this comment

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

In your last commit all fine but can you move this implementation to HashCalculatorFragment? This needs because HashCalculatorFragment is a "main" fragment of the app and user can exit by double click just only from it. Thanks.

@fartem
Copy link
Member

fartem commented May 24, 2021

@yasin459 Also please check Codacy issues (link).

@yasin459
Copy link
Contributor Author

I made another change, transferred to hashcheckercalculator, and codacy is fixed.anything else?

Copy link
Member

@fartem fartem left a comment

Choose a reason for hiding this comment

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

Need attention about "Magic Number" in HashCalculatorFragment.

getString(R.string.action_exit_now),
v -> getActivity().finish()
);
if (doubleBackToExitPressedTwice) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot! I'm approve this PR. If you want, you also ca extract time to wait (2000 ms) to the local static constant (its a best practice to extract all variables that can use as constant to a local fields). This is a "Magic Number", you can read more about this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i made magic number, thank you for your advice

@fartem fartem merged commit 6f95755 into hash-checker:master May 30, 2021
@fartem
Copy link
Member

fartem commented May 30, 2021

@yasin459 Thanks. I'm added you to Contributors section in README.md.

@fartem fartem added this to Done in 1.1.0 May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
1.1.0
Done
Development

Successfully merging this pull request may close these issues.

Add app closing with double tap on back button
2 participants