Search in sources :

Example 1 with AnalyticsHelper

use of com.voipgrid.vialer.analytics.AnalyticsHelper 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 AnalyticsHelper

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

the class CallRecordAdapter method onClick.

@Override
public void onClick(View view) {
    // Get the position of the list item the buttons is clicked for.
    View parentRow = (View) view.getParent();
    ListView listView = (ListView) parentRow.getParent();
    final int position = listView.getPositionForView(parentRow);
    // Get the call record.
    CallRecord callRecord = getItem(position);
    String direction = callRecord.getDirection();
    String numberToCall = null;
    // Determine direction and the number we need to call.
    if (direction.equals(CallRecord.DIRECTION_OUTBOUND)) {
        numberToCall = callRecord.getDialedNumber();
    } else if (direction.equals(CallRecord.DIRECTION_INBOUND)) {
        numberToCall = callRecord.getCaller();
    }
    if (numberToCall != null && !mCallAlreadySetup) {
        mCallAlreadySetup = true;
        new DialHelper(mActivity, new JsonStorage(mActivity), ConnectivityHelper.get(mActivity), new AnalyticsHelper(((AnalyticsApplication) mActivity.getApplication()).getDefaultTracker())).callNumber(numberToCall, "");
        PreferenceManager.getDefaultSharedPreferences(mActivity).edit().putString(DialerActivity.LAST_DIALED, numberToCall).apply();
    }
}
Also used : ListView(android.widget.ListView) DialHelper(com.voipgrid.vialer.util.DialHelper) JsonStorage(com.voipgrid.vialer.util.JsonStorage) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) CallRecord(com.voipgrid.vialer.api.models.CallRecord) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 3 with AnalyticsHelper

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

the class FcmMessagingService method onMessageReceived.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);
    mRemoteLogger.d("onMessageReceived");
    Map<String, String> data = remoteMessage.getData();
    String requestType = data.get(MESSAGE_TYPE);
    LogHelper.using(mRemoteLogger).logMiddlewareMessageReceived(remoteMessage, requestType);
    if (requestType == null) {
        mRemoteLogger.e("No requestType");
        return;
    }
    if (requestType.equals(CALL_REQUEST_TYPE)) {
        AnalyticsHelper analyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
        ConnectivityHelper connectivityHelper = ConnectivityHelper.get(this);
        mRemoteLogger.d("SipService Active: " + SipService.sipServiceActive);
        mRemoteLogger.d("CurrentConnection: " + connectivityHelper.getConnectionTypeString());
        mRemoteLogger.d("Payload: " + data.toString());
        boolean connectionSufficient = connectivityHelper.hasNetworkConnection() && connectivityHelper.hasFastData();
        // just return and don't reply to the middleware for now.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
            boolean isDeviceIdleMode = powerManager.isDeviceIdleMode();
            mRemoteLogger.d("is device in idle mode: " + isDeviceIdleMode);
            if (isDeviceIdleMode && !connectionSufficient) {
                mRemoteLogger.e("Device in idle mode and connection insufficient. For now do nothing wait for next middleware push.");
                return;
            }
        }
        if (!connectionSufficient) {
            mRemoteLogger.e("Connection is insufficient. For now do nothing and wait for next middleware push");
            return;
        }
        // fast enough to support VoIP call.
        if (!SipService.sipServiceActive) {
            String number = data.get(PHONE_NUMBER);
            // Is the current number suppressed.
            if (number != null && (number.equalsIgnoreCase(SUPPRESSED) || number.toLowerCase().contains("xxxx"))) {
                number = getString(R.string.supressed_number);
            }
            String callerId = data.get(CALLER_ID) != null ? data.get(CALLER_ID) : "";
            String responseUrl = data.get(RESPONSE_URL) != null ? data.get(RESPONSE_URL) : "";
            String requestToken = data.get(REQUEST_TOKEN) != null ? data.get(REQUEST_TOKEN) : "";
            String messageStartTime = data.get(MESSAGE_START_TIME) != null ? data.get(MESSAGE_START_TIME) : "";
            mRemoteLogger.d("Payload processed, calling startService method");
            // First start the SIP service with an incoming call.
            startSipService(number, callerId, responseUrl, requestToken, messageStartTime);
        } else {
            mRemoteLogger.d("Reject due to lack of connection");
            // Inform the middleware the incoming call is received but the app can not handle
            // the sip call because there is no LTE or Wifi connection available at this
            // point.
            String analyticsLabel = connectivityHelper.getAnalyticsLabel();
            analyticsHelper.sendEvent(getString(R.string.analytics_event_category_middleware), getString(R.string.analytics_event_action_middleware_rejected), analyticsLabel);
            replyServer(data.get(RESPONSE_URL) != null ? data.get(RESPONSE_URL) : "", data.get(REQUEST_TOKEN) != null ? data.get(REQUEST_TOKEN) : "", data.get(MESSAGE_START_TIME) != null ? data.get(MESSAGE_START_TIME) : "", false);
        }
    } else if (requestType.equals(MESSAGE_REQUEST_TYPE)) {
        mRemoteLogger.d("Code not implemented");
    // TODO implement this message.
    }
}
Also used : PowerManager(android.os.PowerManager) ConnectivityHelper(com.voipgrid.vialer.util.ConnectivityHelper) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Example 4 with AnalyticsHelper

