songjungeun 4 years ago
parent
commit
9b39442e62

+ 13 - 9
app/src/main/java/com/dbs/consent/ynu/MainActivity.java

@@ -229,15 +229,19 @@ public class MainActivity extends AppCompatActivity {
       });
 
   private void nextActivity() {
-    new Handler().postDelayed(new Runnable() {
-      @Override
-      public void run() {
-        // 수행할 내용 입력
-        Intent intent = new Intent(mContext, LoginActivity.class);
-        startActivity(intent);
-        finish();
-      }
-    }, 500); // 2초 뒤에 수행할 내용에 입력된게 실행됨, 시간은 사용자에 맞게 변경하면됨
+//    new Handler().postDelayed(new Runnable() {
+//      @Override
+//      public void run() {
+//        // 수행할 내용 입력
+//        Intent intent = new Intent(mContext, LoginActivity.class);
+//        startActivity(intent);
+//        finish();
+//      }
+//    }, 500); // 2초 뒤에 수행할 내용에 입력된게 실행됨, 시간은 사용자에 맞게 변경하면됨
+
+    Intent intent = new Intent(mContext, LoginActivity.class);
+    startActivity(intent);
+    finish();
   }
 
   @Override

+ 83 - 1
app/src/main/java/com/dbs/consent/ynu/consent/EFormSaveHandler.java

@@ -2,9 +2,20 @@ package com.dbs.consent.ynu.consent;
 
 import android.content.Context;
 
+import com.dbs.consent.ynu.R;
 import com.dbs.consent.ynu.activity.ConsentActivity;
 import com.dbs.consent.ynu.httpTask.HttpCallBack;
+import com.dbs.consent.ynu.httpTask.HttpImageUpload;
+import com.dbs.consent.ynu.util.ConsentConfig;
+import com.dbs.consent.ynu.util.Util;
 
+import org.json.JSONObject;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 
 import kr.co.clipsoft.eform.EFormToolkit;
@@ -35,10 +46,81 @@ public class EFormSaveHandler implements IEventHandler<ResultEventArgs>, HttpCal
     this.apiType      = apiType;
   }
 
