Skip to content

Commit

Permalink
Minor bugs fixed and removed hardcoded strings (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghu150999 authored Jul 10, 2020
1 parent 1ca85c0 commit c328801
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class BillingActivity extends AppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_billing);
setTitle("Billing");
setTitle(getString(R.string.billing));
// Get current merchant instance
merchant = Merchant.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ConfirmationActivity extends AppCompatActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_confirmation);
setTitle("Products");
setTitle(getString(R.string.products));
// Get current merchant
merchant = Merchant.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DebugActivity extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Debug tools");
setTitle(getString(R.string.debug_tools));
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.activity_debug, null, false);
mContainer.addView(contentView, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class InventoryActivity extends MainActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Product catalog");
setTitle(getString(R.string.product_catalog));
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mContentView = inflater.inflate(R.layout.activity_inventory, null, false);
mContainer.addView(mContentView, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class LocationPickerActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Pick location");
setTitle(getString(R.string.pick_location));
setContentView(R.layout.activity_location_picker);

// Set default location to previous location if available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class NewOrderDisplayActivity extends AppCompatActivity implements NewOrd
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_order_display);
setTitle("Order");
setTitle(getString(R.string.order));
mTotalPrice = findViewById(R.id.text_view_total_price);
TextView mTextViewCustomerName = findViewById(R.id.text_view_customer_name);
mOrder = (Order) getIntent().getSerializableExtra("order");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class NewOrdersActivity extends MainActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("New Orders");
setTitle(getString(R.string.new_order));
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mContentView = inflater.inflate(R.layout.activity_new_orders, null, false);
mContainer.addView(mContentView, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class OfferDetailsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_offer_details);
setTitle("Offer");
setTitle(getString(R.string.offer));
mDiscountType = findViewById(R.id.radio_group_set_discount_type);
mDiscountType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class OngoingOrderDisplayActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Order");
setTitle(getString(R.string.order));
setContentView(R.layout.activity_ongoing_order_display);
order = (Order) getIntent().getSerializableExtra("order");
initViews();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class OngoingOrdersActivity extends MainActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Ongoing orders");
setTitle(getString(R.string.ongoing_orders));
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mContentView = inflater.inflate(R.layout.activity_new_orders, null, false);
mContainer.addView(mContentView, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.google.android.material.button.MaterialButtonToggleGroup;
import com.google.android.material.textfield.TextInputEditText;
Expand Down Expand Up @@ -49,7 +47,7 @@ public class ProductOfferActivity extends MainActivity implements OfferActionLis
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Offers");
setTitle(getString(R.string.offers));
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mContentView = inflater.inflate(R.layout.activity_product_offer, null, false);
mContainer.addView(mContentView, 0);
Expand Down Expand Up @@ -166,10 +164,12 @@ public void onDeleteOfferSelect(int type, int itemIdx, int offerIdx) {
if (type == OfferActionListener.PRODUCT_OFFER) {
Product product = mProductOfferAdapter.getProducts().get(itemIdx);
product.getOffers().remove(offerIdx);
mProductOfferAdapter.notifyItemChanged(itemIdx);
FirebaseUtils.updateProductOffers(product);
} else {
Brand brand = mBrandOfferAdapter.getBrands().get(itemIdx);
brand.getOffers().remove(offerIdx);
mBrandOfferAdapter.notifyItemChanged(itemIdx);
FirebaseUtils.updateBrandOffers(brand);
}
}
Expand Down Expand Up @@ -203,6 +203,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
UIUtils.showToast(this, "Offer updated");
}
// Refresh views
mProductOfferAdapter.notifyDataSetChanged();
mBrandOfferAdapter.notifyDataSetChanged();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class SettingsActivity extends AppCompatActivity {

private TextInputEditText mEditTextDomainName;
private TextInputLayout mTextLayoutDomainName;
private Button mSetLocation;

private boolean isDomainNameOptionOverridden = false;
private boolean isDomainNameChangeConfirmed = false;
Expand All @@ -46,7 +47,7 @@ public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Settings");
setTitle(getString(R.string.settings));
setContentView(R.layout.activity_settings);
Merchant merchant = Merchant.getInstance();
final TextInputEditText storeName = findViewById(R.id.edit_text_store_name);
Expand All @@ -65,8 +66,11 @@ protected void onCreate(Bundle savedInstanceState) {
mLocation = merchant.getLatLng();
}

Button setLocation = findViewById(R.id.button_set_location);
setLocation.setOnClickListener(new View.OnClickListener() {
mSetLocation = findViewById(R.id.button_set_location);
if (mLocation != null) {
mSetLocation.setText(R.string.change_location);
}
mSetLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SettingsActivity.this, LocationPickerActivity.class);
Expand Down Expand Up @@ -190,7 +194,7 @@ public void onCheckComplete(boolean isAvailable) {
if (mEditTextDomainName.getText().toString().trim().equals(queryDomainName)) {
searchProgressBar.setVisibility(View.INVISIBLE);
mTextLayoutDomainName.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
if (isAvailable || mSavedDomainName.equals(queryDomainName)) {
if (isAvailable || queryDomainName.equals(mSavedDomainName)) {
mTextLayoutDomainName.setEndIconDrawable(getDrawable(R.drawable.ic_action_ok_circle));
mDomainName = s.toString();
} else {
Expand All @@ -211,6 +215,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
double latitutde = data.getDoubleExtra(CommonUtils.LATITUDE, 0.0);
double longitude = data.getDoubleExtra(CommonUtils.LONGITUDE, 0.0);
mLocation = new LatLng(latitutde, longitude);
mSetLocation.setText(R.string.change_location);
} else {
UIUtils.showToast(this, getString(R.string.no_location_set));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ public Double getDiscountedPrice() {
if (discountedPrice == null) {
discountedPrice = MRP;
}
double bestOffer = 0.0;
boolean isOfferAvailable = false;
for (Offer offer : getOffers()) {
double currentOfferPrice = 0.0;
if (Offer.EXPIRED.equals(offer.getStatus())) continue;
isOfferAvailable = true;
if (offer.getOfferType() == Offer.OfferType.PERCENTAGE_OFFER) {
currentOfferPrice = MRP * offer.getOfferAmount() / (double) 100;
} else {
currentOfferPrice = offer.getOfferAmount();
}
if (currentOfferPrice > bestOffer) {
bestOffer = currentOfferPrice;
}
}
double offerDiscountPrice = MRP - bestOffer;
if (isOfferAvailable && offerDiscountPrice < discountedPrice) return offerDiscountPrice;
return discountedPrice;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ScanBarcodeActivity extends ScanActivity {

@Override
protected void initViews() {
setTitle("Scan Barcode");
setTitle(getString(R.string.scan_barcode));
setContentView(R.layout.activity_scan_barcode);
TextView helpText = findViewById(R.id.text_view_help);
helpText.setText(R.string.point_at_a_barcode_to_scan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ScanTextActivity extends ScanActivity implements

@Override
protected void initViews() {
setTitle("Scan Text");
setTitle(getString(R.string.scan_text));
setContentView(R.layout.activity_scan_text);
TextView helpText = findViewById(R.id.text_view_help);
helpText.setText(R.string.point_at_product_text_to_scan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_text_search"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text" />

</com.google.android.material.textfield.TextInputLayout>

Expand Down
6 changes: 4 additions & 2 deletions merchant-app/app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_text_store_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:inputType="text" />

</com.google.android.material.textfield.TextInputLayout>

Expand Down Expand Up @@ -128,7 +129,8 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_text_domain_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:inputType="text" />

</com.google.android.material.textfield.TextInputLayout>

Expand Down
31 changes: 21 additions & 10 deletions merchant-app/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@
<string name="set_quantity">Set quantity</string>
<string name="quick_add_message">Newly detected products have been added to your inventory</string>
<string name="set_discount">Set discount</string>
<string name="debug_tools">Debug tools</string>
<string name="no_internet_connection">No internet connection</string>
<string name="accept">Accept</string>
<string name="decline">Decline</string>
<string name="customer_name_placeholder">Raghu\'s order</string>
<string name="new_orders">New orders</string>
<string name="profile_icon">Profile icon</string>
<string name="inventory">Inventory</string>
<string name="ongoing_orders">Ongoing orders</string>
<string name="settings">Settings</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="google_logo">google logo</string>
Expand Down Expand Up @@ -88,16 +85,15 @@
<string name="attachment_summary_on">Automatically download attachments for incoming emails</string>

<string name="attachment_summary_off">Only download attachments when manually requested</string>
<string name="offers">Offers</string>
<string name="pick_location_marker">Pick location marker</string>
<string name="save">Save</string>
<string name="set_location">Set Location</string>
<string name="store_location">Store Location</string>
<string name="store_address">Store address</string>
<string name="store_name">Store name</string>
<string name="domain_name_help_info">You can choose to provide a domain name for your store which will allow more customers to access your store.</string>
<string name="domain_name_label">Domain name (optional)</string>
<string name="location_permission_rationale">Location permissions are required for you to access current location.</string>
<string name="domain_name_help_info">You can choose to provide a URL Path for your store which will allow more customers to access your store.</string>
<string name="domain_name_label">Shareable URL Path (optional)</string>
<string name="location_permission_rationale">Location permissions are required to access your current location if you want to set your current location as your store location.</string>
<string name="forever">Forever</string>
<string name="ok">OK</string>
<string name="set_price_msg">Set a price to mark available</string>
Expand Down Expand Up @@ -132,7 +128,6 @@
<string name="time_of_order">Time of order:</string>
<string name="customer_address">Customer Address</string>
<string name="call">Call</string>
<string name="products">Products</string>
<string name="deliver_with_dunzo">Deliver with Dunzo</string>
<string name="find_products">Find products</string>
<string name="price">Price:</string>
Expand All @@ -159,7 +154,23 @@
<string name="new_product">New product</string>
<string name="search">Search</string>
<string name="search_here">Search here</string>
<string name="invalid_domain_alert_msg">Valid domain name is not set. Do you want to continue?</string>
<string name="domain_name_change_alert_msg">Changing domain name will make all previous domain pages invalid. Do you want to continue?</string>
<string name="invalid_domain_alert_msg">Valid URL Path is not set. Do you want to continue?</string>
<string name="domain_name_change_alert_msg">Changing URL Path will make all previous domain pages invalid. Do you want to continue?</string>
<string name="yes">Yes</string>
<string name="change_location">Change Location</string>

<!-- Activity titles-->
<string name="scan_barcode">Scan Barcode</string>
<string name="scan_text">Scan Text</string>
<string name="billing">Billing</string>
<string name="products">Products</string>
<string name="debug_tools">Debug tools</string>
<string name="product_catalog">Product catalog</string>
<string name="pick_location">Pick location</string>
<string name="new_order">New Orders</string>
<string name="offer">Offer</string>
<string name="order">Order</string>
<string name="ongoing_orders">Ongoing orders</string>
<string name="offers">Offers</string>
<string name="settings">Settings</string>
</resources>

0 comments on commit c328801

Please sign in to comment.