mobile/android/base/BaseGeckoInterface.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/BaseGeckoInterface.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,138 @@
     1.4 +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +package org.mozilla.gecko;
    1.10 +
    1.11 +import org.mozilla.gecko.util.HardwareUtils;
    1.12 +import org.mozilla.gecko.util.ThreadUtils;
    1.13 +import org.mozilla.gecko.prompts.PromptService;
    1.14 +
    1.15 +import android.app.Activity;
    1.16 +import android.content.Context;
    1.17 +import android.graphics.RectF;
    1.18 +import android.hardware.SensorEventListener;
    1.19 +import android.location.LocationListener;
    1.20 +import android.os.Build;
    1.21 +import android.view.View;
    1.22 +import android.view.Window;
    1.23 +import android.view.WindowManager;
    1.24 +import android.widget.AbsoluteLayout;
    1.25 +
    1.26 +public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
    1.27 +    // Bug 908744: Implement GeckoEventListener
    1.28 +    // Bug 908752: Implement SensorEventListener
    1.29 +    // Bug 908755: Implement LocationListener
    1.30 +    // Bug 908756: Implement Tabs.OnTabsChangedListener
    1.31 +    // Bug 908760: Implement GeckoEventResponder
    1.32 +
    1.33 +    private Context mContext;
    1.34 +    private GeckoProfile mProfile;
    1.35 +
    1.36 +    public BaseGeckoInterface(Context context) {
    1.37 +        mContext = context;
    1.38 +    }
    1.39 +
    1.40 +    public GeckoProfile getProfile() {
    1.41 +        // Fall back to default profile if we didn't load a specific one
    1.42 +        if (mProfile == null) {
    1.43 +            mProfile = GeckoProfile.get(mContext);
    1.44 +        }
    1.45 +        return mProfile;
    1.46 +    }
    1.47 +
    1.48 +    // Bug 908770: Implement this
    1.49 +    public PromptService getPromptService() {
    1.50 +        return null;
    1.51 +    }
    1.52 +
    1.53 +    public Activity getActivity() {
    1.54 +        return (Activity)mContext;
    1.55 +    }
    1.56 +
    1.57 +    public String getDefaultUAString() {
    1.58 +        return HardwareUtils.isTablet() ? AppConstants.USER_AGENT_FENNEC_TABLET :
    1.59 +                                          AppConstants.USER_AGENT_FENNEC_MOBILE;
    1.60 +    }
    1.61 +
    1.62 +    // Bug 908772: Implement this
    1.63 +    public LocationListener getLocationListener() {
    1.64 +        return null;
    1.65 +    }
    1.66 +
    1.67 +    // Bug 908773: Implement this
    1.68 +    public SensorEventListener getSensorEventListener() {
    1.69 +        return null;
    1.70 +    }
    1.71 +
    1.72 +    // Bug 908775: Implement this
    1.73 +    public void doRestart() {}
    1.74 +
    1.75 +    public void setFullScreen(final boolean fullscreen) {
    1.76 +        ThreadUtils.postToUiThread(new Runnable() {
    1.77 +            @Override
    1.78 +            public void run() {
    1.79 +                // Hide/show the system notification bar
    1.80 +                Window window = ((Activity)mContext).getWindow();
    1.81 +                window.setFlags(fullscreen ?
    1.82 +                                WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
    1.83 +                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    1.84 +
    1.85 +                if (Build.VERSION.SDK_INT >= 11)
    1.86 +                    window.getDecorView().setSystemUiVisibility(fullscreen ? 1 : 0);
    1.87 +            }
    1.88 +        });
    1.89 +    }
    1.90 +
    1.91 +    // Bug 908779: Implement this
    1.92 +    public void addPluginView(final View view, final RectF rect, final boolean isFullScreen) {}
    1.93 +
    1.94 +    // Bug 908781: Implement this
    1.95 +    public void removePluginView(final View view, final boolean isFullScreen) {}
    1.96 +
    1.97 +    // Bug 908783: Implement this
    1.98 +    public void enableCameraView() {}
    1.99 +
   1.100 +    // Bug 908785: Implement this
   1.101 +    public void disableCameraView() {}
   1.102 +
   1.103 +    // Bug 908786: Implement this
   1.104 +    public void addAppStateListener(GeckoAppShell.AppStateListener listener) {}
   1.105 +
   1.106 +    // Bug 908787: Implement this
   1.107 +    public void removeAppStateListener(GeckoAppShell.AppStateListener listener) {}
   1.108 +
   1.109 +    // Bug 908788: Implement this
   1.110 +    public View getCameraView() {
   1.111 +        return null;
   1.112 +    }
   1.113 +
   1.114 +    // Bug 908789: Implement this
   1.115 +    public void notifyWakeLockChanged(String topic, String state) {}
   1.116 +
   1.117 +    // Bug 908790: Implement this
   1.118 +    public FormAssistPopup getFormAssistPopup() {
   1.119 +        return null;
   1.120 +    }
   1.121 +
   1.122 +    public boolean areTabsShown() {
   1.123 +        return false;
   1.124 +    }
   1.125 +
   1.126 +    // Bug 908791: Implement this
   1.127 +    public AbsoluteLayout getPluginContainer() {
   1.128 +        return null;
   1.129 +    }
   1.130 +
   1.131 +    public void notifyCheckUpdateResult(String result) {
   1.132 +        GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Update:CheckResult", result));
   1.133 +    }
   1.134 +
   1.135 +    public boolean hasTabsSideBar() {
   1.136 +        return false;
   1.137 +    }
   1.138 +
   1.139 +    // Bug 908792: Implement this
   1.140 +    public void invalidateOptionsMenu() {}
   1.141 +}

mercurial