1bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwoodpackage com.android.ex.photo;
2bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
3bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwoodimport android.app.ActionBar;
4bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwoodimport android.graphics.drawable.Drawable;
5bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
6bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood/**
7bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood * Wrapper around {@link ActionBar}.
8bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood */
9bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwoodpublic class ActionBarWrapper implements ActionBarInterface {
10bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
11bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    private final ActionBar mActionBar;
12bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
13bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    private class MenuVisiblityListenerWrapper implements ActionBar.OnMenuVisibilityListener {
14bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
15bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        private final ActionBarInterface.OnMenuVisibilityListener mWrapped;
16bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
17bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        public MenuVisiblityListenerWrapper(ActionBarInterface.OnMenuVisibilityListener wrapped) {
18bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood            mWrapped = wrapped;
19bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        }
20bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
21bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        @Override
22bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        public void onMenuVisibilityChanged(boolean isVisible) {
23bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood            mWrapped.onMenuVisibilityChanged(isVisible);
24bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        }
25bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
26bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
27bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public ActionBarWrapper(ActionBar actionBar) {
28bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar = actionBar;
29bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
30bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
31bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
32bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
33bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.setDisplayHomeAsUpEnabled(showHomeAsUp);
34bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
35bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
36bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
37bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
38bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.addOnMenuVisibilityListener(new MenuVisiblityListenerWrapper(listener));
39bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
40bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
41bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
42bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void setDisplayOptionsShowTitle() {
43bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
44bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
45bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
46bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
47e4c48c7c0374d5dfd52fea40d7639b8f8526043dScott Kennedy    public CharSequence getTitle() {
48e4c48c7c0374d5dfd52fea40d7639b8f8526043dScott Kennedy       return mActionBar.getTitle();
49e4c48c7c0374d5dfd52fea40d7639b8f8526043dScott Kennedy    }
50e4c48c7c0374d5dfd52fea40d7639b8f8526043dScott Kennedy
51e4c48c7c0374d5dfd52fea40d7639b8f8526043dScott Kennedy    @Override
52bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void setTitle(CharSequence title) {
53bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.setTitle(title);
54bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
55bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
56bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
57bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void setSubtitle(CharSequence subtitle) {
58bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.setSubtitle(subtitle);
59bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
60bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
61bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
62bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void show() {
63bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.show();
64bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
65bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
66bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
67bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void hide() {
68bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.hide();
69bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
70bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
71bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    @Override
72bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    public void setLogo(Drawable logo) {
73bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood        mActionBar.setLogo(logo);
74bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood    }
75bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood
76bb137c8e2ed363e6f5e2c0f14719483d27e8c062Mathew Inwood}
77