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);
}
}
}
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);
}
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());
}
}
}
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);
}
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();
}
}
Aggregations