Search in sources :

Example 1 with ToneGenerator

use of com.voipgrid.vialer.dialer.ToneGenerator in project vialer-android by VoIPGRID.

the class CallKeyPadFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ViewGroup keyPadViewContainer = (ViewGroup) view.findViewById(R.id.fragment_call_key_pad);
    KeyPadView keyPadView = (KeyPadView) keyPadViewContainer.findViewById(R.id.key_pad_view);
    keyPadView.setOnKeyPadClickListener(this);
    mHangupButton = view.findViewById(R.id.button_keypad_call_hangup);
    mHangupButton.setOnClickListener(this);
    mNumberInputView = (NumberInputView) view.findViewById(R.id.number_input_edit_text);
    mNumberInputView.setOnInputChangedListener(new NumberInputView.OnInputChangedListener() {

        @Override
        public void onInputChanged(String number) {
        // This is needed to get the remove button to show up.
        }
    });
    AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
    mToneGenerator = new ToneGenerator(AudioManager.STREAM_DTMF, (int) (Math.floor(audioManager.getStreamVolume(AudioManager.STREAM_DTMF) * 5)));
}
Also used : AudioManager(android.media.AudioManager) ToneGenerator(com.voipgrid.vialer.dialer.ToneGenerator) NumberInputView(com.voipgrid.vialer.dialer.NumberInputView) ViewGroup(android.view.ViewGroup) KeyPadView(com.voipgrid.vialer.dialer.KeyPadView)

Example 2 with ToneGenerator

use of com.voipgrid.vialer.dialer.ToneGenerator in project vialer-android by VoIPGRID.

the class SipService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mHandler = new Handler();
    mToneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, SipConstants.RINGING_VOLUME);
    mSipBroadcaster = new SipBroadcaster(this);
    mPreferences = new Preferences(this);
    mRemoteLogger = new RemoteLogger(SipService.class).enableConsoleLogging();
    mNativeCallManager = new NativeCallManager((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE));
    mRemoteLogger.d("onCreate");
    IntentFilter filter = new IntentFilter();
    filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    registerReceiver(phoneStateReceiver, filter);
    // Create runnable to check if the SipService is still in use.
    mCheckServiceHandler = new Handler();
    mCheckServiceRunnable = new Runnable() {

        @Override
        public void run() {
            // Check if the service is being used after 10 seconds and shutdown the service
            // if required.
            checkServiceBeingUsed();
            mCheckServiceHandler.postDelayed(this, mCheckServiceUsedTimer);
        }
    };
    mCheckServiceHandler.postDelayed(mCheckServiceRunnable, mCheckServiceUsedTimer);
    PhoneAccount phoneAccount = new JsonStorage<PhoneAccount>(this).get(PhoneAccount.class);
    if (phoneAccount != null) {
        // Try to load PJSIP library.
        mSipConfig = new SipConfig(this, phoneAccount);
        try {
            mSipConfig.initLibrary();
        } catch (SipConfig.LibraryInitFailedException e) {
            stopSelf();
        }
    } else {
        // User has no sip account so destroy the service.
        mRemoteLogger.w("No sip account when trying to create service");
        stopSelf();
    }
}
Also used : IntentFilter(android.content.IntentFilter) Handler(android.os.Handler) NativeCallManager(com.voipgrid.vialer.call.NativeCallManager) ToneGenerator(com.voipgrid.vialer.dialer.ToneGenerator) PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) TelephonyManager(android.telephony.TelephonyManager) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) Preferences(com.voipgrid.vialer.Preferences)

Aggregations

ToneGenerator (com.voipgrid.vialer.dialer.ToneGenerator)2 IntentFilter (android.content.IntentFilter)1 AudioManager (android.media.AudioManager)1 Handler (android.os.Handler)1 TelephonyManager (android.telephony.TelephonyManager)1 ViewGroup (android.view.ViewGroup)1 Preferences (com.voipgrid.vialer.Preferences)1 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)1 NativeCallManager (com.voipgrid.vialer.call.NativeCallManager)1 KeyPadView (com.voipgrid.vialer.dialer.KeyPadView)1 NumberInputView (com.voipgrid.vialer.dialer.NumberInputView)1 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)1