Editor.java revision 33de212ec780eaf2bc8d86908f07da33ea8dd7f2
15aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford/* 25aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * Copyright (C) 2012 The Android Open Source Project 35aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * 45aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * Licensed under the Apache License, Version 2.0 (the "License"); 55aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * you may not use this file except in compliance with the License. 65aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * You may obtain a copy of the License at 75aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * 85aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * http://www.apache.org/licenses/LICENSE-2.0 95aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * 105aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * Unless required by applicable law or agreed to in writing, software 115aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * distributed under the License is distributed on an "AS IS" BASIS, 125aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * See the License for the specific language governing permissions and 145aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * limitations under the License. 155aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford */ 165aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 175aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordpackage com.android.gallery3d.filtershow.editors; 185aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 195aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport android.content.Context; 20235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.util.AttributeSet; 212ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroardimport android.util.Log; 225aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport android.view.LayoutInflater; 236a07dfbe03c8396cc43840a1630ea480a2cff663John Hofordimport android.view.Menu; 242ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroardimport android.view.MenuItem; 255aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport android.view.View; 265aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport android.view.ViewGroup; 27235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.widget.Button; 28235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.widget.FrameLayout; 29235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.widget.LinearLayout; 30235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.widget.PopupMenu; 31235d2179374bec14040f20af91dc753e38ea3639John Hofordimport android.widget.SeekBar; 326a07dfbe03c8396cc43840a1630ea480a2cff663John Hofordimport android.widget.SeekBar.OnSeekBarChangeListener; 335aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 346a07dfbe03c8396cc43840a1630ea480a2cff663John Hofordimport com.android.gallery3d.R; 355aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport com.android.gallery3d.filtershow.cache.ImageLoader; 36235d2179374bec14040f20af91dc753e38ea3639John Hofordimport com.android.gallery3d.filtershow.controller.Control; 37cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroardimport com.android.gallery3d.filtershow.filters.FilterRepresentation; 385aa08941bda0cfbcfba522c53937dd66867f890dJohn Hofordimport com.android.gallery3d.filtershow.imageshow.ImageShow; 39cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroardimport com.android.gallery3d.filtershow.imageshow.MasterImage; 40cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroardimport com.android.gallery3d.filtershow.presets.ImagePreset; 415aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 425aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford/** 435aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * Base class for Editors Must contain a mImageShow and a top level view 445aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford */ 452ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroardpublic class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonListener { 465aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected Context mContext; 475aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected View mView; 485aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected ImageShow mImageShow; 495aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected FrameLayout mFrameLayout; 506a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford protected SeekBar mSeekBar; 51235d2179374bec14040f20af91dc753e38ea3639John Hoford Button mEditTitle; 52f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard protected Button mFilterTitle; 535aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected int mID; 545aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford private final String LOGTAG = "Editor"; 55cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard protected FilterRepresentation mLocalRepresentation = null; 566a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford protected byte mShowParameter = SHOW_VALUE_UNDEFINED; 57f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard private Button mButton; 586a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public static byte SHOW_VALUE_UNDEFINED = -1; 596a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public static byte SHOW_VALUE_OFF = 0; 606a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public static byte SHOW_VALUE_INT = 1; 615aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 626a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public String calculateUserMessage(Context context, String effectName, Object parameterValue) { 6333de212ec780eaf2bc8d86908f07da33ea8dd7f2John Hoford return effectName.toUpperCase() + " " + parameterValue; 646a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 656a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 665aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected Editor(int id) { 675aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mID = id; 685aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 696a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 705aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public int getID() { 715aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return mID; 725aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 735aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 746a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public byte showParameterValue() { 756a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford return mShowParameter; 766a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 776a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 7891be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard public boolean showsSeekBar() { 7991be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard return true; 8091be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard } 8191be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard 82f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard public void setUpEditorUI(View actionButton, View editControl, 83f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard Button editTitle, Button stateButton) { 84f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mEditTitle = editTitle; 85f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mFilterTitle = stateButton; 86f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mButton = editTitle; 87235d2179374bec14040f20af91dc753e38ea3639John Hoford setMenuIcon(true); 88235d2179374bec14040f20af91dc753e38ea3639John Hoford setUtilityPanelUI(actionButton, editControl); 89235d2179374bec14040f20af91dc753e38ea3639John Hoford } 90235d2179374bec14040f20af91dc753e38ea3639John Hoford 91be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard public boolean showsPopupIndicator() { 92be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard return true; 93be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard } 94be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard 956a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford /** 966a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford * @param actionButton the would be the area for menu etc 976a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford * @param editControl this is the black area for sliders etc 986a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford */ 996a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public void setUtilityPanelUI(View actionButton, View editControl) { 100235d2179374bec14040f20af91dc753e38ea3639John Hoford 101235d2179374bec14040f20af91dc753e38ea3639John Hoford AttributeSet aset; 102235d2179374bec14040f20af91dc753e38ea3639John Hoford Context context = editControl.getContext(); 103235d2179374bec14040f20af91dc753e38ea3639John Hoford LayoutInflater inflater = 104235d2179374bec14040f20af91dc753e38ea3639John Hoford (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 105235d2179374bec14040f20af91dc753e38ea3639John Hoford LinearLayout lp = (LinearLayout) inflater.inflate( 106235d2179374bec14040f20af91dc753e38ea3639John Hoford R.layout.filtershow_seekbar, (ViewGroup) editControl, true); 107235d2179374bec14040f20af91dc753e38ea3639John Hoford mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar); 108235d2179374bec14040f20af91dc753e38ea3639John Hoford mSeekBar.setOnSeekBarChangeListener(this); 109235d2179374bec14040f20af91dc753e38ea3639John Hoford 11091be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard if (showsSeekBar()) { 11191be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard mSeekBar.setOnSeekBarChangeListener(this); 11291be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard mSeekBar.setVisibility(View.VISIBLE); 11391be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard } else { 11491be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard mSeekBar.setVisibility(View.INVISIBLE); 11591be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard } 116235d2179374bec14040f20af91dc753e38ea3639John Hoford 117f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard if (mButton != null) { 118be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard if (showsPopupIndicator()) { 119f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 120235d2179374bec14040f20af91dc753e38ea3639John Hoford R.drawable.filtershow_menu_marker, 0); 121be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard } else { 122f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0); 123be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard } 124be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard } 1256a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 1266a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 1276a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford @Override 1286a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) { 1296a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 1306a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 1316a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 1326a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public void setPanel() { 1336a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 1346a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 1356a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 1365aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public void createEditor(Context context,FrameLayout frameLayout) { 1375aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mContext = context; 1385aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mFrameLayout = frameLayout; 139cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard mLocalRepresentation = null; 1405aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1415aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1425aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford protected void unpack(int viewid, int layoutid) { 1435aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1445aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (mView == null) { 1455aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mView = mFrameLayout.findViewById(viewid); 1465aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (mView == null) { 1475aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford LayoutInflater inflater = (LayoutInflater) mContext.getSystemService 1485aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford (Context.LAYOUT_INFLATER_SERVICE); 1495aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mView = inflater.inflate(layoutid, mFrameLayout, false); 1505aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mFrameLayout.addView(mView, mView.getLayoutParams()); 1515aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1525aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1535aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mImageShow = findImageShow(mView); 1545aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1555aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1565aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford private ImageShow findImageShow(View view) { 1575aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (view instanceof ImageShow) { 1585aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return (ImageShow) view; 1595aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1605aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (!(view instanceof ViewGroup)) { 1615aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return null; 1625aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1635aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford ViewGroup vg = (ViewGroup) view; 1645aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford int n = vg.getChildCount(); 1655aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford for (int i = 0; i < n; i++) { 1665aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford View v = vg.getChildAt(i); 1675aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (v instanceof ImageShow) { 1685aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return (ImageShow) v; 1695aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } else if (v instanceof ViewGroup) { 1705aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return findImageShow(v); 1715aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1725aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1735aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return null; 1745aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1755aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1765aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public View getTopLevelView() { 1775aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return mView; 1785aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1795aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1805aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public ImageShow getImageShow() { 1815aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford return mImageShow; 1825aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1835aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1845aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public void setImageLoader(ImageLoader imageLoader) { 1855aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mImageShow.setImageLoader(imageLoader); 1865aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1875aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 1885aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public void setVisibility(int visible) { 1895aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mView.setVisibility(visible); 1905aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 1915aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 192cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard public FilterRepresentation getLocalRepresentation() { 193cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard if (mLocalRepresentation == null) { 194cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard ImagePreset preset = MasterImage.getImage().getPreset(); 195cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation(); 196cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard mLocalRepresentation = preset.getFilterRepresentationCopyFrom(filterRepresentation); 1976a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford if (mShowParameter == SHOW_VALUE_UNDEFINED) { 1986a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford boolean show = filterRepresentation.showParameterValue(); 1996a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford mShowParameter = show ? SHOW_VALUE_INT : SHOW_VALUE_OFF; 2006a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 2016a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 202f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard } 203cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard return mLocalRepresentation; 204cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard } 205cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard 206cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard public void commitLocalRepresentation() { 207cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard ImagePreset preset = MasterImage.getImage().getPreset(); 208cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard preset.updateFilterRepresentation(getLocalRepresentation()); 209f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard if (mButton != null) { 210f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard updateText(); 211f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard } 212f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard } 213f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard 214f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard protected void updateText() { 215f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard String s = ""; 216f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard if (mLocalRepresentation != null) { 217f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard s = mContext.getString(mLocalRepresentation.getTextId()); 2187112720bc6100049d24845cfbf3de69cdbd4fdebJohn Hoford } 219f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mButton.setText(calculateUserMessage(mContext, s, "")); 220cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard } 221cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard 2225aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford /** 2235aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford * called after the filter is set and the select is called 2245aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford */ 2255aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public void reflectCurrentFilter() { 226cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard mLocalRepresentation = null; 227f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard FilterRepresentation representation = getLocalRepresentation(); 228f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard if (representation != null && mFilterTitle != null && representation.getTextId() != 0) { 229f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard String text = mContext.getString(representation.getTextId()).toUpperCase(); 230f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mFilterTitle.setText(text); 231f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard updateText(); 232f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard } 2335aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 2345aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 2355aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public boolean useUtilityPanel() { 236001283a72d451999e3308f45dc365d4defc0af39John Hoford return true; 2375aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 2385aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 2395aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford public void openUtilityPanel(LinearLayout mAccessoryViewList) { 240235d2179374bec14040f20af91dc753e38ea3639John Hoford setMenuIcon(false); 2415aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford if (mImageShow != null) { 2425aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford mImageShow.openUtilityPanel(mAccessoryViewList); 2435aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 2445aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford } 2455aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford 246235d2179374bec14040f20af91dc753e38ea3639John Hoford protected void setMenuIcon(boolean on) { 247235d2179374bec14040f20af91dc753e38ea3639John Hoford mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds( 248235d2179374bec14040f20af91dc753e38ea3639John Hoford 0, 0, on ? R.drawable.filtershow_menu_marker : 0, 0); 249235d2179374bec14040f20af91dc753e38ea3639John Hoford } 250f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard 2516a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford protected void createMenu(int[] strId, View button) { 2526a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford PopupMenu pmenu = new PopupMenu(mContext, button); 2536a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford Menu menu = pmenu.getMenu(); 2546a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford for (int i = 0; i < strId.length; i++) { 2556a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford menu.add(Menu.NONE, Menu.FIRST + i, 0, mContext.getString(strId[i])); 2566a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 257235d2179374bec14040f20af91dc753e38ea3639John Hoford setMenuIcon(true); 258235d2179374bec14040f20af91dc753e38ea3639John Hoford 2596a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 2606a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 261235d2179374bec14040f20af91dc753e38ea3639John Hoford public Control[] getControls() { 262235d2179374bec14040f20af91dc753e38ea3639John Hoford return null; 263235d2179374bec14040f20af91dc753e38ea3639John Hoford } 2646a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford @Override 2656a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public void onStartTrackingTouch(SeekBar arg0) { 2666a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 2676a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 2686a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 2696a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford @Override 2706a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford public void onStopTrackingTouch(SeekBar arg0) { 2716a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 2726a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford } 2736a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford 2742ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard @Override 2752ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard public void swapLeft(MenuItem item) { 2762ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard 2772ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard } 2782ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard 2792ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard @Override 2802ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard public void swapRight(MenuItem item) { 2812ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard 2822ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard } 2837668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard 2847668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard public void detach() { 285f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard if (mImageShow != null) { 286f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard mImageShow.unselect(); 287f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard } 2887668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard } 2895aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford} 290