Skip to content

Commit

Permalink
Fixed: A lot of things
Browse files Browse the repository at this point in the history
  • Loading branch information
shvmsaini committed Sep 25, 2021
1 parent 2fdbde2 commit 2a5b813
Show file tree
Hide file tree
Showing 14 changed files with 426 additions and 221 deletions.
123 changes: 123 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

4 changes: 2 additions & 2 deletions .idea/misc.xml

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

65 changes: 51 additions & 14 deletions app/src/main/java/com/agrobuy/app/BuyerDetailActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.agrobuy.app.databinding.BuyerDetailBinding;
import com.agrobuy.app.object.BuyerObject;
import com.bumptech.glide.Glide;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.text.SimpleDateFormat;
import java.util.HashMap;

public class BuyerDetailActivity extends Activity {
public BuyerDetailBinding binding;
public BuyerObject buyerObject;
private FirebaseAuth auth = FirebaseAuth.getInstance();
private FirebaseDatabase database = FirebaseDatabase.getInstance();
private DatabaseReference myRef = database.getReference();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -30,36 +42,61 @@ protected void onCreate(Bundle savedInstanceState) {

binding.topAppBar.setTitle(buyerObject.getBuyerName());

binding.contactCall.setOnClickListener(v->{
binding.contactCall.setOnClickListener(v -> {
Intent i = new Intent(Intent.ACTION_DIAL);
i.setData(Uri.parse("tel:"+ buyerObject.getPhoneNumber()));
i.setData(Uri.parse("tel:" + buyerObject.getPhoneNumber()));
startActivity(i);
});
binding.contactEmail.setOnClickListener(v->{
binding.contactEmail.setOnClickListener(v -> {
Intent i = ExportLogisticsActivity.makeMailIntent(new String[]{buyerObject.getEmail()},
"Buyer Network",null,null);
i.putExtra(Intent.EXTRA_TEXT,"Hi!");
"Buyer Network", null, null);
i.putExtra(Intent.EXTRA_TEXT, "Hi!");
startActivity(i);
});
binding.contactWhatsapp.setOnClickListener(v->{
String url = "https://api.whatsapp.com/send?phone="+ buyerObject.getPersonalNumber();
binding.contactWhatsapp.setOnClickListener(v -> {
String url = "https://api.whatsapp.com/send?phone=" + buyerObject.getPersonalNumber();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
});

binding.sell.setOnClickListener(v->{
binding.sell.setOnClickListener(v -> {
Log.d(BuyerDetailActivity.class.getName(), "Nothing is empty");

// putting item in the database
HashMap<String,String > details = new HashMap<>();
details.put("buyer_ID",buyerObject.getBuyerID());
details.put("buyer_Name",buyerObject.getBuyerName());
HashMap<String,Object> id = new HashMap<>();
id.put(FirebaseAuth.getInstance().getCurrentUser().getUid(),details);
HashMap<String,Object > item = new HashMap<>();
item.put(new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(System.currentTimeMillis()),id);
database.getReference(getString(R.string.buyer_applied)).updateChildren(item);
// opening email
Intent i = ExportLogisticsActivity.makeMailIntent(new String[]{buyerObject.getEmail()},
"Custom Subject Here",null,null);
i.putExtra(Intent.EXTRA_TEXT,"Hi!");
startActivity(i);
"Custom Subject Here", null, null);
i.putExtra(Intent.EXTRA_TEXT, "Hi!");
if (i.resolveActivity(getPackageManager()) != null) {
startActivityForResult(Intent.createChooser(i, "Choose an email client"), 800);
} else {
Toast.makeText(this, "Failed! Please install a email app", Toast.LENGTH_SHORT).show();
}
});

binding.exportFinancing.setOnClickListener(v->{
Intent i = new Intent(this,TradeFinanceActivity.class);
binding.exportFinancing.setOnClickListener(v -> {
Intent i = new Intent(this, TradeFinanceActivity.class);
startActivity(i);
});
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode==800){
if(resultCode==RESULT_OK)
Toast.makeText(getApplicationContext(), "Success! We will get back to you ASAP!", Toast.LENGTH_SHORT).show();
else
Toast.makeText(getApplicationContext(), "Failed! Please send email to complete", Toast.LENGTH_SHORT).show();
}
super.onActivityResult(requestCode, resultCode, data);
}
}
6 changes: 5 additions & 1 deletion app/src/main/java/com/agrobuy/app/BuyerNetworkActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
Expand All @@ -32,12 +33,14 @@ public class BuyerNetworkActivity extends Activity {
public List<BuyerObject> buyerList = new ArrayList<>();
RecyclerView recyclerView;
BuyerDetailAdapter adapter;
TextView emptyView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buyer_network);

emptyView = findViewById(R.id.empty_view);
emptyView.setText("Loading...");
adapter = new BuyerDetailAdapter(this, buyerList,
item ->{
Intent i = new Intent(this, BuyerDetailActivity.class);
Expand All @@ -55,6 +58,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
database.getReference("buyer_network" + "/" + auth.getCurrentUser().getUid()).get()
.addOnCompleteListener(task -> {
if(!task.isSuccessful()){
emptyView.setText("Error getting buyers data");
Log.d("BuyerNetwork", ": Error getting buyers data");
Toast.makeText(this, "Error getting buyers data", Toast.LENGTH_SHORT).show();
}
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/agrobuy/app/DeliveryPartnersActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
Expand All @@ -31,11 +32,13 @@ public class DeliveryPartnersActivity extends Activity {
public List<ContentObject> partnerList = new ArrayList<>();
RecyclerView recyclerView;
ContentDisplayAdapter adapter;

TextView emptyView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buyer_network);
emptyView = findViewById(R.id.empty_view);
emptyView.setText("Loading...");

adapter = new ContentDisplayAdapter(this, partnerList,
item ->{
Expand All @@ -53,8 +56,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
database.getReference("delivery_partners" + "/" + auth.getCurrentUser().getUid()).get()
.addOnCompleteListener(task -> {
if(!task.isSuccessful()){
Log.d("TradeFinance", ": Error getting invoices data");
Toast.makeText(this, "Error getting invoice data", Toast.LENGTH_SHORT).show();
emptyView.setText("Error getting partners data");
Log.d("TradeFinance", ": Error getting partners data");
Toast.makeText(this, "Error getting partners data", Toast.LENGTH_SHORT).show();
}
else{
DataSnapshot snapshot = task.getResult();
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/agrobuy/app/LoggedInActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
//getting instances
mAuth = FirebaseAuth.getInstance();
currUser = mAuth.getCurrentUser();

assert currUser != null;
DatabaseReference myRef = database.getReference("users");
myRef.child(currUser.getUid()).child("name").get().addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
Log.e("firebase", "Error getting data", task.getException());
Log.e("firebase", "Error getting data.", task.getException());
Toast.makeText(this, "Error getting data. Make sure your internet is stable.", Toast.LENGTH_SHORT).show();

}
else {
Log.d("firebase", String.valueOf(task.getResult().getValue()));
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/agrobuy/app/MyInvoicesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
.addOnCompleteListener(task -> {
Log.d("MyInvoices","added onCompleteListener");
if(!task.isSuccessful()){
emptyView.setText("Error getting invoices data.");
Log.d("MyInvoices", ": Error getting invoices data");
Toast.makeText(this, "Error getting invoice data", Toast.LENGTH_SHORT).show();
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/agrobuy/app/TradeFinanceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ public void onClick(@NonNull View view) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==requestCode){
if(requestCode==800){
if(resultCode==RESULT_OK)
Toast.makeText(getApplicationContext(), "Success! We will get back to you ASAP!", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), "Failed! Please send email to complete", Toast.LENGTH_SHORT).show();
else Toast.makeText(getApplicationContext(), "Failed! Please send email to complete", Toast.LENGTH_SHORT).show();
}else{
super.onActivityResult(requestCode, resultCode, data);
}
}

Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/agrobuy/app/UploadInvoiceActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class UploadInvoiceActivity extends Activity {
DatabaseReference dbRef;
private final FirebaseDatabase database = FirebaseDatabase.getInstance();
Uri uri;
private final int FILE_PICK_REQUEST=200;
private final int FILE_PICK_REQUEST = 200;
private final int REQUEST_CAPTURE_IMAGE = 201;
String imageFilePath ;

Expand Down Expand Up @@ -147,7 +147,6 @@ public void onCancelled(@NonNull DatabaseError error) {
try {
photoFile = createImageFile();
Log.d("imageFilePath",imageFilePath);
// savedInstanceState.putString("imageFilePath",imageFilePath);
} catch (IOException ex) {
// Error occurred while creating the File
}
Expand Down Expand Up @@ -230,4 +229,9 @@ protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
imageFilePath = savedInstanceState.getString("imageFilePath");
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("imageFilePath",String.valueOf(imageFilePath));
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/layout/export_logistics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,13 @@
</LinearLayout>

<Button
android:drawableEnd="@drawable/ic_baseline_arrow_forward_24"
android:id="@+id/avail_logistics"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avail Logistics"
android:textColor="@color/white"
android:backgroundTint="#E91E63"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
Expand Down
Loading

0 comments on commit 2a5b813

Please sign in to comment.