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

# Revert changes to NavigationDrawer_Dashboard deep link handling (ag… #42

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
35 changes: 8 additions & 27 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
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" />

<permission
android:name="com.BugBazaar.permission.contacts"
android:protectionLevel="signature" />

<queries>
<intent>
<action android:name="android.intent.action.PICK" />

<data android:mimeType="*/*" />
</intent>
</queries>

<application
android:allowBackup="true"
android:allowTaskReparenting="true"
Expand All @@ -38,6 +33,9 @@
tools:ignore="CustomPermissionTypo"
tools:replace="android:fullBackupContent"
tools:targetApi="31">
<activity
android:name=".ui.BaseActivity"
android:exported="false" />
<activity
android:name=".ui.RASPSettings"
android:exported="false" />
Expand All @@ -53,18 +51,6 @@
<activity
android:name=".ui.payment.OrderSummary"
android:exported="true" />
<activity
android:name=".ui.Wallet"
android:exported="true" />
<activity
android:name=".ui.myorders.OrderHistoryActivity"
android:exported="true" />
<activity
android:name=".ui.payment.OrderSummary"
android:exported="true" />
<activity
android:name=".ui.TestActivity"
android:exported="true" />
<activity
android:name=".ui.ContactsPack.SelectContacts"
android:exported="true" />
Expand All @@ -78,6 +64,9 @@
android:name=".ui.cart.Cart"
android:exported="false" />

<activity
android:name=".ui.SplashActivity"
android:exported="true" />
<provider
android:name=".provider.UserProfileProvider"
android:authorities="com.BugBazaar.UserProfile"
Expand All @@ -89,7 +78,6 @@
android:authorities="com.bugbazaar.mycontacts"
android:exported="true"
android:permission="com.BugBazaar.permission.contact" />

<activity
android:name=".ui.DetailedProductActivity"
android:exported="false" />
Expand All @@ -99,16 +87,14 @@
<activity
android:name=".ui.NavigationDrawer_Dashboard"
android:exported="true">

</activity>
<activity
android:name=".ui.MyProfile"
android:exported="true" />
<activity
android:name=".ui.TermsAndConditionsActivity"
android:exported="true" />
<activity
android:name=".ui.TermsOfService"
android:exported="false" />
<activity
android:name=".ui.Contact_us"
android:exported="true" />
Expand All @@ -118,23 +104,19 @@
<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>


<activity
android:name=".ui.Deeplink"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

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

<data
android:host="bugbazaar"
android:path="/cart/add"
Expand All @@ -157,5 +139,4 @@
</intent-filter>
</service>
</application>

</manifest>
83 changes: 24 additions & 59 deletions app/src/main/java/com/BugBazaar/ui/NavigationDrawer_Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ protected void onCreate(Bundle savedInstanceState) {

}

/////
// Rest of your activity initialization code

// Hide the keyboard and clear focus from the EditText
Expand All @@ -114,7 +113,7 @@ protected void onCreate(Bundle savedInstanceState) {

// product data
productList = new ArrayList<>();
productList.add(new Product("Old Town Camera",getString(R.string.desc_cycle), R.drawable.item_camera,2499));
productList.add(new Product("Old Town Camera",getString(R.string.desc_cycle), R.drawable.item_camera,3199));
productList.add(new Product("Dumb Watch", getString(R.string.desc_cycle), R.drawable.item_watch,2499));
productList.add(new Product("Skate-Board", getString(R.string.desc_cycle), R.drawable.item_skateboard,1659));
productList.add(new Product("A Lazy BiCycle", getString(R.string.desc_cycle), R.drawable.item_cycle,7049));
Expand All @@ -127,37 +126,28 @@ protected void onCreate(Bundle savedInstanceState) {
productList.add(new Product("Useless Trimmer", getString(R.string.desc_cycle), R.drawable.item_trimmer,799));




//
// boolean isItemPresent = false;
// Intent get_item = getIntent();
// if (get_item.hasExtra("fetched_item")) {
// // Retrieve the "fetched_item" string extra & Check if deeplink_item is present in the product list
// String deeplink_item = get_item.getStringExtra("fetched_item");
// for (Product product : productList) {
// if (product.getName().equals(deeplink_item)) {
// Log.d("Product found:", product.getName());
// Intent detailed_product = new Intent(this, DetailedProductActivity.class);
// detailed_product.putExtra("product", product);
// detailed_product.putExtra("autostart", true);
// this.startActivity(detailed_product);
// //Sending intent to CartItem class
// //Intent intToCartItem = new Intent(this, CartItem.class);
// //intToCartItem.putExtra("product", product);
// //this.startActivity(intToCartItem);
// break; // No need to continue searching if found
// }
// }
//
// }
//Handle Deeplink intent
Intent get_item = getIntent();
if (get_item.hasExtra("fetched_item")) {
// Check for the "fetched_item" string extra
String deeplink_item = get_item.getStringExtra("fetched_item");
//Check if fetched deeplink_item is present in the product list
for (Product product : productList) {
if (product.getName().equals(deeplink_item)) {
Log.d("Product found:", product.getName());
Intent detailed_product = new Intent(this, DetailedProductActivity.class);
detailed_product.putExtra("product", product);
detailed_product.putExtra("autostart", true);
this.startActivity(detailed_product);
break; // No need to continue searching if found
}
}
}

// Create and set the adapter for the GridView
ProductAdapter adapter = new ProductAdapter(this, productList);
productGridView.setAdapter(adapter);

//Handle Deeplink intent


//Adding onClickListener to search button
searchButton.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -270,11 +260,11 @@ else if (itemId == R.id.itemLoginButton) {
Intent intent = new Intent(NavigationDrawer_Dashboard.this, Signin.class);
startActivity(intent);
}else{
Intent intent = new Intent(NavigationDrawer_Dashboard.this, Signin.class);
intent.putExtra("isNavigatedhere",true);
startActivity(intent);
drawerLayout.closeDrawer(GravityCompat.START);
return true;}
Intent intent = new Intent(NavigationDrawer_Dashboard.this, Signin.class);
intent.putExtra("isNavigatedhere",true);
startActivity(intent);
drawerLayout.closeDrawer(GravityCompat.START);
return true;}
}else if (itemId == R.id.itemRASP_Settings){
Intent intent = new Intent(NavigationDrawer_Dashboard.this, RASPSettings.class);
startActivity(intent);
Expand Down Expand Up @@ -310,7 +300,7 @@ public void onDiscountCalculated(double discountedPrice) {
private void handleDiscountedPrice(double discountedPrice) {
double finalDiscount=discountedPrice*100;

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,new Intent(this,Signin.class),0);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,new Intent(this,Signin.class),PendingIntent.FLAG_MUTABLE);
// This is the first run, show your notification
AppInitializationManager.showNotification(this);

Expand Down Expand Up @@ -344,35 +334,10 @@ public void onBackPressed() {
finishAffinity();
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handledeeplink();



}

private void handledeeplink() {


Intent get_item = getIntent();
if (get_item.hasExtra("fetched_item")) {
// Check for the "fetched_item" string extra
String deeplink_item = get_item.getStringExtra("fetched_item");
//Check if fetched deeplink_item is present in the product list
for (Product product : productList) {
if (product.getName().equals(deeplink_item)) {
Log.d("Product found:", product.getName());
Intent detailed_product = new Intent(this, DetailedProductActivity.class);
detailed_product.putExtra("product", product);
detailed_product.putExtra("autostart", true);
this.startActivity(detailed_product);
break; // No need to continue searching if found
}
}
}


}
}
Loading