mobile/android/base/BaseGeckoInterface.java

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:ee0b41ddda8d
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 package org.mozilla.gecko;
7
8 import org.mozilla.gecko.util.HardwareUtils;
9 import org.mozilla.gecko.util.ThreadUtils;
10 import org.mozilla.gecko.prompts.PromptService;
11
12 import android.app.Activity;
13 import android.content.Context;
14 import android.graphics.RectF;
15 import android.hardware.SensorEventListener;
16 import android.location.LocationListener;
17 import android.os.Build;
18 import android.view.View;
19 import android.view.Window;
20 import android.view.WindowManager;
21 import android.widget.AbsoluteLayout;
22
23 public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
24 // Bug 908744: Implement GeckoEventListener
25 // Bug 908752: Implement SensorEventListener
26 // Bug 908755: Implement LocationListener
27 // Bug 908756: Implement Tabs.OnTabsChangedListener
28 // Bug 908760: Implement GeckoEventResponder
29
30 private Context mContext;
31 private GeckoProfile mProfile;
32
33 public BaseGeckoInterface(Context context) {
34 mContext = context;
35 }
36
37 public GeckoProfile getProfile() {
38 // Fall back to default profile if we didn't load a specific one
39 if (mProfile == null) {
40 mProfile = GeckoProfile.get(mContext);
41 }
42 return mProfile;
43 }
44
45 // Bug 908770: Implement this
46 public PromptService getPromptService() {
47 return null;
48 }
49
50 public Activity getActivity() {
51 return (Activity)mContext;
52 }
53
54 public String getDefaultUAString() {
55 return HardwareUtils.isTablet() ? AppConstants.USER_AGENT_FENNEC_TABLET :
56 AppConstants.USER_AGENT_FENNEC_MOBILE;
57 }
58
59 // Bug 908772: Implement this
60 public LocationListener getLocationListener() {
61 return null;
62 }
63
64 // Bug 908773: Implement this
65 public SensorEventListener getSensorEventListener() {
66 return null;
67 }
68
69 // Bug 908775: Implement this
70 public void doRestart() {}
71
72 public void setFullScreen(final boolean fullscreen) {
73 ThreadUtils.postToUiThread(new Runnable() {
74 @Override
75 public void run() {
76 // Hide/show the system notification bar
77 Window window = ((Activity)mContext).getWindow();
78 window.setFlags(fullscreen ?
79 WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
80 WindowManager.LayoutParams.FLAG_FULLSCREEN);
81
82 if (Build.VERSION.SDK_INT >= 11)
83 window.getDecorView().setSystemUiVisibility(fullscreen ? 1 : 0);
84 }
85 });
86 }
87
88 // Bug 908779: Implement this
89 public void addPluginView(final View view, final RectF rect, final boolean isFullScreen) {}
90
91 // Bug 908781: Implement this
92 public void removePluginView(final View view, final boolean isFullScreen) {}
93
94 // Bug 908783: Implement this
95 public void enableCameraView() {}
96
97 // Bug 908785: Implement this
98 public void disableCameraView() {}
99
100 // Bug 908786: Implement this
101 public void addAppStateListener(GeckoAppShell.AppStateListener listener) {}
102
103 // Bug 908787: Implement this
104 public void removeAppStateListener(GeckoAppShell.AppStateListener listener) {}
105
106 // Bug 908788: Implement this
107 public View getCameraView() {
108 return null;
109 }
110
111 // Bug 908789: Implement this
112 public void notifyWakeLockChanged(String topic, String state) {}
113
114 // Bug 908790: Implement this
115 public FormAssistPopup getFormAssistPopup() {
116 return null;
117 }
118
119 public boolean areTabsShown() {
120 return false;
121 }
122
123 // Bug 908791: Implement this
124 public AbsoluteLayout getPluginContainer() {
125 return null;
126 }
127
128 public void notifyCheckUpdateResult(String result) {
129 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Update:CheckResult", result));
130 }
131
132 public boolean hasTabsSideBar() {
133 return false;
134 }
135
136 // Bug 908792: Implement this
137 public void invalidateOptionsMenu() {}
138 }

mercurial