use of com.voipgrid.vialer.analytics.AnalyticsHelper 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 5 with AnalyticsHelper

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

the class WebActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);
    // Set the Toolbar to use as ActionBar
    setSupportActionBar((Toolbar) findViewById(R.id.action_bar));
    // Set the Toolbar title
    getSupportActionBar().setTitle(getIntent().getStringExtra(TITLE));
    // Enabled home as up for the Toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Enabled home button for the Toolbar
    getSupportActionBar().setHomeButtonEnabled(true);
    // Get the ProgressBar
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    // Get the WebView.
    mWebView = (WebView) findViewById(R.id.web_view);
    // Enable javascript.
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    // Set webview client.
    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String url) {
            webView.loadUrl(url);
            return true;
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            mProgressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            mProgressBar.setVisibility(View.INVISIBLE);
            if (getIntent().getStringExtra(PAGE).equals(getString(R.string.web_password_change))) {
                final String js = "javascript:document.getElementById('id_username').value='" + getIntent().getStringExtra(USERNAME) + "';" + "document.getElementById('id_password').value='" + getIntent().getStringExtra(PASSWORD) + "';" + "document.forms[0].submit();";
                if (Build.VERSION.SDK_INT >= 19) {
                    view.evaluateJavascript(js, new ValueCallback<String>() {

                        @Override
                        public void onReceiveValue(String s) {
                        }
                    });
                } else {
                    view.loadUrl(js);
                }
            }
        }
    });
    String uri = getIntent().getStringExtra(PAGE);
    if (uri.startsWith("http")) {
        loadPage(uri);
    } else {
        // request an autologin token and load the requested page.
        autoLoginToken();
    }
    // Track the web view.
    AnalyticsHelper analyticsHelper = new AnalyticsHelper(((AnalyticsApplication) getApplication()).getDefaultTracker());
    analyticsHelper.sendScreenViewTrack(getIntent().getStringExtra(GA_TITLE));
}
Also used : ValueCallback(android.webkit.ValueCallback) Bitmap(android.graphics.Bitmap) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient) AnalyticsHelper(com.voipgrid.vialer.analytics.AnalyticsHelper)

Aggregations

AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)10 AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)6 JsonStorage (com.voipgrid.vialer.util.JsonStorage)5 Intent (android.content.Intent)3 TextView (android.widget.TextView)2 Registration (com.voipgrid.vialer.api.Registration)2 SystemUser (com.voipgrid.vialer.api.models.SystemUser)2 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)2 ResponseBody (okhttp3.ResponseBody)2 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 PowerManager (android.os.PowerManager)1 View (android.view.View)1 ValueCallback (android.webkit.ValueCallback)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ListView (android.widget.ListView)1 Tracker (com.google.android.gms.analytics.Tracker)1