Ejemplo n.º 1
0
  @Override
  public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
    if (LinphoneUtils.isCallEstablished(LinphoneManager.getLc().getCurrentCall())) {
      if (mZoomFactor > 1) {
        // Video is zoomed, slide is used to change center of zoom
        if (distanceX > 0 && mZoomCenterX < 1) {
          mZoomCenterX += 0.01;
        } else if (distanceX < 0 && mZoomCenterX > 0) {
          mZoomCenterX -= 0.01;
        }
        if (distanceY < 0 && mZoomCenterY < 1) {
          mZoomCenterY += 0.01;
        } else if (distanceY > 0 && mZoomCenterY > 0) {
          mZoomCenterY -= 0.01;
        }

        if (mZoomCenterX > 1) mZoomCenterX = 1;
        if (mZoomCenterX < 0) mZoomCenterX = 0;
        if (mZoomCenterY > 1) mZoomCenterY = 1;
        if (mZoomCenterY < 0) mZoomCenterY = 0;

        LinphoneManager.getLc().getCurrentCall().zoomVideo(mZoomFactor, mZoomCenterX, mZoomCenterY);
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 2
0
  @Override
  public boolean onDoubleTap(MotionEvent e) {
    if (LinphoneUtils.isCallEstablished(LinphoneManager.getLc().getCurrentCall())) {
      Log.i("================videoSize===002==");
      if (mZoomFactor == 1.f) {
        // Zoom to make the video fill the screen vertically
        float portraitZoomFactor =
            ((float) mVideoView.getHeight()) / (float) ((3 * mVideoView.getWidth()) / 4);
        // Zoom to make the video fill the screen horizontally
        float landscapeZoomFactor =
            ((float) mVideoView.getWidth()) / (float) ((3 * mVideoView.getHeight()) / 4);

        mZoomFactor = Math.max(portraitZoomFactor, landscapeZoomFactor);
      } else {
        resetZoom();
      }

      LinphoneManager.getLc().getCurrentCall().zoomVideo(mZoomFactor, mZoomCenterX, mZoomCenterY);
      return true;
    }

    return false;
  }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;

    getWindow()
        .addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    setContentView(R.layout.incall);

    isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
    isSpeakerEnabled = LinphoneManager.getLcIfManagerNotDestroyedOrNull().isSpeakerEnabled();

    if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
      if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
        BluetoothManager.getInstance().initBluetooth();
      } else {
        isSpeakerEnabled = false;
      }
    }

    isAnimationDisabled =
        getApplicationContext().getResources().getBoolean(R.bool.disable_animations)
            || !LinphonePreferences.instance().areAnimationsEnabled();

    mListener =
        new LinphoneCoreListenerBase() {
          @Override
          public void callState(
              LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
            if (LinphoneManager.getLc().getCallsNb() == 0) {
              finish();
              return;
            }

            if (state == State.IncomingReceived) {
              startIncomingCallActivity();
              return;
            }

            if (state == State.StreamsRunning) {
              LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);

              isMicMuted = LinphoneManager.getLc().isMicMuted();
              enableAndRefreshInCallActions();

              if (status != null) {
                status.refreshStatusItems(call);
              }
            }

            refreshInCallActions();

            refreshCallList(getResources());

            if (state == State.CallUpdatedByRemote) {
              acceptCallUpdate();
              return;
            }

            transfer.setEnabled(LinphoneManager.getLc().getCurrentCall() != null);
          }
        };

    if (findViewById(R.id.fragmentContainer) != null) {

      initUI();

      if (LinphoneManager.getLc().getCallsNb() > 0) {
        LinphoneCall call = LinphoneManager.getLc().getCalls()[0];

        if (LinphoneUtils.isCallEstablished(call)) {
          enableAndRefreshInCallActions();
        }
      }

      if (savedInstanceState != null) {
        // Fragment already created, no need to create it again (else it will generate a memory leak
        // with duplicated fragments)
        isSpeakerEnabled = savedInstanceState.getBoolean("Speaker");
        isMicMuted = savedInstanceState.getBoolean("Mic");
        refreshInCallActions();
        return;
      }

      audioCallFragment = new AudioCallFragment();

      if (BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) {
        BluetoothManager.getInstance().routeAudioToBluetooth();
      }

      audioCallFragment.setArguments(getIntent().getExtras());
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.fragmentContainer, audioCallFragment)
          .commitAllowingStateLoss();
    }
  }