From 2a634408bcdf5c9970e75ea67091d1f50950d366 Mon Sep 17 00:00:00 2001 From: EGOR-IND <56648862+EGOR-IND@users.noreply.github.com> Date: Tue, 23 Mar 2021 02:51:23 +0530 Subject: [PATCH] added extra layer to edit is_member status --- .../FormCustomerDetailsFragment.java | 57 +++++++++++++++++++ .../res/drawable/ic_cross_cricle_red_24dp.xml | 9 +++ .../layout/fragment_form_customer_details.xml | 23 +++++++- 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/ic_cross_cricle_red_24dp.xml diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/FormCustomerDetailsFragment.java b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/FormCustomerDetailsFragment.java index 6e779fc5..910328b4 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/FormCustomerDetailsFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/createcustomer/FormCustomerDetailsFragment.java @@ -3,9 +3,11 @@ import android.app.Activity; import android.app.DatePickerDialog; import android.content.Context; +import android.os.Build; import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; + import com.google.android.material.textfield.TextInputLayout; import android.text.Editable; import android.text.TextUtils; @@ -16,6 +18,8 @@ import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; import com.stepstone.stepper.Step; import com.stepstone.stepper.VerificationError; @@ -33,6 +37,7 @@ import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnCheckedChanged; import butterknife.OnClick; /** @@ -76,6 +81,12 @@ public class FormCustomerDetailsFragment extends FineractBaseFragment implements @BindView(R.id.cb_is_member) CheckBox cbIsmember; + @BindView(R.id.tv_member_status) + TextView tvMemberStatus; + + @BindView(R.id.iv_edit_is_member) + ImageView ivEditIsMember; + View rootView; private Calendar calendar = Calendar.getInstance(); @@ -144,6 +155,9 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth } public void showPreviousCustomerDetails() { + tvMemberStatus.setVisibility(View.VISIBLE); + ivEditIsMember.setVisibility(View.VISIBLE); + cbIsmember.setVisibility(View.GONE); etAccount.setText(customer.getIdentifier()); etAccount.setEnabled(false); etFirstName.setText(customer.getGivenName()); @@ -152,6 +166,7 @@ public void showPreviousCustomerDetails() { } etLastName.setText(customer.getSurname()); cbIsmember.setChecked(customer.getMember()); + setIsMemberStatus(); dateOfBirth = customer.getDateOfBirth(); calendar.set(Calendar.YEAR, dateOfBirth.getYear()); @@ -298,4 +313,46 @@ public void onAttach(Context context) { + " must implement OnNavigationBarListener.CustomerDetails"); } } + + @OnClick(R.id.iv_edit_is_member) + void editIsMember() { + if (tvMemberStatus.getVisibility() == View.VISIBLE) { + tvMemberStatus.setVisibility(View.GONE); + cbIsmember.setVisibility(View.VISIBLE); + ivEditIsMember.setImageResource(R.drawable.ms_ic_check); + } else { + tvMemberStatus.setVisibility(View.VISIBLE); + cbIsmember.setVisibility(View.GONE); + ivEditIsMember.setImageResource(R.drawable.ic_edit_black_24dp); + } + } + + @OnCheckedChanged(R.id.cb_is_member) + void setIsMemberStatus() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (cbIsmember.isChecked()) { + tvMemberStatus. + setCompoundDrawablesRelativeWithIntrinsicBounds( + R.drawable.ic_check_circle_black_24dp, 0, 0, 0); + } else { + tvMemberStatus. + setCompoundDrawablesRelativeWithIntrinsicBounds( + R.drawable.ic_cross_cricle_red_24dp, 0, 0, 0); + } + } else { + if (cbIsmember.isChecked()) { + tvMemberStatus.setCompoundDrawables( + getResources().getDrawable(R.drawable.ic_check_circle_black_24dp), + getResources().getDrawable(0), + getResources().getDrawable(0), + getResources().getDrawable(0)); + } else { + tvMemberStatus.setCompoundDrawables( + getResources().getDrawable(R.drawable.ic_cross_cricle_red_24dp), + getResources().getDrawable(0), + getResources().getDrawable(0), + getResources().getDrawable(0)); + } + } + } } diff --git a/app/src/main/res/drawable/ic_cross_cricle_red_24dp.xml b/app/src/main/res/drawable/ic_cross_cricle_red_24dp.xml new file mode 100644 index 00000000..dce37b6e --- /dev/null +++ b/app/src/main/res/drawable/ic_cross_cricle_red_24dp.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_form_customer_details.xml b/app/src/main/res/layout/fragment_form_customer_details.xml index ef89fbad..50688b91 100644 --- a/app/src/main/res/layout/fragment_form_customer_details.xml +++ b/app/src/main/res/layout/fragment_form_customer_details.xml @@ -123,7 +123,8 @@ android:orientation="horizontal" android:paddingBottom="@dimen/layout_padding_16dp" android:paddingLeft="@dimen/layout_padding_16dp" - android:paddingRight="@dimen/layout_padding_16dp"> + android:paddingRight="@dimen/layout_padding_16dp" + android:gravity="center_vertical"> + android:paddingLeft="@dimen/layout_padding_16dp" + android:layout_weight="1"/> + + + +