├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── renesotolira.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── MenuDroid-Server.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── aybars
│ │ └── arslan
│ │ └── menudroid_server
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── aybars
│ │ └── arslan
│ │ └── menudroid_server
│ │ ├── MainActivity.java
│ │ ├── MainActivityServer.java
│ │ ├── OrderDetailsActivity.java
│ │ ├── db
│ │ ├── SqlOperations.java
│ │ └── SqliteConnection.java
│ │ ├── services
│ │ └── MyService.java
│ │ └── socket
│ │ ├── JsonSocketServer.java
│ │ └── ServerAsyncTask.java
│ └── res
│ ├── drawable
│ ├── food_icon.png
│ ├── food_icon_real.png
│ ├── logo_small_crop.png
│ ├── main_custom_button.xml
│ ├── main_custom_button_blue.xml
│ ├── main_custom_button_coffee.xml
│ ├── main_custom_button_green.xml
│ ├── main_custom_button_logined.xml
│ ├── main_custom_button_text_color.xml
│ ├── main_custom_button_yellow.xml
│ └── main_test.png
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_order_details.xml
│ ├── activity_server.xml
│ └── tool_bar.xml
│ ├── menu
│ ├── menu_main.xml
│ └── menu_order_details.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
└── main_screen.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | MenuDroid-Server
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/renesotolira.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | Abstraction issues
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MenuDroid-Server.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MenuDroid-Server
2 | MenuDroid - Android Restaurant Managment Project - Server Side
3 |
4 | * [For client application click](https://github.com/arslanaybars/MenuDroid)
5 |
6 | This project purpose to develop a open source restaurant management application
7 |
8 | - Its our main screen
9 |
10 | 
11 |
12 | Blue table means : Have Order
13 | Yellow table means : Want to get Bill
14 | Green table means : Calling Waiter
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.2"
6 |
7 | defaultConfig {
8 | applicationId "aybars.arslan.menudroid_server"
9 | minSdkVersion 14
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
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 | compile 'com.android.support:appcompat-v7:21.0.3'
25 | // Material Dialogs -for dialog
26 | compile 'com.afollestad:material-dialogs:0.6.3.5'
27 | }
28 |
--------------------------------------------------------------------------------
/app/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 D:\AndroidStudio\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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/aybars/arslan/menudroid_server/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/MainActivity.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server;
2 |
3 | import android.os.AsyncTask;
4 | import android.os.Bundle;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.util.Log;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 | import android.widget.TextView;
10 | import android.widget.Toast;
11 |
12 | import java.io.BufferedReader;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.InputStreamReader;
16 | import java.io.PrintWriter;
17 | import java.net.InetAddress;
18 | import java.net.NetworkInterface;
19 | import java.net.ServerSocket;
20 | import java.net.Socket;
21 | import java.net.SocketException;
22 | import java.util.Enumeration;
23 |
24 |
25 | public class MainActivity extends ActionBarActivity {
26 |
27 | private TextView tvClientMsg,tvServerIP,tvServerPort;
28 | private final int SERVER_PORT = 8080; //Define the server port
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_main);
34 |
35 | tvServerIP = (TextView)findViewById(R.id.tvServerIP);
36 | tvServerPort = (TextView)findViewById(R.id.tvServerPort);
37 | tvServerPort.setText(Integer.toString(SERVER_PORT));
38 | //String from Client
39 | tvClientMsg = (TextView)findViewById(R.id.tvClientMsg);
40 |
41 | getDeviceIpAddress();
42 |
43 | //New thread to listen to incoming connections
44 | new Thread(new Runnable() {
45 |
46 | @Override
47 | public void run() {
48 | try {
49 | //Create a server socket object and bind it to a port
50 | ServerSocket socServer = new ServerSocket(SERVER_PORT);
51 | //Create server side client socket reference
52 | Socket socClient = null;
53 | //Infinite loop will listen for client requests to connect
54 | while (true) {
55 | //Accept the client connection and hand over communication to server side client socket
56 | socClient = socServer.accept();
57 | //For each client new instance of AsyncTask will be created
58 | ServerAsyncTask serverAsyncTask = new ServerAsyncTask();
59 | //Start the AsyncTask execution
60 | //Accepted client socket object will pass as the parameter
61 | serverAsyncTask.execute(new Socket[] {socClient});
62 | }
63 | } catch (IOException e) {
64 | e.printStackTrace();
65 | }
66 | }
67 | }).start();
68 | }
69 |
70 | /**
71 | * Get ip address of the device
72 | */
73 | public void getDeviceIpAddress() {
74 | try {
75 | //Loop through all the network interface devices
76 | for (Enumeration enumeration = NetworkInterface
77 | .getNetworkInterfaces(); enumeration.hasMoreElements();) {
78 | NetworkInterface networkInterface = enumeration.nextElement();
79 | //Loop through all the ip addresses of the network interface devices
80 | for (Enumeration enumerationIpAddr = networkInterface.getInetAddresses(); enumerationIpAddr.hasMoreElements();) {
81 | InetAddress inetAddress = enumerationIpAddr.nextElement();
82 | //Filter out loopback address and other irrelevant ip addresses
83 | if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == 4) {
84 | //Print the device ip address in to the text view
85 | tvServerIP.setText(inetAddress.getHostAddress());
86 | }
87 | }
88 | }
89 | } catch (SocketException e) {
90 | Log.e("ERROR:", e.toString());
91 | }
92 | }
93 |
94 |
95 |
96 | /**
97 | * AsyncTask which handles the commiunication with clients
98 | */
99 | class ServerAsyncTask extends AsyncTask {
100 | //Background task which serve for the client
101 | @Override
102 | protected String doInBackground(Socket... params) {
103 | String result = null;
104 | //Get the accepted socket object
105 | Socket mySocket = params[0];
106 | try {
107 | //Get the data input stream comming from the client
108 | InputStream is = mySocket.getInputStream();
109 | //Get the output stream to the client
110 | PrintWriter out = new PrintWriter(
111 | mySocket.getOutputStream(), true);
112 | //Write data to the data output stream
113 | out.println("Hello from MenuDroid-Server");
114 | //Buffer the data input stream
115 | BufferedReader br = new BufferedReader(
116 | new InputStreamReader(is));
117 | //Read the contents of the data buffer
118 | result = br.readLine();
119 | //Close the client connection
120 | mySocket.close();
121 | } catch (IOException e) {
122 | e.printStackTrace();
123 | }
124 | return result;
125 | }
126 |
127 | @Override
128 | protected void onPostExecute(String s) {
129 | //After finishing the execution of background task data will be write the text view
130 | tvClientMsg.setText(s);
131 | Log.i("message from client : ",s);
132 | }
133 | }
134 |
135 |
136 | @Override
137 | public boolean onCreateOptionsMenu(Menu menu) {
138 | // Inflate the menu; this adds items to the action bar if it is present.
139 | getMenuInflater().inflate(R.menu.menu_main, menu);
140 | return true;
141 | }
142 |
143 | @Override
144 | public boolean onOptionsItemSelected(MenuItem item) {
145 | // Handle action bar item clicks here. The action bar will
146 | // automatically handle clicks on the Home/Up button, so long
147 | // as you specify a parent activity in AndroidManifest.xml.
148 | int id = item.getItemId();
149 |
150 | //noinspection SimplifiableIfStatement
151 | if (id == R.id.action_settings) {
152 | return true;
153 | }
154 |
155 |
156 |
157 |
158 | return super.onOptionsItemSelected(item);
159 | }
160 |
161 | Toast m_currentToast;
162 |
163 | void showToast(String text) {
164 | if (m_currentToast != null) {
165 | m_currentToast.cancel();
166 | }
167 | m_currentToast = Toast.makeText(this, text, Toast.LENGTH_LONG);
168 | m_currentToast.show();
169 |
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/MainActivityServer.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.os.Handler;
8 | import android.support.v7.app.ActionBarActivity;
9 | import android.util.Log;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.TextView;
15 |
16 | import com.afollestad.materialdialogs.AlertDialogWrapper;
17 |
18 | import java.net.InetAddress;
19 | import java.net.NetworkInterface;
20 | import java.net.SocketException;
21 | import java.util.ArrayList;
22 | import java.util.Enumeration;
23 | import java.util.HashMap;
24 | import java.util.Timer;
25 | import java.util.TimerTask;
26 |
27 | import aybars.arslan.menudroid_server.db.SqlOperations;
28 | import aybars.arslan.menudroid_server.services.MyService;
29 |
30 |
31 |
32 |
33 | public class MainActivityServer extends ActionBarActivity {
34 | private static Timer timer2;
35 | private boolean isPaused = true;
36 | private SqlOperations sqliteoperation;
37 | private static final String KEY_NUMBER_TABLE = "number_table";
38 | private static final String KEY_KIND_REQUEST = "kind_of_request";
39 | private static final String KEY_REQUEST_TEXT = "request_text";
40 | private static final String KEY_CONFIRM_SESSION = "confirmSession";
41 | private static final String KEY_SHOW = "show";
42 | static String TABLE_NAME = "Table Name";
43 | private Button btnTable;
44 | private TextView tvIP;
45 |
46 | private Handler handler = new Handler();
47 |
48 | private SqlOperations sqliteoperationShow,sqliteoperation2 ;
49 |
50 |
51 | @Override
52 | protected void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | setContentView(R.layout.activity_server);
55 | Log.d("SERVICE", "starting service");
56 | startService(new Intent(MainActivityServer.this, MyService.class)); //this line enabled the Intent service.
57 | sqliteoperation = new SqlOperations(getApplicationContext());
58 | sqliteoperation.open();
59 | tvIP = (TextView) findViewById(R.id.tvIP);
60 | getDeviceIpAddress(); //Ipaddress method.
61 |
62 | }
63 |
64 | @Override
65 | public void onResume() {
66 | Log.i("Activity", "onResume()");
67 | handler.postDelayed(runnable, 1000);
68 | super.onResume();
69 |
70 | }
71 |
72 |
73 | public void tableClick(View v){
74 | String IdAsString = v.getResources().getResourceName(v.getId());
75 | //this return namepackage: id /btn1 or btn2 , etc
76 | //this is to get "btn1" , "btn5" depending from the View selected.
77 | String idString[]=IdAsString.split("/");
78 | Log.d("idString",IdAsString);
79 | Log.d("idString[1]",idString[1]); //btn?
80 | int tableNumber=Integer.parseInt(idString[1].substring(3));
81 | Log.d("Table","table # "+tableNumber);//get tables number
82 | //get color status
83 | sqliteoperation2 = new SqlOperations(getApplicationContext());
84 | sqliteoperation2.open();
85 | String status=sqliteoperation2.getSpecificTableStatus(tableNumber);
86 | Log.d("status","status is "+status);//get tables number
87 | sqliteoperation2.close();
88 |
89 | if(status.equals("O")){
90 | // Intent intentOrder = new Intent(MainActivityServer.this, OrderDetailsActivity.class);
91 | // intentOrder.putExtra("number", String.valueOf(tableNumber));
92 | // startActivity(intentOrder);
93 | // ChangeColorTable(btnTable, "W", 0, 1, tableNumber);
94 | showOrder(String.valueOf(tableNumber));
95 | } else if (status.equals("W")) {
96 | // ChangeColorTable(btnTable, "W", 0, 1, tableNumber);
97 | showWaiter(tableNumber);
98 | } else if (status.equals("B")) {
99 | // ChangeColorTable(btnTable, "B", 0, 1, tableNumber);
100 | showBill(tableNumber);
101 | } else if (status.equals("L")) {
102 | // ChangeColorTable(btnTable, "L", 0, 1, tableNumber);
103 | showLogined(tableNumber);
104 | } else {
105 |
106 | }
107 | }
108 |
109 | private void showOrder(String number) {
110 | //TODO
111 | //add delivered button after click delivered the button rechange the table color
112 |
113 | sqliteoperation= new SqlOperations(getApplicationContext());
114 | sqliteoperation.open();
115 | ArrayList> dictionary =sqliteoperation.getOrder(Integer.parseInt(number));
116 | // sqliteoperation.close();
117 |
118 | String totalbyFood,quantity,food_name,messageOrder,price;
119 | messageOrder="\nOrder\nYour ordered";
120 | float totalbyOrder=0;
121 | int j;
122 | for (int i = 0; i < dictionary.size(); i++) {
123 |
124 | j=i+1;
125 | /*I start at index 0 and finish at the penultimate index */
126 | HashMap map = dictionary.get(i); //Get the corresponding map from the index
127 | totalbyFood=map.get("totalByFood").toString();
128 | price=map.get("price").toString();
129 | quantity=map.get("quantity").toString();
130 | food_name=map.get("food_name").toString();
131 | messageOrder+="\n "+j+" - "+food_name+" ("+price+" $ x "+ quantity +") "+ totalbyFood+"$";
132 | totalbyOrder+=Float.parseFloat(totalbyFood);
133 | }
134 | messageOrder+="\n Total = "+totalbyOrder+"$";
135 |
136 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
137 | dialogBuilder.setMessage(messageOrder);//R.string.main_order_message)
138 | dialogBuilder.setTitle("Details");
139 |
140 | dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
141 | @Override
142 | public void onClick(DialogInterface dialog, int which) {
143 | dialog.dismiss();
144 | }
145 | });
146 |
147 | dialogBuilder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
148 | @Override
149 | public void onClick(DialogInterface dialog, int which) {
150 | //Scan Barcode
151 | // clean
152 | // ChangeColorTable(btnTable, "L");
153 | }
154 | });
155 | dialogBuilder.create().show();
156 | }
157 |
158 | private void showWaiter(final int number) {
159 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
160 | dialogBuilder.setMessage("Are you sure to call waiter");
161 | dialogBuilder.setTitle("Call Waiter");
162 |
163 | dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
164 | @Override
165 | public void onClick(DialogInterface dialog, int which) {
166 | dialog.dismiss();
167 | }
168 | });
169 |
170 | dialogBuilder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
171 | @Override
172 | public void onClick(DialogInterface dialog, int which) {
173 | // After called waiter rechange table
174 | // but still table have some people so showed logined color
175 | btnTable = chooseTable(number);
176 | btnTable.setBackgroundResource(R.drawable.main_custom_button_logined);
177 | }
178 | });
179 |
180 | dialogBuilder.create().show();
181 | }
182 |
183 | private void showBill(final int number) {
184 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
185 | dialogBuilder.setMessage("Bill paid");
186 | dialogBuilder.setTitle("Finish session");
187 |
188 | dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
189 | @Override
190 | public void onClick(DialogInterface dialog, int which) {
191 | dialog.dismiss();
192 | }
193 | });
194 |
195 | dialogBuilder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
196 | @Override
197 | public void onClick(DialogInterface dialog, int which) {
198 | // after payment recolor
199 | // TODO after payment also finish the session
200 | btnTable = chooseTable(number);
201 | btnTable.setBackgroundResource(R.drawable.main_custom_button_logined);
202 | }
203 | });
204 |
205 | dialogBuilder.create().show();
206 | }
207 |
208 | private void showLogined(final int number) {
209 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
210 | dialogBuilder.setMessage("message");
211 | dialogBuilder.setTitle("Title");
212 |
213 | dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
214 | @Override
215 | public void onClick(DialogInterface dialog, int which) {
216 | dialog.dismiss();
217 | }
218 | });
219 |
220 | dialogBuilder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
221 | @Override
222 | public void onClick(DialogInterface dialog, int which) {
223 | // After called waiter rechange table
224 | // but still table have some people so showed logined color
225 | btnTable = chooseTable(number);
226 | btnTable.setBackgroundResource(R.drawable.main_custom_button_logined);
227 | }
228 | });
229 |
230 | dialogBuilder.create().show();
231 | }
232 |
233 | /**
234 | * Get ip address of the device
235 | */
236 | public void getDeviceIpAddress() {
237 | try {
238 | //Loop through all the network interface devices
239 | for (Enumeration enumeration = NetworkInterface
240 | .getNetworkInterfaces(); enumeration.hasMoreElements(); ) {
241 | NetworkInterface networkInterface = enumeration.nextElement();
242 | //Loop through all the ip addresses of the network interface devices
243 | for (Enumeration enumerationIpAddr = networkInterface.getInetAddresses(); enumerationIpAddr.hasMoreElements(); ) {
244 | InetAddress inetAddress = enumerationIpAddr.nextElement();
245 | //Filter out loopback address and other irrelevant ip addresses
246 | if (!inetAddress.isLoopbackAddress() && inetAddress.getAddress().length == 4) {
247 | //Print the device ip address in to the text view
248 | tvIP.setText(inetAddress.getHostAddress());
249 | }
250 | }
251 | }
252 | } catch (SocketException e) {
253 | Log.e("ERROR:", e.toString());
254 | }
255 | }
256 |
257 | private Runnable runnable = new Runnable() {
258 | @Override
259 | public void run() {
260 | /* do what you need to do */
261 | try{
262 | doLoopProcess2();
263 | }catch(Exception e)
264 | {
265 | Log.d("Exception", ""+e.toString());
266 | }
267 |
268 | /* and here comes the "trick" */
269 | handler.postDelayed(this, 10000);
270 | }
271 | };
272 |
273 |
274 |
275 | @Override
276 | public void onPause() {
277 | Log.i("Activity", "onPause()");
278 | super.onPause();
279 | }
280 |
281 | @Override
282 | public void onStop() {
283 | handler.removeCallbacks(runnable);
284 | Log.i("Activity", "onStop()");
285 | super.onStop();
286 | }
287 |
288 | public void doLoopProcess2() {
289 |
290 | final ArrayList> dictionary = sqliteoperation.getTableStatus();
291 | runOnUiThread(new Runnable() {
292 | @Override
293 | public void run() {
294 | for (int i = 0; i < dictionary.size(); i++) {
295 | /*I start at index 0 and finish at the penultimate index */
296 | HashMap map = dictionary.get(i); //Get the corresponding map from the index
297 | Log.d("DictionaryMAinActivity", map.get(KEY_NUMBER_TABLE) + " --- " +
298 | map.get(KEY_KIND_REQUEST) + "------" +
299 | map.get(KEY_REQUEST_TEXT) + "------" +
300 | map.get(KEY_CONFIRM_SESSION) + "------" +
301 | map.get(KEY_SHOW)); /*this is a simple log XD, to verify if there is information.*/
302 | TABLE_NAME = map.get(KEY_REQUEST_TEXT);
303 |
304 |
305 | btnTable = chooseTable(Integer.parseInt(map.get(KEY_NUMBER_TABLE).toString()));
306 | //get the capital letter from each Map,
307 | ChangeColorTable(btnTable, map.get(KEY_KIND_REQUEST).toString().toUpperCase(),
308 | Integer.parseInt(map.get(KEY_CONFIRM_SESSION).toString()), Integer.parseInt(map.get(KEY_SHOW).toString()), Integer.parseInt(map.get(KEY_NUMBER_TABLE).toString()));
309 | }
310 | }
311 | });
312 | }
313 |
314 | public void doLoopProcess() {
315 |
316 |
317 |
318 | //Timer with a thread inside to search the status of each table.
319 | int delay = 100; //is the delay or sleep between every timer loop.
320 | int period = 10000;//ten seconds
321 | final Context ctx = this;
322 | timer2 = new Timer();
323 | timer2.scheduleAtFixedRate(new TimerTask() {
324 | public void run() {
325 | Thread thread = new Thread() {
326 | @Override
327 | public void run() {
328 | try {
329 | synchronized (this) {
330 | wait(1000);
331 |
332 | /* call the method getTableStatus from SqlOperations class ,
333 | this method returns an ArrayList>
334 | this means_:
335 | Index- KEY VALUE
336 | (1) number_table 1
337 | kind_of_request W
338 | request_text W-MenuDroidTable1
339 | (2) number_table 2
340 | kind_of_request O
341 | request_text O-MenuDroidTable1
342 | (3) ....
343 | ....
344 | ...
345 | (4)
346 | .
347 | .
348 | .
349 | .
350 | ETC
351 | */
352 | final ArrayList> dictionary = sqliteoperation.getTableStatus();
353 | runOnUiThread(new Runnable() {
354 | @Override
355 | public void run() {
356 | for (int i = 0; i < dictionary.size(); i++) {
357 | /*I start at index 0 and finish at the penultimate index */
358 | HashMap map = dictionary.get(i); //Get the corresponding map from the index
359 | Log.d("DictionaryMAinActivity", map.get(KEY_NUMBER_TABLE) + " --- " +
360 | map.get(KEY_KIND_REQUEST) + "------" +
361 | map.get(KEY_REQUEST_TEXT) + "------" +
362 | map.get(KEY_CONFIRM_SESSION) + "------" +
363 | map.get(KEY_SHOW)); /*this is a simple log XD, to verify if there is information.*/
364 | TABLE_NAME = map.get(KEY_REQUEST_TEXT);
365 |
366 |
367 | btnTable = chooseTable(Integer.parseInt(map.get(KEY_NUMBER_TABLE).toString()));
368 | //get the capital letter from each Map,
369 | ChangeColorTable(btnTable, map.get(KEY_KIND_REQUEST).toString().toUpperCase(),
370 | Integer.parseInt(map.get(KEY_CONFIRM_SESSION).toString()),Integer.parseInt(map.get(KEY_SHOW).toString()),Integer.parseInt(map.get(KEY_NUMBER_TABLE).toString()));
371 | }
372 | }
373 | });
374 |
375 | }
376 | } catch (InterruptedException e) {
377 | e.printStackTrace();
378 | /*Get possible execption*/
379 | }
380 | }
381 |
382 | ;
383 | };
384 | thread.start();
385 | }
386 | }, delay, period);
387 | }
388 |
389 | public Button chooseTable(int number) {
390 | Button btnChooseTable = (Button) findViewById(R.id.btn1);
391 | // GET the value from number_table key form the actual Map. (this map has "key"-"value
392 | switch (number) {
393 | //Depending the number is the table (button) that we get to change the color.
394 | case 1:
395 | btnChooseTable = (Button) findViewById(R.id.btn1);
396 | break;
397 | case 2:
398 | btnChooseTable = (Button) findViewById(R.id.btn2);
399 | break;
400 | case 3:
401 | btnChooseTable = (Button) findViewById(R.id.btn3);
402 | break;
403 | case 4:
404 | btnChooseTable = (Button) findViewById(R.id.btn4);
405 | break;
406 | case 5:
407 | btnChooseTable = (Button) findViewById(R.id.btn5);
408 | break;
409 | case 6:
410 | btnChooseTable = (Button) findViewById(R.id.btn6);
411 | break;
412 | case 7:
413 | btnChooseTable = (Button) findViewById(R.id.btn7);
414 | break;
415 | case 8:
416 | btnChooseTable = (Button) findViewById(R.id.btn8);
417 | break;
418 | case 9:
419 | btnChooseTable = (Button) findViewById(R.id.btn9);
420 | break;
421 |
422 | }
423 | return btnChooseTable;
424 | }
425 |
426 | public void ChangeColorTable(Button tableColor, String capitalLetter,int session,int show,int numbertable) {
427 | if (capitalLetter.equals("B")) {
428 | /*B- bill = the color change to yellow*/
429 | tableColor.setBackgroundResource(R.drawable.main_custom_button_yellow);
430 | tableColor.setTextColor(R.drawable.main_custom_button_blue);
431 | } else if (capitalLetter.equals("O")) {
432 | /*O- order = the color change to blue*/
433 | tableColor.setBackgroundResource(R.drawable.main_custom_button_blue);
434 | } else if (capitalLetter.equals("W")) {
435 | /*W waiter = the color change to green */
436 | tableColor.setBackgroundResource(R.drawable.main_custom_button_green);
437 | } else if (capitalLetter.equals("L")) {
438 | /*L login = the color logined */
439 | tableColor.setBackgroundResource(R.drawable.main_custom_button_logined);
440 | if(session==0 && show==1){
441 | ///update show to cero
442 | sqliteoperationShow = new SqlOperations(getApplicationContext());
443 | sqliteoperationShow.open();
444 | sqliteoperationShow.updatevalueShow(numbertable);
445 | sqliteoperationShow.close();
446 |
447 | showInstantLogin(numbertable);
448 | //when you accept de dialog update session to 1
449 | }
450 |
451 | } else {
452 | // If the result is diferrent to B,O,W , the color change to brown
453 | // TODO I think we dont need to brown button if the table non use so its red -RIGHT
454 | tableColor.setBackgroundResource(R.drawable.main_custom_button);
455 | }
456 | }
457 |
458 | private void showInstantLogin(final int numbertable) {
459 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
460 | dialogBuilder.setTitle("test");
461 | dialogBuilder.setMessage( TABLE_NAME + " is logined");
462 |
463 | dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
464 | @Override
465 | public void onClick(DialogInterface dialog, int which) {
466 | dialog.dismiss();
467 | }
468 | });
469 |
470 | dialogBuilder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
471 | @Override
472 | public void onClick(DialogInterface dialog, int which) {
473 |
474 | SqlOperations sqliteoperationConfirm = new SqlOperations(getApplicationContext());
475 | sqliteoperationConfirm .open();
476 | sqliteoperationConfirm .updatevalueConfirm(numbertable);
477 | sqliteoperationConfirm .close();
478 | dialog.dismiss();
479 | }
480 | });
481 |
482 | dialogBuilder.create().show();
483 | }
484 |
485 | @Override
486 | protected void onDestroy() {
487 | Log.i("Activity", "onStop()");
488 | handler.removeCallbacks(runnable);
489 | if(sqliteoperation!=null) sqliteoperation.close();
490 | if(sqliteoperation2!=null) sqliteoperation2.close();
491 | if(sqliteoperationShow!=null) sqliteoperationShow.close();
492 | super.onDestroy();
493 | }
494 |
495 | @Override
496 | public boolean onCreateOptionsMenu(Menu menu) {
497 | // Inflate the menu; this adds items to the action bar if it is present.
498 | getMenuInflater().inflate(R.menu.menu_main, menu);
499 | return true;
500 | }
501 |
502 | @Override
503 | public boolean onOptionsItemSelected(MenuItem item) {
504 | // Handle action bar item clicks here. The action bar will
505 | // automatically handle clicks on the Home/Up button, so long
506 | // as you specify a parent activity in AndroidManifest.xml.
507 | int id = item.getItemId();
508 | //noinspection SimplifiableIfStatement
509 | if (id == R.id.action_settings) {
510 | return true;
511 | }
512 |
513 | return true;
514 | }
515 |
516 | }
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/OrderDetailsActivity.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.util.Log;
7 | import android.view.Menu;
8 | import android.view.MenuItem;
9 |
10 | import com.afollestad.materialdialogs.AlertDialogWrapper;
11 |
12 | import java.util.ArrayList;
13 | import java.util.HashMap;
14 |
15 | import aybars.arslan.menudroid_server.db.SqlOperations;
16 |
17 |
18 | public class OrderDetailsActivity extends ActionBarActivity {
19 | private SqlOperations sqliteoperation;
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_order_details);
24 | Intent intent = getIntent();
25 | String numberString = intent.getStringExtra("number");
26 | Log.d("number", "the number is : "+numberString);
27 | showDialog(numberString);
28 | }
29 |
30 | public void showDialog(String number){
31 |
32 | sqliteoperation= new SqlOperations(getApplicationContext());
33 | sqliteoperation.open();
34 | ArrayList> dictionary =sqliteoperation.getOrder(Integer.parseInt(number));
35 | sqliteoperation.close();
36 |
37 | String totalbyFood,quantity,food_name,messageOrder,price;
38 | messageOrder="\nOrder\nYour ordered";
39 | float totalbyOrder=0;
40 | int j;
41 | for (int i = 0; i < dictionary.size(); i++) {
42 |
43 | j=i+1;
44 | /*I start at index 0 and finish at the penultimate index */
45 | HashMap map = dictionary.get(i); //Get the corresponding map from the index
46 | totalbyFood=map.get("totalByFood").toString();
47 | price=map.get("price").toString();
48 | quantity=map.get("quantity").toString();
49 | food_name=map.get("food_name").toString();
50 | messageOrder+="\n "+j+" - "+food_name+" ("+price+" $ x "+ quantity +") "+ totalbyFood+"$";
51 | totalbyOrder+=Float.parseFloat(totalbyFood);
52 | }
53 | messageOrder+="\n Total = "+totalbyOrder+"$";
54 |
55 | AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(this);
56 | dialogBuilder.setMessage(messageOrder);//R.string.main_order_message)
57 | dialogBuilder.setTitle("Details");
58 | dialogBuilder.create().show();
59 | }
60 |
61 | @Override
62 | public boolean onCreateOptionsMenu(Menu menu) {
63 | // Inflate the menu; this adds items to the action bar if it is present.
64 | getMenuInflater().inflate(R.menu.menu_order_details, menu);
65 | return true;
66 | }
67 |
68 | @Override
69 | public boolean onOptionsItemSelected(MenuItem item) {
70 | // Handle action bar item clicks here. The action bar will
71 | // automatically handle clicks on the Home/Up button, so long
72 | // as you specify a parent activity in AndroidManifest.xml.
73 | int id = item.getItemId();
74 |
75 | //noinspection SimplifiableIfStatement
76 | if (id == R.id.action_settings) {
77 | return true;
78 | }
79 |
80 | return super.onOptionsItemSelected(item);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/db/SqlOperations.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server.db;
2 |
3 |
4 | import android.content.ContentValues;
5 | import android.content.Context;
6 | import android.database.Cursor;
7 | import android.database.SQLException;
8 | import android.database.sqlite.SQLiteDatabase;
9 | import android.util.Log;
10 |
11 | import org.json.JSONArray;
12 | import org.json.JSONException;
13 |
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 |
17 | /***
18 | * Clase para manipular las operaciones simples con db local como son insert,delete,update,etc
19 | */
20 | public class SqlOperations {
21 |
22 | //the next two variable it is only for debugging test.
23 | private String TAG = this.getClass().getSimpleName();
24 | private boolean LogDebug=true;
25 |
26 | // Database fields
27 | private SQLiteDatabase database;
28 | private SqliteConnection sqliteconnection;
29 | private static final String KEY_NUMBER_TABLE = "number_table";
30 | private static final String KEY_KIND_REQUEST = "kind_of_request";
31 | private static final String KEY_REQUEST_TEXT = "request_text";
32 | private static final String KEY_CONFIRM_SESSION = "confirmSession";
33 | private static final String KEY_SHOW = "show";
34 |
35 |
36 |
37 | private static final String KEY_QTY = "quantity";
38 | private static final String KEY_FOOD_NAME = "food_name";
39 | private static final String KEY_PRICE = "price";
40 | private static final String KEY_TOTAL = "total";
41 |
42 |
43 | public SqlOperations(Context context) {
44 | sqliteconnection = new SqliteConnection(context); //conexion y/o creacion de DB
45 | }
46 |
47 | public void open() throws SQLException {
48 |
49 |
50 |
51 | database = sqliteconnection.getWritableDatabase(); // avaliable to write in the db.
52 | }
53 |
54 | public void close() {
55 | if(database!=null){ database.close();}
56 |
57 | sqliteconnection.close(); //close db
58 | }
59 |
60 | public String getSpecificTableStatus(int number) {
61 | Cursor cursor;
62 | String status="";
63 | String select = "SELECT kind_of_request FROM Restaurant where number_table="+number+" order by _id desc limit 1";
64 | cursor = database.rawQuery(select, null);
65 | if (cursor.getCount() == 0) // if there are no elements do nothing
66 | {
67 | Log.d(TAG, "no elements");
68 | } else {
69 | cursor.moveToNext();
70 | status=cursor.getString(0);
71 | }
72 | if(cursor!=null) cursor.close();
73 |
74 | return status;
75 | }
76 |
77 |
78 | public void updatevalueShow(int numbertable){
79 | /*This method is to doesnt show the Login Dialog*/
80 | ContentValues row = new ContentValues();
81 | row.put(KEY_SHOW,0);
82 | database.update(SqliteConnection.TABLE_NAME, row, "number_table "+"="+numbertable, null);
83 | }
84 |
85 | public void updatevalueConfirm(int numbertable){
86 | /*This method is to know if the session was confirmed*/
87 | ContentValues row = new ContentValues();
88 | row.put(KEY_CONFIRM_SESSION,1);
89 | database.update(SqliteConnection.TABLE_NAME, row, "number_table "+"="+numbertable, null);
90 | }
91 |
92 | public ArrayList> getTableStatus (){
93 |
94 | Cursor cursor;
95 | ArrayList> allElementsDictionary = new ArrayList>();
96 | String select = "SELECT distinct(number_table) ,kind_of_request,request_text,confirmSession,show FROM Restaurant group by number_table order by _id desc";
97 | /*The rawQuery do a query that we write before (select ... from restaurant ...)*/
98 | cursor = database.rawQuery(select,null);
99 | if(cursor.getCount()==0) // if there are no elements do nothing
100 | {
101 | Log.d(TAG,"no elements");
102 | ///return allElements dictionary empty.
103 | }
104 | else
105 | { //if there are elemnts
106 | Log.d(TAG,"there are elemnets");
107 | //get all the rows and pass the data to allElements dictionary.
108 |
109 | while(cursor.moveToNext()){
110 |
111 | //The cursor save all the rows returned by the query.
112 | //moveToNext is to advance at the next row.
113 | /*
114 | COLUMN (0) number_table , COLUMN (1) kind_of_request , COLUMN (2) request_Text
115 | * row (1) = 2 O O-MenuDroidTable2
116 | * row (2) == 1 W
117 | * ...
118 | * moveToNext means if I am in row(2) I will pass to row(3)
119 | *
120 | *
121 | *
122 | *
123 | *
124 | * */
125 |
126 | //cursor.getString(1) means I get the data from column with index 1 in this case "kind_of_request"
127 | /*
128 | *
129 | * */
130 |
131 |
132 | HashMap map = new HashMap();
133 | map.put(KEY_NUMBER_TABLE, cursor.getString(0));
134 | map.put(KEY_KIND_REQUEST, cursor.getString(1));
135 | map.put(KEY_REQUEST_TEXT, cursor.getString(2));
136 | map.put(KEY_CONFIRM_SESSION, cursor.getString(3));
137 | map.put(KEY_SHOW, cursor.getString(4));
138 | allElementsDictionary.add(map);
139 |
140 | if (LogDebug) {
141 | Log.d(TAG, "number : " + cursor.getString(0) +
142 | "\n kind :" + cursor.getString(1)+
143 | "\n text :" + cursor.getString(2)+
144 | "\n confirmSession :" + cursor.getString(3)+
145 | "\n show :" + cursor.getString(4)
146 | );
147 | }
148 |
149 | }
150 | }
151 | if (cursor!=null)
152 | {
153 | cursor.close();//It is important close the cursor when you finish your process.
154 | }
155 |
156 |
157 | return allElementsDictionary;
158 | }
159 |
160 | public void insertRequest(String request){
161 | /*The request could be:
162 | * B-MenuDroidTable#
163 | * O-
164 | * W-
165 | *
166 | * Where # is the table number e.g. 1,2,3,4 ,etc
167 | * B means Bill
168 | * O means order
169 | * W mean Waiter
170 | * L mean Login
171 | * */
172 | //GET THE REQUEST CHAIN and split the first character and get the table number
173 | String kind_request=request.substring(0,1);
174 | int last=request.lastIndexOf("Table")+5;
175 | Log.d("LAST", ""+last);
176 | String number=request.substring(last);
177 | Log.d("LAST", "" + number);
178 | ContentValues row = new ContentValues();
179 | row.put(KEY_NUMBER_TABLE, number);
180 | row.put(KEY_KIND_REQUEST, kind_request);
181 | row.put(KEY_REQUEST_TEXT, request);
182 | row.put(KEY_CONFIRM_SESSION, 0);
183 | row.put(KEY_SHOW, 1);
184 | database.insert(SqliteConnection.TABLE_NAME, null, row); //insert in DB the request
185 |
186 | Log.d("REQUEST","Kind is : "+kind_request+
187 | "request : "+ request+
188 | "number : "+number);
189 |
190 | // //if kind requet is L reset the tables order
191 | // if(kind_request.equals("L")){
192 | // setEmptyTableOrder(Integer.parseInt(number));
193 | // }
194 |
195 | }
196 |
197 | // public void setEmptyTableOrder(int numberTable){
198 | // database.delete("OrderClient", "number_table="+numberTable, null);
199 | // }
200 |
201 | public void insertOrder(JSONArray order,String numberTable) throws JSONException {
202 |
203 | for (int i = 0; i < order.length(); i++) { //Search inner the Categories array
204 | String totalByFood = order.getJSONObject(i).getString("totalByFood");
205 | String price = order.getJSONObject(i).getString("price");
206 | String quantity = order.getJSONObject(i).getString("quantity");
207 | String food_name = order.getJSONObject(i).getString("food_name");
208 |
209 | Log.d("TOTAL", "The total by food is " + totalByFood);
210 | Log.d("TOTAL", "The price " + price);
211 | Log.d("TOTAL", "The qty" + quantity);
212 | Log.d("TOTAL", "The food " + food_name);
213 | ContentValues row = new ContentValues();
214 | row.put(KEY_FOOD_NAME, food_name);
215 | row.put(KEY_QTY, Integer.parseInt(quantity));
216 | row.put(KEY_PRICE, price);
217 | row.put(KEY_NUMBER_TABLE, Integer.parseInt(numberTable));
218 | row.put(KEY_TOTAL,totalByFood);
219 | database.insert(SqliteConnection.TABLE_NAME_ORDER, null, row); //insert in DB the request
220 | }
221 | }
222 |
223 |
224 | public ArrayList> getOrder(int number){
225 |
226 | Cursor cursor;
227 | ArrayList> allElementsDictionary = new ArrayList>();
228 | String select = "SELECT quantity,price,food_name,total,number_table from OrderClient where number_table="+number+"";
229 | cursor = database.rawQuery(select,null);
230 | if(cursor.getCount()==0) // if there are no elements do nothing
231 | {
232 | Log.d(TAG,"no elements");
233 | }
234 | else
235 | { //if there are elemnts
236 | Log.d(TAG,"there are elemnets");
237 | //get all the rows and pass the data to allElements dictionary.
238 | float totalByOrder=0;
239 | while(cursor.moveToNext()){
240 | int qty=Integer.parseInt(cursor.getString(0));
241 |
242 | if(qty>0){
243 | float totalByFood=Float.parseFloat(cursor.getString(3));// qty * price
244 | totalByOrder+=totalByFood;
245 | HashMap map = new HashMap();
246 |
247 | map.put(KEY_QTY, cursor.getString(0));
248 | map.put(KEY_PRICE, cursor.getString(1));
249 | map.put(KEY_FOOD_NAME, cursor.getString(2));
250 | map.put("totalByFood", cursor.getString(3));
251 | allElementsDictionary.add(map);
252 | if (LogDebug) {
253 | Log.d(TAG, "qty : " + cursor.getString(0) +
254 | "\n price :" + cursor.getString(1)+
255 | "\n foodname :" + cursor.getString(2)+
256 | "\n totalByFood :"+ cursor.getString(3)+
257 | "\n table :"+ cursor.getString(4)
258 | );
259 | }
260 | }
261 | Log.d(TAG,"total is :"+totalByOrder);
262 | }
263 | }
264 | if (cursor!=null)
265 | {
266 | cursor.close();//It is important close the cursor when you finish your process.
267 | }
268 | return allElementsDictionary;
269 | }
270 |
271 |
272 | }
273 |
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/db/SqliteConnection.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server.db;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteOpenHelper;
6 |
7 | /**
8 | * Created by renesotolira on 21/03/15.
9 | */
10 | public class SqliteConnection extends SQLiteOpenHelper {
11 |
12 | public static final String DATABASE_NAME = "DroidRestaurant.db";
13 | public static final String TABLE_NAME = "Restaurant";
14 | private static final int DATABASE_VERSION = 1;
15 | public static final String TABLE_NAME_ORDER = "OrderClient";
16 |
17 |
18 |
19 | String sqlCreateTableOrder= "CREATE TABLE OrderClient (_id INTEGER PRIMARY KEY, number_table INTEGER, quantity INTEGER, price TEXT, total TEXT, food_name TEXT)";
20 |
21 | String sqlCreateTableRestaurant= "CREATE TABLE Restaurant (_id INTEGER PRIMARY KEY, number_table INTEGER, kind_of_request INTEGER, request_text TEXT, confirmSession INTEGER, show INTEGER)";
22 |
23 | /*Add new tables :
24 | * Categories
25 | * Food
26 | * */
27 | String sqlCreateTableCategories= "CREATE TABLE Categories (_idCategory INTEGER PRIMARY KEY, category_name TEXT)";
28 | String sqlCreateTableFood= "CREATE TABLE Food (_idFood INTEGER PRIMARY KEY, categoryID INTEGER, food_name TEXT)";
29 |
30 | public SqliteConnection(Context context) {
31 | super(context, DATABASE_NAME, null,DATABASE_VERSION);
32 | }
33 |
34 | @Override
35 | public void onCreate(SQLiteDatabase db) {
36 | db.execSQL(sqlCreateTableRestaurant);
37 | db.execSQL(sqlCreateTableCategories);
38 | db.execSQL(sqlCreateTableFood);
39 | db.execSQL(sqlCreateTableOrder);
40 |
41 | }
42 |
43 | @Override
44 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
45 | // db.execSQL("DROP TABLE IF EXISTS Restaurant");
46 |
47 | //db.execSQL(sqlCreateTableRestaurant);
48 |
49 | }
50 |
51 |
52 | }
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/services/MyService.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server.services;
2 |
3 | import android.app.AlarmManager;
4 | import android.app.IntentService;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.database.Cursor;
9 | import android.database.sqlite.SQLiteDatabase;
10 | import android.os.Build;
11 | import android.os.IBinder;
12 | import android.os.SystemClock;
13 | import android.util.Log;
14 |
15 | import java.io.IOException;
16 | import java.net.ServerSocket;
17 | import java.net.Socket;
18 | import java.util.Timer;
19 | import java.util.TimerTask;
20 |
21 | import aybars.arslan.menudroid_server.socket.ServerAsyncTask;
22 |
23 | /**
24 | * This is a IntentService , it will be running in background , every time was listen to request from client device.
25 | */
26 | public class MyService extends IntentService {
27 | private final int SERVER_PORT = 8080; //Define the server port
28 | private static Timer timer;
29 | private boolean isPaused = true;
30 | private SQLiteDatabase dbGlobal;
31 | private Cursor cursorSearch;
32 | private Context c=this;
33 | public MyService() {
34 | super("MyService");
35 | }
36 |
37 | @Override
38 | public void onCreate() {
39 | super.onCreate();
40 | startService(); //this is for create and call the startService method.
41 | }
42 |
43 | private void startService() {
44 | int delay = 100;
45 | int period = 500;
46 | final Context ctx = this;
47 | timer = new Timer();
48 | Log.d("SERVICE", "time");
49 | /*This is a thread that works every 1/2 second you can adjust the time with the variable called period ,
50 | evey 1000 is equal to 1 second*/
51 | timer.scheduleAtFixedRate(new TimerTask() {
52 | public void run() {
53 | if (isPaused == true) {
54 | /*This is your server socket code */
55 | try {
56 | //Create a server socket object and bind it to a port
57 | ServerSocket socServer = new ServerSocket(SERVER_PORT);
58 | //Create server side client socket reference
59 | Socket socClient = null;
60 | //Infinite loop will listen for client requests to connect
61 | while (true) {
62 | Log.d("SERVICE", "running");
63 | //Accept the client connection and hand over communication to server side client socket
64 | socClient = socServer.accept();
65 | //For each client new instance of AsyncTask will be created
66 | ServerAsyncTask serverAsyncTask = new ServerAsyncTask(c);
67 | //Start the AsyncTask execution
68 | //Accepted client socket object will pass as the parameter
69 | serverAsyncTask.execute(new Socket[] {socClient}); //call the asynctask "serverasynctask"
70 | }
71 | } catch (IOException e) {
72 | e.printStackTrace();
73 | }
74 | }
75 | }
76 | }, delay, period);
77 | }
78 |
79 | @Override
80 | public void onDestroy() {
81 | isPaused = false;
82 | timer.cancel();
83 | super.onDestroy();
84 | }
85 |
86 | @Override
87 | public int onStartCommand(Intent intenc, int flags, int idArranque) {
88 |
89 | /*The start_sticky is necesarry to retain and recreate the service in case of this was killed. .*/
90 | return START_STICKY;
91 | }
92 |
93 | @Override
94 | public IBinder onBind(Intent intencion) {
95 | return null;
96 | }
97 |
98 | @Override
99 | protected void onHandleIntent(Intent intent) {
100 | }
101 |
102 | @Override
103 | public void onTaskRemoved(Intent rootIntent) {
104 | /*This code it is similar to the START_STICKY s function */
105 | Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
106 | restartServiceIntent.setPackage(getPackageName());
107 | PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
108 | AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
109 | alarmService.set(
110 | AlarmManager.ELAPSED_REALTIME,
111 | SystemClock.elapsedRealtime() + 1000,
112 | restartServicePendingIntent);
113 | if (Build.VERSION.SDK_INT >= 14) {
114 | super.onTaskRemoved(rootIntent);
115 | }
116 | }
117 | }
118 |
119 |
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/socket/JsonSocketServer.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server.socket;
2 |
3 | import android.util.Log;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | import java.io.DataInputStream;
9 | import java.io.DataOutputStream;
10 | import java.io.IOException;
11 | import java.net.ServerSocket;
12 | import java.net.Socket;
13 |
14 | /**
15 | * Created by renesotolira on 25/04/15.
16 | */
17 | public class JsonSocketServer extends Thread {
18 | /*This is the new Socket Server , this listen JSON data*/
19 |
20 | private int SocketServerPort = 8080;
21 | private String TAG="ServerSocket";
22 | @Override
23 | public void run() {
24 |
25 | Socket socket = null;
26 | DataInputStream dataInputStream = null;
27 | DataOutputStream dataOutputStream = null;
28 |
29 | try {
30 | Log.i(TAG, "Creating server socket");
31 | ServerSocket serverSocket = new ServerSocket(SocketServerPort);
32 |
33 | // while (true) {
34 | socket = serverSocket.accept();
35 | dataInputStream = new DataInputStream(
36 | socket.getInputStream());
37 | dataOutputStream = new DataOutputStream(
38 | socket.getOutputStream());
39 |
40 | String messageFromClient, messageToClient, request;
41 |
42 | //If no message sent from client, this code will block the program
43 | messageFromClient = dataInputStream.readUTF();
44 |
45 | final JSONObject jsondata;
46 | jsondata = new JSONObject(messageFromClient);
47 |
48 | try {
49 | request = jsondata.getString("request");
50 | Log.d(TAG,""+request);
51 | if (request.equals("order")) {
52 | String clientIPAddress = jsondata.getString("success");
53 | String array = jsondata.getString("Students");
54 | Log.d(TAG,""+clientIPAddress +"and the students array is "+ array);
55 | messageToClient = "Connection Accepted";
56 | dataOutputStream.writeUTF(messageToClient);
57 | } else if (request.equals("O-")) {
58 | messageToClient = "Connection Accepted";
59 | dataOutputStream.writeUTF(messageToClient);
60 | Log.d(TAG, "you send O-");
61 | }else if (request.equals("B-")) {
62 | messageToClient = "Connection Accepted";
63 | dataOutputStream.writeUTF(messageToClient);
64 | Log.d(TAG, "you send B-");
65 | }else if (request.equals("W-")) {
66 | messageToClient = "Connection Accepted";
67 | dataOutputStream.writeUTF(messageToClient);
68 | Log.d(TAG, "you send W-");
69 | }else if (request.equals("L-")) {
70 | messageToClient = "Connection Accepted";
71 | dataOutputStream.writeUTF(messageToClient);
72 | Log.d(TAG, "you send L-");
73 | }else{
74 | messageToClient = "Connection Accepted";
75 | dataOutputStream.writeUTF(messageToClient);
76 | Log.d(TAG, "you send other thing");
77 | dataOutputStream.flush();
78 | }
79 | } catch (JSONException e) {
80 | // e.printStackStrace();
81 | Log.e(TAG, "Unable to get request");
82 | dataOutputStream.flush();
83 | }
84 | serverSocket.close();
85 | // }
86 |
87 | } catch (IOException e) {
88 | // e.printStackStrace();
89 | Log.e(TAG, e.toString());
90 | } catch (JSONException e) {
91 | e.printStackTrace();
92 | Log.e(TAG, e.toString());
93 | } finally {
94 | if (socket != null) {
95 | try {
96 | socket.close();
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | Log.e(TAG, e.toString());
100 | }
101 | }
102 |
103 | if (dataInputStream != null) {
104 | try {
105 | dataInputStream.close();
106 | } catch (IOException e) {
107 | e.printStackTrace();
108 | Log.e(TAG, e.toString());
109 | }
110 | }
111 |
112 | if (dataOutputStream != null) {
113 | try {
114 | dataOutputStream.close();
115 | } catch (IOException e) {
116 | e.printStackTrace();
117 | Log.e(TAG, e.toString());
118 | }
119 | }
120 | }
121 |
122 | }
123 |
124 | }
--------------------------------------------------------------------------------
/app/src/main/java/aybars/arslan/menudroid_server/socket/ServerAsyncTask.java:
--------------------------------------------------------------------------------
1 | package aybars.arslan.menudroid_server.socket;
2 |
3 | import android.content.Context;
4 | import android.os.AsyncTask;
5 | import android.util.Log;
6 |
7 | import org.json.JSONArray;
8 | import org.json.JSONException;
9 | import org.json.JSONObject;
10 |
11 | import java.io.DataInputStream;
12 | import java.io.DataOutputStream;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.PrintWriter;
16 | import java.net.Socket;
17 |
18 | import aybars.arslan.menudroid_server.db.SqlOperations;
19 |
20 | /**
21 | * AsyncTask which handles the commiunication with clients
22 | */
23 | public class ServerAsyncTask extends AsyncTask {
24 |
25 | private Context mContext;
26 | private String TAG="ServerSocket";
27 |
28 | public ServerAsyncTask(Context context) {
29 | this.mContext = context;
30 | }
31 | private SqlOperations sqliteoperation,sqliteoperation2;
32 | //Background task which serve for the client
33 | @Override
34 | protected JSONObject doInBackground(Socket... params) {
35 | JSONObject jsondata = null;
36 | //Get the accepted socket object
37 | Socket mySocket = params[0];
38 |
39 | DataInputStream dataInputStream = null;
40 | DataOutputStream dataOutputStream = null;
41 | try {
42 | //Get the data input stream comming from the client
43 | InputStream is = mySocket.getInputStream();
44 | //Get the output stream to the client
45 | PrintWriter out = new PrintWriter(
46 | mySocket.getOutputStream(), true);
47 | //Write data to the data output stream
48 | out.println("Connection Accepted");
49 |
50 | dataInputStream = new DataInputStream(
51 | mySocket.getInputStream());
52 | dataOutputStream = new DataOutputStream(
53 | mySocket.getOutputStream());
54 |
55 | String messageFromClient, messageToClient, request;
56 |
57 |
58 | //If no message sent from client, this code will block the program
59 | messageFromClient = dataInputStream.readUTF();
60 | jsondata = new JSONObject(messageFromClient);
61 | // messageToClient = "Connection Accepted";
62 | // dataOutputStream.writeUTF(messageToClient);
63 |
64 | String message = jsondata.getString("request");
65 | // Log.d(TAG,""+message);
66 |
67 |
68 | //Close the client connection
69 | mySocket.close();
70 | } catch (IOException e) {
71 | Log.e(TAG,"excepction socket "+ e.toString());
72 | e.printStackTrace();
73 | } catch (JSONException e) {
74 | Log.e(TAG, "excepction json "+e.toString());
75 | e.printStackTrace();
76 | }
77 | return jsondata;
78 | }
79 |
80 | @Override
81 | protected void onPostExecute(JSONObject jsondata) {
82 | //After finishing the execution of background task data will be write the text view
83 | // Log.i("CLIENT", "The message from client is: "+s);
84 | if(jsondata!=null) {
85 | String result="";
86 | try {
87 | String request = jsondata.getString("request");
88 | Log.d(TAG,""+request);
89 | if (request.equals("O-")) { //if is an order
90 | String array = jsondata.getString("messageArray");
91 | String message = jsondata.getString("message");
92 | Log.d(TAG,"the food array is "+ array);
93 | Log.d(TAG, "you send "+request + " "+message);
94 | result=request+message;
95 |
96 | JSONArray OrderArray = jsondata.getJSONArray("messageArray");
97 | if(OrderArray!=null) { //only save if the order has information
98 | saveStatusTable(result);
99 | //now save the customer order.
100 | int last = result.lastIndexOf("Table") + 5;
101 | String number = result.substring(last);
102 | sqliteoperation2 = new SqlOperations(mContext); //new instantiate SqlOperations, this is our class to do insert,delete,update to the databse.
103 | sqliteoperation2.open(); //open the Database, (the database is ready to be read or write on it.
104 | sqliteoperation2.insertOrder(OrderArray, number);
105 | sqliteoperation2.close();
106 | }
107 |
108 | }else if(!request.equals("")){
109 |
110 | String message = jsondata.getString("message");
111 | Log.d(TAG, "you send "+request + " "+message);
112 | result=request+message;
113 | saveStatusTable(result);
114 | }else{
115 | Log.d(TAG, "you send other thing");
116 |
117 | }
118 | } catch (JSONException e) {
119 | // e.printStackStrace();
120 | Log.e(TAG, "Unable to get request");
121 | // dataOutputStream.flush();
122 | }
123 |
124 |
125 |
126 | }
127 | /* in case of order ARRAY save at SQLITE other table*/
128 |
129 | /*call the our method insertRequest ,
130 | this take the client-request (B-MenuDroidTable1) and split the number table,
131 | and the capital letter and save it at database */
132 |
133 | }
134 |
135 | public void saveStatusTable(String result) {
136 | sqliteoperation = new SqlOperations(mContext); //new instantiate SqlOperations, this is our class to do insert,delete,update to the databse.
137 | sqliteoperation.open(); //open the Database, (the database is ready to be read or write on it.
138 | sqliteoperation.insertRequest(result);
139 | sqliteoperation.close();
140 | }
141 | }
142 |
143 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/food_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/drawable/food_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/food_icon_real.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/drawable/food_icon_real.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/logo_small_crop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/drawable/logo_small_crop.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_blue.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_coffee.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_logined.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_text_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_custom_button_yellow.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/main_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/drawable/main_test.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
20 |
21 |
29 |
30 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_order_details.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_server.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
16 |
17 |
22 |
23 |
24 |
25 |
31 |
32 |
39 |
40 |
52 |
53 |
67 |
68 |
80 |
81 |
82 |
89 |
90 |
102 |
103 |
117 |
118 |
130 |
131 |
132 |
133 |
140 |
141 |
153 |
154 |
168 |
169 |
181 |
182 |
183 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tool_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_order_details.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #d75050
4 | #C83C3B
5 | #8F90DD
6 |
7 | #c91f12
8 |
9 |
10 | #e62117
11 | #c31c13
12 | #8a140e
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2dp
4 | 2dp
5 | 8dp
6 | 8dp
7 | 10dp
8 | 15sp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MenuDroid-Server
3 | Hello world!
4 | Settings
5 | 1
6 | 2
7 | 3
8 | 4
9 | 5
10 | 6
11 |
12 |
13 | Accept
14 | Cancel
15 | OrderDetailsActivity
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
19 |
20 |
21 |
28 |
29 |
30 |
34 |
35 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.1.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/img/main_screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arslanaybars/MenuDroid-Server/64bd5da66f2bced801c47fab0cae530c643ef502/img/main_screen.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------