Skip to content

Commit

Permalink
Merge branch 'master' into vedant
Browse files Browse the repository at this point in the history
  • Loading branch information
banditAmit committed Jul 28, 2024
2 parents 18fd1f6 + c3e3c65 commit 1e43f1c
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/qaplug_profiles.xml

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

11 changes: 9 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@
<action android:name="com.BugBazaar.CUSTOMACT" />
</intent-filter>
</receiver>

<receiver
android:name=".BugBazaarAddress"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="bugbazaar.address_update"></action>
</intent-filter>
</receiver>
<service
android:name=".ui.components.SMSService"
android:enabled="true"
Expand All @@ -195,4 +202,4 @@
</service>
</application>

</manifest>
</manifest>
9 changes: 6 additions & 3 deletions app/src/main/java/com/BugBazaar/controller/UserAuthSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/com/BugBazaar/ui/Deeplink.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/BugBazaar/ui/Signin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
68 changes: 64 additions & 4 deletions app/src/main/java/com/BugBazaar/ui/addresses/Address.java
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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<AddressItem> 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);
Expand Down Expand Up @@ -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<ResolveInfo> 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
}



}
15 changes: 15 additions & 0 deletions app/src/main/java/com/BugBazaar/ui/addresses/AddressReceiver.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1e43f1c

Please sign in to comment.