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

Sharing multiple connections #4084

Merged
merged 91 commits into from
Jul 13, 2016

Conversation

kwonye
Copy link
Contributor

@kwonye kwonye commented May 10, 2016

Fixes #4071

To test:

Add multiple accounts to a single connection and post. It should post to the multiple accounts correctly.
Also, disconnect accounts to verify updates to accounts are correct.

Needs review: @nbradbury

@kwonye kwonye changed the title Feature/4071 sharing multi user Sharing multiple connections May 10, 2016
@@ -118,6 +121,17 @@ public void onResume() {
setNavigationIcon(R.drawable.ic_close_white_24dp);
}

private void clearCookies() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct in thinking removeAllCookies() will affect every WebView in the app? If so, this might be a problem since it would force the user to re-login to any authenticated page they visited in the app.

Also, keep in mind that clearing cookies is asynchronous, so it's possible that the cookies won't be cleared before the page is browsed. If this is a concern, you may want to flush the cookie manager before browsing (keeping in mind that's a blocking call).

One final nit: this seems like it belongs in a utility class since it's not tied to the publicize feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I correct in thinking removeAllCookies() will affect every WebView in the app? If so, this might be a problem since it would force the user to re-login to any authenticated page they visited in the app.

Yup, you're right. I like your emphasis on might because I went through the same thought process. I believe it is ok because I don't see too many use cases where someone has navigated far beyond WordPress-related content. And since with WordPress-related content we are passing the credentials in anyway, they'll always be logged-in.

Also, keep in mind that clearing cookies is asynchronous, so it's possible that the cookies won't be cleared before the page is browsed. If this is a concern, you may want to flush the cookie manager before browsing (keeping in mind that's a blocking call).

Good call. I'll move it to when the WebView closes (like iOS does)

One final nit: this seems like it belongs in a utility class since it's not tied to the publicize feature.

That's fair. I'll create (I couldn't find one) a WebViewUtils class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I'll move it to when the WebView closes (like iOS does)

Sorry, didn't finish my thought there. If it's at the end, it will solve the async issue of the webview showing up before the cookies are cleared.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to clear cookies from specific domains rather than clear them all? If so, this may help.

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 tried that method (and many other similar methods) and unfortunately it doesn't seem to actually work. Setting a cookie doesn't actually overwrite it. It looks like people have had mixed results with different versions of Android.

Because of all of this I believe we should keep the deletion of all cookies.

@nbradbury
Copy link
Contributor

When the publicize list activity is shown prior to publicize data being available, the "Loading..." message appears on top of the connections text.

loading

@nbradbury
Copy link
Contributor

Prior to testing this PR, I already had a test Twitter account setup with publicize. Using this PR, I attempted to add a second Twitter account. I got all the way through the process, but when I was returned to the publicize detail I saw a toast stating "an error occurred" and the second Twitter account didn't appear.

The log shows "Unexpected response code 400 for https://public-api.wordpress.com/rest/v1.1/sites/52451176/publicize-connections/new"

I tried again with the same result, and it occurs in both the emulator and on a real device.

Note that this 2nd Twitter account has "verify login requests" enabled, which required having Twitter send me a verification code in order to login with the app. I disabled this setting, but the problem still occurred.

@kwonye
Copy link
Contributor Author

kwonye commented May 10, 2016

The log shows "Unexpected response code 400 for https://public-api.wordpress.com/rest/v1.1/sites/52451176/publicize-connections/new"

Well that's thoroughly confusing... That's not on the list of errors for that endpoint https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/publicize-connections/new/#apidoc-resource-errors

@kwonye
Copy link
Contributor Author

kwonye commented May 10, 2016

When the publicize list activity is shown prior to publicize data being available, the "Loading..." message appears on top of the connections text.

Addressed in d4efbf9

@nbradbury
Copy link
Contributor

@kwonye Just in case you weren't aware, this is currently failing Travis.

@kwonye
Copy link
Contributor Author

kwonye commented May 12, 2016

@nbradbury ready for a second pass. I've created #4089 where we can address design issues we find.

@kwonye
Copy link
Contributor Author

kwonye commented May 12, 2016

@kwonye Just in case you weren't aware, this is currently failing Travis.

Thanks. It's because setImgAlpha() is not available in API 14. I've changed the minAPI to 16 (which will be done by the time this feature ships according to #4052)

@nbradbury
Copy link
Contributor

Hmm, something's very broken here.

I have a test Twitter account named AutomatticNickB and my real Twitter account is nbradbury.

AutomatticNickB was previously connected, so I disconnected it and the Twitter connected accounts list correctly showed no connected accounts.

Then I connected my nbradbury account. When I returned to the detail fragment, it showed AutomatticNickB as being connected again, and nbradbury wasn't listed at all.

Just to be clear, this is what I saw after I disconnected AutomatticNickB and connected nbradbury:

device-2016-05-12-150732

@kwonye
Copy link
Contributor Author

kwonye commented May 15, 2016

@nbradbury I'm in the state of your "Unexpected response code 400" error that you saw. Unfortunately the ServerError is null.

Still unable to repro the incorrect Twitter account showing, but gun to my head I'm guessing they're related.

I'll continue investigating and ping you once this is ready to review again, thanks 👍

@kwonye
Copy link
Contributor Author

kwonye commented Jun 29, 2016

Ok @nbradbury ready for another pass! Multi-users show the correct selection dialog now.

@nbradbury
Copy link
Contributor

When I attempted to connect a Twitter account, I saw the dialog below which incorrectly says I'm connecting Facebook. The description is cut off, as is the list of connected users (and I'm not sure why that list is even shown here). I also don't understand why "Nick Bradbury" is listed four times, nor why it's even in the list (I don't have a Twitter account named "Nick Bradbury").

device-2016-06-29-040106

When I canceled that dialog, I saw a toast that once again mentioned Facebook even though it was a Twitter account.

device-2016-06-29-040300

@kwonye
Copy link
Contributor Author

kwonye commented Jun 29, 2016

@nbradbury thanks for that, we weren't properly filtering out the different services. It's been resolved 👍

@nbradbury
Copy link
Contributor

I'm still confused by that dialog (but it looks a lot better). When I clicked to add a Twitter connection, I signed into my AutomatticNickB account. So why does this dialog need to ask me which account to authorize?

device-2016-06-29-154239

@kwonye
Copy link
Contributor Author

kwonye commented Jul 7, 2016

I'm still confused by that dialog (but it looks a lot better). When I clicked to add a Twitter connection, I signed into my AutomatticNickB account. So why does this dialog need to ask me which account to authorize?

@nbradbury unfortunately we do not get the information that tells us which account the user requested. We just get a list of all the connections available, and that dialog shows the ones that are not connected yet. The web has to do this as well unfortunately.

@nbradbury
Copy link
Contributor

I just pulled the latest changes, and now I'm getting a ClassCastException after connecting my Twitter account:

java.lang.ClassCastException: android.support.v7.widget.RecyclerView cannot be cast to android.widget.LinearLayout
                                                                         at org.wordpress.android.ui.publicize.PublicizeAccountChooserDialogFragment.hideConnectedView(PublicizeAccountChooserDialogFragment.java:77)
                                                                         at org.wordpress.android.ui.publicize.PublicizeAccountChooserDialogFragment.configureRecyclerViews(PublicizeAccountChooserDialogFragment.java:70)
                                                                         at org.wordpress.android.ui.publicize.PublicizeAccountChooserDialogFragment.onCreateDialog(PublicizeAccountChooserDialogFragment.java:48)
                                                                         at android.support.v4.app.DialogFragment.getLayoutInflater(DialogFragment.java:307)

This occurs when the app navigates away from Twitter's "Redirecting you back to the application" page.

@kwonye
Copy link
Contributor Author

kwonye commented Jul 13, 2016

Thanks @nbradbury, that was a typo on my part. I was pulling the wrong resource ID. It works now.

@nbradbury
Copy link
Contributor

:shipit:

@nbradbury nbradbury merged commit 087f846 into feature/sharing-master Jul 13, 2016
@nbradbury nbradbury deleted the feature/4071-sharing-multi-user branch July 13, 2016 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants