From ae3f1caffca0638a5205508992fba298bb111400 Mon Sep 17 00:00:00 2001 From: BanditAmit Date: Sun, 28 Jul 2024 17:34:28 +0530 Subject: [PATCH] Offer handling in deeplink --- .../main/java/com/BugBazaar/ui/Deeplink.java | 50 +++++++++++-------- .../ui/addresses/AddressReceiver.java | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/BugBazaar/ui/Deeplink.java b/app/src/main/java/com/BugBazaar/ui/Deeplink.java index 0d4526d..590ef7e 100644 --- a/app/src/main/java/com/BugBazaar/ui/Deeplink.java +++ b/app/src/main/java/com/BugBazaar/ui/Deeplink.java @@ -17,13 +17,22 @@ public class Deeplink extends AppCompatActivity { //private List products; WebView webView; + TextView messageTextView; + TextView toolbarTitle; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_deep_link); + + // Toolbar title set + TextView toolbarTitle = findViewById(R.id.toolbarTitle); + toolbarTitle.setText("DeepLink"); + + messageTextView= findViewById(R.id.messageTextView); Intent intent = getIntent(); Uri deeplink = intent.getData(); + toolbarTitle = findViewById(R.id.toolbarTitle); // Deep link handling for item if (deeplink != null && "/cart/add".equals(deeplink.getPath())) { @@ -41,44 +50,45 @@ public void onCreate(Bundle savedInstanceState) { // Deep link handling for msg if (deeplink != null && "/offers".equals(deeplink.getPath())) { - String message = deeplink.getQueryParameter("msg"); - if (message != null) { - // Display the message, e.g., in a TextView - TextView toolbarTitle = findViewById(R.id.toolbarTitle); - toolbarTitle.setText("Offers"); - TextView messageTextView = findViewById(R.id.messageTextView); + String message = deeplink.getQueryParameter("textMsg"); + String offer = deeplink.getQueryParameter("offer"); + if (message != null && offer!=null) { messageTextView.setText(message); - } else { - TextView toolbarTitle = findViewById(R.id.toolbarTitle); - toolbarTitle.setText("Offers"); - TextView messageTextView = findViewById(R.id.messageTextView); - messageTextView.setText("Coming Soon...............!"); + Intent intentA = new Intent(this, NavigationDrawer_Dashboard.class); + intentA.setData(Uri.parse(offer)); + startActivity(intentA); } + + } // Deep link handling for url if (deeplink != null && "/web".equals(deeplink.getPath())) { - String webViewUrl = deeplink.getQueryParameter("url"); + String webViewUrl = deeplink.getQueryParameter("urlToLoad"); // Check if the "url" parameter contains "payatu.com" if (webViewUrl != null && webViewUrl.contains("payatu.com")) { - TextView toolbarTitle = findViewById(R.id.toolbarTitle); - toolbarTitle.setText("BugBazaar"); + webView = findViewById(R.id.deeplink_view); setupwebview(webView); this.webView.loadUrl(webViewUrl); + messageTextView.setVisibility(View.GONE); + } + else{ + messageTextView.setText("Host is invalid."); } } } - //Code to handle back button - Redirect to home page on back pressed - public void onBackButtonClick (View view){ - // onBackPressed(); // Navigate back to the previous activity - Intent backtohome = new Intent(this, NavigationDrawer_Dashboard.class); - startActivity(backtohome); - } + //Code to handle back button - Redirect to home page on back pressed + private void setupwebview (WebView webView){ webView.setWebViewClient(new WebViewClient()); webView.setWebChromeClient(new WebChromeClient()); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setAllowUniversalAccessFromFileURLs(true); } + public void onBackButtonClick (View view){ + // onBackPressed(); // Navigate back to the previous activity + Intent backtohome = new Intent(this, NavigationDrawer_Dashboard.class); + startActivity(backtohome); } +} \ No newline at end of file diff --git a/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java index 5dd9819..47e5377 100644 --- a/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java +++ b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java @@ -10,6 +10,6 @@ public class AddressReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Toast.makeText(context.getApplicationContext(), "address hacker changes", Toast.LENGTH_SHORT).show(); + Toast.makeText(context.getApplicationContext(), "your address changed", Toast.LENGTH_SHORT).show(); } }