-
   @Override
   public void eventReceived(Object o, ResultEventArgs resultEventArgs) {
+    saveMapData = createSaveData(resultEventArgs, consentData);
+    saveProcess(saveMapData, resultEventArgs);
+  }
+
+  private HashMap<String, Object> createSaveData(ResultEventArgs eventArgs, HashMap<String, Object> consentData) {
+    HashMap<String, Object> resultMap = new HashMap<>();
+    return resultMap;
+  }
+
+  private void saveProcess(HashMap<String, Object> saveMapData, ResultEventArgs eventArgs) {
+    if (!Util.checkNetwork(mContext)) {
+      eFormToolkit.sendEFormViewerCancelEvent(mContext.getString(R.string.networkError));
+    } else {
+      switch (eventArgs.getResultCode()) {
+        case SAVE: // 인증
+        case TEMP_SAVE2: // 확인
+          Util.callHttpUrlConnection(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.SAVE_CONFIRM_CERTIFY, null, callBack);
+          break;
+        case TEMP_SAVE: // 임시
+          Util.callHttpUrlConnection(mContext, ConsentConfig.HOST_CONSENT, ConsentConfig.SAVE_TEMP, null, callBack);
+          break;
+      }
+    }
+  }
+
+  private HashMap<String, String> imageUpload(ResultEventArgs eventArgs) {
+    HashMap<String, String> saveData = new HashMap<>();
+
+    ArrayList<String> imagePathList = eventArgs.getImagePath();
+    String imageFileSize = "";
+
+    JSONObject imageFileJsonObj = new JSONObject();
+    StringBuffer hashValue = new StringBuffer();
+    try {
+      for (int i = 0; i < imagePathList.size(); i++) {
+        File imageFile = new File(imagePathList.get(i));
+        String fileName = Util.convertDateString(new Date(), "yyyy/MM/dd") + imageFile.getName();
+
+        imageFileSize += String.valueOf(imageFile.length() / 1024);
+        if (imagePathList.size() - 1 > i) {
+          imageFileSize += ", ";
+        }
+
+        HttpImageUpload imageUpload = new HttpImageUpload(ConsentConfig.CONSENT_IMAGE_UPLOAD_URL, imageFile, fileName);
+        boolean result = imageUpload.execute().get();
+        imageFileJsonObj.put("imageFile" + (i + 1), fileName);
+        hashValue.append(createHashValue(imageFile));
+
+        if ((i + 1) < imagePathList.size()) {
+          hashValue.append("^");
+        }
+
+        imageFile.delete();
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+
+    return saveData;
+  }
 
+  /**
+   * HashValue 생성
+   * @param consentImageFile
+   * @return
+   * @throws Exception
+   */
+  private String createHashValue(File consentImageFile) throws Exception {
+    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(consentImageFile));
+    byte[] fileBuf = new byte[bis.available()];
+    bis.read(fileBuf);
+    return Util.sha256(null, fileBuf);
   }
 
   @Override

+ 93 - 3
app/src/main/java/com/dbs/consent/ynu/customView/CustomSettingAlertDialog.java

@@ -6,6 +6,7 @@ import android.graphics.PorterDuff;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 import android.widget.CompoundButton;
@@ -18,9 +19,12 @@ import androidx.core.content.ContextCompat;
 import com.dbs.consent.ynu.BuildConfig;
 import com.dbs.consent.ynu.R;
 import com.dbs.consent.ynu.activity.ConsentActivity;
+import com.dbs.consent.ynu.httpTask.HttpCallBack;
 import com.dbs.consent.ynu.util.ConsentConfig;
 import com.dbs.consent.ynu.util.Util;
 
+import org.json.JSONException;
+import org.json.JSONObject;
 import org.ksoap2.serialization.SoapObject;
 
 import java.util.HashMap;
@@ -87,9 +91,12 @@ public class CustomSettingAlertDialog extends Dialog {
 
     Drawable confirmBg  = (Drawable) btnConfirm.getBackground();
     Drawable cancelBg   = (Drawable) btnCancel.getBackground();
-    confirmBg.setColorFilter(ContextCompat.getColor(mContext, R.color.commonColor), PorterDuff.Mode.SRC_ATOP);
 
-    cancelBg.setColorFilter(ContextCompat.getColor(mContext, R.color.alertCancelColor), PorterDuff.Mode.SRC_ATOP);
+    confirmBg.setTint(ContextCompat.getColor(mContext, R.color.commonColor));
+    cancelBg.setTint(ContextCompat.getColor(mContext, R.color.alertCancelColor));
+
+//    confirmBg.setColorFilter(ContextCompat.getColor(mContext, R.color.commonColor), PorterDuff.Mode.SRC_ATOP);
+//    cancelBg.setColorFilter(ContextCompat.getColor(mContext, R.color.alertCancelColor), PorterDuff.Mode.SRC_ATOP);
   }
   
   private void setSetting() {
@@ -119,7 +126,90 @@ public class CustomSettingAlertDialog extends Dialog {
   }
   
   private void settingSubmit() {
-//    ((ConsentActivity) mContext).showProgress();
+    ((ConsentActivity) mContext).showProgress();
+    HttpCallBack callBack = new HttpCallBack() {
+      @Override
+      public void result(String result) {
+        Log.e(TAG, "result -- > " + result);
+        if (result.equals("")) {
+          stop();
+        } else {
+          try {
+            JSONObject jsonObject = Util.xmltoJsonObject(result);
+            String jsonStr = Util.xmlToJsonString(jsonObject);
+            JSONObject object = new JSONObject(jsonStr);
+            Log.e(TAG, "object -- > " + object);
+
+            int res = Integer.parseInt(object.get("responseData").toString().trim());
+
+            if (res == 1) {
+              Util.setStringPreference(mContext, "userInfo", "indexPage", status);
+              dismiss();
+              ((ConsentActivity) mContext).dismissProgress();
+            } else {
+              stop();
+            }
+
+          } catch (JSONException e) {
+            e.printStackTrace();
+          }
+        }
+      }
+
+      @Override
+      public void stop() {
+        ((ConsentActivity) mContext).showSingButtonDialog(mContext.getString(R.string.settingError));
+        ((ConsentActivity) mContext).dismissProgress();
+        dismiss();
+      }
+
+      @Override
+      public void error() {
+        stop();
+      }
+    };
+
+    String str = "";
+    String message = mContext.getString(R.string.settingAlertMsg);
+    if (status.equals("I")) {
+      str = mContext.getString(R.string.admission);
+    } else if (status.equals("O")) {
+      str = mContext.getString(R.string.outPatient);
+    } else if (status.equals("E")) {
+      str = mContext.getString(R.string.emergency);
+    } else if (status.equals("OP")) {
+      str = mContext.getString(R.string.surgery);
+    } else {
+      str = mContext.getString(R.string.search);
+    }
+
+    message = String.format(message, str);
+    ((ConsentActivity) mContext).csAlert.show();
+    ((ConsentActivity) mContext).csAlert.setContent(message, "");
+
+    ((ConsentActivity) mContext).csAlert.btnConfirm.setOnClickListener(new View.OnClickListener() {
+      @Override
+      public void onClick(View v) {
+        HashMap<String, String> mData = new HashMap<String, String>();
+        mData.put("userId", userId);
+        mData.put("status", status);
+        mData.put("instCd", BuildConfig.INST_CD);
+        Util.callHttpUrlConnection(mContext, ConsentConfig.HOST_HOSPITAL, ConsentConfig.UPDATE_USER_SETUP, mData, callBack);
+//        Util.callHttp(mContext, ConsentConfig.HOST_HOSPITAL, ConsentConfig.UPDATE_USER_SETUP , mData, callBack);
+        ((ConsentActivity) mContext).csAlert.dismiss();
+      }
+    });
+
+    ((ConsentActivity) mContext).csAlert.btnCancel.setOnClickListener(new View.OnClickListener() {
+      @Override
+      public void onClick(View v) {
+        ((ConsentActivity) mContext).csAlert.dismiss();
+        ((ConsentActivity) mContext).dismissProgress();
+        dismiss();
+      }
+    });
+
+
 //    final CallBack callBack = new CallBack() {
 //      @Override
 //      public void result(SoapObject result) {

+ 2 - 0
app/src/main/java/com/dbs/consent/ynu/fragment/HistoryFragment.java

@@ -108,6 +108,8 @@ public class HistoryFragment extends Fragment {
 
     View view = (View) inflater.inflate(R.layout.activity_history_fragment, container, false);
 
+    csAlert = new CustomAlertDialog(mContext);
+
     typePatient         = (LinearLayout) view.findViewById(R.id.typePatient);
     patientLeftRound    = (LinearLayout) view.findViewById(R.id.patientLeftRound);
     ivPatient           = (ImageView) view.findViewById(R.id.ivPatient);

+ 9 - 1
app/src/main/res/layout/custom_setting_alert.xml

@@ -2,11 +2,12 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:background="@drawable/department_layer">
 
     <LinearLayout
         android:layout_width="350dp"
-        android:layout_height="360dp"
+        android:layout_height="400dp"
         android:layout_centerInParent="true"
         android:background="@drawable/department_layer"
         android:orientation="vertical">
@@ -54,6 +55,7 @@
 
                     <RadioButton
                         android:id="@+id/inPatientRid"
+                        style="@style/MyRadioButtonStyle"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:padding="8dp"
@@ -62,6 +64,7 @@
 
                     <RadioButton
                         android:id="@+id/outPatientRid"
+                        style="@style/MyRadioButtonStyle"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:padding="8dp"
@@ -70,6 +73,7 @@
 
                     <RadioButton
                         android:id="@+id/erPatientRid"
+                        style="@style/MyRadioButtonStyle"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:padding="8dp"
@@ -78,6 +82,7 @@
 
                     <RadioButton
                         android:id="@+id/opPatientRid"
+                        style="@style/MyRadioButtonStyle"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:padding="8dp"
@@ -86,6 +91,7 @@
 
                     <RadioButton
                         android:id="@+id/searchRid"
+                        style="@style/MyRadioButtonStyle"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:padding="8dp"
@@ -113,6 +119,7 @@
                     <Button
                         android:id="@+id/btnConfirm"
                         style="?android:attr/borderlessButtonStyle"
+                        app:backgroundTint="@null"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent"
                         android:layout_marginLeft="48dp"
@@ -128,6 +135,7 @@
                     <Button
                         android:id="@+id/btnCancel"
                         style="?android:attr/borderlessButtonStyle"
+                        app:backgroundTint="@null"
                         android:layout_width="match_parent"
                         android:layout_height="match_parent"
                         android:layout_marginLeft="10dp"