Search in sources :

Example 1 with AnalyticsApplication

use of com.voipgrid.vialer.analytics.AnalyticsApplication in project vialer-android by VoIPGRID.

the class TwoStepCallActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_two_step_call);
    /* set the AnalyticsHelper */
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    mSystemUser = (SystemUser) new JsonStorage(this).get(SystemUser.class);
    mApi = ServiceGenerator.createService(this, Api.class, getString(R.string.api_url), getEmail(), getPassword());
    mRemoteLogger = new RemoteLogger(TwoStepCallActivity.class);
    String numberToCall = getIntent().getStringExtra(NUMBER_TO_CALL);
    mTwoStepCallTask = new TwoStepCallTask(mApi, mSystemUser.getMobileNumber(), numberToCall);
    mTwoStepCallTask.execute();
    mStatusTextView = ((TextView) findViewById(R.id.status_text_view));
    mTwoStepCallView = (TwoStepCallView) findViewById(R.id.two_step_call_view);
    mTwoStepCallView.setOutgoingNumber(mSystemUser.getOutgoingCli());
    mTwoStepCallView.setNumberA(mSystemUser.getMobileNumber());
    mTwoStepCallView.setNumberB(numberToCall);
    updateStateView(TwoStepCallUtils.STATE_INITIAL);
    mAnalyticsHelper.sendEvent(getString(R.string.analytics_event_category_call), getString(R.string.analytics_event_action_outbound), getString(R.string.analytics_event_label_connect_a_b));
    ((TextView) findViewById(R.id.name_text_view)).setText(numberToCall);
}
Also used : AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) TextView(android.widget.TextView) Api(com.voipgrid.vialer.api.Api) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) JsonStorage(com.voipgrid.vialer.util.JsonStorage) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 2 with AnalyticsApplication

use of com.voipgrid.vialer.analytics.AnalyticsApplication in project vialer-android by VoIPGRID.

the class DialerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dialer);
    // Set the AnalyticsHelper
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mJsonStorage = new JsonStorage(this);
    mConnectivityHelper = ConnectivityHelper.get(this);
    mReachabilityReceiver = new ReachabilityReceiver(this);
    mContactsListView = (ListView) findViewById(R.id.list_view);
    mEmptyView = (TextView) findViewById(R.id.message);
    mEmptyView.setText("");
    // This should be called before setupContactParts.
    setupKeypad();
    Intent intent = getIntent();
    String type = intent.getType();
    // Sadly HTC fails to include the mime-type in the intent in 4.4.2.
    Uri contactUri = intent.getData();
    mHasPermission = ContactsPermission.hasPermission(this);
    mAskForPermission = true;
    // Check for contact permissions before doing contact related work.
    if (mHasPermission) {
        // Handling this intent is only needed when we have contact permissions.
        // This should be called after setupKeyPad.
        setupContactParts();
        /**
         * The app added a "Vialer call <number>" to the native contacts app. clicking this
         * opens the app with the appname's profile and the data necessary for opening the app.
         */
        if ((!TextUtils.isEmpty(type) && type.equals(getString(R.string.profile_mimetype))) || contactUri != null) {
            // presses call with vialer in a contact.
            if (!mJsonStorage.has(SystemUser.class)) {
                startActivity(new Intent(this, SetupActivity.class));
                finish();
            }
            Cursor cursor = getContentResolver().query(contactUri, new String[] { ContactsContract.CommonDataKinds.StructuredName.PHONETIC_NAME, ContactsContract.Data.DATA3 }, null, null, null);
            cursor.moveToFirst();
            String number = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA3));
            mNumberInputView.setNumber(number);
            cursor.close();
        }
    } else {
        // Set the empty view for the contact list to inform the user this functionality will
        // not work.
        mEmptyView.setText(getString(R.string.permission_contact_dialer_list_message));
        mContactsListView.setEmptyView(mEmptyView);
    }
    // Make sure there is no keyboard popping up when pasting in the dialer input field.
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
Also used : ReachabilityReceiver(com.voipgrid.vialer.reachability.ReachabilityReceiver) AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) SetupActivity(com.voipgrid.vialer.onboarding.SetupActivity) SystemUser(com.voipgrid.vialer.api.models.SystemUser) Intent(android.content.Intent) JsonStorage(com.voipgrid.vialer.util.JsonStorage) Cursor(android.database.Cursor) Uri(android.net.Uri) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 3 with AnalyticsApplication

