Browse Source

[회원가입][Common] 모바일 인증 화면 유효성 텍스트 추가 및 자동스크롤 기능 수정중

Hasemi 7 years ago
parent
commit
63791cd50e

+ 25 - 15
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/IMobileAuthorizationDialog.java

@@ -11,40 +11,50 @@ package kr.co.zumo.app.lifeplus.view.dialog;
  * @since 2018-09-17
  */
 public interface IMobileAuthorizationDialog {
+
+  /**
+   * clear validation name textView
+   */
+  void doClearNameValidationTextView();
+
   /**
    * name validation check
    *
-   * @param inputName
+   * @param StringId
    */
-  void doNameValidationMessage(String inputName);
+  void doNameValidationMessage(int StringId);
 
   /**
    * nationality validation check
-   *
-   * @param inputNationality
    */
-  void doNationalityValidationMessage(String inputNationality);
+  void doNationalityValidationMessage();
 
   /**
-   * birth date validation check
-   *
-   * @param inputBirthDate
+   * clear validation birthDate textView
    */
-  void doBirthDateValidationMessage(String inputBirthDate);
+  void doClearBirthDateValidationTextView();
+
+  /**
+   * birthDate validation message
+   */
+  void doBirthDateValidationMessage(int StringId);
 
   /**
    * gender validation check
-   *
-   * @param inputGender
    */
-  void doGenderValidationMessage(String inputGender);
+  void doGenderValidationMessage();
+
+  /**
+   * clear validation Phone Number textView
+   */
+  void doClearPhoneNumberValidationTextView();
 
   /**
-   * 핸드폰 번호 validation check
+   * Phone Number validation check
    *
-   * @param inputPhoneNumber
+   * @param stringId
    */
-  void doPhoneNumberCheckedValidationMessage(String inputPhoneNumber);
+  void doPhoneNumberCheckedValidationMessage(int stringId);
 
   /**
    * 인증번호 validation check

+ 63 - 6
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/MobileAuthorizationDialog.java

@@ -1,9 +1,11 @@
 package kr.co.zumo.app.lifeplus.view.dialog;
 
 
+import android.app.Activity;
 import android.app.Dialog;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
+import android.support.annotation.StringRes;
 import android.support.v4.app.DialogFragment;
 import android.text.Editable;
 import android.text.TextWatcher;
@@ -11,11 +13,13 @@ import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView;
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.EditText;
+import android.widget.LinearLayout;
 import android.widget.RadioButton;
 import android.widget.Spinner;
 import android.widget.TextView;
@@ -40,6 +44,9 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
   private Button buttonTimeDelay;
   private Button buttonIdentifyNumberSend;
 
+  private InputMethodManager manager;
+
+  private LinearLayout linearLayout;
   private EditText editTextName;
   private RadioButton radioSelectLocal;
   private EditText editTextBirthDate;
@@ -55,6 +62,10 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
   private EditText editTextAuthorizedNumber;
   private TextView textViewPhoneIdentifyTime;
 
+  private TextView textViewBirthValidation;
+  private TextView textViewNameValidation;
+  private TextView textViewPhoneValidation;
+
   private MobileAuthorizationPresenter presenter;
   CheckBoxAllDriver checkBoxAllDriver;
 
@@ -71,6 +82,11 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
   @Override
   public void onCreate(Bundle savedInstanceState) {
     setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
+    // getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    // getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
+    InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
+    // TODO: auto scroll 추가
+
     presenter = new MobileAuthorizationPresenter(this);
     if (null != resultListener) {
       presenter.setResultListener(resultListener);
@@ -142,7 +158,7 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
    * @param view
    */
   private void initView(View view) {
-
+    linearLayout = view.findViewById(R.id.linear_layout_identify);
     buttonConfirm = view.findViewById(R.id.button_phone_identify_confirm);
     buttonTimeDelay = view.findViewById(R.id.button_phone_identify_time_delay);
     buttonIdentifyNumberSend = view.findViewById(R.id.button_identify_number_send);
@@ -160,6 +176,9 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
     editTextPhoneNumber = view.findViewById(R.id.edit_text_phone_number);
     editTextAuthorizedNumber = view.findViewById(R.id.edit_text_authorized_number);
     textViewPhoneIdentifyTime = view.findViewById(R.id.text_view_phone_identify_time);
+    textViewBirthValidation = view.findViewById(R.id.text_view_birth_validation);
+    textViewNameValidation = view.findViewById(R.id.text_view_name_validation);
+    textViewPhoneValidation = view.findViewById(R.id.text_view_phone_number_validation);
 
     checkBoxAllDriver = new CheckBoxAllDriver(checkBoxAllAgree);
     checkBoxAllDriver.addChildBox(checkBoxAgree1);
@@ -167,10 +186,21 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
     checkBoxAllDriver.addChildBox(checkBoxAgree3);
     checkBoxAllDriver.addChildBox(checkBoxAgree4);
 
+    linearLayout.setOnClickListener(this);
     buttonConfirm.setOnClickListener(this);
     buttonTimeDelay.setOnClickListener(this);
     buttonIdentifyNumberSend.setOnClickListener(this);
 
+    editTextName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+      @Override
+      public void onFocusChange(View view, boolean isFocusChanged) {
+        if (!isFocusChanged) {
+          presenter.doClearNameValidationTextView();
+        }
+      }
+    });
+
+
     editTextName.addTextChangedListener(new TextWatcher() {
       @Override
       public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -188,6 +218,15 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
       }
     });
 
