-
Notifications
You must be signed in to change notification settings - Fork 35
Conversation
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. |
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 :)
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. |
There was a problem hiding this 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, ""); |
There was a problem hiding this comment.
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.
briteDatabase.delete(CachedMessage.TABLE_NAME, ""); | |
briteDatabase.delete(CachedMessage.TABLE_NAME, null); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(() -> { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
Hey @Tunous Thanks for your feedback and review. I'll update the PR (I didn't have the time yet sadly). |
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.
Some images: