| Chunk |
|---|
| Conflicting content |
|---|
launchAddMoneyView();
}
<<<<<<< HEAD
@Override
public void onResume() {
super.onResume();
tracker.trackPageView("AddMoneyActivity");
}
@Override
public void onPause() {
super.onPause();
}
=======
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
protected void launchAddMoneyView() {
setContentView(R.layout.money_amount_controller); |
| Solution content |
|---|
launchAddMoneyView();
}
@Override
public void onResume() {
super.onResume();
tracker.trackPageView("Amount");
}
protected void launchAddMoneyView() {
setContentView(R.layout.money_amount_controller); |
| File |
|---|
| AddMoneyActivity.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Annotation |
| Method declaration |
| Chunk |
|---|
| Conflicting content |
|---|
package me.pdthx; <<<<<<< HEAD ======= import android.content.pm.ActivityInfo; >>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010 import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; |
| Solution content |
|---|
package me.pdthx; import android.content.pm.ActivityInfo; import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; |
| File |
|---|
| BaseActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Import |
| Chunk |
|---|
| Conflicting content |
|---|
import android.view.MenuItem;
public class BaseActivity extends Activity {
<<<<<<< HEAD
public static final String TAG = "BaseActivity";
protected SharedPreferences prefs;
protected AlertDialog alertDialog;
protected ProgressDialog progressDialog;
protected Facebook facebook = new Facebook("332189543469634");
protected AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(
facebook);
protected static boolean signedInViaFacebook = false;
protected static ArrayList |
| Solution content |
|---|
import android.view.MenuItem;
public class BaseActivity extends Activity {
public static final String TAG = "BaseActivity";
protected SharedPreferences prefs;
protected AlertDialog alertDialog;
protected ProgressDialog progressDialog;
protected Facebook facebook = new Facebook("332189543469634");
facebook.getAccessToken());
protected AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(
facebook);
protected static boolean signedInViaFacebook = false;
protected static ArrayList |
| File |
|---|
| BaseActivity.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Annotation |
| Attribute |
| If statement |
| Method declaration |
| Method invocation |
| Method signature |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
public class ContactList {
<<<<<<< HEAD
private ArrayList |
| Solution content |
|---|
public class ContactList {
private ArrayList |
| File |
|---|
| ContactList.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Method declaration |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
package me.pdthx; <<<<<<< HEAD ======= import me.pdthx.helpers.PhoneNumberFormatter; import android.app.ProgressDialog; import android.provider.ContactsContract; import android.net.Uri; import java.io.InputStream; >>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010 import java.io.IOException; import java.net.URL; import java.util.ArrayList; |
| Solution content |
|---|
package me.pdthx; import me.pdthx.helpers.PhoneNumberFormatter; import android.app.ProgressDialog; import android.provider.ContactsContract; import android.net.Uri; import java.io.InputStream; import java.io.IOException; import java.net.URL; import java.util.ArrayList; |
| File |
|---|
| FriendsListActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Import |
| Chunk |
|---|
| Conflicting content |
|---|
public final class FriendsListActivity extends BaseActivity {
<<<<<<< HEAD
private ProgressDialog m_ProgressDialog = null;
private FriendAdapter m_adapter;
public static final String TAG = "FriendListActivity";
private ListView mListView = null;
private TextView mEmptyTextView = null;
private final static int SETFRIENDIMAGE = 1;
private static HashMap |
| Solution content |
|---|
public final class FriendsListActivity extends BaseActivity {
private FriendAdapter m_adapter;
public static final String TAG = "FriendListActivity";
private ListView mListView = null;
private TextView mEmptyTextView = null;
private final static int SETFRIENDIMAGE = 1;
private static HashMap |
| File |
|---|
| FriendsListActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Annotation |
| Attribute |
| Cast expression |
| If statement |
| Method declaration |
| Method invocation |
| Method signature |
| Chunk |
|---|
| Conflicting content |
|---|
for (int x = 0; x < friendsList.size(); x++) {
<<<<<<< HEAD
}
}
}
ArrayList |
| Solution content |
|---|
for (int x = 0; x < friendsList.size(); x++) {
Friend friend = friendsList.get(x);
if (friend.masterSearch(current.toLowerCase())) {
searched.add(friend);
}
}
if(searchBar.getText().toString().length() == 0)
{ |
| File |
|---|
| FriendsListActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Annotation |
| Attribute |
| For statement |
| If statement |
| Method declaration |
| Method invocation |
| Method signature |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
import java.text.NumberFormat; <<<<<<< HEAD import com.google.android.apps.analytics.GoogleAnalyticsTracker; import me.pdthx.Login.TabUIActivity; ======= >>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010 import me.pdthx.Requests.UserRequest; import me.pdthx.Responses.UserResponse; import me.pdthx.Services.UserService; |
| Solution content |
|---|
import java.text.NumberFormat; import me.pdthx.Requests.UserRequest; import me.pdthx.Responses.UserResponse; import me.pdthx.Services.UserService; |
| File |
|---|
| HomeActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Import |
| Chunk |
|---|
| Conflicting content |
|---|
@Override
public void onCreate(Bundle savedInstanceState) {
<<<<<<< HEAD
super.onCreate(savedInstanceState);
tracker.trackPageView("HomeActivity");
=======
super.onCreate(savedInstanceState);
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
if(prefs.getString("userId", "").length() == 0) {
startActivityForResult(new Intent(this, SignInActivity.class), 1); |
| Solution content |
|---|
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tracker.trackPageView("Home");
if(prefs.getString("userId", "").length() == 0) {
startActivityForResult(new Intent(this, SignInActivity.class), 1); |
| File |
|---|
| HomeActivity.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
import me.pdthx.helpers.PhoneNumberFormatter; public class Friend implements Comparable |
| Solution content |
|---|
public class Friend implements Comparable |
| File |
|---|
| Friend.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Annotation |
| Attribute |
| Method declaration |
| Chunk |
|---|
| Conflicting content |
|---|
@Override
public void afterTextChanged(Editable s) {
<<<<<<< HEAD
ArrayList |
| Solution content |
|---|
@Override
public void afterTextChanged(Editable s) {
ArrayList |
| File |
|---|
| PaystreamActivity.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Attribute |
| For statement |
| If statement |
| Method invocation |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
searched.clear();
for (int x = 0; x < recieve_transactions.size(); x++)
{
<<<<<<< HEAD
if(m_transactions.get(x).search(current))
{
searched.add(recieve_transactions.get(x));
}
}
if (searchBar.getText().toString().length() == 0) {
m_adapter = new PaystreamAdapter(PaystreamActivity.this,R.layout.transaction_item, recieve_transactions);
}
else {
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item, searched);
}
} else if (checked == 2131165313) {
searched.clear();
for (int x = 0; x < other_transactions.size(); x++)
{
if(other_transactions.get(x).search(current))
{
searched.add(other_transactions.get(x));
}
}
if (searchBar.getText().toString().length() == 0) {
m_adapter = new PaystreamAdapter(PaystreamActivity.this,R.layout.transaction_item, other_transactions);
}
else {
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item, searched);
}
=======
if(tempList.get(j).getRecipientUri().equals(searched.get(i)))
{
m_transactions.add(tempList.get(j));
break;
}
}
}
if(searchBar.getText().toString().length() == 0)
{
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item,
transactionsList);
m_transactions.clear();
}
else
{
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item,
m_transactions);
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
}
|
| Solution content |
|---|
searched.clear();
for (int x = 0; x < recieve_transactions.size(); x++)
{
if(m_transactions.get(x).search(current))
{
searched.add(recieve_transactions.get(x));
}
}
if (searchBar.getText().toString().length() == 0) {
m_adapter = new PaystreamAdapter(PaystreamActivity.this,R.layout.transaction_item, recieve_transactions);
}
else {
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item, searched);
}
} else if (checked == 2131165313) {
searched.clear();
for (int x = 0; x < other_transactions.size(); x++)
{
if(other_transactions.get(x).search(current))
{
searched.add(other_transactions.get(x));
}
}
if (searchBar.getText().toString().length() == 0) {
m_adapter = new PaystreamAdapter(PaystreamActivity.this,R.layout.transaction_item, other_transactions);
}
else {
m_adapter = new PaystreamAdapter(PaystreamActivity.this, R.layout.transaction_item, searched);
}
}
|
| File |
|---|
| PaystreamActivity.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Attribute |
| For statement |
| If statement |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
@Override
public void onTextChanged(CharSequence s, int start, int before,
<<<<<<< HEAD
int count) {
=======
int count)
{
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
}
|
| Solution content |
|---|
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
|
| File |
|---|
| PaystreamActivity.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
<<<<<<< HEAD
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tracker.trackPageView("ProfileSetupActivity");
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
=======
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
showProfileSetup();
} |
| Solution content |
|---|
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tracker.trackPageView("ProfileSetupActivity");
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
showProfileSetup();
} |
| File |
|---|
| ProfileSetupActivity.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
startActivityForResult(new Intent(RequestPaymentActivity.this, AddMoneyActivity.class), ADD_MONEY);
}
});
<<<<<<< HEAD
btnCamera = (Button) findViewById(R.id.camera);
btnCamera.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
startActivityForResult(new Intent(RequestPaymentActivity.this, CameraActivity.class), CAMERA);
}
});
=======
// txtAmount.addTextChangedListener(new TextWatcher() {
// String current = "";
//
// @Override
// public void onTextChanged(CharSequence s, int start, int before,
// int count) {
// if (!s.toString().equals(current)) {
// EditText txtAmount = (EditText) findViewById(R.id.txtRequestMoneyAmount);
// txtAmount.removeTextChangedListener(this);
//
// String cleanString = s.toString().replaceAll("[$,.]", "");
//
// double parsed = Double.parseDouble(cleanString);
// String formatted = NumberFormat.getCurrencyInstance()
// .format((parsed / 100));
//
// current = formatted;
// txtAmount.setText(formatted);
// txtAmount.setSelection(formatted.length());
//
// txtAmount.addTextChangedListener(this);
// }
// }
//
// @Override
// public void afterTextChanged(Editable arg0) {
// if (arg0.length() == 14) {
// arg0.replace(13, 14, "");
// }
// }
//
// @Override
// public void beforeTextChanged(CharSequence arg0, int arg1,
// int arg2, int arg3) {
//
// }
// });
//
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
btnAddContacts = (Button) findViewById(R.id.addRecipient);
btnAddContacts.setOnClickListener(new OnClickListener(){
|
| Solution content |
|---|
startActivityForResult(new Intent(RequestPaymentActivity.this, AddMoneyActivity.class), ADD_MONEY);
}
});
btnCamera = (Button) findViewById(R.id.camera);
btnCamera.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
startActivityForResult(new Intent(RequestPaymentActivity.this, CameraActivity.class), CAMERA);
}
});
btnAddContacts = (Button) findViewById(R.id.addRecipient);
btnAddContacts.setOnClickListener(new OnClickListener(){
|
| File |
|---|
| RequestPaymentActivity.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Attribute |
| Cast expression |
| Comment |
| Method invocation |
| Chunk |
|---|
| Conflicting content |
|---|
}
if (resultCode == RESULT_OK) {
if (requestCode == ADDING_FRIEND) {
Bundle bundle = data.getExtras();
<<<<<<< HEAD
Friend pickedFriend = new Friend();
pickedFriend.setId(bundle.getString("contact_id"));
if (!pickedFriend.getId().equals("")) {
friend = friendsList.get(friendsList.indexOf(pickedFriend));
if (friend.getType().equals("Facebook")) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPhoneNumber();
btnAddContacts.setText(friend.getName() + ": " + friend.getPhoneNumber());
}
}
=======
if (bundle.getString("id") != null)
{
Friend chosenContact = new Friend();
chosenContact.setId(bundle.getString("id"));
friend = friendsList.get(friendsList.indexOf(chosenContact));
if (friend.isFBContact()) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
else
{
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
}
else if(requestCode == ADD_MONEY){
Bundle bundle = data.getExtras(); |
| Solution content |
|---|
if (resultCode == RESULT_OK) {
if (requestCode == ADDING_FRIEND) {
Bundle bundle = data.getExtras();
if (bundle.getString("id") != null)
{
Friend chosenContact = new Friend();
chosenContact.setId(bundle.getString("id"));
friend = friendsList.get(friendsList.indexOf(chosenContact));
if (friend.isFBContact()) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
}
else
{
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
}
else if(requestCode == ADD_MONEY){
Bundle bundle = data.getExtras(); |
| File |
|---|
| RequestPaymentActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| If statement |
| Method invocation |
| Variable |
| Chunk |
|---|
| Conflicting content |
|---|
private String comments = "";
private String errorMessage = "";
<<<<<<< HEAD
private Location location;
private LocationManager locationManager;
private LocationListener locationListener;
private Friend friend;
=======
private Location location;
private LocationManager locationManager;
private LocationListener locationListener;
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
private Friend friend;
|
| Solution content |
|---|
private String comments = "";
private String errorMessage = "";
private Location location;
private LocationManager locationManager;
private LocationListener locationListener;
private Friend friend;
|
| File |
|---|
| SendPaymentActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Attribute |
| Chunk |
|---|
| Conflicting content |
|---|
}
<<<<<<< HEAD
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
tracker.trackPageView("/SendPaymentActivity");
setTitle("Send Money");
=======
}
};
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
@Override
public void onCreate(Bundle savedInstanceState) { |
| Solution content |
|---|
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) { |
| File |
|---|
| SendPaymentActivity.java |
| Developer's decision |
|---|
| Version 2 |
| Kind of conflict |
|---|
| Annotation |
| Method invocation |
| Method signature |
| Chunk |
|---|
| Conflicting content |
|---|
launchSendMoneyView();
<<<<<<< HEAD
@Override
public void onResume() {
super.onResume();
tracker.trackPageView("/SendPaymentActivity");
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, locationListener);
// locationManager.requestLocationUpdates(
// LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
@Override
public void onPause() {
super.onPause();
locationManager.removeUpdates(locationListener);
}
protected android.app.Dialog onCreateDialog(int id) {
AlertDialog alertDialog = null;
ProgressDialog progressDialog = null;
Thread thread = null;
switch (id) {
case SUBMITPAYMENT_DIALOG:
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Submitting Request...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
thread = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
SubmitPaymentRequest();
} catch (Exception e) {
e.printStackTrace();
}
dialogHandler.sendEmptyMessage(SUBMITPAYMENT_ACTION);
}
});
dialog = progressDialog;
thread.start();
return dialog;
case SUBMITPAYMENTFAILED_DIALOG:
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Failed");
alertDialog.setMessage(errorMessage);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case SUBMITPAYMENTSUCCESS_DIALOG:
return true;
friend = friendsList.get(friendsList.indexOf(pickedFriend));
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Payment Sumitted");
NumberFormat nf = NumberFormat.getCurrencyInstance();
alertDialog.setMessage(String.format(
"Your payment for %s was sent to %s.", nf.format(amount),
recipientUri));
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeDialog(4);
dialog.dismiss();
friend = null;
btnAddContacts.setText("Add recipient");
txtAmount.setText("$0.00");
txtComments.setText("");
}
});
return alertDialog;
case NORECIPIENTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify a Recipient");
alertDialog
.setMessage("You must specify the recipient's mobile number.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case NOAMOUNTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify an Amount");
alertDialog.setMessage("You must specify the amount to send.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case INVALIDPASSCODELENGTH_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Invalid Passcode");
alertDialog
.setMessage("Your passcode is atleast 4 buttons. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case PAYMENTEXCEEDSLIMIT_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Exceeds Limit");
alertDialog
.setMessage("The payment exceeds your upper limit. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
}
return null;
}
protected void launchSendMoneyView() {
sendMoneyView = View.inflate(this, R.layout.contactmanager, null);
setContentView(sendMoneyView);
btnAddContacts = (Button) findViewById(R.id.addRecipient);
txtAmount = (Button) findViewById(R.id.btnAmount);
txtComments = (EditText) findViewById(R.id.txtComments);
btnSendMoney = (Button) findViewById(R.id.btnSubmitPaymentRequest);
Typeface type = Typeface.createFromAsset(getAssets(),"HelveticaWorld-Bold.ttf");
btnSendMoney.setTypeface(type);
btnSendMoney.setTextColor(Color.WHITE);
txtAmount.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
if (friend.getType().equals("Facebook")) {
startActivityForResult(new Intent(SendPaymentActivity.this, AddMoneyActivity.class), ADD_MONEY);
}
});
btnAddContacts.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivityForResult(new Intent(SendPaymentActivity.this, FriendsListActivity.class), ADDING_FRIEND);
}
});
// txtAmount.addTextChangedListener(new TextWatcher() {
// String current = "";
//
// @Override
// public void onTextChanged(CharSequence s, int start, int before,
// int count) {
// if (!s.toString().equals(current)) {
// txtAmount.removeTextChangedListener(this);
//
// String cleanString = s.toString().replaceAll("[$,.]", "");
//
// double parsed = Double.parseDouble(cleanString);
// String formatted = NumberFormat.getCurrencyInstance()
// .format((parsed / 100));
//
// current = formatted;
// txtAmount.setText(formatted);
// txtAmount.setSelection(formatted.length());
//
// txtAmount.addTextChangedListener(this);
// }
// }
//
// @Override
// public void afterTextChanged(Editable arg0) {
// // TODO Auto-generated method stub
// if (arg0.length() == 14) {
// arg0.replace(13, 14, "");
// }
// }
//
// @Override
// public void beforeTextChanged(CharSequence arg0, int arg1,
// int arg2, int arg3) {
// // TODO Auto-generated method stub
//
// }
// });
btnSendMoney.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
boolean isValid = true;
amount = Double.parseDouble(txtAmount.getText().toString().trim()
.replaceAll("[$,]*", ""));
comments = txtComments.getText().toString();
if (isValid && recipientUri.length() == 0) {
showDialog(NORECIPIENTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount == 0) {
showDialog(NOAMOUNTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount > prefs.getInt("upperLimit", 0)) {
showDialog(PAYMENTEXCEEDSLIMIT_DIALOG);
isValid = false;
}
if (isValid) {
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (isBetterLocation(lastKnownLocation, location)) {
location = lastKnownLocation;
}
if(prefs.getString("userId", "").length() == 0) {
startActivityForResult(new Intent(SendPaymentActivity.this, SignInActivity.class), 1);
} else {
showSecurityPinDialog();
}
}
}
});
btnSendMoney.setVisibility(View.VISIBLE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == ADDING_FRIEND) {
Bundle bundle = data.getExtras();
Friend pickedFriend = new Friend();
pickedFriend.setId(bundle.getString("contact_id"));
if (!pickedFriend.getId().equals("")) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPhoneNumber();
btnAddContacts.setText(friend.getName() + ": " + friend.getPhoneNumber());
}
}
}
else if(requestCode == ADD_MONEY){
Bundle bundle = data.getExtras();
String amount = bundle.getString("index");
txtAmount.setText(amount);
}
else {
launchSendMoneyView();
}
}
else {
if (requestCode != ADDING_FRIEND && requestCode != ADD_MONEY) {
finish();
}
}
}
protected void showSecurityPinDialog() {
final Dialog d = new Dialog(SendPaymentActivity.this, R.style.CustomDialogTheme);
d.setContentView(R.layout.security_dialog);
d.getWindow().setLayout(400, 600);
d.show();
TextView txtConfirmHeader = (TextView)d.findViewById(R.id.txtConfirmHeader);
TextView txtConfirmBody = (TextView)d.findViewById(R.id.txtConfirmBody);
txtConfirmHeader.setText("Confirm Your Payment");
txtConfirmBody.setText(String.format("To confirm your payment of %s to %s, swipe you pin below.",
txtAmount.getText(), friend.getName()));
Button btnCancel = (Button) d.findViewById(R.id.btnCancelSendMoney);
btnCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
d.dismiss();
}
});
final CustomLockView ctrlSecurityPin = (CustomLockView) d.findViewById(R.id.ctrlSecurityPin);
ctrlSecurityPin.invalidate();
ctrlSecurityPin.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
passcode = ctrlSecurityPin.getPasscode();
if (passcode.length() > 3) {
amount = Double.parseDouble(txtAmount.getText().toString()
.replace("$", ""));
comments = txtComments.getText().toString();
passcode = ctrlSecurityPin.getPasscode();
d.dismiss();
showDialog(SUBMITPAYMENT_DIALOG);
} else
showDialog(INVALIDPASSCODELENGTH_DIALOG);
return false;
}
});
}
protected void SubmitPaymentRequest() {
PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.UserId = prefs.getString("userId", "");
paymentRequest.SecurityPin = passcode;
paymentRequest.SenderUri = prefs.getString("login", "");
paymentRequest.RecipientUri = recipientUri;
paymentRequest.Amount = amount;
paymentRequest.Comments = comments;
paymentRequest.SenderAccountId = prefs.getString("paymentAccountId", "0");
if (location != null) {
paymentRequest.Latitude = location.getLatitude();
paymentRequest.Longitude = location.getLongitude();
}
paymentResponse = PaymentServices.sendMoney(paymentRequest);
}
/** Determines whether one Location reading is better than the current Location fix
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/
private boolean isBetterLocation(Location location, Location currentBestLocation) {
final int TWO_MINUTES = 1000 * 60 * 2;
if (location != null) {
if (currentBestLocation == null) {
// A new location is always better than no location
}
// Check whether the new location fix is newer or older
long timeDelta = location.getTime() - currentBestLocation.getTime();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
boolean isNewer = timeDelta > 0;
// If it's been more than two minutes since the current location, use the new location
// because the user has likely moved
if (isSignificantlyNewer) {
return true;
// If the new location is more than two minutes older, it must be worse
} else if (isSignificantlyOlder) {
return false;
}
// Check whether the new location fix is more or less accurate
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
boolean isLessAccurate = accuracyDelta > 0;
boolean isMoreAccurate = accuracyDelta < 0;
boolean isSignificantlyLessAccurate = accuracyDelta > 200;
// Check if the old and new location are from the same provider
boolean isFromSameProvider = isSameProvider(location.getProvider(),
currentBestLocation.getProvider());
// Determine location quality using a combination of timeliness and accuracy
if (isMoreAccurate) {
return true;
} else if (isNewer && !isLessAccurate) {
return true;
} else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
return true;
}
}
return false;
}
/** Checks whether two providers are the same */
private boolean isSameProvider(String provider1, String provider2) {
if (provider1 == null) {
return provider2 == null;
}
return provider1.equals(provider2);
}
=======
}
@Override
public void onResume() {
super.onResume();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, locationListener);
// locationManager.requestLocationUpdates(
// LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
@Override
public void onPause() {
super.onPause();
locationManager.removeUpdates(locationListener);
}
protected android.app.Dialog onCreateDialog(int id) {
AlertDialog alertDialog = null;
ProgressDialog progressDialog = null;
Thread thread = null;
switch (id) {
case SUBMITPAYMENT_DIALOG:
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Submitting Request...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
thread = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
SubmitPaymentRequest();
} catch (Exception e) {
e.printStackTrace();
}
dialogHandler.sendEmptyMessage(SUBMITPAYMENT_ACTION);
}
});
dialog = progressDialog;
thread.start();
return dialog;
case SUBMITPAYMENTFAILED_DIALOG:
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Failed");
alertDialog.setMessage(errorMessage);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case SUBMITPAYMENTSUCCESS_DIALOG:
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Payment Sumitted");
NumberFormat nf = NumberFormat.getCurrencyInstance();
alertDialog.setMessage(String.format(
"Your payment for %s was sent to %s.", nf.format(amount),
recipientUri));
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeDialog(4);
dialog.dismiss();
friend = null;
btnAddContacts.setText("Add recipient");
txtAmount.setText("$0.00");
txtComments.setText("");
}
});
return alertDialog;
case NORECIPIENTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify a Recipient");
alertDialog
.setMessage("You must specify the recipient's mobile number.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case NOAMOUNTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify an Amount");
alertDialog.setMessage("You must specify the amount to send.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case INVALIDPASSCODELENGTH_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Invalid Passcode");
alertDialog
.setMessage("Your passcode is atleast 4 buttons. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case PAYMENTEXCEEDSLIMIT_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Exceeds Limit");
alertDialog
.setMessage("The payment exceeds your upper limit. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
}
return null;
}
protected void launchSendMoneyView() {
sendMoneyView = View.inflate(this, R.layout.contactmanager, null);
setContentView(sendMoneyView);
btnAddContacts = (Button) findViewById(R.id.addRecipient);
txtAmount = (Button) findViewById(R.id.btnAmount);
txtComments = (EditText) findViewById(R.id.txtComments);
btnSendMoney = (Button) findViewById(R.id.btnSubmitPaymentRequest);
Typeface type = Typeface.createFromAsset(getAssets(),"HelveticaWorld-Bold.ttf");
btnSendMoney.setTypeface(type);
btnSendMoney.setTextColor(Color.WHITE);
txtAmount.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivityForResult(new Intent(SendPaymentActivity.this, AddMoneyActivity.class), ADD_MONEY);
}
});
btnAddContacts.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivityForResult(new Intent(SendPaymentActivity.this, FriendsListActivity.class), ADDING_FRIEND);
}
});
// txtAmount.addTextChangedListener(new TextWatcher() {
// String current = "";
//
// @Override
// public void onTextChanged(CharSequence s, int start, int before,
// int count) {
// if (!s.toString().equals(current)) {
// txtAmount.removeTextChangedListener(this);
//
// String cleanString = s.toString().replaceAll("[$,.]", "");
//
// double parsed = Double.parseDouble(cleanString);
// String formatted = NumberFormat.getCurrencyInstance()
// .format((parsed / 100));
//
// current = formatted;
// txtAmount.setText(formatted);
// txtAmount.setSelection(formatted.length());
//
// txtAmount.addTextChangedListener(this);
// }
// }
//
// @Override
// public void afterTextChanged(Editable arg0) {
// // TODO Auto-generated method stub
// if (arg0.length() == 14) {
// arg0.replace(13, 14, "");
// }
// }
//
// @Override
// public void beforeTextChanged(CharSequence arg0, int arg1,
// int arg2, int arg3) {
// // TODO Auto-generated method stub
//
// }
// });
btnSendMoney.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
boolean isValid = true;
amount = Double.parseDouble(txtAmount.getText().toString().trim()
.replaceAll("[$,]*", ""));
comments = txtComments.getText().toString();
if (isValid && recipientUri.length() == 0) {
showDialog(NORECIPIENTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount == 0) {
showDialog(NOAMOUNTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount > prefs.getInt("upperLimit", 0)) {
showDialog(PAYMENTEXCEEDSLIMIT_DIALOG);
isValid = false;
}
if (isValid) {
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (isBetterLocation(lastKnownLocation, location)) {
location = lastKnownLocation;
}
if(prefs.getString("userId", "").length() == 0) {
startActivityForResult(new Intent(SendPaymentActivity.this, SignInActivity.class), 1);
} else {
showSecurityPinDialog();
}
}
}
});
btnSendMoney.setVisibility(View.VISIBLE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == ADDING_FRIEND) {
Bundle bundle = data.getExtras();
Friend chosenContact = new Friend();
if (bundle.getString("id") != null)
{
chosenContact.setId(bundle.getString("id"));
friend = friendsList.get(friendsList.indexOf(chosenContact));
if (friend.isFBContact()) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
}
else
{
String paypoint = bundle.getString("paypoint");
chosenContact.setName("New Contact");
chosenContact.setPaypoint(paypoint);
friend = chosenContact;
recipientUri = "" + paypoint;
btnAddContacts.setText("New contact: " + paypoint);
}
}
else if(requestCode == ADD_MONEY){
Bundle bundle = data.getExtras();
String amount = bundle.getString("index");
txtAmount.setText("$"+ amount);
}
else {
launchSendMoneyView();
}
}
else {
if (requestCode != ADDING_FRIEND && requestCode != ADD_MONEY) {
finish();
}
}
}
protected void showSecurityPinDialog() {
final Dialog d = new Dialog(SendPaymentActivity.this, R.style.CustomDialogTheme);
d.setContentView(R.layout.security_dialog);
d.getWindow().setLayout(400, 600);
d.show();
TextView txtConfirmHeader = (TextView)d.findViewById(R.id.txtConfirmHeader);
TextView txtConfirmBody = (TextView)d.findViewById(R.id.txtConfirmBody);
txtConfirmHeader.setText("Confirm Your Payment");
txtConfirmBody.setText(String.format("To confirm your payment of %s to %s, swipe you pin below.",
txtAmount.getText(), friend.getName()));
Button btnCancel = (Button) d.findViewById(R.id.btnCancelSendMoney);
btnCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
d.dismiss();
}
});
final CustomLockView ctrlSecurityPin = (CustomLockView) d.findViewById(R.id.ctrlSecurityPin);
ctrlSecurityPin.invalidate();
ctrlSecurityPin.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
passcode = ctrlSecurityPin.getPasscode();
if (passcode.length() > 3) {
amount = Double.parseDouble(txtAmount.getText().toString()
.replace("$", ""));
comments = txtComments.getText().toString();
passcode = ctrlSecurityPin.getPasscode();
d.dismiss();
showDialog(SUBMITPAYMENT_DIALOG);
} else
showDialog(INVALIDPASSCODELENGTH_DIALOG);
return false;
}
});
}
protected void SubmitPaymentRequest() {
PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.UserId = prefs.getString("userId", "");
paymentRequest.SecurityPin = passcode;
paymentRequest.SenderUri = prefs.getString("login", "");
paymentRequest.RecipientUri = recipientUri;
paymentRequest.Amount = amount;
paymentRequest.Comments = comments;
paymentRequest.SenderAccountId = prefs.getString("paymentAccountId", "0");
if (location != null) {
paymentRequest.Latitude = location.getLatitude();
paymentRequest.Longitude = location.getLongitude();
}
paymentResponse = PaymentServices.sendMoney(paymentRequest);
}
/** Determines whether one Location reading is better than the current Location fix
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/
private boolean isBetterLocation(Location location, Location currentBestLocation) {
final int TWO_MINUTES = 1000 * 60 * 2;
if (location != null) {
if (currentBestLocation == null) {
// A new location is always better than no location
return true;
}
// Check whether the new location fix is newer or older
long timeDelta = location.getTime() - currentBestLocation.getTime();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
boolean isNewer = timeDelta > 0;
// If it's been more than two minutes since the current location, use the new location
// because the user has likely moved
if (isSignificantlyNewer) {
return true;
// If the new location is more than two minutes older, it must be worse
} else if (isSignificantlyOlder) {
return false;
}
// Check whether the new location fix is more or less accurate
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
boolean isLessAccurate = accuracyDelta > 0;
boolean isMoreAccurate = accuracyDelta < 0;
boolean isSignificantlyLessAccurate = accuracyDelta > 200;
// Check if the old and new location are from the same provider
boolean isFromSameProvider = isSameProvider(location.getProvider(),
currentBestLocation.getProvider());
// Determine location quality using a combination of timeliness and accuracy
if (isMoreAccurate) {
return true;
} else if (isNewer && !isLessAccurate) {
return true;
} else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
return true;
}
}
return false;
}
/** Checks whether two providers are the same */
private boolean isSameProvider(String provider1, String provider2) {
if (provider1 == null) {
return provider2 == null;
}
return provider1.equals(provider2);
}
>>>>>>> 31a4072af63868cb5dc09a90683f893d7dca6010
} |
| Solution content |
|---|
launchSendMoneyView();
}
@Override
public void onResume() {
super.onResume();
tracker.trackPageView("Send Money");
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0, locationListener);
// locationManager.requestLocationUpdates(
// LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
@Override
public void onPause() {
super.onPause();
locationManager.removeUpdates(locationListener);
}
protected android.app.Dialog onCreateDialog(int id) {
AlertDialog alertDialog = null;
ProgressDialog progressDialog = null;
Thread thread = null;
switch (id) {
case SUBMITPAYMENT_DIALOG:
tracker.trackPageView("Send Money: Confirm");
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Submitting Request...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
thread = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
SubmitPaymentRequest();
} catch (Exception e) {
e.printStackTrace();
}
dialogHandler.sendEmptyMessage(SUBMITPAYMENT_ACTION);
}
});
dialog = progressDialog;
thread.start();
return dialog;
case SUBMITPAYMENTFAILED_DIALOG:
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Failed");
alertDialog.setMessage(errorMessage);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case SUBMITPAYMENTSUCCESS_DIALOG:
tracker.trackPageView("Send Money: Completed");
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Payment Sumitted");
NumberFormat nf = NumberFormat.getCurrencyInstance();
alertDialog.setMessage(String.format(
"Your payment for %s was sent to %s.", nf.format(amount),
recipientUri));
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
removeDialog(4);
dialog.dismiss();
friend = null;
btnAddContacts.setText("Add recipient");
txtAmount.setText("$0.00");
txtComments.setText("");
}
});
return alertDialog;
case NORECIPIENTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify a Recipient");
alertDialog
.setMessage("You must specify the recipient's mobile number.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case NOAMOUNTSPECIFIED_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Please Specify an Amount");
alertDialog.setMessage("You must specify the amount to send.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case INVALIDPASSCODELENGTH_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Invalid Passcode");
alertDialog
.setMessage("Your passcode is atleast 4 buttons. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
case PAYMENTEXCEEDSLIMIT_DIALOG:
alertDialog = new AlertDialog.Builder(SendPaymentActivity.this)
.create();
alertDialog.setTitle("Exceeds Limit");
alertDialog
.setMessage("The payment exceeds your upper limit. Please try again.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return alertDialog;
}
return null;
}
protected void launchSendMoneyView() {
sendMoneyView = View.inflate(this, R.layout.contactmanager, null);
setContentView(sendMoneyView);
btnAddContacts = (Button) findViewById(R.id.addRecipient);
txtAmount = (Button) findViewById(R.id.btnAmount);
txtComments = (EditText) findViewById(R.id.txtComments);
btnSendMoney = (Button) findViewById(R.id.btnSubmitPaymentRequest);
Typeface type = Typeface.createFromAsset(getAssets(),"HelveticaWorld-Bold.ttf");
btnSendMoney.setTypeface(type);
btnSendMoney.setTextColor(Color.WHITE);
txtAmount.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivityForResult(new Intent(SendPaymentActivity.this, AddMoneyActivity.class), ADD_MONEY);
}
});
btnAddContacts.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
startActivityForResult(new Intent(SendPaymentActivity.this, FriendsListActivity.class), ADDING_FRIEND);
}
});
btnSendMoney.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
boolean isValid = true;
amount = Double.parseDouble(txtAmount.getText().toString().trim()
.replaceAll("[$,]*", ""));
comments = txtComments.getText().toString();
if (isValid && recipientUri.length() == 0) {
showDialog(NORECIPIENTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount == 0) {
showDialog(NOAMOUNTSPECIFIED_DIALOG);
isValid = false;
}
if (isValid && amount > prefs.getInt("upperLimit", 0)) {
showDialog(PAYMENTEXCEEDSLIMIT_DIALOG);
isValid = false;
}
if (isValid) {
Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (isBetterLocation(lastKnownLocation, location)) {
location = lastKnownLocation;
}
if(prefs.getString("userId", "").length() == 0) {
startActivityForResult(new Intent(SendPaymentActivity.this, SignInActivity.class), 1);
} else {
showSecurityPinDialog();
}
}
}
});
btnSendMoney.setVisibility(View.VISIBLE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == ADDING_FRIEND) {
Bundle bundle = data.getExtras();
Friend chosenContact = new Friend();
if (bundle.getString("id") != null)
{
chosenContact.setId(bundle.getString("id"));
friend = friendsList.get(friendsList.indexOf(chosenContact));
if (friend.isFBContact()) {
recipientUri = "fb_" + friend.getId();
btnAddContacts.setText(friend.getName() + ": " + friend.getId());
}
else {
recipientUri = "" + friend.getPaypoint();
btnAddContacts.setText(friend.toString());
}
}
else
{
String paypoint = bundle.getString("paypoint");
chosenContact.setName("New Contact");
chosenContact.setPaypoint(paypoint);
friend = chosenContact;
recipientUri = "" + paypoint;
btnAddContacts.setText("New contact: " + paypoint);
}
}
else if(requestCode == ADD_MONEY){
Bundle bundle = data.getExtras();
String amount = bundle.getString("index");
txtAmount.setText("$"+ amount);
}
else {
launchSendMoneyView();
}
}
else {
if (requestCode != ADDING_FRIEND && requestCode != ADD_MONEY) {
finish();
}
}
}
protected void showSecurityPinDialog() {
final Dialog d = new Dialog(SendPaymentActivity.this, R.style.CustomDialogTheme);
d.setContentView(R.layout.security_dialog);
d.getWindow().setLayout(400, 600);
d.show();
TextView txtConfirmHeader = (TextView)d.findViewById(R.id.txtConfirmHeader);
TextView txtConfirmBody = (TextView)d.findViewById(R.id.txtConfirmBody);
txtConfirmHeader.setText("Confirm Your Payment");
txtConfirmBody.setText(String.format("To confirm your payment of %s to %s, swipe you pin below.",
txtAmount.getText(), friend.getName()));
Button btnCancel = (Button) d.findViewById(R.id.btnCancelSendMoney);
btnCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
d.dismiss();
}
});
final CustomLockView ctrlSecurityPin = (CustomLockView) d.findViewById(R.id.ctrlSecurityPin);
ctrlSecurityPin.invalidate();
ctrlSecurityPin.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
passcode = ctrlSecurityPin.getPasscode();
if (passcode.length() > 3) {
amount = Double.parseDouble(txtAmount.getText().toString()
.replace("$", ""));
comments = txtComments.getText().toString();
passcode = ctrlSecurityPin.getPasscode();
d.dismiss();
showDialog(SUBMITPAYMENT_DIALOG);
} else
showDialog(INVALIDPASSCODELENGTH_DIALOG);
return false;
}
});
}
protected void SubmitPaymentRequest() {
PaymentRequest paymentRequest = new PaymentRequest();
paymentRequest.UserId = prefs.getString("userId", "");
paymentRequest.SecurityPin = passcode;
paymentRequest.SenderUri = prefs.getString("login", "");
paymentRequest.RecipientUri = recipientUri;
paymentRequest.Amount = amount;
paymentRequest.Comments = comments;
paymentRequest.SenderAccountId = prefs.getString("paymentAccountId", "0");
if (location != null) {
paymentRequest.Latitude = location.getLatitude();
paymentRequest.Longitude = location.getLongitude();
}
paymentResponse = PaymentServices.sendMoney(paymentRequest);
}
/** Determines whether one Location reading is better than the current Location fix
* @param location The new Location that you want to evaluate
* @param currentBestLocation The current Location fix, to which you want to compare the new one
*/
private boolean isBetterLocation(Location location, Location currentBestLocation) {
final int TWO_MINUTES = 1000 * 60 * 2;
if (location != null) {
if (currentBestLocation == null) {
// A new location is always better than no location
return true;
}
// Check whether the new location fix is newer or older
long timeDelta = location.getTime() - currentBestLocation.getTime();
boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
boolean isNewer = timeDelta > 0;
// If it's been more than two minutes since the current location, use the new location
// because the user has likely moved
if (isSignificantlyNewer) {
return true;
// If the new location is more than two minutes older, it must be worse
} else if (isSignificantlyOlder) {
return false;
}
// Check whether the new location fix is more or less accurate
int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
boolean isLessAccurate = accuracyDelta > 0;
boolean isMoreAccurate = accuracyDelta < 0;
boolean isSignificantlyLessAccurate = accuracyDelta > 200;
// Check if the old and new location are from the same provider
boolean isFromSameProvider = isSameProvider(location.getProvider(),
currentBestLocation.getProvider());
// Determine location quality using a combination of timeliness and accuracy
if (isMoreAccurate) {
return true;
} else if (isNewer && !isLessAccurate) {
return true;
} else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
return true;
}
}
return false;
}
/** Checks whether two providers are the same */
private boolean isSameProvider(String provider1, String provider2) {
if (provider1 == null) {
return provider2 == null;
}
return provider1.equals(provider2);
}
} |
| File |
|---|
| SendPaymentActivity.java |
| Developer's decision |
|---|
| Manual |
| Kind of conflict |
|---|
| Annotation |
| Comment |
| Method declaration |