From 265dbdd43f18c5938d192df54e33e4b230792e3d Mon Sep 17 00:00:00 2001 From: vjprakash Date: Wed, 16 May 2018 22:48:31 +0530 Subject: [PATCH] Call button added instead of textview for phone number --- .../ui/home/view/HomeActivity.java | 18 +++++++- app/src/main/res/drawable/ic_call.xml | 11 +++++ app/src/main/res/layout/donor_sheet.xml | 46 +++++++++---------- app/src/main/res/layout/receiver_sheet.xml | 9 ++-- 4 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 app/src/main/res/drawable/ic_call.xml diff --git a/app/src/main/java/com/udacity/nanodegree/blooddonation/ui/home/view/HomeActivity.java b/app/src/main/java/com/udacity/nanodegree/blooddonation/ui/home/view/HomeActivity.java index 68a36c3..0e8e4ee 100644 --- a/app/src/main/java/com/udacity/nanodegree/blooddonation/ui/home/view/HomeActivity.java +++ b/app/src/main/java/com/udacity/nanodegree/blooddonation/ui/home/view/HomeActivity.java @@ -120,6 +120,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); }); + (mDonorSheet.findViewById(R.id.phone)).setOnClickListener(view -> { + String phoneNum = (String) view.getTag(); + Uri dialIntentUri = Uri.parse("tel:"+phoneNum); + Intent dialIntent = new Intent(Intent.ACTION_DIAL, dialIntentUri); + dialIntent.setData(dialIntentUri); + startActivity(dialIntent); + }); + (mReceiver.findViewById(R.id.phone)).setOnClickListener(view -> { + String phoneNum = (String) view.getTag(); + Uri dialIntentUri = Uri.parse("tel:"+phoneNum); + Intent dialIntent = new Intent(Intent.ACTION_DIAL, dialIntentUri); + dialIntent.setData(dialIntentUri); + startActivity(dialIntent); + }); } @Override @@ -321,14 +335,14 @@ public boolean onMarkerClick(Marker marker) { if (marker.getTitle().contains(getString(R.string.donor))) { ((TextView) mDonorSheet.findViewById(R.id.name)).setText(mReceiverDonorRequestType.getfName() + " " + mReceiverDonorRequestType.getlName()); ((TextView) mDonorSheet.findViewById(R.id.blood_group)).setText(mReceiverDonorRequestType.getbGp()); - ((TextView) mDonorSheet.findViewById(R.id.phone)).setText(mReceiverDonorRequestType.getPhone()); + (mDonorSheet.findViewById(R.id.phone)).setTag(mReceiverDonorRequestType.getPhone()); ((TextView) mDonorSheet.findViewById(R.id.purpose)).setText(mReceiverDonorRequestType.getPurpose()); (mDonorSheet.findViewById(R.id.direction)).setTag(mReceiverDonorRequestType.getLocation()); toggleBottomSheet(donorBehavior, receiverBehaviour); } else if (marker.getTitle().contains(getString(R.string.blood_request))) { ((TextView) mReceiver.findViewById(R.id.name)).setText(mReceiverDonorRequestType.getfName() + " " + mReceiverDonorRequestType.getlName()); ((TextView) mReceiver.findViewById(R.id.blood_group)).setText(mReceiverDonorRequestType.getbGp()); - ((TextView) mReceiver.findViewById(R.id.phone)).setText(mReceiverDonorRequestType.getPhone()); + (mReceiver.findViewById(R.id.phone)).setTag(mReceiverDonorRequestType.getPhone()); ((TextView) mReceiver.findViewById(R.id.purpose)).setText(mReceiverDonorRequestType.getPurpose()); (mReceiver.findViewById(R.id.direction)).setTag(mReceiverDonorRequestType.getLocation()); toggleBottomSheet(receiverBehaviour, donorBehavior); diff --git a/app/src/main/res/drawable/ic_call.xml b/app/src/main/res/drawable/ic_call.xml new file mode 100644 index 0000000..90cb897 --- /dev/null +++ b/app/src/main/res/drawable/ic_call.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/donor_sheet.xml b/app/src/main/res/layout/donor_sheet.xml index bbe5aaf..5a371a3 100644 --- a/app/src/main/res/layout/donor_sheet.xml +++ b/app/src/main/res/layout/donor_sheet.xml @@ -8,14 +8,16 @@ android:orientation="vertical" app:behavior_hideable="true" app:behavior_peekHeight="56dp" - app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> + app:layout_behavior="android.support.design.widget.BottomSheetBehavior" + > + > - + android:textStyle="bold" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> - - + android:layout_alignParentEnd="true" />