Editor.java revision 5d24515190c1664f944b7950d1a75b0df0de2ff8
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
627638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck    public static void hackFixStrings(Menu menu) {
637638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck        int count = menu.size();
647638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck        for (int i = 0; i < count; i++) {
657638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck            MenuItem item = menu.getItem(i);
667638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck            item.setTitle(item.getTitle().toString().toUpperCase());
677638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck        }
687638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck    }
697638772c0ceb5528b12c9943bad5391658d6c78dJohn Reck
706a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
7133de212ec780eaf2bc8d86908f07da33ea8dd7f2John Hoford        return effectName.toUpperCase() + " " + parameterValue;
726a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
736a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
745aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    protected Editor(int id) {
755aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mID = id;
765aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
776a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
785aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public int getID() {
795aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        return mID;
805aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
815aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
826a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public byte showParameterValue() {
836a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford        return mShowParameter;
846a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
856a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
8691be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard    public boolean showsSeekBar() {
8791be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard        return true;
8891be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard    }
8991be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard
90f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard    public void setUpEditorUI(View actionButton, View editControl,
91f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard                              Button editTitle, Button stateButton) {
92f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        mEditTitle = editTitle;
93f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        mFilterTitle = stateButton;
94f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        mButton = editTitle;
95235d2179374bec14040f20af91dc753e38ea3639John Hoford        setMenuIcon(true);
96235d2179374bec14040f20af91dc753e38ea3639John Hoford        setUtilityPanelUI(actionButton, editControl);
97235d2179374bec14040f20af91dc753e38ea3639John Hoford    }
98235d2179374bec14040f20af91dc753e38ea3639John Hoford
99be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard    public boolean showsPopupIndicator() {
100be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard        return true;
101be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard    }
102be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard
1036a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    /**
1046a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford     * @param actionButton the would be the area for menu etc
1056a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford     * @param editControl this is the black area for sliders etc
1066a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford     */
1076a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public void setUtilityPanelUI(View actionButton, View editControl) {
108235d2179374bec14040f20af91dc753e38ea3639John Hoford
109235d2179374bec14040f20af91dc753e38ea3639John Hoford        AttributeSet aset;
110235d2179374bec14040f20af91dc753e38ea3639John Hoford        Context context = editControl.getContext();
111235d2179374bec14040f20af91dc753e38ea3639John Hoford        LayoutInflater inflater =
112235d2179374bec14040f20af91dc753e38ea3639John Hoford                (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
113235d2179374bec14040f20af91dc753e38ea3639John Hoford        LinearLayout lp = (LinearLayout) inflater.inflate(
114235d2179374bec14040f20af91dc753e38ea3639John Hoford                R.layout.filtershow_seekbar, (ViewGroup) editControl, true);
115235d2179374bec14040f20af91dc753e38ea3639John Hoford        mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar);
116235d2179374bec14040f20af91dc753e38ea3639John Hoford        mSeekBar.setOnSeekBarChangeListener(this);
117235d2179374bec14040f20af91dc753e38ea3639John Hoford
11891be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard        if (showsSeekBar()) {
11991be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard            mSeekBar.setOnSeekBarChangeListener(this);
12091be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard            mSeekBar.setVisibility(View.VISIBLE);
12191be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard        } else {
12291be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard            mSeekBar.setVisibility(View.INVISIBLE);
12391be98c35f6c5f19d7629bb29e7261970b2f4c67nicolasroard        }
124235d2179374bec14040f20af91dc753e38ea3639John Hoford
125f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        if (mButton != null) {
126be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard            if (showsPopupIndicator()) {
127f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard                mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0,
128235d2179374bec14040f20af91dc753e38ea3639John Hoford                        R.drawable.filtershow_menu_marker, 0);
129be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard            } else {
130f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard                mButton.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
131be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard            }
132be31e587c1485fb8e3d7c8b079250ffbdc26e1b9nicolasroard        }
1336a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
1346a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
1356a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    @Override
1366a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public void onProgressChanged(SeekBar sbar, int progress, boolean arg2) {
1376a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
1386a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
1396a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
1406a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public void setPanel() {
1416a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
1426a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
1436a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
1445aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public void createEditor(Context context,FrameLayout frameLayout) {
1455aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mContext = context;
1465aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mFrameLayout = frameLayout;
147cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        mLocalRepresentation = null;
1485aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1495aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1505aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    protected void unpack(int viewid, int layoutid) {
1515aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1525aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        if (mView == null) {
1535aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            mView = mFrameLayout.findViewById(viewid);
1545aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            if (mView == null) {
1555aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                LayoutInflater inflater = (LayoutInflater) mContext.getSystemService
1565aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                        (Context.LAYOUT_INFLATER_SERVICE);
1575aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                mView = inflater.inflate(layoutid, mFrameLayout, false);
1585aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                mFrameLayout.addView(mView, mView.getLayoutParams());
1595aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            }
1605aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        }
1615aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mImageShow = findImageShow(mView);
1625aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1635aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1645aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    private ImageShow findImageShow(View view) {
1655aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        if (view instanceof ImageShow) {
1665aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            return (ImageShow) view;
1675aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        }
1685aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        if (!(view instanceof ViewGroup)) {
1695aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            return null;
1705aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        }
1715aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        ViewGroup vg = (ViewGroup) view;
1725aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        int n = vg.getChildCount();
1735aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        for (int i = 0; i < n; i++) {
1745aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            View v = vg.getChildAt(i);
1755aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            if (v instanceof ImageShow) {
1765aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                return (ImageShow) v;
1775aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            } else if (v instanceof ViewGroup) {
1785aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford                return findImageShow(v);
1795aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            }
1805aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        }
1815aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        return null;
1825aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1835aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1845aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public View getTopLevelView() {
1855aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        return mView;
1865aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1875aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1885aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public ImageShow getImageShow() {
1895aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        return mImageShow;
1905aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1915aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1925aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public void setImageLoader(ImageLoader imageLoader) {
1935aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mImageShow.setImageLoader(imageLoader);
1945aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1955aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
1965aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public void setVisibility(int visible) {
1975aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        mView.setVisibility(visible);
1985aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
1995aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
200cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard    public FilterRepresentation getLocalRepresentation() {
201cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        if (mLocalRepresentation == null) {
202cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard            ImagePreset preset = MasterImage.getImage().getPreset();
203cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard            FilterRepresentation filterRepresentation = MasterImage.getImage().getCurrentFilterRepresentation();
204cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard            mLocalRepresentation = preset.getFilterRepresentationCopyFrom(filterRepresentation);
2055d24515190c1664f944b7950d1a75b0df0de2ff8nicolasroard            if (mShowParameter == SHOW_VALUE_UNDEFINED && filterRepresentation != null) {
2066a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford                boolean show = filterRepresentation.showParameterValue();
2076a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford                mShowParameter = show ? SHOW_VALUE_INT : SHOW_VALUE_OFF;
2086a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford            }
2096a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
210f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        }
211cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        return mLocalRepresentation;
212cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard    }
213cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard
214cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard    public void commitLocalRepresentation() {
215cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        ImagePreset preset = MasterImage.getImage().getPreset();
216cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        preset.updateFilterRepresentation(getLocalRepresentation());
217f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        if (mButton != null) {
218f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard            updateText();
219f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        }
220f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard    }
221f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard
222f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard    protected void updateText() {
223f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        String s = "";
224f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        if (mLocalRepresentation != null) {
225f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard            s = mContext.getString(mLocalRepresentation.getTextId());
2267112720bc6100049d24845cfbf3de69cdbd4fdebJohn Hoford        }
227f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        mButton.setText(calculateUserMessage(mContext, s, ""));
228cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard    }
229cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard
2305aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    /**
2315aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford     * called after the filter is set and the select is called
2325aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford     */
2335aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public void reflectCurrentFilter() {
234cf0b2aad3bc5d80c51316ae10e1cf2c3476259aanicolasroard        mLocalRepresentation = null;
235f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        FilterRepresentation representation = getLocalRepresentation();
236f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        if (representation != null && mFilterTitle != null && representation.getTextId() != 0) {
237f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard            String text = mContext.getString(representation.getTextId()).toUpperCase();
238f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard            mFilterTitle.setText(text);
239f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard            updateText();
240f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard        }
2415aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
2425aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
2435aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public boolean useUtilityPanel() {
244001283a72d451999e3308f45dc365d4defc0af39John Hoford        return true;
2455aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
2465aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
2475aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    public void openUtilityPanel(LinearLayout mAccessoryViewList) {
248235d2179374bec14040f20af91dc753e38ea3639John Hoford        setMenuIcon(false);
2495aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        if (mImageShow != null) {
2505aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford            mImageShow.openUtilityPanel(mAccessoryViewList);
2515aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford        }
2525aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford    }
2535aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford
254235d2179374bec14040f20af91dc753e38ea3639John Hoford    protected void setMenuIcon(boolean on) {
255235d2179374bec14040f20af91dc753e38ea3639John Hoford        mEditTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
256235d2179374bec14040f20af91dc753e38ea3639John Hoford                0, 0, on ? R.drawable.filtershow_menu_marker : 0, 0);
257235d2179374bec14040f20af91dc753e38ea3639John Hoford    }
258f5eedf1635eba7edfa7d41fd4e991cced978c4b2nicolasroard
2596a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    protected void createMenu(int[] strId, View button) {
2606a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford        PopupMenu pmenu = new PopupMenu(mContext, button);
2616a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford        Menu menu = pmenu.getMenu();
2626a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford        for (int i = 0; i < strId.length; i++) {
2636a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford            menu.add(Menu.NONE, Menu.FIRST + i, 0, mContext.getString(strId[i]));
2646a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford        }
265235d2179374bec14040f20af91dc753e38ea3639John Hoford        setMenuIcon(true);
266235d2179374bec14040f20af91dc753e38ea3639John Hoford
2676a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
2686a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
269235d2179374bec14040f20af91dc753e38ea3639John Hoford    public Control[] getControls() {
270235d2179374bec14040f20af91dc753e38ea3639John Hoford        return null;
271235d2179374bec14040f20af91dc753e38ea3639John Hoford    }
2726a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    @Override
2736a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public void onStartTrackingTouch(SeekBar arg0) {
2746a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
2756a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
2766a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
2776a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    @Override
2786a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    public void onStopTrackingTouch(SeekBar arg0) {
2796a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
2806a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford    }
2816a07dfbe03c8396cc43840a1630ea480a2cff663John Hoford
2822ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    @Override
2832ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    public void swapLeft(MenuItem item) {
2842ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard
2852ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    }
2862ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard
2872ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    @Override
2882ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    public void swapRight(MenuItem item) {
2892ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard
2902ff0e04ddcf770a782f94ddee936a1c205e1f322nicolasroard    }
2917668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard
2927668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard    public void detach() {
2937668544ee3e8ba3b14d127b9ecd1cf4a3b2f3e11nicolasroard    }
2945aa08941bda0cfbcfba522c53937dd66867f890dJohn Hoford}
295