Gallery2: if phone is locked, pause the video, if not, start it.

If there was a video playing before locking the phone,
After pressing the emergency call option in lock screen,
and then presses back key, the MovieActivity will resume,
so the video will play background.

Set a listener, if Keyguard is locked,pause the video,
if not, start it.

CRs-Fixed: 427283

Change-Id: Ia825afee691ee53f53eebf1f96efe09ef88ca743
Gallery2: force close happens when remove Gallery widget

The mSource may be null if we destroyed the widget.

So we make the function return null if we remove the
widget to make gallery avoid force closing.

CRs-Fixed: 362477

Change-Id: Ied227235f4dc78aeed69a70c264e523268c344d0
Gallery2: cut some menu items if current page is single item

There is no need to show those items in the menu when we
view this picture in the Mms

Cut some menu items if current page is single item

CRs-Fixed: 379918

Change-Id: I73f7070aebb576c2fe783cbb24f4e6c97a3fc36a
Gallery2: update selected number for database change

mSourceMediaSet will be updated for database changed
But mTotal will not if it is more than zero.

Update mTotal all the time for database changed

CRs-Fixed: 407961

Change-Id: I432b33ba62c04b18c6a1628b6b10dc9b77a72fc1
Gallery2: set the progress bar when we pause the video

The progress bar isn't set when we pause the video.

Set the progress bar when we pause the video

CRs-Fixed: BZ1623

Change-Id: I3d450df6fdf8195983692ed8a71ab42717e9c36c
Gallery2: invalidate album view even only size changed

After deleting the pictures, it didn't request to
update the view. so the left pictures can not be
updated and displayed instantly.

Invalidate album view even only size changed to
make it shown correctly.

CRs-Fixed: 393995

Change-Id: I9924edf3a1d0e46d045425b9d078758e8cb50685
Gallery2: keep selection mode when deSelectAll

Origin code will call leaveSelectionMode function in
deSelectAll and will not keep in selected status on
this situation.

Add DESELECT_ALL_MODE in AlbumPage and
AlbumSetPage to make stay in selection mode even if
choose deSelectAll.

CRs-Fixed: 342469

Change-Id: Ia8819ba197444c33b1641ad33dd8602ecca0075c
Gallery2: if selected count is 0, leave selection mode.

If the selected count is 0, no need stay in selection
mode.

After we toggle a item, if selected count is 0，leave
the selection mode.

CRs-Fixed: 412492

Change-Id: Ia3ecd1c77f4074f21b1f906050b4a7bc2dc37c6e
Gallery2: catch OOM error when crop big-size picture

An OOM error happened when set big size of picture as wallpaper

We catch the OOM error, and if fail to crop the picture, we
show a toast.

CRs-Fixed: 522476

Change-Id: Ia9d7f41ca768c9183b26051fb08c9f823fec0074
Gallery2: The menu bar will not flicker.

When select/unselect items,the operation of menu bar is set
visible or invisible repeatly which cause the menu bar flicker.

Add a condition to judge whether the menu bar should invisible at the
beginning. And make the Share operation invisible only when the num of
selection picture is over 300.

CRs-Fixed: 567580

Change-Id: I58c724f7426a33f8b94bac174fc4d512a7aa6c49
Gallery2: Fix the superposition of two images issue

When we zoom out to film mode from single photo mode with more than two
fingers, PhotoView will receive multi onScaleBegin/onScaleEnd streams.
But when mModeChanged is true, it will only notify PositionController to
beginScale but not to endScale, then mInScale remains in true state. So
when we back to single photo mode from film mode, focuse photo can't do
scale animation in Box.startSnapback().

According to the logic in onScaleEnd(), we will ignore other scale begin
notification if film mode has been changed.

CRs-Fixed: 551984

Change-Id: I468d932adab0a3540f107501db4d0ea4b7ffbb10
Gallery2: Remove slideshow option if all files of the folder are video

Enter Gallery and open folder whose files are all video, press
menu key should no slideshow option.

Add condition to remove slideshow if the folder are all video
files.

CRs-Fixed: 574984

Change-Id: Ib1603f1609b6490e44039ab64abefb44f14bd477
Gallery2: fix cropview shows abnormal if lock and rotate screen

The canvas value will effect the screenbounds value.
When screen is locked, the screen orientation will be force
changed to portrait but the screenbounds will still use
landscape value.

To fix this issue, if found screenbounds changed, we will make
dirty true to update the view.

CRs-Fixed: 557210

Change-Id: Ia84581d122da76f084117dfd0a195ce2784e18c9
Gallery2: fix can not add gallery widget to home screen

When selected to add a cropped picture to home screen,
the binder transaction failed because it was too large,
add widget failed.

We reduce the allowed maximum bitmap size in intent,
to make sure that binder size will not greater than 1M.

CRs-Fixed: 528927

Change-Id: Id63c8503dead66ab18531a78b0b4206d1fd30d07
Gallery2: fix selection count didn't update after floder is deleted

If we select an album and then delete it in file explorer, the
Gallery2 can not update the selection count, we change to
leave selection mode when albumsetpage is paused.

CRs-Fixed: 529042

Change-Id: Ic972ea23a64e0779e18ca9397b4619fb90ce3ecf
Gallery2: fix display abnormal when tap sharpness in filtershow

In Android4.3 version, it using stride to pad row layouts in
script, and can't do 1D indexing of 2D objects, this make
the resulting pixel values are not the corresponding
coordinates' pixel value.

We change to use rsGetElementAt() not gPixels() to
get the correct pixel values.

CRs-Fixed: 539928

Change-Id: Ifc0e516014c9fd974f3e7df163b06f732499f7c0
Gallery2: Fix force close when deletes about 5000 pictures.

According to the log analysis, it's the NullPointerException
and ArrayIndexOutOfBoundsException which will cause application
crashes.

The root cause is multiple thread will call the method
getMediaItem in LocalMergeAlbum. To avoid multiple thread mess,
add lock to keep safe.

CRs-Fixed: 545575

Change-Id: Iaadbb638cfb3f15193f5fcb7d4027ddd5f881201
Gallery2: Fix NPE in LocalSource during monkey test.

The object which is obtained by accquire MediaProvider client is null
when MediaStorage is killed or disabled by monkey test or others.

Add null check in LocalSource.java::pause().

CRs-Fixed: 540075

Change-Id: Icba85e77e86793e344e55255c27b195c11186fc8
Gallery2: fix issue in readTag when parse Exif

When read some Tag of jpeg images,the offset is less than
the IFD0 offset position,then try to copy data above IFD0
as Tag value no matter whether data exists above IFD0,so
null exception occurs in System.arraycopy.This issue can
effect user in two aspects:
1.black thumbnail for some jpeg images in ALbumSetPage
and ALbumPage.
2.force close happens when get details of some jpeg images.

We set offset for this Tag not value on above situation.

Change-Id: Icd368afcbed80556de0940e562dbcca42c53c849
CRs-Fixed: 525081
Gallery2: fix two same albums come out after double click tags

When user click group by tags in albumpage,it will start
albumsetpage to make gallery display the pictures which
are sorted by tags.Then albumpsetpage will new a thread
to load albums data.So two threads will be created if user
click group by tags twice quickly.So the data will be handled
by two thread.So the size of the albums will be add twice.
So two same albums came out.

For thread security,we add a synchronized to make sure the mAlbums can
be only handled by one thread.

CRs-Fixed: 562742

Change-Id: Ib1e2356fe25811c6d5d083cedd1861ce3bf7dea3