From dee1ac6d26028bd32c8701ed0f1c97506cabbfd0 Mon Sep 17 00:00:00 2001 From: Gazebo Date: Fri, 17 Jul 2020 22:08:52 -0300 Subject: [PATCH] ReformulandoTabelasDeviceProjects --- .../DevicesFragments/AddDeviceFragment.java | 4 ++- .../DevicesFragments/DevicesFragment.java | 3 +- .../DevicesFragments/ViewDevicesFragment.java | 12 ++++++-- .../ProjectsFragments/AddProjectFragment.java | 4 ++- .../ProjectsFragments/ProjectFragment.java | 2 +- .../ViewProjectsFragment.java | 20 ++++++------ .../sextafeiramobile/ListItemRow.java | 2 ++ .../sextafeiramobile/ServerConnection.java | 16 +++++----- .../main/res/layout/fragment_adddevice.xml | 27 ++++++++++++++++ .../main/res/layout/fragment_addproject.xml | 28 +++++++++++++++++ .../main/res/layout/fragment_viewdevice.xml | 29 ++++++++++++++++++ .../main/res/layout/fragment_viewproject.xml | 13 ++++---- App/app/src/main/res/values/strings.xml | 1 + .../java/FridayInterface/FXMLController.java | 20 ++++++------ .../FridayInterface/FXMLController$16.class | Bin 1759 -> 1759 bytes .../FridayInterface/FXMLController$17.class | Bin 1759 -> 1759 bytes .../FridayInterface/FXMLController.class | Bin 10041 -> 10036 bytes Server/DataBase.py | 18 +++++------ Server/DevicesStatus.json | 4 --- Server/Server.py | 17 ++++------ Server/__pycache__/DataBase.cpython-36.pyc | Bin 5374 -> 5361 bytes 21 files changed, 155 insertions(+), 65 deletions(-) diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/AddDeviceFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/AddDeviceFragment.java index 72ea155..3740946 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/AddDeviceFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/AddDeviceFragment.java @@ -19,6 +19,7 @@ public class AddDeviceFragment extends Fragment { private Button btnAddDevice; private EditText device; private EditText desc; + private EditText actions; private ServerConnection connection; @@ -31,13 +32,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c device = view.findViewById(R.id.txtAddDevice); desc = view.findViewById(R.id.txtAddDeviceDescription); + actions = view.findViewById(R.id.txtAddDeviceActions); btnAddDevice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { connection = new ServerConnection(); - connection.sendRequest(connection.prepareAddDevice("insertDevice", device.getText().toString(), desc.getText().toString(), "json")); + connection.sendRequest(connection.prepareAddDevice("insertDevice", device.getText().toString(), desc.getText().toString(), Integer.parseInt(actions.getText().toString()))); if(connection.getMsgStatus()){ Toast.makeText(view.getContext(), "Device adicionado", Toast.LENGTH_SHORT).show(); diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java index 3b2b50a..0f2a288 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/DevicesFragment.java @@ -53,7 +53,7 @@ public void onClick(View view) { ServerConnection connection = new ServerConnection(); - arrayList = connection.sendRequest(connection.prepareRequest("getDevicesJsons")); + arrayList = connection.sendRequest(connection.prepareRequest("getDevices")); arrayAdapter = new ListItemRow(view.getContext(), arrayList, "Devices"); @@ -67,6 +67,7 @@ public void onItemClick(AdapterView adapterView, View view, int i, long l) { intent.putExtra("ID", arrayList.get(i).getInt(0)); intent.putExtra("Device", arrayList.get(i).get(1).toString()); intent.putExtra("Description", arrayList.get(i).get(2).toString()); + intent.putExtra("Actions", arrayList.get(i).getInt(3)); assert getFragmentManager() != null; getFragmentManager().beginTransaction().replace(R.id.frame, new ViewDevicesFragment()).commit(); diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java index 9c13e3b..9a21b21 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/DevicesFragments/ViewDevicesFragment.java @@ -24,6 +24,7 @@ public class ViewDevicesFragment extends Fragment { private Intent intent; private EditText txtDevice; private EditText txtDescription; + private EditText txtActions; private Button btnEditSend; private Button btnDeleteCancel; @@ -42,6 +43,7 @@ public class ViewDevicesFragment extends Fragment { private AlertDialog removeDialog; + @SuppressLint("SetTextI18n") @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -51,18 +53,20 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c txtDevice = view.findViewById(R.id.txtViewDevice); txtDescription = view.findViewById(R.id.txtViewDeviceDescription); + txtActions = view.findViewById(R.id.txtViewDeviceActions); intent = getActivity().getIntent(); ID = intent.getIntExtra("ID", 0); txtDevice.setText(intent.getStringExtra("Device")); txtDescription.setText(intent.getStringExtra("Description")); + txtActions.setText(Integer.toString(intent.getIntExtra("Actions", 0))); btnEditSend = view.findViewById(R.id.btnEditDevice); btnDeleteCancel = view.findViewById(R.id.btnRemoveDevice); removeAlert = new AlertDialog.Builder(view.getContext()); - removeAlert.setMessage("Deseja remover a interação?"); + removeAlert.setMessage("Deseja remover o device?"); removeAlert.setCancelable(false); removeAlert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @@ -92,6 +96,7 @@ public void onClick(View view) { if(btnEditSend.getText().equals("Editar")){ txtDevice.setEnabled(true); txtDescription.setEnabled(true); + txtActions.setEnabled(true); btnDeleteCancel.setText("Cancelar"); btnEditSend.setText("Salvar"); @@ -104,10 +109,11 @@ public void onClick(View view) { }else{ connection.sendRequest(connection.prepareUpdateDevice("updateDevice", ID, txtDevice.getText().toString(), txtDescription.getText().toString(), - "json")); + Integer.parseInt(txtActions.getText().toString()))); txtDevice.setEnabled(false); txtDescription.setEnabled(false); + txtActions.setEnabled(false); btnDeleteCancel.setText("Excluir"); btnEditSend.setText("Editar"); @@ -121,6 +127,7 @@ public void onClick(View view) { intent.putExtra("ID", ID); intent.putExtra("Device", txtDevice.getText().toString()); intent.putExtra("Description", txtDescription.getText().toString()); + intent.putExtra("Actions", Integer.parseInt(txtActions.getText().toString())); if(connection.getMsgStatus()){ Toast.makeText(getContext(), "Salvo", Toast.LENGTH_SHORT).show(); @@ -152,6 +159,7 @@ public void onClick(View view) { txtDevice.setText(intent.getStringExtra("Device")); txtDescription.setText(intent.getStringExtra("Description")); + txtDescription.setText(intent.getIntExtra("Actions", 0)); } } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/AddProjectFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/AddProjectFragment.java index c8d3aeb..04a61d5 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/AddProjectFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/AddProjectFragment.java @@ -17,6 +17,7 @@ public class AddProjectFragment extends Fragment { private Button btnAddProject; + private EditText type; private EditText project; private ServerConnection connection; @@ -28,13 +29,14 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c btnAddProject = view.findViewById(R.id.btnAddProject); project = view.findViewById(R.id.txtAddNameProject); + type = view.findViewById(R.id.txtAddTypeProject); btnAddProject.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { connection = new ServerConnection(); - connection.sendRequest(connection.prepareAddProject("insertProject", project.getText().toString(), "repository")); + connection.sendRequest(connection.prepareAddProject("insertProject", type.getText().toString(), project.getText().toString())); if(connection.getMsgStatus()){ Toast.makeText(view.getContext(), "Projeto adicionado", Toast.LENGTH_SHORT).show(); diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java index 88a519c..1272f65 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ProjectFragment.java @@ -64,7 +64,7 @@ public void onItemClick(AdapterView adapterView, View view, int i, long l) { intent = getActivity().getIntent(); intent.putExtra("ID", arrayList.get(i).getInt(0)); intent.putExtra("Project", arrayList.get(i).get(1).toString()); - intent.putExtra("Repository", arrayList.get(i).get(2).toString()); + intent.putExtra("type", arrayList.get(i).get(2).toString()); assert getFragmentManager() != null; getFragmentManager().beginTransaction().replace(R.id.frame, new ViewProjectsFragment()).commit(); diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java index 1baeea1..54febc4 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/Fragments/SkillsFragments/ProjectsFragments/ViewProjectsFragment.java @@ -23,7 +23,7 @@ public class ViewProjectsFragment extends Fragment { private Intent intent; private EditText txtProject; - private EditText txtRepository; + private EditText txtType; private Button btnEditSend; private Button btnDeleteCancel; @@ -48,7 +48,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c connection = new ServerConnection(); txtProject = view.findViewById(R.id.txtViewProject); - txtRepository = view.findViewById(R.id.txtViewRepository); + txtType = view.findViewById(R.id.txtViewProjectType); btnEditSend = view.findViewById(R.id.btnEditProject); btnDeleteCancel = view.findViewById(R.id.btnRemoveProject); @@ -57,10 +57,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c ID = intent.getIntExtra("ID", 0); txtProject.setText(intent.getStringExtra("Project")); - txtRepository.setText(intent.getStringExtra("Repository")); + txtType.setText(intent.getStringExtra("type")); removeAlert = new AlertDialog.Builder(view.getContext()); - removeAlert.setMessage("Deseja remover a interação?"); + removeAlert.setMessage("Deseja remover o projeto?"); removeAlert.setCancelable(false); removeAlert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @@ -89,7 +89,7 @@ public void onClick(DialogInterface dialogInterface, int i) { public void onClick(View view) { if(btnEditSend.getText().equals("Editar")){ txtProject.setEnabled(true); - txtRepository.setEnabled(true); + txtType.setEnabled(true); btnDeleteCancel.setText("Cancelar"); @@ -102,10 +102,10 @@ public void onClick(View view) { btnDeleteCancel.setCompoundDrawablesWithIntrinsicBounds(cancelIcon, null, null, null); }else{ - connection.sendRequest(connection.prepareUpdateProject("updateProject", ID, txtProject.getText().toString(), txtRepository.getText().toString())); + connection.sendRequest(connection.prepareUpdateProject("updateProject", ID, txtType.getText().toString(), txtProject.getText().toString())); txtProject.setEnabled(false); - txtRepository.setEnabled(false); + txtType.setEnabled(false); btnDeleteCancel.setText("Excluir"); btnEditSend.setText("Editar"); @@ -118,7 +118,7 @@ public void onClick(View view) { intent.putExtra("ID", ID); intent.putExtra("Project", txtProject.getText().toString()); - intent.putExtra("Repository", txtRepository.getText().toString()); + intent.putExtra("type", txtType.getText().toString()); if(connection.getMsgStatus()){ Toast.makeText(getContext(), "Salvo", Toast.LENGTH_SHORT).show(); @@ -138,7 +138,7 @@ public void onClick(View view) { }else{ txtProject.setEnabled(false); - txtRepository.setEnabled(false); + txtType.setEnabled(false); btnDeleteCancel.setText("Excluir"); btnEditSend.setText("Editar"); @@ -150,7 +150,7 @@ public void onClick(View view) { btnDeleteCancel.setCompoundDrawablesWithIntrinsicBounds(removeIcon, null, null, null); txtProject.setText(intent.getStringExtra("Project")); - txtRepository.setText(intent.getStringExtra("Repository")); + txtType.setText(intent.getStringExtra("type")); } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ListItemRow.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ListItemRow.java index bf76a7f..8d484db 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ListItemRow.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ListItemRow.java @@ -71,12 +71,14 @@ public View getView(int position, View convertView, ViewGroup parent) { listID.setText(arrayLine.get(0).toString()); listField1.setText(arrayLine.get(1).toString()); listField2.setText(arrayLine.get(2).toString()); + listField3.setText(arrayLine.get(3).toString()); break; case "Projects": arrayLine = list.get(position); listID.setText(arrayLine.get(0).toString()); listField1.setText(arrayLine.get(1).toString()); + listField2.setText(arrayLine.get(2).toString()); break; } diff --git a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java index 5a4acd4..5651800 100644 --- a/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java +++ b/App/app/src/main/java/com/gazeboindustries/sextafeiramobile/ServerConnection.java @@ -113,14 +113,14 @@ public JSONObject prepareAddInteraction(String request, String key1, String key2 return jsonRequest; } - public JSONObject prepareAddDevice(String request, String device, String desc, String json){ + public JSONObject prepareAddDevice(String request, String device, String desc, int actions){ try { this.jsonRequest = new JSONObject(); this.jsonRequest.put("header", "gazeboindustries09082004"); this.jsonRequest.put("request", request); this.jsonRequest.put("device", device); this.jsonRequest.put("description", desc); - this.jsonRequest.put("json", json); + this.jsonRequest.put("actions", actions); } catch (JSONException e) { e.printStackTrace(); @@ -145,13 +145,13 @@ public JSONObject prepareAddHomework(String request, String type, String subject return jsonRequest; } - public JSONObject prepareAddProject(String request, String project, String desc){ + public JSONObject prepareAddProject(String request, String type, String project){ try { this.jsonRequest = new JSONObject(); this.jsonRequest.put("header", "gazeboindustries09082004"); this.jsonRequest.put("request", request); + this.jsonRequest.put("type", type); this.jsonRequest.put("project", project); - this.jsonRequest.put("repository", desc); } catch (JSONException e) { e.printStackTrace(); @@ -190,7 +190,7 @@ public JSONObject prepareUpdateInteraction(String request, int updateId, String return jsonRequest; } - public JSONObject prepareUpdateDevice(String request, int updateId, String device, String desc, String json){ + public JSONObject prepareUpdateDevice(String request, int updateId, String device, String desc, int actions){ try { this.jsonRequest = new JSONObject(); this.jsonRequest.put("header", "gazeboindustries09082004"); @@ -198,7 +198,7 @@ public JSONObject prepareUpdateDevice(String request, int updateId, String devic this.jsonRequest.put("updateId", updateId); this.jsonRequest.put("device", device); this.jsonRequest.put("description", desc); - this.jsonRequest.put("json", json); + this.jsonRequest.put("actions", actions); } catch (JSONException e) { e.printStackTrace(); @@ -224,14 +224,14 @@ public JSONObject prepareUpdateHomework(String request, int updateId, String typ return jsonRequest; } - public JSONObject prepareUpdateProject(String request, int updateId, String project, String desc){ + public JSONObject prepareUpdateProject(String request, int updateId, String type, String project){ try { this.jsonRequest = new JSONObject(); this.jsonRequest.put("header", "gazeboindustries09082004"); this.jsonRequest.put("request", request); this.jsonRequest.put("updateId", updateId); + this.jsonRequest.put("type", type); this.jsonRequest.put("project", project); - this.jsonRequest.put("repository", desc); } catch (JSONException e) { e.printStackTrace(); diff --git a/App/app/src/main/res/layout/fragment_adddevice.xml b/App/app/src/main/res/layout/fragment_adddevice.xml index ef21fd3..ea1e12f 100644 --- a/App/app/src/main/res/layout/fragment_adddevice.xml +++ b/App/app/src/main/res/layout/fragment_adddevice.xml @@ -73,6 +73,33 @@ + + + + + + +