summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-08-14 17:17:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-14 17:17:25 +0000
commit99c1eeb3929c4faa15e3347a83ce9c4ae6551f0b (patch)
tree574d546dcb67f27be1e0f128ddf604ec279a2d5a /src
parenta27067c7ec4e08805f7cc1936ae7f5783724dfad (diff)
parent0b33ef03f2023a49d82cd608d79bb9b59c791e06 (diff)
downloadandroid_packages_apps_Gallery2-99c1eeb3929c4faa15e3347a83ce9c4ae6551f0b.tar.gz
android_packages_apps_Gallery2-99c1eeb3929c4faa15e3347a83ce9c4ae6551f0b.tar.bz2
android_packages_apps_Gallery2-99c1eeb3929c4faa15e3347a83ce9c4ae6551f0b.zip
Merge "fix tablet ui" into gb-ub-photos-carlsbad
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorGrad.java101
-rw-r--r--src/com/android/gallery3d/filtershow/editors/ParametricEditor.java2
2 files changed, 100 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorGrad.java b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
index f427ccbd8..d855851d6 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorGrad.java
@@ -16,15 +16,18 @@
package com.android.gallery3d.filtershow.editors;
import android.content.Context;
+import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
import android.widget.ToggleButton;
import com.android.gallery3d.R;
@@ -51,7 +54,7 @@ public class EditorGrad extends ParametricEditor
private static final int DEL_ICON = R.drawable.ic_grad_del;
private int mSliderMode = MODE_BRIGHTNESS;
ImageGrad mImageGrad;
-
+ ParamAdapter []mAdapters = new ParamAdapter[3];
public EditorGrad() {
super(ID, R.layout.filtershow_grad_editor, R.id.gradEditor);
}
@@ -85,7 +88,11 @@ public class EditorGrad extends ParametricEditor
}
public void updateSeekBar(FilterGradRepresentation rep) {
- mControl.updateUI();
+ if (ParametricEditor.useCompact(mContext)) {
+ mControl.updateUI();
+ } else {
+ updateParameters();
+ }
}
@Override
@@ -127,6 +134,96 @@ public class EditorGrad extends ParametricEditor
}
}
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ if (ParametricEditor.useCompact(mContext)) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ return;
+ }
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.GONE);
+ }
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LinearLayout lp = (LinearLayout) inflater.inflate(
+ R.layout.filtershow_grad_ui, (ViewGroup) editControl, true);
+
+ mAdapters[0] = new ParamAdapter(R.id.gradContrastSeekBar, R.id.gradContrastValue,
+ lp, MODE_CONTRAST);
+ mAdapters[1] = new ParamAdapter(R.id.gradBrightnessSeekBar, R.id.gradBrightnessValue,
+ lp, MODE_BRIGHTNESS);
+ mAdapters[2] = new ParamAdapter(R.id.gradSaturationSeekBar, R.id.gradSaturationValue,
+ lp, MODE_SATURATION);
+ lp.findViewById(R.id.gradAddButton).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ fireLeftAction();
+ }
+ });
+ lp.findViewById(R.id.gradDelButton).setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ fireRightAction();
+ }
+ });
+ }
+
+ public void updateParameters() {
+ FilterGradRepresentation rep = getGradRepresentation();
+ for (int i = 0; i < mAdapters.length; i++) {
+ mAdapters[i].updateValues(rep);
+ }
+ }
+
+ private class ParamAdapter implements OnSeekBarChangeListener {
+ SeekBar mSlider;
+ TextView mTextView;
+ int mMin = -100;
+ int mMax = 100;
+ int mMode;
+
+ public ParamAdapter(int seekId, int textId, LinearLayout layout, int mode) {
+ mSlider = (SeekBar) layout.findViewById(seekId);
+ mTextView = (TextView) layout.findViewById(textId);
+ mSlider.setOnSeekBarChangeListener(this);
+ mSlider.setMax(mMax - mMin);
+ mMode = mode;
+ FilterGradRepresentation rep = getGradRepresentation();
+ if (rep != null){
+ updateValues(rep);
+ }
+ }
+
+ public void updateValues(FilterGradRepresentation rep) {
+ int value = rep.getParameter(mMode);
+ mTextView.setText(Integer.toString(value));
+ mSlider.setProgress(value - mMin);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ FilterGradRepresentation rep = getGradRepresentation();
+ int value = progress + mMin;
+ rep.setParameter(mMode, value);
+ mSliderMode = mMode;
+ mEffectName = "";
+ mTextView.setText(Integer.toString(value));
+ mView.invalidate();
+ commitLocalRepresentation();
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+
+ }
+ }
+
private void showPopupMenu(LinearLayout accessoryViewList) {
Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
if (button == null) {
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
index d80b1473c..f7a8d7ec3 100644
--- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -145,7 +145,7 @@ public class ParametricEditor extends Editor {
};
}
- static boolean useCompact(Context context) {
+ protected static boolean useCompact(Context context) {
return context.getResources().getConfiguration().orientation
== Configuration.ORIENTATION_PORTRAIT;
}