Esempio n. 1
0
  @Override
  public void onBackPressed() {
    if (currentFragment == firstFragment) {
      LinphonePreferences.instance().firstLaunchSuccessful();
      if (getResources().getBoolean(R.bool.setup_cancel_move_to_back)) {
        moveTaskToBack(true);
      } else {
        setResult(Activity.RESULT_CANCELED);
        finish();
      }
    }
    if (currentFragment == SetupFragmentsEnum.MENU) {
      WelcomeFragment fragment = new WelcomeFragment();
      changeFragment(fragment);
      currentFragment = SetupFragmentsEnum.WELCOME;

      next.setVisibility(View.VISIBLE);
      back.setVisibility(View.GONE);
    } else if (currentFragment == SetupFragmentsEnum.GENERIC_LOGIN
        || currentFragment == SetupFragmentsEnum.LINPHONE_LOGIN
        || currentFragment == SetupFragmentsEnum.REMOTE_PROVISIONING) {
      MenuFragment fragment = new MenuFragment();
      changeFragment(fragment);
      currentFragment = SetupFragmentsEnum.MENU;
    } else if (currentFragment == SetupFragmentsEnum.WIZARD) {
      AppUtil.logout();
    } else if (currentFragment == SetupFragmentsEnum.WIZARD_CONFIRM) {
      WizardFragment fragment = new WizardFragment();
      changeFragment(fragment);
      currentFragment = SetupFragmentsEnum.WIZARD;
    } else if (currentFragment == SetupFragmentsEnum.WELCOME) {
      finish();
    }
  }
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     if (currentFragment == FragmentsAvailable.DIALER
         || currentFragment == FragmentsAvailable.CONTACTS
         || currentFragment == FragmentsAvailable.HISTORY
         || currentFragment == FragmentsAvailable.CHATLIST
         || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT
         || currentFragment == FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS) {
       boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
       if (!isBackgroundModeActive) {
         stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
         finish();
       } else if (LinphoneUtils.onKeyBackGoHome(this, keyCode, event)) {
         return true;
       }
     } else {
       if (isTablet()) {
         if (currentFragment == FragmentsAvailable.SETTINGS) {
           updateAnimationsState();
         }
       }
     }
   } else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
     if (event.getRepeatCount() < 1) {
       statusFragment.openOrCloseStatusBar(true);
     }
   }
   return super.onKeyDown(keyCode, event);
 }
Esempio n. 3
0
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.setup_cancel) {
      LinphonePreferences.instance().firstLaunchSuccessful();
      if (getResources().getBoolean(R.bool.setup_cancel_move_to_back)) {
        moveTaskToBack(true);
      } else {
        setResult(Activity.RESULT_CANCELED);
        finish();
      }
    } else if (id == R.id.setup_next) {
      if (firstFragment == SetupFragmentsEnum.LINPHONE_LOGIN) {
        LinphoneLoginFragment linphoneFragment = (LinphoneLoginFragment) fragment;
        linphoneFragment.linphoneLogIn();
      } else {
        if (currentFragment == SetupFragmentsEnum.WELCOME) {
          MenuFragment fragment = new MenuFragment();
          changeFragment(fragment);
          currentFragment = SetupFragmentsEnum.MENU;

          next.setVisibility(View.GONE);
          back.setVisibility(View.VISIBLE);
        } else if (currentFragment == SetupFragmentsEnum.WIZARD) {
          wizardFragment.createAccountClickedHandle();
        } else if (currentFragment == SetupFragmentsEnum.WIZARD_CONFIRM) {
          finish();
        }
      }
    } else if (id == R.id.setup_back) {
      onBackPressed();
    }
  }
