summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AbstractGalleryActivity.java24
-rw-r--r--src/com/android/gallery3d/app/ActivityState.java3
-rw-r--r--src/com/android/gallery3d/app/AlbumListViewPage.java34
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java202
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java109
-rw-r--r--src/com/android/gallery3d/app/Config.java159
-rw-r--r--src/com/android/gallery3d/app/FilterUtils.java9
-rw-r--r--src/com/android/gallery3d/app/GalleryActionBar.java271
-rw-r--r--src/com/android/gallery3d/app/GalleryActivity.java303
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java3
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java163
-rw-r--r--src/com/android/gallery3d/app/PhotoPageBottomControls.java37
-rw-r--r--src/com/android/gallery3d/data/ClusterAlbum.java71
-rw-r--r--src/com/android/gallery3d/data/ClusterAlbumSet.java138
-rw-r--r--src/com/android/gallery3d/data/ClusterSource.java2
-rw-r--r--src/com/android/gallery3d/data/Clustering.java8
-rw-r--r--src/com/android/gallery3d/data/FilterDeleteSet.java4
-rw-r--r--src/com/android/gallery3d/data/LocalAlbum.java27
-rw-r--r--src/com/android/gallery3d/data/MediaItem.java3
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java6
-rw-r--r--src/com/android/gallery3d/data/MediaSet.java10
-rw-r--r--src/com/android/gallery3d/data/TimeClustering.java22
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java351
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryView.java2
-rw-r--r--src/com/android/gallery3d/filtershow/category/IconView.java6
-rw-r--r--src/com/android/gallery3d/filtershow/category/MainPanel.java86
-rw-r--r--src/com/android/gallery3d/filtershow/controller/BasicSlider.java7
-rw-r--r--src/com/android/gallery3d/filtershow/controller/StyleChooser.java2
-rw-r--r--src/com/android/gallery3d/filtershow/controller/TitledSlider.java2
-rw-r--r--src/com/android/gallery3d/filtershow/editors/Editor.java47
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorChanSat.java2
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorDraw.java12
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorGrad.java8
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorPanel.java31
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorStraighten.java2
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorVignette.java2
-rw-r--r--src/com/android/gallery3d/filtershow/editors/ParametricEditor.java14
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java6
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterDualCamFusionRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java8
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java8
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java9
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java9
-rw-r--r--src/com/android/gallery3d/filtershow/history/HistoryManager.java46
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java1
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java1
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java1
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java29
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java3
-rw-r--r--src/com/android/gallery3d/ui/AbstractSlotRenderer.java36
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java16
-rw-r--r--src/com/android/gallery3d/ui/AlbumLabelMaker.java153
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java3
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java2
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java333
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlotRenderer.java101
-rw-r--r--src/com/android/gallery3d/ui/DialogDetailsView.java44
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java37
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java2
-rw-r--r--src/com/android/gallery3d/ui/PopupList.java7
-rw-r--r--src/com/android/gallery3d/ui/SelectionManager.java14
-rw-r--r--src/com/android/gallery3d/ui/SlotView.java27
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java16
64 files changed, 2452 insertions, 647 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
index 84a9b5753..915fc948a 100644
--- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java
+++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java
@@ -37,6 +37,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.Toolbar;
import android.os.Handler;
import com.android.gallery3d.R;
@@ -62,6 +63,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext
private boolean mDisableToggleStatusBar;
private PanoramaViewHelper mPanoramaViewHelper;
private static final int ONRESUME_DELAY = 50;
+ private Toolbar mToolbar;
private AlertDialog mAlertDialog = null;
private BroadcastReceiver mMountReceiver = new BroadcastReceiver() {
@@ -76,7 +78,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mOrientationManager = new OrientationManager(this);
- toggleStatusBarByOrientation();
getWindow().setBackgroundDrawable(null);
mPanoramaViewHelper = new PanoramaViewHelper(this);
mPanoramaViewHelper.onCreate();
@@ -100,7 +101,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext
mStateManager.onConfigurationChange(config);
getGalleryActionBar().onConfigurationChanged();
invalidateOptionsMenu();
- toggleStatusBarByOrientation();
}
@Override
@@ -314,18 +314,6 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext
mDisableToggleStatusBar = true;
}
- // Shows status bar in portrait view, hide in landscape view
- private void toggleStatusBarByOrientation() {
- if (mDisableToggleStatusBar) return;
-
- Window win = getWindow();
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
- win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- } else {
- win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
- }
-
public TransitionStore getTransitionStore() {
return mTransitionStore;
}
@@ -392,4 +380,12 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext
Log.e(TAG, "Error printing an image", fnfe);
}
}
+
+ public Toolbar getToolbar() {
+ return mToolbar;
+ }
+
+ public void setToolbar(Toolbar toolbar) {
+ mToolbar = toolbar ;
+ }
}
diff --git a/src/com/android/gallery3d/app/ActivityState.java b/src/com/android/gallery3d/app/ActivityState.java
index 2f1e0c9d9..11be8c6dd 100644
--- a/src/com/android/gallery3d/app/ActivityState.java
+++ b/src/com/android/gallery3d/app/ActivityState.java
@@ -205,9 +205,6 @@ abstract public class ActivityState {
actionBar.show();
}
int stateCount = mActivity.getStateManager().getStateCount();
- mActivity.getGalleryActionBar().setDisplayOptions(stateCount > 1, true);
- // Default behavior, this can be overridden in ActivityState's onResume.
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
activity.invalidateOptionsMenu();
diff --git a/src/com/android/gallery3d/app/AlbumListViewPage.java b/src/com/android/gallery3d/app/AlbumListViewPage.java
new file mode 100644
index 000000000..a207cb969
--- /dev/null
+++ b/src/com/android/gallery3d/app/AlbumListViewPage.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.gallery3d.app;
+
+public class AlbumListViewPage extends AlbumPage {
+
+}
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index bd9f0170b..65442d056 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
//import android.drm.DrmHelper;
+import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
@@ -27,11 +28,15 @@ import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.text.TextUtils;
+import android.util.TypedValue;
+import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.gallery3d.R;
@@ -76,6 +81,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
public static final String KEY_SHOW_CLUSTER_MENU = "cluster-menu";
public static final String KEY_EMPTY_ALBUM = "empty-album";
public static final String KEY_RESUME_ANIMATION = "resume_animation";
+ public static final String KEY_IS_VIDEOS_SCREEN = "is-videos-screen";
+ public static final String KEY_VIEWTYPE = "viewtype";
private static final int REQUEST_SLIDESHOW = 1;
public static final int REQUEST_PHOTO = 2;
@@ -100,7 +107,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
protected SelectionManager mSelectionManager;
private boolean mGetContent;
- private boolean mShowClusterMenu;
+ //private boolean mShowClusterMenu;
+ private boolean mIsVideoScreen;
private ActionModeHandler mActionModeHandler;
private int mFocusIndex = 0;
@@ -124,6 +132,20 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private static final int MSG_PICK_PHOTO = 0;
private PhotoFallbackEffect mResumeEffect;
+
+ private Config.AlbumPage mConfig;
+ private Config.AlbumPageList mConfigList;
+ private GalleryActionBar mActionBar;
+
+ public static final int GRID_VIEW = 0;
+ public static final int LIST_VIEW = 1;
+ public static int mCurrentView = GRID_VIEW;
+ private final String PREF_VIEWTYPE = "albumview-type";
+ public boolean mViewType = true;
+ private Bundle mData;
+ private MenuItem mItemViewType;
+ private TextView tvEmptyAlbum;
+ private boolean mShowedEmptyToastForSelf;
private PhotoFallbackEffect.PositionProvider mPositionProvider =
new PhotoFallbackEffect.PositionProvider() {
@Override
@@ -159,21 +181,51 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
protected void onLayout(
boolean changed, int left, int top, int right, int bottom) {
- int slotViewTop = mActivity.getGalleryActionBar().getHeight();
- int slotViewBottom = bottom - top;
- int slotViewRight = right - left;
+ int paddingLeft;
+ int paddingBottom;
+ int paddingRight;
+ int paddingTop;
+
+ if (right - left > bottom - top) {
+ if (mViewType) {
+ paddingTop = mConfig.paddingLeft;
+ } else {
+ paddingTop = mConfigList.paddingLeft;
+ }
+ paddingBottom = mConfig.paddingBottomLand;
+ paddingRight = mConfig.paddingRightLand;
+ paddingLeft = mConfig.paddingLeftLand;
+ }
+ else {
+ if (mViewType) {
+ paddingTop = mConfig.paddingLeft;
+ paddingLeft = mConfig.paddingLeft;
+ } else {
+ paddingTop = mConfigList.paddingLeft;
+ paddingLeft = mConfigList.paddingLeft;
+ }
+ paddingBottom = mConfig.paddingBottom;
+ paddingRight = mConfig.paddingRight;
+ }
+ int slotViewTop = mActivity.getGalleryActionBar().getHeight()
+ + paddingTop;
+ int slotViewBottom = bottom - top - paddingBottom;
+ int slotViewRight = right - left - paddingRight;
+ int slotViewLeft = paddingLeft;
if (mShowDetails) {
- mDetailsHelper.layout(left, slotViewTop, right, bottom);
+ mDetailsHelper.layout(slotViewLeft, slotViewTop, slotViewRight, slotViewBottom);
} else {
mAlbumView.setHighlightItemPath(null);
}
// Set the mSlotView as a reference point to the open animation
mOpenCenter.setReferencePosition(0, slotViewTop);
- mSlotView.layout(0, slotViewTop, slotViewRight, slotViewBottom);
- GalleryUtils.setViewPointMatrix(mMatrix,
- (right - left) / 2, (bottom - top) / 2, -mUserDistance);
+ mSlotView.layout(slotViewLeft, slotViewTop, slotViewRight,
+ slotViewBottom);
+
+ GalleryUtils.setViewPointMatrix(mMatrix, (right - left) / 2,
+ (bottom - top) / 2, -mUserDistance);
}
@Override
@@ -213,6 +265,8 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
hideDetails();
} else if (mSelectionManager.inSelectionMode()) {
mSelectionManager.leaveSelectionMode();
+ } else if (mIsVideoScreen) {
+ super.onBackPressed();
} else {
if(mLaunchedFromPhotoPage) {
mActivity.getTransitionStore().putIfNotPresent(
@@ -233,6 +287,10 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (mInCameraApp) {
GalleryUtils.startGalleryActivity(mActivity);
} else if (mActivity.getStateManager().getStateCount() > 1) {
+ mActivity.getToolbar().setNavigationContentDescription(mActivity.getResources().
+ getString(R.string.drawer_desc));
+ mActivity.getToolbar().setNavigationIcon(R.drawable.drawer);
+ ((GalleryActivity)mActivity).toggleNavDrawer(true);
super.onBackPressed();
} else if (mParentMediaSetString != null) {
Bundle data = new Bundle(getData());
@@ -347,6 +405,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP,
startInFilmstrip);
data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, mMediaSet.isCameraRoll());
+ data.putBoolean(PhotoPage.KEY_FROM_VIDEOS_SCREEN, mIsVideoScreen);
if (startInFilmstrip) {
mActivity.getStateManager().switchState(this, FilmstripPage.class, data);
} else {
@@ -392,14 +451,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
String newPath = FilterUtils.newClusterPath(basePath, clusterType);
Bundle data = new Bundle(getData());
data.putString(AlbumSetPage.KEY_MEDIA_PATH, newPath);
- if (mShowClusterMenu) {
- Context context = mActivity.getAndroidContext();
- data.putString(AlbumSetPage.KEY_SET_TITLE, mMediaSet.getName());
- data.putString(AlbumSetPage.KEY_SET_SUBTITLE,
- GalleryActionBar.getClusterByTypeString(context, clusterType));
- }
-
- // mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
mActivity.getStateManager().startStateForResult(
AlbumSetPage.class, REQUEST_DO_ANIMATION, data);
}
@@ -408,12 +459,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
protected void onCreate(Bundle data, Bundle restoreState) {
super.onCreate(data, restoreState);
mUserDistance = GalleryUtils.meterToPixel(USER_DISTANCE_METER);
+ mCurrentView = GalleryUtils.getIntPref(mActivity, PREF_VIEWTYPE,
+ GRID_VIEW);
+ mViewType = mCurrentView == GRID_VIEW;
+ mData = data;
initializeViews();
initializeData(data);
mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
- mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
+ mIsVideoScreen = data.getBoolean(KEY_IS_VIDEOS_SCREEN, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
+ mActionBar = mActivity.getGalleryActionBar();
if (data.getBoolean(KEY_AUTO_SELECT_ALL)) {
mSelectionManager.selectAll();
@@ -454,12 +510,12 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
boolean enableHomeButton = (mActivity.getStateManager().getStateCount() > 1) |
mParentMediaSetString != null;
- GalleryActionBar actionBar = mActivity.getGalleryActionBar();
- actionBar.setDisplayOptions(enableHomeButton, false);
- if (!mGetContent) {
- actionBar.enableAlbumModeMenu(GalleryActionBar.ALBUM_GRID_MODE_SELECTED, this);
+ //GalleryActionBar actionBar = mActivity.getGalleryActionBar();
+ mActionBar.setDisplayOptions(enableHomeButton, true);
+ if (enableHomeButton) {
+ mActivity.getToolbar().setNavigationContentDescription("back");
+ mActivity.getToolbar().setNavigationIcon(R.drawable.back);
}
-
// Set the reload bit here to prevent it exit this page in clearLoadingBit().
setLoadingBit(BIT_LOADING_RELOAD);
mLoadingFailed = false;
@@ -488,9 +544,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mAlbumDataAdapter.pause();
mAlbumView.pause();
DetailsHelper.pause();
- if (!mGetContent) {
- mActivity.getGalleryActionBar().disableAlbumModeMenu(true);
- }
if (mSyncTask != null) {
mSyncTask.cancel();
@@ -511,10 +564,18 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private void initializeViews() {
mSelectionManager = new SelectionManager(mActivity, false);
mSelectionManager.setSelectionListener(this);
- Config.AlbumPage config = Config.AlbumPage.get(mActivity);
- mSlotView = new SlotView(mActivity, config.slotViewSpec);
- mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView,
- mSelectionManager, config.placeholderColor);
+ mConfig = Config.AlbumPage.get(mActivity);
+ mConfigList = Config.AlbumPageList.get(mActivity);
+ if (mViewType) {
+ mSlotView = new SlotView(mActivity, mConfig.slotViewSpec);
+ mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView,
+ mConfig.labelSpec, mSelectionManager, mConfig.placeholderColor, mViewType);
+ } else {
+ mSlotView = new SlotView(mActivity, mConfigList.slotViewSpec);
+ mAlbumView = new AlbumSlotRenderer(mActivity, mSlotView,
+ mConfigList.labelSpec, mSelectionManager,
+ mConfig.placeholderColor, mViewType);
+ }
mSlotView.setSlotRenderer(mAlbumView);
mRootPane.addComponent(mSlotView);
mSlotView.setListener(new SlotView.SimpleListener() {
@@ -583,26 +644,27 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
@Override
protected boolean onCreateActionBar(Menu menu) {
- GalleryActionBar actionBar = mActivity.getGalleryActionBar();
+ //GalleryActionBar actionBar = mActivity.getGalleryActionBar();
MenuInflater inflator = getSupportMenuInflater();
if (mGetContent) {
inflator.inflate(R.menu.pickup, menu);
int typeBits = mData.getInt(GalleryActivity.KEY_TYPE_BITS,
DataManager.INCLUDE_IMAGE);
- actionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
+ mActionBar.setTitle(GalleryUtils.getSelectionModePrompt(typeBits));
} else {
inflator.inflate(R.menu.album, menu);
- actionBar.setTitle(mMediaSet.getName());
+ mActionBar.setTitle(mMediaSet.getName());
- FilterUtils.setupMenuItems(actionBar, mMediaSetPath, true);
+ FilterUtils.setupMenuItems(mActionBar, mMediaSetPath, true);
- menu.findItem(R.id.action_group_by).setVisible(mShowClusterMenu);
menu.findItem(R.id.action_camera).setVisible(
- MediaSetUtils.isCameraSource(mMediaSetPath)
- && GalleryUtils.isCameraAvailable(mActivity));
+ GalleryUtils.isAnyCameraAvailable(mActivity));
+ menu.findItem(R.id.action_slideshow).setVisible(!mIsVideoScreen);
+ MenuItem item = menu.findItem(R.id.action_view_type);
+ updateMenuTitle(item);
}
- actionBar.setSubtitle(null);
+ //actionBar.setSubtitle(null);
return true;
}
@@ -650,10 +712,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mSelectionManager.setAutoLeaveSelectionMode(false);
mSelectionManager.enterSelectionMode();
return true;
- case R.id.action_group_by: {
- mActivity.getGalleryActionBar().showClusterDialog(this);
- return true;
- }
case R.id.action_slideshow: {
mInCameraAndWantQuitOnPause = false;
Bundle data = new Bundle();
@@ -676,6 +734,10 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
GalleryUtils.startCameraActivity(mActivity);
return true;
}
+ case R.id.action_view_type: {
+ switchView();
+ return true;
+ }
default:
return false;
}
@@ -793,12 +855,24 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
mLoadingBits &= ~loadTaskBit;
if (mLoadingBits == 0 && mIsActive) {
if (mAlbumDataAdapter.size() == 0) {
+ if (mIsVideoScreen)
+ {
+ mShowedEmptyToastForSelf = true;
+ showEmptyAlbumToast(Toast.LENGTH_LONG);
+ }
+ else {
Intent result = new Intent();
result.putExtra(KEY_EMPTY_ALBUM, true);
setStateResult(Activity.RESULT_OK, result);
mActivity.getStateManager().finishState(this);
+ }
+ return;
}
}
+ if (mShowedEmptyToastForSelf && mIsVideoScreen) {
+ mShowedEmptyToastForSelf = false;
+ hideEmptyAlbumToast();
+ }
}
private class MyLoadingListener implements LoadingListener {
@@ -850,4 +924,50 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
switchToFilmstrip();
}
}
+
+ public void updateMenuTitle(MenuItem item) {
+
+ item.setTitle(mViewType ? R.string.action_viewtype_list
+ : R.string.action_viewtype_grid);
+ }
+
+ private void switchView() {
+ if (mViewType) {
+ mCurrentView = LIST_VIEW;
+ GalleryUtils.setIntPref(mActivity, PREF_VIEWTYPE, mCurrentView);
+ mActivity.getStateManager().switchState(this,
+ AlbumListViewPage.class, mData);
+ } else {
+ mCurrentView = GRID_VIEW;
+ GalleryUtils.setIntPref(mActivity, PREF_VIEWTYPE, mCurrentView);
+ mActivity.getStateManager().switchState(this, AlbumPage.class,
+ mData);
+ }
+
+ }
+
+
+
+ private void showEmptyAlbumToast(int toastLength) {
+ tvEmptyAlbum = new TextView(mActivity);
+ tvEmptyAlbum.setText(R.string.tvEmptyVideos);
+ tvEmptyAlbum.setTextColor(Color.parseColor("#8A000000"));
+ tvEmptyAlbum.setGravity(Gravity.CENTER);
+ tvEmptyAlbum.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
+ RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity)
+ .findViewById(R.id.gallery_root);
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ lp.addRule(RelativeLayout.CENTER_IN_PARENT);
+ galleryRoot.addView(tvEmptyAlbum, lp);
+ }
+
+ private void hideEmptyAlbumToast() {
+
+ if (tvEmptyAlbum != null)
+ {
+ tvEmptyAlbum.setVisibility(View.GONE);
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 068ac33a0..d2cc0ca57 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -22,11 +22,14 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Color;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.util.TypedValue;
+import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuInflater;
@@ -35,6 +38,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.gallery3d.R;
@@ -122,6 +126,7 @@ public class AlbumSetPage extends ActivityState implements
private Button mCameraButton;
private boolean mShowedEmptyToastForSelf = false;
+ private TextView tvEmptyAlbum;
@Override
protected int getBackgroundColorId() {
@@ -136,17 +141,38 @@ public class AlbumSetPage extends ActivityState implements
boolean changed, int left, int top, int right, int bottom) {
mEyePosition.resetPosition();
- int slotViewTop = mActionBar.getHeight() + mConfig.paddingTop;
- int slotViewBottom = bottom - top - mConfig.paddingBottom;
- int slotViewRight = right - left;
+ int paddingLeft;
+ int paddingBottom;
+ int paddingRight;
+ int paddingTop;
+
+ if (right - left > bottom - top) {
+ paddingTop = mConfig.paddingTopLand;
+ paddingBottom = mConfig.paddingBottomLand;
+ paddingRight = mConfig.paddingRightLand;
+ paddingLeft = mConfig.paddingLeftLand;
+ }
+ else
+ {
+ paddingTop = mConfig.paddingTop;
+ paddingBottom = mConfig.paddingBottom;
+ paddingRight = mConfig.paddingRight;
+ paddingLeft = mConfig.paddingLeft;
+ }
+
+ int slotViewTop = mActionBar.getHeight() + paddingTop;
+ int slotViewBottom = bottom - top - paddingBottom;
+ int slotViewRight = right - left - paddingRight;
+ int slotViewLeft = paddingLeft ;
+
if (mShowDetails) {
- mDetailsHelper.layout(left, slotViewTop, right, bottom);
+ mDetailsHelper.layout(slotViewLeft, slotViewTop, slotViewRight, slotViewBottom);
} else {
mAlbumSetView.setHighlightItemPath(null);
}
- mSlotView.layout(0, slotViewTop, slotViewRight, slotViewBottom);
+ mSlotView.layout(slotViewLeft, slotViewTop, slotViewRight, slotViewBottom);
}
@Override
@@ -218,23 +244,24 @@ public class AlbumSetPage extends ActivityState implements
WeakReference<Toast> mEmptyAlbumToast = null;
private void showEmptyAlbumToast(int toastLength) {
- Toast toast;
- if (mEmptyAlbumToast != null) {
- toast = mEmptyAlbumToast.get();
- if (toast != null) {
- toast.show();
- return;
- }
- }
- toast = Toast.makeText(mActivity, R.string.empty_album, toastLength);
- mEmptyAlbumToast = new WeakReference<Toast>(toast);
- toast.show();
+ tvEmptyAlbum = new TextView(mActivity);
+ tvEmptyAlbum.setText(R.string.tvEmptyAlbum);
+ tvEmptyAlbum.setTextColor(Color.parseColor("#8A000000"));
+ tvEmptyAlbum.setGravity(Gravity.CENTER);
+ tvEmptyAlbum.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
+ RelativeLayout galleryRoot = (RelativeLayout) ((Activity) mActivity)
+ .findViewById(R.id.gallery_root);
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT);
+ lp.addRule(RelativeLayout.CENTER_IN_PARENT);
+ galleryRoot.addView(tvEmptyAlbum, lp);
}
private void hideEmptyAlbumToast() {
- if (mEmptyAlbumToast != null) {
- Toast toast = mEmptyAlbumToast.get();
- if (toast != null) toast.cancel();
+ if (tvEmptyAlbum != null)
+ {
+ tvEmptyAlbum.setVisibility(View.GONE);
}
}
@@ -272,10 +299,10 @@ public class AlbumSetPage extends ActivityState implements
data.putInt(PhotoPage.KEY_INDEX_HINT, 0);
data.putString(PhotoPage.KEY_MEDIA_SET_PATH,
mediaPath);
- data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, true);
+ data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, false);
data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, targetSet.isCameraRoll());
mActivity.getStateManager().startStateForResult(
- FilmstripPage.class, AlbumPage.REQUEST_PHOTO, data);
+ SinglePhotoPage.class, AlbumPage.REQUEST_PHOTO, data);
return;
}
data.putString(AlbumPage.KEY_MEDIA_PATH, mediaPath);
@@ -333,9 +360,8 @@ public class AlbumSetPage extends ActivityState implements
mEyePosition = new EyePosition(context, this);
mDetailsSource = new MyDetailsSource();
mActionBar = mActivity.getGalleryActionBar();
- mSelectedAction = data.getInt(AlbumSetPage.KEY_SELECTED_CLUSTER_TYPE,
- FilterUtils.CLUSTER_BY_ALBUM);
-
+ //mSelectedAction = data.getInt(AlbumSetPage.KEY_SELECTED_CLUSTER_TYPE,
+ // FilterUtils.CLUSTER_BY_ALBUM);
mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {
@Override
public void handleMessage(Message message) {
@@ -447,7 +473,7 @@ public class AlbumSetPage extends ActivityState implements
// Call disableClusterMenu to avoid receiving callback after paused.
// Don't hide menu here otherwise the list menu will disappear earlier than
// the action bar, which is janky and unwanted behavior.
- mActionBar.disableClusterMenu(false);
+ //mActionBar.disableClusterMenu(false);
if (mSyncTask != null) {
mSyncTask.cancel();
mSyncTask = null;
@@ -468,9 +494,9 @@ public class AlbumSetPage extends ActivityState implements
mAlbumSetView.resume();
mEyePosition.resume();
mActionModeHandler.resume();
- if (mShowClusterMenu) {
+ /*if (mShowClusterMenu) {
mActionBar.enableClusterMenu(mSelectedAction, this);
- }
+ }*/
if (!mInitialSynced) {
setLoadingBit(BIT_LOADING_SYNC);
mSyncTask = mMediaSet.requestSync(AlbumSetPage.this);
@@ -547,21 +573,21 @@ public class AlbumSetPage extends ActivityState implements
inflater.inflate(R.menu.albumset, menu);
boolean wasShowingClusterMenu = mShowClusterMenu;
mShowClusterMenu = !inAlbum;
- if (mShowClusterMenu != wasShowingClusterMenu) {
+ /*if (mShowClusterMenu != wasShowingClusterMenu) {
if (mShowClusterMenu) {
mActionBar.enableClusterMenu(mSelectedAction, this);
} else {
mActionBar.disableClusterMenu(true);
}
- }
- boolean selectAlbums = !inAlbum &&
- mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM;
+ }*/
+ boolean selectAlbums = !inAlbum ;// &&
+ // mActionBar.getClusterTypeAction() == FilterUtils.CLUSTER_BY_ALBUM;
MenuItem selectItem = menu.findItem(R.id.action_select);
selectItem.setTitle(activity.getString(
selectAlbums ? R.string.select_album : R.string.select_group));
MenuItem cameraItem = menu.findItem(R.id.action_camera);
- cameraItem.setVisible(GalleryUtils.isCameraAvailable(activity));
+ cameraItem.setVisible(GalleryUtils.isAnyCameraAvailable(activity));
FilterUtils.setupMenuItems(mActionBar, mMediaSet.getPath(), false);
@@ -574,10 +600,7 @@ public class AlbumSetPage extends ActivityState implements
MenuItem moreItem = menu.findItem(R.id.action_more_image);
moreItem.setVisible(mActivity.getResources().getBoolean(
R.bool.config_show_more_images));
-
-
- mActionBar.setTitle(mTitle);
- mActionBar.setSubtitle(mSubtitle);
+ mActionBar.setTitle(R.string.albums_title);
}
return true;
}
@@ -649,7 +672,7 @@ public class AlbumSetPage extends ActivityState implements
}
}
- private String getSelectedString() {
+ /*private String getSelectedString() {
int count = mSelectionManager.getSelectedCount();
int action = mActionBar.getClusterTypeAction();
int string = action == FilterUtils.CLUSTER_BY_ALBUM
@@ -657,22 +680,24 @@ public class AlbumSetPage extends ActivityState implements
: R.plurals.number_of_groups_selected;
String format = mActivity.getResources().getQuantityString(string, count);
return String.format(format, count);
- }
+ }*/
@Override
public void onSelectionModeChange(int mode) {
switch (mode) {
case SelectionManager.ENTER_SELECTION_MODE: {
- mActionBar.disableClusterMenu(true);
+ //mActionBar.disableClusterMenu(true);
mActionModeHandler.startActionMode();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+ ((GalleryActivity)mActivity).toggleNavDrawer(false);
break;
}
case SelectionManager.LEAVE_SELECTION_MODE: {
mActionModeHandler.finishActionMode();
- if (mShowClusterMenu) {
+ ((GalleryActivity)mActivity).toggleNavDrawer(true);
+ /*if (mShowClusterMenu) {
mActionBar.enableClusterMenu(mSelectedAction, this);
- }
+ }*/
mRootPane.invalidate();
break;
}
@@ -686,7 +711,7 @@ public class AlbumSetPage extends ActivityState implements
@Override
public void onSelectionChange(Path path, boolean selected) {
- mActionModeHandler.setTitle(getSelectedString());
+// mActionModeHandler.setTitle(getSelectedString());
mActionModeHandler.updateSupportedOperation(path, selected);
}
diff --git a/src/com/android/gallery3d/app/Config.java b/src/com/android/gallery3d/app/Config.java
index 7183acc33..8e8d11b26 100644
--- a/src/com/android/gallery3d/app/Config.java
+++ b/src/com/android/gallery3d/app/Config.java
@@ -21,7 +21,10 @@ import android.content.res.Resources;
import com.android.gallery3d.R;
import com.android.gallery3d.ui.AlbumSetSlotRenderer;
+import com.android.gallery3d.ui.AlbumSlotRenderer;
import com.android.gallery3d.ui.SlotView;
+import com.android.gallery3d.ui.TimeLineSlotRenderer;
+import com.android.gallery3d.ui.TimeLineSlotView;
final class Config {
public static class AlbumSetPage {
@@ -32,6 +35,12 @@ final class Config {
public int paddingTop;
public int paddingBottom;
public int placeholderColor;
+ public int paddingLeft;
+ public int paddingRight;
+ public int paddingTopLand;
+ public int paddingBottomLand;
+ public int paddingLeftLand;
+ public int paddingRightLand;
public static synchronized AlbumSetPage get(Context context) {
if (sInstance == null) {
@@ -46,21 +55,34 @@ final class Config {
placeholderColor = r.getColor(R.color.albumset_placeholder);
slotViewSpec = new SlotView.Spec();
- slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land);
- slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port);
+ //slotViewSpec.rowsLand = r.getInteger(R.integer.albumset_rows_land);
+ //slotViewSpec.rowsPort = r.getInteger(R.integer.albumset_rows_port);
+ slotViewSpec.colsLand = r.getInteger(R.integer.albumset_cols_land);
+ slotViewSpec.colsPort = r.getInteger(R.integer.albumset_cols_port);
slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.albumset_slot_gap);
+ slotViewSpec.slotGapLand = r.getDimensionPixelSize(R.dimen.albumset_slot_gap_land);
slotViewSpec.slotHeightAdditional = 0;
+ slotViewSpec.slotWidth = r.getDimensionPixelSize(R.dimen.slot_width);
+ slotViewSpec.slotHeight = r.getDimensionPixelSize(R.dimen.slot_height);
paddingTop = r.getDimensionPixelSize(R.dimen.albumset_padding_top);
paddingBottom = r.getDimensionPixelSize(R.dimen.albumset_padding_bottom);
+ paddingLeft = r.getDimensionPixelSize(R.dimen.albumset_padding_left);
+ paddingRight = r.getDimensionPixelSize(R.dimen.albumset_padding_right);
+
+ paddingTopLand = r.getDimensionPixelSize(R.dimen.albumset_padding_top_land);
+ paddingBottomLand = r.getDimensionPixelSize(R.dimen.albumset_padding_bottom_land);
+
+ paddingLeftLand = r.getDimensionPixelSize(R.dimen.albumset_padding_left_land);
+ paddingRightLand = r.getDimensionPixelSize(R.dimen.albumset_padding_right_land);
labelSpec = new AlbumSetSlotRenderer.LabelSpec();
labelSpec.labelBackgroundHeight = r.getDimensionPixelSize(
R.dimen.albumset_label_background_height);
- labelSpec.titleOffset = r.getDimensionPixelSize(
+ /*labelSpec.titleOffset = r.getDimensionPixelSize(
R.dimen.albumset_title_offset);
labelSpec.countOffset = r.getDimensionPixelSize(
- R.dimen.albumset_count_offset);
+ R.dimen.albumset_count_offset);*/
labelSpec.titleFontSize = r.getDimensionPixelSize(
R.dimen.albumset_title_font_size);
labelSpec.countFontSize = r.getDimensionPixelSize(
@@ -69,8 +91,12 @@ final class Config {
R.dimen.albumset_left_margin);
labelSpec.titleRightMargin = r.getDimensionPixelSize(
R.dimen.albumset_title_right_margin);
- labelSpec.iconSize = r.getDimensionPixelSize(
- R.dimen.albumset_icon_size);
+ labelSpec.titleLeftMargin = r.getDimensionPixelSize(
+ R.dimen.albumset_title_left_margin);
+ labelSpec.countRightMargin = r.getDimensionPixelSize(
+ R.dimen.albumset_count_right_margin);
+ /*labelSpec.iconSize = r.getDimensionPixelSize(
+ R.dimen.albumset_icon_size);*/
labelSpec.backgroundColor = r.getColor(
R.color.albumset_label_background);
labelSpec.titleColor = r.getColor(R.color.albumset_label_title);
@@ -80,9 +106,17 @@ final class Config {
public static class AlbumPage {
private static AlbumPage sInstance;
-
+ public AlbumSlotRenderer.LabelSpec labelSpec;
public SlotView.Spec slotViewSpec;
public int placeholderColor;
+ public int paddingTop;
+ public int paddingBottom;
+ public int paddingLeft;
+ public int paddingRight;
+ public int paddingTopLand;
+ public int paddingBottomLand;
+ public int paddingLeftLand;
+ public int paddingRightLand;
public static synchronized AlbumPage get(Context context) {
if (sInstance == null) {
@@ -97,9 +131,26 @@ final class Config {
placeholderColor = r.getColor(R.color.album_placeholder);
slotViewSpec = new SlotView.Spec();
- slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land);
- slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port);
+ //slotViewSpec.rowsLand = r.getInteger(R.integer.album_rows_land);
+ //slotViewSpec.rowsPort = r.getInteger(R.integer.album_rows_port);
+ slotViewSpec.colsLand = r.getInteger(R.integer.album_cols_land);
+ slotViewSpec.colsPort = r.getInteger(R.integer.album_cols_port);
+ slotViewSpec.slotWidth = r.getDimensionPixelSize(R.dimen.slot_width_album);
+ slotViewSpec.slotHeight = r.getDimensionPixelSize(R.dimen.slot_height_album);
slotViewSpec.slotGap = r.getDimensionPixelSize(R.dimen.album_slot_gap);
+ slotViewSpec.slotGapLand = r.getDimensionPixelSize(R.dimen.album_slot_gap_land);
+
+ paddingTop = r.getDimensionPixelSize(R.dimen.album_padding_top);
+ paddingBottom = r.getDimensionPixelSize(R.dimen.album_padding_bottom);
+
+ paddingLeft = r.getDimensionPixelSize(R.dimen.album_padding_left);
+ paddingRight = r.getDimensionPixelSize(R.dimen.album_padding_right);
+
+ paddingTopLand = r.getDimensionPixelSize(R.dimen.album_padding_top_land);
+ paddingBottomLand = r.getDimensionPixelSize(R.dimen.album_padding_bottom_land);
+
+ paddingLeftLand = r.getDimensionPixelSize(R.dimen.album_padding_left_land);
+ paddingRightLand = r.getDimensionPixelSize(R.dimen.album_padding_right_land);
}
}
@@ -123,5 +174,95 @@ final class Config {
cachePinMargin = r.getDimensionPixelSize(R.dimen.cache_pin_margin);
}
}
+
+ public static class AlbumPageList {
+ private static AlbumPageList sInstance;
+
+ public SlotView.Spec slotViewSpec;
+ public AlbumSlotRenderer.LabelSpec labelSpec;
+ public int paddingTop;
+ public int paddingBottom;
+ public int paddingLeft;
+ public int paddingRight;
+ public int placeholderColor;
+
+ public static synchronized AlbumPageList get(Context context) {
+ if (sInstance == null) {
+ sInstance = new AlbumPageList(context);
+ }
+ return sInstance;
+ }
+
+ private AlbumPageList(Context context) {
+ Resources r = context.getResources();
+
+ placeholderColor = r.getColor(R.color.album_placeholder);
+
+ slotViewSpec = new SlotView.Spec();
+ slotViewSpec.slotHeight = r
+ .getDimensionPixelSize(R.dimen.slot_height_albumlist);
+ slotViewSpec.slotGap = r
+ .getDimensionPixelSize(R.dimen.albumlist_slot_gap);
+ slotViewSpec.slotGapLand = r
+ .getDimensionPixelSize(R.dimen.albumlist_slot_gap);
+ paddingTop = r.getDimensionPixelSize(R.dimen.albumlist_padding_top);
+ paddingBottom = r
+ .getDimensionPixelSize(R.dimen.album_padding_bottom);
+
+ paddingLeft = r.getDimensionPixelSize(R.dimen.albumlist_left_margin);
+ paddingRight = r.getDimensionPixelSize(R.dimen.album_padding_right);
+ labelSpec = new AlbumSlotRenderer.LabelSpec();
+ labelSpec.labelBackgroundHeight = r
+ .getDimensionPixelSize(R.dimen.albumlist_label_background_height);
+ labelSpec.titleFontSize = r
+ .getDimensionPixelSize(R.dimen.albumset_title_font_size);
+ labelSpec.leftMargin = r
+ .getDimensionPixelSize(R.dimen.albumlist_left_margin);
+ labelSpec.titleLeftMargin = r
+ .getDimensionPixelSize(R.dimen.albumlist_title_margin);
+ labelSpec.iconSize = r
+ .getDimensionPixelSize(R.dimen.albumlist_thumb_size);
+ labelSpec.backgroundColor = r
+ .getColor(R.color.albumset_label_background);
+ labelSpec.titleColor = r.getColor(R.color.albumlist_label_title);
+ }
+ }
+
+ public static class TimeLinePage {
+ private static TimeLinePage sInstance;
+
+ public TimeLineSlotView.Spec slotViewSpec;
+ public TimeLineSlotRenderer.LabelSpec labelSpec;
+ public int placeholderColor;
+
+ public static synchronized TimeLinePage get(Context context) {
+ if (sInstance == null) {
+ sInstance = new TimeLinePage(context);
+ }
+ return sInstance;
+ }
+ private TimeLinePage(Context context) {
+ Resources r = context.getResources();
+
+ placeholderColor = r.getColor(R.color.album_placeholder);
+
+ slotViewSpec = new TimeLineSlotView.Spec();
+ slotViewSpec.colsLand = r.getInteger(R.integer.album_cols_land);
+ slotViewSpec.colsPort = r.getInteger(R.integer.album_cols_port);
+ slotViewSpec.slotGapPort = r.getDimensionPixelSize(R.dimen.timeline_port_slot_gap);
+ slotViewSpec.slotGapLand = r.getDimensionPixelSize(R.dimen.timeline_land_slot_gap);
+ slotViewSpec.titleHeight = r.getDimensionPixelSize(R.dimen.timeline_title_height);
+
+ labelSpec = new TimeLineSlotRenderer.LabelSpec();
+
+ labelSpec.timeLineTitleHeight = r.getDimensionPixelSize(
+ R.dimen.timeline_title_height);
+ labelSpec.timeLineTitleFontSize = r.getDimensionPixelSize(
+ R.dimen.timeline_title_font_size);
+ labelSpec.timeLineTitleTextColor = r.getColor(R.color.timeline_title_text_color);
+ labelSpec.timeLineNumberTextColor = r.getColor(R.color.timeline_title_number_text_color);
+ labelSpec.timeLineTitleBackgroundColor = r.getColor(R.color.timeline_title_background_color);
+ }
+ }
}
diff --git a/src/com/android/gallery3d/app/FilterUtils.java b/src/com/android/gallery3d/app/FilterUtils.java
index bc28a9cc1..3e055357d 100644
--- a/src/com/android/gallery3d/app/FilterUtils.java
+++ b/src/com/android/gallery3d/app/FilterUtils.java
@@ -63,6 +63,7 @@ public class FilterUtils {
public static final int CLUSTER_BY_TAG = 8;
public static final int CLUSTER_BY_SIZE = 16;
public static final int CLUSTER_BY_FACE = 32;
+ public static final int CLUSTER_BY_VIDEOS = 64;
public static final int FILTER_IMAGE_ONLY = 1;
public static final int FILTER_VIDEO_ONLY = 2;
@@ -95,7 +96,7 @@ public class FilterUtils {
setMenuItemApplied(actionBar, CLUSTER_BY_FACE,
(ctype & CLUSTER_BY_FACE) != 0, (ccurrent & CLUSTER_BY_FACE) != 0);
- actionBar.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0);
+// actionBar.setClusterItemVisibility(CLUSTER_BY_ALBUM, !inAlbum || ctype == 0);
setMenuItemApplied(actionBar, R.id.action_cluster_album, ctype == 0,
ccurrent == 0);
@@ -165,11 +166,11 @@ public class FilterUtils {
private static void setMenuItemApplied(
GalleryActionBar model, int id, boolean applied, boolean updateTitle) {
- model.setClusterItemEnabled(id, !applied);
+// model.setClusterItemEnabled(id, !applied);
}
private static void setMenuItemAppliedEnabled(GalleryActionBar model, int id, boolean applied, boolean enabled, boolean updateTitle) {
- model.setClusterItemEnabled(id, enabled);
+// model.setClusterItemEnabled(id, enabled);
}
// Add a specified filter to the path.
@@ -208,6 +209,8 @@ public class FilterUtils {
case CLUSTER_BY_FACE:
kind = "face";
break;
+ case CLUSTER_BY_VIDEOS:
+ return "/local/video/-1";
default: /* CLUSTER_BY_ALBUM */
return base;
}
diff --git a/src/com/android/gallery3d/app/GalleryActionBar.java b/src/com/android/gallery3d/app/GalleryActionBar.java
index 588f5842a..1e8458738 100644
--- a/src/com/android/gallery3d/app/GalleryActionBar.java
+++ b/src/com/android/gallery3d/app/GalleryActionBar.java
@@ -26,6 +26,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -34,6 +36,7 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ShareActionProvider;
import android.widget.TextView;
+import android.widget.Toolbar;
import android.widget.TwoLineListItem;
import com.android.gallery3d.R;
@@ -41,7 +44,7 @@ import com.android.gallery3d.common.ApiHelper;
import java.util.ArrayList;
-public class GalleryActionBar implements OnNavigationListener {
+public class GalleryActionBar {
@SuppressWarnings("unused")
private static final String TAG = "GalleryActionBar";
@@ -53,9 +56,9 @@ public class GalleryActionBar implements OnNavigationListener {
private AbstractGalleryActivity mActivity;
private ActionBar mActionBar;
private int mCurrentIndex;
- private ClusterAdapter mAdapter = new ClusterAdapter();
+// private ClusterAdapter mAdapter = new ClusterAdapter();
- private AlbumModeAdapter mAlbumModeAdapter;
+// private AlbumModeAdapter mAlbumModeAdapter;
private OnAlbumModeSelectedListener mAlbumModeListener;
private int mLastAlbumModeSelected;
private CharSequence [] mAlbumModes;
@@ -107,7 +110,7 @@ public class GalleryActionBar implements OnNavigationListener {
R.string.group_by_tags)
};
- private class ClusterAdapter extends BaseAdapter {
+ /*private class ClusterAdapter extends BaseAdapter {
@Override
public int getCount() {
@@ -134,9 +137,9 @@ public class GalleryActionBar implements OnNavigationListener {
view.setText(sClusterItems[position].spinnerTitle);
return convertView;
}
- }
+ }*/
- private class AlbumModeAdapter extends BaseAdapter {
+ /*private class AlbumModeAdapter extends BaseAdapter {
@Override
public int getCount() {
return mAlbumModes.length;
@@ -174,7 +177,7 @@ public class GalleryActionBar implements OnNavigationListener {
view.setText((CharSequence) getItem(position));
return convertView;
}
- }
+ }*/
public static String getClusterByTypeString(Context context, int type) {
for (ActionItem item : sClusterItems) {
@@ -210,104 +213,105 @@ public class GalleryActionBar implements OnNavigationListener {
return mActionBar != null ? mActionBar.getHeight() : 0;
}
- public void setClusterItemEnabled(int id, boolean enabled) {
- for (ActionItem item : sClusterItems) {
- if (item.action == id) {
- item.enabled = enabled;
- return;
- }
- }
- }
-
- public void setClusterItemVisibility(int id, boolean visible) {
- for (ActionItem item : sClusterItems) {
- if (item.action == id) {
- item.visible = visible;
- return;
- }
- }
- }
-
- public int getClusterTypeAction() {
- return sClusterItems[mCurrentIndex].action;
- }
-
- public void enableClusterMenu(int action, ClusterRunner runner) {
- if (mActionBar != null) {
- // Don't set cluster runner until action bar is ready.
- mClusterRunner = null;
- mActionBar.setListNavigationCallbacks(mAdapter, this);
- mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
- setSelectedAction(action);
- mClusterRunner = runner;
- }
- }
+// public void setClusterItemEnabled(int id, boolean enabled) {
+// for (ActionItem item : sClusterItems) {
+// if (item.action == id) {
+// item.enabled = enabled;
+// return;
+// }
+// }
+// }
+
+// public void setClusterItemVisibility(int id, boolean visible) {
+// for (ActionItem item : sClusterItems) {
+// if (item.action == id) {
+// item.visible = visible;
+// return;
+// }
+// }
+// }
+
+// public int getClusterTypeAction() {
+// return sClusterItems[mCurrentIndex].action;
+// }
+
+// public void enableClusterMenu(int action, ClusterRunner runner) {
+// if (mActionBar != null) {
+// // Don't set cluster runner until action bar is ready.
+// mClusterRunner = null;
+//// mActionBar.setListNavigationCallbacks(mAdapter, this);
+// mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+// setSelectedAction(action);
+// mClusterRunner = runner;
+// }
+// }
// The only use case not to hideMenu in this method is to ensure
// all elements disappear at the same time when exiting gallery.
// hideMenu should always be true in all other cases.
- public void disableClusterMenu(boolean hideMenu) {
- if (mActionBar != null) {
- mClusterRunner = null;
- if (hideMenu) {
- mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- }
- }
- }
+// public void disableClusterMenu(boolean hideMenu) {
+// if (mActionBar != null) {
+// mClusterRunner = null;
+// if (hideMenu) {
+// mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+// }
+// }
+// }
public void onConfigurationChanged() {
if (mActionBar != null && mAlbumModeListener != null) {
- OnAlbumModeSelectedListener listener = mAlbumModeListener;
- enableAlbumModeMenu(mLastAlbumModeSelected, listener);
- }
- }
-
- public void enableAlbumModeMenu(int selected, OnAlbumModeSelectedListener listener) {
- if (mActionBar != null) {
- if (mAlbumModeAdapter == null) {
- // Initialize the album mode options if they haven't been already
- Resources res = mActivity.getResources();
- mAlbumModes = new CharSequence[] {
- res.getString(R.string.switch_photo_filmstrip),
- res.getString(R.string.switch_photo_grid)};
- mAlbumModeAdapter = new AlbumModeAdapter();
- }
- mAlbumModeListener = null;
- mLastAlbumModeSelected = selected;
- mActionBar.setListNavigationCallbacks(mAlbumModeAdapter, this);
- mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
- mActionBar.setSelectedNavigationItem(selected);
- mAlbumModeListener = listener;
- }
- }
+// OnAlbumModeSelectedListener listener = mAlbumModeListener;
+// enableAlbumModeMenu(mLastAlbumModeSelected, listener);
- public void disableAlbumModeMenu(boolean hideMenu) {
- if (mActionBar != null) {
- mAlbumModeListener = null;
- if (hideMenu) {
- mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
- }
}
}
- public void showClusterDialog(final ClusterRunner clusterRunner) {
- createDialogData();
- 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.
- mActivity.getGLRoot().lockRenderThread();
- try {
- clusterRunner.doCluster(actions.get(which).intValue());
- } finally {
- mActivity.getGLRoot().unlockRenderThread();
- }
- }
- }).create().show();
- }
+// public void enableAlbumModeMenu(int selected, OnAlbumModeSelectedListener listener) {
+// if (mActionBar != null) {
+// if (mAlbumModeAdapter == null) {
+// // Initialize the album mode options if they haven't been already
+// Resources res = mActivity.getResources();
+// mAlbumModes = new CharSequence[] {
+// res.getString(R.string.switch_photo_filmstrip),
+// res.getString(R.string.switch_photo_grid)};
+// mAlbumModeAdapter = new AlbumModeAdapter();
+// }
+// mAlbumModeListener = null;
+// mLastAlbumModeSelected = selected;
+// mActionBar.setListNavigationCallbacks(mAlbumModeAdapter, this);
+// mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+// mActionBar.setSelectedNavigationItem(selected);
+// mAlbumModeListener = listener;
+// }
+// }
+
+// public void disableAlbumModeMenu(boolean hideMenu) {
+// if (mActionBar != null) {
+// mAlbumModeListener = null;
+// if (hideMenu) {
+// mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+// }
+// }
+// }
+
+// public void showClusterDialog(final ClusterRunner clusterRunner) {
+// createDialogData();
+// 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.
+// mActivity.getGLRoot().lockRenderThread();
+// try {
+// clusterRunner.doCluster(actions.get(which).intValue());
+// } finally {
+// mActivity.getGLRoot().unlockRenderThread();
+// }
+// }
+// }).create().show();
+// }
@TargetApi(ApiHelper.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setHomeButtonEnabled(boolean enabled) {
@@ -355,39 +359,39 @@ public class GalleryActionBar implements OnNavigationListener {
if (mActionBar != null) mActionBar.removeOnMenuVisibilityListener(listener);
}
- public boolean setSelectedAction(int type) {
- if (mActionBar == null) return false;
-
- for (int i = 0, n = sClusterItems.length; i < n; i++) {
- ActionItem item = sClusterItems[i];
- if (item.action == type) {
- mActionBar.setSelectedNavigationItem(i);
- mCurrentIndex = i;
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {
- if (itemPosition != mCurrentIndex && mClusterRunner != null
- || mAlbumModeListener != null) {
- // Need to lock rendering when operations invoked by system UI (main thread) are
- // modifying slot data used in GL thread for rendering.
- mActivity.getGLRoot().lockRenderThread();
- try {
- if (mAlbumModeListener != null) {
- mAlbumModeListener.onAlbumModeSelected(itemPosition);
- } else {
- mClusterRunner.doCluster(sClusterItems[itemPosition].action);
- }
- } finally {
- mActivity.getGLRoot().unlockRenderThread();
- }
- }
- return false;
- }
+// public boolean setSelectedAction(int type) {
+// if (mActionBar == null) return false;
+//
+// for (int i = 0, n = sClusterItems.length; i < n; i++) {
+// ActionItem item = sClusterItems[i];
+// if (item.action == type) {
+// mActionBar.setSelectedNavigationItem(i);
+// mCurrentIndex = i;
+// return true;
+// }
+// }
+// return false;
+// }
+
+// @Override
+// public boolean onNavigationItemSelected(int itemPosition, long itemId) {
+// if (itemPosition != mCurrentIndex && mClusterRunner != null
+// || mAlbumModeListener != null) {
+// // Need to lock rendering when operations invoked by system UI (main thread) are
+// // modifying slot data used in GL thread for rendering.
+// mActivity.getGLRoot().lockRenderThread();
+// try {
+// if (mAlbumModeListener != null) {
+// mAlbumModeListener.onAlbumModeSelected(itemPosition);
+// } else {
+// mClusterRunner.doCluster(sClusterItems[itemPosition].action);
+// }
+// } finally {
+// mActivity.getGLRoot().unlockRenderThread();
+// }
+// }
+// return false;
+// }
private Menu mActionBarMenu;
private ShareActionProvider mSharePanoramaActionProvider;
@@ -435,4 +439,17 @@ public class GalleryActionBar implements OnNavigationListener {
onShareListener);
}
}
+
+ public void setBackGroundTransparent()
+ {
+ mActionBar.setBackgroundDrawable(new ColorDrawable(Color.argb(66, 0, 0, 0)));
+
+ }
+
+ public void setBackGroundDefault()
+ {
+ mActionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#e53935")));
+ }
+
+
}
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index 4071a082b..d7ee8fcf9 100644
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +20,7 @@
package com.android.gallery3d.app;
import java.util.Locale;
-
+import android.os.Handler;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.ContentUris;
@@ -36,13 +39,30 @@ import android.os.SystemProperties;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
+import android.view.Gravity;
import android.view.InputDevice;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
import android.widget.Toast;
+import android.widget.Toolbar;
+import android.widget.Toolbar.OnMenuItemClickListener;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v4.widget.DrawerLayout.DrawerListener;
+import android.text.TextUtils;
+import java.util.ArrayList;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
@@ -74,19 +94,24 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
private static final String TAG = "GalleryActivity";
private Dialog mVersionCheckDialog;
+ private ListView mDrawerListView;
+ private DrawerLayout mDrawerLayout;
+ public static boolean mIsparentActivityFInishing;
+ NavigationDrawerListAdapter mNavigationAdapter;
+ public Toolbar mToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_ACTION_BAR);
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
if (getIntent().getBooleanExtra(KEY_DISMISS_KEYGUARD, false)) {
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
- setContentView(R.layout.main);
+ setContentView(R.layout.gallery_main);
+ initView();
if (savedInstanceState != null) {
getStateManager().restoreFromState(savedInstanceState);
@@ -99,6 +124,208 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
startBulkMpoProcess();
}
+ private static class ActionItem {
+ public int action;
+ public int title;
+ public int icon;
+
+ public ActionItem(int action, int title, int icon) {
+ this.action = action;
+ this.title = title;
+ this.icon = icon;
+ }
+ }
+
+ private static final ActionItem[] sActionItems = new ActionItem[] {
+ new ActionItem(FilterUtils.CLUSTER_BY_TIME,
+ R.string.timeline_title, R.drawable.timeline),
+ new ActionItem(FilterUtils.CLUSTER_BY_ALBUM, R.string.albums_title,
+ R.drawable.albums),
+ new ActionItem(FilterUtils.CLUSTER_BY_VIDEOS,
+ R.string.videos_title, R.drawable.videos) };
+
+ public void initView() {
+ mDrawerListView = (ListView) findViewById(R.id.navList);
+ mNavigationAdapter = new NavigationDrawerListAdapter(this);
+ mDrawerListView.setAdapter(mNavigationAdapter);
+ mToolbar = (Toolbar) findViewById(R.id.toolbar);
+ setActionBar(mToolbar);
+
+ mDrawerListView
+ .setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ getGLRoot().lockRenderThread();
+ showScreen(position);
+
+ mNavigationAdapter.setClickPosition(position);
+ mDrawerListView.invalidateViews();
+ mDrawerLayout.closeDrawer(Gravity.LEFT);
+ getGLRoot().unlockRenderThread();
+ }
+ });
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
+ mDrawerLayout.setDrawerListener(new DrawerListener() {
+
+ @Override
+ public void onDrawerStateChanged(int arg0) {
+ if (getStateManager().getStateCount() == 1)
+ {
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
+ } else {
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+ }
+ }
+
+ @Override
+ public void onDrawerSlide(View arg0, float arg1) {
+
+ }
+
+ @Override
+ public void onDrawerOpened(View arg0) {
+
+ }
+
+ @Override
+ public void onDrawerClosed(View arg0) {
+
+ }
+ });
+ mToolbar.setNavigationContentDescription("drawer");
+ mToolbar.setNavigationOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (mToolbar.getNavigationContentDescription().equals("drawer")) {
+ mDrawerLayout.openDrawer(Gravity.LEFT);
+
+ } else {
+ mToolbar.setNavigationContentDescription("drawer");
+ mToolbar.setNavigationIcon(R.drawable.drawer);
+ onBackPressed();
+ }
+ }
+ });
+ setToolbar(mToolbar);
+ }
+
+ public void toggleNavDrawer(boolean setDrawerVisibility)
+ {
+ if (mDrawerLayout != null) {
+ if (setDrawerVisibility) {
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
+ }
+ else {
+ mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
+ }
+ }
+ }
+
+ public void showScreen(int position) {
+ if (position > 2) {
+ position = 1;
+ }
+ // Bundle data = new Bundle();
+ // int clusterType;
+ // String newPath;
+ String basePath = getDataManager().getTopSetPath(
+ DataManager.INCLUDE_ALL);
+ switch (position) {
+
+ case 0:
+ startTimelinePage(); //Timeline view
+ break;
+ case 1:
+ startAlbumPage(); // Albums View
+ break;
+ case 2:
+ startVideoPage(); // Videos view
+ break;
+ default:
+ break;
+ }
+
+ mNavigationAdapter.setClickPosition(position);
+
+ mDrawerListView.invalidateViews();
+ mToolbar.setTitle(getResources().getStringArray(
+ R.array.title_array_nav_items)[position]);
+
+ mDrawerListView.setItemChecked(position, true);
+ mDrawerListView.setSelection(position);
+ mToolbar.setNavigationContentDescription("drawer");
+ mToolbar.setNavigationIcon(R.drawable.drawer);
+ }
+
+ private class NavigationDrawerListAdapter extends BaseAdapter {
+
+ private int curTab = 0;
+ Context mContext;
+
+ public NavigationDrawerListAdapter(Context context) {
+ mContext = context;
+
+ }
+
+ @Override
+ public int getCount() {
+ return sActionItems.length;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return sActionItems[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view;
+
+ if (convertView == null) {
+ LayoutInflater inflater = (LayoutInflater) mContext
+ .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(
+ com.android.gallery3d.R.layout.drawer_list_item, null);
+ } else {
+ view = convertView;
+ }
+
+ TextView titleView = (TextView) view.findViewById(R.id.itemTitle);
+ ImageView iconView = (ImageView) view.findViewById(R.id.ivItem);
+
+ titleView.setText(sActionItems[position].title);
+ iconView.setImageResource(sActionItems[position].icon);
+
+ if (curTab == position) {
+ view.setBackgroundResource(R.drawable.drawer_item_selected_bg);
+ } else {
+ view.setBackgroundColor(android.R.color.transparent);
+ }
+
+ return view;
+ }
+
+ public void setClickPosition(int position) {
+ curTab = position;
+ }
+ }
+
+ public static int getActionTitle(Context context, int type) {
+ for (ActionItem item : sActionItems) {
+ if (item.action == type) {
+ return item.title;
+ }
+ }
+ return -1;
+ }
+
private void initializeByIntent() {
Intent intent = getIntent();
String action = intent.getAction();
@@ -120,16 +347,72 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
|| ACTION_REVIEW.equalsIgnoreCase(action)){
startViewAction(intent);
} else {
- startDefaultPage();
+ startTimelinePage();
+ mToolbar.setTitle(R.string.albums_title);
}
}
- public void startDefaultPage() {
+ public void startAlbumPage() {
PicasaSource.showSignInReminder(this);
Bundle data = new Bundle();
- data.putString(AlbumSetPage.KEY_MEDIA_PATH,
- getDataManager().getTopSetPath(DataManager.INCLUDE_ALL));
- getStateManager().startState(AlbumSetPage.class, data);
+ int clusterType = FilterUtils.CLUSTER_BY_ALBUM;
+ data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager()
+ .getTopSetPath(DataManager.INCLUDE_ALL));
+ if (getStateManager().getStateCount() == 0)
+ getStateManager().startState(AlbumSetPage.class, data);
+ else {
+ ActivityState state = getStateManager().getTopState();
+ String oldClass = state.getClass().getSimpleName();
+ String newClass = AlbumSetPage.class.getSimpleName();
+ if (!oldClass.equals(newClass)) {
+ getStateManager().switchState(getStateManager().getTopState(),
+ AlbumSetPage.class, data);
+ }
+ }
+ mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.setOnCancelListener(this);
+ }
+ }
+
+ private void startTimelinePage() {
+ String newBPath = getDataManager().getTopSetPath(DataManager.INCLUDE_ALL);
+ String newPath = FilterUtils.switchClusterPath(newBPath, FilterUtils.CLUSTER_BY_TIME);
+ Bundle data = new Bundle();
+ data.putString(TimeLinePage.KEY_MEDIA_PATH, newPath);
+ if (getStateManager().getStateCount() == 0)
+ getStateManager().startState(TimeLinePage.class, data);
+ else {
+ ActivityState state = getStateManager().getTopState();
+ String oldClass = state.getClass().getSimpleName();
+ String newClass = TimeLinePage.class.getSimpleName();
+ if (!oldClass.equals(newClass)) {
+ getStateManager().switchState(getStateManager().getTopState(),
+ TimeLinePage.class, data);
+ }
+ }
+ mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
+ if (mVersionCheckDialog != null) {
+ mVersionCheckDialog.setOnCancelListener(this);
+ }
+ }
+
+ public void startVideoPage() {
+ PicasaSource.showSignInReminder(this);
+ String basePath = getDataManager().getTopSetPath(
+ DataManager.INCLUDE_ALL);
+ Bundle data = new Bundle();
+ int clusterType = FilterUtils.CLUSTER_BY_VIDEOS;
+ String newPath = FilterUtils.switchClusterPath(basePath, clusterType);
+ data.putString(AlbumPage.KEY_MEDIA_PATH, newPath);
+ data.putBoolean(AlbumPage.KEY_IS_VIDEOS_SCREEN, true);
+ ActivityState state = getStateManager().getTopState();
+ String oldClass = state.getClass().getSimpleName();
+ String newClass = AlbumPage.class.getSimpleName();
+ if (!oldClass.equals(newClass)) {
+ getStateManager().switchState(getStateManager().getTopState(),
+ AlbumPage.class, data);
+ }
mVersionCheckDialog = PicasaSource.getVersionCheckDialog(this);
if (mVersionCheckDialog != null) {
mVersionCheckDialog.setOnCancelListener(this);
@@ -224,7 +507,7 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
getStateManager().startState(AlbumSetPage.class, data);
}
} else {
- startDefaultPage();
+ startTimelinePage();
}
} else {
Path itemPath = dm.findPathByUri(uri, contentType);
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index beab0e5ef..87c224208 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -37,7 +37,9 @@ import android.content.pm.ActivityInfo;
import android.database.Cursor;
//import android.drm.DrmHelper;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.ColorDrawable;
import android.media.AudioManager;
import android.media.audiofx.AudioEffect;
import android.media.audiofx.AudioEffect.Descriptor;
@@ -270,6 +272,7 @@ public class MovieActivity extends Activity {
actionBar.setDisplayOptions(
ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE,
ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
+ actionBar.setBackgroundDrawable(new ColorDrawable(Color.argb(66, 0, 0, 0)));
actionBar.addOnMenuVisibilityListener(new OnMenuVisibilityListener() {
@Override
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index f72505670..15b70d330 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -82,7 +82,7 @@ import java.util.Locale;
public abstract class PhotoPage extends ActivityState implements
PhotoView.Listener, AppBridge.Server, ShareActionProvider.OnShareTargetSelectedListener,
- PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener {
+ PhotoPageBottomControls.Delegate {
private static final String TAG = "PhotoPage";
private static final int MSG_HIDE_BARS = 1;
@@ -123,7 +123,8 @@ public abstract class PhotoPage extends ActivityState implements
public static final String KEY_SHOW_WHEN_LOCKED = "show_when_locked";
public static final String KEY_IN_CAMERA_ROLL = "in_camera_roll";
public static final String KEY_READONLY = "read-only";
-
+ public static final String KEY_FROM_VIDEOS_SCREEN = "from-video-screen";
+ public static final String KEY_FROM_TIMELINE_SCREEN = "from-timeline-screen";
// Bundle key, used for checking whether it is from widget
public static final String KEY_IS_FROM_WIDGET = "is_from_widget";
@@ -178,6 +179,8 @@ public abstract class PhotoPage extends ActivityState implements
private boolean mStartInFilmstrip;
private boolean mHasCameraScreennailOrPlaceholder = false;
private boolean mRecenterCameraOnResume = true;
+ private boolean mIsFromVideoScreen;
+ private boolean mIsFromTimelineScreen;
// These are only valid after the panorama callback
private boolean mIsPanorama;
@@ -202,6 +205,10 @@ public abstract class PhotoPage extends ActivityState implements
private int mLastSystemUiVis = 0;
+ private ShareActionProvider mShareActionProvider;
+ private Intent mShareIntent;
+ private boolean mIsPhotoChanged = true;
+
private final PanoramaSupportCallback mUpdatePanoramaMenuItemsCallback = new PanoramaSupportCallback() {
@Override
public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
@@ -270,6 +277,7 @@ public abstract class PhotoPage extends ActivityState implements
public void onCreate(Bundle data, Bundle restoreState) {
super.onCreate(data, restoreState);
mActionBar = mActivity.getGalleryActionBar();
+ mActionBar.setBackGroundTransparent();
mSelectionManager = new SelectionManager(mActivity, false);
mMenuExecutor = new MenuExecutor(mActivity, mSelectionManager);
@@ -279,6 +287,8 @@ public abstract class PhotoPage extends ActivityState implements
mApplication = (GalleryApp) ((Activity) mActivity).getApplication();
mOrientationManager = mActivity.getOrientationManager();
mActivity.getGLRoot().setOrientationSource(mOrientationManager);
+ mIsFromVideoScreen = data.getBoolean(KEY_FROM_VIDEOS_SCREEN, false);
+ mIsFromTimelineScreen = data.getBoolean(KEY_FROM_TIMELINE_SCREEN, false);
mHandler = new SynchronizedHandler(mActivity.getGLRoot()) {
@Override
@@ -469,6 +479,9 @@ public abstract class PhotoPage extends ActivityState implements
mSetPathString = "/filter/delete/{" + mSetPathString + "}";
mMediaSet = (FilterDeleteSet) mActivity.getDataManager()
.getMediaSet(mSetPathString);
+ if(mMediaSet != null && mIsFromTimelineScreen) {
+ mMediaSet.setClusterKind(-1);
+ }
if (mMediaSet == null) {
Log.w(TAG, "failed to restore " + mSetPathString);
}
@@ -527,6 +540,7 @@ public abstract class PhotoPage extends ActivityState implements
public void onPhotoChanged(int index, Path item) {
int oldIndex = mCurrentIndex;
mCurrentIndex = index;
+ mIsPhotoChanged = true;
if (mHasCameraScreennailOrPlaceholder) {
if (mCurrentIndex > 0) {
@@ -552,7 +566,10 @@ public abstract class PhotoPage extends ActivityState implements
if (!mSkipUpdateCurrentPhoto) {
if (item != null) {
MediaItem photo = mModel.getMediaItem(0);
- if (photo != null) updateCurrentPhoto(photo);
+ if (photo != null) {
+ mActionBar.setTitle(photo.getName());
+ updateCurrentPhoto(photo);
+ }
}
updateBars();
}
@@ -635,19 +652,36 @@ public abstract class PhotoPage extends ActivityState implements
if (mCurrentPhoto == null) {
return false;
}
- switch(control) {
- case R.id.photopage_bottom_control_edit:
- return mHaveImageEditor && mShowBars && !mReadOnlyView
- && !mPhotoView.getFilmMode()
- && (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_EDIT) != 0
- && mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE;
- case R.id.photopage_bottom_control_panorama:
- return mIsPanorama;
- case R.id.photopage_bottom_control_tiny_planet:
- return mHaveImageEditor && mShowBars
- && mIsPanorama360 && !mPhotoView.getFilmMode();
- default:
- return false;
+ if (mIsPhotoChanged) {
+ if (mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_VIDEO) {
+ mBottomControls.setSharePositionForVideo(mActivity);
+ } else {
+ mBottomControls.setSharePositionForImage();
+ }
+ mIsPhotoChanged = false;
+ }
+ switch (control) {
+ case R.id.photopage_bottom_controls:
+ return mShowBars;
+ case R.id.photopage_bottom_control_edit:
+ return mHaveImageEditor
+ && mShowBars
+ && !mReadOnlyView
+ && !mPhotoView.getFilmMode()
+ && (mCurrentPhoto.getSupportedOperations() & MediaItem.SUPPORT_EDIT) != 0
+ && mCurrentPhoto.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE;
+ // case R.id.photopage_bottom_control_panorama:
+ // return mIsPanorama;
+ // case R.id.photopage_bottom_control_tiny_planet:
+ // return mHaveImageEditor && mShowBars
+ // && mIsPanorama360 && !mPhotoView.getFilmMode();
+ case R.id.photopage_bottom_control_share:
+ mShareIntent = new Intent(Intent.ACTION_SEND);
+ return mShowBars;
+ case R.id.photopage_bottom_control_delete:
+ return mShowBars;
+ default:
+ return false;
}
}
@@ -657,15 +691,39 @@ public abstract class PhotoPage extends ActivityState implements
case R.id.photopage_bottom_control_edit:
launchPhotoEditor();
return;
- case R.id.photopage_bottom_control_panorama:
- mActivity.getPanoramaViewHelper()
- .showPanorama(mCurrentPhoto.getContentUri());
- return;
- case R.id.photopage_bottom_control_tiny_planet:
- launchTinyPlanet();
- return;
- default:
+ case R.id.photopage_bottom_control_share:
+ if (mModel != null && mModel.getMediaItem(0) != null) {
+ Uri uri = Uri.parse(mModel.getMediaItem(0).getFilePath());
+ mShareIntent.setType(MenuExecutor.getMimeType(mModel
+ .getMediaItem(0).getMediaType()));
+ mShareIntent.putExtra(Intent.EXTRA_STREAM, uri);
+ mActivity.startActivity(Intent.createChooser(mShareIntent,
+ "Share via"));
+ }
+ return;
+
+ case R.id.photopage_bottom_control_delete:
+ String confirmMsg = null;
+ confirmMsg = mActivity.getResources().getQuantityString(
+ R.plurals.delete_selection, 1);
+ if (mModel != null && mModel.getMediaItem(0) != null) {
+ Path path = mModel.getMediaItem(0).getPath();
+ mSelectionManager.deSelectAll();
+ mSelectionManager.toggle(path);
+ MenuItem item = null;
+ mMenuExecutor.onMenuClicked(item, confirmMsg,
+ mConfirmDialogListener);
+ }
return;
+ // case R.id.photopage_bottom_control_panorama:
+ // mActivity.getPanoramaViewHelper()
+ // .showPanorama(mCurrentPhoto.getContentUri());
+ // return;
+ // case R.id.photopage_bottom_control_tiny_planet:
+ // launchTinyPlanet();
+ // return;
+ default:
+ return;
}
}
@@ -950,6 +1008,17 @@ public abstract class PhotoPage extends ActivityState implements
onUpPressed();
} else {
super.onBackPressed();
+ mActionBar.setBackGroundDefault();
+ int count = mActivity.getStateManager().getStateCount();
+ if(mIsFromTimelineScreen) {
+ mMediaSet.setClusterKind(0);
+ }
+ if (mIsFromVideoScreen || count == 1 || mIsFromTimelineScreen) {
+ mActivity.getToolbar().setNavigationContentDescription(
+ "drawer");
+ mActivity.getToolbar().setNavigationIcon(R.drawable.drawer);
+ ((GalleryActivity)mActivity).toggleNavDrawer(true);
+ }
}
}
}
@@ -1024,7 +1093,7 @@ public abstract class PhotoPage extends ActivityState implements
mActionBar.createActionBarMenu(R.menu.photo, menu);
mHaveImageEditor = GalleryUtils.isEditorAvailable(mActivity, "image/*");
updateMenuOperations();
- mActionBar.setTitle(mMediaSet != null ? mMediaSet.getName() : "");
+ //mActionBar.setTitle(mMediaSet != null ? mMediaSet.getName() : "");
return true;
}
@@ -1124,7 +1193,7 @@ public abstract class PhotoPage extends ActivityState implements
SlideshowPage.class, REQUEST_SLIDESHOW, data);
return true;
}
- case R.id.action_crop: {
+ /*case R.id.action_crop: {
Activity activity = mActivity;
Intent intent = new Intent(CropActivity.CROP_ACTION);
intent.setClass(activity, CropActivity.class);
@@ -1134,7 +1203,7 @@ public abstract class PhotoPage extends ActivityState implements
? REQUEST_CROP_PICASA
: REQUEST_CROP);
return true;
- }
+ }*/
case R.id.action_trim: {
Intent intent = new Intent(mActivity, TrimVideo.class);
intent.setData(manager.getContentUri(path));
@@ -1160,10 +1229,10 @@ public abstract class PhotoPage extends ActivityState implements
launchPhotoEditor();
return true;
}
- case R.id.action_simple_edit: {
+ /*case R.id.action_simple_edit: {
launchSimpleEditor();
return true;
- }
+ }*/
case R.id.action_details: {
if (mShowDetails) {
hideDetails();
@@ -1180,8 +1249,8 @@ public abstract class PhotoPage extends ActivityState implements
confirmMsg = mActivity.getResources().getQuantityString(
R.plurals.delete_selection, 1);
case R.id.action_setas:
- case R.id.action_rotate_ccw:
- case R.id.action_rotate_cw:
+ //case R.id.action_rotate_ccw:
+ //case R.id.action_rotate_cw:
case R.id.action_show_on_map:
mSelectionManager.deSelectAll();
mSelectionManager.toggle(path);
@@ -1372,11 +1441,11 @@ public abstract class PhotoPage extends ActivityState implements
case REQUEST_EDIT:
setCurrentPhotoByIntent(data);
break;
- case REQUEST_CROP:
+ /*case REQUEST_CROP:
if (resultCode == Activity.RESULT_OK) {
setCurrentPhotoByIntent(data);
}
- break;
+ break;*/
case REQUEST_CROP_PICASA: {
if (resultCode == Activity.RESULT_OK) {
Context context = mActivity.getAndroidContext();
@@ -1422,9 +1491,9 @@ public abstract class PhotoPage extends ActivityState implements
mHandler.removeMessages(MSG_REFRESH_BOTTOM_CONTROLS);
refreshBottomControlsWhenReady();
mActionBar.removeOnMenuVisibilityListener(mMenuVisibilityListener);
- if (mShowSpinner) {
- mActionBar.disableAlbumModeMenu(true);
- }
+ // if (mShowSpinner) {
+ // mActionBar.disableAlbumModeMenu(true);
+ // }
onCommitDeleteImage();
mMenuExecutor.pause();
if (mMediaSet != null) mMediaSet.clearDeletion();
@@ -1438,14 +1507,14 @@ public abstract class PhotoPage extends ActivityState implements
@Override
public void onFilmModeChanged(boolean enabled) {
refreshBottomControlsWhenReady();
- if (mShowSpinner) {
+ /*if (mShowSpinner) {
if (enabled) {
mActionBar.enableAlbumModeMenu(
GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
} else {
mActionBar.disableAlbumModeMenu(true);
}
- }
+ }*/
if (enabled) {
mHandler.removeMessages(MSG_HIDE_BARS);
UsageStatistics.onContentViewChanged(
@@ -1538,13 +1607,17 @@ public abstract class PhotoPage extends ActivityState implements
mModel.resume();
mPhotoView.resume();
mActionBar.setDisplayOptions(
- ((mSecureAlbum == null) && (mSetPathString != null)), false);
+ ((mSecureAlbum == null) && (mSetPathString != null)), true);
mActionBar.addOnMenuVisibilityListener(mMenuVisibilityListener);
refreshBottomControlsWhenReady();
- if (mShowSpinner && mPhotoView.getFilmMode()) {
- mActionBar.enableAlbumModeMenu(
- GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
- }
+ if (((mSecureAlbum == null) && (mSetPathString != null))) {
+ mActivity.getToolbar().setNavigationContentDescription("back");
+ mActivity.getToolbar().setNavigationIcon(R.drawable.back);
+ }
+ // if (mShowSpinner && mPhotoView.getFilmMode()) {
+ // mActionBar.enableAlbumModeMenu(
+ // GalleryActionBar.ALBUM_FILMSTRIP_MODE_SELECTED, this);
+ // }
if (!mShowBars) {
mActionBar.hide();
mActivity.getGLRoot().setLightsOutMode(true);
@@ -1595,12 +1668,12 @@ public abstract class PhotoPage extends ActivityState implements
}
}
- @Override
+ /*@Override
public void onAlbumModeSelected(int mode) {
if (mode == GalleryActionBar.ALBUM_GRID_MODE_SELECTED) {
switchToGrid();
}
- }
+ }*/
@Override
public void refreshBottomControlsWhenReady() {
diff --git a/src/com/android/gallery3d/app/PhotoPageBottomControls.java b/src/com/android/gallery3d/app/PhotoPageBottomControls.java
index 57f8b6f35..f12f6fb69 100644
--- a/src/com/android/gallery3d/app/PhotoPageBottomControls.java
+++ b/src/com/android/gallery3d/app/PhotoPageBottomControls.java
@@ -17,6 +17,8 @@
package com.android.gallery3d.app;
import android.content.Context;
+import android.content.res.Resources;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -24,6 +26,7 @@ import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.RelativeLayout;
+import android.widget.ImageButton;
import com.android.gallery3d.R;
@@ -50,6 +53,9 @@ public class PhotoPageBottomControls implements OnClickListener {
private static final int CONTAINER_ANIM_DURATION_MS = 200;
private static final int CONTROL_ANIM_DURATION_MS = 150;
+ private ImageButton imgShare;
+ private RelativeLayout.LayoutParams defaultParams;
+
private static Animation getControlAnimForVisibility(boolean visible) {
Animation anim = visible ? new AlphaAnimation(0f, 1f)
: new AlphaAnimation(1f, 0f);
@@ -66,11 +72,16 @@ public class PhotoPageBottomControls implements OnClickListener {
mContainer = (ViewGroup) inflater
.inflate(R.layout.photopage_bottom_controls, mParentLayout, false);
mParentLayout.addView(mContainer);
-
+ imgShare = (ImageButton) mContainer
+ .findViewById(R.id.photopage_bottom_control_share);
+ defaultParams = (RelativeLayout.LayoutParams) imgShare
+ .getLayoutParams();
for (int i = mContainer.getChildCount() - 1; i >= 0; i--) {
View child = mContainer.getChildAt(i);
child.setOnClickListener(this);
mControlsVisible.put(child, false);
+ if (i == 0)
+ mControlsVisible.put(mContainer, false);
}
mContainerAnimIn.setDuration(CONTAINER_ANIM_DURATION_MS);
@@ -79,6 +90,30 @@ public class PhotoPageBottomControls implements OnClickListener {
mDelegate.refreshBottomControlsWhenReady();
}
+ public void setSharePositionForImage() {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imgShare
+ .getLayoutParams();
+ params.removeRule(RelativeLayout.ALIGN_PARENT_START);
+ params.removeRule(RelativeLayout.ALIGN_PARENT_LEFT);
+ params.leftMargin = 0;
+ params.addRule(RelativeLayout.CENTER_IN_PARENT,-1);
+ imgShare.setLayoutParams(params);
+ }
+
+ public void setSharePositionForVideo(Context context) {
+ imgShare = (ImageButton) mContainer
+ .findViewById(R.id.photopage_bottom_control_share);
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imgShare
+ .getLayoutParams();
+ params.addRule(RelativeLayout.ALIGN_PARENT_START,-1);
+ Resources r = context.getResources();
+ int margin = (int) TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP, 20, r.getDisplayMetrics());
+ params.leftMargin = margin;
+ imgShare.setLayoutParams(params);
+
+ }
+
private void hide() {
mContainer.clearAnimation();
mContainerAnimOut.reset();
diff --git a/src/com/android/gallery3d/data/ClusterAlbum.java b/src/com/android/gallery3d/data/ClusterAlbum.java
index 8681952bf..3f84cc903 100644
--- a/src/com/android/gallery3d/data/ClusterAlbum.java
+++ b/src/com/android/gallery3d/data/ClusterAlbum.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.data;
import java.util.ArrayList;
+import com.android.gallery3d.util.GalleryUtils;
public class ClusterAlbum extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
@@ -26,13 +27,22 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
private DataManager mDataManager;
private MediaSet mClusterAlbumSet;
private MediaItem mCover;
+ private final int INVALID_COUNT = -1;
+ private int mImageCount = INVALID_COUNT;
+ private int mVideoCount = INVALID_COUNT;
+ private int mKind = -1;
+
+
+ private TimeLineTitleMediaItem mTimelineTitleMediaItem;
public ClusterAlbum(Path path, DataManager dataManager,
- MediaSet clusterAlbumSet) {
+ MediaSet clusterAlbumSet, int kind) {
super(path, nextVersionNumber());
mDataManager = dataManager;
mClusterAlbumSet = clusterAlbumSet;
mClusterAlbumSet.addContentListener(this);
+ mKind = kind;
+ mTimelineTitleMediaItem = new TimeLineTitleMediaItem(path);
}
public void setCoverMediaItem(MediaItem cover) {
@@ -48,12 +58,16 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
mPaths = paths;
}
- ArrayList<Path> getMediaItems() {
+ public ArrayList<Path> getMediaItems() {
return mPaths;
}
public void setName(String name) {
mName = name;
+ mTimelineTitleMediaItem.setTitle(name);
+ /*if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ mTimelineTitleMediaItem = new TimeLineTitleMediaItem(name);
+ }*/
}
@Override
@@ -63,12 +77,52 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
@Override
public int getMediaItemCount() {
+ if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ return mPaths.size()+1;
+ }
return mPaths.size();
}
+ public void setImageItemCount(int count) {
+ mImageCount = count;
+ if (mTimelineTitleMediaItem != null && mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ mTimelineTitleMediaItem.setImageCount(count);
+ }
+ }
+
+ public void setVideoItemCount(int count) {
+ mVideoCount = count;
+ if (mTimelineTitleMediaItem != null && mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ mTimelineTitleMediaItem.setVideoCount(count);
+ }
+ }
+
@Override
public ArrayList<MediaItem> getMediaItem(int start, int count) {
- return getMediaItemFromPath(mPaths, start, count, mDataManager);
+ //return getMediaItemFromPath(mPaths, start, count, mDataManager);
+ if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ if (mPaths.size() <= 0) return null;
+ if (start == 0) {
+ ArrayList<MediaItem> mediaItemList = new ArrayList<MediaItem>();
+ mediaItemList.addAll(getMediaItemFromPath(mPaths, start, count - 1, mDataManager));
+ mediaItemList.add(0, mTimelineTitleMediaItem);
+ return mediaItemList;
+ } else {
+ return getMediaItemFromPath(mPaths, start - 1, count, mDataManager);
+ }
+ } else {
+ return getMediaItemFromPath(mPaths, start, count, mDataManager);
+ }
+ }
+
+ @Override
+ public int getImageItemCount() {
+ return mImageCount;
+ }
+
+ @Override
+ public int getVideoItemCount() {
+ return mVideoCount;
}
public static ArrayList<MediaItem> getMediaItemFromPath(
@@ -102,6 +156,9 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
@Override
public int getTotalMediaItemCount() {
+ if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ return mPaths.size()+1;
+ }
return mPaths.size();
}
@@ -140,4 +197,12 @@ public class ClusterAlbum extends MediaSet implements ContentListener {
public boolean isLeafAlbum() {
return true;
}
+
+ public TimeLineTitleMediaItem getTimelineTitle() {
+ return mTimelineTitleMediaItem;
+ }
+
+ public void setClusterKind(int kind) {
+ mKind = kind;
+ }
}
diff --git a/src/com/android/gallery3d/data/ClusterAlbumSet.java b/src/com/android/gallery3d/data/ClusterAlbumSet.java
index cb212ba36..c16b6bf79 100644
--- a/src/com/android/gallery3d/data/ClusterAlbumSet.java
+++ b/src/com/android/gallery3d/data/ClusterAlbumSet.java
@@ -20,9 +20,12 @@ import android.content.Context;
import android.net.Uri;
import com.android.gallery3d.app.GalleryApp;
-
+import com.android.gallery3d.util.GalleryUtils;
+import com.android.gallery3d.common.Utils;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Arrays;
+import java.util.HashMap;
public class ClusterAlbumSet extends MediaSet implements ContentListener {
@SuppressWarnings("unused")
@@ -33,6 +36,10 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
private ArrayList<ClusterAlbum> mAlbums = new ArrayList<ClusterAlbum>();
private boolean mFirstReloadDone;
+ private int mTotalMediaItemCount;
+ private ArrayList<Integer> mAlbumItemCountList;
+ private ArrayList<TimeLineTitleMediaItem> mTimelineTitleMediaList;
+
public ClusterAlbumSet(Path path, GalleryApp application,
MediaSet baseSet, int kind) {
super(path, INVALID_DATA_VERSION);
@@ -59,14 +66,20 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
@Override
public long reload() {
- if (mBaseSet.reload() > mDataVersion) {
- if (mFirstReloadDone) {
- updateClustersContents();
- } else {
- updateClusters();
- mFirstReloadDone = true;
+ synchronized(this){
+ if (mBaseSet.reload() > mDataVersion) {
+ if (mFirstReloadDone) {
+ updateClustersContents();
+ } else {
+ updateClusters();
+ mFirstReloadDone = true;
+ }
+ mDataVersion = nextVersionNumber();
+ }
+ if (mKind == ClusterSource.CLUSTER_ALBUMSET_TIME) {
+ calculateTotalItemsCount();
+ createTimelineTitleMediaList();
}
- mDataVersion = nextVersionNumber();
}
return mDataVersion;
}
@@ -117,22 +130,24 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
synchronized (DataManager.LOCK) {
album = (ClusterAlbum) dataManager.peekMediaObject(childPath);
if (album == null) {
- album = new ClusterAlbum(childPath, dataManager, this);
+ album = new ClusterAlbum(childPath, dataManager, this, mKind);
}
}
album.setMediaItems(clustering.getCluster(i));
album.setName(childName);
album.setCoverMediaItem(clustering.getClusterCover(i));
+ album.setImageItemCount(clustering.getClusterImageCount(i));
+ album.setVideoItemCount(clustering.getClusterVideoCount(i));
mAlbums.add(album);
}
}
- private void updateClustersContents() {
- final HashSet<Path> existing = new HashSet<Path>();
+ protected void updateClustersContents() {
+ final HashMap<Path, Integer> existing = new HashMap<Path, Integer>();
mBaseSet.enumerateTotalMediaItems(new MediaSet.ItemConsumer() {
@Override
public void consume(int index, MediaItem item) {
- existing.add(item.getPath());
+ existing.put(item.getPath(), item.getMediaType());
}
});
@@ -144,16 +159,111 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener {
ArrayList<Path> oldPaths = mAlbums.get(i).getMediaItems();
ArrayList<Path> newPaths = new ArrayList<Path>();
int m = oldPaths.size();
+ int imageCount = 0;
+ int videoCount = 0;
+ int mediaType = MEDIA_TYPE_UNKNOWN;
+ ClusterAlbum album = mAlbums.get(i);
for (int j = 0; j < m; j++) {
Path p = oldPaths.get(j);
- if (existing.contains(p)) {
+ if (existing.containsKey(p)) {
newPaths.add(p);
+ mediaType = existing.get(p);
+ existing.remove(p);
+ if(mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
+ imageCount++;
+ } else if(mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ videoCount++;
+ }
}
}
- mAlbums.get(i).setMediaItems(newPaths);
+ album.setImageItemCount(imageCount);
+ album.setVideoItemCount(videoCount);
+ album.setMediaItems(newPaths);
if (newPaths.isEmpty()) {
mAlbums.remove(i);
}
}
+
+ updateClusters();
}
+
+ private void calculateTotalItemsCount() {
+ mTotalMediaItemCount = 0;
+ if( mAlbums != null && mAlbums.size() > 0) {
+ mAlbumItemCountList = new ArrayList<Integer>();
+ for(ClusterAlbum album: mAlbums) {
+ int count = album.getMediaItemCount();
+ mTotalMediaItemCount = mTotalMediaItemCount + count;
+ mAlbumItemCountList.add(mTotalMediaItemCount);
+ }
+ }
+ }
+
+ private void createTimelineTitleMediaList() {
+ if (mTimelineTitleMediaList == null) {
+ mTimelineTitleMediaList = new ArrayList<TimeLineTitleMediaItem>();
+ }
+ mTimelineTitleMediaList.clear();
+ for(ClusterAlbum album: mAlbums) {
+ mTimelineTitleMediaList.add(album.getTimelineTitle());
+ }
+ }
+
+ public TimeLineTitleMediaItem getTimelineTitleMediaItem(int index) {
+ if (mTimelineTitleMediaList == null || index >= mTimelineTitleMediaList.size()) {
+ return null;
+ }
+ return mTimelineTitleMediaList.get(index);
+ }
+
+ @Override
+ public int getMediaItemCount() {
+ return mTotalMediaItemCount;
+ }
+
+ @Override
+ public ArrayList<MediaItem> getMediaItem(int start, int count) {
+ if ((start + count) > mTotalMediaItemCount ) {
+ count = mTotalMediaItemCount - start;
+ }
+ if (count <= 0) return null;
+ ArrayList<MediaItem> mediaItems = new ArrayList<MediaItem>();
+ int startAlbum = findTimelineAlbumIndex(start);
+ int endAlbum = findTimelineAlbumIndex(start + count - 1);
+ int pAlbumCount = 0;
+ int s;
+ int lCount;
+ if (startAlbum > 0) {
+ pAlbumCount = mAlbumItemCountList.get(startAlbum -1);
+ }
+ s = start - pAlbumCount;
+ for (int i = startAlbum; i <= endAlbum && i < mAlbums.size(); ++i) {
+ int albumCount = mAlbums.get(i).getTotalMediaItemCount();
+ lCount = Math.min(albumCount - s, count);
+ ArrayList<MediaItem> items = mAlbums.get(i).getMediaItem(s, lCount);
+ if (items != null)
+ mediaItems.addAll(items);
+ count -= lCount;
+ s = 0;
+ }
+ return mediaItems;
+ }
+
+ public int findTimelineAlbumIndex(int itemIndex) {
+ int index = Arrays.binarySearch(mAlbumItemCountList.toArray(new Integer[0]), itemIndex);
+ if (index < mTotalMediaItemCount && index >= 0)
+ return index + 1;
+ if (index < 0) {
+ index = (index * (-1)) - 1;
+ }
+ return index;
+ }
+
+ public ClusterAlbum getAlbumFromindex(int index) {
+ int albumIndex = findTimelineAlbumIndex(index);
+ if (albumIndex >= 0 && albumIndex < mAlbums.size()) {
+ return mAlbums.get(albumIndex);
+ }
+ return null;
+ }
}
diff --git a/src/com/android/gallery3d/data/ClusterSource.java b/src/com/android/gallery3d/data/ClusterSource.java
index a1f22e57a..f4ef1102f 100644
--- a/src/com/android/gallery3d/data/ClusterSource.java
+++ b/src/com/android/gallery3d/data/ClusterSource.java
@@ -77,7 +77,7 @@ class ClusterSource extends MediaSource {
MediaSet parent = dataManager.getMediaSet(path.getParent());
// The actual content in the ClusterAlbum will be filled later
// when the reload() method in the parent is run.
- return new ClusterAlbum(path, dataManager, parent);
+ return new ClusterAlbum(path, dataManager, parent, matchType);
}
default:
throw new RuntimeException("bad path: " + path);
diff --git a/src/com/android/gallery3d/data/Clustering.java b/src/com/android/gallery3d/data/Clustering.java
index 4072bf57b..204bd1a34 100644
--- a/src/com/android/gallery3d/data/Clustering.java
+++ b/src/com/android/gallery3d/data/Clustering.java
@@ -26,4 +26,12 @@ public abstract class Clustering {
public MediaItem getClusterCover(int index) {
return null;
}
+
+ public int getClusterImageCount(int index) {
+ return 0;
+ }
+
+ public int getClusterVideoCount(int index) {
+ return 0;
+ }
}
diff --git a/src/com/android/gallery3d/data/FilterDeleteSet.java b/src/com/android/gallery3d/data/FilterDeleteSet.java
index f7329739d..fcf0dec74 100644
--- a/src/com/android/gallery3d/data/FilterDeleteSet.java
+++ b/src/com/android/gallery3d/data/FilterDeleteSet.java
@@ -258,4 +258,8 @@ public class FilterDeleteSet extends MediaSet implements ContentListener {
public int getNumberOfDeletions() {
return mCurrent.size();
}
+
+ public void setClusterKind(int kind) {
+ mBaseSet.setClusterKind(kind);
+ }
}
diff --git a/src/com/android/gallery3d/data/LocalAlbum.java b/src/com/android/gallery3d/data/LocalAlbum.java
index 7b7015af6..24d3b1b3f 100644
--- a/src/com/android/gallery3d/data/LocalAlbum.java
+++ b/src/com/android/gallery3d/data/LocalAlbum.java
@@ -75,7 +75,11 @@ public class LocalAlbum extends MediaSet {
mProjection = LocalImage.PROJECTION;
mItemPath = LocalImage.ITEM_PATH;
} else {
+ if (mBucketId == -1) {
+ mWhereClause = null;
+ } else {
mWhereClause = VideoColumns.BUCKET_ID + " = ?";
+ }
mOrderClause = VideoColumns.DATE_TAKEN + " DESC, "
+ VideoColumns._ID + " DESC";
mBaseUri = Video.Media.EXTERNAL_CONTENT_URI;
@@ -88,9 +92,10 @@ public class LocalAlbum extends MediaSet {
public LocalAlbum(Path path, GalleryApp application, int bucketId,
boolean isImage) {
- this(path, application, bucketId, isImage,
- BucketHelper.getBucketName(
- application.getContentResolver(), bucketId));
+ this(path, application, bucketId, isImage, bucketId == -1 ? application
+ .getAndroidContext().getString(R.string.videos_title)
+ : BucketHelper.getBucketName(application.getContentResolver(),
+ bucketId));
}
@Override
@@ -118,10 +123,16 @@ public class LocalAlbum extends MediaSet {
.appendQueryParameter("limit", start + "," + count).build();
ArrayList<MediaItem> list = new ArrayList<MediaItem>();
GalleryUtils.assertNotInRenderThread();
- Cursor cursor = mResolver.query(
+ Cursor cursor;
+ if (mBucketId == -1) {
+ cursor = mResolver.query(uri, mProjection, mWhereClause, null,
+ mOrderClause);
+ } else {
+ cursor = mResolver.query(
uri, mProjection, mWhereClause,
new String[]{String.valueOf(mBucketId)},
mOrderClause);
+ }
if (cursor == null) {
Log.w(TAG, "query fail: " + uri);
return list;
@@ -229,9 +240,15 @@ public class LocalAlbum extends MediaSet {
@Override
public int getMediaItemCount() {
if (mCachedCount == INVALID_COUNT) {
- Cursor cursor = mResolver.query(
+ Cursor cursor;
+ if (mBucketId == -1) {
+ cursor = mResolver.query(mBaseUri, COUNT_PROJECTION,
+ mWhereClause, null, mOrderClause);
+ } else {
+ cursor = mResolver.query(
mBaseUri, COUNT_PROJECTION, mWhereClause,
new String[]{String.valueOf(mBucketId)}, null);
+ }
if (cursor == null) {
Log.w(TAG, "query fail");
return 0;
diff --git a/src/com/android/gallery3d/data/MediaItem.java b/src/com/android/gallery3d/data/MediaItem.java
index 92ac88dc6..9d952bc4d 100644
--- a/src/com/android/gallery3d/data/MediaItem.java
+++ b/src/com/android/gallery3d/data/MediaItem.java
@@ -57,6 +57,9 @@ public abstract class MediaItem extends MediaObject {
public MediaItem(Path path, long version) {
super(path, version);
}
+ public MediaItem(Path path) {
+ super(path);
+ }
public long getDateInMs() {
return 0;
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 6e3867647..6f8eef3ac 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -52,6 +52,8 @@ public abstract class MediaObject {
public static final int MEDIA_TYPE_DRM_VIDEO = 5;
public static final int MEDIA_TYPE_DRM_IMAGE = 6;
public static final int MEDIA_TYPE_ALL = MEDIA_TYPE_IMAGE | MEDIA_TYPE_VIDEO;
+ //TYPE for Timeline Title
+ public static final int MEDIA_TYPE_TIMELINE_TITLE= 7;
public static final String MEDIA_TYPE_IMAGE_STRING = "image";
public static final String MEDIA_TYPE_VIDEO_STRING = "video";
@@ -85,6 +87,10 @@ public abstract class MediaObject {
mDataVersion = version;
}
+ public MediaObject(Path path) {
+ mPath = path;
+ }
+
public Path getPath() {
return mPath;
}
diff --git a/src/com/android/gallery3d/data/MediaSet.java b/src/com/android/gallery3d/data/MediaSet.java
index 4c009c735..9f7ffceda 100644
--- a/src/com/android/gallery3d/data/MediaSet.java
+++ b/src/com/android/gallery3d/data/MediaSet.java
@@ -62,6 +62,14 @@ public abstract class MediaSet extends MediaObject {
return 0;
}
+ public int getImageItemCount(){
+ return 0;
+ }
+
+ public int getVideoItemCount(){
+ return 0;
+ }
+
// Returns the media items in the range [start, start + count).
//
// The number of media items returned may be less than the specified count
@@ -350,4 +358,6 @@ public abstract class MediaSet extends MediaObject {
if (listener != null) listener.onSyncDone(MediaSet.this, mResult);
}
}
+
+ public void setClusterKind(int kind){};
}
diff --git a/src/com/android/gallery3d/data/TimeClustering.java b/src/com/android/gallery3d/data/TimeClustering.java
index 35cbab1ee..87111f29d 100644
--- a/src/com/android/gallery3d/data/TimeClustering.java
+++ b/src/com/android/gallery3d/data/TimeClustering.java
@@ -108,6 +108,7 @@ public class TimeClustering extends Clustering {
if (index < 0 || index >= total) return;
SmallItem s = new SmallItem();
s.path = item.getPath();
+ s.mediaType = item.getMediaType();
s.dateInMs = item.getDateInMs();
item.getLatLong(latLng);
s.lat = latLng[0];
@@ -189,6 +190,19 @@ public class TimeClustering extends Clustering {
mMaxClusterSize = Utils.clamp(mMaxClusterSize, MIN_MAX_CLUSTER_SIZE, MAX_MAX_CLUSTER_SIZE);
}
+ @Override
+ public int getClusterImageCount(int index) {
+ // TODO Auto-generated method stub
+ return mClusters.get(index).mPhotoCount;
+
+ }
+
+ @Override
+ public int getClusterVideoCount(int index) {
+ // TODO Auto-generated method stub
+ return mClusters.get(index).mVideoCount;
+ }
+
private void compute(SmallItem currentItem) {
if (currentItem != null) {
int numClusters = mClusters.size();
@@ -343,12 +357,15 @@ class SmallItem {
Path path;
long dateInMs;
double lat, lng;
+ int mediaType;
}
class Cluster {
@SuppressWarnings("unused")
private static final String TAG = "Cluster";
private static final String MMDDYY_FORMAT = "MMddyy";
+ public int mPhotoCount = 0;
+ public int mVideoCount = 0;
// This is for TimeClustering only.
public boolean mGeographicallySeparatedFromPrevCluster = false;
@@ -359,6 +376,11 @@ class Cluster {
}
public void addItem(SmallItem item) {
+ if(item.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
+ mPhotoCount++;
+ } else if(item.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ mVideoCount++;
+ }
mItems.add(item);
}
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index fbb832fd6..4ff3e2ff4 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Vector;
+import java.util.Locale;
import android.app.ActionBar;
import android.app.AlertDialog;
@@ -47,22 +48,31 @@ import android.os.IBinder;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.print.PrintHelper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
+import android.view.Window;
import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
import android.view.ViewPropertyAnimator;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.Button;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
import android.widget.PopupMenu;
+import android.widget.RelativeLayout;
+import android.widget.RelativeLayout.LayoutParams;
import android.widget.ShareActionProvider;
import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
import android.widget.Toast;
@@ -129,6 +139,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private ImageShow mImageShow = null;
private View mSaveButton = null;
+ private View mDoneButton = null, mCancelButton = null;
private EditorPlaceHolder mEditorPlaceHolder = new EditorPlaceHolder(this);
private Editor mCurrentEditor = null;
@@ -185,6 +196,14 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private PopupMenu mCurrentMenu = null;
private boolean mLoadingVisible = true;
private boolean mReleaseDualCamOnDestory = true;
+ private FrameLayout mCategoryFragment;
+ private View mEffectsContainer;
+ private View mEffectsTextContainer;
+ private ImageButton imgComparison;
+ private String mPopUpText, mExit;
+ RelativeLayout rlImageContainer;
+ boolean isOrientationChanged;
+ private boolean isComingFromEditorScreen;
public ProcessingService getProcessingService() {
return mBoundService;
@@ -262,7 +281,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
boolean onlyUsePortrait = getResources().getBoolean(R.bool.only_use_portrait);
if (onlyUsePortrait) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@@ -282,7 +300,13 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (findViewById(R.id.main_panel_container) == null) {
return;
}
+ Fragment main = getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG);
MainPanel panel = new MainPanel();
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(MainPanel.EDITOR_TAG, isComingFromEditorScreen);
+ panel.setArguments(bundle);
+ isComingFromEditorScreen = false;
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
transaction.commitAllowingStateLoss();
@@ -300,6 +324,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
public void run() {
EditorPanel panel = new EditorPanel();
panel.setEditor(currentId);
+ setActionBarForEffects(currentEditor);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
@@ -336,30 +361,200 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private void loadXML() {
setContentView(R.layout.filtershow_activity);
+ Resources r = getResources();
+ setActionBar(false);
+ mPopUpText = r.getString(R.string.save_and_exit).toUpperCase(
+ Locale.getDefault());
+ mExit = r.getString(R.string.exit).toUpperCase(Locale.getDefault());
+ int marginTop = r.getDimensionPixelSize(R.dimen.compare_margin_top);
+ int marginRight = r.getDimensionPixelSize(R.dimen.compare_margin_right);
+ imgComparison = (ImageButton) findViewById(R.id.imgComparison);
+ rlImageContainer = (RelativeLayout) findViewById(R.id.imageContainer);
+
+ mImageShow = (ImageShow) findViewById(R.id.imageShow);
+ mImageViews.add(mImageShow);
+
+ setupEditors();
+
+ mEditorPlaceHolder.hide();
+ mImageShow.attach();
+ setupStatePanel();
+
+ imgComparison.setOnTouchListener(new OnTouchListener() {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ int action = event.getAction();
+ action = action & MotionEvent.ACTION_MASK;
+ if (action == MotionEvent.ACTION_DOWN) {
+
+ HistoryManager adapter = mMasterImage.getHistory();
+ int position = adapter.backToOriginal();// adapter.undo();
+ mMasterImage.onHistoryItemClick(position);
+ v.setPressed(true);
+ backToMain();
+ invalidateViews();
+ }
+ if (action == MotionEvent.ACTION_UP
+ || action == MotionEvent.ACTION_CANCEL
+ || action == MotionEvent.ACTION_OUTSIDE) {
+ v.setPressed(false);
+ HistoryManager adapter = mMasterImage.getHistory();
+ int position = adapter.backToCurrent();
+ mMasterImage.onHistoryItemClick(position);
+ invalidateViews();
+
+ }
+
+ return false;
+ }
+ });
+ }
+
+ public void toggleComparisonButtonVisibility() {
+ if (imgComparison.getVisibility() == View.VISIBLE)
+ imgComparison.setVisibility(View.GONE);
+ }
+
+ public void setActionBar(boolean isEffectClicked) {
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
- actionBar.setCustomView(R.layout.filtershow_actionbar);
- actionBar.setBackgroundDrawable(new ColorDrawable(
- getResources().getColor(R.color.background_screen)));
+ actionBar.setBackgroundDrawable(new ColorDrawable(getResources()
+ .getColor(R.color.edit_actionbar_background)));
+ if (!isEffectClicked) {
+ actionBar.setCustomView(R.layout.filtershow_actionbar);
+ mSaveButton = actionBar.getCustomView();
+ mSaveButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ saveImage();
+ }
+ });
+ invalidateOptionsMenu();
+ } else {
+ mMenu.clear();
+ final Fragment main = getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG);
+
+ actionBar.setCustomView(R.layout.filtershow_actionbar_new);
+ mCancelButton = actionBar.getCustomView().findViewById(
+ R.id.imgCancel);
+ mDoneButton = actionBar.getCustomView().findViewById(R.id.imgDone);
+ mCancelButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ MainPanel mainPanel = (MainPanel) main;
+ mainPanel.toggleEffectsTrayVisibility(true);
+ setActionBar(false);
+ HistoryManager adapter = mMasterImage.getHistory();
+ int position = adapter.undoCurrentFilter();
+ mMasterImage.onHistoryItemClick(position);
+ adapter.resetActiveFilter();
+ backToMain();
+ invalidateViews();
+ }
+ });
+ mDoneButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ // saveImage();
+ MainPanel mainPanel = (MainPanel) main;
+ mainPanel.toggleEffectsTrayVisibility(true);
+ setActionBar(false);
+ HistoryManager adapter = mMasterImage
+ .getHistory();
+ adapter.resetActiveFilter();
+ }
+ });
+ isEffectClicked = false;
+ }
- mSaveButton = actionBar.getCustomView();
- mSaveButton.setOnClickListener(new OnClickListener() {
+ }
+
+ public void setActionBarForEffects(final Editor currentEditor) {
+ View view;
+ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = inflater.inflate(R.layout.filtershow_editor_panel, null);
+ View editControl = view.findViewById(R.id.controlArea);
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+ actionBar.setBackgroundDrawable(new ColorDrawable(getResources()
+ .getColor(R.color.edit_actionbar_background)));
+ actionBar.setCustomView(R.layout.filtershow_actionbar_effects);
+ ImageButton cancelButton = (ImageButton) actionBar.getCustomView()
+ .findViewById(R.id.cancelFilter);
+ ImageButton applyButton = (ImageButton) actionBar.getCustomView()
+ .findViewById(R.id.applyFilter);
+ Button editTitle = (Button) actionBar.getCustomView().findViewById(
+ R.id.applyEffect);
+ editTitle.setTransformationMethod(null);
+ View actionControl = actionBar.getCustomView().findViewById(
+ R.id.panelAccessoryViewList);
+ cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
- public void onClick(View view) {
- saveImage();
+ public void onClick(View v) {
+ cancelCurrentFilter();
+ FilterShowActivity.this.backToMain();
+ setActionBar(false);
+ }
+ });
+ applyButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ currentEditor.finalApplyCalled();
+ FilterShowActivity.this.backToMain();
+ setActionBar(false);
}
});
- mImageShow = (ImageShow) findViewById(R.id.imageShow);
- mImageViews.add(mImageShow);
+ if (currentEditor != null) {
+ currentEditor.setUpEditorUI(editTitle, actionControl, editControl);
+ currentEditor.reflectCurrentFilter();
+ if (currentEditor.useUtilityPanel()) {
+ currentEditor.openUtilityPanel((LinearLayout) actionControl);
+ }
+ }
+ }
- setupEditors();
+ public void cancelCurrentFilter() {
+ MasterImage masterImage = MasterImage.getImage();
+ HistoryManager adapter = masterImage.getHistory();
- mEditorPlaceHolder.hide();
- mImageShow.attach();
+ int position = adapter.undo();
+ masterImage.onHistoryItemClick(position);
+ invalidateViews();
+ }
- setupStatePanel();
+ private void toggleEffectsTrayVisibility(boolean isEffectTrayEnabled) {
+ if (isEffectTrayEnabled) {
+ mCategoryFragment.setVisibility(View.VISIBLE);
+ mEffectsContainer.setVisibility(View.GONE);
+ mEffectsTextContainer.setVisibility(View.GONE);
+ } else {
+ mCategoryFragment.setVisibility(View.GONE);
+ mEffectsContainer.setVisibility(View.VISIBLE);
+ mEffectsTextContainer.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void adjustCompareButton(boolean scaled) {
+ Resources r = getResources();
+ int marginTop, marginRight;
+ if (scaled) {
+ marginTop = r
+ .getDimensionPixelSize(R.dimen.compare_margin_top_scaled);
+ marginRight = r
+ .getDimensionPixelSize(R.dimen.compare_margin_right_scaled);
+ } else {
+ marginTop = r.getDimensionPixelSize(R.dimen.compare_margin_top);
+ marginRight = r.getDimensionPixelSize(R.dimen.compare_margin_right);
+
+ }
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imgComparison
+ .getLayoutParams();
+ params.setMargins(0, marginTop, marginRight, 0);
+ imgComparison.setLayoutParams(params);
}
public void fillCategories() {
@@ -705,6 +900,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
public void setCurrentPanel(int currentPanel) {
mCurrentPanel = currentPanel;
+ HistoryManager adapter = mMasterImage.getHistory();
+ adapter.setActiveFilter(currentPanel);
}
public int getCurrentPanel() {
@@ -1030,16 +1227,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ menu.clear();
getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu);
- MenuItem showState = menu.findItem(R.id.showImageStateButton);
- if (mShowingImageStatePanel) {
- showState.setTitle(R.string.hide_imagestate_panel);
- } else {
- showState.setTitle(R.string.show_imagestate_panel);
- }
- mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share)
- .getActionProvider();
+ mShareActionProvider = (ShareActionProvider) menu.findItem(
+ R.id.menu_share).getActionProvider();
mShareActionProvider.setShareIntent(getDefaultShareIntent());
mShareActionProvider.setOnShareTargetSelectedListener(this);
mMenu = menu;
@@ -1051,14 +1243,14 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (mMenu == null || mMasterImage == null) {
return;
}
- MenuItem undoItem = mMenu.findItem(R.id.undoButton);
- MenuItem redoItem = mMenu.findItem(R.id.redoButton);
+ //MenuItem undoItem = mMenu.findItem(R.id.undoButton);
+ //MenuItem redoItem = mMenu.findItem(R.id.redoButton);
MenuItem resetItem = mMenu.findItem(R.id.resetHistoryButton);
MenuItem printItem = mMenu.findItem(R.id.printButton);
if (!PrintHelper.systemSupportsPrint()) {
printItem.setVisible(false);
}
- mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
+ //mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem);
}
@Override
@@ -1085,7 +1277,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.undoButton: {
+ /*case R.id.undoButton: {
HistoryManager adapter = mMasterImage.getHistory();
int position = adapter.undo();
mMasterImage.onHistoryItemClick(position);
@@ -1099,15 +1291,15 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mMasterImage.onHistoryItemClick(position);
invalidateViews();
return true;
- }
+ }*/
case R.id.resetHistoryButton: {
resetHistory();
return true;
}
- case R.id.showImageStateButton: {
+ /*case R.id.showImageStateButton: {
toggleImageStatePanel();
return true;
- }
+ }*/
case R.id.exportFlattenButton: {
showExportOptionsDialog();
return true;
@@ -1303,9 +1495,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (mMasterImage == null) {
return;
}
- loadXML();
- fillCategories();
- loadMainPanel();
+ //loadXML();
+ //fillCategories();
+ //loadMainPanel();
if (mCurrentMenu != null) {
mCurrentMenu.dismiss();
@@ -1376,28 +1568,81 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
@Override
public void onBackPressed() {
- Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ if (imgComparison != null && imgComparison.getVisibility() == View.GONE) {
+ imgComparison.setVisibility(View.VISIBLE);
+ }
+ Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG);
+
if (currentPanel instanceof MainPanel) {
- if (!mImageShow.hasModifications()) {
- done();
+ MainPanel mainPanel = (MainPanel) currentPanel;
+ if (mainPanel.isCategoryPanelVisible()) {
+ if (mImageShow.hasModifications()) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(R.string.unsaved).setTitle(
+ R.string.save_before_exit);
+ builder.setPositiveButton(mPopUpText,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id) {
+ // saveImage();
+ HistoryManager adapter = mMasterImage
+ .getHistory();
+ adapter.resetActiveFilter();
+ }
+ });
+ builder.setNegativeButton(mExit,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id) {
+ HistoryManager adapter = mMasterImage
+ .getHistory();
+ int position = adapter.undoCurrentFilter();
+ mMasterImage.onHistoryItemClick(position);
+ adapter.resetActiveFilter();
+ backToMain();
+ invalidateViews();
+ }
+ });
+ builder.show();
+ }
+ setActionBar(false);
+ mainPanel.toggleEffectsTrayVisibility(true);
+ invalidateOptionsMenu();
+ if (MasterImage.getImage().getScaleFactor() < 1)
+ setScaleImage(false);
+ adjustCompareButton(false);
+
} else {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(R.string.unsaved).setTitle(R.string.save_before_exit);
- builder.setPositiveButton(R.string.save_and_exit, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- saveImage();
- }
- });
- builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- done();
- }
- });
- builder.show();
+ if (!mImageShow.hasModifications()) {
+ done();
+ } else {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(R.string.unsaved).setTitle(
+ R.string.save_before_exit);
+ builder.setPositiveButton(R.string.save_and_exit,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id) {
+ saveImage();
+ }
+ });
+ builder.setNegativeButton(R.string.exit,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog,
+ int id) {
+ done();
+ }
+ });
+ builder.show();
+ }
}
} else {
+ isComingFromEditorScreen = true;
backToMain();
}
}
@@ -1571,4 +1816,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
});
}
+
+ public void setScaleImage(boolean isScaled) {
+ mImageShow.scaleImage(isScaled,getBaseContext());
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryView.java b/src/com/android/gallery3d/filtershow/category/CategoryView.java
index 1570517ea..99af80f4d 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryView.java
@@ -64,7 +64,7 @@ public class CategoryView extends IconView
mSelectPaint.setColor(mSelectionColor);
mBorderPaint = new Paint(mSelectPaint);
- mBorderPaint.setColor(Color.BLACK);
+// mBorderPaint.setColor(Color.BLACK);
mBorderStroke = mSelectionStroke / 3;
}
diff --git a/src/com/android/gallery3d/filtershow/category/IconView.java b/src/com/android/gallery3d/filtershow/category/IconView.java
index cba2d794f..089203acf 100644
--- a/src/com/android/gallery3d/filtershow/category/IconView.java
+++ b/src/com/android/gallery3d/filtershow/category/IconView.java
@@ -69,7 +69,7 @@ public class IconView extends View {
private void setup(Context context) {
Resources res = getResources();
mTextColor = res.getColor(R.color.filtershow_categoryview_text);
- mBackgroundColor = res.getColor(R.color.filtershow_categoryview_background);
+ mBackgroundColor = res.getColor(android.R.color.transparent);
mMargin = res.getDimensionPixelOffset(R.dimen.category_panel_margin);
mTextSize = res.getDimensionPixelSize(R.dimen.category_panel_text_size);
}
@@ -80,7 +80,7 @@ public class IconView extends View {
}
mPaint.setTextSize(mTextSize);
if (getOrientation() == VERTICAL) {
- text = text.toUpperCase();
+// text = text.toUpperCase();
// TODO: set this in xml
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
}
@@ -108,7 +108,7 @@ public class IconView extends View {
// justify to the left.
x = mMargin;
}
- int y = canvas.getHeight() - 2*mMargin;
+ int y = canvas.getHeight() / 2 ;//- 2*mMargin;
canvas.drawText(text, x, y, mPaint);
}
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index a80df3bfa..93da39ceb 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -22,8 +22,11 @@ import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.util.Log;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
@@ -43,8 +46,13 @@ public class MainPanel extends Fragment {
private ImageButton filtersButton;
private ImageButton dualCamButton;
private ImageButton makeupButton;
+ private View mEffectsContainer;
+ private View mEffectsTextContainer;
+ private FrameLayout mCategoryFragment;
+ private View mBottomView;
public static final String FRAGMENT_TAG = "MainPanel";
+ public static final String EDITOR_TAG = "coming-from-editor-panel";
public static final int LOOKS = 0;
public static final int BORDERS = 1;
public static final int GEOMETRY = 2;
@@ -55,6 +63,7 @@ public class MainPanel extends Fragment {
private int mCurrentSelected = -1;
private int mPreviousToggleVersions = -1;
+ private boolean isEffectClicked;
private void selection(int position, boolean value) {
if (value) {
@@ -114,9 +123,21 @@ public class MainPanel extends Fragment {
geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton);
filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton);
dualCamButton = (ImageButton) mMainView.findViewById(R.id.dualCamButton);
+ mCategoryFragment = (FrameLayout) mMainView
+ .findViewById(R.id.category_panel_container);
+ mBottomView = mMainView.findViewById(R.id.bottom_panel);
+ mEffectsContainer = mMainView.findViewById(R.id.effectsContainer);
+ mEffectsTextContainer = mMainView.findViewById(R.id.effectsText);
if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton);
makeupButton.setVisibility(View.VISIBLE);
+ TextView beautify = (TextView) mEffectsTextContainer
+ .findViewById(R.id.tvBeautify);
+ beautify.setVisibility(View.VISIBLE);
+ }
+ boolean showPanel = false;
+ if (getArguments() != null) {
+ showPanel = getArguments().getBoolean(EDITOR_TAG);
}
if(makeupButton != null) {
@@ -161,8 +182,10 @@ public class MainPanel extends Fragment {
enableDualCameraButton(DualCameraNativeEngine.getInstance().isLibLoaded());
FilterShowActivity activity = (FilterShowActivity) getActivity();
- showImageStatePanel(activity.isShowingImageStatePanel());
- showPanel(activity.getCurrentPanel());
+ //showImageStatePanel(activity.isShowingImageStatePanel());
+ if (showPanel) {
+ showPanel(activity.getCurrentPanel());
+ }
return mMainView;
}
@@ -173,13 +196,39 @@ public class MainPanel extends Fragment {
return true;
}
+ public boolean isCategoryPanelVisible() {
+ return (View.VISIBLE == mCategoryFragment.getVisibility());
+ }
+
+ public void toggleEffectsTrayVisibility(boolean isCategoryTrayVisible) {
+ if (isCategoryTrayVisible) {
+ mCategoryFragment.setVisibility(View.GONE);
+ mEffectsContainer.setVisibility(View.VISIBLE);
+ mEffectsTextContainer.setVisibility(View.VISIBLE);
+ } else {
+ mCategoryFragment.setVisibility(View.VISIBLE);
+ mEffectsContainer.setVisibility(View.GONE);
+ mEffectsTextContainer.setVisibility(View.GONE);
+ }
+ }
+
private void setCategoryFragment(CategoryPanel category, boolean fromRight) {
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
if (fromRight) {
transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_right);
} else {
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
}
+ if (isEffectClicked) {
+ toggleEffectsTrayVisibility(false);
+ activity.setActionBar(isEffectClicked);
+ isEffectClicked = false;
+ } else {
+ toggleEffectsTrayVisibility(true);
+ activity.setActionBar(isEffectClicked);
+
+ }
transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG);
transaction.commitAllowingStateLoss();
}
@@ -198,9 +247,9 @@ public class MainPanel extends Fragment {
}
public void loadCategoryBorderPanel() {
- if (mCurrentSelected == BORDERS) {
+ /*if (mCurrentSelected == BORDERS) {
return;
- }
+ }*/
boolean fromRight = isRightAnimation(BORDERS);
selection(mCurrentSelected, false);
CategoryPanel categoryPanel = new CategoryPanel();
@@ -211,7 +260,7 @@ public class MainPanel extends Fragment {
}
public void loadCategoryMakeupPanel() {
- if (makeupButton == null || mCurrentSelected == MAKEUP) {
+ if (makeupButton == null) {
return;
}
boolean fromRight = isRightAnimation(MAKEUP);
@@ -224,9 +273,9 @@ public class MainPanel extends Fragment {
}
public void loadCategoryGeometryPanel() {
- if (mCurrentSelected == GEOMETRY) {
+ /*if (mCurrentSelected == GEOMETRY) {
return;
- }
+ }*/
if (MasterImage.getImage().hasTinyPlanet()) {
return;
}
@@ -240,9 +289,9 @@ public class MainPanel extends Fragment {
}
public void loadCategoryFiltersPanel() {
- if (mCurrentSelected == FILTERS) {
+ /*if (mCurrentSelected == FILTERS) {
return;
- }
+ }*/
boolean fromRight = isRightAnimation(FILTERS);
selection(mCurrentSelected, false);
CategoryPanel categoryPanel = new CategoryPanel();
@@ -253,9 +302,9 @@ public class MainPanel extends Fragment {
}
public void loadCategoryVersionsPanel() {
- if (mCurrentSelected == VERSIONS) {
+ /*if (mCurrentSelected == VERSIONS) {
return;
- }
+ }*/
FilterShowActivity activity = (FilterShowActivity) getActivity();
activity.updateVersions();
boolean fromRight = isRightAnimation(VERSIONS);
@@ -268,9 +317,9 @@ public class MainPanel extends Fragment {
}
public void loadCategoryDualCamPanel() {
- if (mCurrentSelected == DUALCAM) {
+ /*if (mCurrentSelected == DUALCAM) {
return;
- }
+ }*/
boolean fromRight = isRightAnimation(DUALCAM);
selection(mCurrentSelected, false);
CategoryPanel categoryPanel = new CategoryPanel();
@@ -281,9 +330,11 @@ public class MainPanel extends Fragment {
}
public void showPanel(int currentPanel) {
+ isEffectClicked = true;
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
switch (currentPanel) {
case LOOKS: {
- loadCategoryLookPanel(false);
+ loadCategoryLookPanel(true);
break;
}
case BORDERS: {
@@ -311,6 +362,13 @@ public class MainPanel extends Fragment {
break;
}
}
+ if (currentPanel > 0) {
+ activity.setScaleImage(true);
+ activity.adjustCompareButton(true);
+ } else {
+ activity.setScaleImage(false);
+ activity.adjustCompareButton(false);
+ }
}
public void setToggleVersionsPanelButton(ImageButton button) {
diff --git a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
index 811b47466..1ff3e1677 100644
--- a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
+++ b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java
@@ -21,14 +21,17 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.editors.Editor;
public class BasicSlider implements Control {
private SeekBar mSeekBar;
+ private TextView mFilterValue,mFilterText;
private ParameterInteger mParameter;
Editor mEditor;
@@ -42,8 +45,12 @@ public class BasicSlider implements Control {
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout lp = (LinearLayout) inflater.inflate(
R.layout.filtershow_seekbar, container, true);
+ LinearLayout lpBasicFilterContainer = (LinearLayout) lp.findViewById(R.id.basicFilterContainer);
mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
+ mFilterText = (TextView)lpBasicFilterContainer.findViewById(R.id.tvFilterName);
+ mFilterValue = (TextView)lpBasicFilterContainer.findViewById(R.id.tvFilterValue);
mSeekBar.setVisibility(View.VISIBLE);
+ mEditor.setBasicFilterUI(mFilterText, mFilterValue);
updateUI();
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
diff --git a/src/com/android/gallery3d/filtershow/controller/StyleChooser.java b/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
index dc31401e0..ab17d63d7 100644
--- a/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
+++ b/src/com/android/gallery3d/filtershow/controller/StyleChooser.java
@@ -45,7 +45,7 @@ public class StyleChooser implements Control {
LayoutParams lp = new LayoutParams(dim, dim);
for (int i = 0; i < n; i++) {
final ImageButton button = new ImageButton(context);
- button.setScaleType(ScaleType.CENTER_CROP);
+ button.setScaleType(ScaleType.CENTER_INSIDE);
button.setLayoutParams(lp);
button.setBackgroundResource(android.R.color.transparent);
mIconButton.add(button);
diff --git a/src/com/android/gallery3d/filtershow/controller/TitledSlider.java b/src/com/android/gallery3d/filtershow/controller/TitledSlider.java
index f29442bb9..8031b759f 100644
--- a/src/com/android/gallery3d/filtershow/controller/TitledSlider.java
+++ b/src/com/android/gallery3d/filtershow/controller/TitledSlider.java
@@ -88,7 +88,7 @@ public class TitledSlider implements Control {
@Override
public void updateUI() {
if (mControlName != null && mParameter.getParameterName() != null) {
- mControlName.setText(mParameter.getParameterName().toUpperCase());
+ mControlName.setText(mParameter.getParameterName());
}
if (mControlValue != null) {
mControlValue.setText(
diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java
index e3eec390b..490e5991c 100644
--- a/src/com/android/gallery3d/filtershow/editors/Editor.java
+++ b/src/com/android/gallery3d/filtershow/editors/Editor.java
@@ -31,9 +31,11 @@ import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.controller.Control;
+import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -62,6 +64,9 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
public static byte SHOW_VALUE_UNDEFINED = -1;
public static byte SHOW_VALUE_OFF = 0;
public static byte SHOW_VALUE_INT = 1;
+ private View mActionButton, mEditControl;
+ private TextView mBasicFilterText;
+ private TextView mBasicFilterValue;
public static void hackFixStrings(Menu menu) {
int count = menu.size();
@@ -72,7 +77,7 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
}
public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
- return effectName.toUpperCase() + " " + parameterValue;
+ return effectName + " " + parameterValue;
}
protected Editor(int id) {
@@ -91,16 +96,37 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
return true;
}
- public void setUpEditorUI(View actionButton, View editControl,
+ /*public void setUpEditorUI(View actionButton, View editControl,
Button editTitle, Button stateButton) {
mEditTitle = editTitle;
mFilterTitle = stateButton;
mButton = editTitle;
MasterImage.getImage().resetGeometryImages(false);
setUtilityPanelUI(actionButton, editControl);
+ }*/
+
+ public void setUpEditorUI(View editControl, Button stateButton) {
+
+ mFilterTitle = stateButton;
+ MasterImage.getImage().resetGeometryImages(false);
+ mEditControl = editControl;
+ setUtilityPanelUI(null, editControl);
}
- public boolean showsPopupIndicator() {
+ public void setUpEditorUI(Button editTitle, View actionButton,
+ View editControl) {
+ mEditTitle = editTitle;
+ mButton = editTitle;
+ setUtilityPanelUI(actionButton, editControl);
+ }
+
+ public void setBasicFilterUI(TextView textFilterName,
+ TextView textFilterValue) {
+ mBasicFilterText = textFilterName;
+ mBasicFilterValue = textFilterValue;
+ }
+
+ public boolean showsPopupIndicator() {
return false;
}
@@ -257,6 +283,19 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
s = mContext.getString(mLocalRepresentation.getTextId());
}
mButton.setText(calculateUserMessage(mContext, s, ""));
+ if (mLocalRepresentation instanceof FilterBasicRepresentation
+ && mBasicFilterText != null) {
+ mBasicFilterText.setText(s);
+ String text = calculateUserMessage(mContext, s, "");
+ String[] split = text.split("[+-]");
+ int length = split.length;
+ if (length == 2)
+ mBasicFilterValue.setText(split[1] != null ? split[1] : "");
+ mBasicFilterText.setVisibility(View.VISIBLE);
+ mBasicFilterValue.setVisibility(View.VISIBLE);
+ mButton.setVisibility(View.INVISIBLE);
+
+ }
}
/**
@@ -285,7 +324,7 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis
protected void setMenuIcon(boolean on) {
mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
- 0, 0, on ? R.drawable.filtershow_menu_marker_rtl : 0, 0);
+ 0, 0, on ? R.drawable.spinner_triangle : 0, 0);
}
protected void createMenu(int[] strId, View button) {
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java b/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java
index abf0a690f..135c19373 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorChanSat.java
@@ -162,7 +162,7 @@ public class EditorChanSat extends ParametricEditor implements OnSeekBarChangeLi
value = rep.getValue(FilterChanSatRepresentation.MODE_MAGENTA);
mMagentaBar.setProgress(value + 100);
mMagentaValue.setText("" + value);
- String text = mContext.getString(rep.getTextId()).toUpperCase();
+ String text = mContext.getString(rep.getTextId());
mFilterTitle.setText(text);
updateText();
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
index 58bde1260..33e328098 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorDraw.java
@@ -61,11 +61,11 @@ public class EditorDraw extends ParametricEditor implements FilterView {
private static final int MODE_STYLE = FilterDrawRepresentation.PARAM_STYLE;
private static final int MODE_COLOR = FilterDrawRepresentation.PARAM_COLOR;
int[] brushIcons = {
- R.drawable.brush_flat,
- R.drawable.brush_round,
- R.drawable.brush_gauss,
- R.drawable.brush_marker,
- R.drawable.brush_spatter
+ R.drawable.square,
+ R.drawable.round,
+ R.drawable.feather,
+ R.drawable.rectangle,
+ R.drawable.random
};
int[] mBasColors = {
@@ -257,7 +257,7 @@ public class EditorDraw extends ParametricEditor implements FilterView {
R.layout.filtershow_draw_ui, (ViewGroup) editControl, true);
mTabletUI = new EditorDrawTabletUI(this, mContext, lp);
- mDrawString = mContext.getResources().getString(R.string.imageDraw).toUpperCase();
+ mDrawString = mContext.getResources().getString(R.string.imageDraw);
setMenuIcon(true);
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorGrad.java b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
index 059121634..96b8dbdd7 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
@@ -51,8 +51,8 @@ public class EditorGrad extends ParametricEditor
private static final int MODE_BRIGHTNESS = FilterGradRepresentation.PARAM_BRIGHTNESS;
private static final int MODE_SATURATION = FilterGradRepresentation.PARAM_SATURATION;
private static final int MODE_CONTRAST = FilterGradRepresentation.PARAM_CONTRAST;
- private static final int ADD_ICON = R.drawable.ic_grad_add;
- private static final int DEL_ICON = R.drawable.ic_grad_del;
+ private static final int ADD_ICON = R.drawable.addspot;
+ private static final int DEL_ICON = R.drawable.delete;
private int mSliderMode = MODE_BRIGHTNESS;
ImageGrad mImageGrad;
ParamAdapter []mAdapters = new ParamAdapter[3];
@@ -215,7 +215,7 @@ public class EditorGrad extends ParametricEditor
if (mSliderMode != mMode) {
mSliderMode = mMode;
mEffectName = mContext.getResources().getString(getModeNameid(mMode));
- mEffectName = mEffectName.toUpperCase();
+// mEffectName = mEffectName.toUpperCase();
}
mTextView.setText(Integer.toString(value));
mView.invalidate();
@@ -311,7 +311,7 @@ public class EditorGrad extends ParametricEditor
return mEffectName;
}
int val = rep.getParameter(mSliderMode);
- return mEffectName.toUpperCase() + ((val > 0) ? " +" : " ") + val;
+ return mEffectName + ((val > 0) ? " +" : " ") + val;
}
private FilterGradRepresentation getGradRepresentation() {
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
index 54409923e..a127ddf2e 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
@@ -27,6 +27,8 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
+import android.widget.TextView;
+
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.history.HistoryManager;
@@ -80,39 +82,14 @@ public class EditorPanel extends Fragment {
return mMainView;
}
mMainView = (LinearLayout) inflater.inflate(R.layout.filtershow_editor_panel, null);
-
- View actionControl = mMainView.findViewById(R.id.panelAccessoryViewList);
+ //TextView mFilterText = (TextView) mMainView.findViewById(R.id.tvFilterName);
View editControl = mMainView.findViewById(R.id.controlArea);
- ImageButton cancelButton = (ImageButton) mMainView.findViewById(R.id.cancelFilter);
- ImageButton applyButton = (ImageButton) mMainView.findViewById(R.id.applyFilter);
- Button editTitle = (Button) mMainView.findViewById(R.id.applyEffect);
- cancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- cancelCurrentFilter();
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- activity.backToMain();
- }
- });
-
Button toggleState = (Button) mMainView.findViewById(R.id.toggle_state);
mEditor = activity.getEditor(mEditorID);
if (mEditor != null) {
- mEditor.setUpEditorUI(actionControl, editControl, editTitle, toggleState);
+ mEditor.setUpEditorUI(editControl, toggleState);
mEditor.reflectCurrentFilter();
- if (mEditor.useUtilityPanel()) {
- mEditor.openUtilityPanel((LinearLayout) actionControl);
- }
}
- applyButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FilterShowActivity activity = (FilterShowActivity) getActivity();
- mEditor.finalApplyCalled();
- activity.backToMain();
- }
- });
-
showImageStatePanel(activity.isShowingImageStatePanel());
return mMainView;
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
index ff84ba8f9..d77df71a9 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java
@@ -41,7 +41,7 @@ public class EditorStraighten extends Editor implements EditorInfo {
public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
String apply = context.getString(R.string.apply_effect);
apply += " " + effectName;
- return apply.toUpperCase();
+ return apply;
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
index 630a1a9da..fb17ba76e 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorVignette.java
@@ -128,7 +128,7 @@ public class EditorVignette extends ParametricEditor {
}
mImageVignette.setRepresentation(rep);
- String text = mContext.getString(rep.getTextId()).toUpperCase();
+ String text = mContext.getString(rep.getTextId());
mFilterTitle.setText(text);
updateText();
}
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
index c16865721..8398c31c2 100644
--- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -115,12 +115,12 @@ public class ParametricEditor extends Editor {
if (mShowParameter == SHOW_VALUE_INT & useCompact(context)) {
if (getLocalRepresentation() instanceof FilterBasicRepresentation) {
FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
- apply += " " + effectName.toUpperCase() + " " + interval.getStateRepresentation();
+ apply += " " + effectName + " " + interval.getStateRepresentation();
} else {
- apply += " " + effectName.toUpperCase() + " " + parameterValue;
+ apply += " " + effectName + " " + parameterValue;
}
} else {
- apply += " " + effectName.toUpperCase();
+ apply += " " + effectName;
}
return apply;
}
@@ -172,11 +172,15 @@ public class ParametricEditor extends Editor {
if (param != null) {
control(param, editControl);
} else {
- mSeekBar = new SeekBar(editControl.getContext());
+ /*mSeekBar = new SeekBar(editControl.getContext());
LayoutParams lp = new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
mSeekBar.setLayoutParams(lp);
- ((LinearLayout) editControl).addView(mSeekBar);
+ ((LinearLayout) editControl).addView(mSeekBar);*/
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.VISIBLE);
+ }
mSeekBar.setOnSeekBarChangeListener(this);
}
}
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index ba6fff382..3de93cf5a 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -380,8 +380,8 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
};
int[] overlayId = {
- R.drawable.filtershow_dualcam_focus,
- R.drawable.filtershow_dualcam_halo
+ R.drawable.focus,
+ R.drawable.halo
};
String[] serializationNames = {
@@ -415,7 +415,7 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
FilterDualCamSketchRepresentation sketch = new FilterDualCamSketchRepresentation(
context.getString(R.string.sketch), R.string.sketch);
- sketch.setOverlayId(R.drawable.filtershow_dualcam_sketch);
+ sketch.setOverlayId(R.drawable.sketch);
sketch.setOverlayOnly(true);
sketch.setSerializationName("DUAL_CAM_SKETCH");
mDualCam.add(sketch);
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterDualCamFusionRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterDualCamFusionRepresentation.java
index 0e3598b48..8e38c250b 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterDualCamFusionRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterDualCamFusionRepresentation.java
@@ -58,7 +58,7 @@ public class FilterDualCamFusionRepresentation extends FilterRepresentation {
setEditorId(EditorDualCamFusion.ID);
setShowParameterValue(false);
setTextId(R.string.fusion);
- setOverlayId(R.drawable.filtershow_dualcam_fusion);
+ setOverlayId(R.drawable.fusion);
setOverlayOnly(true);
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 1d580c1c4..1a32e46e0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -20,7 +20,6 @@ import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.renderscript.Allocation;
-import android.graphics.Rect;
import android.widget.Toast;
import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils;
@@ -93,13 +92,6 @@ public abstract class ImageFilter implements Cloneable {
.getGeometryFilters(), true, MasterImage.getImage().getOriginalBounds(), w, h);
}
- protected Matrix getImageToScreenMatrix(int imageWidth, int imageHeight, int viewWidth,
- int viewHeight) {
- Rect imageDimens = new Rect(0, 0, imageWidth, imageHeight);
- return GeometryMathUtils.getImageToScreenMatrix(getEnvironment().getImagePreset()
- .getGeometryFilters(), true, imageDimens, viewWidth, viewHeight);
- }
-
public void setEnvironment(FilterEnvironment environment) {
mEnvironment = environment;
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java
index c019c1ab8..1e89f3361 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamFusion.java
@@ -82,10 +82,8 @@ public class ImageFilterDualCamFusion extends ImageFilter {
Rect originalBounds = MasterImage.getImage().getOriginalBounds();
int origW = originalBounds.width();
int origH = originalBounds.height();
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(w, h, BitmapCache.FILTERS);
+ filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(origW, origH, BitmapCache.FILTERS);
filteredBitmap.setHasAlpha(true);
boolean result = DualCameraNativeEngine.getInstance().getForegroundImg(point.x, point.y, filteredBitmap);
@@ -114,10 +112,12 @@ public class ImageFilterDualCamFusion extends ImageFilter {
bitmap.setHasAlpha(true);
Canvas canvas = new Canvas(bitmap);
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
canvas.drawColor(0, PorterDuff.Mode.CLEAR);
if(getEnvironment().getImagePreset().getDoApplyGeometry()) {
- Matrix originalToScreen = getImageToScreenMatrix(w, h, w, h);
+ Matrix originalToScreen = getOriginalToScreenMatrix(w, h);
canvas.drawBitmap(filteredBitmap, originalToScreen, null);
} else {
canvas.drawBitmap(filteredBitmap, null, new Rect(0,0,w,h), null);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java
index 254773938..6907fe394 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamSketch.java
@@ -78,10 +78,8 @@ public class ImageFilterDualCamSketch extends ImageFilter {
Rect originalBounds = MasterImage.getImage().getOriginalBounds();
int origW = originalBounds.width();
int origH = originalBounds.height();
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(w, h, BitmapCache.FILTERS);
+ filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(origW, origH, BitmapCache.FILTERS);
result = DualCameraNativeEngine.getInstance().applySketch(point.x, point.y, filteredBitmap);
@@ -107,9 +105,10 @@ public class ImageFilterDualCamSketch extends ImageFilter {
}
Canvas canvas = new Canvas(bitmap);
-
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
if(getEnvironment().getImagePreset().getDoApplyGeometry()) {
- Matrix originalToScreen = getImageToScreenMatrix(w, h, w, h);
+ Matrix originalToScreen = getOriginalToScreenMatrix(w, h);
canvas.drawBitmap(filteredBitmap, originalToScreen, mPaint);
} else {
canvas.drawBitmap(filteredBitmap, null, new Rect(0,0,w,h), mPaint);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java
index af1531aad..dce31c353 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDualCamera.java
@@ -81,10 +81,8 @@ public class ImageFilterDualCamera extends ImageFilter {
Rect originalBounds = MasterImage.getImage().getOriginalBounds();
int origW = originalBounds.width();
int origH = originalBounds.height();
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(w, h, BitmapCache.FILTERS);
+ filteredBitmap = MasterImage.getImage().getBitmapCache().getBitmap(origW, origH, BitmapCache.FILTERS);
boolean result = false;
@@ -122,9 +120,10 @@ public class ImageFilterDualCamera extends ImageFilter {
}
Canvas canvas = new Canvas(bitmap);
-
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
if(getEnvironment().getImagePreset().getDoApplyGeometry()) {
- Matrix originalToScreen = getImageToScreenMatrix(w, h, w, h);
+ Matrix originalToScreen = getOriginalToScreenMatrix(w, h);
canvas.drawBitmap(filteredBitmap, originalToScreen, mPaint);
} else {
canvas.drawBitmap(filteredBitmap, null, new Rect(0,0,w,h), mPaint);
diff --git a/src/com/android/gallery3d/filtershow/history/HistoryManager.java b/src/com/android/gallery3d/filtershow/history/HistoryManager.java
index 9d5065a28..216bb1e16 100644
--- a/src/com/android/gallery3d/filtershow/history/HistoryManager.java
+++ b/src/com/android/gallery3d/filtershow/history/HistoryManager.java
@@ -25,10 +25,13 @@ public class HistoryManager {
private static final String LOGTAG = "HistoryManager";
private Vector<HistoryItem> mHistoryItems = new Vector<HistoryItem>();
+ private Vector<HistoryItem> mHistoryItemsActiveFilter = new Vector<HistoryItem>();
private int mCurrentPresetPosition = 0;
+ private int mComparePresetPosition = 0;
private MenuItem mUndoMenuItem = null;
private MenuItem mRedoMenuItem = null;
private MenuItem mResetMenuItem = null;
+ private int mActiveFilter = -1;
public void setMenuItems(MenuItem undoItem, MenuItem redoItem, MenuItem resetItem) {
mUndoMenuItem = undoItem;
@@ -128,6 +131,7 @@ public class HistoryManager {
public void addHistoryItem(HistoryItem preset) {
insert(preset, 0);
+ insertActiveFilter(preset, 0);
updateMenuItems();
}
@@ -170,4 +174,46 @@ public class HistoryManager {
return mCurrentPresetPosition;
}
+ public int backToOriginal() {
+ saveComparePresetPosition();
+ mCurrentPresetPosition = getCount() - 1;
+ return mCurrentPresetPosition;
+ }
+
+ public int backToCurrent() {
+ mCurrentPresetPosition = getCurrentPresetPosition();
+ return mCurrentPresetPosition;
+ }
+ public int setActiveFilter(int value)
+ {
+ mActiveFilter = value;
+ return mActiveFilter;
+ }
+ private void insertActiveFilter(HistoryItem preset, int position)
+ {
+ mHistoryItemsActiveFilter.add(preset);
+ }
+ public void resetActiveFilter()
+ {
+ mHistoryItemsActiveFilter.clear();
+ }
+ public int undoCurrentFilter()
+ {
+ mCurrentPresetPosition = mCurrentPresetPosition + mHistoryItemsActiveFilter.size();
+ if (mCurrentPresetPosition >= getCount()) {
+ mCurrentPresetPosition = getCount() - 1;
+ }
+ updateMenuItems();
+ return mCurrentPresetPosition;
+ }
+
+ public void saveComparePresetPosition()
+ {
+ mComparePresetPosition = mCurrentPresetPosition ;
+ }
+ public int getCurrentPresetPosition()
+ {
+ return mComparePresetPosition;
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
index 614b6485d..958170c78 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
@@ -446,6 +446,9 @@ public final class GeometryMathUtils {
bw = bitmapHeight;
}
float scale = GeometryMathUtils.scale(bw, bh, viewWidth, viewHeight);
+ if (scale > 3.0f) {
+ scale = 3.0f;
+ }
scale *= SHOW_SCALE;
float s = Math.min(viewWidth / (float) bitmapWidth, viewHeight / (float) bitmapHeight);
Matrix m = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
index 4e53f8247..6f0268fb6 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
@@ -261,6 +261,7 @@ public class ImageCrop extends ImageShow {
if (!mValidDraw || bitmap == null) {
return;
}
+ toggleComparisonButtonVisibility();
forceStateConsistency();
mImageBounds.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
// If display matrix doesn't exist, create it and its dependencies
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java b/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java
index 26c49b1a8..acc0e4df9 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageMirror.java
@@ -66,6 +66,7 @@ public class ImageMirror extends ImageShow {
if (image == null) {
return;
}
+ toggleComparisonButtonVisibility();
GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep);
GeometryMathUtils.drawTransformedCropped(mDrawHolder, canvas, image, getWidth(),
getHeight());
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
index 5186c09d7..a620847bb 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageRotate.java
@@ -70,6 +70,7 @@ public class ImageRotate extends ImageShow {
if (image == null) {
return;
}
+ toggleComparisonButtonVisibility();
GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep);
GeometryMathUtils.drawTransformedCropped(mDrawHolder, canvas, image, canvas.getWidth(),
canvas.getHeight());
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 9ca143fde..261d43fb8 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -44,6 +44,7 @@ import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.android.gallery3d.R;
@@ -124,6 +125,7 @@ public class ImageShow extends View implements OnGestureListener,
private Paint mMaskPaint = new Paint();
private Matrix mShaderMatrix = new Matrix();
private boolean mDidStartAnimation = false;
+ private boolean isScalingUpAllowed = true;
private static Bitmap convertToAlphaMask(Bitmap b) {
Bitmap a = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ALPHA_8);
@@ -324,7 +326,7 @@ public class ImageShow extends View implements OnGestureListener,
}
// drawHighresImage(canvas, fullHighres);
- drawCompareImage(canvas, getGeometryOnlyImage());
+ //drawCompareImage(canvas, getGeometryOnlyImage());
canvas.restore();
@@ -1031,4 +1033,29 @@ public class ImageShow extends View implements OnGestureListener,
return false;
}
+ public void scaleImage(boolean isScaled, Context context) {
+ float scale = 1.0f;
+ Bitmap bitmap = MasterImage.getImage().getOriginalBitmapLarge();
+ int bitmapWidth = bitmap.getWidth();
+ int bitmapheight = bitmap.getHeight();
+
+// int width = MasterImage.getImage().getOriginalBounds().width();
+// int height = MasterImage.getImage().getOriginalBounds().height();
+ int width = getWidth();
+ int height = getHeight();
+ int scaledWidth = context.getResources().getDimensionPixelSize(R.dimen.scaled_image_width);
+ int scaledHeight = context.getResources().getDimensionPixelSize(R.dimen.scaled_image_height);
+ if (isScaled) {
+ scale = (float) scaledHeight / height ;
+ }
+ MasterImage.getImage().setScaleFactor(scale);
+
+ invalidate();
+ }
+
+ public void toggleComparisonButtonVisibility()
+ {
+ mActivity.toggleComparisonButtonVisibility();
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
index 4742f2ecf..829af18eb 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java
@@ -223,6 +223,9 @@ public class ImageStraighten extends ImageShow {
ih = imageHeight;
}
float scale = GeometryMathUtils.scale(iw, ih, viewWidth, viewHeight);
+ if (scale > 3.0f) {
+ scale = 3.0f;
+ }
scale *= GeometryMathUtils.SHOW_SCALE;
GeometryMathUtils.scaleRect(tmp, scale);
getUntranslatedStraightenCropBounds(tmp, mAngle);
diff --git a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
index 63bcbea5d..e9190e3fd 100644
--- a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
@@ -35,15 +35,17 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
private final NinePatchTexture mFramePressed;
private final NinePatchTexture mFrameSelected;
private final ResourceTexture mDrmIcon;
+ private final ResourceTexture mSelectionIcon;
private FadeOutTexture mFramePressedUp;
protected AbstractSlotRenderer(Context context) {
mVideoOverlay = new ResourceTexture(context, R.drawable.ic_video_thumb);
- mVideoPlayIcon = new ResourceTexture(context, R.drawable.ic_gallery_play);
+ mVideoPlayIcon = new ResourceTexture(context, R.drawable.play_detail);
mPanoramaIcon = new ResourceTexture(context, R.drawable.ic_360pano_holo_light);
mFramePressed = new NinePatchTexture(context, R.drawable.grid_pressed);
mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
mDrmIcon = new ResourceTexture(context, R.drawable.drm_image);
+ mSelectionIcon = new ResourceTexture(context, R.drawable.multiselect);
}
protected void drawContent(GLCanvas canvas,
@@ -52,7 +54,7 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
// The content is always rendered in to the largest square that fits
// inside the slot, aligned to the top of the slot.
- width = height = Math.min(width, height);
+ //width = height = Math.min(width, height);
if (rotation != 0) {
canvas.translate(width / 2, height / 2);
canvas.rotate(rotation, 0, 0, 1);
@@ -69,20 +71,18 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
canvas.restore();
}
- protected void drawVideoOverlay(GLCanvas canvas, int width, int height) {
+ protected void drawVideoOverlay(GLCanvas canvas, int width, int height,
+ boolean isGridViewShown, int thumbSize) {
// Scale the video overlay to the height of the thumbnail and put it
// on the left side.
- ResourceTexture v = mVideoOverlay;
- float scale = (float) height / v.getHeight();
- int w = Math.round(scale * v.getWidth());
- int h = Math.round(scale * v.getHeight());
- v.draw(canvas, 0, 0, w, h);
-
- int s = Math.min(width, height) / 6;
- mVideoPlayIcon.draw(canvas, (width - s) / 2, (height - s) / 2, s, s);
+ int side = Math.min(width, height) / 6;
+ if (!isGridViewShown)
+ width = thumbSize;
+ mVideoPlayIcon.draw(canvas, (width - side) / 2, (height - side) / 2, side, side);
}
- protected void drawDrmOverlay(GLCanvas canvas, int width, int height, int Drm_mediaType) {
+ protected void drawDrmOverlay(GLCanvas canvas, int width, int height, int Drm_mediaType,
+ boolean isGridViewShown, int thumbSize) {
// Scale the video overlay to the height of the thumbnail and put it on the left side.
if (Drm_mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO) {
ResourceTexture v = mVideoOverlay;
@@ -92,11 +92,18 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
v.draw(canvas, 0, 0, w, h);
}
int side = Math.min(width, height) / 6;
+ if (!isGridViewShown) {
+ width = thumbSize;
+ }
mDrmIcon.draw(canvas, (width - side) / 2, (height - side) / 2, side, side);
}
- protected void drawPanoramaIcon(GLCanvas canvas, int width, int height) {
+ protected void drawPanoramaIcon(GLCanvas canvas, int width, int height,
+ boolean isGridViewShown, int thumbSize) {
int iconSize = Math.min(width, height) / 6;
+ if (!isGridViewShown) {
+ width = thumbSize;
+ }
mPanoramaIcon.draw(canvas, (width - iconSize) / 2, (height - iconSize) / 2,
iconSize, iconSize);
}
@@ -124,7 +131,8 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
}
protected void drawSelectedFrame(GLCanvas canvas, int width, int height) {
- drawFrame(canvas, mFrameSelected.getPaddings(), mFrameSelected, 0, 0, width, height);
+ mSelectionIcon.draw(canvas,15,15);
+ //drawFrame(canvas, mFrameSelected.getPaddings(), mFrameSelected, 0, 0, width, height);
}
protected static void drawFrame(GLCanvas canvas, Rect padding, Texture frame,
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index 080b6af2c..3ff8ed232 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -31,6 +31,7 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ShareActionProvider;
+import android.widget.Toolbar;
import android.widget.ShareActionProvider.OnShareTargetSelectedListener;
import com.android.gallery3d.R;
@@ -80,6 +81,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
private final Handler mMainHandler;
private ActionMode mActionMode;
private boolean mShareMaxDialog = false;
+ private Toolbar mToolbar;
private static class GetAllPanoramaSupports implements PanoramaSupportCallback {
private int mNumInfoRequired;
@@ -131,11 +133,13 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
mMenuExecutor = new MenuExecutor(activity, selectionManager);
mMainHandler = new Handler(activity.getMainLooper());
mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity.getAndroidContext());
+ mToolbar = mActivity.getToolbar();
}
public void startActionMode() {
Activity a = mActivity;
- mActionMode = a.startActionMode(this);
+// mActionMode = a.startActionMode(this);
+ mActionMode = mActivity.getToolbar().startActionMode(this);
View customView = LayoutInflater.from(a).inflate(
R.layout.action_mode, null);
mActionMode.setCustomView(customView);
@@ -238,6 +242,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(R.menu.operation, menu);
+ mActivity.getToolbar().setVisibility(View.INVISIBLE);
mMenu = menu;
mSharePanoramaMenuItem = menu.findItem(R.id.action_share_panorama);
@@ -262,6 +267,8 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
@Override
public void onDestroyActionMode(ActionMode mode) {
mSelectionManager.leaveSelectionMode();
+ mActivity.getToolbar().setVisibility(View.VISIBLE);
+
}
private ArrayList<MediaObject> getSelectedMediaObjects(JobContext jc) {
@@ -279,7 +286,6 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
}
selected.add(manager.getMediaObject(path));
}
-
return selected;
}
// Menu options are determined by selection set itself.
@@ -401,9 +407,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
// Disable share actions until share intent is in good shape
if (mSharePanoramaMenuItem != null) mSharePanoramaMenuItem.setEnabled(false);
- if (mShareMenuItem != null && mSelectionManager.inSelectAllMode()) {
- mShareMenuItem.setVisible(false);
- }
+ if (mShareMenuItem != null) mShareMenuItem.setEnabled(false);
// Generate sharing intent and update supported operations in the background
// The task can take a long time and be canceled in the mean time.
@@ -489,7 +493,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
mShareMaxDialog = false;
}
- mShareMenuItem.setVisible(canShare);
+ mShareMenuItem.setEnabled(canShare);
mShareActionProvider.setShareIntent(share_intent);
}
}
diff --git a/src/com/android/gallery3d/ui/AlbumLabelMaker.java b/src/com/android/gallery3d/ui/AlbumLabelMaker.java
index 3ac3bb7fe..20e4a2dea 100644
--- a/src/com/android/gallery3d/ui/AlbumLabelMaker.java
+++ b/src/com/android/gallery3d/ui/AlbumLabelMaker.java
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,18 +41,19 @@ import java.util.Locale;
public class AlbumLabelMaker {
private static final int BORDER_SIZE = 0;
- private final AlbumSetSlotRenderer.LabelSpec mSpec;
- private final TextPaint mTitlePaint;
- private final TextPaint mCountPaint;
+ private AlbumSetSlotRenderer.LabelSpec mSpec;
+ private AlbumSlotRenderer.LabelSpec mAlbumListSpec;
+ private TextPaint mTitlePaint;
+ private TextPaint mCountPaint;
private final Context mContext;
private int mLabelWidth;
private int mBitmapWidth;
private int mBitmapHeight;
- private final LazyLoadedBitmap mLocalSetIcon;
+ /*private final LazyLoadedBitmap mLocalSetIcon;
private final LazyLoadedBitmap mPicasaIcon;
- private final LazyLoadedBitmap mCameraIcon;
+ private final LazyLoadedBitmap mCameraIcon;*/
public AlbumLabelMaker(Context context, AlbumSetSlotRenderer.LabelSpec spec) {
mContext = context;
@@ -57,16 +61,22 @@ public class AlbumLabelMaker {
mTitlePaint = getTextPaint(spec.titleFontSize, spec.titleColor, false);
mCountPaint = getTextPaint(spec.countFontSize, spec.countColor, false);
- mLocalSetIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_folder);
+ /*mLocalSetIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_folder);
mPicasaIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_picasa);
- mCameraIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_camera);
+ mCameraIcon = new LazyLoadedBitmap(R.drawable.frame_overlay_gallery_camera);*/
+ }
+
+ public AlbumLabelMaker(Context context, AlbumSlotRenderer.LabelSpec spec) {
+ mContext = context;
+ mAlbumListSpec = spec;
+ mTitlePaint = getTextPaint(spec.titleFontSize, spec.titleColor, false);
}
public static int getBorderSize() {
return BORDER_SIZE;
}
- private Bitmap getOverlayAlbumIcon(int sourceType) {
+ /*private Bitmap getOverlayAlbumIcon(int sourceType) {
switch (sourceType) {
case DataSourceType.TYPE_CAMERA:
return mCameraIcon.get();
@@ -76,13 +86,14 @@ public class AlbumLabelMaker {
return mPicasaIcon.get();
}
return null;
- }
+ }*/
private static TextPaint getTextPaint(int textSize, int color, boolean isBold) {
TextPaint paint = new TextPaint();
paint.setTextSize(textSize);
paint.setAntiAlias(true);
paint.setColor(color);
+ paint.setTypeface(Typeface.SANS_SERIF);
//paint.setShadowLayer(2f, 0f, 0f, Color.LTGRAY);
if (isBold) {
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
@@ -109,12 +120,16 @@ public class AlbumLabelMaker {
}
}
- public synchronized void setLabelWidth(int width) {
+ public synchronized void setLabelWidth(int width, String key) {
if (mLabelWidth == width) return;
mLabelWidth = width;
int borders = 2 * BORDER_SIZE;
mBitmapWidth = width + borders;
- mBitmapHeight = mSpec.labelBackgroundHeight + borders;
+ if (key.equalsIgnoreCase(AlbumSetSlidingWindow.KEY_ALBUM)) {
+ mBitmapHeight = mSpec.labelBackgroundHeight + borders;
+ } else {
+ mBitmapHeight = mAlbumListSpec.labelBackgroundHeight + borders;
+ }
}
public ThreadPool.Job<Bitmap> requestLabel(
@@ -122,6 +137,10 @@ public class AlbumLabelMaker {
return new AlbumLabelJob(title, count, sourceType);
}
+ public ThreadPool.Job<Bitmap> requestLabel(String title) {
+ return new AlbumLabelJob(title);
+ }
+
static void drawText(Canvas canvas,
int x, int y, String text, int lengthLimit, TextPaint p) {
// The TextPaint cannot be used concurrently
@@ -134,8 +153,9 @@ public class AlbumLabelMaker {
private class AlbumLabelJob implements ThreadPool.Job<Bitmap> {
private final String mTitle;
- private final String mCount;
- private final int mSourceType;
+ private String mCount;
+ private int mSourceType;
+ private boolean isAlbumListViewShown;
public AlbumLabelJob(String title, String count, int sourceType) {
mTitle = title;
@@ -143,13 +163,20 @@ public class AlbumLabelMaker {
mSourceType = sourceType;
}
+ public AlbumLabelJob(String title) {
+ mTitle = title;
+ isAlbumListViewShown = true;
+
+ }
+
@Override
public Bitmap run(JobContext jc) {
AlbumSetSlotRenderer.LabelSpec s = mSpec;
+ AlbumSlotRenderer.LabelSpec s1 = mAlbumListSpec;
String title = mTitle;
String count = mCount;
- Bitmap icon = getOverlayAlbumIcon(mSourceType);
+ //Bitmap icon = getOverlayAlbumIcon(mSourceType);
Bitmap bitmap;
int labelWidth;
@@ -159,17 +186,27 @@ public class AlbumLabelMaker {
bitmap = GalleryBitmapPool.getInstance().get(mBitmapWidth, mBitmapHeight);
}
- if (bitmap == null) {
- int borders = 2 * BORDER_SIZE;
+ int borders = 2 * BORDER_SIZE;
+ if (!isAlbumListViewShown) {
+ if (bitmap == null) {
+
+ bitmap = Bitmap
+ .createBitmap(labelWidth + borders,
+ s.labelBackgroundHeight + borders,
+ Config.ARGB_8888);
+ }
+ } else {
bitmap = Bitmap.createBitmap(labelWidth + borders,
- s.labelBackgroundHeight + borders, Config.ARGB_8888);
+ s1.labelBackgroundHeight + borders, Config.ARGB_8888);
}
Canvas canvas = new Canvas(bitmap);
canvas.clipRect(BORDER_SIZE, BORDER_SIZE,
bitmap.getWidth() - BORDER_SIZE,
bitmap.getHeight() - BORDER_SIZE);
- canvas.drawColor(mSpec.backgroundColor, PorterDuff.Mode.SRC);
+ if (!isAlbumListViewShown) {
+ canvas.drawColor(mSpec.backgroundColor, PorterDuff.Mode.SRC);
+ }
canvas.translate(BORDER_SIZE, BORDER_SIZE);
@@ -178,57 +215,59 @@ public class AlbumLabelMaker {
// draw title
if (jc.isCancelled()) return null;
int strLength = (int) mTitlePaint.measureText(title);
- int x = labelWidth - (s.leftMargin + s.iconSize) - strLength;
+ if (!isAlbumListViewShown) {
+ int x = labelWidth - s.leftMargin - strLength;
// TODO: is the offset relevant in new reskin?
// int y = s.titleOffset;
int y = (s.labelBackgroundHeight - s.titleFontSize) / 2;
- drawText(canvas, x, y, title, labelWidth - s.leftMargin - x -
- s.titleRightMargin, mTitlePaint);
+ drawText(canvas, x, y, title, labelWidth - s.leftMargin - x, mTitlePaint);
// draw count
if (jc.isCancelled()) return null;
- x = s.leftMargin + 10;// plus 10 to get a much bigger margin
+ x = s.leftMargin + 10 - s.titleRightMargin;// plus 10 to get a much bigger margin
y = (s.labelBackgroundHeight - s.countFontSize) / 2;
drawText(canvas, x, y, count,
labelWidth - x, mCountPaint);
- // draw the icon
- if (icon != null) {
- if (jc.isCancelled()) return null;
- float scale = (float) s.iconSize / icon.getWidth();
- canvas.translate(labelWidth - s.leftMargin - s.iconSize,
- (s.labelBackgroundHeight -
- Math.round(scale * icon.getHeight())) / 2f);
- canvas.scale(scale, scale);
- canvas.drawBitmap(icon, 0, 0, null);
+ } else {
+ int x = labelWidth
+ - (s1.leftMargin + s1.iconSize)
+ - strLength;
+ // TODO: is the offset relevant in new reskin?
+ // int y = s.titleOffset;
+ int y = (s1.labelBackgroundHeight - s1.titleFontSize) / 2;
+ drawText(canvas, x, y, title, labelWidth - s1.leftMargin
+ - x, mTitlePaint);
}
- } else { // LTR
- // draw title
- if (jc.isCancelled()) return null;
- int x = s.leftMargin + s.iconSize;
- // TODO: is the offset relevant in new reskin?
- // int y = s.titleOffset;
- int y = (s.labelBackgroundHeight - s.titleFontSize) / 2;
- drawText(canvas, x, y, title, labelWidth - s.leftMargin - x -
- s.titleRightMargin, mTitlePaint);
- // draw count
- if (jc.isCancelled()) return null;
- x = labelWidth - s.titleRightMargin;
- y = (s.labelBackgroundHeight - s.countFontSize) / 2;
- drawText(canvas, x, y, count,
- labelWidth - x, mCountPaint);
-
- // draw the icon
- if (icon != null) {
- if (jc.isCancelled()) return null;
- float scale = (float) s.iconSize / icon.getWidth();
- canvas.translate(s.leftMargin, (s.labelBackgroundHeight -
- Math.round(scale * icon.getHeight())) / 2f);
- canvas.scale(scale, scale);
- canvas.drawBitmap(icon, 0, 0, null);
+ } else { // LTR
+ // draw title
+ if (jc.isCancelled())
+ return null;
+ if (!isAlbumListViewShown) {
+ int x = s.leftMargin + s.titleLeftMargin;
+ // TODO: is the offset relevant in new reskin?
+ // int y = s.titleOffset;
+ int y = (s.labelBackgroundHeight - s.titleFontSize) / 2;
+ drawText(canvas, x, y, title, labelWidth - s.leftMargin - x
+ - s.titleRightMargin - s.countRightMargin, mTitlePaint);
+
+ // draw count
+ if (jc.isCancelled())
+ return null;
+ x = labelWidth - s.titleRightMargin - s.countRightMargin;
+ y = (s.labelBackgroundHeight - s.countFontSize) / 2;
+ drawText(canvas, x, y, count, labelWidth - x, mCountPaint);
+ } else {
+
+ int x = s1.leftMargin + s1.iconSize;
+ // TODO: is the offset relevant in new reskin?
+ // int y = s.titleOffset;
+ int y = (s1.labelBackgroundHeight - s1.titleFontSize) / 2;
+
+ drawText(canvas, x, y, title, labelWidth - s1.leftMargin
+ - x, mTitlePaint);
}
- }
-
+ }
return bitmap;
}
}
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 8149df4b3..8dd149647 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -39,6 +39,7 @@ import com.android.gallery3d.util.ThreadPool;
public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
private static final String TAG = "AlbumSetSlidingWindow";
private static final int MSG_UPDATE_ALBUM_ENTRY = 1;
+ public static final String KEY_ALBUM = "AlbumSet";
public static interface Listener {
public void onSizeChanged(int size);
@@ -527,7 +528,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
mSlotWidth = width;
mLoadingLabel = null;
- mLabelMaker.setLabelWidth(mSlotWidth);
+ mLabelMaker.setLabelWidth(mSlotWidth,KEY_ALBUM);
if (!mIsActive) return;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index 46daf1451..5c817e6de 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -58,11 +58,13 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
public int countFontSize;
public int leftMargin;
public int iconSize;
+ public int titleLeftMargin;
public int titleRightMargin;
public int backgroundColor;
public int titleColor;
public int countColor;
public int borderSize;
+ public int countRightMargin;
}
public AlbumSetSlotRenderer(AbstractGalleryActivity activity,
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index fec7d1e92..f0540b175 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,17 +19,28 @@
package com.android.gallery3d.ui;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.Bitmap.Config;
import android.os.Message;
+import android.text.TextPaint;
+import android.text.TextUtils;
import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumDataLoader;
+import com.android.gallery3d.app.AlbumPage;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
import com.android.gallery3d.data.Path;
+import com.android.gallery3d.glrenderer.BitmapTexture;
import com.android.gallery3d.glrenderer.Texture;
+import com.android.gallery3d.glrenderer.TextureUploader;
import com.android.gallery3d.glrenderer.TiledTexture;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
@@ -38,14 +52,18 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
private static final int MSG_UPDATE_ENTRY = 0;
private static final int JOB_LIMIT = 2;
+ private static final int MSG_UPDATE_ALBUM_ENTRY = 1;
+ public static final String KEY_ALBUM = "Album";
public static interface Listener {
public void onSizeChanged(int size);
+
public void onContentChanged();
}
public static class AlbumEntry {
public MediaItem item;
+ public String name; // For title of image
public Path path;
public boolean isPanorama;
public int rotation;
@@ -55,6 +73,9 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public Texture content;
private BitmapLoader contentLoader;
private PanoSupportListener mPanoSupportListener;
+ public BitmapTexture labelTexture;
+ private BitmapLoader labelLoader;
+
}
private final AlbumDataLoader mSource;
@@ -75,36 +96,64 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
private int mActiveRequestCount = 0;
private boolean mIsActive = false;
+ private AlbumLabelMaker mLabelMaker;
+ private int mSlotWidth;
+ private BitmapTexture mLoadingLabel;
+ private TextureUploader mLabelUploader;
+ private int mCurrentView;
+ private AbstractGalleryActivity mActivity;
+ private boolean isSlotSizeChanged;
+ private boolean mViewType;
private class PanoSupportListener implements PanoramaSupportCallback {
public final AlbumEntry mEntry;
- public PanoSupportListener (AlbumEntry entry) {
+
+ public PanoSupportListener(AlbumEntry entry) {
mEntry = entry;
}
+
@Override
- public void panoramaInfoAvailable(MediaObject mediaObject, boolean isPanorama,
- boolean isPanorama360) {
- if (mEntry != null) mEntry.isPanorama = isPanorama;
+ public void panoramaInfoAvailable(MediaObject mediaObject,
+ boolean isPanorama, boolean isPanorama360) {
+ if (mEntry != null)
+ mEntry.isPanorama = isPanorama;
}
}
public AlbumSlidingWindow(AbstractGalleryActivity activity,
- AlbumDataLoader source, int cacheSize) {
+ AlbumDataLoader source, int cacheSize,
+ AlbumSlotRenderer.LabelSpec labelSpec, boolean viewType) {
source.setDataListener(this);
mSource = source;
+ mViewType = viewType;
mData = new AlbumEntry[cacheSize];
mSize = source.size();
-
mHandler = new SynchronizedHandler(activity.getGLRoot()) {
@Override
public void handleMessage(Message message) {
- Utils.assertTrue(message.what == MSG_UPDATE_ENTRY);
- ((ThumbnailLoader) message.obj).updateEntry();
+ switch (message.what) {
+ case 0:
+ Utils.assertTrue(message.what == MSG_UPDATE_ENTRY);
+ ((ThumbnailLoader) message.obj).updateEntry();
+ break;
+ case 1:
+ Utils.assertTrue(message.what == MSG_UPDATE_ALBUM_ENTRY);
+ ((EntryUpdater) message.obj).updateEntry();
+ break;
+ }
+
}
};
mThreadPool = new JobLimiter(activity.getThreadPool(), JOB_LIMIT);
+ if (!mViewType) {
+ mLabelMaker = new AlbumLabelMaker(activity.getAndroidContext(),
+ labelSpec);
+ mLabelUploader = new TextureUploader(activity.getGLRoot());
+ }
mTileUploader = new TiledTexture.Uploader(activity.getGLRoot());
+ mActivity = activity;
+
}
public void setListener(Listener listener) {
@@ -113,8 +162,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public AlbumEntry get(int slotIndex) {
if (!isActiveSlot(slotIndex)) {
- Utils.fail("invalid slot: %s outsides (%s, %s)",
- slotIndex, mActiveStart, mActiveEnd);
+ Utils.fail("invalid slot: %s outsides (%s, %s)", slotIndex,
+ mActiveStart, mActiveEnd);
}
return mData[slotIndex % mData.length];
}
@@ -124,7 +173,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
}
private void setContentWindow(int contentStart, int contentEnd) {
- if (contentStart == mContentStart && contentEnd == mContentEnd) return;
+ if (contentStart == mContentStart && contentEnd == mContentEnd)
+ return;
if (!mIsActive) {
mContentStart = contentStart;
@@ -170,12 +220,13 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
mActiveStart = start;
mActiveEnd = end;
- int contentStart = Utils.clamp((start + end) / 2 - data.length / 2,
- 0, Math.max(0, mSize - data.length));
+ int contentStart = Utils.clamp((start + end) / 2 - data.length / 2, 0,
+ Math.max(0, mSize - data.length));
int contentEnd = Math.min(contentStart + data.length, mSize);
setContentWindow(contentStart, contentEnd);
updateTextureUploadQueue();
- if (mIsActive) updateAllImageRequests();
+ if (mIsActive)
+ updateAllImageRequests();
}
private void uploadBgTextureInSlot(int index) {
@@ -184,12 +235,21 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
if (entry.bitmapTexture != null) {
mTileUploader.addTexture(entry.bitmapTexture);
}
+ if (!mViewType) {
+ if (entry.labelTexture != null) {
+ mLabelUploader.addBgTexture(entry.labelTexture);
+ }
+ }
}
}
private void updateTextureUploadQueue() {
- if (!mIsActive) return;
+ if (!mIsActive)
+ return;
mTileUploader.clear();
+ if (!mViewType) {
+ mLabelUploader.clear();
+ }
// add foreground textures
for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
@@ -197,11 +257,16 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
if (entry.bitmapTexture != null) {
mTileUploader.addTexture(entry.bitmapTexture);
}
+ if (!mViewType) {
+ if (entry.labelTexture != null) {
+ mLabelUploader.addFgTexture(entry.labelTexture);
+ }
+ }
}
// add background textures
- int range = Math.max(
- (mContentEnd - mActiveEnd), (mActiveStart - mContentStart));
+ int range = Math.max((mContentEnd - mActiveEnd),
+ (mActiveStart - mContentStart));
for (int i = 0; i < range; ++i) {
uploadBgTextureInSlot(mActiveEnd + i);
uploadBgTextureInSlot(mActiveStart - i - 1);
@@ -209,54 +274,108 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
}
// We would like to request non active slots in the following order:
- // Order: 8 6 4 2 1 3 5 7
- // |---------|---------------|---------|
- // |<- active ->|
- // |<-------- cached range ----------->|
+ // Order: 8 6 4 2 1 3 5 7
+ // |---------|---------------|---------|
+ // |<- active ->|
+ // |<-------- cached range ----------->|
private void requestNonactiveImages() {
- int range = Math.max(
- (mContentEnd - mActiveEnd), (mActiveStart - mContentStart));
- for (int i = 0 ;i < range; ++i) {
- requestSlotImage(mActiveEnd + i);
- requestSlotImage(mActiveStart - 1 - i);
+ int range = Math.max((mContentEnd - mActiveEnd),
+ (mActiveStart - mContentStart));
+ for (int i = 0; i < range; ++i) {
+ // requestSlotImage(mActiveEnd + i);
+ // requestSlotImage(mActiveStart - 1 - i);
+ requestImagesInSlot(mActiveEnd + i);
+ requestImagesInSlot(mActiveStart - 1 - i);
+ }
+ isSlotSizeChanged = false;
+ }
+
+ private void requestImagesInSlot(int slotIndex) {
+ if (slotIndex < mContentStart || slotIndex >= mContentEnd)
+ return;
+ AlbumEntry entry = mData[slotIndex % mData.length];
+ if (isSlotSizeChanged && !mViewType) {
+ if ((entry.content != null || entry.item == null)
+ && entry.labelTexture != null) {
+ return;
+
+ } else {
+ if (entry.labelLoader != null)
+ entry.labelLoader.startLoad();
+ }
+ } else {
+ if (entry.content != null || entry.item == null)
+ return;
+ entry.mPanoSupportListener = new PanoSupportListener(entry);
+ entry.item.getPanoramaSupport(entry.mPanoSupportListener);
+ if (entry.contentLoader != null)
+ entry.contentLoader.startLoad();
+ if (!mViewType) {
+
+ if (entry.labelLoader != null)
+ entry.labelLoader.startLoad();
+ }
}
+
}
// return whether the request is in progress or not
private boolean requestSlotImage(int slotIndex) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return false;
+ if (slotIndex < mContentStart || slotIndex >= mContentEnd)
+ return false;
AlbumEntry entry = mData[slotIndex % mData.length];
- if (entry.content != null || entry.item == null) return false;
+ if (entry.content != null || entry.item == null)
+ return false;
// Set up the panorama callback
entry.mPanoSupportListener = new PanoSupportListener(entry);
entry.item.getPanoramaSupport(entry.mPanoSupportListener);
- entry.contentLoader.startLoad();
return entry.contentLoader.isRequestInProgress();
}
+ private static boolean startLoadBitmap(BitmapLoader loader) {
+ if (loader == null)
+ return false;
+ loader.startLoad();
+ return loader.isRequestInProgress();
+ }
+
private void cancelNonactiveImages() {
- int range = Math.max(
- (mContentEnd - mActiveEnd), (mActiveStart - mContentStart));
- for (int i = 0 ;i < range; ++i) {
+ int range = Math.max((mContentEnd - mActiveEnd),
+ (mActiveStart - mContentStart));
+ for (int i = 0; i < range; ++i) {
cancelSlotImage(mActiveEnd + i);
cancelSlotImage(mActiveStart - 1 - i);
}
}
private void cancelSlotImage(int slotIndex) {
- if (slotIndex < mContentStart || slotIndex >= mContentEnd) return;
+ if (slotIndex < mContentStart || slotIndex >= mContentEnd)
+ return;
AlbumEntry item = mData[slotIndex % mData.length];
- if (item.contentLoader != null) item.contentLoader.cancelLoad();
+ if (item.contentLoader != null)
+ item.contentLoader.cancelLoad();
+ if (!mViewType) {
+ if (item.labelLoader != null)
+ item.labelLoader.cancelLoad();
+ }
}
private void freeSlotContent(int slotIndex) {
AlbumEntry data[] = mData;
int index = slotIndex % data.length;
AlbumEntry entry = data[index];
- if (entry.contentLoader != null) entry.contentLoader.recycle();
- if (entry.bitmapTexture != null) entry.bitmapTexture.recycle();
+ if (entry.contentLoader != null)
+ entry.contentLoader.recycle();
+ if (!mViewType) {
+ if (entry.labelLoader != null)
+ entry.labelLoader.recycle();
+ if (entry.labelTexture != null)
+ entry.labelTexture.recycle();
+ }
+ if (entry.bitmapTexture != null)
+ entry.bitmapTexture.recycle();
data[index] = null;
}
@@ -264,28 +383,63 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
AlbumEntry entry = new AlbumEntry();
MediaItem item = mSource.get(slotIndex); // item could be null;
entry.item = item;
- entry.mediaType = (item == null)
- ? MediaItem.MEDIA_TYPE_UNKNOWN
+ entry.name = (item == null) ? null : item.getName();
+ entry.mediaType = (item == null) ? MediaItem.MEDIA_TYPE_UNKNOWN
: entry.item.getMediaType();
entry.path = (item == null) ? null : item.getPath();
entry.rotation = (item == null) ? 0 : item.getRotation();
entry.contentLoader = new ThumbnailLoader(slotIndex, entry.item);
+ if (!mViewType) {
+ if (entry.labelLoader != null) {
+ entry.labelLoader.recycle();
+ entry.labelLoader = null;
+ entry.labelTexture = null;
+ }
+ if (entry.name != null) {
+ entry.labelLoader = new AlbumLabelLoader(slotIndex, entry.name);
+ }
+ }
mData[slotIndex % mData.length] = entry;
}
private void updateAllImageRequests() {
mActiveRequestCount = 0;
for (int i = mActiveStart, n = mActiveEnd; i < n; ++i) {
- if (requestSlotImage(i)) ++mActiveRequestCount;
+ AlbumEntry entry = mData[i % mData.length];
+ if (isSlotSizeChanged) {
+ if ((entry.content != null || entry.item == null)
+ && entry.labelTexture != null) {
+ continue;
+ } else {
+ if (startLoadBitmap(entry.labelLoader))
+ ++mActiveRequestCount;
+ }
+
+ }
+
+ else {
+ if (entry.content != null || entry.item == null)
+ continue;
+ if (startLoadBitmap(entry.contentLoader))
+ ++mActiveRequestCount;
+ if (!mViewType) {
+ if (startLoadBitmap(entry.labelLoader))
+ ++mActiveRequestCount;
+ }
+ }
+
+ // if (requestSlotImage(i)) ++mActiveRequestCount;
}
- if (mActiveRequestCount == 0) {
+
+ if (isSlotSizeChanged || mActiveRequestCount == 0) {
requestNonactiveImages();
} else {
+
cancelNonactiveImages();
}
}
- private class ThumbnailLoader extends BitmapLoader {
+ private class ThumbnailLoader extends BitmapLoader {
private final int mSlotIndex;
private final MediaItem mItem;
@@ -307,7 +461,9 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public void updateEntry() {
Bitmap bitmap = getBitmap();
- if (bitmap == null) return; // error or recycled
+
+ if (bitmap == null)
+ return; // error or recycled
AlbumEntry entry = mData[mSlotIndex % mData.length];
entry.bitmapTexture = new TiledTexture(bitmap);
entry.content = entry.bitmapTexture;
@@ -315,8 +471,10 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
if (isActiveSlot(mSlotIndex)) {
mTileUploader.addTexture(entry.bitmapTexture);
--mActiveRequestCount;
- if (mActiveRequestCount == 0) requestNonactiveImages();
- if (mListener != null) mListener.onContentChanged();
+ if (mActiveRequestCount == 0)
+ requestNonactiveImages();
+ if (mListener != null)
+ mListener.onContentChanged();
} else {
mTileUploader.addTexture(entry.bitmapTexture);
}
@@ -327,9 +485,12 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public void onSizeChanged(int size) {
if (mSize != size) {
mSize = size;
- if (mListener != null) mListener.onSizeChanged(mSize);
- if (mContentEnd > mSize) mContentEnd = mSize;
- if (mActiveEnd > mSize) mActiveEnd = mSize;
+ if (mListener != null)
+ mListener.onSizeChanged(mSize);
+ if (mContentEnd > mSize)
+ mContentEnd = mSize;
+ if (mActiveEnd > mSize)
+ mActiveEnd = mSize;
}
}
@@ -356,10 +517,88 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
public void pause() {
mIsActive = false;
+ if (!mViewType)
+ mLabelUploader.clear();
mTileUploader.clear();
TiledTexture.freeResources();
for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
freeSlotContent(i);
}
}
+
+ private static interface EntryUpdater {
+ public void updateEntry();
+ }
+
+ private class AlbumLabelLoader extends BitmapLoader implements EntryUpdater {
+ private final int mSlotIndex;
+ private final String mTitle;
+
+ public AlbumLabelLoader(int slotIndex, String title) {
+ mSlotIndex = slotIndex;
+ mTitle = title;
+ // mTotalCount = totalCount;
+ // mSourceType = sourceType;
+ }
+
+ @Override
+ protected Future<Bitmap> submitBitmapTask(FutureListener<Bitmap> l) {
+ return mThreadPool.submit(mLabelMaker.requestLabel(mTitle), this);
+ }
+
+ @Override
+ protected void onLoadComplete(Bitmap bitmap) {
+ mHandler.obtainMessage(MSG_UPDATE_ALBUM_ENTRY, this).sendToTarget();
+ }
+
+ @Override
+ public void updateEntry() {
+ Bitmap bitmap = getBitmap();
+ if (bitmap == null)
+ return; // Error or recycled
+
+ AlbumEntry entry = mData[mSlotIndex % mData.length];
+ entry.labelTexture = new BitmapTexture(bitmap);
+ entry.labelTexture.setOpaque(false);
+ // entry.labelTexture = texture;
+
+ if (isActiveSlot(mSlotIndex)) {
+ mLabelUploader.addFgTexture(entry.labelTexture);
+ --mActiveRequestCount;
+ if (mActiveRequestCount == 0)
+ requestNonactiveImages();
+ if (mListener != null)
+ mListener.onContentChanged();
+ } else {
+ mLabelUploader.addBgTexture(entry.labelTexture);
+ }
+ }
+ }
+
+ public void onSlotSizeChanged(int width, int height) {
+ if (mSlotWidth == width)
+ return;
+
+ isSlotSizeChanged = !mViewType ;
+ mSlotWidth = width;
+ mLoadingLabel = null;
+ mLabelMaker.setLabelWidth(mSlotWidth,KEY_ALBUM);
+
+ if (!mIsActive)
+ return;
+
+ for (int i = mContentStart, n = mContentEnd; i < n; ++i) {
+ AlbumEntry entry = mData[i % mData.length];
+ if (entry.labelLoader != null) {
+ entry.labelLoader.recycle();
+ entry.labelLoader = null;
+ entry.labelTexture = null;
+ }
+ if (entry.name != null) {
+ entry.labelLoader = new AlbumLabelLoader(i, entry.name);
+ }
+ }
+ updateAllImageRequests();
+ updateTextureUploadQueue();
+ }
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
index 5c1441ee9..5d4898f10 100644
--- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
@@ -1,4 +1,7 @@
/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +21,7 @@ package com.android.gallery3d.ui;
import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumDataLoader;
+import com.android.gallery3d.app.AlbumPage;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.glrenderer.ColorTexture;
@@ -25,10 +29,24 @@ import com.android.gallery3d.glrenderer.FadeInTexture;
import com.android.gallery3d.glrenderer.GLCanvas;
import com.android.gallery3d.glrenderer.Texture;
import com.android.gallery3d.glrenderer.TiledTexture;
+import com.android.gallery3d.glrenderer.UploadedTexture;
+import com.android.gallery3d.ui.AlbumSlidingWindow.AlbumEntry;
public class AlbumSlotRenderer extends AbstractSlotRenderer {
@SuppressWarnings("unused")
private static final String TAG = "AlbumView";
+ private boolean mIsGridViewShown;
+
+ public static class LabelSpec {
+ public int labelBackgroundHeight;
+ public int titleFontSize;
+ public int leftMargin;
+ public int iconSize;
+ public int titleLeftMargin;
+ public int backgroundColor;
+ public int titleColor;
+ public int borderSize;
+ }
public interface SlotFilter {
public boolean acceptSlot(int index);
@@ -40,7 +58,7 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
private AlbumSlidingWindow mDataWindow;
private final AbstractGalleryActivity mActivity;
private final ColorTexture mWaitLoadingTexture;
- private final SlotView mSlotView;
+ private SlotView mSlotView;
private final SelectionManager mSelectionManager;
private int mPressedIndex = -1;
@@ -49,33 +67,40 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
private boolean mInSelectionMode;
private SlotFilter mSlotFilter;
+ protected final LabelSpec mLabelSpec;
- public AlbumSlotRenderer(AbstractGalleryActivity activity, SlotView slotView,
- SelectionManager selectionManager, int placeholderColor) {
+ public AlbumSlotRenderer(AbstractGalleryActivity activity,
+ SlotView slotView, LabelSpec labelSpec,
+ SelectionManager selectionManager, int placeholderColor,
+ boolean viewType) {
super(activity);
mActivity = activity;
mSlotView = slotView;
mSelectionManager = selectionManager;
mPlaceholderColor = placeholderColor;
-
+ mLabelSpec = labelSpec;
mWaitLoadingTexture = new ColorTexture(mPlaceholderColor);
mWaitLoadingTexture.setSize(1, 1);
+ mIsGridViewShown = viewType;
}
public void setPressedIndex(int index) {
- if (mPressedIndex == index) return;
+ if (mPressedIndex == index)
+ return;
mPressedIndex = index;
mSlotView.invalidate();
}
public void setPressedUp() {
- if (mPressedIndex == -1) return;
+ if (mPressedIndex == -1)
+ return;
mAnimatePressedUp = true;
mSlotView.invalidate();
}
public void setHighlightItemPath(Path path) {
- if (mHighlightItemPath == path) return;
+ if (mHighlightItemPath == path)
+ return;
mHighlightItemPath = path;
mSlotView.invalidate();
}
@@ -87,22 +112,28 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
mDataWindow = null;
}
if (model != null) {
- mDataWindow = new AlbumSlidingWindow(mActivity, model, CACHE_SIZE);
+ mDataWindow = new AlbumSlidingWindow(mActivity, model, CACHE_SIZE,
+ mLabelSpec, mIsGridViewShown);
mDataWindow.setListener(new MyDataModelListener());
mSlotView.setSlotCount(model.size());
+
}
}
private static Texture checkTexture(Texture texture) {
return (texture instanceof TiledTexture)
- && !((TiledTexture) texture).isReady()
- ? null
- : texture;
+ && !((TiledTexture) texture).isReady() ? null : texture;
}
@Override
- public int renderSlot(GLCanvas canvas, int index, int pass, int width, int height) {
- if (mSlotFilter != null && !mSlotFilter.acceptSlot(index)) return 0;
+ public int renderSlot(GLCanvas canvas, int index, int pass, int width,
+ int height) {
+ int thumbSize = 0;
+ if (!mIsGridViewShown) {
+ thumbSize = mLabelSpec.iconSize;
+ }
+ if (mSlotFilter != null && !mSlotFilter.acceptSlot(index))
+ return 0;
AlbumSlidingWindow.AlbumEntry entry = mDataWindow.get(index);
@@ -118,20 +149,25 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
entry.content = content;
}
drawContent(canvas, content, width, height, entry.rotation);
- if ((content instanceof FadeInTexture) &&
- ((FadeInTexture) content).isAnimating()) {
+ if ((content instanceof FadeInTexture)
+ && ((FadeInTexture) content).isAnimating()) {
renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
}
+ if (!mIsGridViewShown)
+ renderRequestFlags |= renderLabel(canvas, entry, width, height);
if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- drawVideoOverlay(canvas, width, height);
- } else if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
+ drawVideoOverlay(canvas, width, height, mIsGridViewShown, thumbSize);
+ }
+
+ if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
|| (entry.mediaType == MediaObject.MEDIA_TYPE_DRM_IMAGE)) {
- drawDrmOverlay(canvas, width, height, entry.mediaType);
+ drawDrmOverlay(canvas, width, height, entry.mediaType,
+ mIsGridViewShown, thumbSize);
}
if (entry.isPanorama) {
- drawPanoramaIcon(canvas, width, height);
+ drawPanoramaIcon(canvas, width, height, mIsGridViewShown, thumbSize);
}
renderRequestFlags |= renderOverlay(canvas, index, entry, width, height);
@@ -139,6 +175,19 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
return renderRequestFlags;
}
+ protected int renderLabel(GLCanvas canvas, AlbumEntry entry, int width,
+ int height) {
+ Texture content = checkLabelTexture(entry.labelTexture);
+ if (content == null) {
+ content = mWaitLoadingTexture;
+ }
+ int b = AlbumLabelMaker.getBorderSize();
+ int h = mLabelSpec.labelBackgroundHeight;
+ content.draw(canvas, -b, height - h + b, width + b + b, h);
+
+ return 0;
+ }
+
private int renderOverlay(GLCanvas canvas, int index,
AlbumSlidingWindow.AlbumEntry entry, int width, int height) {
int renderRequestFlags = 0;
@@ -155,22 +204,30 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
}
} else if ((entry.path != null) && (mHighlightItemPath == entry.path)) {
drawSelectedFrame(canvas, width, height);
- } else if (mInSelectionMode && mSelectionManager.isItemSelected(entry.path)) {
+ } else if (mInSelectionMode
+ && mSelectionManager.isItemSelected(entry.path)) {
drawSelectedFrame(canvas, width, height);
}
return renderRequestFlags;
}
+ private static Texture checkLabelTexture(Texture texture) {
+ return ((texture instanceof UploadedTexture) && ((UploadedTexture) texture)
+ .isUploading()) ? null : texture;
+ }
+
private class MyDataModelListener implements AlbumSlidingWindow.Listener {
@Override
public void onContentChanged() {
mSlotView.invalidate();
+
}
@Override
public void onSizeChanged(int size) {
mSlotView.setSlotCount(size);
mSlotView.invalidate();
+
}
}
@@ -196,7 +253,9 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
@Override
public void onSlotSizeChanged(int width, int height) {
- // Do nothing
+ if (!mIsGridViewShown && mDataWindow != null) {
+ mDataWindow.onSlotSizeChanged(width, height);
+ }
}
public void setSlotFilter(SlotFilter slotFilter) {
diff --git a/src/com/android/gallery3d/ui/DialogDetailsView.java b/src/com/android/gallery3d/ui/DialogDetailsView.java
index 26934105b..84d224fc4 100644
--- a/src/com/android/gallery3d/ui/DialogDetailsView.java
+++ b/src/com/android/gallery3d/ui/DialogDetailsView.java
@@ -21,8 +21,10 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
+import android.content.res.Resources;
import android.text.TextUtils;
import android.text.format.Formatter;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -54,7 +56,7 @@ public class DialogDetailsView implements DetailsViewContainer {
private MediaDetails mDetails;
private final DetailsSource mSource;
private int mIndex;
- private Dialog mDialog;
+ private AlertDialog mDialog;
private CloseListener mListener;
public DialogDetailsView(AbstractGalleryActivity activity, DetailsSource source) {
@@ -94,17 +96,19 @@ public class DialogDetailsView implements DetailsViewContainer {
ListView detailsList = (ListView) LayoutInflater.from(mActivity.getAndroidContext()).inflate(
R.layout.details_list, null, false);
detailsList.setAdapter(mAdapter);
- mDialog = new AlertDialog.Builder(mActivity)
- .setView(detailsList)
- .setTitle(title)
- .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int whichButton) {
- mDialog.dismiss();
- }
- })
- .create();
+ AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
+
+ builder.setView(detailsList);
+ builder.setTitle(title);
+ builder.setPositiveButton(R.string.close,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ mDialog.dismiss();
+ }
+ });
+ mDialog = builder.create();
mDialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
@@ -113,6 +117,24 @@ public class DialogDetailsView implements DetailsViewContainer {
}
}
});
+ mDialog.show();
+ Resources r = mActivity.getResources();
+
+ int buttonColor = r.getColor(R.color.dialog_button_color);
+ mDialog.getButton(DialogInterface.BUTTON_POSITIVE)
+ .setTextSize(TypedValue.COMPLEX_UNIT_SP,14);
+ mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(
+ buttonColor);
+
+ builder.setView(detailsList);
+ builder.setTitle(title);
+ builder.setPositiveButton(R.string.close,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ mDialog.dismiss();
+ }
+ });
}
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 2e8b90644..c4636cb38 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -183,9 +183,9 @@ public class MenuExecutor {
supportPrint &= PrintHelper.systemSupportsPrint();
boolean supportDrmInfo = (supported & MediaObject.SUPPORT_DRM_INFO) != 0;
setMenuItemVisible(menu, R.id.action_delete, supportDelete);
- setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate);
- setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate);
- setMenuItemVisible(menu, R.id.action_crop, supportCrop);
+ //setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate);
+ //setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate);
+ //setMenuItemVisible(menu, R.id.action_crop, supportCrop);
setMenuItemVisible(menu, R.id.action_trim, supportTrim);
setMenuItemVisible(menu, R.id.action_mute, supportMute);
// Hide panorama until call to updateMenuForPanorama corrects it
@@ -204,8 +204,8 @@ public class MenuExecutor {
boolean disablePanorama360Options) {
setMenuItemVisible(menu, R.id.action_share_panorama, shareAsPanorama360);
if (disablePanorama360Options) {
- setMenuItemVisible(menu, R.id.action_rotate_ccw, false);
- setMenuItemVisible(menu, R.id.action_rotate_cw, false);
+ //setMenuItemVisible(menu, R.id.action_rotate_ccw, false);
+ //setMenuItemVisible(menu, R.id.action_rotate_cw, false);
}
}
@@ -242,11 +242,11 @@ public class MenuExecutor {
mSelectionManager.selectAll();
}
return;
- case R.id.action_crop: {
+ /*case R.id.action_crop: {
Intent intent = getIntentBySingleSelectedPath(CropActivity.CROP_ACTION);
((Activity) mActivity).startActivity(intent);
return;
- }
+ }*/
case R.id.action_edit: {
Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_EDIT)
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -273,12 +273,15 @@ public class MenuExecutor {
case R.id.action_delete:
title = R.string.delete;
break;
- case R.id.action_rotate_cw:
+ case R.id.photopage_bottom_control_delete:
+ title = R.string.delete;
+ break;
+ /*case R.id.action_rotate_cw:
title = R.string.rotate_right;
break;
case R.id.action_rotate_ccw:
title = R.string.rotate_left;
- break;
+ break;*/
case R.id.action_show_on_map:
title = R.string.show_on_map;
break;
@@ -335,7 +338,14 @@ public class MenuExecutor {
public void onMenuClicked(MenuItem menuItem, String confirmMsg,
final ProgressListener listener) {
- final int action = menuItem.getItemId();
+ final int action;
+ if (menuItem == null) {
+ action = R.id.photopage_bottom_control_delete;
+ }
+ else
+ {
+ action = menuItem.getItemId();
+ }
if (confirmMsg != null) {
if (listener != null) listener.onConfirmDialogShown();
@@ -401,12 +411,15 @@ public class MenuExecutor {
case R.id.action_delete:
manager.delete(path);
break;
- case R.id.action_rotate_cw:
+ case R.id.photopage_bottom_control_delete:
+ manager.delete(path);
+ break;
+ /*case R.id.action_rotate_cw:
manager.rotate(path, 90);
break;
case R.id.action_rotate_ccw:
manager.rotate(path, -90);
- break;
+ break;*/
case R.id.action_toggle_full_caching: {
MediaObject obj = manager.getMediaObject(path);
int cacheFlag = obj.getCacheFlag();
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index cb14e490d..3cb24e4a1 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -307,7 +307,7 @@ public class PhotoView extends GLView {
mEdgeView.onAbsorb(velocity, direction);
}
});
- mVideoPlayIcon = new ResourceTexture(mContext, R.drawable.ic_control_play);
+ mVideoPlayIcon = new ResourceTexture(mContext, R.drawable.play_detail);
mDrmIcon = new ResourceTexture(mContext, R.drawable.drm_image);
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; i++) {
if (i == 0) {
diff --git a/src/com/android/gallery3d/ui/PopupList.java b/src/com/android/gallery3d/ui/PopupList.java
index 248f50b25..a03e27ca2 100644
--- a/src/com/android/gallery3d/ui/PopupList.java
+++ b/src/com/android/gallery3d/ui/PopupList.java
@@ -17,7 +17,9 @@
package com.android.gallery3d.ui;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.Rect;
+import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
@@ -154,9 +156,10 @@ public class PopupList {
private PopupWindow createPopupWindow() {
PopupWindow popup = new PopupWindow(mContext);
popup.setOnDismissListener(mOnDismissListener);
+ popup.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ffffff")));
- popup.setBackgroundDrawable(mContext.getResources().getDrawable(
- R.drawable.menu_dropdown_panel_holo_dark));
+// popup.setBackgroundDrawable(mContext.getResources().getDrawable(
+// R.drawable.menu_dropdown_panel_holo_dark));
mContentList = new ListView(mContext, null,
android.R.attr.dropDownListViewStyle);
diff --git a/src/com/android/gallery3d/ui/SelectionManager.java b/src/com/android/gallery3d/ui/SelectionManager.java
index 0164a7a75..d7cd16229 100644
--- a/src/com/android/gallery3d/ui/SelectionManager.java
+++ b/src/com/android/gallery3d/ui/SelectionManager.java
@@ -147,6 +147,20 @@ public class SelectionManager {
}
}
+ public void toggleTimeLineSet(ArrayList<Path> paths) {
+ if (mClickedSet.containsAll(paths))
+ mClickedSet.removeAll(paths);
+ else {
+ enterSelectionMode();
+ mClickedSet.addAll(paths);
+ }
+ int count = getSelectedCount();
+ if (count == (mSourceMediaSet.getMediaItemCount() - mSourceMediaSet.getSubMediaSetCount()))
+ selectAll();
+ if (mListener != null) mListener.onSelectionChange(paths.get(0), isItemSelected(paths.get(0)));
+ if (count == 0 && mAutoLeave)
+ leaveSelectionMode();
+ }
private static boolean expandMediaSet(ArrayList<Path> items, MediaSet set, int maxSelection) {
int subCount = set.getSubMediaSetCount();
for (int i = 0; i < subCount; i++) {
diff --git a/src/com/android/gallery3d/ui/SlotView.java b/src/com/android/gallery3d/ui/SlotView.java
index eaf23f553..b5fa2bf6c 100644
--- a/src/com/android/gallery3d/ui/SlotView.java
+++ b/src/com/android/gallery3d/ui/SlotView.java
@@ -16,6 +16,7 @@
package com.android.gallery3d.ui;
+import android.app.Activity;
import android.graphics.Rect;
import android.os.Handler;
import android.text.TextUtils;
@@ -24,6 +25,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.DecelerateInterpolator;
+import com.android.gallery3d.R;
import com.android.gallery3d.anim.Animation;
import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.common.Utils;
@@ -35,7 +37,7 @@ public class SlotView extends GLView {
@SuppressWarnings("unused")
private static final String TAG = "SlotView";
- private static final boolean WIDE = true;
+ private static final boolean WIDE = false;
private static final int INDEX_NONE = -1;
public static final int RENDER_MORE_PASS = 1;
@@ -94,11 +96,13 @@ public class SlotView extends GLView {
// Flag to check whether it is come from Photo Page.
private boolean isFromPhotoPage = false;
+ private Activity mActivity;
public SlotView(AbstractGalleryActivity activity, Spec spec) {
mGestureDetector = new GestureDetector(activity, new MyGestureListener());
mScroller = new ScrollerHelper(activity);
mHandler = new SynchronizedHandler(activity.getGLRoot());
+ mActivity = activity;
setSlotSpec(spec);
}
@@ -410,6 +414,9 @@ public class SlotView extends GLView {
public int rowsLand = -1;
public int rowsPort = -1;
public int slotGap = -1;
+ public int slotGapLand = -1;
+ public int colsLand = -1;
+ public int colsPort = -1;
}
public class Layout {
@@ -508,7 +515,7 @@ public class SlotView extends GLView {
int availableUnits = Math.min(mUnitCount, mSlotCount);
int usedMinorLength = availableUnits * minorUnitSize +
(availableUnits - 1) * mSlotGap;
- padding[0] = (minorLength - usedMinorLength) / 2;
+ padding[0] = 0;//mActivity.getResources().getDimensionPixelSize(R.dimen.toolbar_height);
// Then calculate how many columns we need for all slots.
int count = ((mSlotCount + mUnitCount - 1) / mUnitCount);
@@ -516,20 +523,20 @@ public class SlotView extends GLView {
// If the content length is less then the screen width, put
// extra padding in left and right.
- padding[1] = Math.max(0, (majorLength - mContentLength) / 2);
+ padding[1] = 0 ;//Math.max(0, (majorLength - mContentLength) / 2);
}
private void initLayoutParameters() {
// Initialize mSlotWidth and mSlotHeight from mSpec
if (mSpec.slotWidth != -1) {
- mSlotGap = 0;
- mSlotWidth = mSpec.slotWidth;
- mSlotHeight = mSpec.slotHeight;
+ mSlotGap = (mWidth > mHeight) ? mSpec.slotGapLand : mSpec.slotGap;
+ int cols = (mWidth > mHeight) ? mSpec.colsLand : mSpec.colsPort;
+ mSlotHeight = Math.max(1, (mWidth - (cols - 1) * mSlotGap) / cols) ;
+ mSlotWidth = mSlotHeight ;//mSpec.slotWidth;
} else {
- int rows = (mWidth > mHeight) ? mSpec.rowsLand : mSpec.rowsPort;
- mSlotGap = mSpec.slotGap;
- mSlotHeight = Math.max(1, (mHeight - (rows - 1) * mSlotGap) / rows);
- mSlotWidth = mSlotHeight - mSpec.slotHeightAdditional;
+ mSlotGap = (mWidth > mHeight) ? mSpec.slotGapLand : mSpec.slotGap;;
+ mSlotHeight = mSpec.slotHeight;//Math.max(1, (mHeight - (rows - 1) * mSlotGap) / rows);
+ mSlotWidth = mWidth;//mSlotHeight - mSpec.slotHeightAdditional;
}
if (mRenderer != null) {
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index 8e4ebb714..d7fb3332a 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -23,6 +23,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -44,6 +45,7 @@ import com.android.gallery3d.app.PackagesMonitor;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
+import com.android.gallery3d.ui.SharedPreferencesCompat;
import com.android.gallery3d.ui.TiledScreenNail;
import com.android.gallery3d.util.IntentHelper;
import com.android.gallery3d.util.ThreadPool.CancelListener;
@@ -421,4 +423,18 @@ public class GalleryUtils {
int h = item.getHeight();
return (h > 0 && w / h >= 2);
}
+ // Newly added methods
+ public static int getIntPref(Context context, String name, int def) {
+ SharedPreferences prefs =
+ context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
+ return prefs.getInt(name, def);
+ }
+
+ public static void setIntPref(Context context, String name, int value) {
+ SharedPreferences prefs =
+ context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
+ Editor ed = prefs.edit();
+ ed.putInt(name, value);
+ ed.commit();
+ }
}