Commit a09824edbdb204647e9be5553ebedd743a2a8813

Authored by kristinlaahneolsen
1 parent 3d4574f1

Laget klar sekvens-aktiviteten med dropdown og knapp for generering av rapport. …

…Popup-metode er også klar til bruk til når vi skal implementere algoritme for dette
Risiko/app/src/main/java/activity/MainMenu.java
... ... @@ -21,6 +21,9 @@ public class MainMenu extends AppCompatActivity {
21 21 toActivityList = findViewById(R.id.btn_to_activitylist);
22 22 toActivityList.setOnClickListener(view -> startActivity(new Intent(this, Activities.class)));
23 23  
  24 + toSequences= findViewById(R.id.btn_to_sequense_of_activities);
  25 + toSequences.setOnClickListener(view -> startActivity(new Intent(this, SequenceOfActivities.class)));
  26 +
24 27 toEventList = findViewById(R.id.btn_to_events);
25 28 toEventList.setOnClickListener(view -> startActivity(new Intent(this, Incident.class)));
26 29  
... ...
Risiko/app/src/main/java/activity/SequenceOfActivities.java
1 1 package activity;
2 2  
  3 +import android.content.Intent;
  4 +import android.support.v7.app.AlertDialog;
3 5 import android.support.v7.app.AppCompatActivity;
4 6 import android.os.Bundle;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.widget.ArrayAdapter;
  10 +import android.widget.Button;
  11 +import android.widget.Spinner;
5 12  
6 13 import com.risiko.risiko.R;
7 14  
8 15 public class SequenceOfActivities extends AppCompatActivity {
  16 + Button generateReport;
9 17  
10 18 @Override
11 19 protected void onCreate(Bundle savedInstanceState) {
12 20 super.onCreate(savedInstanceState);
13 21 setContentView(R.layout.activity_sequence_of_activities);
  22 +
  23 + generateReport = findViewById(R.id.btn_generate_report);
  24 + generateReport.setOnClickListener(view -> reportDialog());
  25 +
  26 +
  27 + Spinner activity1Spinner = (Spinner) findViewById(R.id.spinner_activity1);
  28 + ArrayAdapter<CharSequence> activity1Adapter = ArrayAdapter.createFromResource(this, R.array.activities_array, android.R.layout.simple_spinner_item);
  29 + activity1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  30 + activity1Spinner.setAdapter(activity1Adapter);
  31 +
  32 + Spinner activity2Spinner = (Spinner) findViewById(R.id.spinner_activity2);
  33 + ArrayAdapter<CharSequence> activity2Adapter = ArrayAdapter.createFromResource(this, R.array.activities_array, android.R.layout.simple_spinner_item);
  34 + activity2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  35 + activity2Spinner.setAdapter(activity2Adapter);
  36 +
  37 + Spinner activity3Spinner = (Spinner) findViewById(R.id.spinner_activity3);
  38 + ArrayAdapter<CharSequence> activity3Adapter = ArrayAdapter.createFromResource(this, R.array.activities_array, android.R.layout.simple_spinner_item);
  39 + activity3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  40 + activity3Spinner.setAdapter(activity3Adapter);
  41 +
  42 + }
  43 +
  44 +
  45 + private void reportDialog() {
  46 + LayoutInflater layoutInflater = LayoutInflater.from(this);
  47 + View promptView = layoutInflater.inflate(R.layout.popup_report, null);
  48 + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
  49 + alertDialogBuilder.setView(promptView);
  50 +
  51 + alertDialogBuilder.setCancelable(false)
  52 + .setNegativeButton(getString(R.string.cancel),
  53 + (dialog, id) -> dialog.cancel());
  54 + AlertDialog alert = alertDialogBuilder.create();
  55 +
  56 + alert.show();
14 57 }
15 58 }
... ...
Risiko/app/src/main/res/layout/activity_sequence_of_activities.xml
... ... @@ -6,4 +6,120 @@
6 6 android:layout_height="match_parent"
7 7 tools:context="com.risiko.risiko.activity.SequenceOfActivities">
8 8  
  9 + <LinearLayout
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent"
  12 + android:orientation="vertical"
  13 + android:layout_margin="15dp">
  14 +
  15 +
  16 + <TextView
  17 + android:layout_gravity="center"
  18 + android:id="@+id/tv_sequence_headline"
  19 + android:layout_width="wrap_content"
  20 + android:layout_height="wrap_content"
  21 + android:text="@string/sequence_of_activities"
  22 + android:textStyle="bold"
  23 + android:textSize="25dp"
  24 + app:layout_constraintLeft_toLeftOf="parent"
  25 + app:layout_constraintRight_toRightOf="parent"
  26 + app:layout_constraintTop_toTopOf="parent"
  27 + android:layout_marginTop="25dp"/>
  28 +
  29 + <TextView
  30 + android:layout_marginTop="20dp"
  31 + android:textAlignment="center"
  32 + android:id="@+id/tv_sequence_description"
  33 + app:layout_constraintLeft_toLeftOf="parent"
  34 + app:layout_constraintRight_toRightOf="parent"
  35 + app:layout_constraintTop_toBottomOf="@id/tv_sequence_headline"
  36 + android:layout_width="wrap_content"
  37 + android:layout_height="wrap_content"
  38 + android:text="@string/sequence_description"/>
  39 +
  40 + <LinearLayout
  41 + android:layout_margin="10dp"
  42 + android:padding="10dp"
  43 + android:background="@color/colorLightGray"
  44 + android:layout_width="match_parent"
  45 + android:layout_height="wrap_content"
  46 + android:orientation="horizontal">
  47 +
  48 + <TextView
  49 + android:layout_marginEnd="20dp"
  50 + android:layout_width="wrap_content"
  51 + android:layout_height="wrap_content"
  52 + android:textSize="17sp"
  53 + android:textStyle="bold"
  54 + android:text="@string/chose_activity" />
  55 +
  56 + <Spinner
  57 + android:id="@+id/spinner_activity1"
  58 + android:layout_width="fill_parent"
  59 + android:layout_height="wrap_content" />
  60 +
  61 + </LinearLayout>
  62 +
  63 + <LinearLayout
  64 + android:layout_margin="10dp"
  65 + android:padding="10dp"
  66 + android:background="@color/colorLightGray"
  67 + android:layout_width="match_parent"
  68 + android:layout_height="wrap_content"
  69 + android:orientation="horizontal">
  70 +
  71 + <TextView
  72 + android:layout_marginEnd="20dp"
  73 + android:layout_width="wrap_content"
  74 + android:layout_height="wrap_content"
  75 + android:textSize="17sp"
  76 + android:textStyle="bold"
  77 + android:text="@string/chose_activity" />
  78 +
  79 + <Spinner
  80 + android:id="@+id/spinner_activity2"
  81 + android:layout_width="fill_parent"
  82 + android:layout_height="wrap_content" />
  83 +
  84 + </LinearLayout>
  85 +
  86 +
  87 + <LinearLayout
  88 + android:layout_margin="10dp"
  89 + android:padding="10dp"
  90 + android:background="@color/colorLightGray"
  91 + android:layout_width="match_parent"
  92 + android:layout_height="wrap_content"
  93 + android:orientation="horizontal">
  94 +
  95 + <TextView
  96 + android:layout_marginEnd="20dp"
  97 + android:layout_width="wrap_content"
  98 + android:layout_height="wrap_content"
  99 + android:textSize="17sp"
  100 + android:textStyle="bold"
  101 + android:text="@string/chose_activity" />
  102 +
  103 + <Spinner
  104 + android:id="@+id/spinner_activity3"
  105 + android:layout_width="fill_parent"
  106 + android:layout_height="wrap_content" />
  107 +
  108 + </LinearLayout>
  109 +
  110 + <Button
  111 + android:id="@+id/btn_generate_report"
  112 + android:layout_marginVertical="50dp"
  113 + android:layout_gravity="center"
  114 + android:layout_width="200dp"
  115 + android:layout_height="wrap_content"
  116 + android:text="@string/generate_report"/>
  117 +
  118 + </LinearLayout>
  119 +
  120 +
  121 +
  122 +
  123 +
  124 +
9 125 </android.support.constraint.ConstraintLayout>
... ...
Risiko/app/src/main/res/layout/popup_report.xml 0 → 100644
  1 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2 + android:layout_width="match_parent"
  3 + android:layout_height="wrap_content"
  4 + android:orientation="vertical"
  5 + android:padding="10dp">
  6 +
  7 + <TextView
  8 + android:id="@+id/pop_event_headline"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content"
  11 + android:background="@color/colorLightGreen"
  12 + android:padding="10dp"
  13 + android:text="@string/report"
  14 + android:textAlignment="center"
  15 + android:textAppearance="?android:attr/textAppearanceMedium"
  16 + android:textStyle="bold"/>
  17 +
  18 + <TextView
  19 + android:layout_marginVertical="20dp"
  20 + android:layout_width="match_parent"
  21 + android:layout_height="wrap_content"
  22 + android:textStyle="bold"
  23 + android:text="@string/possible_outcomes"/>
  24 +
  25 + <TextView
  26 + android:layout_marginVertical="20dp"
  27 + android:layout_width="match_parent"
  28 + android:layout_height="50dp"
  29 + android:text="Her kommer alle mulige utfall.."
  30 + android:textStyle="italic"/>
  31 +
  32 + <TextView
  33 + android:layout_marginVertical="20dp"
  34 + android:layout_width="match_parent"
  35 + android:layout_height="wrap_content"
  36 + android:text="@string/comment"
  37 + android:textStyle="bold"/>
  38 +
  39 + <TextView
  40 + android:layout_marginVertical="20dp"
  41 + android:layout_width="match_parent"
  42 + android:layout_height="50dp"
  43 + android:text="Her kommer en kommentar for mulighet til å gjennomføre denne sekvensen av hendelser uten alvorlige konsekvenser"
  44 + android:textStyle="italic"/>
  45 +
  46 +
  47 +</LinearLayout>
... ...
Risiko/app/src/main/res/values/array.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <resources>
3 3  
4   - <string-array name="consequence_array">
5   - <item>Ufarlig</item>
6   - <item>Moderate</item>
7   - <item>Alvorlig</item>
8   - </string-array>
  4 + <string-array name="consequence_array">
  5 + <item>Ufarlig</item>
  6 + <item>Moderate</item>
  7 + <item>Alvorlig</item>
  8 + </string-array>
9 9  
10 10 <string-array name="associated_risk_array">
11 11 <item>Lav</item>
... ... @@ -13,5 +13,16 @@
13 13 <item>Stor</item>
14 14 </string-array>
15 15  
  16 + <string-array name="activities_array">
  17 + <item>Gi blodtrykksmedisin</item>
  18 + <item>Kjøre bil</item>
  19 + <item>Dosering av smertestillende</item>
  20 + <item>Gå ned trappen</item>
  21 + <item>Kjøre til sykehuset</item>
  22 + <item>Ta buss</item>
  23 + <item>Skjære frossen kylling</item>
  24 + <item>Konsumere alkohol</item>
  25 + </string-array>
  26 +
16 27  
17 28 </resources>
... ...
Risiko/app/src/main/res/values/strings.xml
... ... @@ -22,5 +22,11 @@
22 22 <string name="place">Sted:</string>
23 23 <string name="description">Beskrivelse:</string>
24 24 <string name="associated_risk">Tilknyttet risiko</string>
  25 + <string name="sequence_of_activities">Sekvens av hendelser</string>
  26 + <string name="sequence_description">Her kan du velge en sekvens av aktiviteter og generere en risikorapport tilknyttet denne sekvensen</string>
  27 + <string name="chose_activity">Velg aktivitet</string>
  28 + <string name="generate_report">Generer rapport</string>
  29 + <string name="report">Sekvensrapport</string>
  30 + <string name="comment">Kommentar</string>
25 31  
26 32 </resources>
... ...