0
|
1 /*
|
|
2 * ConnectBot: simple, powerful, open-source SSH client for Android
|
|
3 * Copyright 2007 Kenny Root, Jeffrey Sharkey
|
|
4 *
|
|
5 * Licensed under the Apache License, Version 2.0 (the "License");
|
|
6 * you may not use this file except in compliance with the License.
|
|
7 * You may obtain a copy of the License at
|
|
8 *
|
|
9 * http://www.apache.org/licenses/LICENSE-2.0
|
|
10 *
|
|
11 * Unless required by applicable law or agreed to in writing, software
|
|
12 * distributed under the License is distributed on an "AS IS" BASIS,
|
|
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14 * See the License for the specific language governing permissions and
|
|
15 * limitations under the License.
|
|
16 */
|
|
17
|
|
18 package com.five_ten_sg.connectbot;
|
|
19
|
|
20 import com.five_ten_sg.connectbot.util.PreferenceConstants;
|
|
21 import android.annotation.TargetApi;
|
|
22 import android.app.ActionBar;
|
|
23 import android.app.Activity;
|
|
24
|
|
25 public abstract class ActionBarWrapper {
|
|
26 public interface OnMenuVisibilityListener {
|
|
27 public void onMenuVisibilityChanged(boolean isVisible);
|
|
28 }
|
|
29
|
|
30 public static ActionBarWrapper getActionBar(Activity activity) {
|
|
31 if (PreferenceConstants.PRE_HONEYCOMB)
|
|
32 return new DummyActionBar();
|
|
33 else
|
|
34 return new RealActionBar(activity);
|
|
35 }
|
|
36
|
|
37 public void hide() {
|
|
38 }
|
|
39
|
|
40 public void show() {
|
|
41 }
|
|
42
|
|
43 public void addOnMenuVisibilityListener(OnMenuVisibilityListener listener) {
|
|
44 }
|
|
45
|
|
46 public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
|
|
47 }
|
|
48
|
|
49 private static class DummyActionBar extends ActionBarWrapper {
|
|
50 }
|
|
51
|
|
52 @TargetApi(11)
|
|
53 private static class RealActionBar extends ActionBarWrapper {
|
|
54 private final ActionBar actionBar;
|
|
55
|
|
56 public RealActionBar(Activity activity) {
|
|
57 actionBar = activity.getActionBar();
|
|
58 }
|
|
59
|
|
60 @Override
|
|
61 public void hide() {
|
|
62 actionBar.hide();
|
|
63 }
|
|
64
|
|
65 @Override
|
|
66 public void show() {
|
|
67 actionBar.show();
|
|
68 }
|
|
69
|
|
70 @Override
|
|
71 public void addOnMenuVisibilityListener(final OnMenuVisibilityListener listener) {
|
|
72 actionBar.addOnMenuVisibilityListener(new ActionBar.OnMenuVisibilityListener() {
|
|
73 public void onMenuVisibilityChanged(boolean isVisible) {
|
|
74 listener.onMenuVisibilityChanged(isVisible);
|
|
75 }
|
|
76 });
|
|
77 }
|
|
78
|
|
79 @Override
|
|
80 public void setDisplayHomeAsUpEnabled(boolean showHomeAsUp) {
|
|
81 actionBar.setDisplayHomeAsUpEnabled(showHomeAsUp);
|
|
82 }
|
|
83 }
|
|
84 }
|