|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.community.pocket.ui.main.ui.info; |
|
|
|
package com.community.pocket.ui.main.ui.info; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
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.login.LoginActivity; |
|
|
|
import com.community.pocket.ui.main.ui.share.Response; |
|
|
|
import com.community.pocket.ui.main.ui.share.Response; |
|
|
|
import com.community.pocket.util.AppDatabase; |
|
|
|
import com.community.pocket.util.AppDatabase; |
|
|
|
|
|
|
|
import com.community.pocket.util.Param; |
|
|
|
import com.community.pocket.util.PropertiesUtil; |
|
|
|
import com.community.pocket.util.PropertiesUtil; |
|
|
|
import com.github.mikephil.charting.charts.LineChart; |
|
|
|
import com.github.mikephil.charting.charts.LineChart; |
|
|
|
import com.github.mikephil.charting.data.Entry; |
|
|
|
import com.github.mikephil.charting.data.Entry; |
|
|
@ -91,9 +93,6 @@ public class InfoFragment extends BaseFragment { |
|
|
|
//确认新密码
|
|
|
|
//确认新密码
|
|
|
|
private EditText confirmNewPwd; |
|
|
|
private EditText confirmNewPwd; |
|
|
|
|
|
|
|
|
|
|
|
//修改密码按钮
|
|
|
|
|
|
|
|
private Button modifyPwdBtn; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//打开修改密码弹窗
|
|
|
|
//打开修改密码弹窗
|
|
|
|
@ViewInject(R.id.open_modify_password) |
|
|
|
@ViewInject(R.id.open_modify_password) |
|
|
|
private Button openModify; |
|
|
|
private Button openModify; |
|
|
@ -127,7 +126,11 @@ public class InfoFragment extends BaseFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (infoFormState.getNewPwdError() != null) { |
|
|
|
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) { |
|
|
|
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()); |
|
|
|
infoResponse.toast(getContext()); |
|
|
|
|
|
|
|
|
|
|
|
if (infoResponse.getResult() == Response.Result.OK) { |
|
|
|
if (infoResponse.getResult() == Response.Result.OK) { |
|
|
|
handler.sendEmptyMessage(0); |
|
|
|
|
|
|
|
logout(logout); |
|
|
|
logout(logout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -227,34 +234,31 @@ public class InfoFragment extends BaseFragment { |
|
|
|
newPwd.addTextChangedListener(textWatcher); |
|
|
|
newPwd.addTextChangedListener(textWatcher); |
|
|
|
confirmNewPwd.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())); |
|
|
|
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()) { |
|
|
|
handler = new Handler(Looper.getMainLooper()) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void handleMessage(@NonNull Message msg) { |
|
|
|
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.show(); |
|
|
|
|
|
|
|
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|