Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Commit

Permalink
removed extra spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
shikherjaiswal committed Sep 7, 2018
1 parent 86cfa63 commit a38143b
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,8 @@ public void onClick(View view) {
quantity.requestFocus();
} else {
//Entered Order quantity is greater than 0

if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.SEND_SMS)
!= PackageManager.PERMISSION_GRANTED) {

// Permission is not granted
// Ask for permission
ActivityCompat.requestPermissions(getActivity(),
Expand All @@ -172,24 +170,19 @@ public void onClick(View view) {
if(smsPermissionGranted) {
SmsManager smsManager = SmsManager.getDefault();
//Sms cannot parse html tags so remove them and use appropriate alternative

String message = (presenter.getMessageBodyForOrder() +Integer.parseInt(quantity.getText().toString())).toString();
String patternRegex = "<[/]*b>"; // To match <b> and </b>
message = message.replaceAll("<br>","\n");
message = message.replaceAll(patternRegex," ");
String phoneNo = "121";
smsManager.sendTextMessage(phoneNo, null,message, null, null);

Toast.makeText(getActivity(), "Message sent", Toast.LENGTH_LONG).show();
orderMedicineDialog.dismiss();

}
else{
//Show Toast message
Toast.makeText(getActivity(), "Cannot use this feature without Send SMS permission", Toast.LENGTH_LONG).show();
}


}
}
});
Expand Down Expand Up @@ -255,8 +248,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
{
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

if (requestCode == PERMISSIONS_REQUEST_SEND_SMS && grantResults.length >0 && grantResults[0] == PackageManager.PERMISSION_GRANTED )
{
if (requestCode == PERMISSIONS_REQUEST_SEND_SMS && grantResults.length >0 && grantResults[0] == PackageManager.PERMISSION_GRANTED ) {
smsPermissionGranted = true;
}
}
Expand Down

0 comments on commit a38143b

Please sign in to comment.