Search in sources :

Example 1 with RemoteLogger

use of com.voipgrid.vialer.logging.RemoteLogger in project vialer-android by VoIPGRID.

the class AccountFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Bundle arguments = getArguments();
    if (arguments != null) {
        mMobileEditText = (EditText) view.findViewById(R.id.mobileNumberTextDialog);
        mMobileEditText.setText(arguments.getString(ARG_MOBILE));
        mMobileEditText.addTextChangedListener(this);
        mMobileEditText.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                final int DRAWABLE_RIGHT = 2;
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    if (event.getRawX() >= (mMobileEditText.getRight() - mMobileEditText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
                        mListener.onAlertDialog(getString(R.string.phonenumber_info_text_title), getString(R.string.phonenumber_info_text));
                        return true;
                    }
                }
                return false;
            }
        });
        mOutgoingEditText = (EditText) view.findViewById(R.id.outgoingNumberTextDialog);
        String outGoingNumber = arguments.getString(ARG_OUTGOING);
        // TODO Find a better solution for this (VIALA-575) in future.
        if (outGoingNumber == null || outGoingNumber.isEmpty()) {
            // Forced logging due to user not being able to set/unset it at this point.
            mRemoteLogger = new RemoteLogger(AccountFragment.class).forceRemoteLogging(true);
            mRemoteLogger.d("no outGoingNumber");
            SystemUser systemUser = (SystemUser) new JsonStorage(getActivity()).get(SystemUser.class);
            outGoingNumber = systemUser.getOutgoingCli();
        }
        // Sometimes the outgoing number is suppressed (anonymous), so we capture that here.
        if (outGoingNumber != null && outGoingNumber.equals(SUPPRESSED)) {
            outGoingNumber = getString(R.string.supressed_number);
        }
        mOutgoingEditText.setText(outGoingNumber);
        mOutgoingEditText.addTextChangedListener(this);
        mConfigureButton = (Button) view.findViewById(R.id.button_configure);
        mConfigureButton.setOnClickListener(this);
        // enable configure button when mobile number is available for the SystemUser
        if (mMobileEditText.getText().length() > 0) {
            mConfigureButton.setEnabled(true);
        }
    }
}
Also used : Bundle(android.os.Bundle) SystemUser(com.voipgrid.vialer.api.models.SystemUser) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) JsonStorage(com.voipgrid.vialer.util.JsonStorage) View(android.view.View) MotionEvent(android.view.MotionEvent)

Example 2 with RemoteLogger

use of com.voipgrid.vialer.logging.RemoteLogger in project vialer-android by VoIPGRID.

the class SetupActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setup);
    mJsonStorage = new JsonStorage(this);
    mPreferences = new Preferences(this);
    // Forced logging due to user not being able to set/unset it at this point.
    mRemoteLogger = new RemoteLogger(SetupActivity.class).forceRemoteLogging(true);
    Fragment gotoFragment = null;
    Integer fragmentId = null;
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        fragmentId = bundle.getInt("fragment");
        mActivityToReturnToName = bundle.getString("activity");
        if (fragmentId == R.id.fragment_voip_account_missing) {
            gotoFragment = ((SetUpVoipAccountFragment) getFragmentManager().findFragmentById(fragmentId)).newInstance();
        } else if (fragmentId == R.id.fragment_account) {
            SystemUser systemUser = (SystemUser) mJsonStorage.get(SystemUser.class);
            gotoFragment = ((AccountFragment) getFragmentManager().findFragmentById(fragmentId)).newInstance(systemUser.getMobileNumber(), systemUser.getOutgoingCli());
        }
    }
    if (findViewById(R.id.fragment_container) != null) {
        if (gotoFragment == null) {
            gotoFragment = LogoFragment.newInstance();
        }
        if (fragmentId != null && fragmentId == R.id.fragment_account) {
            swapFragment(gotoFragment, AccountFragment.class.getSimpleName());
        } else {
            swapFragment(gotoFragment, gotoFragment.getClass().getSimpleName());
        }
    }
}
Also used : Bundle(android.os.Bundle) SystemUser(com.voipgrid.vialer.api.models.SystemUser) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) JsonStorage(com.voipgrid.vialer.util.JsonStorage) Preferences(com.voipgrid.vialer.Preferences) Fragment(android.app.Fragment)

Example 3 with RemoteLogger

use of com.voipgrid.vialer.logging.RemoteLogger in project vialer-android by VoIPGRID.

the class ContactCursorLoader method populateMatrixCursor.

/**
 * Populate a MatrixCursor that is UI friendly with the matches found for the t9 query.
 * @param matches List of T9Match objects to be inserted into the MatrixCursor.
 */
