diff --git a/.idea/misc.xml b/.idea/misc.xml index 7d78d96..70efdb0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,12 +4,23 @@ + + + + + + + + + + + diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml new file mode 100644 index 0000000..07de02a --- /dev/null +++ b/.idea/qaplug_profiles.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ddf4e43..b235212 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -176,7 +176,14 @@ - + + + + + - \ No newline at end of file + diff --git a/app/src/main/java/com/BugBazaar/controller/UserAuthSave.java b/app/src/main/java/com/BugBazaar/controller/UserAuthSave.java index 10db807..2f2642e 100644 --- a/app/src/main/java/com/BugBazaar/controller/UserAuthSave.java +++ b/app/src/main/java/com/BugBazaar/controller/UserAuthSave.java @@ -16,14 +16,17 @@ public class UserAuthSave { private static SharedPreferences sharedPreferences1; private static final String keypasscode_flag = "passcode_flag"; + private static final String USER_DATA = "userCred"; private static SharedPreferences sharedPreferences; private SessionManager sessionManager; // Move the initialization to a constructor + private static SharedPreferences sharedPreferences1; - public UserAuthSave(Context context) { + public UserAuthSave(Context context) { sharedPreferences = context.getSharedPreferences(USER_PREFERENCES, Context.MODE_PRIVATE); - sessionManager = new SessionManager(context); - sharedPreferences1 = context.getSharedPreferences(USER_DATA, Context.MODE_PRIVATE);// Initialize SessionManager in the constructor + sessionManager = new SessionManager(context); // Initialize SessionManager in the constructor + sharedPreferences1 = context.getSharedPreferences(USER_DATA, Context.MODE_PRIVATE); + } public void saveUserData(String randomToken, boolean loggedIn) { diff --git a/app/src/main/java/com/BugBazaar/ui/Deeplink.java b/app/src/main/java/com/BugBazaar/ui/Deeplink.java index aa90833..590ef7e 100644 --- a/app/src/main/java/com/BugBazaar/ui/Deeplink.java +++ b/app/src/main/java/com/BugBazaar/ui/Deeplink.java @@ -51,9 +51,15 @@ public void onCreate(Bundle savedInstanceState) { // Deep link handling for msg if (deeplink != null && "/offers".equals(deeplink.getPath())) { String message = deeplink.getQueryParameter("textMsg"); - if (message != null) { + String offer = deeplink.getQueryParameter("offer"); + if (message != null && offer!=null) { messageTextView.setText(message); + Intent intentA = new Intent(this, NavigationDrawer_Dashboard.class); + intentA.setData(Uri.parse(offer)); + startActivity(intentA); } + + } // Deep link handling for url diff --git a/app/src/main/java/com/BugBazaar/ui/Signin.java b/app/src/main/java/com/BugBazaar/ui/Signin.java index 187b634..500114f 100644 --- a/app/src/main/java/com/BugBazaar/ui/Signin.java +++ b/app/src/main/java/com/BugBazaar/ui/Signin.java @@ -89,7 +89,9 @@ public void onClick(View v) { userAuthSave.saveUserData( randomToken,isLoggedin); userAuthSave.saveuserCred(username,password); sessionManager.setLoggedIn(true); + String randomToken = TokenGenerator.generateRandomToken(64); userAuthSave.saveUserData( randomToken,isLoggedin); + userAuthSave.saveuserCred(username,password); // Successful login, do something (e.g., start a new activity) Toast.makeText(Signin.this, "Login successful!", Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/BugBazaar/ui/addresses/Address.java b/app/src/main/java/com/BugBazaar/ui/addresses/Address.java index 6c656f2..597afd8 100644 --- a/app/src/main/java/com/BugBazaar/ui/addresses/Address.java +++ b/app/src/main/java/com/BugBazaar/ui/addresses/Address.java @@ -1,24 +1,56 @@ package com.BugBazaar.ui.addresses; - +import android.content.ComponentName; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.database.sqlite.SQLiteDatabase; +import android.database.Cursor; +import android.content.ContentValues; import android.content.Context; +import android.database.sqlite.SQLiteOpenHelper; import android.os.Bundle; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; import com.BugBazaar.R; import com.BugBazaar.ui.BaseActivity; +import com.BugBazaar.ui.SessionManager; +import com.BugBazaar.ui.Signin; import java.util.List; public class Address extends BaseActivity { + private SessionManager sessionManager; + private EditText editTextNewAddrNickName; + private EditText editTextNewAddress; + private EditText searchBoxEditText; + private Button btnSaveAddress; + private Button btnSearchAddress; + private LinearLayout addressListLayout; + private SQLiteDatabase database; + private AddressDatabaseHelper dbHelper; // Declare dbHelper here @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_address); + addressListLayout = findViewById(R.id.addressListLayout); + + /// + + + + + + /// + //Toolbar title set TextView toolbarTitle = findViewById(R.id.toolbarTitle); @@ -68,9 +100,10 @@ public void onClick(View v) { } else { addressListLayout.removeAllViews(); // Insert data into the SQLite database - dbHelper.insertAddress(nickname, address); + + sendacrosscomponents(nickname,address); List addresses = dbHelper.getAllAddresses(); - Toast.makeText(getApplicationContext(), "Address has been saved Successfully", Toast.LENGTH_SHORT).show(); + for (AddressItem item : addresses) { View customAddressView = inflater.inflate(R.layout.item_address, null); @@ -131,9 +164,36 @@ public void onClick(View v) { } }); } - //Code to handle backbutton + + private void sendacrosscomponents(String nickname, String address) { + Intent intent = new Intent("bugbazaar.address_update"); + intent.putExtra("nickname",nickname); + intent.putExtra("address",address); + sendImplicitBroadcast(this,intent); + } + + private static void sendImplicitBroadcast(Context ctxt, Intent i) { + PackageManager pm=ctxt.getPackageManager(); + List matches=pm.queryBroadcastReceivers(i, 0); + + for (ResolveInfo resolveInfo : matches) { + Intent explicit=new Intent(i); + ComponentName cn= + new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, + resolveInfo.activityInfo.name); + + explicit.setComponent(cn); + Log.d("test", String.valueOf(cn)); + ctxt.sendBroadcast(explicit); + } + } + + + //Code to handle backbutton public void onBackButtonClick(View view) { onBackPressed(); // Navigate back to the previous activity } + + } diff --git a/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java new file mode 100644 index 0000000..47e5377 --- /dev/null +++ b/app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java @@ -0,0 +1,15 @@ +package com.BugBazaar.ui.addresses; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; +import android.widget.Toast; + +public class AddressReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + + Toast.makeText(context.getApplicationContext(), "your address changed", Toast.LENGTH_SHORT).show(); + } +} diff --git a/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java b/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java index b7c7f8d..b211d0e 100644 --- a/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java +++ b/app/src/main/java/com/BugBazaar/ui/payment/OrderSummary.java @@ -63,6 +63,7 @@ protected void onCreate(Bundle savedInstanceState) { txtFinalCostOS = findViewById(R.id.txtFinalCostOS); btnProceedPaymentOS = findViewById(R.id.btnProceedPaymentOS); + // Retrieve all addresses from the AddressDB database addressDBHelper = new AddressDatabaseHelper(this); addressList = addressDBHelper.getAllAddresses();