瀏覽代碼

[공통][Bug] 간편 암호 입력 다이얼로그 리팩토링

hyodong.min 7 年之前
父節點
當前提交
5566e633a6

+ 9 - 8
app/src/main/java/kr/co/zumo/app/lifeplus/activity/SplashActivity.java

@@ -66,7 +66,7 @@ public class SplashActivity extends AppCompatActivity {
     if (SuperModel.getInstance().isInitialized()) {
       Log.e("APP#  SplashActivity | onCreate", "|" + " restart from call...........");
 
-      linkActivity(context, ScreenStarter.START_FROM_MAIN, param);
+      linkActivity(ScreenStarter.START_FROM_MAIN, param);
 
     }
     else {
@@ -82,26 +82,27 @@ public class SplashActivity extends AppCompatActivity {
         .subscribe(isConnected -> {
           disposable.dispose();
 
-          starter.launch(isConnected, (context1, fragmentFlag) -> jumpActivity(context1, fragmentFlag, param));
+          starter.launch(isConnected, (context1, fragmentFlag) -> jumpActivity(fragmentFlag, param));
         }, Throwable::printStackTrace)
       );
     }
   }
 
-  private void linkActivity(Context context1, int fragmentFlag, String param) {
-    Intent intent = new Intent(context1, MainActivity.class);
+  private void linkActivity(int fragmentFlag, String param) {
+    Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra(ScreenStarter.FLAG_FRAGMENT, fragmentFlag);
     intent.putExtra(ScreenStarter.SHARE_PARAMETER, param);
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-    context1.startActivity(intent);
+
+    startActivity(intent);
   }
 
-  private void jumpActivity(Context context1, int fragmentFlag, String param) {
-    Intent intent = new Intent(context1, MainActivity.class);
+  private void jumpActivity(int fragmentFlag, String param) {
+    Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra(ScreenStarter.FLAG_FRAGMENT, fragmentFlag);
     intent.putExtra(ScreenStarter.SHARE_PARAMETER, param);
 
-    context1.startActivity(intent);
+    startActivity(intent);
   }
 
   @Override

+ 47 - 84
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/pin/CustomPinConfirmPresenter.java

@@ -3,13 +3,7 @@
  */
 package kr.co.zumo.app.lifeplus.view.custom.pin;
 
-import java.util.concurrent.TimeUnit;
-
-import io.reactivex.Completable;
-import io.reactivex.android.schedulers.AndroidSchedulers;
-import io.reactivex.disposables.CompositeDisposable;
 import kr.co.zumo.app.R;
-import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 
 /**
  * CustomPinConfirmPresenter
@@ -21,105 +15,74 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
  * @history 민효동   [2018-10-04]   [최초 작성]
  * @since 2018-10-04
  */
-public class CustomPinConfirmPresenter implements IPinContract.Presenter {
-
-  protected IPinContract.View view;
-  protected IPinContract.Listener listener;
+public class CustomPinConfirmPresenter extends CustomPinPresenter {
 
-  protected String pin;
-  protected int matchCount;
-  protected CompositeDisposable disposable = new CompositeDisposable();
 
   public CustomPinConfirmPresenter(IPinContract.View view, IPinContract.Listener listener) {
-    this.view = view;
-    this.listener = listener;
-  }
-
-  protected boolean isResetButtonVisible() {
-    return true;
+    super(view, listener);
   }
 
+  /**
+   * 닫기 버튼 보이기 설정
+   *
+   * @return
+   */
   protected boolean isCloseButtonVisible() {
     return true;
   }
 
+  /**
+   * 문의 버튼 보이기 설정
+   *
+   * @return
+   */
   protected boolean isHelpButtonVisible() {
     return true;
   }
 
-  @Override
-  public void start() {
-    this.view.setPresenter(this);
-    this.view.setResetButtonVisible(isResetButtonVisible());
-  }
-
-  @Override
-  public void onPinStart() {
-    view.setCloseButtonVisible(isCloseButtonVisible());
-    view.setHelpButtonVisible(isHelpButtonVisible());
-    view.setResetButtonVisible(isResetButtonVisible());
-    view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
-    view.updateGuideText(R.string.login_input_pin);
-    view.updateTitleText(R.string.login_input_pin_title);
-    view.restart();
-  }
-
-  @Override
-  public void onPinResult(String result) {
-    view.setDisabled();
-    listener.onPinResult(result);
+  /**
+   * 재설정 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected boolean isResetButtonVisible() {
+    return true;
   }
 
-  @Override
-  public void onClickPinReset() {
-    listener.onClickPinReset();
+  /**
+   * 5회 입력 후 표시 문구 설정
+   *
+   * @return
+   */
+  protected int getFailGuideStringId() {
+    return R.string.pin_miss_match_error;
   }
 
-  @Override
-  public void onClickClose() {
-    listener.onClickClose();
+  /**
+   * Guide 문구 설정
+   *
+   * @return
+   */
+  protected int getGuideStringId() {
+    return R.string.login_input_pin;
   }
 
-  @Override
-  public void retry() {
-    // 일치 하지 않으면 5회 재시도 후
-    if (++matchCount < 5) {
-      view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
-      view.updateGuideText(String.format(ResourceUtil.getString(R.string.pin_miss_match_error_repeat), matchCount));
-      view.restart();
-    }
-    else {
-          /*
-           5회 이상 불일치 시 ‘간편암호가 5회이상 일치하지 않아, 입력값이 초기화됩니다.’ 밸리데이션 문구 1초간 노출
-          - 입력값 초기화된 상태로 STEP1로 변경
-           */
-      view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
-      view.updateGuideText(R.string.pin_miss_match_error);
-
-      view.setDisabled();
-      disposable.add(
-        Completable.timer(1000, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
-          .subscribe(() -> {
-
-            pin = null;
-            listener.onPinFail();
-
-          }, Throwable::printStackTrace)
-      );
-    }
-
+  /**
+   * Title 문구 설정
+   *
+   * @return
+   */
+  protected int getTitleStringId() {
+    return R.string.login_input_pin_title;
   }
 
-  @Override
-  public void onClickHelp() {
-    listener.onPinHelp();
+  /**
+   * 가이드 텍스트 기본 컬러
+   *
+   * @return
+   */
+  protected int getGuideTextColorId() {
+    return R.color.C999999;
   }
 
-  @Override
-  public void dispose() {
-    if (null != disposable) {
-      disposable.dispose();
-      disposable = null;
-    }
-  }
 }

+ 59 - 12
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/pin/CustomPinInputPresenter.java

@@ -4,7 +4,6 @@
 package kr.co.zumo.app.lifeplus.view.custom.pin;
 
 import kr.co.zumo.app.R;
-import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 
 /**
  * CustomPinInputPresenter
@@ -16,7 +15,7 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
  * @history 민효동   [2018-11-01]   [최초 작성]
  * @since 2018-11-01
  */
-public class CustomPinInputPresenter extends CustomPinConfirmPresenter {
+public class CustomPinInputPresenter extends CustomPinPresenter {
 
   private boolean isResetButtonVisible;
 
@@ -25,19 +24,67 @@ public class CustomPinInputPresenter extends CustomPinConfirmPresenter {
     this.isResetButtonVisible = isResetButtonVisible;
   }
 
-  @Override
-  public void onPinStart() {
-    view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
-    view.updateTitleText(R.string.confirm_pin_title_text);
-    view.updateGuideText(R.string.confirm_pin_guide_text);
-    view.setHelpButtonVisible(false);
-    view.setCloseButtonVisible(isCloseButtonVisible());
-    view.setResetButtonVisible(isResetButtonVisible());
-    view.restart();
+  /**
+   * 닫기 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected boolean isCloseButtonVisible() {
+    return true;
   }
 
-  @Override
+  /**
+   * 문의 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected boolean isHelpButtonVisible() {
+    return false;
+  }
+
+  /**
+   * 재설정 버튼 보이기 설정
+   *
+   * @return
+   */
   protected boolean isResetButtonVisible() {
     return isResetButtonVisible;
   }
+
+  /**
+   * 5회 입력 후 표시 문구 설정
+   *
+   * @return
+   */
+  protected int getFailGuideStringId() {
+    return R.string.pin_miss_match_guide;
+  }
+
+  /**
+   * Guide 문구 설정
+   *
+   * @return
+   */
+  protected int getGuideStringId() {
+    return R.string.confirm_pin_guide_text;
+  }
+
+  /**
+   * Title 문구 설정
+   *
+   * @return
+   */
+  protected int getTitleStringId() {
+    return R.string.confirm_pin_title_text;
+  }
+
+  /**
+   * 가이드 텍스트 기본 컬러
+   *
+   * @return
+   */
+  protected int getGuideTextColorId() {
+    return R.color.C999999;
+  }
+
 }

+ 162 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/pin/CustomPinPresenter.java

@@ -0,0 +1,162 @@
+/*
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
+ */
+package kr.co.zumo.app.lifeplus.view.custom.pin;
+
+import java.util.concurrent.TimeUnit;
+
+import io.reactivex.Completable;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
+
+/**
+ * CustomPinConfirmPresenter
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2018-10-04]   [최초 작성]
+ * @since 2018-10-04
+ */
+public abstract class CustomPinPresenter implements IPinContract.Presenter {
+
+  protected IPinContract.View view;
+  protected IPinContract.Listener listener;
+
+  protected String pin;
+  protected int matchCount;
+  protected CompositeDisposable disposable = new CompositeDisposable();
+
+  public CustomPinPresenter(IPinContract.View view, IPinContract.Listener listener) {
+    this.view = view;
+    this.listener = listener;
+  }
+
+  /**
+   * 닫기 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected abstract boolean isCloseButtonVisible();
+
+  /**
+   * 문의 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected abstract boolean isHelpButtonVisible();
+
+  /**
+   * 재설정 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected abstract boolean isResetButtonVisible();
+
+  /**
+   * 5회 입력 후 표시 문구 설정
+   *
+   * @return
+   */
+  protected abstract int getFailGuideStringId();
+
+
+  /**
+   * Guide 문구 설정
+   *
+   * @return
+   */
+  protected abstract int getGuideStringId();
+
+  /**
+   * Title 문구 설정
+   *
+   * @return
+   */
+  protected abstract int getTitleStringId();
+
+  /**
+   * 가이드 텍스트 기본 컬러
+   *
+   * @return
+   */
+  protected abstract int getGuideTextColorId();
+
+  @Override
+  public final void start() {
+    this.view.setPresenter(this);
+  }
+
+  @Override
+  public final void onPinStart() {
+    view.setCloseButtonVisible(isCloseButtonVisible());
+    view.setHelpButtonVisible(isHelpButtonVisible());
+    view.setResetButtonVisible(isResetButtonVisible());
+    view.updateGuideTextColor(ResourceUtil.getColor(getGuideTextColorId()));
+    view.updateGuideText(getGuideStringId());
+    view.updateTitleText(getTitleStringId());
+    view.restart();
+  }
+
+  @Override
+  public final void onPinResult(String result) {
+    view.setDisabled();
+    listener.onPinResult(result);
+  }
+
+  @Override
+  public final void onClickPinReset() {
+    listener.onClickPinReset();
+  }
+
+  @Override
+  public final void onClickClose() {
+    listener.onClickClose();
+  }
+
+  @Override
+  public final void retry() {
+    // 일치 하지 않으면 5회 재시도 후
+    if (++matchCount < 5) {
+      view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
+      view.updateGuideText(String.format(ResourceUtil.getString(R.string.pin_miss_match_error_repeat), matchCount));
+      view.restart();
+    }
+    else {
+          /*
+           5회 이상 불일치 시 ‘간편암호가 5회이상 일치하지 않아, 입력값이 초기화됩니다.’ 밸리데이션 문구 1초간 노출
+          - 입력값 초기화된 상태로 STEP1로 변경
+           */
+      view.updateGuideTextColor(ResourceUtil.getColor(R.color.CF12815));
+      view.updateGuideText(getFailGuideStringId());
+
+      view.setDisabled();
+      disposable.add(
+        Completable.timer(1000, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
+          .subscribe(() -> {
+
+            pin = null;
+            listener.onPinFail();
+
+          }, Throwable::printStackTrace)
+      );
+    }
+
+  }
+
+  @Override
+  public final void onClickHelp() {
+    listener.onPinHelp();
+  }
+
+  @Override
+  public final void dispose() {
+    if (null != disposable) {
+      disposable.dispose();
+      disposable = null;
+    }
+  }
+}

+ 55 - 18
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/pin/CustomPinUnlockPresenter.java

@@ -4,7 +4,6 @@
 package kr.co.zumo.app.lifeplus.view.custom.pin;
 
 import kr.co.zumo.app.R;
-import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 
 /**
  * CustomPinConfirmPresenter
@@ -16,36 +15,74 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
  * @history 민효동   [2018-10-04]   [최초 작성]
  * @since 2018-10-04
  */
-public class CustomPinUnlockPresenter extends CustomPinConfirmPresenter {
+public class CustomPinUnlockPresenter extends CustomPinPresenter {
 
   public CustomPinUnlockPresenter(IPinContract.View view, IPinContract.Listener listener) {
     super(view, listener);
   }
 
-  @Override
-  protected boolean isResetButtonVisible() {
-    return true;
-  }
-
-  @Override
+  /**
+   * 닫기 버튼 보이기 설정
+   *
+   * @return
+   */
   protected boolean isCloseButtonVisible() {
     return false;
   }
 
-  @Override
+  /**
+   * 문의 버튼 보이기 설정
+   *
+   * @return
+   */
   protected boolean isHelpButtonVisible() {
     return true;
   }
 
-  @Override
-  public void onPinStart() {
-    view.setCloseButtonVisible(isCloseButtonVisible());
-    view.setHelpButtonVisible(isHelpButtonVisible());
-    view.setResetButtonVisible(isResetButtonVisible());
-    view.updateGuideTextColor(ResourceUtil.getColor(R.color.C999999));
-    view.updateGuideText(R.string.login_input_pin);
-    view.updateTitleText(R.string.pin_unlock);
-    view.restart();
+  /**
+   * 재설정 버튼 보이기 설정
+   *
+   * @return
+   */
+  protected boolean isResetButtonVisible() {
+    return true;
+  }
+
+  /**
+   * 5회 입력 후 표시 문구 설정
+   *
+   * @return
+   */
+  protected int getFailGuideStringId() {
+    return R.string.pin_miss_match_guide;
   }
 
+  /**
+   * Guide 문구 설정
+   *
+   * @return
+   */
+  protected int getGuideStringId() {
+    return R.string.login_input_pin;
+  }
+
+  /**
+   * Title 문구 설정
+   *
+   * @return
+   */
+  protected int getTitleStringId() {
+    return R.string.pin_unlock;
+  }
+
+  /**
+   * 가이드 텍스트 기본 컬러
+   *
+   * @return
+   */
+  protected int getGuideTextColorId() {
+    return R.color.C999999;
+  }
+
+
 }

+ 16 - 17
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/pin/CustomPinView.java

@@ -129,27 +129,27 @@ public class CustomPinView extends ConstraintLayout implements IPinContract.View
    ***********************************/
 
   private ArrayList<Button> createButtonListFromView(View view) {
-    ArrayList<Button> list = new ArrayList<Button>();
-    list.add((Button) view.findViewById(R.id.button_0));
-    list.add((Button) view.findViewById(R.id.button_1));
-    list.add((Button) view.findViewById(R.id.button_2));
-    list.add((Button) view.findViewById(R.id.button_3));
-    list.add((Button) view.findViewById(R.id.button_4));
-    list.add((Button) view.findViewById(R.id.button_5));
-    list.add((Button) view.findViewById(R.id.button_6));
-    list.add((Button) view.findViewById(R.id.button_7));
-    list.add((Button) view.findViewById(R.id.button_8));
-    list.add((Button) view.findViewById(R.id.button_9));
+    ArrayList<Button> list = new ArrayList<>();
+    list.add(view.findViewById(R.id.button_0));
+    list.add(view.findViewById(R.id.button_1));
+    list.add(view.findViewById(R.id.button_2));
+    list.add(view.findViewById(R.id.button_3));
+    list.add(view.findViewById(R.id.button_4));
+    list.add(view.findViewById(R.id.button_5));
+    list.add(view.findViewById(R.id.button_6));
+    list.add(view.findViewById(R.id.button_7));
+    list.add(view.findViewById(R.id.button_8));
+    list.add(view.findViewById(R.id.button_9));
 
     return list;
   }
 
   private ArrayList<ImageView> createImageListFromView(View view) {
-    ArrayList<ImageView> list = new ArrayList<ImageView>();
-    list.add((ImageView) view.findViewById(R.id.image_pin_code1));
-    list.add((ImageView) view.findViewById(R.id.image_pin_code2));
-    list.add((ImageView) view.findViewById(R.id.image_pin_code3));
-    list.add((ImageView) view.findViewById(R.id.image_pin_code4));
+    ArrayList<ImageView> list = new ArrayList<>();
+    list.add(view.findViewById(R.id.image_pin_code1));
+    list.add(view.findViewById(R.id.image_pin_code2));
+    list.add(view.findViewById(R.id.image_pin_code3));
+    list.add(view.findViewById(R.id.image_pin_code4));
     return list;
   }
 
@@ -283,7 +283,6 @@ public class CustomPinView extends ConstraintLayout implements IPinContract.View
   }
 
   private void setEnabledInternal(boolean enabled) {
-    textReset.setEnabled(enabled);
     buttonDelete.setEnabled(enabled);
     buttonShuffle.setEnabled(enabled);
     for (Button button : buttonList) {

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/pin/MainPinUnlockPresenter.java

@@ -76,13 +76,13 @@ public class MainPinUnlockPresenter extends Presenter<MainPinUnlockModel, IMainP
         verifyPin(event.getString());
         break;
       case Event.FAIL:
-        onBackPressed();
+        // 그냥 있음
         break;
       case Event.RESET:
         go(ScreenID.PIN_RESET_AUTH);
         break;
       case Event.EXIT:
-        onBackPressed();
+        // 숨김 처림 됨
         break;
       case Event.HELP:
         // 이메일 문의

+ 6 - 3
app/src/main/res/layout/pin_view.xml

@@ -27,6 +27,7 @@
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toStartOf="@+id/image_close"
       app:layout_constraintTop_toTopOf="parent"/>
+
     <ImageView
       android:id="@+id/image_close"
       android:layout_width="40dp"
@@ -53,17 +54,16 @@
     android:orientation="vertical">
 
 
-
     <TextView
       android:id="@+id/text_title"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:gravity="center_horizontal"
       android:lineSpacingExtra="7sp"
-      android:text="@string/sign_up_register_pin_title"
       android:textAlignment="center"
       android:textColor="#000000"
       android:textSize="17sp"
+      tools:text="@string/sign_up_register_pin_title"
       />
 
     <Space
@@ -75,10 +75,12 @@
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:lineSpacingExtra="5sp"
-      android:text="@string/sign_up_register_pin"
+      android:paddingStart="25dp"
+      android:paddingEnd="25dp"
       android:textAlignment="center"
       android:textColor="@color/C999999"
       android:textSize="14sp"
+      tools:text="@string/sign_up_register_pin"
       />
   </LinearLayout>
 
@@ -191,6 +193,7 @@
         android:layout_height="wrap_content"
         android:layout_weight="1"
         />
+
       <Button
         android:id="@+id/button_0"
         style="@style/PinButton"

+ 2 - 1
app/src/main/res/values/strings.xml

@@ -160,7 +160,8 @@
   <string name="pin_code_reset_message">사용하실 간편암호 4자리를 입력해주세요.</string>
   <string name="pin_code_again_message">확인을 위해 한번 더 입력해주세요.</string>
   <string name="pin_miss_match_error_repeat">간편암호가 일치하지 않습니다. 다시 입력해주세요.(%d/5)</string>
-  <string name="pin_miss_match_init">간편암호가 5회이상 일치하지 않아, 입력값이 초기화됩니다.</string>
+  <string name="pin_miss_match_init">간편암호가 5회이상 일치하지 않아,\n입력값이 초기화됩니다.</string>
+  <string name="pin_miss_match_guide">간편암호가 5회이상 일치하지 않아,\n간편암호 재설정 후 이용가능합니다.</string>
 
   <string name="sign_up_shuffle">재배열</string>