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

Fix #2427: Create LogoutDialogFragment #3119

Merged
merged 7 commits into from
May 6, 2021

Conversation

ArpitShukIa
Copy link
Contributor

Explanation

Fixes #2427: I created a new DialogFragment replacing the old AlertDialog in AdministratorControlsAccountActionsViewModel and removed the IntentFactoryShim dependency as it is no longer being used. Also added test for the fix.

Test Results:

Robolectric:
image

Expresso:
image

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The PR follows the style guide.
  • The PR does not contain any unnecessary auto-generated code from Android Studio.
  • The PR is made from a branch that's not called "develop".
  • The PR is made from a branch that is up-to-date with "develop".
  • The PR's branch is based on "develop" and not on any other branch.
  • The PR is assigned to an appropriate reviewer in both the Assignees and the Reviewers sections.

@ArpitShukIa
Copy link
Contributor Author

@rt4914 PTAL.

@ArpitShukIa
Copy link
Contributor Author

The bazel checks are failing. Probably because LogoutDialogFragment is not visible to AdministratorControlsAccountActionsViewModel.
How to fix this?

@rt4914
Copy link
Contributor

rt4914 commented Apr 26, 2021

Will review it once it gets review by @prayutsu or @FareesHussain

@rt4914 rt4914 removed their assignment Apr 26, 2021
Copy link
Contributor

@prayutsu prayutsu left a comment

Choose a reason for hiding this comment

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

Left some comments. PTAL @ArpitShukIa

@prayutsu prayutsu assigned ArpitShukIa and unassigned prayutsu Apr 27, 2021
@ArpitShukIa ArpitShukIa assigned prayutsu and unassigned ArpitShukIa Apr 27, 2021
Copy link
Contributor

@FareesHussain FareesHussain left a comment

Choose a reason for hiding this comment

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

@ArpitShukIa Implementation LGTM,

PTAL there is a bazel build error.

As AdministratorControlsAccountActionsViewModel no longer imports the resources move it from VIEW_MODELS_WITH_RESOURCE_IMPORTS to VIEW_MODELS source set to optimize the build but this doesn't solve the bazel error, as we don't have Activities or Fragments in the viewmodels so far there is no dep added to the view_models target.

To fix this we need to add the :app dep to the :view_models but this is definitely not a good practice.

I suggest creating a new Listner and use the LogoutDialogFragment within the AdministratorControlsActivity or AdministratorControlsFragment

@BenHenning WDYT?

Copy link
Contributor

@FareesHussain FareesHussain left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks

Copy link
Contributor

@prayutsu prayutsu left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks @ArpitShukIa

@prayutsu prayutsu assigned rt4914 and unassigned prayutsu Apr 27, 2021
@BenHenning
Copy link
Sponsor Member

BenHenning commented Apr 27, 2021

Sorry, I think I'll need to take a pass on this tomorrow, but I can follow up to the comment above now.

@BenHenning
Copy link
Sponsor Member

@ArpitShukIa Implementation LGTM,

PTAL there is a bazel build error.

As AdministratorControlsAccountActionsViewModel no longer imports the resources move it from VIEW_MODELS_WITH_RESOURCE_IMPORTS to VIEW_MODELS source set to optimize the build but this doesn't solve the bazel error, as we don't have Activities or Fragments in the viewmodels so far there is no dep added to the view_models target.

To fix this we need to add the :app dep to the :view_models but this is definitely not a good practice.

I suggest creating a new Listner and use the LogoutDialogFragment within the AdministratorControlsActivity or AdministratorControlsFragment

@BenHenning WDYT?

I agree with moving this out of the resources view model list if R is no longer needed. Regarding the dependency, I'm fairly certain you can't add :app to :view_models since that will likely result in a circular dependency.

I'm not sure I'm following what the need for the listener is. What specific problem do you see here @FareesHussain?

@FareesHussain
Copy link
Contributor

I'm not sure I'm following what the need for the listener is. What specific problem do you see here @FareesHussain?

https://github.com/oppia/oppia-android/runs/2445936672

Before using the listener. the AdministratorControlsAccountActionsViewModel imports the LogoutDialogFragment. I had a look into the error and found that the LogoutDialogFragment comes under the :app target, I noticed none of the other viewmodels have imported from the :app target so to fix the Bazel error, I suggested adding a listener inorder to call the showLogoutDialog function. I'm not sure if there is any other way to fix it.

@BenHenning
Copy link
Sponsor Member

Ah I see, thanks for clarifying @FareesHussain. Yes, that seems like the correct way to solve this since the interface provides indirection (plus it's a bit cleaner not to directly interact with the activity/fragment lifecycles except at in that activity or fragment implementation class).

@BenHenning
Copy link
Sponsor Member

BenHenning commented Apr 29, 2021

I'm actually going to take a pass on just my codeowners here (presumably Bazel) after @rt4914 has a chance to review it in case there are any big changes.

Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@@ -16,14 +16,16 @@ const val SELECTED_CONTROLS_TITLE_SAVED_KEY =
const val LAST_LOADED_FRAGMENT_KEY = "LAST_LOADED_FRAGMENT_KEY"
const val PROFILE_LIST_FRAGMENT = "PROFILE_LIST_FRAGMENT"
const val APP_VERSION_FRAGMENT = "APP_VERSION_FRAGMENT"
const val LOGOUT_DIALOG_FRAGMENT = "LOGOUT_DIALOG_FRAGMENT"
Copy link
Contributor

Choose a reason for hiding this comment

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

This tag should be shifted to LogoutDialogFragment companion object and then it should be used wherever requried.

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

dialog.dismiss()
}
.setPositiveButton(R.string.log_out_dialog_okay_button) { _, _ ->
// TODO(#762): Replace [ProfileChooserActivity] to [LoginActivity] once it is added.
Copy link
Contributor

Choose a reason for hiding this comment

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

This TODO is not needed here. You can remove this.

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

@rt4914 rt4914 removed their assignment Apr 30, 2021
Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @ArpitShukIa! Generally LGTM for Bazel changes, but had 2 nit comments to address before approving.

@BenHenning BenHenning assigned ArpitShukIa and unassigned BenHenning May 1, 2021
@ArpitShukIa ArpitShukIa assigned BenHenning and unassigned ArpitShukIa May 1, 2021
@ArpitShukIa
Copy link
Contributor Author

@BenHenning I have committed the requested changes. PTAL.

Copy link
Sponsor Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @ArpitShukIa. LGTM for codeowners.

@BenHenning
Copy link
Sponsor Member

The Bazel issues are existing problems and are unrelated to this PR, so merging this as-is.

@BenHenning BenHenning merged commit a623929 into oppia:develop May 6, 2021
@ArpitShukIa ArpitShukIa deleted the logout-dialog branch May 7, 2021 12:13
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.

Logout Dialog disappears on orientation change
5 participants