Esempio n. 4
0
 private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) {
   boolean needsEchoCalibration = LinphoneManager.getLc().needsEchoCalibration();
   if (needsEchoCalibration && mPrefs.isFirstLaunch()) {
     mPrefs.setAccountEnabled(
         mPrefs.getAccountCount() - 1, false); // We'll enable it after the echo calibration
     EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment();
     fragment.enableEcCalibrationResultSending(sendEcCalibrationResult);
     changeFragment(fragment);
     currentFragment = SetupFragmentsEnum.ECHO_CANCELLER_CALIBRATION;
     back.setVisibility(View.VISIBLE);
     next.setVisibility(View.GONE);
     next.setEnabled(false);
     cancel.setEnabled(false);
   } else {
     if (mPrefs.isFirstLaunch()) {
       mPrefs.setEchoCancellation(false);
     }
     success();
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (getArguments() != null && getArguments().getSerializable("About") != null) {
      about = (FragmentsAvailable) getArguments().getSerializable("About");
    }

    View view = inflater.inflate(R.layout.about, container, false);

    TextView aboutText = (TextView) view.findViewById(R.id.AboutText);
    try {
      aboutText.setText(
          String.format(
              getString(R.string.about_text),
              getActivity()
                  .getPackageManager()
                  .getPackageInfo(getActivity().getPackageName(), 0)
                  .versionName));
    } catch (NameNotFoundException e) {
      Log.e(e, "cannot get version name");
    }

    sendLogButton = view.findViewById(R.id.send_log);
    sendLogButton.setOnClickListener(this);
    sendLogButton.setVisibility(
        LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);

    resetLogButton = view.findViewById(R.id.reset_log);
    resetLogButton.setOnClickListener(this);
    resetLogButton.setVisibility(
        LinphonePreferences.instance().isDebugEnabled() ? View.VISIBLE : View.GONE);

    exitButton = view.findViewById(R.id.exit);
    exitButton.setOnClickListener(this);
    exitButton.setVisibility(View.VISIBLE);

    return view;
  }
Esempio n. 6
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getResources().getBoolean(R.bool.isTablet)
        && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    setContentView(R.layout.setup);
    firstFragment = SetupFragmentsEnum.WIZARD;
    if (findViewById(R.id.fragmentContainer) != null) {
      if (savedInstanceState == null) {
        display(firstFragment);
      } else {
        currentFragment =
            (SetupFragmentsEnum) savedInstanceState.getSerializable("CurrentFragment");
      }
    }
    mPrefs = LinphonePreferences.instance();

    initUI();

    mListener =
        new LinphoneCoreListenerBase() {
          @Override
          public void registrationState(
              LinphoneCore lc,
              LinphoneProxyConfig cfg,
              LinphoneCore.RegistrationState state,
              String smessage) {
            if (accountCreated) {
              if (address != null && address.asString().equals(cfg.getIdentity())) {
                if (state == RegistrationState.RegistrationOk) {
                  if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
                    launchEchoCancellerCalibration(true);
                  }
                } else if (state == RegistrationState.RegistrationFailed) {
                  Toast.makeText(
                          SetupActivity.this,
                          getString(R.string.first_launch_bad_login_password),
                          Toast.LENGTH_LONG)
                      .show();
                }
              }
            }
          }
        };

    instance = this;
  };
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.setup_apply) {
      String url = remoteProvisioningUrl.getText().toString();
      LinphonePreferences.instance().setRemoteProvisioningUrl(url);

      // Restart Linphone
      Intent intent = new Intent();
      intent.setClass(getActivity(), LinphoneLauncherActivity.class);
      getActivity().finish();
      LinphoneActivity.instance().exit();
      startActivity(intent);
    }
  }
