コード例 #1
0
  public void initializeView(EventDispatcher eventDispatcher) {
    mLayerClient = new GeckoLayerClient(getContext(), this, eventDispatcher);
    mPanZoomController = mLayerClient.getPanZoomController();
    mMarginsAnimator = mLayerClient.getLayerMarginsAnimator();

    mRenderer = new LayerRenderer(this);
    mInputConnectionHandler = null;

    setFocusable(true);
    setFocusableInTouchMode(true);

    GeckoAccessibility.setDelegate(this);
  }
コード例 #2
0
 public void destroy() {
   if (mLayerClient != null) {
     mLayerClient.destroy();
   }
   if (mRenderer != null) {
     mRenderer.destroy();
   }
 }
コード例 #3
0
  public void geckoConnected() {
    // See if we want to force 16-bit colour before doing anything
    PrefsHelper.getPref(
        "gfx.android.rgb16.force",
        new PrefsHelper.PrefHandlerBase() {
          @Override
          public void prefValue(String pref, boolean force16bit) {
            if (force16bit) {
              GeckoAppShell.setScreenDepthOverride(16);
            }
          }
        });

    mLayerClient.notifyGeckoReady();
    addTouchInterceptor(
        new TouchEventInterceptor() {
          private PointF mInitialTouchPoint = null;

          @Override
          public boolean onInterceptTouchEvent(View view, MotionEvent event) {
            return false;
          }

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event == null) {
              return true;
            }

            int action = event.getActionMasked();
            PointF point = new PointF(event.getX(), event.getY());
            if (action == MotionEvent.ACTION_DOWN) {
              mInitialTouchPoint = point;
            }

            if (mInitialTouchPoint != null && action == MotionEvent.ACTION_MOVE) {
              if (PointUtils.subtract(point, mInitialTouchPoint).length()
                  < PanZoomController.PAN_THRESHOLD) {
                // Don't send the touchmove event if if the users finger hasn't moved far.
                // Necessary for Google Maps to work correctly. See bug 771099.
                return true;
              } else {
                mInitialTouchPoint = null;
              }
            }

            GeckoAppShell.sendEventToGecko(GeckoEvent.createMotionEvent(event, false));
            return true;
          }
        });
  }
コード例 #4
0
 public void setInputConnectionHandler(InputConnectionHandler inputConnectionHandler) {
   mInputConnectionHandler = inputConnectionHandler;
   mLayerClient.forceRedraw(null);
 }
コード例 #5
0
 public void setIsRTL(boolean aIsRTL) {
   mLayerClient.setIsRTL(aIsRTL);
 }
コード例 #6
0
 public void setZoomConstraints(ZoomConstraints constraints) {
   mLayerClient.setZoomConstraints(constraints);
 }
コード例 #7
0
 public PointF convertViewPointToLayerPoint(PointF viewPoint) {
   return mLayerClient.convertViewPointToLayerPoint(viewPoint);
 }
コード例 #8
0
 public ImmutableViewportMetrics getViewportMetrics() {
   return mLayerClient.getViewportMetrics();
 }
コード例 #9
0
  public void show(
      String aTitle,
      String aText,
      PromptButton[] aButtons,
      PromptListItem[] aMenuList,
      boolean aMultipleSelection) {
    final GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
    layerClient.post(
        new Runnable() {
          public void run() {
            // treat actions that show a dialog as if preventDefault by content to prevent panning
            layerClient.getPanZoomController().abortPanning();
          }
        });

    AlertDialog.Builder builder = new AlertDialog.Builder(GeckoApp.mAppContext);
    if (!aTitle.equals("")) {
      builder.setTitle(aTitle);
    }

    if (!aText.equals("")) {
      builder.setMessage(aText);
    }

    int length = mInputs == null ? 0 : mInputs.length;
    if (aMenuList != null && aMenuList.length > 0) {
      int resourceId = android.R.layout.select_dialog_item;
      if (mSelected != null && mSelected.length > 0) {
        if (aMultipleSelection) {
          resourceId = android.R.layout.select_dialog_multichoice;
        } else {
          resourceId = android.R.layout.select_dialog_singlechoice;
        }
      }
      PromptListAdapter adapter =
          new PromptListAdapter(GeckoApp.mAppContext, resourceId, aMenuList);
      if (mSelected != null && mSelected.length > 0) {
        if (aMultipleSelection) {
          adapter.listView = (ListView) mInflater.inflate(R.layout.select_dialog_list, null);
          adapter.listView.setOnItemClickListener(this);
          builder.setInverseBackgroundForced(true);
          adapter.listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
          adapter.listView.setAdapter(adapter);
          builder.setView(adapter.listView);
        } else {
          int selectedIndex = -1;
          for (int i = 0; i < mSelected.length; i++) {
            if (mSelected[i]) {
              selectedIndex = i;
              break;
            }
          }
          mSelected = null;
          builder.setSingleChoiceItems(adapter, selectedIndex, this);
        }
      } else {
        builder.setAdapter(adapter, this);
        mSelected = null;
      }
    } else if (length == 1) {
      builder.setView(mInputs[0].getView());
    } else if (length > 1) {
      LinearLayout linearLayout = new LinearLayout(GeckoApp.mAppContext);
      linearLayout.setOrientation(LinearLayout.VERTICAL);
      for (int i = 0; i < length; i++) {
        View content = mInputs[i].getView();
        linearLayout.addView(content);
      }
      builder.setView((View) linearLayout);
    }

    length = aButtons == null ? 0 : aButtons.length;
    if (length > 0) {
      builder.setPositiveButton(aButtons[0].label, this);
    }
    if (length > 1) {
      builder.setNeutralButton(aButtons[1].label, this);
    }
    if (length > 2) {
      builder.setNegativeButton(aButtons[2].label, this);
    }

    mDialog = builder.create();
    mDialog.setOnCancelListener(this);
    mDialog.show();
  }