diff options
| author | John Hoford <hoford@google.com> | 2013-08-14 09:16:15 -0700 |
|---|---|---|
| committer | John Hoford <hoford@google.com> | 2013-08-14 10:15:08 -0700 |
| commit | 0b33ef03f2023a49d82cd608d79bb9b59c791e06 (patch) | |
| tree | 9da2594586b09a18471e5f4f514446faae58701f | |
| parent | 2e1bc2e37f285bfaf302a0533a372d4373474d9c (diff) | |
| download | android_packages_apps_Gallery2-0b33ef03f2023a49d82cd608d79bb9b59c791e06.tar.gz android_packages_apps_Gallery2-0b33ef03f2023a49d82cd608d79bb9b59c791e06.tar.bz2 android_packages_apps_Gallery2-0b33ef03f2023a49d82cd608d79bb9b59c791e06.zip | |
fix tablet ui
Change-Id: I38aba41e92fdd555391b8ae3ebd65b473bd48366
3 files changed, 236 insertions, 3 deletions
diff --git a/res/layout-land/filtershow_grad_ui.xml b/res/layout-land/filtershow_grad_ui.xml new file mode 100644 index 000000000..63f941801 --- /dev/null +++ b/res/layout-land/filtershow_grad_ui.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/top" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:visibility="visible" > + + <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnCount="2" + android:orientation="horizontal" > + + <TextView + android:id="@+id/controlName1" + android:layout_gravity="left" + android:layout_marginLeft="8dip" + android:text="@string/editor_grad_brightness" /> + + <TextView + android:id="@+id/gradBrightnessValue" + android:layout_gravity="right" + android:layout_marginRight="8dip" + android:textStyle="bold" /> + + <SeekBar + android:id="@+id/gradBrightnessSeekBar" + android:layout_width="match_parent" + android:layout_column="0" + android:layout_columnSpan="2" + android:layout_gravity="fill_horizontal" + style="@style/FilterShowSlider" /> + </GridLayout> + + + <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnCount="2" + android:orientation="horizontal" > + + <TextView + android:id="@+id/controlName2" + android:layout_gravity="left" + android:layout_marginLeft="8dip" + android:text="@string/editor_grad_saturation"/> + + <TextView + android:id="@+id/gradSaturationValue" + android:layout_gravity="right" + android:layout_marginRight="8dip" + android:textStyle="bold" /> + + <SeekBar + android:id="@+id/gradSaturationSeekBar" + android:layout_width="match_parent" + android:layout_column="0" + android:layout_columnSpan="2" + android:layout_gravity="fill_horizontal" + style="@style/FilterShowSlider" /> + </GridLayout> + <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnCount="2" + android:orientation="horizontal" > + + <TextView + android:id="@+id/controlName3" + android:layout_gravity="left" + android:layout_marginLeft="8dip" + android:text="@string/editor_grad_contrast"/> + + <TextView + android:id="@+id/gradContrastValue" + android:layout_gravity="right" + android:layout_marginRight="8dip" + android:textStyle="bold" /> + + <SeekBar + android:id="@+id/gradContrastSeekBar" + android:layout_width="match_parent" + android:layout_column="0" + android:layout_columnSpan="2" + android:layout_gravity="fill_horizontal" + style="@style/FilterShowSlider" /> + </GridLayout> + <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnCount="2" + android:orientation="horizontal" + android:layout_marginTop="24dp" > + + <ImageButton + android:id="@+id/gradAddButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left|center_vertical" + android:scaleType="centerInside" + android:layout_weight="0" + android:background="@drawable/filtershow_button_background" + android:src="@drawable/filtershow_addpoint" + android:paddingBottom="8dp" + android:layout_marginLeft="48dp" /> + + <ImageButton + android:id="@+id/gradDelButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right|center_vertical" + android:scaleType="centerInside" + android:layout_weight="0" + android:background="@drawable/filtershow_button_background" + android:src="@drawable/ic_menu_trash_holo_light" + android:paddingBottom="8dp" + android:layout_marginRight="48dp" /> + </GridLayout> +</LinearLayout> 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; } |
