Skip to content

Commit

Permalink
1. Refined Share Via SMS.
Browse files Browse the repository at this point in the history
  • Loading branch information
banditVedant committed Oct 3, 2023
1 parent 9157adf commit b6f4741
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -37,6 +38,11 @@ public void onBindViewHolder(ViewHolder holder, int position) {
// Set a background color or other UI indication for selected contacts
if (contact.isSelected()) {
holder.itemView.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.selected_contact_bg_color));

// Use a Handler to delay changing the background color back to TRANSPARENT
new Handler().postDelayed(() -> {
holder.itemView.setBackgroundColor(Color.TRANSPARENT);
}, 2000); // 5000 milliseconds (5 seconds)
} else {
holder.itemView.setBackgroundColor(Color.TRANSPARENT);
}
Expand All @@ -45,11 +51,21 @@ public void onBindViewHolder(ViewHolder holder, int position) {
holder.itemView.setOnClickListener(v -> {
// Update the selected contact
contact.setSelected(!contact.isSelected());
notifyItemChanged(position);
// Reset the background color of all contacts
for (Contacts c : contactsList) {
if (c != contact) {
c.setSelected(false);
}
}
notifyDataSetChanged();

// Check if the contact is selected
if (contact.isSelected()) {
// Open the SMS app with the selected contact and predefined SMS body
openSmsApp(holder.itemView.getContext(), contact.getPhoneNumber(), "ReferMee pls");
openSmsApp(holder.itemView.getContext(), contact.getPhoneNumber(), "Hey there, I'm using BugBazaar for all of my bug needs.\n" +
"Check out our new application and you will never have to go back to any other shopping app. \n\n" +
"BugBazaar!! for all your vulnerabilty needs!!");

}
});
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/BugBazaar/ui/ContactsPack/ReferUs.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public void onCopyLinkClick(View view){

public void openEmailApp(View view){
String emailSubject="Invitation to join Bugbazaar!!";
String emailContent="Hey there, you friend is using BugBazaar for all of his bugs needs. \n " +
"\nCheck it out our new application and you will never have to go back to any other shopping app. " +
"\n\nBugBazaar!! for all your vulnerabilty needs!!";
String emailContent="Hey there, I'm using BugBazaar for all of my bug needs. \n " +
"\nCheck out our new application and you will never have to go back to any other shopping app. " +
"\n\nBugBazaar!! for all your vulnerabilty needs!!.";
String emailAddress= edtEmailId.getText().toString();
Log.d("emailId",emailAddress);
//Creating Intent
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_account_box_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#2F4E6A"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,3H5C3.9,3 3,3.9 3,5v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5C21,3.9 20.1,3 19,3zM12,6c1.93,0 3.5,1.57 3.5,3.5c0,1.93 -1.57,3.5 -3.5,3.5s-3.5,-1.57 -3.5,-3.5C8.5,7.57 10.07,6 12,6zM19,19H5v-0.23c0,-0.62 0.28,-1.2 0.76,-1.58C7.47,15.82 9.64,15 12,15s4.53,0.82 6.24,2.19c0.48,0.38 0.76,0.97 0.76,1.58V19z"/>
</vector>
21 changes: 6 additions & 15 deletions app/src/main/res/layout/activity_select_contacts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,24 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select from Contacts"
android:text="Select any contact"
android:layout_gravity="center"
android:textStyle="bold"
android:paddingTop="10dp"
android:textSize="30dp"></TextView>
android:textColor="@color/main_theme"
android:textSize="35dp"></TextView>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
android:layout_gravity="left"
android:layout_marginLeft="30dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="16dp" />
</ScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<Button
android:id="@+id/btnSendSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
></Button>
</LinearLayout>

</LinearLayout>
19 changes: 17 additions & 2 deletions app/src/main/res/layout/contact_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,34 @@
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginRight="20dp"
android:src="@drawable/baseline_account_box_24"></ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/contactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="Contact-Name"
android:textColor="#000000" />

<TextView
android:id="@+id/contactNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="90921223456"
android:textColor="#555555" />

</LinearLayout>
</LinearLayout>
</LinearLayout>

0 comments on commit b6f4741

Please sign in to comment.