Esempio n. 8
0
 public void onCallStateChanged(LinphoneCall linphoneCall, State state, String str) {
   if (instance == null) {
     Log.m11095i("Service not ready, discarding call state change to ", state.toString());
     return;
   }
   if (state == State.IncomingReceived) {
     onIncomingReceived();
   }
   if (state == State.CallUpdatedByRemote) {
     boolean videoEnabled = linphoneCall.getRemoteParams().getVideoEnabled();
     boolean videoEnabled2 = linphoneCall.getCurrentParamsCopy().getVideoEnabled();
     boolean shouldAutomaticallyAcceptVideoRequests =
         LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
     if (!(!videoEnabled
         || videoEnabled2
         || shouldAutomaticallyAcceptVideoRequests
         || LinphoneManager.getLc().isInConference())) {
       try {
         LinphoneManager.getLc().deferCallUpdate(linphoneCall);
       } catch (Throwable e) {
         C1104b.m6368b((Object) this, e);
       }
     }
   }
   if (state == State.StreamsRunning) {
     if (getResources().getBoolean(C1134b.enable_call_notification)) {}
     if (Version.sdkAboveOrEqual(12)) {
       this.mWifiLock.acquire();
     }
   } else if (getResources().getBoolean(C1134b.enable_call_notification)) {
   }
   if ((state == State.CallEnd || state == State.Error)
       && LinphoneManager.getLc().getCallsNb() < 1
       && Version.sdkAboveOrEqual(12)) {
     this.mWifiLock.release();
   }
   this.mHandler.post(new C28015(linphoneCall, state, str));
 }
 private void updateAnimationsState() {
   isAnimationDisabled =
       getResources().getBoolean(R.bool.disable_animations)
           || !LinphonePreferences.instance().areAnimationsEnabled();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (!isTablet()
        && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    if (!LinphoneManager.isInstanciated()) {
      Log.e("No service running: avoid crash by starting the launcher", this.getClass().getName());
      // super.onCreate called earlier
      finish();
      startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
      return;
    }

    boolean useFirstLoginActivity =
        getResources().getBoolean(R.bool.display_account_wizard_at_first_start);
    if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
      Intent wizard = new Intent();
      wizard.setClass(this, RemoteProvisioningLoginActivity.class);
      wizard.putExtra("Domain", LinphoneManager.getInstance().wizardLoginViewDomain);
      startActivityForResult(wizard, REMOTE_PROVISIONING_LOGIN_ACTIVITY);
    } else if (useFirstLoginActivity && LinphonePreferences.instance().isFirstLaunch()) {
      if (LinphonePreferences.instance().getAccountCount() > 0) {
        LinphonePreferences.instance().firstLaunchSuccessful();
      } else {
        startActivityForResult(
            new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY);
      }
    }

    if (getResources().getBoolean(R.bool.use_linphone_tag)) {
      ContactsManager.getInstance()
          .initializeSyncAccount(getApplicationContext(), getContentResolver());
    } else {
      ContactsManager.getInstance()
          .initializeContactManager(getApplicationContext(), getContentResolver());
    }

    if (!LinphonePreferences.instance().isContactsMigrationDone()) {
      ContactsManager.getInstance().migrateContacts();
      LinphonePreferences.instance().contactsMigrationDone();
    }

    setContentView(R.layout.main);
    instance = this;
    fragmentsHistory = new ArrayList<FragmentsAvailable>();
    initButtons();

    currentFragment = nextFragment = FragmentsAvailable.DIALER;
    fragmentsHistory.add(currentFragment);
    if (savedInstanceState == null) {
      if (findViewById(R.id.fragmentContainer) != null) {
        dialerFragment = new DialerFragment();
        dialerFragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager()
            .beginTransaction()
            .add(R.id.fragmentContainer, dialerFragment, currentFragment.toString())
            .commit();
        selectMenu(FragmentsAvailable.DIALER);
      }
    }

    mListener =
        new LinphoneCoreListenerBase() {
          @Override
          public void messageReceived(
              LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
            if (!displayChatMessageNotification(message.getFrom().asStringUriOnly())) {
              cr.markAsRead();
            }
            displayMissedChats(getChatStorage().getUnreadMessageCount());
            if (messageListFragment != null && messageListFragment.isVisible()) {
              ((ChatListFragment) messageListFragment).refresh();
            }
          }

          @Override
          public void registrationState(
              LinphoneCore lc,
              LinphoneProxyConfig proxy,
              LinphoneCore.RegistrationState state,
              String smessage) {
            if (state.equals(RegistrationState.RegistrationCleared)) {
              if (lc != null) {
                LinphoneAuthInfo authInfo =
                    lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(), proxy.getDomain());
                if (authInfo != null) lc.removeAuthInfo(authInfo);
              }
            }
          }

          @Override
          public void callState(
              LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
            if (state == State.IncomingReceived) {
              startActivity(new Intent(LinphoneActivity.instance(), IncomingCallActivity.class));
            } else if (state == State.OutgoingInit) {
              if (call.getCurrentParamsCopy().getVideoEnabled()) {
                startVideoActivity(call);
              } else {
                startIncallActivity(call);
              }
            } else if (state == State.CallEnd
                || state == State.Error
                || state == State.CallReleased) {
              // Convert LinphoneCore message for internalization
              if (message != null && message.equals("Call declined.")) {
                displayCustomToast(getString(R.string.error_call_declined), Toast.LENGTH_LONG);
              } else if (message != null && message.equals("Not Found")) {
                displayCustomToast(getString(R.string.error_user_not_found), Toast.LENGTH_LONG);
              } else if (message != null && message.equals("Unsupported media type")) {
                displayCustomToast(getString(R.string.error_incompatible_media), Toast.LENGTH_LONG);
              } else if (message != null && state == State.Error) {
                displayCustomToast(
                    getString(R.string.error_unknown) + " - " + message, Toast.LENGTH_LONG);
              }
              resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
            }

            int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
            displayMissedCalls(missedCalls);
          }
        };

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      lc.addListener(mListener);
    }

    int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
    displayMissedCalls(missedCalls);

    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
      case Surface.ROTATION_0:
        rotation = 0;
        break;
      case Surface.ROTATION_90:
        rotation = 90;
        break;
      case Surface.ROTATION_180:
        rotation = 180;
        break;
      case Surface.ROTATION_270:
        rotation = 270;
        break;
    }

    LinphoneManager.getLc().setDeviceRotation(rotation);
    mAlwaysChangingPhoneAngle = rotation;

    updateAnimationsState();
  }
Esempio n. 11
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();
    }
  }
    /**
     * Creates a new account
     *
     * @throws LinphoneCoreException
     */
    public void saveNewAccount() throws LinphoneCoreException {

      if (tempUsername == null
          || tempUsername.length() < 1
          || tempDomain == null
          || tempDomain.length() < 1) {
        Log.w("Skipping account save: username or domain not provided");
        return;
      }

      String identity = "sip:" + tempUsername + "@" + tempDomain;
      String proxy = "sip:";
      if (tempProxy == null) {
        proxy += tempDomain;
      } else {
        if (!tempProxy.startsWith("sip:")
            && !tempProxy.startsWith("<sip:")
            && !tempProxy.startsWith("sips:")
            && !tempProxy.startsWith("<sips:")) {
          proxy += tempProxy;
        } else {
          proxy = tempProxy;
        }
      }
      LinphoneAddress proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxy);
      LinphoneAddress identityAddr = LinphoneCoreFactory.instance().createLinphoneAddress(identity);

      if (tempDisplayName != null) {
        identityAddr.setDisplayName(tempDisplayName);
      }

      if (tempTransport != null) {
        proxyAddr.setTransport(tempTransport);
      }

      String route = tempOutboundProxy ? proxyAddr.asStringUriOnly() : null;

      LinphoneProxyConfig prxCfg =
          lc.createProxyConfig(
              identityAddr.asString(), proxyAddr.asStringUriOnly(), route, tempEnabled);

      if (tempContactsParams != null) prxCfg.setContactUriParameters(tempContactsParams);
      if (tempExpire != null) {
        try {
          prxCfg.setExpires(Integer.parseInt(tempExpire));
        } catch (NumberFormatException nfe) {
        }
      }

      prxCfg.enableAvpf(tempAvpfEnabled);
      prxCfg.setAvpfRRInterval(tempAvpfRRInterval);
      prxCfg.enableQualityReporting(tempQualityReportingEnabled);
      prxCfg.setQualityReportingCollector(tempQualityReportingCollector);
      prxCfg.setQualityReportingInterval(tempQualityReportingInterval);

      if (tempRealm != null) prxCfg.setRealm(tempRealm);

      LinphoneAuthInfo authInfo =
          LinphoneCoreFactory.instance()
              .createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain);

      lc.addProxyConfig(prxCfg);
      lc.addAuthInfo(authInfo);

      if (!tempNoDefault && LinphonePreferences.instance().getAccountCount() == 1)
        lc.setDefaultProxyConfig(prxCfg);
    }