use of com.voipgrid.vialer.analytics.AnalyticsApplication in project vialer-android by VoIPGRID.

the class CallActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mRemoteLogger = new RemoteLogger(CallActivity.class).enableConsoleLogging();
    mRemoteLogger.d("onCreate");
    // Check if we have permission to use the microphone. If not, request it.
    if (!MicrophonePermission.hasPermission(this)) {
        MicrophonePermission.askForPermission(this);
    }
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    setContentView(R.layout.activity_call);
    // Fetch a broadcast manager for communication.
    mBroadcastManager = LocalBroadcastManager.getInstance(this);
    mNotificationHelper = NotificationHelper.getInstance(this);
    // Set the AnalyticsHelper.
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    mMediaManager = MediaManager.init(this, this, this);
    mProximityHelper = new ProximitySensorHelper(this, this, findViewById(R.id.screen_off));
    // Fetch a broadcast manager for communication to the sip service
    mBroadcastManager = LocalBroadcastManager.getInstance(this);
    mStateView = (TextView) findViewById(R.id.state_text_view);
    mCallDurationView = (TextView) findViewById(R.id.duration_text_view);
    mConnected = false;
    onCallStatesUpdateButtons(SERVICE_STOPPED);
    Intent intent = getIntent();
    // Get the intent to see if it's an outgoing or an incoming call.
    mType = intent.getType();
    if (mType.equals(TYPE_INCOMING_CALL) || mType.equals(TYPE_OUTGOING_CALL)) {
        // Update the textView with a number URI.
        mPhoneNumberToDisplay = intent.getStringExtra(PHONE_NUMBER);
        mCallerIdToDisplay = intent.getStringExtra(CONTACT_NAME);
        displayCallInfo();
        mIsIncomingCall = mType.equals(TYPE_INCOMING_CALL);
        Boolean openedFromNotification = intent.getBooleanExtra(NotificationHelper.TAG, false);
        if (openedFromNotification && !mIsIncomingCall) {
            mNotificationId = mNotificationHelper.displayCallProgressNotification(getCallerInfo(), getString(R.string.callnotification_active_call), TYPE_CONNECTED_CALL, mCallerIdToDisplay, mPhoneNumberToDisplay, NotificationHelper.mCallNotifyId);
            toggleCallStateButtonVisibility(TYPE_CONNECTED_CALL);
            // Keep timer running for as long as possible.
            mCallHandler.postDelayed(mCallDurationRunnable, 1000);
            mCallDurationView.setVisibility(View.VISIBLE);
        } else {
            toggleCallStateButtonVisibility(mType);
            if (mIsIncomingCall) {
                mRemoteLogger.d("inComingCall");
                mNotificationHelper.removeAllNotifications();
                mNotificationId = mNotificationHelper.displayCallProgressNotification(getCallerInfo(), getString(R.string.callnotification_incoming_call), mType, mCallerIdToDisplay, mPhoneNumberToDisplay, NotificationHelper.mCallNotifyId);
                // Ringing event.
                mAnalyticsHelper.sendEvent(getString(R.string.analytics_event_category_call), getString(R.string.analytics_event_action_inbound), getString(R.string.analytics_event_label_ringing));
                if (!ReadExternalStoragePermission.hasPermission(this)) {
                    ReadExternalStoragePermission.askForPermission(this);
                }
                mIncomingCallIsRinging = true;
                mMediaManager.startIncomingCallRinger();
            } else {
                mRemoteLogger.d("outgoingCall");
                mNotificationId = mNotificationHelper.displayCallProgressNotification(getCallerInfo(), getString(R.string.callnotification_dialing), mType, mCallerIdToDisplay, mPhoneNumberToDisplay, NotificationHelper.mCallNotifyId);
            }
        }
        mMediaManager.callStarted();
    }
    mProximityHelper.startSensor();
}
Also used : AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) Intent(android.content.Intent) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) ProximitySensorHelper(com.voipgrid.vialer.util.ProximitySensorHelper) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 4 with AnalyticsApplication

