├── Food Delivery
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── soxluvr23
│ │ └── afinal
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── soxluvr23
│ │ │ └── afinal
│ │ │ ├── CheckOut.java
│ │ │ ├── MainActivity.java
│ │ │ ├── OrderPlaced.java
│ │ │ ├── Restaurant.java
│ │ │ └── RestaurantView.java
│ └── res
│ │ ├── drawable
│ │ ├── chicagos.png
│ │ ├── johnathans.png
│ │ ├── oaklawn.png
│ │ ├── sataitos.png
│ │ └── slims.png
│ │ ├── layout
│ │ ├── activity_check_out.xml
│ │ ├── activity_main.xml
│ │ ├── activity_order_placed.xml
│ │ └── activity_restaurant_view.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── soxluvr23
│ └── afinal
│ └── ExampleUnitTest.java
└── README.md
/Food Delivery/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.2"
6 | defaultConfig {
7 | applicationId "com.example.soxluvr23.afinal"
8 | minSdkVersion 15
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:24.2.1'
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.google.android.gms:play-services-maps:9.4.0'
30 | }
31 |
--------------------------------------------------------------------------------
/Food Delivery/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Soxluvr23\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/Food Delivery/src/androidTest/java/com/example/soxluvr23/afinal/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.soxluvr23.afinal", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/java/com/example/soxluvr23/afinal/CheckOut.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.text.Editable;
7 | import android.text.TextWatcher;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.EditText;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import java.text.DecimalFormat;
16 |
17 | public class CheckOut extends AppCompatActivity {
18 | String purchaseAddress = "";
19 | String restaurantAddress = "";
20 | boolean deliveryPickup = true;
21 | private String lineItems = "";
22 | private String restaurant = "";
23 | private int deliveryCharge = 0;
24 | private int imageId = 0;
25 | private double total = 0.0;
26 | DecimalFormat df = new DecimalFormat("#.00");
27 |
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_check_out);
33 | }
34 |
35 | @Override
36 | protected void onStart() {
37 | super.onStart();
38 | TextView res = (TextView) findViewById(R.id.Restaurant);
39 | TextView deliverycharge = (TextView) findViewById(R.id.deliveryCharge);
40 | TextView address = (TextView) findViewById(R.id.address);
41 | TextView orderdetails = (TextView) findViewById(R.id.OrderDisplay);
42 | TextView totalview = (TextView) findViewById(R.id.total);
43 | Button Total = (Button) findViewById(R.id.button2);
44 | final EditText name = (EditText) findViewById(R.id.editText);
45 | final EditText phone = (EditText) findViewById(R.id.editText5);
46 | final EditText card = (EditText) findViewById(R.id.editText4);
47 | card.addTextChangedListener(new CreditCardNumberFormattingTextWatcher());
48 |
49 |
50 | final Intent intent = getIntent();
51 | if (intent != null) {
52 | lineItems = intent.getCharSequenceExtra("LineItems").toString();
53 | restaurant = intent.getCharSequenceExtra("Restaurant").toString();
54 | purchaseAddress = intent.getCharSequenceExtra("purchaseAddress").toString();
55 | deliveryCharge = intent.getIntExtra("DeliveryCharge",3);
56 | deliveryPickup = intent.getBooleanExtra("deliveryPickup", true);
57 | restaurantAddress = intent.getCharSequenceExtra("RestaurantAddress").toString();
58 | imageId = intent.getIntExtra("image",0);
59 | total = Double.parseDouble(intent.getCharSequenceExtra("Total").toString());
60 |
61 | res.setText(restaurant);
62 | deliverycharge.setText("Delivery Charge: $"+df.format(deliveryCharge));
63 | ImageView img = (ImageView) findViewById(R.id.image);
64 | img.setImageResource(imageId);
65 | if (deliveryPickup){
66 | orderdetails.setText(lineItems+"\nSUBTOTAL: "+"$"+df.format(total)+"\n\nDelivery Charge $"+df.format(deliveryCharge)+"\nTip $3.00");
67 | total = total+deliveryCharge+3.00;
68 | totalview.setText("Total: $"+df.format(total));
69 | }else{
70 | orderdetails.setText(lineItems+"SUBTOTAL: "+"$"+df.format(total));
71 | totalview.setText("$"+df.format(total));
72 | }
73 | address.setText(purchaseAddress);
74 | }
75 |
76 |
77 |
78 | Total.setOnClickListener(new View.OnClickListener() {
79 | @Override
80 | public void onClick(View v) {
81 | if (!name.getText().toString().equals("") && !phone.getText().toString().equals("") && !card.getText().toString().equals("")){
82 | Intent intent = new Intent(CheckOut.this, OrderPlaced.class);
83 | intent.putExtra("Total",total);
84 | intent.putExtra("Restaurant",restaurant);
85 | intent.putExtra("Address",purchaseAddress);
86 | intent.putExtra("RestaurantAddress",restaurantAddress);
87 | intent.putExtra("image",imageId);
88 | startActivity(intent);
89 | }
90 | }
91 | });
92 | }
93 | public static class CreditCardNumberFormattingTextWatcher implements TextWatcher {
94 |
95 | private boolean lock;
96 |
97 | @Override
98 | public void onTextChanged(CharSequence s, int start, int before, int count) {
99 | }
100 |
101 | @Override
102 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
103 | }
104 |
105 | @Override
106 | public void afterTextChanged(Editable s) {
107 | for (int i = 4; i < s.length(); i += 5) {
108 | if (s.toString().charAt(i) != ' ') {
109 | s.insert(i, " ");
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/java/com/example/soxluvr23/afinal/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.location.Location;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.location.Geocoder;
9 | import android.view.View;
10 | import android.widget.AdapterView;
11 | import android.widget.ArrayAdapter;
12 | import android.widget.Button;
13 | import android.widget.CompoundButton;
14 | import android.widget.ListView;
15 | import android.widget.Switch;
16 | import android.widget.TextView;
17 | import android.location.Address;
18 |
19 | import java.io.IOException;
20 | import java.text.DecimalFormat;
21 | import java.util.ArrayList;
22 | import java.util.HashMap;
23 | import java.util.List;
24 | import java.util.Locale;
25 | import java.util.Map;
26 |
27 | public class MainActivity extends AppCompatActivity {
28 | String address = "";
29 | Context con = this;
30 | Geocoder coder;
31 | public ArrayList Locations = new ArrayList<>();
32 | TextView addressView;
33 | private boolean deliveryPickup = true;
34 | Switch swtch;
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | coder = new Geocoder(con, Locale.getDefault()) ;
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_main);
41 | swtch = (Switch) findViewById(R.id.switch1);
42 | swtch.setChecked(true);
43 | Locations = populate();
44 | Button button= (Button) findViewById(R.id.addressButton);
45 | addressView = (TextView) findViewById(R.id.addressInput);
46 | button.setOnClickListener(new View.OnClickListener() {
47 | @Override
48 | public void onClick(View v) {
49 | address = addressView.getText().toString();
50 | try {
51 | ArrayList adresses = (ArrayList) coder.getFromLocationName(address, 50);
52 | for(Address add : adresses){
53 | HashMap local = findRestaurants(add);
54 | dispRestaurants(local);
55 | break;
56 | }
57 |
58 | } catch (IOException e) {
59 | e.printStackTrace();
60 | }
61 |
62 | }
63 | });
64 | swtch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
65 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
66 | if (isChecked) {
67 | deliveryPickup = true;
68 | } else {
69 | deliveryPickup = false;
70 | }
71 | }
72 | });
73 | }
74 |
75 | private void dispRestaurants(HashMap local){
76 | DecimalFormat df = new DecimalFormat("#.##");
77 | // Find the ListView resource.
78 | final ListView restaurants = (ListView) findViewById(R.id.ListViewRestaurants);
79 | // Create ArrayAdapter using the planet list.
80 | List list = new ArrayList();
81 | for (Map.Entry entry : local.entrySet()){
82 | list.add(entry.getKey()+": "+df.format(entry.getValue())+" miles away");
83 | }
84 | //Log.d("A",local.size()+"");
85 | if (local.size() > 0){
86 | ArrayAdapter listAdapter = new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, list);
87 |
88 | // Set the ArrayAdapter as the ListView's adapter.
89 | restaurants.setAdapter( listAdapter );
90 | restaurants.setClickable(true);
91 | restaurants.setOnItemClickListener(new AdapterView.OnItemClickListener() {
92 |
93 | @Override
94 | public void onItemClick(AdapterView> arg0, View arg1, int position, long arg3) {
95 |
96 | String s = restaurants.getItemAtPosition(position).toString();
97 | int i = s.indexOf(":");
98 | s = s.substring(0,i);
99 |
100 | Intent intent = new Intent(MainActivity.this, RestaurantView.class);
101 | intent.putExtra("Location", s);
102 | intent.putExtra("Locations",Locations);
103 | intent.putExtra("PurchaseLocation",addressView.getText().toString());
104 | intent.putExtra("deliveryPickup",deliveryPickup);
105 | startActivity(intent);
106 | }
107 | });
108 | }
109 | else{
110 | List lst = new ArrayList();
111 | restaurants.setClickable(false);
112 | lst.add("No Locations near you!");
113 | ArrayAdapter listAdapter = new ArrayAdapter(this, R.layout.support_simple_spinner_dropdown_item, lst);
114 |
115 | // Set the ArrayAdapter as the ListView's adapter.
116 | restaurants.setAdapter( listAdapter );
117 | }
118 | }
119 |
120 | private HashMap findRestaurants(Address loc) {
121 | HashMap local = new HashMap<>();
122 | Location locationA = new Location("point A");
123 | locationA.setLatitude(loc.getLatitude());
124 | locationA.setLongitude(loc.getLongitude());
125 |
126 | for (Restaurant res : Locations){
127 | //Log.d("A: "+locationA.getLatitude(),""+locationA.getLongitude());
128 | Location locationB = new Location("point B");
129 | locationB.setLatitude(res.getAddress().getLatitude());
130 | locationB.setLongitude(res.getAddress().getLongitude());
131 | //Log.d("B: "+locationB.getLatitude(),""+locationB.getLongitude());
132 | // Log.d("DIST: ",locationA.distanceTo(locationB)+"");
133 | if (locationA.distanceTo(locationB) < 24140.2){
134 | local.put(res.getName(), (locationA.distanceTo(locationB)*0.000621371));
135 | }
136 | }
137 | return local;
138 | }
139 |
140 | private ArrayList populate(){
141 | ArrayList Locations = new ArrayList<>();
142 | Restaurant temp = new Restaurant();
143 | temp.setName("Chicago's Pizza");
144 | temp.setAddressName("7225 W Harlem Ave.");
145 | temp.setDeliveryFee(4);
146 | Address loc = new Address(new Locale("English","Chicago"));
147 | loc.setLatitude(42.039788);
148 | loc.setLongitude(-87.807562);
149 | temp.setAddress(loc);
150 | temp.setImageid(R.drawable.chicagos);
151 | HashMap hours = new HashMap<>();
152 | hours.put("Sunday","11:00 AM - 7:00 PM");
153 | hours.put("Monday","10:00 AM - 10:00 PM");
154 | hours.put("Tuesday","10:00 AM - 10:00 PM");
155 | hours.put("Wednesday","10:00 AM - 10:00 PM");
156 | hours.put("Thursday","10:00 AM - 10:00 PM");
157 | hours.put("Friday","10:00 AM - 11:00 PM");
158 | hours.put("Saturday","10:00 AM - 2:00 AM");
159 | temp.setHours(hours);
160 | HashMap MENU = new HashMap<>();
161 | MENU.put("Spaghetti",16);
162 | MENU.put("Spaghettios",25);
163 | MENU.put("Spaghettios Pizza",30);
164 | MENU.put("Chocolate Pizza",5);
165 | MENU.put("Cheese Sticks",4);
166 | temp.setMENU(MENU);
167 | Locations.add(temp);
168 |
169 | temp = new Restaurant();
170 | temp.setName("Slim's Hotdogs");
171 | temp.setAddressName("469 W Huron St.");
172 | temp.setDeliveryFee(4);
173 | loc = new Address(new Locale("English","Chicago"));
174 | loc.setLatitude(41.894443);
175 | loc.setLongitude(-87.641243);
176 | temp.setAddress(loc);
177 | temp.setImageid(R.drawable.slims);
178 | hours = new HashMap<>();
179 | hours.put("Sunday","3:00 PM - 7:00 PM");
180 | hours.put("Monday","10:00 AM - 10:00 PM");
181 | hours.put("Tuesday","10:00 AM - 10:00 PM");
182 | hours.put("Wednesday","10:00 AM - 10:00 PM");
183 | hours.put("Thursday","10:00 AM - 10:00 PM");
184 | hours.put("Friday","10:00 AM - 11:00 PM");
185 | hours.put("Saturday","10:00 AM - 1:00 PM");
186 | temp.setHours(hours);
187 | MENU = new HashMap<>();
188 | MENU.put("Hot Dog",3);
189 | MENU.put("Cheese Dog",4);
190 | MENU.put("Midway Monster",10);
191 | MENU.put("Fries",1);
192 | MENU.put("Milkshake",3);
193 | temp.setMENU(MENU);
194 | Locations.add(temp);
195 |
196 | temp = new Restaurant();
197 | temp.setName("Johnathan's Jerk Chicken");
198 | temp.setDeliveryFee(8);
199 | loc = new Address(new Locale("English","Chicago"));
200 | loc.setLatitude(41.893215);
201 | loc.setLongitude(-87.616899);
202 | temp.setAddress(loc);
203 | temp.setImageid(R.drawable.johnathans);
204 | temp.setAddressName("401 E Ontario St.");
205 | hours = new HashMap<>();
206 | hours.put("Sunday","6:00 AM - 12:00 AM");
207 | hours.put("Monday","10:00 AM - 10:00 PM");
208 | hours.put("Tuesday","10:00 AM - 10:00 PM");
209 | hours.put("Wednesday","10:00 AM - 10:00 PM");
210 | hours.put("Thursday","10:00 AM - 10:00 PM");
211 | hours.put("Friday","10:00 AM - 11:00 PM");
212 | hours.put("Saturday","6:00 AM - 4:00 AM");
213 | temp.setHours(hours);
214 | MENU = new HashMap<>();
215 | MENU.put("Jerk Chicken",17);
216 | MENU.put("Side of Rice",5);
217 | MENU.put("Cornbread",7);
218 | MENU.put("Fountain Soda",3);
219 | MENU.put("Beer",8);
220 | temp.setMENU(MENU);
221 | Locations.add(temp);
222 |
223 | temp = new Restaurant();
224 | temp.setName("Oak Lawn Family Restaurant");
225 | temp.setDeliveryFee(5);
226 | loc = new Address(new Locale("English","Chicago"));
227 | temp.setAddressName("9400 SW Hwy");
228 | loc.setLatitude(41.719444);
229 | loc.setLongitude(-87.748611);
230 | temp.setAddress(loc);
231 | temp.setImageid(R.drawable.oaklawn);
232 | hours = new HashMap<>();
233 | hours.put("Sunday","9:00 AM - 3:00 PM");
234 | hours.put("Monday","9:00 AM - 3:00 PM");
235 | hours.put("Tuesday","9:00 AM - 3:00 PM");
236 | hours.put("Wednesday","9:00 AM - 3:00 PM");
237 | hours.put("Thursday","9:00 AM - 3:00 PM");
238 | hours.put("Friday","9:00 AM - 3:00 PM");
239 | hours.put("Saturday","9:00 AM - 3:00 PM");
240 | temp.setHours(hours);
241 | MENU = new HashMap<>();
242 | MENU.put("Omelet",9);
243 | MENU.put("Hash Browns",5);
244 | MENU.put("Bacon",7);
245 | MENU.put("Coffee",3);
246 | MENU.put("Pancakes",8);
247 | temp.setMENU(MENU);
248 | Locations.add(temp);
249 |
250 | temp = new Restaurant();
251 | temp.setName("SataitoDawgs");
252 | temp.setAddressName("4104 N Harlem Ave");
253 | temp.setDeliveryFee(30);
254 | loc = new Address(new Locale("English","Chicago"));
255 | loc.setLatitude(41.955527);
256 | loc.setLongitude(-87.808507);
257 | temp.setAddress(loc);
258 | temp.setImageid(R.drawable.sataitos);
259 | hours = new HashMap<>();
260 | hours.put("Sunday","ALL DAY");
261 | hours.put("Monday","ALL DAY");
262 | hours.put("Tuesday","ALL DAY");
263 | hours.put("Wednesday","ALL DAY");
264 | hours.put("Thursday","ALL DAY");
265 | hours.put("Friday","ALL DAY");
266 | hours.put("Saturday","ALL DAY");
267 | temp.setHours(hours);
268 | MENU = new HashMap<>();
269 | MENU.put("SataitoDawg",49);
270 | MENU.put("SataitoFries",27);
271 | MENU.put("Platinum Hot Dog",1);
272 | MENU.put("Gold Leaf Fries",1);
273 | MENU.put("Diamond Infused Soda",1);
274 | temp.setMENU(MENU);
275 | Locations.add(temp);
276 |
277 | return Locations;
278 | }
279 |
280 | }
281 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/java/com/example/soxluvr23/afinal/OrderPlaced.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.location.Address;
6 | import android.location.Geocoder;
7 | import android.location.Location;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.os.Bundle;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.google.android.gms.maps.CameraUpdateFactory;
15 | import com.google.android.gms.maps.GoogleMap;
16 | import com.google.android.gms.maps.OnMapReadyCallback;
17 | import com.google.android.gms.maps.SupportMapFragment;
18 | import com.google.android.gms.maps.model.LatLng;
19 | import com.google.android.gms.maps.model.MarkerOptions;
20 | import java.io.IOException;
21 | import java.text.DecimalFormat;
22 | import java.util.ArrayList;
23 | import java.util.Locale;
24 |
25 | public class OrderPlaced extends AppCompatActivity implements OnMapReadyCallback {
26 | Context con = this;
27 | Geocoder coder;
28 | private double total = 0;
29 | private String restaurant = "";
30 | private String Address = "";
31 | private String restaurantAddress = "";
32 | private int imageId = 0;
33 | DecimalFormat df = new DecimalFormat("#.00");
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | coder = new Geocoder(con, Locale.getDefault()) ;
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_order_placed);
40 |
41 | SupportMapFragment mapFragment =
42 | (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
43 | mapFragment.getMapAsync(this);
44 | }
45 |
46 | @Override
47 | protected void onStart() {
48 | super.onStart();
49 | TextView res = (TextView) findViewById(R.id.Restaurant);
50 | TextView address = (TextView) findViewById(R.id.address);
51 | TextView Total = (TextView) findViewById(R.id.Total);
52 |
53 |
54 | Intent intent = getIntent();
55 | if (intent != null) {
56 | total = intent.getDoubleExtra("Total",0);
57 | restaurant = intent.getCharSequenceExtra("Restaurant").toString();
58 | Address = intent.getCharSequenceExtra("Address").toString();
59 | restaurantAddress = intent.getCharSequenceExtra("RestaurantAddress").toString();
60 | imageId = intent.getIntExtra("image", 0);
61 |
62 | ImageView img = (ImageView) findViewById(R.id.image);
63 | img.setImageResource(imageId);
64 |
65 | }
66 | res.setText(restaurant);
67 | address.setText(restaurantAddress);
68 | Total.setText("TOTAL: $"+df.format(total));
69 |
70 | }
71 |
72 | Location makeLocation(String Address) {
73 | ArrayList adresses = new ArrayList<>();
74 | try {
75 | adresses = (ArrayList) coder.getFromLocationName(Address, 50);
76 | } catch (IOException e) {
77 | e.printStackTrace();
78 | }
79 | Location locationA = new Location(Address);
80 | locationA.setLatitude(adresses.get(0).getLatitude());
81 | locationA.setLongitude(adresses.get(0).getLongitude());
82 | return locationA;
83 | }
84 |
85 | @Override
86 | public void onMapReady(GoogleMap map) {
87 | Location Start = makeLocation(restaurantAddress);
88 | Location End = makeLocation(Address);
89 | map.addMarker(new MarkerOptions().position(new LatLng(Start.getLatitude(), Start.getLongitude())).title("Restaurant"));
90 | map.addMarker(new MarkerOptions().position(new LatLng(End.getLatitude(), End.getLongitude())).title("Destination"));
91 | float zoomLevel = (float) 11.0; //This goes up to 21
92 | map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(End.getLatitude(), End.getLongitude()), zoomLevel));
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/java/com/example/soxluvr23/afinal/Restaurant.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.location.Address;
4 | import android.os.Bundle;
5 | import android.os.Parcel;
6 | import android.os.Parcelable;
7 | import android.util.Log;
8 | import java.util.HashMap;
9 | import java.util.Locale;
10 |
11 | public class Restaurant implements Parcelable{
12 | String name = "";
13 | HashMap MENU = new HashMap<>();
14 | HashMap hours = new HashMap<>();
15 | Address address = new Address(new Locale("English","Chicago"));
16 | double distance = 0;
17 | int deliveryFee = 0;
18 | String add = "";
19 | int imageId = 0;
20 |
21 | Restaurant(){
22 |
23 | }
24 |
25 | protected Restaurant(Parcel in) {
26 | name = in.readString();
27 | imageId = in.readInt();
28 | address = in.readParcelable(Address.class.getClassLoader());
29 | distance = in.readDouble();
30 | deliveryFee = in.readInt();
31 | add = in.readString();
32 | Bundle bun = in.readBundle();
33 | hours = (HashMap) bun.getSerializable("HOURS");
34 | MENU = (HashMap) bun.getSerializable("MENU");
35 |
36 | }
37 |
38 | @Override
39 | public void writeToParcel(Parcel dest, int flags) {
40 | dest.writeString(name);
41 | dest.writeInt(imageId);
42 | dest.writeParcelable(address, flags);
43 | dest.writeDouble(distance);
44 | dest.writeInt(deliveryFee);
45 | dest.writeString(add);
46 | Bundle bun = new Bundle();
47 | bun.putSerializable("HOURS",hours);
48 | bun.putSerializable("MENU",MENU);
49 | dest.writeBundle(bun);
50 | }
51 |
52 | @Override
53 | public int describeContents() {
54 | return 0;
55 | }
56 |
57 | public static final Creator CREATOR = new Creator() {
58 | @Override
59 | public Restaurant createFromParcel(Parcel in) {
60 | return new Restaurant(in);
61 | }
62 |
63 | @Override
64 | public Restaurant[] newArray(int size) {
65 | return new Restaurant[size];
66 | }
67 | };
68 |
69 | public void setMENU(HashMap MENU){
70 | this.MENU = MENU;
71 | }
72 |
73 | public void setHours(HashMap hours){
74 | Log.d(""+hours.size(),"sethours");
75 | this.hours = hours;
76 | }
77 |
78 | public void setAddress(Address address){
79 | this.address = address;
80 | }
81 |
82 | public void setDeliveryFee(int deliveryFee){
83 | this.deliveryFee = deliveryFee;
84 | }
85 |
86 | public void setName(String name){
87 | this.name = name;
88 | }
89 |
90 | public String getHours(String day){
91 | Log.d(""+hours.size(),"gethours");
92 |
93 | switch(day){
94 | case "Sunday":
95 | return hours.get("Sunday");
96 | case "Monday":
97 | return hours.get("Monday");
98 |
99 | case "Tuesday":
100 | return hours.get("Tuesday");
101 | case "Wednesday":
102 | return hours.get("Wednesday");
103 |
104 | case "Thursday":
105 | return hours.get("Thursday");
106 |
107 | case "Friday":
108 | return hours.get("Friday");
109 | case "Saturday":
110 | return hours.get("Saturday");
111 | }
112 | return null;
113 | }
114 |
115 | public Address getAddress() {
116 | return address;
117 | }
118 |
119 | public String getName() {
120 | return name;
121 | }
122 |
123 | public void setAddressName(String addressName) {
124 | this.add = addressName;
125 | }
126 | public String getAddressName() {
127 | return add;
128 | }
129 |
130 | public int getImageId() {
131 | return imageId;
132 | }
133 |
134 | public void setImageid(int imageid) {
135 | this.imageId = imageid;
136 | }
137 |
138 | public HashMap getMENU() {
139 | return MENU;
140 | }
141 |
142 | public int getDeliveryCharge() {
143 | return deliveryFee;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/java/com/example/soxluvr23/afinal/RestaurantView.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import android.content.Intent;
4 | import android.icu.util.Calendar;
5 | import android.os.Build;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.AdapterView;
11 | import android.widget.ArrayAdapter;
12 | import android.widget.AutoCompleteTextView;
13 | import android.widget.Button;
14 | import android.widget.ImageView;
15 | import android.widget.ListAdapter;
16 | import android.widget.TextView;
17 |
18 | import java.text.DecimalFormat;
19 | import java.text.SimpleDateFormat;
20 | import java.util.ArrayList;
21 | import java.util.Arrays;
22 | import java.util.Date;
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | public class RestaurantView extends AppCompatActivity {
27 | ArrayList loc = new ArrayList();
28 | Restaurant restaurant = new Restaurant();
29 | private AutoCompleteTextView textView;
30 | DecimalFormat df = new DecimalFormat("#.00");
31 | HashMap MENU = new HashMap();
32 | private String purchaseAddress = "";
33 | private boolean deliveryPickup = true;
34 |
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_restaurant_view);
40 | }
41 |
42 | @Override
43 | protected void onStart() {
44 | super.onStart();
45 |
46 | Intent intent = getIntent();
47 | if (intent != null) {
48 | TextView res = (TextView) findViewById(R.id.Restaurant);
49 | TextView address = (TextView) findViewById(R.id.address);
50 | String currentLocation = intent.getCharSequenceExtra("Location").toString();
51 | loc = getIntent().getParcelableArrayListExtra("Locations");
52 | purchaseAddress = intent.getCharSequenceExtra("PurchaseLocation").toString();
53 | deliveryPickup = intent.getBooleanExtra("deliveryPickup",true);
54 | restaurant = findLoc(loc,currentLocation);
55 | String hours = setDate();
56 | res.setText(currentLocation);
57 | address.setText(restaurant.getAddressName());
58 | TextView dayview = (TextView) findViewById(R.id.hours);
59 | dayview.setText(hours);
60 | ImageView img = (ImageView) findViewById(R.id.image);
61 | img.setImageResource(restaurant.getImageId());
62 |
63 | String[] menu = Arrays.copyOf( restaurant.getMENU().keySet().toArray(), restaurant.getMENU().keySet().toArray().length, String[].class);
64 | MENU = restaurant.getMENU();
65 | ArrayAdapter adapter = new ArrayAdapter(this,
66 | android.R.layout.simple_dropdown_item_1line,menu );
67 | textView = (AutoCompleteTextView)
68 | findViewById(R.id.ItemInput);
69 | textView.setAdapter(adapter);
70 |
71 | final TextView UnitCostInput = (TextView) findViewById(R.id.UnitCostInput);
72 | final TextView QuantityInput = (TextView) findViewById(R.id.QuantityInput);
73 | final TextView OrderDisplay = (TextView) findViewById(R.id.OrderDisplay);
74 | final TextView TotalDisplay = (TextView) findViewById(R.id.TotalDisplay);
75 | final Button ButtonNewItem = (Button) findViewById(R.id.ButtonNewItem);
76 | final Button Total = (Button) findViewById(R.id.Total);
77 |
78 | ButtonNewItem.setOnClickListener(new View.OnClickListener() {
79 | @Override
80 | public void onClick(View v) {
81 | if (textView.getText()+"" != ""){
82 | OrderDisplay.append(""+textView.getText()+" x "+QuantityInput.getText()+"\n");
83 | }
84 | TotalDisplay.setText(df.format(((Double.parseDouble(TotalDisplay.getText()+""))+((Double.parseDouble(UnitCostInput.getText()+""))*(Double.parseDouble(QuantityInput.getText()+"")))))+"");
85 |
86 | textView.setText("");
87 | textView.requestFocus();
88 | UnitCostInput.setText("0.00");
89 | QuantityInput.setText(1+"");
90 | textView.setText("");
91 | textView.requestFocus();
92 | }
93 | });
94 |
95 | textView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
96 | @Override
97 | public void onFocusChange(View view, boolean b) {
98 | if(b){
99 | textView.showDropDown();
100 | }
101 | if(!b) {
102 | // on focus off
103 | String str = textView.getText().toString();
104 |
105 | ListAdapter listAdapter = textView.getAdapter();
106 | for(int i = 0; i < listAdapter.getCount(); i++) {
107 | String temp = listAdapter.getItem(i).toString();
108 | if(str.compareTo(temp) == 0) {
109 | return;
110 | }
111 | }
112 | for (Map.Entry entry : MENU.entrySet()){
113 | Log.d(entry.getKey(),textView.getText().toString());
114 | if (entry.getKey().equals(textView.getText().toString())){
115 | UnitCostInput.setText(""+df.format(entry.getValue()));
116 | break;
117 | }
118 | }
119 |
120 | textView.setText("");
121 |
122 | }
123 | }
124 | });
125 |
126 | textView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
127 |
128 | @Override
129 | public void onItemClick(AdapterView> parent, View view,
130 | int position, long id) {
131 |
132 | for (Map.Entry entry : MENU.entrySet()){
133 | if (entry.getKey().equals(textView.getText().toString())){
134 | UnitCostInput.setText(""+df.format(entry.getValue()));
135 | break;
136 | }
137 | }
138 | }
139 | });
140 | Total.setOnClickListener(new View.OnClickListener() {
141 | @Override
142 | public void onClick(View v) {
143 | if (OrderDisplay.getText().toString().equals("")){
144 | Log.d("SDS","DSDS");
145 | }else{
146 | Intent intent = new Intent(RestaurantView.this, CheckOut.class);
147 | intent.putExtra("LineItems",OrderDisplay.getText().toString());
148 | intent.putExtra("Restaurant",restaurant.getName());
149 | intent.putExtra("purchaseAddress",purchaseAddress);
150 | intent.putExtra("DeliveryCharge",restaurant.getDeliveryCharge());
151 | intent.putExtra("deliveryPickup",deliveryPickup);
152 | intent.putExtra("image",restaurant.getImageId());
153 | intent.putExtra("Total",TotalDisplay.getText().toString());
154 | intent.putExtra("RestaurantAddress",restaurant.getAddressName());
155 | startActivity(intent);
156 | }
157 |
158 | }
159 | });
160 |
161 |
162 | }
163 | }
164 |
165 | String setDate(){
166 | SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
167 | Date d = new Date();
168 | String dayOfTheWeek = sdf.format(d);
169 | String hours = restaurant.getHours(dayOfTheWeek);
170 | return hours;
171 |
172 | }
173 |
174 | public Restaurant findLoc(ArrayList Locations, String Location){
175 |
176 | for (Restaurant r: Locations){
177 | if (Location.equals(r.getName())){
178 | return r;
179 | }
180 | }
181 | return null;
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/drawable/chicagos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/drawable/chicagos.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/drawable/johnathans.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/drawable/johnathans.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/drawable/oaklawn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/drawable/oaklawn.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/drawable/sataitos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/drawable/sataitos.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/drawable/slims.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/drawable/slims.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/layout/activity_check_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
22 |
23 |
33 |
34 |
35 |
38 |
39 |
45 |
46 |
50 |
51 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
81 |
82 |
88 |
89 |
93 |
94 |
105 |
106 |
120 |
121 |
122 |
123 |
127 |
128 |
135 |
136 |
144 |
145 |
146 |
150 |
151 |
158 |
159 |
172 |
173 |
174 |
179 |
180 |
186 |
187 |
196 |
197 |
202 |
203 |
209 |
210 |
213 |
214 |
221 |
222 |
227 |
228 |
236 |
237 |
242 |
243 |
244 |
245 |
246 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
25 |
26 |
32 |
33 |
44 |
45 |
56 |
57 |
67 |
68 |
75 |
76 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/layout/activity_order_placed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
26 |
27 |
28 |
31 |
32 |
38 |
39 |
43 |
44 |
54 |
55 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
76 |
77 |
83 |
84 |
87 |
88 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/layout/activity_restaurant_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
25 |
26 |
27 |
30 |
31 |
37 |
41 |
42 |
51 |
52 |
58 |
59 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
83 |
84 |
85 |
90 |
91 |
92 |
100 |
101 |
102 |
103 |
107 |
108 |
117 |
118 |
131 |
132 |
133 |
134 |
138 |
139 |
149 |
150 |
164 |
165 |
166 |
167 |
172 |
173 |
184 |
185 |
199 |
200 |
201 |
205 |
206 |
215 |
216 |
227 |
228 |
229 |
230 |
241 |
242 |
243 |
244 |
245 |
246 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/powermobileweb/Food-Delivery-Android/8de9402b68945d8761f736358b1189ed30f5a560/Food Delivery/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | final
3 |
4 |
--------------------------------------------------------------------------------
/Food Delivery/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Food Delivery/src/test/java/com/example/soxluvr23/afinal/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.soxluvr23.afinal;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Food-Delivery-Android-Application
2 |
3 | On the First Screen it takes a plain text address from the user and converts it to a Location with a Latitude and Longitude value so that it can compare to other locations. There is also the option to choose between Pickup and Delivery. Even though not super clear, you wouldn’t pay a tip or a delivery fee if you were to choose to pick it up yourself.
4 |
5 | After hitting submit, the App takes your Latitude and Longitude and finds the distance between those restaurants and you. The distance method built into the Android Location class returns in meters so there is a conversion to miles needed. Although not super obvious, that is actually a ListView and if it had more restaurants, it would scroll through. That Location gets all restaurants except one in the suburbs in this example. To change the address, just type in the edittext field again and submit. To progress, click on the restaurant you want to eat at.
6 |
7 | The next menu is the brains of the application; it actually takes the orders. You type in the Items field and there is a drop down that yields options. Clicking on that will go to quantity and after adjusting that, clicking add to order will add it to the bottom item log, which is a little bit different than assignment 3. To proceed, click Checkout. To go to the previous menu, just hit the back button.
8 |
9 | After adding food, it gives you the option to check out and place the order. It reuses the address provided before, but needs the customer’s Name, Phone and Credit Card Number. You can’t actually continue without filling out these fields. Clicking Place order will place the order and bring you to the final menu.
10 |
11 | The final screen shows a map of the restaurant and the customer’s location and displays the order.
12 |
--------------------------------------------------------------------------------