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

Add batch mode to contextual action bar #1601

Closed
wants to merge 4 commits into from
Closed

Add batch mode to contextual action bar #1601

wants to merge 4 commits into from

Conversation

eikowagenknecht
Copy link
Contributor

Follow-up to #1008. CAB = Contextual Action Bar.

The implementation works only on API 11+, so I left the "old" CAB for API 9-10.

If only one item is selected, the new CAB works exactly as the old one did. As soon as a second item is tapped, all menu items but delete get removed/hidden and the title is set to "batch mode" with a subtitle telling how many items are currently selected. The delete action works exactly like the deletion of conversations in the ConversationListFragment, which means it uses an AsyncTask. In fact, I took the code for most of the multiple-delete method from there, so credits to whoever implemented this ;-)

When the selected items are reduced to one, the classic CAB is shown again.

cab


}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is too long, please try breaking it up.

@eikowagenknecht
Copy link
Contributor Author

It's way shorter now (both ocurrences). I know that

  • setCorrectMenuVisibility(MessageRecord messageRecord, Menu menu) and
  • setCorrectMenuVisibility(MessageRecord messageRecord, android.view.Menu menu)

are almost the same, but I don't see how to merge them, because Menu (from ABS) and android.view.Menu are completely different classes. If you have any hints how to do that, let me know.

@moxie0
Copy link
Contributor

moxie0 commented Jun 13, 2014

Seems like it'd be better to make this work under GB than to have two context mode implementations in this class?

@mcginty
Copy link
Contributor

mcginty commented Jun 13, 2014

@eikowagenknecht
Copy link
Contributor Author

Allright, I'm working on it.

@eikowagenknecht
Copy link
Contributor Author

@moxie0 Here you go, should work on older devices now as well. I tested it for quite some minutes and did not find any problems. My emulator is currently messed up, so I could only test on my actual device running 4.4.2 though. Some more testing by someone else would be appreciated.

Also, getMessageRecord is not used any more. Shall I remove it?

/Edit: Ok, it seems like single clicking items while not in batch mode will also select them. Not intended, will fix.

@eikowagenknecht
Copy link
Contributor Author

Fixed, using the hackish solution of just calling "setItemChecked(position, false)" on every click, unchecking the item the instant it is checked. I tested this and it seems to work well.

The "new Runnable" method from method from http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode only works sometimes, unpredictable.

Also see https://groups.google.com/forum/#!topic/android-developers/qeJ-bnGUugg for further details.

I would prefer a clean solution, but can't find any, unfortunately. Maybe a more experienced Android developers has an ide on how to do this the best possible way?

@McLoo
Copy link
Contributor

McLoo commented Jun 15, 2014

short test on GB Emu (argh! sooo slooow!)
.

  • no "selected"-highlights for selected items. single or multi select
  • selecting an older message, where you have to scroll to, scrolls back to the last message
    [edit: the click highlight is shown]
  • i could swear while testing the point mentioned before the selection of the second message remove all selections - but surely hit the same message again
  • selected 2 messages. deleting question is "...delete THIS message"
  • when canceling deletion the selection (not the selected message) gets removed
  • what is the check mark for? deselecting? that's what it does.

Didn't get error logs. 👍

What about copying or forwarding a multiselect? Would be a nice to have :)

@McLoo
Copy link
Contributor

McLoo commented Jun 15, 2014

  • selecting a message with a link is not possible. when hitting the contained link the "open url" dialog pops up

@eikowagenknecht
Copy link
Contributor Author

Thanks for the testing, McLoo! On KK everythings works fine, so I didn't expect that many problems with GB. Seems like I will have to fix my emulator setup to do some more testing and repairing on my own :-\

Regarding the open url issue: That one isn't new, it has been a problem with the old context menu and also the previous CAB. There is an issue somewhere here and also a pull request that has been closed because it didn't fix all problems correctly and moxie didn't want a half baked solution.

Copying or forwarding a multiselect can be added once the basics work :-)

@eikowagenknecht
Copy link
Contributor Author

Ok, Emulator is running again. API 10 Phone emulated.

Checking your findings now:

no "selected"-highlights for selected items. single or multi select

Verified, same problem here.

selecting an older message, where you have to scroll to, scrolls back to the last message [edit: the click highlight is shown]

I can not see this happening here, neither with touch nor with dpad navigation. Can you describe it in more detail please? How do you select the message? When does it scroll?

i could swear while testing the point mentioned before the selection of the second message remove all selections - but surely hit the same message again

Could not confirm, but will be easier to test once selected messages have background :-)

selected 2 messages. deleting question is "...delete THIS message"

Oops, fixed.

when canceling deletion the selection (not the selected message) gets removed

This was intended behaviour, but changing it might be better. I'll have a look at it.

what is the check mark for? deselecting? that's what it does.

Which checkmark? The one on the top left? Yes, that is for deselecting and the same behaviour as in every other application that uses the CAB.

i.e. click delete -> click no -> actionbar stays
@eikowagenknecht
Copy link
Contributor Author

no "selected"-highlights for selected items. single or multi select

Seems to be an Android 2.3 problem. I tried following the first solution here: http://stackoverflow.com/questions/15799021/android-listview-selected-background-doesnt-work-in-2-3 but got lost because our Adapter class looks different.

Another approach (which apparently works) would be to do a setBackgroundResource on the view

  • after a longclick
  • after a click
  • loop to reset all in onDestroyActionMode

But I have two problems there:

  • Seems to be a bit hackish
  • I have to set the background depending on the current theme.. which I don't know

when canceling deletion the selection (not the selected message) gets removed

Changed that. Now the CAB stays until an action has been done.

@McLoo
Copy link
Contributor

McLoo commented Jun 15, 2014

selecting an older message, where you have to scroll to, scrolls back to the last message [edit: the click highlight is shown]

I can not see this happening here, neither with touch nor with dpad navigation. Can you describe it in more detail please? How do you select the message? When does it scroll?

explanation in screenshots:
unbenannt

@McLoo
Copy link
Contributor

McLoo commented Aug 2, 2014

@phenx-de any progress on this? just wanted to batch select, noticing it's not in yet :/

@eikowagenknecht
Copy link
Contributor Author

@McLoo Unfortunately not yet. I don't have too much free time for this right now. I hope this will change in the next few weeks, so I can finish this pull request.

@titaniumbones
Copy link

I'm also interested in this feature -- is this still the right place to watch for any new developments? Thanks for the hard work you guys.

@eikowagenknecht
Copy link
Contributor Author

Sorry, I won't be able to work on this any further in the next few month.

7cbdf61 could still be merged, though, making it work for newer android devices.

moxie0 added a commit that referenced this pull request Dec 14, 2014
moxie0 added a commit that referenced this pull request Dec 22, 2014
moxie0 added a commit that referenced this pull request Dec 29, 2014
@moxie0 moxie0 closed this in ed556fb Dec 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants