@SuppressLint("UseSparseArrays") @Override public void onResume() { message.addTextChangedListener(textWatcher); addVirtualKeyboardVisiblityListener(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.addListener(mListener); } if (LinphoneActivity.isInstanciated()) { if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) { LinphoneActivity.instance().hideStatusBar(); } LinphoneActivity.instance().updateChatFragment(this); } String draft = getArguments().getString("messageDraft"); message.setText(draft); remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE); dispayMessageList(); super.onResume(); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.status, container, false); statusText = (TextView) view.findViewById(R.id.status_text); statusLed = (ImageView) view.findViewById(R.id.status_led); mListener = new LinphoneCoreListenerBase() { @Override public void registrationState( final LinphoneCore lc, final LinphoneProxyConfig proxy, final LinphoneCore.RegistrationState state, String smessage) { if (!isAttached || !RedfoxService.isReady()) { return; } if (lc.getProxyConfigList() == null) { statusLed.setImageResource(R.drawable.led_disconnected); statusText.setText(getString(R.string.no_account)); } else { statusLed.setVisibility(View.VISIBLE); } if (lc.getDefaultProxyConfig() != null && lc.getDefaultProxyConfig().equals(proxy)) { statusLed.setImageResource(getStatusIconResource(state, true)); statusText.setText(getStatusIconText(state)); } else if (lc.getDefaultProxyConfig() == null) { statusLed.setImageResource(getStatusIconResource(state, true)); statusText.setText(getStatusIconText(state)); } try { statusText.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { lc.refreshRegisters(); } }); } catch (IllegalStateException ise) { } } }; LinphoneCore lc = RedfoxManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.addListener(mListener); LinphoneProxyConfig lpc = lc.getDefaultProxyConfig(); if (lpc != null) { mListener.registrationState(lc, lpc, lpc.getState(), null); } } return view; }
@Override protected void onResume() { super.onResume(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.addListener(mListener); } }
@Override protected void onResume() { instance = this; LinphoneManager.startProximitySensorForActivity(this); setCallControlsVisibleAndRemoveCallbacks(); super.onResume(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); if (lc != null) { lc.addListener(mListener); } refreshCallList(getResources()); }
@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(); }