Search in sources :

Example 1 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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 JsonStorage

use of com.voipgrid.vialer.util.JsonStorage in project vialer-android by VoIPGRID.

the class SetUpVoipAccountFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mContext = getActivity().getApplicationContext();
    mJsonStorage = new JsonStorage(mContext);
    mAccountHelper = new AccountHelper(mContext);
    mSystemUser = (SystemUser) mJsonStorage.get(SystemUser.class);
    mApi = ServiceGenerator.createService(getActivity(), Api.class, getString(R.string.api_url), mAccountHelper.getEmail(), mAccountHelper.getPassword());
    mVoipAccountButton = (Button) view.findViewById(R.id.set_voip_account_button);
    mVoipAccountButton.setOnClickListener(this);
    mCancelButton = (Button) view.findViewById(R.id.cancel_set_voip_account_button);
    mCancelButton.setOnClickListener(this);
}
Also used : AccountHelper(com.voipgrid.vialer.util.AccountHelper) Api(com.voipgrid.vialer.api.Api) JsonStorage(com.voipgrid.vialer.util.JsonStorage)

Example 3 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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 4 with JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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 JsonStorage

use of com.voipgrid.vialer.util.JsonStorage 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)

Aggregations

JsonStorage (com.voipgrid.vialer.util.JsonStorage)14 SystemUser (com.voipgrid.vialer.api.models.SystemUser)6 AnalyticsHelper (com.voipgrid.vialer.analytics.AnalyticsHelper)5 RemoteLogger (com.voipgrid.vialer.logging.RemoteLogger)5 AnalyticsApplication (com.voipgrid.vialer.analytics.AnalyticsApplication)4 AccountHelper (com.voipgrid.vialer.util.AccountHelper)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Preferences (com.voipgrid.vialer.Preferences)3 Api (com.voipgrid.vialer.api.Api)3 SetupActivity (com.voipgrid.vialer.onboarding.SetupActivity)3 SharedPreferences (android.content.SharedPreferences)2 View (android.view.View)2 TextView (android.widget.TextView)2 Registration (com.voipgrid.vialer.api.Registration)2 PhoneAccount (com.voipgrid.vialer.api.models.PhoneAccount)2 ReachabilityReceiver (com.voipgrid.vialer.reachability.ReachabilityReceiver)2 ConnectivityHelper (com.voipgrid.vialer.util.ConnectivityHelper)2 PhoneAccountHelper (com.voipgrid.vialer.util.PhoneAccountHelper)2 ResponseBody (okhttp3.ResponseBody)2