Esempio n. 13
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    sipUri = getArguments().getString("SipUri");
    String displayName = getArguments().getString("DisplayName");
    String pictureUri = getArguments().getString("PictureUri");

    view = inflater.inflate(R.layout.chat, container, false);

    useLinphoneMessageStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);

    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    remoteComposing = (TextView) view.findViewById(R.id.remoteComposing);
    remoteComposing.setVisibility(View.GONE);

    messagesList = (ListView) view.findViewById(R.id.chatMessageList);

    message = (EditText) view.findViewById(R.id.message);
    if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
      message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
      message.setMaxLines(1);
    }

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    uploadLayout.setVisibility(View.GONE);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);

    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);
    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    if (!getResources().getBoolean(R.bool.disable_chat_send_file)) {
      registerForContextMenu(sendImage);
      sendImage.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              pickImage();
            }
          });
    } else {
      sendImage.setEnabled(false);
    }

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            uploadThread.interrupt();
            uploadLayout.setVisibility(View.GONE);
            textLayout.setVisibility(View.VISIBLE);
            progressBar.setProgress(0);
          }
        });

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      chatRoom = lc.getOrCreateChatRoom(sipUri);
      // Only works if using liblinphone storage
      chatRoom.markAsRead();
    }

    displayChatHeader(displayName, pictureUri);

    uploadServerUri = LinphonePreferences.instance().getSharingPictureServerUrl();

    textWatcher =
        new TextWatcher() {
          public void afterTextChanged(Editable arg0) {}

          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}

          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
              sendMessage.setEnabled(false);
            } else {
              if (chatRoom != null) chatRoom.compose();
              sendMessage.setEnabled(true);
            }
          }
        };

    // Force hide keyboard
    if (LinphoneActivity.isInstanciated()) {
      InputMethodManager imm =
          (InputMethodManager)
              LinphoneActivity.instance().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Workaround for SGS3 issue
    if (savedInstanceState != null) {
      fileToUploadPath = savedInstanceState.getString("fileToUploadPath");
      imageToUpload = savedInstanceState.getParcelable("imageToUpload");
    }
    if (fileToUploadPath != null || imageToUpload != null) {
      sendImage.post(
          new Runnable() {
            @Override
            public void run() {
              sendImage.showContextMenu();
            }
          });
    }

    return view;
  }
Esempio n. 14
0
 public void success() {
   mPrefs.firstLaunchSuccessful();
   setResult(Activity.RESULT_OK);
   finish();
 }
Esempio n. 15
0
 public void isEchoCalibrationFinished() {
   mPrefs.setAccountEnabled(mPrefs.getAccountCount() - 1, true);
   success();
 }
Esempio n. 16
0
  public void saveCreatedAccount(String username, String password, String domain) {
    if (accountCreated) return;

    String identity = "sip:" + username + "@" + domain;
    try {
      address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }

    boolean isMainAccountLinphoneDotOrg =
        !getResources().getBoolean(R.bool.use_register_verify_user_webservice);
    boolean useLinphoneDotOrgCustomPorts =
        getResources().getBoolean(R.bool.use_linphone_server_ports);
    AccountBuilder builder =
        new AccountBuilder(LinphoneManager.getLc())
            .setUsername(username)
            .setDomain(domain)
            .setPassword(password);

    if (isMainAccountLinphoneDotOrg && useLinphoneDotOrgCustomPorts) {
      if (getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
        builder.setProxy(domain + ":5228").setTransport(TransportType.LinphoneTransportTcp);
      } else {
        builder.setProxy(domain + ":5223").setTransport(TransportType.LinphoneTransportTls);
      }

      builder
          .setExpires("604800")
          .setOutboundProxyEnabled(true)
          .setAvpfEnabled(true)
          .setAvpfRRInterval(3)
          .setQualityReportingCollector("sip:[email protected]")
          .setQualityReportingEnabled(true)
          .setQualityReportingInterval(180)
          .setRealm("sip.linphone.org");

      mPrefs.setStunServer(getString(R.string.default_stun));
      mPrefs.setIceEnabled(true);
    } else {
      String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
      if (!TextUtils.isEmpty(forcedProxy)) {
        builder.setProxy(forcedProxy).setOutboundProxyEnabled(true).setAvpfRRInterval(5);
      }
    }

    if (getResources().getBoolean(R.bool.enable_push_id)) {
      String regId = mPrefs.getPushNotificationRegistrationID();
      String appId = getString(R.string.push_sender_id);
      if (regId != null && mPrefs.isPushNotificationEnabled()) {
        String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId;
        builder.setContactParameters(contactInfos);
      }
    }

    try {
      builder.saveNewAccount();
      accountCreated = true;
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }
  }