void populateMatrixCursor(List<T9Match> matches) {
    // Create a mutable cursor to manipulate for search.
    if (mMatrixCursor == null) {
        mMatrixCursor = new MatrixCursor(new String[] { "_id", "name", "photo", "number", "type" });
    }
    T9Match match;
    boolean addResult;
    String displayName;
    String number;
    int type;
    String label;
    for (int i = 0; i < matches.size(); i++) {
        match = matches.get(i);
        displayName = match.getDisplayName();
        number = match.getNumber();
        type = match.getType();
        if (type == ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM) {
            label = match.getLabel();
        } else {
            label = ContactsContract.CommonDataKinds.Phone.getTypeLabel(mContext.getResources(), type, "").toString();
        }
        addResult = false;
        if (mT9Query.length() != 0) {
            // Only allowed T9 chars for name matching.
            if (mT9Query.substring(0, 1).matches("[2-9]")) {
                if (T9NameMatcher.T9QueryMatchesName(mT9Query, displayName)) {
                    addResult = true;
                    try {
                        displayName = T9NameMatcher.highlightMatchedPart(mT9Query, displayName);
                    } catch (Exception e) {
                        // TODO: Remove this piece of code if we find the bug. Until then
                        // force remote logging.
                        RemoteLogger logger = new RemoteLogger(ContactCursorLoader.class).forceRemoteLogging(true);
                        logger.e(e.getClass().getSimpleName());
                        logger.e("QUERY: " + mT9Query);
                        logger.e("DISPLAYNAME: " + displayName);
                        // Log displayname B64 encoded in case of formatting done by our logging.
                        logger.e("ENCODED DISPLAYNAME: " + Base64.encodeToString(displayName.getBytes(), 0));
                    // Displayname will be shown without highlighting.
                    }
                }
            }
            if (number != null) {
                if (number.startsWith("+")) {
                    if (("0" + number.substring(3)).startsWith(mT9Query)) {
                        addResult = true;
                        number = "<b>" + number.substring(0, mT9Query.length() + 2) + "</b>" + number.substring(mT9Query.length() + 2);
                    }
                }
                if (number.startsWith(mT9Query)) {
                    addResult = true;
                    number = "<b>" + number.substring(0, mT9Query.length()) + "</b>" + number.substring(mT9Query.length());
                }
            }
        } else {
            // No query so add all 20 results.
            addResult = true;
        }
        if (addResult) {
            mMatrixCursor.addRow(new Object[] { Long.toString(match.getContactId()), displayName, match.getThumbnailUri(), number, label });
        }
    }
}
Also used : RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) MatrixCursor(android.database.MatrixCursor)

Example 4 with RemoteLogger

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

use of com.voipgrid.vialer.logging.RemoteLogger in project vialer-android by VoIPGRID.

the class BluetoothMediaSessionService method onCreate.

@Override
public void onCreate() {
    mContext = this;
    mRemoteLogger = new RemoteLogger(BluetoothMediaSessionService.class).enableConsoleLogging();
    mRemoteLogger.v("onCreate()");
    MediaSessionCompat session = new MediaSessionCompat(this, TAG);
    PlaybackStateCompat.Builder stateBuilder = new PlaybackStateCompat.Builder();
    stateBuilder.setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS);
    stateBuilder.setState(PlaybackStateCompat.STATE_PLAYING, 0, 1);
    session.setPlaybackState(stateBuilder.build());
    session.setCallback(mSessionCallback);
    session.setFlags(MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS | MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS);
    session.setPlaybackToLocal(AudioManager.STREAM_VOICE_CALL);
    mSession = session;
}
Also used : PlaybackStateCompat(android.support.v4.media.session.PlaybackStateCompat) RemoteLogger(com.voipgrid.vialer.logging.RemoteLogger) MediaSessionCompat(android.support.v4.media.session.MediaSessionCompat)

Aggregations

RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)17 JsonStorage (com.voipgrid.vialer.util.JsonStorage)5 Bundle (android.os.Bundle)4 Preferences (com.voipgrid.vialer.Preferences)4 Intent (android.content.Intent)3 Account (android.accounts.Account)2 SharedPreferences (android.content.SharedPreferences)2 AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)2 AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)2 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)2 SystemUser (com.voipgrid.vialer.api.models.SystemUser)2 SetupActivity (com.voipgrid.vialer.onboarding.SetupActivity)2 AccountHelper (com.voipgrid.vialer.util.AccountHelper)2 Activity (android.app.Activity)1 Fragment (android.app.Fragment)1 IntentFilter (android.content.IntentFilter)1 MatrixCursor (android.database.MatrixCursor)1 Handler (android.os.Handler)1 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)1 PlaybackStateCompat (android.support.v4.media.session.PlaybackStateCompat)1