Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amit #21

Merged
merged 15 commits into from
Oct 10, 2023
Merged

Amit #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ android {
dependencies {
implementation 'com.google.firebase:firebase-storage-ktx:20.2.1'
implementation 'com.google.firebase:firebase-common:20.3.3'
implementation 'com.google.firebase:firebase-inappmessaging-display:20.2.0'
implementation 'com.google.firebase:firebase-messaging:23.1.0'
releaseImplementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Expand Down
41 changes: 31 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS"> </uses-permission>
<permission android:name="com.BugBazaar.permission.contacts" android:protectionLevel="signature"/>

<queries>
<intent>
Expand All @@ -29,9 +32,13 @@
android:theme="@style/Theme.BugBazaar"
android:usesCleartextTraffic="true"
tools:replace="android:fullBackupContent"
tools:targetApi="31">
tools:targetApi="31"
tools:ignore="CustomPermissionTypo">
<activity
android:name=".ui.ReferUs"
android:name=".ui.ContactsPack.SelectContacts"
android:exported="true" />
<activity
android:name=".ui.ContactsPack.ReferUs"
android:exported="true" />
<activity
android:name=".ui.cart.CartActivity"
Expand All @@ -46,27 +53,32 @@
android:enabled="true"
android:exported="true"
android:readPermission="@string/app_name" />
<provider
android:name=".provider.MyContactsProvider"
android:authorities="com.bugbazaar.mycontacts"
android:permission="com.BugBazaar.permission.contact"
android:exported="true" />

<activity
android:name=".ui.DetailedProductActivity"
android:exported="false" />
<activity
android:name=".ui.CreatePasscode"
android:exported="true" >
</activity>

android:exported="true" />
<activity
android:name=".ui.NavigationDrawer_Dashboard"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />

<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="bugbazaar"
android:scheme="bb"
android:pathPrefix="/dashboard">
</data>
android:pathPrefix="/dashboard"
android:scheme="bb" />
</intent-filter>
</activity>
<activity
Expand All @@ -87,9 +99,10 @@
<activity
android:name=".ui.Signin"
android:clearTaskOnLaunch="true"
android:exported="true" >
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -109,6 +122,14 @@
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<service
android:name=".MyFirebaseInstanceIDService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>

</application>

</manifest>
15 changes: 15 additions & 0 deletions app/src/main/java/com/BugBazaar/MyFirebaseInstanceIDService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.BugBazaar;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

import androidx.annotation.Nullable;

public class MyFirebaseInstanceIDService extends Service {
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
2 changes: 2 additions & 0 deletions app/src/main/java/com/BugBazaar/controller/UserAuthSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static void savepasscode(int passcode) {
editor.apply();
}



public static String getSavedUsername() {
return sharedPreferences.getString(KEY_USERNAME, "");
}
Expand Down
56 changes: 56 additions & 0 deletions app/src/main/java/com/BugBazaar/provider/MyContactsProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.BugBazaar.provider;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;

public class MyContactsProvider extends ContentProvider {
// Define your authority and content URI
public static final String AUTHORITY = "com.bugbazaar.mycontacts";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts");

@Override
public boolean onCreate() {
// Initialize your database or data source here
// Return true if initialization is successful
return true;
}

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

// Query the ContactsContract to retrieve all contacts
return getContext().getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
projection,
selection,
selectionArgs,
sortOrder
);
}

@Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}

@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
// Implement update operation if needed
return 0;
}

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
// Implement delete operation if needed
return 0;
}

@Override
public String getType(Uri uri) {
return null;
}
}
101 changes: 101 additions & 0 deletions app/src/main/java/com/BugBazaar/ui/ContactsPack/ContactAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.BugBazaar.ui.ContactsPack;
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;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.BugBazaar.R;
import java.util.List;

public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ViewHolder> {
private List<Contacts> contactsList;

public ContactAdapter(List<Contacts> contactsList) {
this.contactsList = contactsList;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.contact_item, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Contacts contact = contactsList.get(position);

holder.contactName.setText(contact.getName());
holder.contactNumber.setText(contact.getPhoneNumber());

// 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);
}

// Handle item click to toggle contact selection
holder.itemView.setOnClickListener(v -> {
// Update the selected contact
contact.setSelected(!contact.isSelected());
// 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(), "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!!");

}
});
}

@Override
public int getItemCount() {
return contactsList.size();
}

private void openSmsApp(android.content.Context context, String phoneNumber, String smsBody) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("smsto:" + phoneNumber)); // Set the recipient phone number
intent.putExtra("sms_body", smsBody); // Set the SMS body

if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent); // Start the SMS app
} else {
// Handle the case where there is no SMS app installed
Toast.makeText(context, "No SMS app found.", Toast.LENGTH_SHORT).show();
}
}

public class ViewHolder extends RecyclerView.ViewHolder {
public TextView contactName;
public TextView contactNumber;

public ViewHolder(View itemView) {
super(itemView);
contactName = itemView.findViewById(R.id.contactName);
contactNumber = itemView.findViewById(R.id.contactNumber);
}
}
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/BugBazaar/ui/ContactsPack/Contacts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.BugBazaar.ui.ContactsPack;

public class Contacts {
private String name;
private String phoneNumber;
private boolean isSelected;

public Contacts(String name, String phoneNumber) {
this.name = name;
this.phoneNumber = phoneNumber;
this.isSelected = false; // Initialize isSelected to false by default
}

public String getName() {
return name;
}

public String getPhoneNumber() {
return phoneNumber;
}

public boolean isSelected() {
return isSelected;
}

public void setSelected(boolean selected) {
isSelected = selected;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.BugBazaar.ui;
package com.BugBazaar.ui.ContactsPack;

import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -15,11 +15,13 @@
import android.widget.Toast;

import com.BugBazaar.R;
import com.BugBazaar.ui.ContactsPack.SelectContacts;

public class ReferUs extends AppCompatActivity {

Button btnCopyLink;
Button btnSendEmail;
Button openContactButton;
EditText edtEmailId;
ClipboardManager clipboardManager;

Expand All @@ -35,6 +37,7 @@ protected void onCreate(Bundle savedInstanceState) {
clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
btnSendEmail=findViewById(R.id.btnSendEmail);
edtEmailId=findViewById(R.id.edtEmailId);
openContactButton=findViewById(R.id.openContactButton);

}
public void onCopyLinkClick(View view){
Expand All @@ -47,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 All @@ -62,6 +65,11 @@ public void openEmailApp(View view){
startActivity(Intent.createChooser(iEMail, "Email via: "));
edtEmailId.setText("");
}
public void openSelectContacts(View view){

Intent intent=new Intent(this, SelectContacts.class);
startActivity(intent);
}


//Code to handle backbutton
Expand Down
Loading
Loading