summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/app')
-rw-r--r--src/com/android/gallery3d/app/AlbumDataLoader.java2
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java7
-rw-r--r--src/com/android/gallery3d/app/AlbumPicker.java2
-rw-r--r--src/com/android/gallery3d/app/AlbumSetDataLoader.java2
-rw-r--r--src/com/android/gallery3d/app/AppBridge.java2
-rw-r--r--src/com/android/gallery3d/app/CropImage.java7
-rw-r--r--src/com/android/gallery3d/app/EyePosition.java3
-rw-r--r--src/com/android/gallery3d/app/FilterUtils.java1
-rw-r--r--src/com/android/gallery3d/app/GalleryActionBar.java6
-rw-r--r--src/com/android/gallery3d/app/GalleryAppImpl.java5
-rw-r--r--src/com/android/gallery3d/app/ManageCachePage.java1
-rw-r--r--src/com/android/gallery3d/app/MovieControllerOverlay.java724
-rw-r--r--src/com/android/gallery3d/app/OrientationManager.java1
-rw-r--r--src/com/android/gallery3d/app/PhotoDataAdapter.java14
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java3
-rw-r--r--src/com/android/gallery3d/app/PickerActivity.java1
-rw-r--r--src/com/android/gallery3d/app/SinglePhotoDataAdapter.java5
-rw-r--r--src/com/android/gallery3d/app/SlideshowDataAdapter.java6
-rw-r--r--src/com/android/gallery3d/app/SlideshowPage.java11
19 files changed, 445 insertions, 358 deletions
diff --git a/src/com/android/gallery3d/app/AlbumDataLoader.java b/src/com/android/gallery3d/app/AlbumDataLoader.java
index 71a575658..8e6fcf5c2 100644
--- a/src/com/android/gallery3d/app/AlbumDataLoader.java
+++ b/src/com/android/gallery3d/app/AlbumDataLoader.java
@@ -201,6 +201,7 @@ public class AlbumDataLoader {
}
private class MySourceListener implements ContentListener {
+ @Override
public void onContentDirty() {
if (mReloadTask != null) mReloadTask.notifyDirty();
}
@@ -243,6 +244,7 @@ public class AlbumDataLoader {
mVersion = version;
}
+ @Override
public UpdateInfo call() throws Exception {
UpdateInfo info = new UpdateInfo();
long version = mVersion;
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index b4e600bd8..be17f975a 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -459,6 +459,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
});
mActionModeHandler = new ActionModeHandler(mActivity, mSelectionManager);
mActionModeHandler.setActionModeListener(new ActionModeListener() {
+ @Override
public boolean onActionItemClicked(MenuItem item) {
return onItemSelected(item);
}
@@ -483,6 +484,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (mDetailsHelper == null) {
mDetailsHelper = new DetailsHelper(mActivity, mRootPane, mDetailsSource);
mDetailsHelper.setCloseListener(new CloseListener() {
+ @Override
public void onClose() {
hideDetails();
}
@@ -607,6 +609,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
}
+ @Override
public void onSelectionModeChange(int mode) {
switch (mode) {
case SelectionManager.ENTER_SELECTION_MODE: {
@@ -627,6 +630,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
}
+ @Override
public void onSelectionChange(Path path, boolean selected) {
Utils.assertTrue(mActionMode != null);
int count = mSelectionManager.getSelectedCount();
@@ -693,16 +697,19 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private class MyDetailsSource implements DetailsHelper.DetailsSource {
private int mIndex;
+ @Override
public int size() {
return mAlbumDataAdapter.size();
}
+ @Override
public int setIndex() {
Path id = mSelectionManager.getSelected(false).get(0);
mIndex = mAlbumDataAdapter.findItem(id);
return mIndex;
}
+ @Override
public MediaDetails getDetails() {
// this relies on setIndex() being called beforehand
MediaObject item = mAlbumDataAdapter.get(mIndex);
diff --git a/src/com/android/gallery3d/app/AlbumPicker.java b/src/com/android/gallery3d/app/AlbumPicker.java
index 7509e63cb..65eb77291 100644
--- a/src/com/android/gallery3d/app/AlbumPicker.java
+++ b/src/com/android/gallery3d/app/AlbumPicker.java
@@ -24,8 +24,6 @@ import com.android.gallery3d.data.DataManager;
public class AlbumPicker extends PickerActivity {
- public static final String KEY_ALBUM_PATH = "album-path";
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
index 33a30bcca..9613f99ec 100644
--- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java
+++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java
@@ -219,6 +219,7 @@ public class AlbumSetDataLoader {
}
private class MySourceListener implements ContentListener {
+ @Override
public void onContentDirty() {
mReloadTask.notifyDirty();
}
@@ -279,6 +280,7 @@ public class AlbumSetDataLoader {
mUpdateInfo = info;
}
+ @Override
public Void call() {
// Avoid notifying listeners of status change after pause
// Otherwise gallery will be in inconsistent state after resume.
diff --git a/src/com/android/gallery3d/app/AppBridge.java b/src/com/android/gallery3d/app/AppBridge.java
index 5d6b1ec52..f89b35a4e 100644
--- a/src/com/android/gallery3d/app/AppBridge.java
+++ b/src/com/android/gallery3d/app/AppBridge.java
@@ -23,10 +23,12 @@ import com.android.gallery3d.ui.ScreenNail;
// This is the bridge to connect a PhotoPage to the external environment.
public abstract class AppBridge implements Parcelable {
+ @Override
public int describeContents() {
return 0;
}
+ @Override
public void writeToParcel(Parcel dest, int flags) {
}
diff --git a/src/com/android/gallery3d/app/CropImage.java b/src/com/android/gallery3d/app/CropImage.java
index a587624ed..6faf8cbcc 100644
--- a/src/com/android/gallery3d/app/CropImage.java
+++ b/src/com/android/gallery3d/app/CropImage.java
@@ -249,6 +249,7 @@ public class CropImage extends AbstractGalleryActivity {
mCropRect = cropRect;
}
+ @Override
public Intent run(JobContext jc) {
RectF cropRect = mCropRect;
Bundle extra = getIntent().getExtras();
@@ -487,6 +488,7 @@ public class CropImage extends AbstractGalleryActivity {
// We wrap the OutputStream so that it can be interrupted.
final InterruptableOutputStream ios = new InterruptableOutputStream(os);
jc.setCancelListener(new CancelListener() {
+ @Override
public void onCancel() {
ios.interrupt();
}
@@ -545,6 +547,7 @@ public class CropImage extends AbstractGalleryActivity {
this, null, getString(messageId), true, false);
mSaveTask = getThreadPool().submit(new SaveOutput(cropRect),
new FutureListener<Intent>() {
+ @Override
public void onFutureDone(Future<Intent> future) {
mSaveTask = null;
if (future.isCancelled()) return;
@@ -827,6 +830,7 @@ public class CropImage extends AbstractGalleryActivity {
if (supportedByBitmapRegionDecoder) {
mLoadTask = getThreadPool().submit(new LoadDataTask(mMediaItem),
new FutureListener<BitmapRegionDecoder>() {
+ @Override
public void onFutureDone(Future<BitmapRegionDecoder> future) {
mLoadTask = null;
BitmapRegionDecoder decoder = future.get();
@@ -841,6 +845,7 @@ public class CropImage extends AbstractGalleryActivity {
} else {
mLoadBitmapTask = getThreadPool().submit(new LoadBitmapDataTask(mMediaItem),
new FutureListener<Bitmap>() {
+ @Override
public void onFutureDone(Future<Bitmap> future) {
mLoadBitmapTask = null;
Bitmap bitmap = future.get();
@@ -925,6 +930,7 @@ public class CropImage extends AbstractGalleryActivity {
mItem = item;
}
+ @Override
public BitmapRegionDecoder run(JobContext jc) {
return mItem == null ? null : mItem.requestLargeImage().run(jc);
}
@@ -936,6 +942,7 @@ public class CropImage extends AbstractGalleryActivity {
public LoadBitmapDataTask(MediaItem item) {
mItem = item;
}
+ @Override
public Bitmap run(JobContext jc) {
return mItem == null
? null
diff --git a/src/com/android/gallery3d/app/EyePosition.java b/src/com/android/gallery3d/app/EyePosition.java
index 89e08468c..d99d97b0e 100644
--- a/src/com/android/gallery3d/app/EyePosition.java
+++ b/src/com/android/gallery3d/app/EyePosition.java
@@ -31,6 +31,7 @@ import com.android.gallery3d.common.Utils;
import com.android.gallery3d.util.GalleryUtils;
public class EyePosition {
+ @SuppressWarnings("unused")
private static final String TAG = "EyePosition";
public interface EyePositionListener {
@@ -180,9 +181,11 @@ public class EyePosition {
}
private class PositionListener implements SensorEventListener {
+ @Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
+ @Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_GYROSCOPE: {
diff --git a/src/com/android/gallery3d/app/FilterUtils.java b/src/com/android/gallery3d/app/FilterUtils.java
index c15457e7e..61a261f2c 100644
--- a/src/com/android/gallery3d/app/FilterUtils.java
+++ b/src/com/android/gallery3d/app/FilterUtils.java
@@ -54,6 +54,7 @@ import com.android.gallery3d.data.Path;
// functions. setupMenuItems() makes sure those types cannot be selected.
//
public class FilterUtils {
+ @SuppressWarnings("unused")
private static final String TAG = "FilterUtils";
public static final int CLUSTER_BY_ALBUM = 1;
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java
index 5c61648f7..2794b3fcd 100644
--- a/src/com/android/gallery3d/app/GalleryActionBar.java
+++ b/src/com/android/gallery3d/app/GalleryActionBar.java
@@ -36,6 +36,7 @@ import com.android.gallery3d.R;
import java.util.ArrayList;
public class GalleryActionBar implements ActionBar.OnNavigationListener {
+ @SuppressWarnings("unused")
private static final String TAG = "GalleryActionBar";
private ClusterRunner mClusterRunner;
@@ -91,18 +92,22 @@ public class GalleryActionBar implements ActionBar.OnNavigationListener {
private class ClusterAdapter extends BaseAdapter {
+ @Override
public int getCount() {
return sClusterItems.length;
}
+ @Override
public Object getItem(int position) {
return sClusterItems[position];
}
+ @Override
public long getItemId(int position) {
return sClusterItems[position].action;
}
+ @Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.action_bar_text,
@@ -207,6 +212,7 @@ public class GalleryActionBar implements ActionBar.OnNavigationListener {
final ArrayList<Integer> actions = mActions;
new AlertDialog.Builder(mContext).setTitle(R.string.group_by).setItems(
mTitles, new DialogInterface.OnClickListener() {
+ @Override
public void onClick(DialogInterface dialog, int which) {
// Need to lock rendering when operations invoked by system UI (main thread) are
// modifying slot data used in GL thread for rendering.
diff --git a/src/com/android/gallery3d/app/GalleryAppImpl.java b/src/com/android/gallery3d/app/GalleryAppImpl.java
index 852926bc7..f725ccf5a 100644
--- a/src/com/android/gallery3d/app/GalleryAppImpl.java
+++ b/src/com/android/gallery3d/app/GalleryAppImpl.java
@@ -49,10 +49,12 @@ public class GalleryAppImpl extends Application implements GalleryApp {
PicasaSource.initialize(this);
}
+ @Override
public Context getAndroidContext() {
return this;
}
+ @Override
public synchronized DataManager getDataManager() {
if (mDataManager == null) {
mDataManager = new DataManager(this);
@@ -61,6 +63,7 @@ public class GalleryAppImpl extends Application implements GalleryApp {
return mDataManager;
}
+ @Override
public ImageCacheService getImageCacheService() {
// This method may block on file I/O so a dedicated lock is needed here.
synchronized (mLock) {
@@ -71,6 +74,7 @@ public class GalleryAppImpl extends Application implements GalleryApp {
}
}
+ @Override
public synchronized ThreadPool getThreadPool() {
if (mThreadPool == null) {
mThreadPool = new ThreadPool();
@@ -78,6 +82,7 @@ public class GalleryAppImpl extends Application implements GalleryApp {
return mThreadPool;
}
+ @Override
public synchronized DownloadCache getDownloadCache() {
if (mDownloadCache == null) {
File cacheDir = new File(getExternalCacheDir(), DOWNLOAD_FOLDER);
diff --git a/src/com/android/gallery3d/app/ManageCachePage.java b/src/com/android/gallery3d/app/ManageCachePage.java
index cdbbfdc50..1f107285e 100644
--- a/src/com/android/gallery3d/app/ManageCachePage.java
+++ b/src/com/android/gallery3d/app/ManageCachePage.java
@@ -56,6 +56,7 @@ public class ManageCachePage extends ActivityState implements
EyePosition.EyePositionListener, OnClickListener {
public static final String KEY_MEDIA_PATH = "media-path";
+ @SuppressWarnings("unused")
private static final String TAG = "ManageCachePage";
private static final int DATA_CACHE_SIZE = 256;
diff --git a/src/com/android/gallery3d/app/MovieControllerOverlay.java b/src/com/android/gallery3d/app/MovieControllerOverlay.java
index f2c9e05dd..4781a1b8a 100644
--- a/src/com/android/gallery3d/app/MovieControllerOverlay.java
+++ b/src/com/android/gallery3d/app/MovieControllerOverlay.java
@@ -41,365 +41,387 @@ import com.android.gallery3d.R;
* The playback controller for the Movie Player.
*/
public class MovieControllerOverlay extends FrameLayout implements
- ControllerOverlay,
- OnClickListener,
- AnimationListener,
- TimeBar.Listener {
-
- private enum State {
- PLAYING,
- PAUSED,
- ENDED,
- ERROR,
- LOADING
- }
-
- private static final float ERROR_MESSAGE_RELATIVE_PADDING = 1.0f / 6;
-
- private Listener listener;
-
- private final View background;
- private final TimeBar timeBar;
-
- private View mainView;
- private final LinearLayout loadingView;
- private final TextView errorView;
- private final ImageView playPauseReplayView;
-
- private final Handler handler;
- private final Runnable startHidingRunnable;
- private final Animation hideAnimation;
-
- private State state;
-
- private boolean hidden;
-
- private boolean canReplay = true;
-
- public MovieControllerOverlay(Context context) {
- super(context);
-
- state = State.LOADING;
-
- LayoutParams wrapContent =
- new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- LayoutParams matchParent =
- new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-
- background = new View(context);
- background.setBackgroundColor(context.getResources().getColor(R.color.darker_transparent));
- addView(background, matchParent);
-
- timeBar = new TimeBar(context, this);
- addView(timeBar, wrapContent);
-
- loadingView = new LinearLayout(context);
- loadingView.setOrientation(LinearLayout.VERTICAL);
- loadingView.setGravity(Gravity.CENTER_HORIZONTAL);
- ProgressBar spinner = new ProgressBar(context);
- spinner.setIndeterminate(true);
- loadingView.addView(spinner, wrapContent);
- TextView loadingText = createOverlayTextView(context);
- loadingText.setText(R.string.loading_video);
- loadingView.addView(loadingText, wrapContent);
- addView(loadingView, wrapContent);
-
- playPauseReplayView = new ImageView(context);
- playPauseReplayView.setImageResource(R.drawable.ic_vidcontrol_play);
- playPauseReplayView.setBackgroundResource(R.drawable.bg_vidcontrol);
- playPauseReplayView.setScaleType(ScaleType.CENTER);
- playPauseReplayView.setFocusable(true);
- playPauseReplayView.setClickable(true);
- playPauseReplayView.setOnClickListener(this);
- addView(playPauseReplayView, wrapContent);
-
- errorView = createOverlayTextView(context);
- addView(errorView, matchParent);
-
- handler = new Handler();
- startHidingRunnable = new Runnable() {
- public void run() {
- startHiding();
- }
- };
-
- hideAnimation = AnimationUtils.loadAnimation(context, R.anim.player_out);
- hideAnimation.setAnimationListener(this);
-
- RelativeLayout.LayoutParams params =
- new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
- setLayoutParams(params);
- hide();
- }
-
- private TextView createOverlayTextView(Context context) {
- TextView view = new TextView(context);
- view.setGravity(Gravity.CENTER);
- view.setTextColor(0xFFFFFFFF);
- view.setPadding(0, 15, 0, 15);
- return view;
- }
-
- public void setListener(Listener listener) {
- this.listener = listener;
- }
-
- public void setCanReplay(boolean canReplay) {
- this.canReplay = canReplay;
- }
-
- public View getView() {
- return this;
- }
-
- public void showPlaying() {
- state = State.PLAYING;
- showMainView(playPauseReplayView);
- }
-
- public void showPaused() {
- state = State.PAUSED;
- showMainView(playPauseReplayView);
- }
-
- public void showEnded() {
- state = State.ENDED;
- showMainView(playPauseReplayView);
- }
-
- public void showLoading() {
- state = State.LOADING;
- showMainView(loadingView);
- }
-
- public void showErrorMessage(String message) {
- state = State.ERROR;
- int padding = (int) (getMeasuredWidth() * ERROR_MESSAGE_RELATIVE_PADDING);
- errorView.setPadding(padding, errorView.getPaddingTop(), padding, errorView.getPaddingBottom());
- errorView.setText(message);
- showMainView(errorView);
- }
-
- public void setTimes(int currentTime, int totalTime) {
- timeBar.setTime(currentTime, totalTime);
- }
-
- public void hide() {
- boolean wasHidden = hidden;
- hidden = true;
- playPauseReplayView.setVisibility(View.INVISIBLE);
- loadingView.setVisibility(View.INVISIBLE);
- background.setVisibility(View.INVISIBLE);
- timeBar.setVisibility(View.INVISIBLE);
- setVisibility(View.INVISIBLE);
- setFocusable(true);
- requestFocus();
- if (listener != null && wasHidden != hidden) {
- listener.onHidden();
- }
- }
-
- private void showMainView(View view) {
- mainView = view;
- errorView.setVisibility(mainView == errorView ? View.VISIBLE : View.INVISIBLE);
- loadingView.setVisibility(mainView == loadingView ? View.VISIBLE : View.INVISIBLE);
- playPauseReplayView.setVisibility(
- mainView == playPauseReplayView ? View.VISIBLE : View.INVISIBLE);
- show();
- }
-
- public void show() {
- boolean wasHidden = hidden;
- hidden = false;
- updateViews();
- setVisibility(View.VISIBLE);
- setFocusable(false);
- if (listener != null && wasHidden != hidden) {
- listener.onShown();
- }
- maybeStartHiding();
- }
-
- private void maybeStartHiding() {
- cancelHiding();
- if (state == State.PLAYING) {
- handler.postDelayed(startHidingRunnable, 2500);
- }
- }
-
- private void startHiding() {
- startHideAnimation(background);
- startHideAnimation(timeBar);
- startHideAnimation(playPauseReplayView);
- }
-
- private void startHideAnimation(View view) {
- if (view.getVisibility() == View.VISIBLE) {
- view.startAnimation(hideAnimation);
- }
- }
-
- private void cancelHiding() {
- handler.removeCallbacks(startHidingRunnable);
- background.setAnimation(null);
- timeBar.setAnimation(null);
- playPauseReplayView.setAnimation(null);
- }
-
- public void onAnimationStart(Animation animation) {
- // Do nothing.
- }
-
- public void onAnimationRepeat(Animation animation) {
- // Do nothing.
- }
-
- public void onAnimationEnd(Animation animation) {
- hide();
- }
-
- public void onClick(View view) {
- if (listener != null) {
- if (view == playPauseReplayView) {
- if (state == State.ENDED) {
- if (canReplay) {
- listener.onReplay();
- }
- } else if (state == State.PAUSED || state == State.PLAYING) {
- listener.onPlayPause();
- }
- }
+ ControllerOverlay,
+ OnClickListener,
+ AnimationListener,
+ TimeBar.Listener {
+
+ private enum State {
+ PLAYING,
+ PAUSED,
+ ENDED,
+ ERROR,
+ LOADING
+ }
+
+ private static final float ERROR_MESSAGE_RELATIVE_PADDING = 1.0f / 6;
+
+ private Listener listener;
+
+ private final View background;
+ private final TimeBar timeBar;
+
+ private View mainView;
+ private final LinearLayout loadingView;
+ private final TextView errorView;
+ private final ImageView playPauseReplayView;
+
+ private final Handler handler;
+ private final Runnable startHidingRunnable;
+ private final Animation hideAnimation;
+
+ private State state;
+
+ private boolean hidden;
+
+ private boolean canReplay = true;
+
+ public MovieControllerOverlay(Context context) {
+ super(context);
+
+ state = State.LOADING;
+
+ LayoutParams wrapContent =
+ new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ LayoutParams matchParent =
+ new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+
+ background = new View(context);
+ background.setBackgroundColor(context.getResources().getColor(R.color.darker_transparent));
+ addView(background, matchParent);
+
+ timeBar = new TimeBar(context, this);
+ addView(timeBar, wrapContent);
+
+ loadingView = new LinearLayout(context);
+ loadingView.setOrientation(LinearLayout.VERTICAL);
+ loadingView.setGravity(Gravity.CENTER_HORIZONTAL);
+ ProgressBar spinner = new ProgressBar(context);
+ spinner.setIndeterminate(true);
+ loadingView.addView(spinner, wrapContent);
+ TextView loadingText = createOverlayTextView(context);
+ loadingText.setText(R.string.loading_video);
+ loadingView.addView(loadingText, wrapContent);
+ addView(loadingView, wrapContent);
+
+ playPauseReplayView = new ImageView(context);
+ playPauseReplayView.setImageResource(R.drawable.ic_vidcontrol_play);
+ playPauseReplayView.setBackgroundResource(R.drawable.bg_vidcontrol);
+ playPauseReplayView.setScaleType(ScaleType.CENTER);
+ playPauseReplayView.setFocusable(true);
+ playPauseReplayView.setClickable(true);
+ playPauseReplayView.setOnClickListener(this);
+ addView(playPauseReplayView, wrapContent);
+
+ errorView = createOverlayTextView(context);
+ addView(errorView, matchParent);
+
+ handler = new Handler();
+ startHidingRunnable = new Runnable() {
+ @Override
+ public void run() {
+ startHiding();
+ }
+ };
+
+ hideAnimation = AnimationUtils.loadAnimation(context, R.anim.player_out);
+ hideAnimation.setAnimationListener(this);
+
+ RelativeLayout.LayoutParams params =
+ new RelativeLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ setLayoutParams(params);
+ hide();
}
- }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (hidden) {
- show();
+ private TextView createOverlayTextView(Context context) {
+ TextView view = new TextView(context);
+ view.setGravity(Gravity.CENTER);
+ view.setTextColor(0xFFFFFFFF);
+ view.setPadding(0, 15, 0, 15);
+ return view;
}
- return super.onKeyDown(keyCode, event);
- }
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (super.onTouchEvent(event)) {
- return true;
+ @Override
+ public void setListener(Listener listener) {
+ this.listener = listener;
}
- if (hidden) {
- show();
- return true;
+ @Override
+ public void setCanReplay(boolean canReplay) {
+ this.canReplay = canReplay;
}
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- cancelHiding();
- if (state == State.PLAYING || state == State.PAUSED) {
- listener.onPlayPause();
+
+ @Override
+ public View getView() {
+ return this;
+ }
+
+ @Override
+ public void showPlaying() {
+ state = State.PLAYING;
+ showMainView(playPauseReplayView);
+ }
+
+ @Override
+ public void showPaused() {
+ state = State.PAUSED;
+ showMainView(playPauseReplayView);
+ }
+
+ @Override
+ public void showEnded() {
+ state = State.ENDED;
+ showMainView(playPauseReplayView);
+ }
+
+ @Override
+ public void showLoading() {
+ state = State.LOADING;
+ showMainView(loadingView);
+ }
+
+ @Override
+ public void showErrorMessage(String message) {
+ state = State.ERROR;
+ int padding = (int) (getMeasuredWidth() * ERROR_MESSAGE_RELATIVE_PADDING);
+ errorView.setPadding(
+ padding, errorView.getPaddingTop(), padding, errorView.getPaddingBottom());
+ errorView.setText(message);
+ showMainView(errorView);
+ }
+
+ @Override
+ public void setTimes(int currentTime, int totalTime) {
+ timeBar.setTime(currentTime, totalTime);
+ }
+
+ public void hide() {
+ boolean wasHidden = hidden;
+ hidden = true;
+ playPauseReplayView.setVisibility(View.INVISIBLE);
+ loadingView.setVisibility(View.INVISIBLE);
+ background.setVisibility(View.INVISIBLE);
+ timeBar.setVisibility(View.INVISIBLE);
+ setVisibility(View.INVISIBLE);
+ setFocusable(true);
+ requestFocus();
+ if (listener != null && wasHidden != hidden) {
+ listener.onHidden();
+ }
+ }
+
+ private void showMainView(View view) {
+ mainView = view;
+ errorView.setVisibility(mainView == errorView ? View.VISIBLE : View.INVISIBLE);
+ loadingView.setVisibility(mainView == loadingView ? View.VISIBLE : View.INVISIBLE);
+ playPauseReplayView.setVisibility(
+ mainView == playPauseReplayView ? View.VISIBLE : View.INVISIBLE);
+ show();
+ }
+
+ @Override
+ public void show() {
+ boolean wasHidden = hidden;
+ hidden = false;
+ updateViews();
+ setVisibility(View.VISIBLE);
+ setFocusable(false);
+ if (listener != null && wasHidden != hidden) {
+ listener.onShown();
}
- break;
- case MotionEvent.ACTION_UP:
maybeStartHiding();
- break;
- }
- return true;
- }
-
- // The paddings of 4 sides which covered by system components. E.g.
- // +-----------------+\
- // | Action Bar | insets.top
- // +-----------------+/
- // | |
- // | Content Area | insets.right = insets.left = 0
- // | |
- // +-----------------+\
- // | Navigation Bar | insets.bottom
- // +-----------------+/
- // Please see View.fitSystemWindows() for more details.
- private final Rect mWindowInsets = new Rect();
-
- @Override
- protected boolean fitSystemWindows(Rect insets) {
- // We don't set the paddings of this View, otherwise,
- // the content will get cropped outside window
- mWindowInsets.set(insets);
- return true;
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- Rect insets = mWindowInsets;
- int pl = insets.left; // the left paddings
- int pr = insets.right;
- int pt = insets.top;
- int pb = insets.bottom;
-
- int h = bottom - top;
- int w = right - left;
- boolean error = errorView.getVisibility() == View.VISIBLE;
-
- int y = h - pb;
- // Put both TimeBar and Background just above the bottom system component.
- // But extend the background to the width of the screen, since we don't
- // care if it will be covered by a system component and it looks better.
- background.layout(0, y - timeBar.getBarHeight(), w, y);
- timeBar.layout(pl, y - timeBar.getPreferredHeight(), w - pr, y);
-
- // Needed, otherwise the framework will not re-layout in case only the padding is changed
- timeBar.requestLayout();
-
- // Put the play/pause/next/ previous button in the center of the screen
- layoutCenteredView(playPauseReplayView, 0, 0, w, h);
-
- if (mainView != null) {
- layoutCenteredView(mainView, 0, 0, w, h);
- }
- }
-
- private void layoutCenteredView(View view, int l, int t, int r, int b) {
- int cw = view.getMeasuredWidth();
- int ch = view.getMeasuredHeight();
- int cl = (r - l - cw) / 2;
- int ct = (b - t - ch) / 2;
- view.layout(cl, ct, cl + cw, ct + ch);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- measureChildren(widthMeasureSpec, heightMeasureSpec);
- }
-
- private void updateViews() {
- if (hidden) {
- return;
- }
- background.setVisibility(View.VISIBLE);
- timeBar.setVisibility(View.VISIBLE);
- playPauseReplayView.setImageResource(
- state == State.PAUSED ? R.drawable.ic_vidcontrol_play :
- state == State.PLAYING ? R.drawable.ic_vidcontrol_pause :
- R.drawable.ic_vidcontrol_reload);
- playPauseReplayView.setVisibility(
- (state != State.LOADING && state != State.ERROR &&
+ }
+
+ private void maybeStartHiding() {
+ cancelHiding();
+ if (state == State.PLAYING) {
+ handler.postDelayed(startHidingRunnable, 2500);
+ }
+ }
+
+ private void startHiding() {
+ startHideAnimation(background);
+ startHideAnimation(timeBar);
+ startHideAnimation(playPauseReplayView);
+ }
+
+ private void startHideAnimation(View view) {
+ if (view.getVisibility() == View.VISIBLE) {
+ view.startAnimation(hideAnimation);
+ }
+ }
+
+ private void cancelHiding() {
+ handler.removeCallbacks(startHidingRunnable);
+ background.setAnimation(null);
+ timeBar.setAnimation(null);
+ playPauseReplayView.setAnimation(null);
+ }
+
+ @Override
+ public void onAnimationStart(Animation animation) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ hide();
+ }
+
+ @Override
+ public void onClick(View view) {
+ if (listener != null) {
+ if (view == playPauseReplayView) {
+ if (state == State.ENDED) {
+ if (canReplay) {
+ listener.onReplay();
+ }
+ } else if (state == State.PAUSED || state == State.PLAYING) {
+ listener.onPlayPause();
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (hidden) {
+ show();
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (super.onTouchEvent(event)) {
+ return true;
+ }
+
+ if (hidden) {
+ show();
+ return true;
+ }
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ cancelHiding();
+ if (state == State.PLAYING || state == State.PAUSED) {
+ listener.onPlayPause();
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ maybeStartHiding();
+ break;
+ }
+ return true;
+ }
+
+ // The paddings of 4 sides which covered by system components. E.g.
+ // +-----------------+\
+ // | Action Bar | insets.top
+ // +-----------------+/
+ // | |
+ // | Content Area | insets.right = insets.left = 0
+ // | |
+ // +-----------------+\
+ // | Navigation Bar | insets.bottom
+ // +-----------------+/
+ // Please see View.fitSystemWindows() for more details.
+ private final Rect mWindowInsets = new Rect();
+
+ @Override
+ protected boolean fitSystemWindows(Rect insets) {
+ // We don't set the paddings of this View, otherwise,
+ // the content will get cropped outside window
+ mWindowInsets.set(insets);
+ return true;
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ Rect insets = mWindowInsets;
+ int pl = insets.left; // the left paddings
+ int pr = insets.right;
+ int pt = insets.top;
+ int pb = insets.bottom;
+
+ int h = bottom - top;
+ int w = right - left;
+ boolean error = errorView.getVisibility() == View.VISIBLE;
+
+ int y = h - pb;
+ // Put both TimeBar and Background just above the bottom system
+ // component.
+ // But extend the background to the width of the screen, since we don't
+ // care if it will be covered by a system component and it looks better.
+ background.layout(0, y - timeBar.getBarHeight(), w, y);
+ timeBar.layout(pl, y - timeBar.getPreferredHeight(), w - pr, y);
+
+ // Needed, otherwise the framework will not re-layout in case only the
+ // padding is changed
+ timeBar.requestLayout();
+
+ // Put the play/pause/next/ previous button in the center of the screen
+ layoutCenteredView(playPauseReplayView, 0, 0, w, h);
+
+ if (mainView != null) {
+ layoutCenteredView(mainView, 0, 0, w, h);
+ }
+ }
+
+ private void layoutCenteredView(View view, int l, int t, int r, int b) {
+ int cw = view.getMeasuredWidth();
+ int ch = view.getMeasuredHeight();
+ int cl = (r - l - cw) / 2;
+ int ct = (b - t - ch) / 2;
+ view.layout(cl, ct, cl + cw, ct + ch);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ measureChildren(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ private void updateViews() {
+ if (hidden) {
+ return;
+ }
+ background.setVisibility(View.VISIBLE);
+ timeBar.setVisibility(View.VISIBLE);
+ playPauseReplayView.setImageResource(
+ state == State.PAUSED ? R.drawable.ic_vidcontrol_play :
+ state == State.PLAYING ? R.drawable.ic_vidcontrol_pause :
+ R.drawable.ic_vidcontrol_reload);
+ playPauseReplayView.setVisibility(
+ (state != State.LOADING && state != State.ERROR &&
!(state == State.ENDED && !canReplay))
- ? View.VISIBLE : View.GONE);
- requestLayout();
- }
-
- // TimeBar listener
-
- public void onScrubbingStart() {
- cancelHiding();
- listener.onSeekStart();
- }
-
- public void onScrubbingMove(int time) {
- cancelHiding();
- listener.onSeekMove(time);
- }
-
- public void onScrubbingEnd(int time) {
- maybeStartHiding();
- listener.onSeekEnd(time);
- }
+ ? View.VISIBLE : View.GONE);
+ requestLayout();
+ }
+
+ // TimeBar listener
+
+ @Override
+ public void onScrubbingStart() {
+ cancelHiding();
+ listener.onSeekStart();
+ }
+
+ @Override
+ public void onScrubbingMove(int time) {
+ cancelHiding();
+ listener.onSeekMove(time);
+ }
+
+ @Override
+ public void onScrubbingEnd(int time) {
+ maybeStartHiding();
+ listener.onSeekEnd(time);
+ }
}
diff --git a/src/com/android/gallery3d/app/OrientationManager.java b/src/com/android/gallery3d/app/OrientationManager.java
index c3e91fb81..f5cbf06c6 100644
--- a/src/com/android/gallery3d/app/OrientationManager.java
+++ b/src/com/android/gallery3d/app/OrientationManager.java
@@ -24,7 +24,6 @@ import android.content.res.Configuration;
import android.provider.Settings;
import android.view.OrientationEventListener;
import android.view.Surface;
-import android.view.ViewConfiguration;
import com.android.gallery3d.ui.OrientationSource;
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index 555ea897c..5339e7e0a 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -341,6 +341,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
updateImageRequests();
}
+ @Override
public void resume() {
mIsActive = true;
mSource.addContentListener(mSourceListener);
@@ -353,6 +354,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
fireDataChange();
}
+ @Override
public void pause() {
mIsActive = false;
@@ -485,35 +487,43 @@ public class PhotoDataAdapter implements PhotoPage.Model {
return LOADING_INIT;
}
+ @Override
public ScreenNail getScreenNail() {
return getScreenNail(0);
}
+ @Override
public int getImageHeight() {
return mTileProvider.getImageHeight();
}
+ @Override
public int getImageWidth() {
return mTileProvider.getImageWidth();
}
+ @Override
public int getLevelCount() {
return mTileProvider.getLevelCount();
}
+ @Override
public Bitmap getTile(int level, int x, int y, int tileSize,
int borderSize, BitmapPool pool) {
return mTileProvider.getTile(level, x, y, tileSize, borderSize, pool);
}
+ @Override
public boolean isEmpty() {
return mSize == 0;
}
+ @Override
public int getCurrentIndex() {
return mCurrentIndex;
}
+ @Override
public MediaItem getMediaItem(int offset) {
int index = mCurrentIndex + offset;
if (index >= mContentStart && index < mContentEnd) {
@@ -522,6 +532,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
return null;
}
+ @Override
public void setCurrentPhoto(Path path, int indexHint) {
if (mItemPath == path) return;
mItemPath = path;
@@ -537,10 +548,12 @@ public class PhotoDataAdapter implements PhotoPage.Model {
}
}
+ @Override
public void setFocusHintDirection(int direction) {
mFocusHintDirection = direction;
}
+ @Override
public void setFocusHintPath(Path path) {
mFocusHintPath = path;
}
@@ -848,6 +861,7 @@ public class PhotoDataAdapter implements PhotoPage.Model {
}
private class SourceListener implements ContentListener {
+ @Override
public void onContentDirty() {
if (mReloadTask != null) mReloadTask.notifyDirty();
}
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 950f8c552..678ba6daf 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -26,15 +26,12 @@ import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.nfc.NfcAdapter;
-import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
import android.widget.ShareActionProvider;
import android.widget.Toast;
diff --git a/src/com/android/gallery3d/app/PickerActivity.java b/src/com/android/gallery3d/app/PickerActivity.java
index f5b2cbdfc..d5bb218ea 100644
--- a/src/com/android/gallery3d/app/PickerActivity.java
+++ b/src/com/android/gallery3d/app/PickerActivity.java
@@ -25,7 +25,6 @@ import android.view.View.OnClickListener;
import android.view.Window;
import com.android.gallery3d.R;
-import com.android.gallery3d.ui.GLRoot;
import com.android.gallery3d.ui.GLRootView;
public class PickerActivity extends AbstractGalleryActivity
diff --git a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
index f5b22d15c..6885456a6 100644
--- a/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/SinglePhotoDataAdapter.java
@@ -84,6 +84,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
private FutureListener<BitmapRegionDecoder> mLargeListener =
new FutureListener<BitmapRegionDecoder>() {
+ @Override
public void onFutureDone(Future<BitmapRegionDecoder> future) {
BitmapRegionDecoder decoder = future.get();
if (decoder == null) return;
@@ -100,12 +101,14 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
private FutureListener<Bitmap> mThumbListener =
new FutureListener<Bitmap>() {
+ @Override
public void onFutureDone(Future<Bitmap> future) {
mHandler.sendMessage(
mHandler.obtainMessage(MSG_UPDATE_IMAGE, future));
}
};
+ @Override
public boolean isEmpty() {
return false;
}
@@ -137,6 +140,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
}
}
+ @Override
public void resume() {
if (mTask == null) {
if (mHasFullImage) {
@@ -150,6 +154,7 @@ public class SinglePhotoDataAdapter extends TileImageViewAdapter
}
}
+ @Override
public void pause() {
Future<?> task = mTask;
task.cancel();
diff --git a/src/com/android/gallery3d/app/SlideshowDataAdapter.java b/src/com/android/gallery3d/app/SlideshowDataAdapter.java
index 7c934ee3b..7a0fba5fb 100644
--- a/src/com/android/gallery3d/app/SlideshowDataAdapter.java
+++ b/src/com/android/gallery3d/app/SlideshowDataAdapter.java
@@ -92,6 +92,7 @@ public class SlideshowDataAdapter implements SlideshowPage.Model {
}
private class ReloadTask implements Job<Void> {
+ @Override
public Void run(JobContext jc) {
while (true) {
synchronized (SlideshowDataAdapter.this) {
@@ -145,6 +146,7 @@ public class SlideshowDataAdapter implements SlideshowPage.Model {
}
private class SourceListener implements ContentListener {
+ @Override
public void onContentDirty() {
synchronized (SlideshowDataAdapter.this) {
mNeedReload.set(true);
@@ -168,8 +170,10 @@ public class SlideshowDataAdapter implements SlideshowPage.Model {
return mImageQueue.removeFirst();
}
+ @Override
public Future<Slide> nextSlide(FutureListener<Slide> listener) {
return mThreadPool.submit(new Job<Slide>() {
+ @Override
public Slide run(JobContext jc) {
jc.setMode(ThreadPool.MODE_NONE);
return innerNextBitmap();
@@ -177,6 +181,7 @@ public class SlideshowDataAdapter implements SlideshowPage.Model {
}, listener);
}
+ @Override
public void pause() {
synchronized (this) {
mIsActive = false;
@@ -188,6 +193,7 @@ public class SlideshowDataAdapter implements SlideshowPage.Model {
mReloadTask = null;
}
+ @Override
public synchronized void resume() {
mIsActive = true;
mSource.addContentListener(mSourceListener);
diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java
index a6ae52725..5ec447f65 100644
--- a/src/com/android/gallery3d/app/SlideshowPage.java
+++ b/src/com/android/gallery3d/app/SlideshowPage.java
@@ -134,6 +134,7 @@ public class SlideshowPage extends ActivityState {
private void loadNextBitmap() {
mModel.nextSlide(new FutureListener<Slide>() {
+ @Override
public void onFutureDone(Future<Slide> future) {
mPendingSlide = future.get();
mHandler.sendEmptyMessage(MSG_SHOW_PENDING_BITMAP);
@@ -242,10 +243,12 @@ public class SlideshowPage extends ActivityState {
mRepeat = repeat;
}
+ @Override
public int findItemIndex(Path path, int hint) {
return hint;
}
+ @Override
public MediaItem getMediaItem(int index) {
if (!mRepeat && index >= mOrder.length) return null;
if (mOrder.length == 0) return null;
@@ -259,6 +262,7 @@ public class SlideshowPage extends ActivityState {
return item;
}
+ @Override
public long reload() {
long version = mMediaSet.reload();
if (version != mSourceVersion) {
@@ -284,10 +288,12 @@ public class SlideshowPage extends ActivityState {
}
}
+ @Override
public void addContentListener(ContentListener listener) {
mMediaSet.addContentListener(listener);
}
+ @Override
public void removeContentListener(ContentListener listener) {
mMediaSet.removeContentListener(listener);
}
@@ -307,10 +313,12 @@ public class SlideshowPage extends ActivityState {
mRepeat = repeat;
}
+ @Override
public int findItemIndex(Path path, int hint) {
return mMediaSet.getIndexOfItem(path, hint);
}
+ @Override
public MediaItem getMediaItem(int index) {
int dataEnd = mDataStart + mData.size();
@@ -328,6 +336,7 @@ public class SlideshowPage extends ActivityState {
return (index < mDataStart || index >= dataEnd) ? null : mData.get(index - mDataStart);
}
+ @Override
public long reload() {
long version = mMediaSet.reload();
if (version != mDataVersion) {
@@ -337,10 +346,12 @@ public class SlideshowPage extends ActivityState {
return mDataVersion;
}
+ @Override
public void addContentListener(ContentListener listener) {
mMediaSet.addContentListener(listener);
}
+ @Override
public void removeContentListener(ContentListener listener) {
mMediaSet.removeContentListener(listener);
}