From c9db460d935016de1175405b2e3cb87a470aea99 Mon Sep 17 00:00:00 2001 From: panqihua <1029559041@qq.com> Date: Sun, 19 Apr 2020 19:24:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=AF=86=E7=A0=81=E4=B8=8D=E8=83=BD=E4=B8=8E=E5=8E=9F?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=9B=B8=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pocket/ui/main/ui/info/InfoFragment.java | 56 ++++++++++--------- .../pocket/ui/main/ui/info/InfoViewModel.java | 2 + .../VisitorAppointmentFragment.java | 7 +++ .../com/community/pocket/util/HttpUtil.java | 11 ---- .../java/com/community/pocket/util/Param.java | 3 +- .../main/layout/info/layout/info_fragment.xml | 17 +++--- .../layout/info/layout/modify_password.xml | 24 -------- .../layout/visitor_appointment_fragment.xml | 1 + app/src/main/res/values-en-rUS/strings.xml | 1 + app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 11 files changed, 54 insertions(+), 70 deletions(-) diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java index 9c28da1..716c10d 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java @@ -1,5 +1,6 @@ package com.community.pocket.ui.main.ui.info; +import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; @@ -29,6 +30,7 @@ import com.community.pocket.ui.listener.MyTextChange; import com.community.pocket.ui.login.LoginActivity; import com.community.pocket.ui.main.ui.share.Response; import com.community.pocket.util.AppDatabase; +import com.community.pocket.util.Param; import com.community.pocket.util.PropertiesUtil; import com.github.mikephil.charting.charts.LineChart; import com.github.mikephil.charting.data.Entry; @@ -91,9 +93,6 @@ public class InfoFragment extends BaseFragment { //确认新密码 private EditText confirmNewPwd; - //修改密码按钮 - private Button modifyPwdBtn; - //打开修改密码弹窗 @ViewInject(R.id.open_modify_password) private Button openModify; @@ -127,7 +126,11 @@ public class InfoFragment extends BaseFragment { } if (infoFormState.getNewPwdError() != null) { - newPwd.setError(getString(infoFormState.getNewPwdError(), PropertiesUtil.getIntValue("password.length"))); + if (infoFormState.getNewPwdError() == R.string.invalid_password) { + newPwd.setError(getString(infoFormState.getNewPwdError(), PropertiesUtil.getIntValue("password.length"))); + } else { + newPwd.setError(getString(infoFormState.getNewPwdError())); + } } if (infoFormState.getConfirmNewPwdError() != null) { @@ -138,7 +141,12 @@ public class InfoFragment extends BaseFragment { } } - modifyPwdBtn.setEnabled(infoFormState.isDataValid()); + Message message = new Message(); + Bundle bundle = new Bundle(); + bundle.putBoolean(Param.enable.name(), infoFormState.isDataValid()); + message.setData(bundle); + handler.sendMessage(message); + } }); @@ -153,7 +161,6 @@ public class InfoFragment extends BaseFragment { infoResponse.toast(getContext()); if (infoResponse.getResult() == Response.Result.OK) { - handler.sendEmptyMessage(0); logout(logout); } @@ -227,34 +234,31 @@ public class InfoFragment extends BaseFragment { newPwd.addTextChangedListener(textWatcher); confirmNewPwd.addTextChangedListener(textWatcher); - //修改密码按钮 - modifyPwdBtn = view.findViewById(R.id.modify_password); - modifyPwdBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - viewModel.modifyPwd(oldPwd.getText().toString(), newPwd.getText().toString()); - } - }); - AlertDialog.Builder alert = new AlertDialog.Builder(Objects.requireNonNull(getContext())); - final AlertDialog alertDialog = alert.setTitle(R.string.modify_password).setView(view).create(); - + final AlertDialog alertDialog = alert.setTitle(R.string.modify_password).setView(view) + .setNegativeButton(R.string.modify_password, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + viewModel.modifyPwd(oldPwd.getText().toString(), newPwd.getText().toString()); + dialog.dismiss(); + } + }) + .setNeutralButton(R.string.action_close, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }) + .create(); handler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(@NonNull Message msg) { - alertDialog.dismiss(); + alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(msg.getData().getBoolean(Param.enable.name())); } }; - Button close = view.findViewById(R.id.close); - close.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - handler.sendEmptyMessage(0); - } - }); - alertDialog.show(); + alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(false); } /** diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java index 4c027c8..62d67ab 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java @@ -37,6 +37,8 @@ public class InfoViewModel extends BaseViewModel { modifyFormState.setValue(new InfoFormState(R.string.invalid_password, null, null)); } else if (!ValidUtil.passwordvalid(newpwd)) { modifyFormState.setValue(new InfoFormState(null, R.string.invalid_password, null)); + } else if (oldpwd.equals(newpwd)) { + modifyFormState.setValue(new InfoFormState(null, R.string.password_diff, null)); } else if (!ValidUtil.passwordvalid(confirmNewPwd)) { modifyFormState.setValue(new InfoFormState(null, null, R.string.invalid_password)); } else if (!newpwd.equals(confirmNewPwd)) { diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java index 959e89a..14281ef 100644 --- a/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java +++ b/app/src/main/java/com/community/pocket/ui/main/ui/visitor/appointment/VisitorAppointmentFragment.java @@ -11,6 +11,7 @@ import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.EditText; +import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.Spinner; import android.widget.TextView; @@ -70,6 +71,10 @@ public class VisitorAppointmentFragment extends BaseFragment { @ViewInject(R.id.submit) private Button submit; + //预约时间layout + @ViewInject(R.id.choose_time_layout) + private LinearLayout chooseTimeLayout; + private VisitorViewModel appointmentViewModel; //动态更新搜索框数据源 @@ -160,6 +165,7 @@ public class VisitorAppointmentFragment extends BaseFragment { @Override public void afterTextChanged(Editable s) { + chooseTimeLayout.setVisibility(View.GONE); if (timeAdpter != null) { timeAdpter.clear(); } @@ -169,6 +175,7 @@ public class VisitorAppointmentFragment extends BaseFragment { if (visitorAdpter != null && visitorAdpter.containsKey(s.toString())) { appointmentViewModel.appointmentDataChanged(appointment.getText(), chooseDate.getText(), today, notes.getText()); initTime(s); + chooseTimeLayout.setVisibility(View.VISIBLE); return; } appointment.setTag(R.string.visitor_tag, s.toString()); diff --git a/app/src/main/java/com/community/pocket/util/HttpUtil.java b/app/src/main/java/com/community/pocket/util/HttpUtil.java index d85345c..1d4c1ea 100644 --- a/app/src/main/java/com/community/pocket/util/HttpUtil.java +++ b/app/src/main/java/com/community/pocket/util/HttpUtil.java @@ -152,17 +152,6 @@ public class HttpUtil { } }); -// int[] buttonId=new int[]{R.id.button,R.id.button2}; -// View.OnClickListener onClickListener=new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// System.exit(0); -// } -// }; -// for(int id:buttonId){ -// view.findViewById(id).setOnClickListener(onClickListener); -// } - builder.setView(constraintLayout); } else { diff --git a/app/src/main/java/com/community/pocket/util/Param.java b/app/src/main/java/com/community/pocket/util/Param.java index 1ea7718..e75fa26 100644 --- a/app/src/main/java/com/community/pocket/util/Param.java +++ b/app/src/main/java/com/community/pocket/util/Param.java @@ -7,5 +7,6 @@ public enum Param { username, email, forumId, - isOutPeople + isOutPeople, + enable } diff --git a/app/src/main/res/layout/main/layout/info/layout/info_fragment.xml b/app/src/main/res/layout/main/layout/info/layout/info_fragment.xml index 724f0ca..c5fab31 100644 --- a/app/src/main/res/layout/main/layout/info/layout/info_fragment.xml +++ b/app/src/main/res/layout/main/layout/info/layout/info_fragment.xml @@ -37,6 +37,7 @@ android:layout_height="wrap_content" android:layout_marginStart="32dp" android:layout_marginTop="@dimen/size_50" + android:textSize="24sp" app:layout_constraintStart_toEndOf="@id/headimg" app:layout_constraintTop_toTopOf="parent" /> @@ -46,6 +47,7 @@ android:layout_height="wrap_content" android:layout_marginStart="32dp" android:layout_marginTop="@dimen/size_50" + android:textSize="24sp" app:layout_constraintStart_toEndOf="@id/headimg" app:layout_constraintTop_toBottomOf="@id/nickname" /> @@ -73,17 +75,9 @@ android:gravity="center" /> -