Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Adds multiple accounts support #90

Closed
wants to merge 1 commit into from

Conversation

mvietri
Copy link

@mvietri mvietri commented Oct 19, 2019

References #83

Updated to master branch and I re-wrote some parts of the manager. Still not 100% sure about this -I'm still learning-

Same mechanics as app shortcuts.

  • Add multiple accounts following the login flow
  • Switch or delete account
  • Logout to userless mode
  • Re order accounts for custom order

Some images:

menu
switch
manager
delete

@mvietri
Copy link
Author

mvietri commented Oct 19, 2019

Well I'm leaving these here and wait for some reviews. I've been using it for a couple of days now with no major issues but I'm sure it can be done better.

@Tunous Tunous added the feature New feature label Oct 20, 2019
@Tunous Tunous self-requested a review October 30, 2019 17:33
@Tunous
Copy link
Owner

Tunous commented Oct 30, 2019

Hello, sorry for the late reply. I forgot about this pull request and only now found some time to review it. Here are some of my suggestion about UX of the account switcher. Keep in mind that these are highly opinionated so if you disagree with anything let me know and we'll select the better option :)

  1. The next most probable action performed by the user will be viewing subreddits after they add a new account. So based on that I would expect the account selector dialog to hide after adding new account. Similarly same should be done after logging out.

  2. Swiping to switch account doesn't feel natural and is hard to discover (ignoring hint at the top of dialog). I would expect to be able to simply click on an account to switch to it.

  3. Is there any usefulness in being able to reorder accounts? That seems more like an unnecessary feature and a static order (alphabetical?) would be better.

  4. Button to add new account should always be last. At least to me this feels more natural.

  5. If you are logged out the logout button is still visible. I would expect it to hide in that case.

  6. When you click on add new account button but then close the login dialog the account switcher disappears. Shouldn't we keep switcher visible after canceling login?

  7. What happens after you delete currently active account. After closing the dialog I can see that it switched me to another account but it's not clear to the user at first. We should either display an indicator showing which account is now active in the switcher or logout the user once active account is deleted.

  8. This seems like a bug but after I added 2 accounts and then deleted both of them then the app kept me logged in to the latest one. We should logout the user instead. (Perhaps this causes point 5 to happen?)

It's a bit of a long list but I tried to find as much imperfections as possible. Overall I really like how it looks and behaves so I'm definitely into merging this after some improvements 👍


I'll follow with code-focused review in the coming days. For now I wanted to focus mostly on UI and UX.

Copy link
Owner

@Tunous Tunous left a comment

Choose a reason for hiding this comment

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

I've went over the code and left some comments. Generally there weren't many issues that I found but I can see that you had some problems with rx inside of AccountManagerActivity. This part needs some rethinking. Mostly the confirmAction which could be cleaned up a bit and split into smaller parts.

public Completable clearMessages() {
return Completable.fromAction(() -> {
try (BriteDatabase.Transaction transaction = briteDatabase.newTransaction()) {
briteDatabase.delete(CachedMessage.TABLE_NAME, "");
Copy link
Owner

Choose a reason for hiding this comment

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

Based on documentation passing null as whereClause parameter will delete all rows. I would suggest to do that instead of passing empty string.

Suggested change
briteDatabase.delete(CachedMessage.TABLE_NAME, "");
briteDatabase.delete(CachedMessage.TABLE_NAME, null);

Copy link
Author

Choose a reason for hiding this comment

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

Ah OK. Anyways I wasn't 100% sure about deleting the cache table but switching to other account would end in merging PM from all your accounts. It's seems to be more a hack than a fix to me.

@@ -184,8 +185,8 @@ DraftStore provideReplyDraftStore(ReplyRepository replyRepository) {
@Provides
OnLoginRequireListener provideOnLoginRequireListener(Application appContext) {
return () -> {
Intent loginIntent = LoginActivity.intent(appContext);
loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent loginIntent = new Intent(appContext, AccountManagerActivity.class);
Copy link
Owner

Choose a reason for hiding this comment

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

AccountManagerActivity has intent function which you could use.

protected void onPostCreate(@Nullable Bundle savedState) {
super.onPostCreate(savedState);

setupUserList();
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you decide to place this inside of onPostCreate? Is there anything wrong with placing it inside of onCreate?

Documentation suggests that it isn't intended to be overridden:

Applications will generally not implement this method; it is intended for system classes to do final initialization after application code has run.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm I have to check where I copy that from. Maybe it's wrong on both side.

}

@Override
protected void onSaveInstanceState(Bundle outState) {
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary override.

return holder;

} else {
throw new AssertionError();
Copy link
Owner

Choose a reason for hiding this comment

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

Could add a message for easier debugging in case this ever happens.

.subscribe(
() -> {
//this.userSessionRepository.get().switchAccount(null, getApplicationContext());
thread.start();
Copy link
Owner

Choose a reason for hiding this comment

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

Mixing threads and rx, that asks for too much trouble :)

If I'm not mistaken you used it to delay the execution by 2 seconds. Did you try using .delay(2, TimeUnit.SECONDS) instead?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah. Rx and me... we don't get along very well haha. When the PR is updated I'll let someone take care of this issue.


private Completable confirmAction(int action) {
if (confirmTimer.isDisposed()) {
ACTION = action;
Copy link
Owner

Choose a reason for hiding this comment

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

Is this necessary? I can see that you are using ACTION only inside of this method. You could use the value passed to parameter directly and remove the field.

Copy link
Author

Choose a reason for hiding this comment

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

Will check.

}

private Completable queueToDelete(AccountManager account){
this.selectedAccount = account;
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary this. prefix.

confirmTimer = Observable.timer(5, TimeUnit.SECONDS)
.compose(applySchedulers())
.subscribe(o -> {
runOnUiThread(() -> {
Copy link
Owner

Choose a reason for hiding this comment

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

The call to applySchedulres above sets observation to happen on the main thread which makes this call redundant.

accountsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
accountsRecyclerView.setAdapter(accountManagerAdapter.get());

//fullscreenProgressView.setVisibility(View.VISIBLE);
Copy link
Owner

Choose a reason for hiding this comment

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

If there is any commented-out code it should be removed.

@mvietri
Copy link
Author

mvietri commented Nov 11, 2019

Hey @Tunous Thanks for your feedback and review. I'll update the PR (I didn't have the time yet sadly).

@Tunous Tunous added the waiting Pull requests that require changes or issues that await response label Jun 13, 2020
@Tunous
Copy link
Owner

Tunous commented Jan 10, 2021

Superseded by #329 which continued on work from this pull request. @mvietri Thank you for the original work.

@Tunous Tunous closed this Jan 10, 2021
@Tunous Tunous added duplicate This issue or pull request already exists and removed waiting Pull requests that require changes or issues that await response labels Jan 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants