aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xAndroidManifest.xml30
-rwxr-xr-xgen/net/redroid/medlog/BuildConfig.java6
-rwxr-xr-xgen/net/redroid/medlog/R.java145
-rwxr-xr-xic_launcher-web.pngbin0 -> 118840 bytes
-rwxr-xr-xlibs/android-support-v4.jarbin0 -> 627582 bytes
-rwxr-xr-xlibs/javacsv.jarbin0 -> 13582 bytes
-rwxr-xr-xlint.xml3
-rwxr-xr-xproguard-project.txt20
-rwxr-xr-xproject.properties14
-rwxr-xr-xres/drawable-hdpi/ic_launcher.pngbin0 -> 6369 bytes
-rwxr-xr-xres/drawable-mdpi/ic_launcher.pngbin0 -> 3108 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_launcher.pngbin0 -> 9945 bytes
-rwxr-xr-xres/drawable-xxhdpi/ic_launcher.pngbin0 -> 18410 bytes
-rwxr-xr-xres/layout/activity_main.xml23
-rwxr-xr-xres/layout/fragment_file_operations.xml31
-rwxr-xr-xres/layout/fragment_main_dummy.xml16
-rwxr-xr-xres/layout/fragment_new_entry.xml216
-rwxr-xr-xres/layout/fragment_view_data.xml24
-rwxr-xr-xres/layout/multiline_spinner_dropdown_item.xml28
-rwxr-xr-xres/layout/override_new_entry.xml95
-rwxr-xr-xres/menu/main.xml9
-rwxr-xr-xres/values-sw600dp/dimens.xml8
-rwxr-xr-xres/values-sw720dp-land/dimens.xml9
-rwxr-xr-xres/values-v11/styles.xml11
-rwxr-xr-xres/values-v14/styles.xml12
-rwxr-xr-xres/values/dimens.xml7
-rwxr-xr-xres/values/strings.xml38
-rwxr-xr-xres/values/styles.xml20
-rwxr-xr-xsrc/com/example/surgerylog/FileOperationsFragment.java185
-rwxr-xr-xsrc/com/example/surgerylog/ISpinnerRefresh.java9
-rwxr-xr-xsrc/com/example/surgerylog/MainActivity.java330
-rwxr-xr-xsrc/com/example/surgerylog/MedLogInfo.java51
-rwxr-xr-xsrc/com/example/surgerylog/MedLogRoot.java142
-rwxr-xr-xsrc/com/example/surgerylog/MedLogSubType.java87
-rwxr-xr-xsrc/com/example/surgerylog/MedLogType.java52
-rwxr-xr-xsrc/com/example/surgerylog/NewEntryFragment.java437
-rwxr-xr-xsrc/com/example/surgerylog/ViewDataFragment.java173
37 files changed, 2231 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100755
index 0000000..fd4ec79
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="net.redroid.medlog"
+ android:versionCode="1"
+ android:versionName="1.8" >
+
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="16" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.Holo.Light.NoActionBar">
+ <!-- android:theme="@android:style/Theme.Holo.NoActionBar"> -->
+ <!-- android:theme="@style/AppTheme" > -->
+
+ <activity
+ android:name="com.example.surgerylog.MainActivity"
+ android:label="@string/app_name" android:screenOrientation="portrait">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/gen/net/redroid/medlog/BuildConfig.java b/gen/net/redroid/medlog/BuildConfig.java
new file mode 100755
index 0000000..c27f499
--- /dev/null
+++ b/gen/net/redroid/medlog/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package net.redroid.medlog;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+} \ No newline at end of file
diff --git a/gen/net/redroid/medlog/R.java b/gen/net/redroid/medlog/R.java
new file mode 100755
index 0000000..59722b1
--- /dev/null
+++ b/gen/net/redroid/medlog/R.java
@@ -0,0 +1,145 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package net.redroid.medlog;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class dimen {
+ /** Default screen margins, per the Android Design guidelines.
+
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+
+ */
+ public static final int activity_horizontal_margin=0x7f040000;
+ public static final int activity_vertical_margin=0x7f040001;
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int FileOperationsView=0x7f080002;
+ public static final int NewEntryView=0x7f080006;
+ public static final int OverrideNewEntry=0x7f080022;
+ public static final int RelativeLayout1=0x7f08001f;
+ public static final int action_settings=0x7f08002b;
+ public static final int anesthesiaOverride=0x7f08000d;
+ public static final int anesthesiaSpinner=0x7f08000c;
+ public static final int dataBaseListView=0x7f080021;
+ public static final int datePicker=0x7f080008;
+ public static final int exportDataBase=0x7f080004;
+ public static final int fillOverrideButton=0x7f08001d;
+ public static final int firstAiderOverride=0x7f08000f;
+ public static final int firstAiderSpinner=0x7f08000e;
+ public static final int importButton=0x7f080003;
+ public static final int interventionOverride=0x7f080019;
+ public static final int interventionSpinner=0x7f080018;
+ public static final int medSubSubTypeOverride=0x7f080015;
+ public static final int medSubSubTypeSpinner=0x7f080014;
+ public static final int medSubTypeOverride=0x7f080013;
+ public static final int medSubTypeSpinner=0x7f080012;
+ public static final int medTypeOverride=0x7f080011;
+ public static final int medTypeSpinner=0x7f080010;
+ public static final int nProcess=0x7f080007;
+ public static final int nSurgery=0x7f080009;
+ public static final int notesText=0x7f08001b;
+ public static final int overrideAnesthesia=0x7f08002a;
+ public static final int overrideCheckBox=0x7f08001c;
+ public static final int overrideFirstAider=0x7f080028;
+ public static final int overrideIntervention=0x7f080027;
+ public static final int overridePatholoty=0x7f080026;
+ public static final int overridePlace=0x7f080029;
+ public static final int overrideSubSubType=0x7f080025;
+ public static final int overrideSubType=0x7f080024;
+ public static final int overrideType=0x7f080023;
+ public static final int pager=0x7f080000;
+ public static final int pager_title_strip=0x7f080001;
+ public static final int pathologyOverride=0x7f080017;
+ public static final int pathologySpinner=0x7f080016;
+ public static final int placeOverride=0x7f08000b;
+ public static final int placeSpinner=0x7f08000a;
+ public static final int refreshBtn=0x7f080020;
+ public static final int saveButton=0x7f08001e;
+ public static final int section_label=0x7f080005;
+ public static final int urgencyCheckBox=0x7f08001a;
+ }
+ public static final class layout {
+ public static final int activity_main=0x7f030000;
+ public static final int fragment_file_operations=0x7f030001;
+ public static final int fragment_main_dummy=0x7f030002;
+ public static final int fragment_new_entry=0x7f030003;
+ public static final int fragment_view_data=0x7f030004;
+ public static final int multiline_spinner_dropdown_item=0x7f030005;
+ public static final int override_new_entry=0x7f030006;
+ }
+ public static final class menu {
+ public static final int main=0x7f070000;
+ }
+ public static final class string {
+ public static final int action_settings=0x7f050001;
+ public static final int anesthesia_str=0x7f05001c;
+ public static final int app_name=0x7f050000;
+ public static final int delete_str=0x7f05000c;
+ public static final int errorMissingProcessNumber_str=0x7f050010;
+ public static final int exportDataBase_str=0x7f050009;
+ public static final int exportMessageError_str=0x7f05000f;
+ public static final int exportMessage_str=0x7f05000e;
+ public static final int filloverride_str=0x7f050015;
+ public static final int firstaider_str=0x7f05001b;
+ public static final int importConfigs_str=0x7f050008;
+ public static final int intervention_str=0x7f05001a;
+ public static final int nProcess_str=0x7f050005;
+ public static final int nSurgery_str=0x7f050006;
+ public static final int no_str=0x7f050013;
+ public static final int notes_str=0x7f05001e;
+ public static final int ok_str=0x7f05000b;
+ public static final int override_str=0x7f050014;
+ public static final int pathology_str=0x7f050019;
+ public static final int place_str=0x7f05001d;
+ public static final int refresh_str=0x7f05000d;
+ public static final int save_str=0x7f05000a;
+ public static final int subsubtype_str=0x7f050018;
+ public static final int subtype_str=0x7f050017;
+ public static final int successSavingEntry_str=0x7f050011;
+ public static final int title_section1=0x7f050002;
+ public static final int title_section2=0x7f050003;
+ public static final int title_section3=0x7f050004;
+ public static final int type_str=0x7f050016;
+ public static final int urgency_str=0x7f050007;
+ public static final int yes_str=0x7f050012;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f060000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f060001;
+ }
+}
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100755
index 0000000..e4d20ec
--- /dev/null
+++ b/ic_launcher-web.png
Binary files differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100755
index 0000000..96644ed
--- /dev/null
+++ b/libs/android-support-v4.jar
Binary files differ
diff --git a/libs/javacsv.jar b/libs/javacsv.jar
new file mode 100755
index 0000000..ceb59eb
--- /dev/null
+++ b/libs/javacsv.jar
Binary files differ
diff --git a/lint.xml b/lint.xml
new file mode 100755
index 0000000..ee0eead
--- /dev/null
+++ b/lint.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint> \ No newline at end of file
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100755
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100755
index 0000000..4ab1256
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..9ef6cfb
--- /dev/null
+++ b/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..330d0a4
--- /dev/null
+++ b/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..e6341a6
--- /dev/null
+++ b/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..590a40f
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100755
index 0000000..6cfef6f
--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -0,0 +1,23 @@
+<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity" >
+
+ <!--
+ This title strip will display the currently visible page title, as well as the page
+ titles for adjacent pages.
+ -->
+
+ <android.support.v4.view.PagerTitleStrip
+ android:id="@+id/pager_title_strip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:background="#33b5e5"
+ android:paddingBottom="4dp"
+ android:paddingTop="4dp"
+ android:textColor="#fff" />
+
+</android.support.v4.view.ViewPager>
diff --git a/res/layout/fragment_file_operations.xml b/res/layout/fragment_file_operations.xml
new file mode 100755
index 0000000..2703afb
--- /dev/null
+++ b/res/layout/fragment_file_operations.xml
@@ -0,0 +1,31 @@
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/FileOperationsView"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity$FileOperationsContext" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/importButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/importConfigs_str" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="25dp" />
+
+ <Button
+ android:id="@+id/exportDataBase"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/exportDataBase_str" />
+ </LinearLayout>
+
+</ScrollView> \ No newline at end of file
diff --git a/res/layout/fragment_main_dummy.xml b/res/layout/fragment_main_dummy.xml
new file mode 100755
index 0000000..57dc8ce
--- /dev/null
+++ b/res/layout/fragment_main_dummy.xml
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity$DummySectionFragment" >
+
+ <TextView
+ android:id="@+id/section_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
diff --git a/res/layout/fragment_new_entry.xml b/res/layout/fragment_new_entry.xml
new file mode 100755
index 0000000..350fd2a
--- /dev/null
+++ b/res/layout/fragment_new_entry.xml
@@ -0,0 +1,216 @@
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/NewEntryView"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MainActivity$NewEntryContext" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" >
+
+ <EditText
+ android:id="@+id/nProcess"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/nProcess_str"
+ android:inputType="number" >
+
+ <requestFocus />
+ </EditText>
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="5dp" />
+
+ <DatePicker
+ android:id="@+id/datePicker"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:calendarViewShown="false" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="5dp" />
+
+ <EditText
+ android:id="@+id/nSurgery"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/nSurgery_str"
+ android:inputType="number" />
+
+ <Spinner
+ android:id="@+id/placeSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/place_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/placeOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/place_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/anesthesiaSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/anesthesia_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/anesthesiaOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/anesthesia_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/firstAiderSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/firstaider_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/firstAiderOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/firstaider_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/medTypeSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/type_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/medTypeOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/type_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/medSubTypeSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/subtype_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/medSubTypeOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/subtype_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/medSubSubTypeSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/subsubtype_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/medSubSubTypeOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/subsubtype_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/pathologySpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/pathology_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/pathologyOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/pathology_str"
+ android:inputType="textMultiLine" />
+
+ <Spinner
+ android:id="@+id/interventionSpinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:prompt="@string/intervention_str"
+ android:spinnerMode="dialog" />
+
+ <EditText
+ android:id="@+id/interventionOverride"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/intervention_str"
+ android:inputType="textMultiLine" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="5dp" />
+
+ <CheckBox
+ android:id="@+id/urgencyCheckBox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/urgency_str" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="5dp" />
+
+ <EditText
+ android:id="@+id/notesText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/notes_str"
+ android:inputType="textMultiLine" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="25dp" />
+
+ <CheckBox
+ android:id="@+id/overrideCheckBox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/override_str" />
+
+ <Button
+ android:id="@+id/fillOverrideButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/filloverride_str" />
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="25dp" />
+
+ <Button
+ android:id="@+id/saveButton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/save_str" />
+ </LinearLayout>
+
+</ScrollView> \ No newline at end of file
diff --git a/res/layout/fragment_view_data.xml b/res/layout/fragment_view_data.xml
new file mode 100755
index 0000000..db246f1
--- /dev/null
+++ b/res/layout/fragment_view_data.xml
@@ -0,0 +1,24 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/RelativeLayout1"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:gravity="bottom"
+ android:orientation="vertical">
+
+ <Button
+ android:id="@+id/refreshBtn"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:text="@string/refresh_str" />
+
+ <ListView
+ android:id="@+id/dataBaseListView"
+ android:layout_width="match_parent"
+ android:layout_height="fill_parent"
+ android:layout_above="@+id/refreshBtn" >
+
+ </ListView>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/multiline_spinner_dropdown_item.xml b/res/layout/multiline_spinner_dropdown_item.xml
new file mode 100755
index 0000000..ff05fc2
--- /dev/null
+++ b/res/layout/multiline_spinner_dropdown_item.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/any/layout/simple_spinner_item.xml
+**
+** Copyright 2008, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ style="?android:attr/spinnerDropDownItemStyle"
+ android:singleLine="false"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="45dp"
+ android:ellipsize="marquee"
+ android:textAlignment="inherit"/>
diff --git a/res/layout/override_new_entry.xml b/res/layout/override_new_entry.xml
new file mode 100755
index 0000000..320feb6
--- /dev/null
+++ b/res/layout/override_new_entry.xml
@@ -0,0 +1,95 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/OverrideNewEntry"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <EditText
+ android:id="@+id/overrideType"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/type_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overrideSubType"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/subtype_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overrideSubSubType"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/subsubtype_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overridePatholoty"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/pathology_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overrideIntervention"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/intervention_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overrideFirstAider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/firstaider_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overridePlace"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/place_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+ <EditText
+ android:id="@+id/overrideAnesthesia"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="10"
+ android:hint="@string/anesthesia_str"
+ android:inputType="text" >
+
+ <requestFocus />
+ </EditText>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/menu/main.xml b/res/menu/main.xml
new file mode 100755
index 0000000..d122a4b
--- /dev/null
+++ b/res/menu/main.xml
@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:showAsAction="never"
+ android:title="@string/action_settings"/>
+
+</menu>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
new file mode 100755
index 0000000..c876987
--- /dev/null
+++ b/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
new file mode 100755
index 0000000..0df3067
--- /dev/null
+++ b/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+<resources>
+
+ <!--
+ Customize dimensions originally defined in res/values/dimens.xml (such as
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100755
index 0000000..e3ef53d
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100755
index 0000000..94dd245
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100755
index 0000000..2e0e2ae
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,7 @@
+<resources>
+
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100755
index 0000000..f17b4ad
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">MedLog</string>
+ <string name="action_settings">Settings</string>
+ <string name="title_section1">Nova Entrada</string>
+ <string name="title_section2">Histórico</string>
+ <string name="title_section3">Configurações</string>
+ <string name="nProcess_str">Nº Processo</string>
+ <string name="nSurgery_str">Nº Cirurgia</string>
+ <string name="urgency_str">Urgência</string>
+ <string name="importConfigs_str">Importar Configurações</string>
+ <string name="exportDataBase_str">Exportar Dados</string>
+ <string name="save_str">Guardar</string>
+ <string name="ok_str">Ok</string>
+ <string name="delete_str">APAGAR</string>
+ <string name="refresh_str">Actualizar</string>
+ <string name="exportMessage_str">Dados exportados para: </string>
+ <string name="exportMessageError_str">Falha ao exportar dados!</string>
+ <string name="errorMissingProcessNumber_str">Falta inserir o número do processo!</string>
+ <string name="successSavingEntry_str">Nova entrada guardada com sucesso!</string>
+
+ <string name="yes_str">sim</string>
+ <string name="no_str">não</string>
+ <string name="override_str">Costumizar</string>
+ <string name="filloverride_str">Usar valores anteriores</string>
+
+ <string name="type_str">Tipo</string>
+ <string name="subtype_str">Subtipo</string>
+ <string name="subsubtype_str">Sub-Subtipo</string>
+ <string name="pathology_str">Patologia</string>
+ <string name="intervention_str">Intervenção</string>
+ <string name="firstaider_str">1º Ajudante</string>
+ <string name="anesthesia_str">Anestesia</string>
+ <string name="place_str">Local</string>
+ <string name="notes_str">Notas</string>
+
+</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100755
index 0000000..4ea9326
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,20 @@
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+</resources>
diff --git a/src/com/example/surgerylog/FileOperationsFragment.java b/src/com/example/surgerylog/FileOperationsFragment.java
new file mode 100755
index 0000000..512f02b
--- /dev/null
+++ b/src/com/example/surgerylog/FileOperationsFragment.java
@@ -0,0 +1,185 @@
+package com.example.surgerylog;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Calendar;
+import java.util.List;
+import net.redroid.medlog.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+import com.csvreader.CsvReader;
+import com.csvreader.CsvWriter;
+
+public class FileOperationsFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this fragment.
+ */
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ MainActivity _activity;
+
+ public FileOperationsFragment() {
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ // This makes sure that the container activity has implemented
+ // the callback interface. If not, it throws an exception
+ try {
+ _activity = (MainActivity) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()
+ + " must implement OnHeadlineSelectedListener");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // get root view
+ View rootView = inflater.inflate(R.layout.fragment_file_operations,
+ container, false);
+
+ return rootView;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ // set import MedLog config button
+ Button importFile = (Button) getView().findViewById(R.id.importButton);
+ importFile.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ try {
+ // create csv values
+ CsvReader reader = new CsvReader(
+ _activity.TemplateDescriptionFile);
+
+ // read headers
+ if (reader.readHeaders() == false) {
+ // could not read headers
+ //Log.e("Error", "Headers could not be read.");
+ }
+
+ // copy back headers
+ String headers[] = reader.getHeaders();
+
+ // check number of headers
+ if (headers.length != _activity.ProcessDescriptionFileNumColumns) {
+ // number of headers is incorrect
+ //Log.e("Error", "CSV has incorrect number of headers.");
+ } else {
+ // everything seems nice.... lets rebuild the tree
+ _activity.Root = new MedLogRoot();
+ }
+
+ // read records
+ while (reader.readRecord() == true) {
+ // get record info into
+ MedLogInfo surgeryInfo = new MedLogInfo(reader
+ .get(headers[0]), // med type
+ reader.get(headers[1]), // med subtype
+ reader.get(headers[2]), // med sub-subtype
+ reader.get(headers[3]), // pathology
+ reader.get(headers[4]) // intervention
+ );
+
+ surgeryInfo.FirstAider = reader.get(headers[5]); // first
+ // aider
+ surgeryInfo.Anesthesia = reader.get(headers[6]); // anesthesia
+ surgeryInfo.Place = reader.get(headers[7]); // place
+
+ // add info to grow tree
+ _activity.Root.GrowTreeWithInfo(surgeryInfo);
+ }
+
+ // close csv reading file
+ reader.close();
+ } catch (FileNotFoundException e) {
+ //Log.e("Error", "Config file not found.");
+ } catch (IOException e) {
+ //Log.e("Error", "Config file IO error.");
+ }
+
+ _activity.SaveMedLogConfig();
+ }
+ });
+
+ // set export data base button
+ Button exportDbBtn = (Button) getView().findViewById(
+ R.id.exportDataBase);
+ exportDbBtn.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+
+ //Log.e("Trace Export", "Exporting data");
+
+ CsvWriter writer = null;
+ boolean success = false;
+ try {
+
+ //Log.e("Trace Export", "Trying to open file");
+
+ writer = new CsvWriter(_activity.ExportFile);
+
+ //Log.e("Trace Export", "Writing headers");
+
+ // Write descriptive headers.
+ String[] headers = { "process number", "surgery number",
+ "date", "type", "subtype", "subsubtype",
+ "pathology", "intervention", "first aider",
+ "anesthesia", "place", "urgency", "notes" };
+ writer.writeRecord(headers);
+
+ //Log.e("Trace Export", "Writing records...");
+
+ // write all the records to CSV
+ String[] record = new String[headers.length];
+ for (MedLogInfo log : _activity.DataBase) {
+ record[0] = log.ProcessNumber.toString();
+ record[1] = log.SurgeryNumber.toString();
+ record[2] = log.GetFormatedDate();
+ record[3] = log.Type;
+ record[4] = log.SubType;
+ record[5] = log.SubSubType;
+ record[6] = log.Pathology;
+ record[7] = log.Intervention;
+ record[8] = log.FirstAider;
+ record[9] = log.Anesthesia;
+ record[10] = log.Place;
+ record[11] = _activity.getString(log.Urgency == true ? R.string.yes_str : R.string.no_str);
+ record[12] = log.Notes;
+ writer.writeRecord(record);
+ }
+
+ String message = _activity.getString(R.string.exportMessage_str)
+ + "'"
+ + _activity.ExportFile + "'";
+ _activity.ShowMessage(message);
+
+ //Log.e("Trace Export", "Done");
+
+ success = true;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ writer.close();
+ if (success == false) {
+ _activity.ShowMessage(R.string.exportMessageError_str);
+ }
+ }
+ }
+ });
+
+ super.onActivityCreated(savedInstanceState);
+ }
+}
diff --git a/src/com/example/surgerylog/ISpinnerRefresh.java b/src/com/example/surgerylog/ISpinnerRefresh.java
new file mode 100755
index 0000000..a8baf36
--- /dev/null
+++ b/src/com/example/surgerylog/ISpinnerRefresh.java
@@ -0,0 +1,9 @@
+package com.example.surgerylog;
+
+import java.util.List;
+
+public interface ISpinnerRefresh {
+
+ void SetSpinnerData(int spinnerId, List<String> spinnerData);
+
+}
diff --git a/src/com/example/surgerylog/MainActivity.java b/src/com/example/surgerylog/MainActivity.java
new file mode 100755
index 0000000..47910cc
--- /dev/null
+++ b/src/com/example/surgerylog/MainActivity.java
@@ -0,0 +1,330 @@
+package com.example.surgerylog;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StreamCorruptedException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Map;
+import net.redroid.medlog.R;
+
+import com.csvreader.CsvReader;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Environment;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentStatePagerAdapter;
+import android.support.v4.app.NavUtils;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class MainActivity extends FragmentActivity
+{
+ /**
+ * The {@link android.support.v4.view.PagerAdapter} that will provide
+ * fragments for each of the sections. We use a
+ * {@link android.support.v4.app.FragmentPagerAdapter} derivative, which
+ * will keep every loaded fragment in memory. If this becomes too memory
+ * intensive, it may be best to switch to a
+ * {@link android.support.v4.app.FragmentStatePagerAdapter}.
+ */
+ SectionsPagerAdapter mSectionsPagerAdapter;
+
+ /**
+ * The {@link ViewPager} that will host the section contents.
+ */
+ ViewPager mViewPager;
+
+ // MedTree root
+ public MedLogRoot Root;
+ public List<MedLogInfo> DataBase;
+ public MedLogInfo CurrentInfo = new MedLogInfo();
+
+ // MedTree description file
+ public int ProcessDescriptionFileNumColumns = 8;
+ public String AppFolder = Environment.getExternalStorageDirectory() + "//MedLog";
+ public String TemplateDescriptionFile = Environment.getExternalStorageDirectory() + "//MedLog//template.csv";
+ public String ExportFile = Environment.getExternalStorageDirectory() + "//MedLog//export.csv";
+ public String MedLogConfigFile = Environment.getExternalStorageDirectory() + "//MedLog//config.bin";
+ public String MedLogDataBaseFile = Environment.getExternalStorageDirectory() + "//MedLog//database.bin";
+ private int MessageTime = 1;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ //Log.e("Trace", "MainActiviyy START");
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ // Create root
+ Root = new MedLogRoot();
+
+ // Create the adapter that will return a fragment for each of the three
+ // primary sections of the app.
+ mSectionsPagerAdapter = new SectionsPagerAdapter(
+ getSupportFragmentManager());
+
+ // Set up the ViewPager with the sections adapter.
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ CheckAppFolder();
+ LoadMedLogConfig();
+ LoadMedLogDB();
+
+ //Log.e("Trace", "MainActiviyy OUT");
+ }
+
+// @Override
+// public boolean onCreateOptionsMenu(Menu menu) {
+// // Inflate the menu; this adds items to the action bar if it is present.
+// getMenuInflater().inflate(R.menu.main, menu);
+// return true;
+// }
+
+ private void CheckAppFolder()
+ {
+ File appFolder = new File(AppFolder);
+ if(appFolder.exists() == false)
+ {
+ appFolder.mkdir();
+ }
+ }
+
+ public void LoadMedLogConfig()
+ {
+ try {
+ //Log.e("Trace Cfg", "input file");
+ FileInputStream fis = new FileInputStream(MedLogConfigFile);
+ //FileInputStream fis = getApplicationContext().openFileInput(MedLogConfigFile);
+ //FileInputStream fis = getApplicationContext().openFileInput("MedLogConfig.bin");
+ //Log.e("Trace Cfg", "input stream");
+ ObjectInputStream is = new ObjectInputStream(fis);
+ //Log.e("Trace Cfg", "read object");
+ Root = (MedLogRoot) is.readObject();
+ //Log.e("Trace Cfg", "close file");
+ is.close();
+ //Log.e("Trace Cfg", "done loading");
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ //Log.e("TrTrace Cfgace", "File not found during load.");
+ } catch (StreamCorruptedException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ //Log.e("Trace Cfg", "Stream corrupted during load.");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ //Log.e("Trace Cfg", "IO Exception during load.");
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ //e.printStackTrace();
+ //Log.e("Trace Cfg", "Class not found during load.");
+ }
+ }
+
+ public void SaveMedLogConfig()
+ {
+ try {
+ //Log.e("Trace Cfg", "get context");
+ Context c = getApplicationContext();
+ //Log.e("Trace Cfg", "open output file");
+ //FileOutputStream fos = getApplicationContext().openFileOutput(MedLogConfigFile, Context.MODE_PRIVATE);
+ FileOutputStream fos = new FileOutputStream(MedLogConfigFile);
+ //Log.e("Trace Cfg", "new output stream");
+ ObjectOutputStream os = new ObjectOutputStream(fos);
+ //Log.e("Trace Cfg", "write");
+ os.writeObject(Root);
+ //Log.e("Trace Cfg", "close");
+ os.close();
+ //Log.e("Trace Cfg", "done");
+ } catch (FileNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ //Log.e("Trace Cfg", "File not found during save.");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ //Log.e("Trace Cfg", "IO Exception during save.");
+ }
+ }
+
+ public void LoadMedLogDB()
+ {
+ try {
+ //Log.e("Trace DB", "input file");
+ FileInputStream fis = new FileInputStream(MedLogDataBaseFile);
+ //Log.e("Trace DB", "input stream");
+ ObjectInputStream is = new ObjectInputStream(fis);
+ //Log.e("Trace DB", "read object");
+ DataBase = (List<MedLogInfo>) is.readObject();
+ //Log.e("Trace DB", "close file");
+ is.close();
+ //Log.e("Trace DB", "done loading");
+ } catch (FileNotFoundException e) {
+ //Log.e("Trace DB", "File not found during load.");
+ } catch (StreamCorruptedException e) {
+ //Log.e("Trace DB", "Stream corrupted during load.");
+ } catch (IOException e) {
+ //Log.e("Trace DB", "IO Exception during data base load.");
+ } catch (ClassNotFoundException e) {
+ //Log.e("Trace DB", "Class 'List<MedLogInfo>' not found during load.");
+ }
+ finally
+ {
+ if(DataBase == null)
+ {
+ // create empty data base
+ DataBase = new ArrayList<MedLogInfo>();
+ }
+ }
+ }
+
+ public void SaveMedLogDB()
+ {
+ try {
+ //Log.e("Trace DB", "get context");
+ Context c = getApplicationContext();
+ //Log.e("Trace DB", "open output file");
+ FileOutputStream fos = new FileOutputStream(MedLogDataBaseFile);
+ //Log.e("Trace DB", "new output stream");
+ ObjectOutputStream os = new ObjectOutputStream(fos);
+ //Log.e("Trace DB", "write");
+ os.writeObject(DataBase);
+ //Log.e("Trace DB", "close");
+ os.close();
+ //Log.e("Trace DB", "done");
+ } catch (FileNotFoundException e) {
+ //Log.e("Trace DB", "File not found during save.");
+ } catch (IOException e) {
+ //Log.e("Trace DB", "IO Exception during save.");
+ }
+ }
+
+ public void AddNewEntry()
+ {
+ DataBase.add(CurrentInfo);
+ SaveMedLogDB();
+ Root.GrowTreeWithInfo(CurrentInfo);
+ SaveMedLogConfig();
+ CurrentInfo = new MedLogInfo();
+ }
+
+ public void ShowMessage(int messageId)
+ {
+ for (int i=0; i < MessageTime; i++)
+ {
+ Toast.makeText(this, messageId, Toast.LENGTH_LONG).show();
+ }
+ }
+
+ public void ShowMessage(String message)
+ {
+ for (int i=0; i < MessageTime; i++)
+ {
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show();
+ }
+ }
+
+ /**
+ * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
+ * one of the sections/tabs/pages.
+ */
+ public class SectionsPagerAdapter extends FragmentStatePagerAdapter //FragmentPagerAdapter
+ {
+
+ public SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int position)
+ {
+ //Log.e("Trace", "new frag IN");
+
+ // getItem is called to instantiate the fragment for the given page.
+ // Return a DummySectionFragment (defined as a static inner class
+ // below) with the page number as its lone argument.
+ Fragment fragment;
+ if(position == 0)
+ {
+ fragment = new NewEntryFragment();
+ }
+ else if(position == 1)
+ {
+ fragment = new ViewDataFragment();
+ }
+ else
+ {
+ fragment = new FileOperationsFragment();
+ }
+
+ Bundle args = new Bundle();
+ args.putInt(NewEntryFragment.ARG_SECTION_NUMBER, position + 1);
+ fragment.setArguments(args);
+
+ // retain instances
+ //Log.e("Trace", "new frag");
+
+ return fragment;
+ }
+
+ @Override
+ public int getCount() {
+ // Show 3 total pages.
+ return 3;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position)
+ {
+ Locale l = Locale.getDefault();
+ switch (position) {
+ case 0:
+ return getString(R.string.title_section1).toUpperCase(l);
+ case 1:
+ return getString(R.string.title_section2).toUpperCase(l);
+ case 2:
+ return getString(R.string.title_section3).toUpperCase(l);
+ }
+ return null;
+ }
+ }
+
+
+}
diff --git a/src/com/example/surgerylog/MedLogInfo.java b/src/com/example/surgerylog/MedLogInfo.java
new file mode 100755
index 0000000..c59bd29
--- /dev/null
+++ b/src/com/example/surgerylog/MedLogInfo.java
@@ -0,0 +1,51 @@
+package com.example.surgerylog;
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+public class MedLogInfo implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1109021350324730228L;
+
+ private static final int MONTH_STARTS_IN_0 = 1;
+
+ public Long ProcessNumber;
+ public Long SurgeryNumber;
+
+ public String GetFormatedDate()
+ {
+ return Date.get(Calendar.DAY_OF_MONTH) + "/"
+ + (Date.get(Calendar.MONTH) + MONTH_STARTS_IN_0) + "/"
+ + Date.get(Calendar.YEAR);
+ }
+ public Calendar Date = Calendar.getInstance();
+
+ public String Type;
+ public String SubType;
+ public String SubSubType;
+ public String Pathology;
+ public String Intervention;
+
+ public String FirstAider;
+ public String Anesthesia;
+ public String Place;
+ public Boolean Urgency;
+ public String Notes;
+
+ public MedLogInfo()
+ {
+ super();
+ }
+
+ public MedLogInfo(String infoType, String infoSubType, String infoSubSubType, String infoPathology, String infoIntervention) {
+ super();
+ this.Type = infoType.trim();
+ this.SubType = infoSubType.trim();
+ this.SubSubType = infoSubSubType.trim();
+ this.Pathology = infoPathology.trim();
+ this.Intervention = infoIntervention.trim();
+ }
+}
diff --git a/src/com/example/surgerylog/MedLogRoot.java b/src/com/example/surgerylog/MedLogRoot.java
new file mode 100755
index 0000000..073701b
--- /dev/null
+++ b/src/com/example/surgerylog/MedLogRoot.java
@@ -0,0 +1,142 @@
+package com.example.surgerylog;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+public class MedLogRoot implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7337501254153966693L;
+ private Dictionary<String, MedLogType> _typeDictionary = new Hashtable<String, MedLogType>();
+ private List<String> _typeList = new ArrayList<String>();
+
+ private List<String> _firsAiderList = new ArrayList<String>();
+ private List<String> _anesthesiaList = new ArrayList<String>();
+ private List<String> _placeList = new ArrayList<String>();
+
+ public MedLogRoot() {
+ }
+
+ public void GrowTreeWithInfo(MedLogInfo info) {
+ // try to add new first aider
+ if (HasFirstAider(info.FirstAider) == false) {
+ AddFirstAider(info.FirstAider);
+ }
+
+ // try to add new anesthesia
+ if (HasAnesthesia(info.Anesthesia) == false) {
+ AddAnesthesia(info.Anesthesia);
+ }
+
+ // try to add new place
+ if (HasPlace(info.Place) == false) {
+ AddPlace(info.Place);
+ }
+
+ // try to add new Type
+ if (HasType(info.Type) == false) {
+ AddType(info.Type);
+ }
+
+ // Only add branches if has root...
+ if (HasType(info.Type) == true) {
+
+ // get Type
+ MedLogType type = _typeDictionary.get(info.Type);
+
+ // add Type related information
+ if (type.HasSubType(info.SubType) == false) {
+ type.AddSubType(info.SubType);
+ }
+
+ // Only add branches if has root...
+ if (type.HasSubType(info.SubType) == true) {
+
+ // get SubType
+ MedLogSubType subType = type.GetMedLogSubType(info.SubType);
+
+ // add SubTyppe related information
+ if (subType.HasSubSubType(info.SubSubType) == false) {
+ subType.AddSubSubType(info.SubSubType);
+ }
+ if (subType.HasPathology(info.Pathology) == false) {
+ subType.AddPathology(info.Pathology);
+ }
+ if (subType.HasIntervention(info.Intervention) == false) {
+ subType.AddIntervention(info.Intervention);
+ }
+ }
+ }
+ }
+
+ private Boolean IsValid(String verify) {
+ return verify.trim().isEmpty() == false;
+ }
+
+ public Boolean HasFirstAider(String firstAider) {
+ return _firsAiderList.contains(firstAider.trim());
+ }
+
+ public void AddFirstAider(String firstAider) {
+ if (IsValid(firstAider))
+ _firsAiderList.add(firstAider.trim());
+ }
+
+ public Boolean HasAnesthesia(String anesthesia) {
+ return _anesthesiaList.contains(anesthesia.trim());
+ }
+
+ public void AddAnesthesia(String anesthesia) {
+ if (IsValid(anesthesia))
+ _anesthesiaList.add(anesthesia.trim());
+ }
+
+ public Boolean HasPlace(String place) {
+ return _placeList.contains(place.trim());
+ }
+
+ public void AddPlace(String place) {
+ if (IsValid(place))
+ _placeList.add(place.trim());
+ }
+
+ public Boolean HasType(String type) {
+ return _typeList.contains(type.trim());
+ }
+
+ public void AddType(String type) {
+ if (IsValid(type)) {
+ String typeTrim = type.trim();
+
+ _typeList.add(typeTrim);
+
+ MedLogType surgeryType = new MedLogType();
+ _typeDictionary.put(typeTrim, surgeryType);
+ }
+ }
+
+ public MedLogType GetMedLogType(String type) {
+ return _typeDictionary.get(type.trim());
+ }
+
+ public List<String> GetTypeList() {
+ return _typeList;
+ }
+
+ public List<String> GetFirstAiderList() {
+ return _firsAiderList;
+ }
+
+ public List<String> GetAnesthesiaList() {
+ return _anesthesiaList;
+ }
+
+ public List<String> GetPlaceList() {
+ return _placeList;
+ }
+}
diff --git a/src/com/example/surgerylog/MedLogSubType.java b/src/com/example/surgerylog/MedLogSubType.java
new file mode 100755
index 0000000..7bac538
--- /dev/null
+++ b/src/com/example/surgerylog/MedLogSubType.java
@@ -0,0 +1,87 @@
+package com.example.surgerylog;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class MedLogSubType implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 964773707334886468L;
+ public List<String> _subSubTypeList = new ArrayList<String>();
+ public List<String> _pathologyList = new ArrayList<String>();
+ public List<String> _interventionList = new ArrayList<String>();
+
+ public MedLogSubType()
+ {
+ }
+
+ private Boolean IsValid(String verify) {
+ return verify.trim().isEmpty() == false;
+ }
+
+ public Boolean HasSubSubType(String subSubType)
+ {
+ return _subSubTypeList.contains(subSubType.trim());
+ }
+
+ public Boolean HasPathology(String pathology)
+ {
+ return _pathologyList.contains(pathology.trim());
+ }
+
+ public Boolean HasIntervention(String intervention)
+ {
+ return _interventionList.contains(intervention.trim());
+ }
+
+ public void AddSubSubType(String subSubType)
+ {
+ if(IsValid(subSubType))
+ _subSubTypeList.add(subSubType.trim());
+ }
+
+ public void AddPathology(String pathology)
+ {
+ if(IsValid(pathology))
+ _pathologyList.add(pathology.trim());
+ }
+
+ public void AddIntervention(String intervention)
+ {
+ if(IsValid(intervention))
+ _interventionList.add(intervention.trim());
+ }
+
+ public List<String> GetSubSubTypeList()
+ {
+ return _subSubTypeList;
+ }
+
+ public List<String> GetPathologyList()
+ {
+ return _pathologyList;
+ }
+
+ public List<String> GetInterventionList()
+ {
+ return _interventionList;
+ }
+
+ public int GetNumberOfSubSubTypes()
+ {
+ return _subSubTypeList.size();
+ }
+
+ public int GetNumberOfPathologies()
+ {
+ return _pathologyList.size();
+ }
+
+ public int GetNumberOfInterventions()
+ {
+ return _interventionList.size();
+ }
+}
diff --git a/src/com/example/surgerylog/MedLogType.java b/src/com/example/surgerylog/MedLogType.java
new file mode 100755
index 0000000..d4bc485
--- /dev/null
+++ b/src/com/example/surgerylog/MedLogType.java
@@ -0,0 +1,52 @@
+package com.example.surgerylog;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+
+public class MedLogType implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7877803213238007254L;
+ private Dictionary<String, MedLogSubType> _subTypeDictionary = new Hashtable<String, MedLogSubType>();
+ private List<String> _subTypeList = new ArrayList<String>();
+
+ public MedLogType()
+ {
+ }
+
+ private Boolean IsValid(String verify) {
+ return verify.trim().isEmpty() == false;
+ }
+
+ public Boolean HasSubType(String subType)
+ {
+ return _subTypeList.contains(subType.trim());
+ }
+
+ public MedLogSubType GetMedLogSubType(String subType)
+ {
+ return _subTypeDictionary.get(subType.trim());
+ }
+
+ public void AddSubType(String subType)
+ {
+ if (IsValid(subType)) {
+ String subTypeTrim = subType.trim();
+
+ _subTypeList.add(subTypeTrim);
+
+ MedLogSubType surgerySubType = new MedLogSubType();
+ _subTypeDictionary.put(subTypeTrim, surgerySubType);
+ }
+ }
+
+ public List<String> GetSubTypeList()
+ {
+ return _subTypeList;
+ }
+}
diff --git a/src/com/example/surgerylog/NewEntryFragment.java b/src/com/example/surgerylog/NewEntryFragment.java
new file mode 100755
index 0000000..522d76b
--- /dev/null
+++ b/src/com/example/surgerylog/NewEntryFragment.java
@@ -0,0 +1,437 @@
+package com.example.surgerylog;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+import java.util.SortedSet;
+import net.redroid.medlog.R;
+
+import android.R.color;
+import android.app.Activity;
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.sax.TextElementListener;
+import android.support.v4.app.Fragment;
+import android.text.method.DateTimeKeyListener;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewDebug.FlagToString;
+import android.webkit.WebView.FindListener;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.AdapterView.OnItemSelectedListener;
+
+public class NewEntryFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this fragment.
+ */
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ private MainActivity _activity;
+
+ public NewEntryFragment() {
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ // This makes sure that the container activity has implemented
+ // the callback interface. If not, it throws an exception
+ try {
+ _activity = (MainActivity) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()
+ + " must implement OnHeadlineSelectedListener");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // get root view
+ View rootView = inflater.inflate(R.layout.fragment_new_entry,
+ container, false);
+
+ return rootView;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // get view
+ View view = getView();
+
+ // set TYPE spinner listener
+ Spinner typeSpinner = (Spinner) view.findViewById(R.id.medTypeSpinner);
+ typeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
+ // An item was selected. You can retrieve the selected item using
+ // parent.getItemAtPosition(pos)
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view,
+ int pos, long id) {
+ // get TYPE
+ MedLogType medType = _activity.Root.GetMedLogType(parent
+ .getSelectedItem().toString());
+
+ // set TYPE child spinner
+ SetSpinnerData(R.id.medSubTypeSpinner, medType.GetSubTypeList());
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+ }
+ });
+
+ // set SUBTYPE spinner listener
+ Spinner subTypeSpinner = (Spinner) view
+ .findViewById(R.id.medSubTypeSpinner);
+ subTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
+ // An item was selected. You can retrieve the selected item using
+ // parent.getItemAtPosition(pos)
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view,
+ int pos, long id) {
+ // get selected TYPE
+ Spinner typeSpinner = (Spinner) getView().findViewById(
+ R.id.medTypeSpinner);
+ String selectedType = typeSpinner.getSelectedItem().toString();
+ MedLogType medType = _activity.Root.GetMedLogType(selectedType);
+
+ // get selected SUBTYPE item
+ MedLogSubType medSubtype = medType.GetMedLogSubType(parent
+ .getSelectedItem().toString());
+
+ // set SUBTYPE children spinners
+ SetSpinnerData(R.id.medSubSubTypeSpinner,
+ medSubtype.GetSubSubTypeList());
+ SetSpinnerData(R.id.pathologySpinner,
+ medSubtype.GetPathologyList());
+ SetSpinnerData(R.id.interventionSpinner,
+ medSubtype.GetInterventionList());
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+ }
+ });
+
+ // set save entry button
+ Button saveBtn = (Button) getView().findViewById(R.id.saveButton);
+ saveBtn.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ // if process number is missing... do not accept
+ if (((EditText) getView().findViewById(R.id.nProcess)).getText()
+ .toString().trim().isEmpty() == true) {
+ _activity.ShowMessage(R.string.errorMissingProcessNumber_str);
+ return;
+ }
+
+ // gather med log info
+ GatherMedLogInfo();
+
+ // apply overriden fields
+ if (OverrideIsActivate()) {
+ ApplyOverride();
+ }
+
+ // Log.e("Trace NewEntry", "All info collected");
+
+ _activity.AddNewEntry();
+
+ _activity.ShowMessage(R.string.successSavingEntry_str);
+
+ // reset all entries to the initial state
+ ResetAllEntries();
+
+ // Log.e("Trace NewEntry", "Entry saved");
+ }
+ });
+
+ // set override check box
+ CheckBox overrideCheck = (CheckBox) getView().findViewById(
+ R.id.overrideCheckBox);
+ overrideCheck.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ if (OverrideIsActivate()) {
+ ShowOverrideFields();
+ } else {
+ HideOverrideFields();
+ }
+ }
+ });
+
+ // set fill override text button
+ Button fillOverrideBtn = (Button) getView().findViewById(
+ R.id.fillOverrideButton);
+ fillOverrideBtn.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View arg0) {
+ FillOverrideFromSpinners();
+ }
+ });
+
+ // hide override fields
+ HideOverrideFields();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ // update type spinner based on current activity root
+ SetSpinnerData(R.id.medTypeSpinner, _activity.Root.GetTypeList());
+
+ // update first aider spinner
+ SetSpinnerData(R.id.firstAiderSpinner,
+ _activity.Root.GetFirstAiderList());
+
+ // update anesthesia spinner
+ SetSpinnerData(R.id.anesthesiaSpinner,
+ _activity.Root.GetAnesthesiaList());
+
+ // update place spinner
+ SetSpinnerData(R.id.placeSpinner, _activity.Root.GetPlaceList());
+ }
+
+ private void SetSpinnerData(int spinnerId, List<String> spinnerValues) {
+ // create array adapter
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(getView()
+ .getContext(),
+ // android.R.layout.simple_spinner_dropdown_item,
+ R.layout.multiline_spinner_dropdown_item, spinnerValues);
+
+ // sort spinner values
+ adapter.sort(new Comparator<String>() {
+ public int compare(String object1, String object2) {
+ return object1.compareTo(object2);
+ }
+ });
+
+ // get spinner
+ Spinner spinner = (Spinner) getView().findViewById(spinnerId);
+
+ // set adapter
+ spinner.setAdapter(adapter);
+ }
+
+ private Spinner GetSpinner(int spinnerId) {
+ return (Spinner) getView().findViewById(spinnerId);
+ }
+
+ private EditText GetEditText(int editTextId) {
+ return (EditText) getView().findViewById(editTextId);
+ }
+
+ private CheckBox GetCheckBox(int checkBoxId){
+ return (CheckBox) getView().findViewById(checkBoxId);
+ }
+
+ private String GetTextFromEditText(int editTextId) {
+ return ((EditText) getView().findViewById(editTextId)).getText().toString();
+ }
+
+ private Boolean OverrideIsActivate() {
+ return ((CheckBox) getView().findViewById(R.id.overrideCheckBox))
+ .isChecked();
+ }
+
+ private String GetTextFromSpinner(int spinnerId) {
+ Object item = ((Spinner) getView().findViewById(spinnerId)).getSelectedItem();
+ if (item != null)
+ return item.toString();
+ else
+ return "";
+ }
+
+ private void GatherMedLogInfo() {
+ // Log.e("Trace NewEntry", "Save requested...");
+
+ // collect med log info
+ _activity.CurrentInfo.ProcessNumber = Long
+ .parseLong(((EditText) getView().findViewById(R.id.nProcess))
+ .getText().toString());
+
+ // check if surgery number is empty
+ if (((EditText) getView().findViewById(R.id.nSurgery)).getText()
+ .toString().trim().isEmpty() == true) {
+ _activity.CurrentInfo.SurgeryNumber = (long) 0;
+ } else {
+ _activity.CurrentInfo.SurgeryNumber = Long
+ .parseLong(((EditText) getView()
+ .findViewById(R.id.nSurgery)).getText().toString());
+ }
+
+ // Log.e("Trace NewEntry", "Collected numbers");
+
+ DatePicker date = ((DatePicker) getView().findViewById(R.id.datePicker));
+ _activity.CurrentInfo.Date.set(date.getYear(), date.getMonth(),
+ date.getDayOfMonth());
+
+ // Log.e("Trace NewEntry", "Collected date");
+
+ // get spinners (avoid empty ones)
+ _activity.CurrentInfo.Type = GetTextFromSpinner(R.id.medTypeSpinner);
+ _activity.CurrentInfo.SubType = GetTextFromSpinner(R.id.medSubTypeSpinner);
+
+ _activity.CurrentInfo.SubSubType = GetTextFromSpinner(R.id.medSubSubTypeSpinner);
+ _activity.CurrentInfo.Pathology = GetTextFromSpinner(R.id.pathologySpinner);
+ _activity.CurrentInfo.Intervention = GetTextFromSpinner(R.id.interventionSpinner);
+ _activity.CurrentInfo.FirstAider = GetTextFromSpinner(R.id.firstAiderSpinner);
+ _activity.CurrentInfo.Anesthesia = GetTextFromSpinner(R.id.anesthesiaSpinner);
+ _activity.CurrentInfo.Place = GetTextFromSpinner(R.id.placeSpinner);
+ _activity.CurrentInfo.Urgency = ((CheckBox) getView().findViewById(
+ R.id.urgencyCheckBox)).isChecked();
+
+ _activity.CurrentInfo.Notes = GetTextFromEditText(R.id.notesText);
+ }
+
+ private void ResetAllEntries()
+ {
+ GetEditText(R.id.nProcess).setText("");
+ GetEditText(R.id.nSurgery).setText("");
+ GetEditText(R.id.placeOverride).setText("");
+ GetEditText(R.id.firstAiderOverride).setText("");
+ GetEditText(R.id.anesthesiaOverride).setText("");
+ GetEditText(R.id.medTypeOverride).setText("");
+ GetEditText(R.id.medSubTypeOverride).setText("");
+ GetEditText(R.id.medSubSubTypeOverride).setText("");
+ GetEditText(R.id.pathologyOverride).setText("");
+ GetEditText(R.id.interventionOverride).setText("");
+ GetCheckBox(R.id.urgencyCheckBox).setChecked(false);
+ GetCheckBox(R.id.overrideCheckBox).setChecked(false);
+ GetEditText(R.id.notesText).setText("");
+
+ // set default spinners
+ GetSpinner(R.id.medTypeSpinner).setSelection(0);
+ GetSpinner(R.id.firstAiderSpinner).setSelection(0);
+ GetSpinner(R.id.anesthesiaSpinner).setSelection(0);
+ GetSpinner(R.id.placeSpinner).setSelection(0);
+
+ // hide override
+ HideOverrideFields();
+ }
+
+ private void ApplyOverride() {
+ String value;
+
+ value = GetTextFromEditText(R.id.medTypeOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.Type = value;
+ }
+
+ value = GetTextFromEditText(R.id.medSubTypeOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.SubType = value;
+ }
+
+ value = GetTextFromEditText(R.id.medSubSubTypeOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.SubSubType = value;
+ }
+
+ value = GetTextFromEditText(R.id.pathologyOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.Pathology = value;
+ }
+
+ value = GetTextFromEditText(R.id.interventionOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.Intervention = value;
+ }
+
+ value = GetTextFromEditText(R.id.firstAiderOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.FirstAider = value;
+ }
+
+ value = GetTextFromEditText(R.id.anesthesiaOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.Anesthesia = value;
+ }
+
+ value = GetTextFromEditText(R.id.placeOverride);
+ if(value.isEmpty() == false)
+ {
+ _activity.CurrentInfo.Place = value;
+ }
+ }
+
+ private void HideOverrideFields() {
+ GetEditText(R.id.firstAiderOverride).setVisibility(View.GONE);
+ GetEditText(R.id.anesthesiaOverride).setVisibility(View.GONE);
+ GetEditText(R.id.placeOverride).setVisibility(View.GONE);
+ GetEditText(R.id.medTypeOverride).setVisibility(View.GONE);
+ GetEditText(R.id.medSubTypeOverride).setVisibility(View.GONE);
+ GetEditText(R.id.medSubSubTypeOverride).setVisibility(View.GONE);
+ GetEditText(R.id.pathologyOverride).setVisibility(View.GONE);
+ GetEditText(R.id.interventionOverride).setVisibility(View.GONE);
+
+ ((Button) getView().findViewById(R.id.fillOverrideButton)).setVisibility(View.GONE);
+ }
+
+ private void ShowOverrideFields()
+ {
+ SetOverrideProperties(R.id.firstAiderOverride);
+ SetOverrideProperties(R.id.anesthesiaOverride);
+ SetOverrideProperties(R.id.placeOverride);
+ SetOverrideProperties(R.id.medTypeOverride);
+ SetOverrideProperties(R.id.medSubTypeOverride);
+ SetOverrideProperties(R.id.medSubSubTypeOverride);
+ SetOverrideProperties(R.id.pathologyOverride);
+ SetOverrideProperties(R.id.interventionOverride);
+
+ ((Button) getView().findViewById(R.id.fillOverrideButton)).setVisibility(View.VISIBLE);
+ }
+
+ private void SetOverrideProperties(int exitTextId)
+ {
+ int overrideColor = Color.argb(128, 51, 181, 229);
+ EditText override;
+ override = GetEditText(exitTextId);
+ override.setVisibility(View.VISIBLE);
+ override.setBackgroundColor(overrideColor);
+ }
+
+ private void FillOverrideFromSpinners()
+ {
+ GetEditText(R.id.firstAiderOverride).setText(GetTextFromSpinner(R.id.firstAiderSpinner));
+ GetEditText(R.id.anesthesiaOverride).setText(GetTextFromSpinner(R.id.anesthesiaSpinner));
+ GetEditText(R.id.placeOverride).setText(GetTextFromSpinner(R.id.placeSpinner));
+ GetEditText(R.id.medTypeOverride).setText(GetTextFromSpinner(R.id.medTypeSpinner));
+ GetEditText(R.id.medSubTypeOverride).setText(GetTextFromSpinner(R.id.medSubTypeSpinner));
+ GetEditText(R.id.medSubSubTypeOverride).setText(GetTextFromSpinner(R.id.medSubSubTypeSpinner));
+ GetEditText(R.id.pathologyOverride).setText(GetTextFromSpinner(R.id.pathologySpinner));
+ GetEditText(R.id.interventionOverride).setText(GetTextFromSpinner(R.id.interventionSpinner));
+ }
+
+}
diff --git a/src/com/example/surgerylog/ViewDataFragment.java b/src/com/example/surgerylog/ViewDataFragment.java
new file mode 100755
index 0000000..6adbbaa
--- /dev/null
+++ b/src/com/example/surgerylog/ViewDataFragment.java
@@ -0,0 +1,173 @@
+package com.example.surgerylog;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import net.redroid.medlog.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.AdapterView.OnItemClickListener;
+
+public class ViewDataFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this fragment.
+ */
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ private MainActivity _activity;
+
+ List<String> _viewDataList = new ArrayList<String>();
+
+ int _lastSelected;
+
+ public ViewDataFragment() {
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ // This makes sure that the container activity has implemented
+ // the callback interface. If not, it throws an exception
+ try {
+ _activity = (MainActivity) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity.toString()
+ + " must implement OnHeadlineSelectedListener");
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // get root view
+ View rootView = inflater.inflate(R.layout.fragment_view_data,
+ container, false);
+
+ return rootView;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ // TODO Auto-generated method stub
+ super.onActivityCreated(savedInstanceState);
+
+ // get list view
+ ListView listView = ((ListView) getView().findViewById(
+ R.id.dataBaseListView));
+
+ // set list view on click event
+ listView.setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+
+ // hold last selected
+ _lastSelected = position;
+
+ // prepare the alert box
+ AlertDialog.Builder _alertbox = new AlertDialog.Builder(
+ _activity);
+ MedLogInfo info = _activity.DataBase.get(position);
+ String infoStr = "#Pro: " + info.ProcessNumber.toString()
+ + "\n" + "#Cir: " + info.SurgeryNumber.toString()
+ + "\n" + "Data: " + info.GetFormatedDate()
+ + "\n" + "Ajud: " + info.FirstAider
+ + "\n" + "Anst: " + info.Anesthesia
+ + "\n" + "Locl: " + info.Place
+ + "\n" + "Tipo: " + info.Type
+ + "\n" + "Subt: " + info.SubType
+ + "\n" + "Pato: " + info.Pathology
+ + "\n" + "Intr: " + info.Intervention
+ + "\n" + "Urgn: " + _activity.getString(info.Urgency == true ? R.string.yes_str : R.string.no_str)
+ + "\n" + "Nota: " + info.Notes
+ ;
+ _alertbox.setMessage(infoStr);
+ _alertbox.setNeutralButton(R.string.ok_str,
+ new DialogInterface.OnClickListener() {
+ // click listener on the alert box
+ public void onClick(DialogInterface arg0, int arg1) {
+ // nothing to do here
+ }
+ });
+ _alertbox.setNegativeButton(R.string.delete_str,
+ new DialogInterface.OnClickListener() {
+ // click listener on the alert box
+ public void onClick(DialogInterface arg0, int arg1) {
+ // TODO delete the database entry
+ _activity.DataBase.remove(_lastSelected);
+ _activity.SaveMedLogDB();
+ UpdateListView();
+ }
+ });
+ _alertbox.show();
+ }
+ });
+
+ // REFRESH BUTTON
+ Button refreshBtn = (Button) getView().findViewById(R.id.refreshBtn);
+ refreshBtn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ UpdateListView();
+ }
+ });
+
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ UpdateListView();
+ }
+
+ public void UpdateListView() {
+ // get list data
+ if (_activity.DataBase != null) {
+
+ // remove old entries
+ _viewDataList.clear();
+
+ // add new entries
+ for (MedLogInfo log : _activity.DataBase) {
+ _viewDataList.add(log.ProcessNumber.toString());
+ }
+ }
+
+ // create array adapter
+ ArrayAdapter<String> adapter = new ArrayAdapter<String>(getView()
+ .getContext(), android.R.layout.simple_list_item_1,
+ _viewDataList);
+
+ // // sort list values
+ // adapter.sort(new Comparator<String>() {
+ // public int compare(String object1, String object2) {
+ // return object1.compareTo(object2);
+ // }
+ // });
+
+ // get list view
+ ListView listView = ((ListView) getView().findViewById(
+ R.id.dataBaseListView));
+
+ // set adapter
+ listView.setAdapter(adapter);
+ }
+
+}