From bf12408e3c5066d8d587c406488c4c8b2e8763ef Mon Sep 17 00:00:00 2001 From: massimiliano Date: Tue, 27 Nov 2018 01:43:42 +0100 Subject: [PATCH] Added incidents and made some strings translatable --- .idea/caches/build_file_checksums.ser | Bin 534 -> 534 bytes app/src/main/AndroidManifest.xml | 4 + .../disroot/disrootapp/ui/StateActivity.java | 120 ++++++++++++++++-- .../disroot/disrootapp/utils/Constants.java | 2 + app/src/main/res/layout/activity_state.xml | 1 + app/src/main/res/layout/list_item.xml | 19 +++ app/src/main/res/values-es/strings.xml | 10 +- app/src/main/res/values-fr/strings.xml | 10 +- app/src/main/res/values-it/strings.xml | 12 +- app/src/main/res/values-nl/strings.xml | 12 +- app/src/main/res/values-pt/strings.xml | 10 +- app/src/main/res/values-sr/strings.xml | 10 +- app/src/main/res/values/strings.xml | 15 ++- 13 files changed, 207 insertions(+), 18 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index c83edae13c0e9cb50e4622f8bd7551f9d70d30be..63c2ad32c84056fff84530be51f3c36ff50135cc 100644 GIT binary patch delta 15 WcmbQnGL2=z43?m@oc4`#su%$+H3ifF delta 15 XcmbQnGL2=z3>GiR+Y2|&sbT~GE%pWo diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d15645f..43c2277 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -59,6 +59,10 @@ + diff --git a/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java index 1b6b15c..087fc8a 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java @@ -35,6 +35,7 @@ public class StateActivity extends AppCompatActivity { // URL to get data JSON static String url = "https://state.disroot.org/api/v1/components"; static String url1 = "https://state.disroot.org/api/v1/components?page=2"; + static String incidenturl0 ="https://state.disroot.org/api/v1/incidents?sort=id&order=desc"; ArrayList> stateList; @@ -71,7 +72,7 @@ public class StateActivity extends AppCompatActivity { super.onPreExecute(); // Showing progress dialog pDialog = new ProgressDialog(StateActivity.this); - pDialog.setMessage("Please wait..."); + pDialog.setMessage("Loading…"); pDialog.setCancelable(false); pDialog.show(); } @@ -83,6 +84,7 @@ public class StateActivity extends AppCompatActivity { // Making a request to url and getting response String jsonStr0 = sh.makeServiceCall(url); String jsonStr1 = sh.makeServiceCall(url1); + String jsonStrincidents0 = sh.makeServiceCall(incidenturl0); Log.e(TAG, "Response from url: " + jsonStr0); @@ -101,7 +103,7 @@ public class StateActivity extends AppCompatActivity { String name = c.getString("name"); String description = c.getString("description"); String updated_at = c.getString("updated_at"); - String lastUpdated = "Last updated: " + updated_at; + String lastUpdated = "Last Updated: " + updated_at; String status_name = c.getString("status_name"); // tmp hash map for single service @@ -144,6 +146,7 @@ public class StateActivity extends AppCompatActivity { String name = c.getString("name"); String description = c.getString("description"); String updated_at = c.getString("updated_at"); + String lastUpdated = "Last updated: " + updated_at; String status_name = c.getString("status_name"); // tmp hash map for single service @@ -153,7 +156,7 @@ public class StateActivity extends AppCompatActivity { service.put("id", id); service.put("name", name); service.put("description", description); - service.put("updated_at", updated_at); + service.put("updated_at", lastUpdated); service.put("status_name", status_name); // adding service to service list @@ -171,7 +174,52 @@ public class StateActivity extends AppCompatActivity { } }); } - } else { + } if (jsonStrincidents0 != null) {//Incidaetnts page + try { + JSONObject jsonObj = new JSONObject(jsonStrincidents0); + + // Getting JSON Array node + JSONArray data = jsonObj.getJSONArray("data"); + + // looping through All data + for (int i = 0; i < data.length(); i++) { + JSONObject c = data.getJSONObject(i); + + String id = c.getString("id"); + String name = c.getString("name"); + String message = c.getString("message"); + String scheduled_at = c.getString("scheduled_at"); + String updated_at = c.getString("updated_at"); + String lastUpdated = "Last Updated: " + updated_at; + String human_status = c.getString("human_status"); + + // tmp hash map for single service + HashMap service = new HashMap<>(); + + // adding each child node to HashMap key => value + service.put("id", id); + service.put("name", name); + service.put("message", message); + service.put("scheduled_at", scheduled_at); + service.put("updated_at", lastUpdated); + service.put("human_status", human_status); + + // adding service to service list + stateList.add(service); + } + } catch (final JSONException e) { + Log.e(TAG, "Json parsing error: " + e.getMessage()); + runOnUiThread(new Runnable() { + @Override + public void run() { + Toast.makeText(getApplicationContext(), + "Json parsing error: " + e.getMessage(), + Toast.LENGTH_LONG) + .show(); + } + }); + } + }else { Log.e(TAG, "Couldn't get json from server."); runOnUiThread(new Runnable() { @Override @@ -196,27 +244,83 @@ public class StateActivity extends AppCompatActivity { //Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( StateActivity.this, stateList, - R.layout.list_item, new String[]{"name", "description", "updated_at", - "status_name"}, new int[]{R.id.name, - R.id.description,R.id.updated_at, R.id.status_name}) + R.layout.list_item, new String[]{"name","message", "description", "updated_at", "scheduled_at", + "status_name", "human_status"}, new int[]{R.id.name, R.id.message, + R.id.description,R.id.updated_at, R.id.scheduled_at, R.id.status_name, R.id.human_status}) //Change Color based on Status { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); + //Name Email + TextView nameMail = v.findViewById(R.id.name); + String nameMailValue = nameMail.getText().toString(); + switch (nameMailValue) { + case "Email Service": + nameMail.setText(R.string.EmailService); + break; + default: + break; + } + //Name WebMail + TextView nameWebmail = v.findViewById(R.id.name); + String nameWebmailValue = nameWebmail.getText().toString(); + switch (nameWebmailValue) { + case "WebMail Service": + nameWebmail.setText(R.string.WebmailService); + break; + default: + break; + } + //Name Cloud + TextView nameCloud = v.findViewById(R.id.name); + String nameCloudValue = nameCloud.getText().toString(); + switch (nameCloudValue) { + case "WebMail Service": + nameCloud.setText(R.string.Cloud); + break; + default: + break; + } + //Make Last updated translatable + TextView updated = v.findViewById(R.id.updated_at); + String updatedValue = updated.getText().toString(); + if (updatedValue.startsWith("Last Updated: ")){ + updated.setText(updatedValue.replace("Last Updated: ",getText(R.string.LastUpdated))); + } + //Status TextView status = v.findViewById(R.id.status_name); String statusValue = status.getText().toString(); switch (statusValue) { case "Operational": status.setTextColor(Color.GREEN); + status.setText(R.string.Operational); break; case "Major Outage": status.setTextColor(Color.RED); + status.setText(R.string.MajorOutage); break; - default: + case "Performance Issues": + status.setText(R.string.PerformanceIssues); status.setTextColor(Color.YELLOW); break; + }//Human_status + TextView humanStatus = v.findViewById(R.id.human_status); + String humanStatusValue = humanStatus.getText().toString(); + switch (humanStatusValue) { + case "Fixed": + case "Scheduled": + humanStatus.setTextColor(Color.GREEN); + break; + case "Investigating": + case "Watching": + humanStatus.setTextColor(Color.YELLOW); + + break; + case "Identified": + humanStatus.setTextColor(Color.RED); + break; } return v; } diff --git a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java index e07aa4a..641233d 100644 --- a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java +++ b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java @@ -7,6 +7,8 @@ public class Constants { public static final long SPLASH_SCREEN_DURATION = 3000; public static final long SPLASH_SCREEN_INTERVAL = 1000; + + public static final String title_activity_state = "StateActivity"; public static final String URL_DisApp_FORUM = "https://forum.disroot.org/"; public static final String URL_DisApp_CALC = "https://calc.disroot.org"; public static final String URL_DisApp_BIN = "https://bin.disroot.org"; diff --git a/app/src/main/res/layout/activity_state.xml b/app/src/main/res/layout/activity_state.xml index f08a549..8521c90 100644 --- a/app/src/main/res/layout/activity_state.xml +++ b/app/src/main/res/layout/activity_state.xml @@ -26,6 +26,7 @@ + + + + + + + + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 4b8167d..95a31f1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -136,5 +136,13 @@ Para continuar, primero necesitas instalar la app de Nextcloud.\nPor favor, selecciona Instalar para continuar desde F-Droid. Para continuar, primero necesitas instalar Conversations.\nPor favor, selecciona Instalar para continuar desde F-Droid. Disroot state - + Operational + Major Outage + Email Service + Last updated: \ + WebMail Service + Cloud + Performance Issues + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 4f1a5b6..474f1b4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -165,5 +165,13 @@ Pour continuer, vous devez d\'abord installer l\'application Nextcloud.\nVeuillez sélectionner Installer pour continuer l\'installation avec F-Droid. Pour continuer, vous devez d\'abord installer Conversations.\nVeuillez sélectionner Installer pour continuer l\'installation avec F-Droid. Disroot state - + Operational + Major Outage + Email Service + Last updated: \ + WebMail Service + Cloud + Performance Issues + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d786ea6..c74ad2e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -134,6 +134,14 @@ Per continuare è necessario installare K9-Mail.\nSelezionate installa per continuare con l\'installazione su F-Droid. Per continuare è necessario installare la app di Nextcloud.\nSelezionate installa per continuare con l\'installazione su F-Droid. Per continuare è necessario installare Conversations.\nSelezionate installa per continuare con l\'installazione su F-Droid. - Disroot state - + Stato Disroot + Operazionale + Grave interruzione del servizio + Servizio Email + Ultimo aggiornamento: \ + Servizio WebMail + Cloud + Problemi di performanza + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 23e36a9..3470e80 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -135,6 +135,14 @@ Om verder te gaan moet u eerst K9-Mail installeren.\nSelecteer Installeren om verder te gaan met de installatie op F-Droid. Om verder te gaan moet u eerst Nextcloud app installeren.\nSelecteer Installeren om verder te gaan met de installatie op F-Droid. Om verder te gaan moet u eerst Conversations installeren.\nSelecteer Installeren om verder te gaan met de installatie op F-Droid. - Disroot state - + Disroot status + Operationeel + Ernstige storing + Email Service + "Laatst geupdate: \" + WebMail Service + Cloud + Prestatieproblemen + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 6636e99..c311045 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -135,5 +135,13 @@ To continue you need to install the Nextcloud app first.\nPlease select install to continue with the installatin on F-Droid. To continue you need to install Conversations first.\nPlease select install to continue with the installatin on F-Droid. Disroot state - + Operational + Major Outage + Email Service + Last updated: \ + WebMail Service + Cloud + Performance Issues + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 6703ec5..924f060 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -136,5 +136,13 @@ To continue you need to install the Nextcloud app first.\nPlease select install to continue with the installatin on F-Droid. To continue you need to install Conversations first.\nPlease select install to continue with the installatin on F-Droid. Disroot state - + Operational + Major Outage + Email Service + Last updated: \ + WebMail Service + Cloud + Performance Issues + No issues + Some systems are experiencing issues diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 64c41e4..2e4f44e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -134,7 +134,18 @@ To continue you need to install K9-Mail first.\nPlease select install to continue with the installatin on F-Droid. To continue you need to install the Nextcloud app first.\nPlease select install to continue with the installatin on F-Droid. To continue you need to install Conversations first.\nPlease select install to continue with the installatin on F-Droid. - StateActivity + StateActivity Disroot state - + Operational + Major Outage + Email Service + "Last updated: " + WebMail Service + Cloud + Performance Issues + No issues + Some systems are experiencing issues + Main2Activity + Hello World from section: %1$d + tabbed_state