use of com.voipgrid.vialer.analytics.AnalyticsApplication in project vialer-android by VoIPGRID.

the class CallRecordFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /* set the AnalyticsHelper */
    mAnalyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getActivity().getApplication()).getDefaultTracker());
    mConnectivityHelper = ConnectivityHelper.get(getActivity());
    mJsonStorage = new JsonStorage(getActivity());
    mFilter = getArguments().getString(ARG_FILTER);
}
Also used : AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) JsonStorage(com.voipgrid.vialer.util.JsonStorage) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 5 with AnalyticsApplication

use of com.voipgrid.vialer.analytics.AnalyticsApplication in project vialer-android by VoIPGRID.

the class MiddlewareHelper method register.

public static void register(final Context context, String token) {
    Preferences sipPreferences = new Preferences(context);
    Tracker analyticsTracker = ((AnalyticsApplication) context.getApplicationContext()).getDefaultTracker();
    final AnalyticsHelper analyticsHelper = new AnalyticsHelper(analyticsTracker);
    if (!sipPreferences.canUseSip()) {
        return;
    }
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    final SharedPreferences.Editor editor = preferences.edit();
    editor.putLong(LAST_REGISTRATION, System.currentTimeMillis());
    JsonStorage jsonStorage = new JsonStorage(context);
    AccountHelper accountHelper = new AccountHelper(context);
    if (!jsonStorage.has(PhoneAccount.class)) {
        return;
    }
    Registration api = ServiceGenerator.createService(context, Registration.class, getBaseApiUrl(context), accountHelper.getEmail(), accountHelper.getPassword());
    String sipUserId = ((PhoneAccount) jsonStorage.get(PhoneAccount.class)).getAccountId();
    String fullName = ((SystemUser) jsonStorage.get(SystemUser.class)).getFullName();
    String appName = context.getPackageName();
    Call<ResponseBody> call = api.register(fullName, token, sipUserId, Build.VERSION.CODENAME, Build.VERSION.RELEASE, appName);
    editor.putString(CURRENT_TOKEN, token);
    call.enqueue(new Callback<ResponseBody>() {

        @Override
        public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) {
            if (response.isSuccessful()) {
                setRegistrationStatus(context, STATUS_REGISTERED);
            } else {
                setRegistrationStatus(context, STATUS_FAILED);
                analyticsHelper.sendException(context.getString(R.string.analytics_event_description_registration_failed));
            }
            editor.apply();
        }

        @Override
        public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
            t.printStackTrace();
            setRegistrationStatus(context, STATUS_FAILED);
        }
    });
}
Also used : Tracker(com.google.android.gms.analytics.Tracker) AccountHelper(com.voipgrid.vialer.util.AccountHelper) SharedPreferences(android.content.SharedPreferences) ResponseBody(okhttp3.ResponseBody) PhoneAccount(com.voipgrid.vialer.api.models.PhoneAccount) AnalyticsApplication(com.voipgrid.vialer.analytics.AnalyticsApplication) Registration(com.voipgrid.vialer.api.Registration) SystemUser(com.voipgrid.vialer.api.models.SystemUser) SharedPreferences(android.content.SharedPreferences) Preferences(com.voipgrid.vialer.Preferences) JsonStorage(com.voipgrid.vialer.util.JsonStorage) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Aggregations

AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)6 AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)6 JsonStorage (com.voipgrid.vialer.util.JsonStorage)4 Intent (android.content.Intent)2 SystemUser (com.voipgrid.vialer.api.models.SystemUser)2 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)2 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 TextView (android.widget.TextView)1 Tracker (com.google.android.gms.analytics.Tracker)1 Preferences (com.voipgrid.vialer.Preferences)1 Api (com.voipgrid.vialer.api.Api)1 Registration (com.voipgrid.vialer.api.Registration)1 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)1 SetupActivity (com.voipgrid.vialer.onboarding.SetupActivity)1 ReachabilityReceiver (com.voipgrid.vialer.reachability.ReachabilityReceiver)1 AccountHelper (com.voipgrid.vialer.util.AccountHelper)1 ProximitySensorHelper (com.voipgrid.vialer.util.ProximitySensorHelper)1 ResponseBody (okhttp3.ResponseBody)1