Browse Source

[공통][Common] 회원 가입 체크 박스 API 대응

Hasemi 7 years ago
parent
commit
1b04117b87

+ 27 - 7
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/auth/MobileAuthView.java

@@ -6,6 +6,7 @@ package kr.co.zumo.app.lifeplus.view.custom.auth;
 import android.content.Context;
 import android.support.annotation.StringRes;
 import android.support.constraint.ConstraintLayout;
+import android.graphics.drawable.StateListDrawable;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.util.AttributeSet;
@@ -147,6 +148,12 @@ public class MobileAuthView extends ConstraintLayout implements IMobileAuthContr
     viewFirstNumberBar = findViewById(R.id.spinner_first_phone_number_bar);
     viewAgreeBar = findViewById(R.id.checkbox_all_agree_bar);
 
+
+    StateListDrawable stateListDrawable = new StateListDrawable();
+    stateListDrawable.addState(new int[]{android.R.attr.state_checked}, context.getResources().getDrawable(R.drawable.ic_checkbox_on));
+    stateListDrawable.addState(new int[]{-android.R.attr.state_checked}, context.getResources().getDrawable(R.drawable.ic_checkbox_off));
+    ((CheckBox) checkBoxAllAgree).setButtonDrawable(stateListDrawable);
+
     checkBoxAllDriver = new CheckBoxAllDriver(checkBoxAllAgree);
 
     // 전체 약관 동의
@@ -165,6 +172,12 @@ public class MobileAuthView extends ConstraintLayout implements IMobileAuthContr
       int index = i;
 
       checkBox = findViewById(ResourceUtil.getId("checkbox_agree" + (i + 1)));
+
+      StateListDrawable stateListDrawable2 = new StateListDrawable();
+      stateListDrawable.addState(new int[]{android.R.attr.state_checked}, context.getResources().getDrawable(R.drawable.ic_checkbox_on));
+      stateListDrawable.addState(new int[]{-android.R.attr.state_checked}, context.getResources().getDrawable(R.drawable.ic_checkbox_off));
+      ((CheckBox) checkBox).setButtonDrawable(stateListDrawable);
+
       checkBoxAllDriver.addChildBox(checkBox);
       checkBox.setOnCheckedChangeListener((compoundButton, b) -> {
         checkBoxAllDriver.check();
@@ -251,15 +264,19 @@ public class MobileAuthView extends ConstraintLayout implements IMobileAuthContr
     });
 
     // gender
+    ((RadioButton) radioSelectMale).setButtonDrawable(new StateListDrawable());
+    ((RadioButton) radioSelectFemale).setButtonDrawable(new StateListDrawable());
     radioSelectMale.setOnCheckedChangeListener((compoundButton, b) -> presenter.setOnGenderCheckedChanged(b));
 
     // nationality
+    ((RadioButton) radioSelectLocal).setButtonDrawable(new StateListDrawable());
+    ((RadioButton) radioSelectForeign).setButtonDrawable(new StateListDrawable());
     radioSelectLocal.setOnCheckedChangeListener((compoundButton, b) -> presenter.onNationalCheckedChanged(b));
 
     // 폰 국번
     spinnerFirstPhoneNumber.setSpinnerEventsListener(new CustomSpinner.OnSpinnerEventsListener() {
 
-      public void setGenderMargin(boolean isMale){
+      public void setGenderMargin(boolean isMale) {
 
       }
 
@@ -452,11 +469,12 @@ public class MobileAuthView extends ConstraintLayout implements IMobileAuthContr
 
   @Override
   public void setGenderMargin(boolean isMale) {
-    RadioGroup.LayoutParams params  = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-    if(isMale){
-        params.setMarginStart(ResourceUtil.dpToPx(-23));
-        radioSelectFemale.setLayoutParams(params);
-    }else{
+    RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+    if (isMale) {
+      params.setMarginStart(ResourceUtil.dpToPx(-23));
+      radioSelectFemale.setLayoutParams(params);
+    }
+    else {
       params.setMarginStart(-10);
       radioSelectFemale.setLayoutParams(params);
     }
@@ -468,11 +486,13 @@ public class MobileAuthView extends ConstraintLayout implements IMobileAuthContr
     if (isLocal) {
       params.setMarginStart(ResourceUtil.dpToPx(-25));
       radioSelectForeign.setLayoutParams(params);
-    }else {
+    }
+    else {
       params.setMarginStart(-10);
       radioSelectForeign.setLayoutParams(params);
     }
   }
+
   /**
    * 모든 UI disabled
    */

+ 9 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/signup/SignUpAgreeFragment.java

@@ -1,5 +1,6 @@
 package kr.co.zumo.app.lifeplus.view.screen.signup;
 
+import android.graphics.drawable.StateListDrawable;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -53,6 +54,7 @@ public class SignUpAgreeFragment extends FragmentBase<SignUpAgreePresenter> impl
     View parent = getView();
     checkBoxAll = parent.findViewById(R.id.agree_check_all);
     checkBoxAllDriver = new CheckBoxAllDriver(checkBoxAll);
+    ((CheckBox) checkBoxAll).setButtonDrawable(new StateListDrawable());
 
     checkBoxAll.setText(R.string.all_agree);
     checkBoxAll.setOnClickListener(v -> {
@@ -124,6 +126,8 @@ public class SignUpAgreeFragment extends FragmentBase<SignUpAgreePresenter> impl
       @Override
       public AgreeHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
         View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_sign_up_agree_list, parent, false);
+        CheckBox checkBox = view.findViewById(R.id.agree_check);
+        checkBox.setButtonDrawable(new StateListDrawable());
         return new AgreeHolder(view);
       }
 
@@ -164,6 +168,11 @@ public class SignUpAgreeFragment extends FragmentBase<SignUpAgreePresenter> impl
       checkBox = itemView.findViewById(R.id.agree_check);
       checkBoxAllDriver.addChildBox(checkBox);
 
+      StateListDrawable stateListDrawable = new StateListDrawable();
+      stateListDrawable.addState(new int[]{android.R.attr.state_checked}, itemView.getContext().getResources().getDrawable(R.drawable.ic_checkbox_on));
+      stateListDrawable.addState(new int[]{-android.R.attr.state_checked}, itemView.getContext().getResources().getDrawable(R.drawable.ic_checkbox_off));
+      ((CheckBox) checkBox).setButtonDrawable(stateListDrawable);
+
       String title = bean.getTitle();
       title = title.replace(ResourceUtil.getString(R.string.agree_required), "");
       title = title.replace(ResourceUtil.getString(R.string.agree_option), "");

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

@@ -94,7 +94,6 @@
   <style name="CommonCheckBox" parent="@style/Widget.AppCompat.CompoundButton.CheckBox">
     <item name="android:background">@null</item>
     <item name="android:paddingLeft">8dp</item>
-    <item name="android:button">@drawable/custom_check_box</item>
     <item name="android:textColor">@color/C000000</item>
     <item name="android:textSize">14sp</item>
     <item name="android:saveEnabled">false</item>