+    editTextBirthDate.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+      @Override
+      public void onFocusChange(View view, boolean isFocusChanged) {
+        if (!isFocusChanged) {
+          presenter.doClearBirthDatValidationTextView();
+        }
+      }
+    });
+
     editTextBirthDate.addTextChangedListener(new TextWatcher() {
       @Override
       public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
@@ -340,6 +379,8 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
       case R.id.button_identify_number_send:
         presenter.onAuthorizationNumberSendButtonClick();
         break;
+      case R.id.linear_layout_identify:
+        break;
       default:
         break;
     }
@@ -348,28 +389,44 @@ public class MobileAuthorizationDialog extends DialogBase implements View.OnClic
 
 
   @Override
-  public void doNameValidationMessage(String inputName) {
+  public void doClearNameValidationTextView() {
+    textViewNameValidation.setText("");
+  }
 
+  @Override
+  public void doNameValidationMessage(@StringRes int StringId) {
+    textViewNameValidation.setText(StringId);
   }
 
   @Override
-  public void doNationalityValidationMessage(String inputNationality) {
+  public void doNationalityValidationMessage() {
 
   }
 
   @Override
-  public void doBirthDateValidationMessage(String inputBirthDate) {
+  public void doClearBirthDateValidationTextView() {
+    textViewBirthValidation.setText("");
+  }
 
+  @Override
+  public void doBirthDateValidationMessage(@StringRes int stringId) {
+    textViewBirthValidation.setText(stringId);
   }
 
+
   @Override
-  public void doGenderValidationMessage(String inputGender) {
+  public void doGenderValidationMessage() {
 
   }
 
   @Override
-  public void doPhoneNumberCheckedValidationMessage(String inputPhoneNumber) {
+  public void doClearPhoneNumberValidationTextView() {
+    textViewPhoneValidation.setText("");
+  }
 
+  @Override
+  public void doPhoneNumberCheckedValidationMessage(@StringRes int stringId) {
+    textViewPhoneValidation.setText(stringId);
   }
 
   @Override

+ 48 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/MobileAuthorizationPresenter.java

@@ -4,6 +4,7 @@ import android.util.Log;
 
 import java.util.Calendar;
 
+import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.util.DateUtil;
 import kr.co.zumo.app.lifeplus.view.presenter.bean.SignUpUserBean;
 
@@ -32,6 +33,10 @@ public class MobileAuthorizationPresenter {
     this.resultListener = resultListener;
   }
 
+  public void doClearNameValidationTextView() {
+    view.doClearNameValidationTextView();
+  }
+
   /**
    * name 필드의 입력시 호출
    *
@@ -39,7 +44,23 @@ public class MobileAuthorizationPresenter {
    */
   public void onNameTextChanged(String inputName) {
     Log.e("APP#  MobileAuthorizationPresenter | doNameValidationMessage", "|" + inputName);
-    userBean.setName(inputName);
+    if (inputName.length() == 0) {
+      //이름 미입력시
+      view.doNameValidationMessage(R.string.phone_identify_name_input_validation);
+    }
+    else if (inputName.length() == 2) {
+      //한글 2자 미만 입력시
+      view.doNameValidationMessage(R.string.phone_identify_name_length_validation);
+    }
+    else if (inputName.length() >= 3) {
+      view.doClearNameValidationTextView();
+      userBean.setName(inputName);
+    }
+
+  }
+
+  public void doClearBirthDatValidationTextView() {
+    view.doClearBirthDateValidationTextView();
   }
 
   /**
@@ -50,8 +71,17 @@ public class MobileAuthorizationPresenter {
   public void onBirthDateTextChanged(String inputBirthDate) {
     Log.e("APP#  MobileAuthorizationPresenter | onBirthDateTextChanged", "|" + inputBirthDate);
 
-    // 8자리 인지 확인
-    if (inputBirthDate.length() == 8) {
+    if (inputBirthDate.length() == 0) {
+      Log.e("APP#  MobileAuthorizationPresenter | onBirthDateTextChanged", "|" + "length 0");
+      view.doBirthDateValidationMessage(R.string.phone_identify_birth_date_input_validation_message);
+    }
+    else if (inputBirthDate.length() <= 7) {
+      //숫자 7자리 이하 입력시
+      Log.e("APP#  MobileAuthorizationPresenter | onBirthDateTextChanged", "|" + "birthDateLength check");
+      view.doBirthDateValidationMessage(R.string.phone_identify_birth_date_length_validation_message);
+    }
+    else if (inputBirthDate.length() == 8) { //8자리 확인
+      view.doClearBirthDateValidationTextView();
       // 년 월 일 확인
       int year = Integer.valueOf(inputBirthDate.substring(0, 4));
       int month = Integer.valueOf(inputBirthDate.substring(4, 6));
@@ -66,12 +96,14 @@ public class MobileAuthorizationPresenter {
 
         Log.i("APP# MobileAuthorizationPresenter | onBirthDateTextChanged", "| isOverAge: " + isOverAge);
 
-        if(isOverAge) {
+        if (isOverAge) {
           // 14 세 이상 가입 가능
         }
         else {
           // 14 세 미만 가입 불가 알림
           // todo 14세 미만 알림
+          Log.e("APP#  MobileAuthorizationPresenter | onBirthDateTextChanged", "|" + "14세미만 알림");
+          view.doBirthDateValidationMessage(R.string.phone_identify_age_limit_validation_message);
         }
 
       }
@@ -87,7 +119,18 @@ public class MobileAuthorizationPresenter {
    */
   public void onPhoneNumberTextChanged(String phoneNumber) {
     Log.e("APP#  MobileAuthorizationPresenter | onPhoneNumberCheckedValidationMessage", "|" + phoneNumber);
-    userBean.setPhoneNumber(phoneNumber);
+
+    if (phoneNumber.length() == 0) {
+      view.doPhoneNumberCheckedValidationMessage(R.string.phone_identify_phone_validation);
+    }
+    else if (phoneNumber.length() <= 6) {
+      view.doPhoneNumberCheckedValidationMessage(R.string.phone_identify_phone_validation);
+    }
+    else {
+      view.doClearPhoneNumberValidationTextView();
+      userBean.setPhoneNumber(phoneNumber);
+    }
+
   }
 
   /**

+ 51 - 7
app/src/main/res/layout/sign_up_phone_identify_dialog.xml

@@ -3,11 +3,15 @@
 <ScrollView
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
+  android:fillViewport="true"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">
 
   <LinearLayout
+    android:focusable="true"
+    android:focusableInTouchMode="true"
+    android:id="@+id/linear_layout_identify"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/white"
@@ -32,7 +36,6 @@
     <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
-      android:layout_marginBottom="10pt"
       android:orientation="horizontal">
 
 
@@ -91,6 +94,22 @@
       </RadioGroup>
 
     </LinearLayout>
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:orientation="vertical"
+      android:layout_marginLeft="5pt"
+
+      >
+
+      <TextView
+        android:id="@+id/text_view_name_validation"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textColor="@color/red"
+        />
+
+    </LinearLayout>
 
 
     <LinearLayout
@@ -100,7 +119,6 @@
       >
 
       <TextView
-        android:id="@+id/textView10"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_margin="5pt"
@@ -112,7 +130,6 @@
     <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
-      android:layout_marginBottom="15pt"
       android:orientation="horizontal">
 
 
@@ -172,6 +189,23 @@
       </RadioGroup>
 
     </LinearLayout>
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:orientation="vertical"
+      android:layout_marginLeft="5pt"
+
+      >
+
+      <TextView
+        android:id="@+id/text_view_birth_validation"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textColor="@color/red"
+        />
+
+    </LinearLayout>
+
 
     <LinearLayout
       android:layout_width="match_parent"
@@ -346,12 +380,24 @@
         android:id="@+id/edit_text_phone_number"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_margin="5pt"
+        android:layout_marginLeft="5pt"
+        android:layout_marginRight="5pt"
+        android:layout_marginTop="5pt"
+        android:maxLength="8"
         android:background="@drawable/input_border"
         android:hint="@string/phone_identify_phone_hint"
         android:inputType="number"
         android:padding="3pt"/>
 
+        <TextView
+          android:id="@+id/text_view_phone_number_validation"
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:textColor="@color/red"
+          android:layout_marginLeft="5pt"
+          android:layout_marginBottom="20dp"
+          />
+
       <Button
         android:id="@+id/button_identify_number_send"
         android:layout_width="match_parent"
@@ -361,8 +407,6 @@
         android:layout_marginRight="5pt"
         android:text="@string/phone_identify_submit"
         />
-
-
     </LinearLayout>
 
     <LinearLayout
@@ -380,7 +424,6 @@
         android:background="@drawable/input_border"
         android:hint="@string/phone_identify_six_characters"
         android:inputType="number"
-
         android:padding="3pt"/>
 
       <Button
@@ -400,6 +443,7 @@
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal"
+      android:isScrollContainer="true"
       android:weightSum="5">
 
       <TextView

+ 1 - 0
app/src/main/res/values/colors.xml

@@ -6,4 +6,5 @@
   <color name="darkGrey">#CCCCCC</color>
   <color name="white">#FFFFFF</color>
   <color name="black">#000000</color>
+  <color name="red">#F44336</color>
 </resources>

+ 8 - 0
app/src/main/res/values/strings.xml

@@ -70,6 +70,14 @@
   <string name="phone_identify_confirm">확 인</string>
   <string name="phone_identify_time">남은 시간 : </string>
   <string name="phone_identify_time_delay">시간 연장</string>
+  <string name="phone_identify_name_input_validation">이름을 입력해주세요</string>
+  <string name="phone_identify_name_length_validation">이름을 정확히 입력해주세요</string>
+  <string name="phone_identify_age_limit_validation_message">만 14세 미만 청소년의 경우 가입이 제한 됩니다</string>
+  <string name="phone_identify_birth_date_length_validation_message">YYYYMMDD 숫자를 입력해 주세요</string>
+  <string name="phone_identify_birth_date_input_validation_message">생년월일을 입력해주세요</string>
+  <string name="phone_identify_phone_validation">휴대전화 번호 뒤 7~8자리를 입력해주세요</string>
+
+
 
   <string name="network_disconnected_message">네트워크 연결되지 않음</string>