GFA v1.0.0版本的 MD5 值为:3410aca4ee64dc2721a807228f78ee1f
以下内容为反编译后的 ChangePersonalInformationActivity.java 源代码,内容仅作参考
package im.wdywshgrwc.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.util.Property;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import butterknife.BindView;
import butterknife.OnClick;
import com.alibaba.fastjson.JSONObject;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.blankj.utilcode.util.TimeUtils;
import com.serenegiant.uvccamera.BuildConfig;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.Callback;
import im.wdywshgrwc.messenger.AndroidUtilities;
import im.wdywshgrwc.messenger.ApplicationLoader;
import im.wdywshgrwc.messenger.BuildVars;
import im.wdywshgrwc.messenger.ContactsController;
import im.wdywshgrwc.messenger.FileLoader;
import im.wdywshgrwc.messenger.FileLog;
import im.wdywshgrwc.messenger.ImageLoader;
import im.wdywshgrwc.messenger.ImageLocation;
import im.wdywshgrwc.messenger.LocaleController;
import im.wdywshgrwc.messenger.MessagesController;
import im.wdywshgrwc.messenger.MessagesStorage;
import im.wdywshgrwc.messenger.NotificationCenter;
import im.wdywshgrwc.messenger.R;
import im.wdywshgrwc.messenger.SendMessagesHelper;
import im.wdywshgrwc.messenger.UserConfig;
import im.wdywshgrwc.messenger.Utilities;
import im.wdywshgrwc.tgnet.ConnectionsManager;
import im.wdywshgrwc.tgnet.RequestDelegate;
import im.wdywshgrwc.tgnet.TLObject;
import im.wdywshgrwc.tgnet.TLRPC;
import im.wdywshgrwc.tgnet.TLRPCLogin;
import im.wdywshgrwc.ui.actionbar.ActionBar;
import im.wdywshgrwc.ui.actionbar.AlertDialog;
import im.wdywshgrwc.ui.actionbar.BaseFragment;
import im.wdywshgrwc.ui.actionbar.Theme;
import im.wdywshgrwc.ui.components.AvatarDrawable;
import im.wdywshgrwc.ui.components.BackupImageView;
import im.wdywshgrwc.ui.components.ImageUpdater;
import im.wdywshgrwc.ui.components.RadialProgressView;
import im.wdywshgrwc.ui.components.filter.MaxByteLengthFilter;
import im.wdywshgrwc.ui.components.toast.ToastUtils;
import im.wdywshgrwc.ui.dialogs.TimeWheelPickerDialog;
import im.wdywshgrwc.ui.hviews.MryEditText;
import im.wdywshgrwc.ui.hviews.MryRoundButton;
import im.wdywshgrwc.ui.hviews.MryRoundButtonDrawable;
import im.wdywshgrwc.ui.hviews.MryTextView;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import np.NPFog;
import okhttp3.Call;
import okhttp3.Response;
public class ChangePersonalInformationActivity extends BaseFragment implements ImageUpdater.ImageUpdaterDelegate, NotificationCenter.NotificationCenterDelegate {
private String accoutName;
private TLRPC.FileLocation avatar;
private AnimatorSet avatarAnimation;
private TLRPC.FileLocation avatarBig;
private AvatarDrawable avatarDrawable;
@BindView(R.id.btnDone)
MryRoundButton btnDone;
private String city;
@BindView(R.id.containerAvatar)
View containerAvatar;
@BindView(R.id.containerCamera)
View containerCamera;
@BindView(R.id.containerFemale)
View containerFemale;
@BindView(R.id.containerGenderSelect)
View containerGenderSelect;
@BindView(R.id.containerMale)
View containerMale;
private String country;
private int currentAccount;
private TextWatcher etNameWatcher;
@BindView(R.id.etNickName)
MryEditText etNickName;
private String inviteCode;
private String ip;
private boolean isRegisterUser;
@BindView(R.id.ivAvatar)
BackupImageView ivAvatar;
@BindView(R.id.ivAvatarProgress)
RadialProgressView ivAvatarProgress;
@BindView(R.id.ivCamera)
ImageView ivCamera;
@BindView(R.id.ivFemale)
ImageView ivFemale;
@BindView(R.id.ivMale)
ImageView ivMale;
@BindView(R.id.ivMore)
ImageView ivMore;
private TLRPC.InputFile mAvatarFile;
private int mBirth;
private boolean mCanGoBack;
private String mCurrentSelectPhotoPath;
private MryRoundButtonDrawable mDrawableFemale;
private MryRoundButtonDrawable mDrawableMale;
private int mGender;
private ImageUpdater mImageUpdater;
private boolean mIsLoginSuccess;
private boolean mShouldShowGenderDialog;
private TimeWheelPickerDialog.Builder mTimePickerBuilder;
private TLRPC.User mUser;
private boolean newAccount;
private String pwdHash;
@BindView(R.id.selectDataOfBirthParent)
View selectDataOfBirthParent;
@BindView(R.id.tvCamera)
MryTextView tvCamera;
@BindView(R.id.tvFemale)
MryTextView tvFemale;
@BindView(R.id.tvMale)
MryTextView tvMale;
@BindView(R.id.tvSelectDateOfBirth)
MryTextView tvSelectDateOfBirth;
@Override
public String getInitialSearchString() {
return ImageUpdater.ImageUpdaterDelegate.CC.$default$getInitialSearchString(this);
}
public ChangePersonalInformationActivity(int currentAccount) {
this.mShouldShowGenderDialog = true;
this.etNameWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
ChangePersonalInformationActivity.this.changeBtnEnbale();
}
};
this.currentAccount = currentAccount;
this.mCanGoBack = false;
this.isRegisterUser = false;
}
public ChangePersonalInformationActivity(boolean newAccount, int currentAccount, String accoutName, String pwdHash, String inviteCode) {
this.mShouldShowGenderDialog = true;
this.etNameWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
ChangePersonalInformationActivity.this.changeBtnEnbale();
}
};
this.newAccount = newAccount;
this.currentAccount = currentAccount;
this.accoutName = accoutName;
this.pwdHash = pwdHash;
this.inviteCode = inviteCode;
this.isRegisterUser = true;
this.mCanGoBack = true;
}
@Override
public boolean onFragmentCreate() {
NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.FileDidUpload);
NotificationCenter.getInstance(this.currentAccount).addObserver(this, NotificationCenter.FileDidFailUpload);
return super.onFragmentCreate();
}
@Override
public void onFragmentDestroy() {
TextWatcher textWatcher;
NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.FileDidUpload);
NotificationCenter.getInstance(this.currentAccount).removeObserver(this, NotificationCenter.FileDidFailUpload);
BackupImageView backupImageView = this.ivAvatar;
if (backupImageView != null) {
backupImageView.setImageDrawable(null);
}
this.mDrawableMale = null;
this.mDrawableFemale = null;
this.avatarDrawable = null;
ImageUpdater imageUpdater = this.mImageUpdater;
if (imageUpdater != null) {
imageUpdater.clear();
this.mImageUpdater = null;
}
this.mAvatarFile = null;
this.avatar = null;
this.avatarBig = null;
this.mTimePickerBuilder = null;
AnimatorSet animatorSet = this.avatarAnimation;
if (animatorSet != null && (animatorSet.isRunning() || this.avatarAnimation.isStarted())) {
this.avatarAnimation.cancel();
}
this.avatarAnimation = null;
MryEditText mryEditText = this.etNickName;
if (mryEditText != null && (textWatcher = this.etNameWatcher) != null) {
mryEditText.removeTextChangedListener(textWatcher);
this.etNameWatcher = null;
}
super.onFragmentDestroy();
}
@Override
public View createView(Context context) {
this.fragmentView = LayoutInflater.from(context).inflate(NPFog.d(2131744951), (ViewGroup) null);
this.fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
useButterKnife();
initActionBar();
initView();
return this.fragmentView;
}
private void initActionBar() {
this.actionBar.setCastShadows(false);
this.actionBar.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
if (this.mCanGoBack) {
this.actionBar.setBackButtonImage(R.mipmap.ic_back);
this.actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
super.onItemClick(id);
if (id == -1 && !ChangePersonalInformationActivity.this.back()) {
ChangePersonalInformationActivity.this.finishFragment();
}
}
});
}
}
private void initView() {
this.tvCamera.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText7));
MryRoundButtonDrawable containerAvatarBg = new MryRoundButtonDrawable();
containerAvatarBg.setIsRadiusAdjustBounds(false);
containerAvatarBg.setCornerRadius(AndroidUtilities.dp(10.0f));
containerAvatarBg.setStrokeData(AndroidUtilities.dp(2.0f), ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine)));
containerAvatarBg.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundGray)));
this.ivMore.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine), PorterDuff.Mode.SRC_IN));
this.btnDone.setPrimaryRadiusAdjustBoundsFillStyle();
this.containerAvatar.setBackground(containerAvatarBg);
this.ivAvatar.setRoundRadius(AndroidUtilities.dp(10.0f));
ImageUpdater imageUpdater = new ImageUpdater();
this.mImageUpdater = imageUpdater;
imageUpdater.setSearchAvailable(false);
this.mImageUpdater.setUploadAfterSelect(false);
this.mImageUpdater.parentFragment = this;
this.mImageUpdater.delegate = this;
this.ivAvatarProgress.setSize(AndroidUtilities.dp(30.0f));
this.ivAvatarProgress.setProgressColor(Theme.getColor(Theme.key_progressCircle));
this.etNickName.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(28.0f), Theme.getColor(Theme.key_windowBackgroundGray)));
this.etNickName.setFilters(new InputFilter[]{new MaxByteLengthFilter(), new InputFilter() {
@Override
public final CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
return ChangePersonalInformationActivity.lambda$initView$0(charSequence, i, i2, spanned, i3, i4);
}
}});
this.etNickName.addTextChangedListener(this.etNameWatcher);
this.selectDataOfBirthParent.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(28.0f), Theme.getColor(Theme.key_windowBackgroundGray)));
this.avatarDrawable = new AvatarDrawable();
loadCurrentState();
if (!this.isRegisterUser) {
TLRPC.User user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(UserConfig.getInstance(this.currentAccount).getClientUserId()));
this.mUser = user;
this.ivAvatar.setImage(ImageLocation.getForUser(user, false), "100_100", this.avatarDrawable, this.mUser);
if (!TextUtils.isEmpty(this.mUser.first_name)) {
this.etNickName.setText(this.mUser.first_name);
}
} else {
String str = this.mCurrentSelectPhotoPath;
if (str != null) {
this.ivAvatar.setImage(str, "100_100", this.avatarDrawable);
}
}
changeGender();
this.containerAvatar.setVisibility(8);
this.containerGenderSelect.setVisibility(8);
this.etNickName.setVisibility(0);
this.selectDataOfBirthParent.setVisibility(8);
}
public static CharSequence lambda$initView$0(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (dstart == 0 && source != null && source.toString().contains(" ")) {
return "";
}
return null;
}
@Override
public void onResume() {
super.onResume();
if (this.newAccount) {
ConnectionsManager.getInstance(this.currentAccount).setAppPaused(false, false);
}
AndroidUtilities.requestAdjustResize(getParentActivity(), this.classGuid);
if (BuildVars.IP_OFF) {
OkHttpUtils.get().url("https://echo.ifconfig.mobi/json").build().execute(new Callback<String>() {
@Override
public String parseNetworkResponse(Response response, int id) throws Exception {
Log.e(BuildConfig.BUILD_TYPE, "response===" + response);
return response.body().string();
}
@Override
public void onError(Call call, Exception e, int id) {
Log.e(BuildConfig.BUILD_TYPE, "e===" + e.getMessage());
}
@Override
public void onResponse(String response, int id) {
if (!TextUtils.isEmpty(response)) {
JSONObject object = (JSONObject) JSONObject.parse(response);
String ip = object.getString("ip");
String country = object.getString("country");
String city = object.getString("city");
Log.e(BuildConfig.BUILD_TYPE, "ip===" + ip);
Log.e(BuildConfig.BUILD_TYPE, "country===" + country);
Log.e(BuildConfig.BUILD_TYPE, "city===" + city);
ChangePersonalInformationActivity.this.ip = ip;
ChangePersonalInformationActivity.this.country = country;
ChangePersonalInformationActivity.this.city = city;
}
}
});
}
}
@Override
public void onPause() {
super.onPause();
AndroidUtilities.removeAdjustResize(getParentActivity(), this.classGuid);
if (this.newAccount) {
ConnectionsManager.getInstance(this.currentAccount).setAppPaused(true, false);
}
}
@OnClick({R.id.containerAvatar, R.id.containerMale, R.id.containerFemale, R.id.tvSelectDateOfBirth, R.id.btnDone})
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnDone:
check();
return;
case R.id.containerAvatar:
TLRPC.User user = this.mUser;
if (user != null) {
ImageUpdater imageUpdater = this.mImageUpdater;
if (user.photo != null && this.mUser.photo.photo_big != null && !(this.mUser.photo instanceof TLRPC.TL_userProfilePhotoEmpty)) {
r3 = true;
}
imageUpdater.openMenu(r3, new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$onClick$1$ChangePersonalInformationActivity();
}
});
return;
}
this.mImageUpdater.openMenu(this.avatar != null, new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.resetAvatar();
}
});
return;
case R.id.containerFemale:
this.mGender = 2;
changeGender();
if (this.mShouldShowGenderDialog) {
this.mShouldShowGenderDialog = false;
needShowAlert(LocaleController.getString(R.string.CannotBeModifiedAfterGenderDetermination), true, null);
return;
}
return;
case R.id.containerMale:
this.mGender = 1;
changeGender();
if (this.mShouldShowGenderDialog) {
this.mShouldShowGenderDialog = false;
needShowAlert(LocaleController.getString(R.string.CannotBeModifiedAfterGenderDetermination), true, null);
return;
}
return;
case R.id.tvSelectDateOfBirth:
showSelectBirthDialog();
return;
default:
return;
}
}
public void lambda$onClick$1$ChangePersonalInformationActivity() {
MessagesController.getInstance(this.currentAccount).deleteUserPhoto(null);
resetAvatar();
}
private void check() {
if (this.isRegisterUser) {
if (this.accoutName == null) {
ToastUtils.show(R.string.PleaseEnterAccountName);
finishFragment();
return;
} else if (this.pwdHash == null) {
ToastUtils.show(R.string.PaymentPasswordEnter);
finishFragment();
return;
}
}
if (TextUtils.isEmpty(((Object) this.etNickName.getText()) + "") || this.etNickName.getText().toString().trim().replaceAll(" ", "").length() == 0) {
ToastUtils.show(R.string.PleaseFillInNickName);
} else if (this.isRegisterUser) {
signUp(this.ip, this.country, this.city);
} else {
setUserInformation();
}
}
private void setUserInformation() {
TLRPCLogin.TL_account_setUserDetail req = new TLRPCLogin.TL_account_setUserDetail();
req.photo = this.mAvatarFile;
req.first_name = clearEndOfStrSpace(this.etNickName.getText().toString().trim());
req.sex = this.mGender;
req.birthday = this.mBirth;
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
showDialog(progressDialog);
ConnectionsManager connectionsManager = ConnectionsManager.getInstance(this.currentAccount);
final int reqId = ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangePersonalInformationActivity.this.lambda$setUserInformation$3$ChangePersonalInformationActivity(progressDialog, tLObject, tL_error);
}
});
connectionsManager.bindRequestToGuid(reqId, this.classGuid);
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ChangePersonalInformationActivity.this.lambda$setUserInformation$4$ChangePersonalInformationActivity(reqId, dialogInterface);
}
});
}
public void lambda$setUserInformation$3$ChangePersonalInformationActivity(final AlertDialog progressDialog, final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$null$2$ChangePersonalInformationActivity(error, response, progressDialog);
}
});
}
public void lambda$null$2$ChangePersonalInformationActivity(TLRPC.TL_error error, TLObject response, AlertDialog progressDialog) {
if (error == null && (response instanceof TLRPC.UserFull)) {
updateUserData((TLRPC.UserFull) response, progressDialog);
} else {
progressDialog.dismiss();
parseError(error);
}
}
public void lambda$setUserInformation$4$ChangePersonalInformationActivity(int reqId, DialogInterface dialog) {
getConnectionsManager().cancelRequest(reqId, false);
}
private void signUp(String ip, String country, String city) {
this.btnDone.setEnabled(false);
TLRPCLogin.TL_auth_SignUpV1 req = new TLRPCLogin.TL_auth_SignUpV1();
TLRPC.TL_dataJSON extend = new TLRPC.TL_dataJSON();
req.extend = extend;
TLRPC.TL_inputFile photo = new TLRPC.TL_inputFile();
photo.id = 0L;
photo.parts = 0;
photo.name = "";
photo.md5_checksum = "";
req.photo = photo;
try {
req.first_name = clearEndOfStrSpace(this.etNickName.getText().toString().trim());
} catch (Exception e) {
FileLog.e(getClass().getName(), "sn fn error: ", e);
}
req.sex = 0;
req.birthday = 0;
req.user_name = this.accoutName;
req.password_hash = this.pwdHash;
JSONObject extendJson = null;
if (!TextUtils.isEmpty(this.inviteCode)) {
extendJson = new JSONObject();
extendJson.put("ProxyCode", (Object) this.inviteCode);
}
String simpleName = ChangePersonalInformationActivity.class.getSimpleName();
StringBuilder sb = new StringBuilder();
sb.append("extj = ");
sb.append(extendJson != null ? extendJson.toJSONString() : "null");
FileLog.d(simpleName, sb.toString());
if (extendJson != null) {
extendJson.put("ip", (Object) ip);
extendJson.put("country", (Object) country);
extendJson.put("city", (Object) city);
} else {
extendJson = new JSONObject();
extendJson.put("ip", (Object) ip);
extendJson.put("country", (Object) country);
extendJson.put("city", (Object) city);
}
req.extend = new TLRPC.TL_dataJSON();
req.extend.data = extendJson.toJSONString();
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
showDialog(progressDialog);
Log.e(BuildConfig.BUILD_TYPE, "req==" + JSONObject.toJSONString(req));
ConnectionsManager connectionsManager = ConnectionsManager.getInstance(this.currentAccount);
final int reqId = ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangePersonalInformationActivity.this.lambda$signUp$6$ChangePersonalInformationActivity(progressDialog, tLObject, tL_error);
}
}, 10);
connectionsManager.bindRequestToGuid(reqId, this.classGuid);
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ChangePersonalInformationActivity.this.lambda$signUp$7$ChangePersonalInformationActivity(reqId, dialogInterface);
}
});
}
public void lambda$signUp$6$ChangePersonalInformationActivity(final AlertDialog progressDialog, final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$null$5$ChangePersonalInformationActivity(progressDialog, error, response);
}
});
}
public void lambda$null$5$ChangePersonalInformationActivity(AlertDialog progressDialog, TLRPC.TL_error error, TLObject response) {
progressDialog.dismiss();
if (error == null && (response instanceof TLRPC.TL_auth_authorization)) {
onAuthSuccess((TLRPC.TL_auth_authorization) response);
} else {
parseError(error);
this.btnDone.setEnabled(true);
}
}
public void lambda$signUp$7$ChangePersonalInformationActivity(int reqId, DialogInterface dialog) {
getConnectionsManager().cancelRequest(reqId, false);
this.btnDone.setEnabled(true);
}
private void changeGender() {
if (this.mDrawableMale == null) {
this.mDrawableMale = new MryRoundButtonDrawable();
}
if (this.mDrawableFemale == null) {
this.mDrawableFemale = new MryRoundButtonDrawable();
}
int i = this.mGender;
if (i == 1) {
this.mDrawableMale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteBlueButton)));
this.mDrawableMale.setIsRadiusAdjustBounds(true);
this.mDrawableMale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_actionBarTabUnactiveText)));
this.containerMale.setBackground(this.mDrawableMale);
this.ivMale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlueButton), PorterDuff.Mode.SRC_IN));
this.tvMale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
this.mDrawableFemale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine)));
this.mDrawableFemale.setIsRadiusAdjustBounds(true);
this.mDrawableFemale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhite)));
this.containerFemale.setBackground(this.mDrawableFemale);
this.ivFemale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6), PorterDuff.Mode.SRC_IN));
this.tvFemale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
} else if (i == 2) {
this.mDrawableMale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine)));
this.mDrawableMale.setIsRadiusAdjustBounds(true);
this.mDrawableMale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhite)));
this.containerMale.setBackground(this.mDrawableMale);
this.ivMale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6), PorterDuff.Mode.SRC_IN));
this.tvMale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
this.mDrawableFemale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteBlueButton)));
this.mDrawableFemale.setIsRadiusAdjustBounds(true);
this.mDrawableFemale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_actionBarTabUnactiveText)));
this.containerFemale.setBackground(this.mDrawableFemale);
this.ivFemale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlueButton), PorterDuff.Mode.SRC_IN));
this.tvFemale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
} else {
this.mDrawableMale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine)));
this.mDrawableMale.setIsRadiusAdjustBounds(true);
this.mDrawableMale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhite)));
this.containerMale.setBackground(this.mDrawableMale);
this.ivMale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6), PorterDuff.Mode.SRC_IN));
this.tvMale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
this.mDrawableFemale.setStrokeData(1, ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine)));
this.mDrawableFemale.setIsRadiusAdjustBounds(true);
this.mDrawableFemale.setBgData(ColorStateList.valueOf(Theme.getColor(Theme.key_windowBackgroundWhite)));
this.containerFemale.setBackground(this.mDrawableFemale);
this.ivFemale.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6), PorterDuff.Mode.SRC_IN));
this.tvFemale.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
}
changeBtnEnbale();
}
private void startUploadAvatarPhoto() {
if (this.avatarBig != null) {
MessagesController.getInstance(this.currentAccount).uploadAvatar(this.avatarBig);
showAvatarProgress(true, true);
}
}
@Override
public void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
if (photos != null) {
this.mCurrentSelectPhotoPath = photos.get(0).path;
}
}
@Override
public void didUploadPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$didUploadPhoto$10$ChangePersonalInformationActivity(file, smallSize, bigSize);
}
});
}
public void lambda$didUploadPhoto$10$ChangePersonalInformationActivity(TLRPC.InputFile file, TLRPC.PhotoSize smallSize, TLRPC.PhotoSize bigSize) {
if (file != null) {
TLRPC.TL_photos_uploadProfilePhoto req = new TLRPC.TL_photos_uploadProfilePhoto();
req.file = file;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangePersonalInformationActivity.this.lambda$null$9$ChangePersonalInformationActivity(tLObject, tL_error);
}
});
} else {
this.avatar = smallSize.location;
this.avatarBig = bigSize.location;
this.ivAvatar.setImage(ImageLocation.getForLocal(this.avatar), "87_87", this.avatarDrawable, (Object) null);
startUploadAvatarPhoto();
}
}
public void lambda$null$9$ChangePersonalInformationActivity(TLObject response, TLRPC.TL_error error) {
if (error == null) {
TLRPC.User user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(UserConfig.getInstance(this.currentAccount).getClientUserId()));
if (user == null) {
user = UserConfig.getInstance(this.currentAccount).getCurrentUser();
if (user != null) {
MessagesController.getInstance(this.currentAccount).putUser(user, false);
} else {
return;
}
} else {
UserConfig.getInstance(this.currentAccount).setCurrentUser(user);
}
TLRPC.TL_photos_photo photo = (TLRPC.TL_photos_photo) response;
ArrayList<TLRPC.PhotoSize> sizes = photo.photo.sizes;
TLRPC.PhotoSize small = FileLoader.getClosestPhotoSizeWithSize(sizes, 150);
TLRPC.PhotoSize big = FileLoader.getClosestPhotoSizeWithSize(sizes, 800);
user.photo = new TLRPC.TL_userProfilePhoto();
user.photo.photo_id = photo.photo.id;
if (small != null) {
user.photo.photo_small = small.location;
}
if (big != null) {
user.photo.photo_big = big.location;
} else if (small != null) {
user.photo.photo_small = small.location;
}
if (photo != null) {
if (small != null && this.avatar != null) {
File destFile = FileLoader.getPathToAttach(small, true);
File src = FileLoader.getPathToAttach(this.avatar, true);
src.renameTo(destFile);
String oldKey = this.avatar.volume_id + "_" + this.avatar.local_id + "@50_50";
String newKey = small.location.volume_id + "_" + small.location.local_id + "@50_50";
ImageLoader.getInstance().replaceImageInCache(oldKey, newKey, ImageLocation.getForUser(user, false), true);
}
if (big != null && this.avatarBig != null) {
File destFile2 = FileLoader.getPathToAttach(big, true);
File src2 = FileLoader.getPathToAttach(this.avatarBig, true);
src2.renameTo(destFile2);
}
}
MessagesStorage.getInstance(this.currentAccount).clearUserPhotos(user.id);
ArrayList<TLRPC.User> users = new ArrayList<>();
users.add(user);
MessagesStorage.getInstance(this.currentAccount).putUsersAndChats(users, null, false, true);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$null$8$ChangePersonalInformationActivity();
}
});
}
public void lambda$null$8$ChangePersonalInformationActivity() {
this.avatar = null;
this.avatarBig = null;
updateUserData(null, null);
showAvatarProgress(false, true);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(MessagesController.UPDATE_MASK_ALL));
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
UserConfig.getInstance(this.currentAccount).saveConfig(true);
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.FileDidUpload) {
if (args != null && args.length >= 2) {
this.mAvatarFile = (TLRPC.InputFile) args[1];
showAvatarProgress(false, true);
changeBtnEnbale();
if (!this.isRegisterUser) {
TLRPC.User user = this.mUser;
return;
}
return;
}
return;
}
if (id == NotificationCenter.FileDidFailUpload) {
showAvatarProgress(false, false);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString(R.string.AppName));
builder.setMessage(LocaleController.getString(R.string.TipsFailedToUploadAvatarTryAgain));
builder.setPositiveButton(LocaleController.getString(R.string.Retry), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ChangePersonalInformationActivity.this.lambda$didReceivedNotification$11$ChangePersonalInformationActivity(dialogInterface, i);
}
});
builder.setNegativeButton(LocaleController.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ChangePersonalInformationActivity.this.lambda$didReceivedNotification$12$ChangePersonalInformationActivity(dialogInterface, i);
}
});
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
ChangePersonalInformationActivity.this.lambda$didReceivedNotification$13$ChangePersonalInformationActivity(dialogInterface);
}
});
showDialog(builder.create());
}
}
public void lambda$didReceivedNotification$11$ChangePersonalInformationActivity(DialogInterface dialog, int which) {
startUploadAvatarPhoto();
}
public void lambda$didReceivedNotification$12$ChangePersonalInformationActivity(DialogInterface dialog, int which) {
resetAvatar();
}
public void lambda$didReceivedNotification$13$ChangePersonalInformationActivity(DialogInterface dialog) {
resetAvatar();
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
ImageUpdater imageUpdater = this.mImageUpdater;
if (imageUpdater != null) {
imageUpdater.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
if (grantResults != null && grantResults[0] == 0) {
if (requestCode == 19) {
this.mImageUpdater.openCamera();
} else if (requestCode == 4) {
this.mImageUpdater.openGallery();
}
}
}
public void resetAvatar() {
this.mAvatarFile = null;
this.avatar = null;
this.avatarBig = null;
showAvatarProgress(false, true);
this.ivAvatar.setImage((ImageLocation) null, (String) null, this.avatarDrawable, (Object) null);
this.containerCamera.setVisibility(0);
changeBtnEnbale();
}
private void showAvatarProgress(final boolean show, boolean animated) {
if (this.containerCamera == null) {
return;
}
AnimatorSet animatorSet = this.avatarAnimation;
if (animatorSet != null) {
animatorSet.cancel();
this.avatarAnimation = null;
}
if (animated) {
this.avatarAnimation = new AnimatorSet();
if (show) {
this.ivAvatarProgress.setVisibility(0);
this.avatarAnimation.playTogether(ObjectAnimator.ofFloat(this.containerCamera, (Property<View, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.ivAvatarProgress, (Property<RadialProgressView, Float>) View.ALPHA, 1.0f));
} else {
this.containerCamera.setVisibility(0);
this.avatarAnimation.playTogether(ObjectAnimator.ofFloat(this.containerCamera, (Property<View, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.ivAvatarProgress, (Property<RadialProgressView, Float>) View.ALPHA, 0.0f));
}
this.avatarAnimation.setDuration(180L);
this.avatarAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ChangePersonalInformationActivity.this.avatarAnimation == null || ChangePersonalInformationActivity.this.containerCamera == null) {
return;
}
if (show) {
ChangePersonalInformationActivity.this.containerCamera.setVisibility(4);
} else {
ChangePersonalInformationActivity.this.ivAvatarProgress.setVisibility(4);
}
ChangePersonalInformationActivity.this.avatarAnimation = null;
}
@Override
public void onAnimationCancel(Animator animation) {
ChangePersonalInformationActivity.this.avatarAnimation = null;
}
});
this.avatarAnimation.start();
return;
}
if (show) {
this.containerCamera.setAlpha(1.0f);
this.containerCamera.setVisibility(4);
this.ivAvatarProgress.setAlpha(1.0f);
this.ivAvatarProgress.setVisibility(0);
return;
}
this.containerCamera.setAlpha(1.0f);
this.containerCamera.setVisibility(0);
this.ivAvatarProgress.setAlpha(0.0f);
this.ivAvatarProgress.setVisibility(4);
}
private void onAuthSuccess(TLRPC.TL_auth_authorization res) {
this.mIsLoginSuccess = true;
ConnectionsManager.getInstance(this.currentAccount).setUserId(res.user.id);
UserConfig.getInstance(this.currentAccount).clearConfig();
MessagesController.getInstance(this.currentAccount).cleanup();
UserConfig.getInstance(this.currentAccount).syncContacts = false;
UserConfig.getInstance(this.currentAccount).setCurrentUser(res.user);
UserConfig.getInstance(this.currentAccount).saveConfig(true);
MessagesStorage.getInstance(this.currentAccount).cleanup(true);
ArrayList<TLRPC.User> users = new ArrayList<>();
users.add(res.user);
MessagesStorage.getInstance(this.currentAccount).putUsersAndChats(users, null, true, true);
MessagesController.getInstance(this.currentAccount).putUser(res.user, false);
ContactsController.getInstance(this.currentAccount).checkAppAccount();
MessagesController.getInstance(this.currentAccount).checkProxyInfo(true);
ConnectionsManager.getInstance(this.currentAccount).updateDcSettings();
clearCurrentState();
if (getParentActivity() instanceof LaunchActivity) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.appDidLogIn, new Object[0]);
if (!this.newAccount) {
presentFragment(new IndexActivity(), true);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
return;
} else {
this.newAccount = false;
((LaunchActivity) getParentActivity()).switchToAccount(this.currentAccount, true);
finishFragment();
return;
}
}
if (getParentActivity() instanceof ExternalActionActivity) {
((ExternalActionActivity) getParentActivity()).onFinishLogin();
}
}
private void updateUserData(TLRPC.UserFull userFull, AlertDialog progressDialog) {
TLRPC.User user;
TLRPC.User newUser;
if (userFull == null || (user = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(UserConfig.getInstance(this.currentAccount).getClientUserId()))) == null || (newUser = userFull.user) == null) {
return;
}
if (user != null) {
user.first_name = newUser.first_name;
user.last_name = newUser.last_name;
user.photo = newUser.photo;
if (user.photo != null) {
if (user.photo.photo_small != null && this.avatar != null) {
File destFile = FileLoader.getPathToAttach(user.photo.photo_small, true);
File src = FileLoader.getPathToAttach(this.avatar, true);
src.renameTo(destFile);
String oldKey = this.avatar.volume_id + "_" + this.avatar.local_id + "@50_50";
String newKey = user.photo.photo_small.volume_id + "_" + user.photo.photo_small.local_id + "@50_50";
ImageLoader.getInstance().replaceImageInCache(oldKey, newKey, ImageLocation.getForUser(user, false), true);
}
if (user.photo.photo_big != null && this.avatarBig != null) {
File destFile2 = FileLoader.getPathToAttach(user.photo.photo_big, true);
File src2 = FileLoader.getPathToAttach(this.avatarBig, true);
src2.renameTo(destFile2);
}
}
MessagesStorage.getInstance(this.currentAccount).clearUserPhotos(user.id);
ArrayList<TLRPC.User> users = new ArrayList<>();
users.add(user);
MessagesStorage.getInstance(this.currentAccount).putUsersAndChats(users, null, false, true);
}
if (user != null && (user.photo instanceof TLRPC.TL_userProfilePhoto)) {
saveImage(progressDialog);
return;
}
ToastUtils.show(R.string.SetupSuccess);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(MessagesController.UPDATE_MASK_ALL));
UserConfig.getInstance(this.currentAccount).saveConfig(true);
finishFragment();
}
private void saveImage(final AlertDialog progressDialog) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$saveImage$15$ChangePersonalInformationActivity(progressDialog);
}
});
}
public void lambda$saveImage$15$ChangePersonalInformationActivity(final AlertDialog progressDialog) {
while (this.ivAvatar.getImageReceiver().getBitmap() == null) {
try {
Thread.sleep(10L);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Bitmap bitmap = this.ivAvatar.getImageReceiver().getBitmap();
File file = new File(AndroidUtilities.getCacheDir().getPath() + File.separator + "user_avatar.jpg");
if (file.exists()) {
file.delete();
}
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangePersonalInformationActivity.this.lambda$null$14$ChangePersonalInformationActivity(progressDialog);
}
});
}
public void lambda$null$14$ChangePersonalInformationActivity(AlertDialog progressDialog) {
if (progressDialog != null) {
progressDialog.dismiss();
}
ToastUtils.show(R.string.SetupSuccess);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(MessagesController.UPDATE_MASK_ALL));
UserConfig.getInstance(this.currentAccount).saveConfig(true);
finishFragment();
}
private String clearEndOfStrSpace(String str) {
if (str != null && str.length() > 0 && str.charAt(str.length() - 1) == ' ') {
return clearEndOfStrSpace(str.substring(0, str.length() - 1));
}
return str;
}
private void parseError(TLRPC.TL_error error) {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
needShowAlert(LocaleController.getString(R.string.InvalidPhoneNumber), true, null);
return;
}
if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
needShowAlert(LocaleController.getString(R.string.InvalidCode), true, null);
finishFragment();
return;
}
if (error.text.contains("FIRSTNAME_INVALID")) {
needShowAlert(LocaleController.getString(R.string.InvalidName), true, null);
return;
}
if (error.text.contains("LASTNAME_INVALID")) {
needShowAlert(LocaleController.getString(R.string.InvalidNickname), true, null);
return;
}
if (error.text.contains("FIRSTNAME_LASTNAME_EMPTY")) {
needShowAlert(LocaleController.getString(R.string.EmptyNameTips), true, null);
return;
}
if (error.text.contains("PHOTO_CHECK_FEAILED")) {
needShowAlert(LocaleController.getString(R.string.FailedToSetAvatarVerification), true, null);
return;
}
if (error.text.contains("ALREDY_CHANGE")) {
needShowAlert(LocaleController.getString(R.string.InformationModified), true, null);
return;
}
if (error.text.contains("NAME_TOO_LONG")) {
needShowAlert(LocaleController.getString(R.string.NickNameIsTooLongAndPleaseTryAgainAfterModified), true, null);
return;
}
if (error.text.contains("PHONE_NUMBER_OCCUPIED")) {
needShowAlert(LocaleController.formatString("ChangePhoneNumberOccupied", R.string.ChangePhoneNumberOccupied, this.accoutName), true, null);
return;
}
if (error.text.contains("PROXYCODE_INVALID")) {
needShowAlert(LocaleController.getString("ProxyCodeInvalid", R.string.ProxyCodeInvalid), true, null);
return;
}
if (error.text.contains("IPORDE_LIMIT")) {
needShowAlert(LocaleController.getString("IpOrDeLimit", R.string.IpOrDeLimit), true, null);
return;
}
if (error.text.contains("SAME_IP_LIMIT")) {
needShowAlert(LocaleController.getString("SameIpOrDeLimit", R.string.SameIpOrDeLimit), true, null);
return;
}
if (error.text.equals("INTERNAL")) {
needShowAlert(LocaleController.getString("InternalError", R.string.InternalError), true, null);
} else if (error.text.contains("FLOOD_WAIT")) {
needShowAlert(LocaleController.getString(R.string.FloodWait), true, null);
} else {
needShowAlert(LocaleController.getString(R.string.OperationFailedPleaseTryAgain), true, null);
}
}
private void needShowAlert(String text, boolean canCancel, DialogInterface.OnClickListener onClickListener) {
if (text == null || getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString(R.string.AppName));
builder.setMessage(text);
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), onClickListener);
AlertDialog dialog = builder.create();
dialog.setCancelable(canCancel);
dialog.setCanceledOnTouchOutside(canCancel);
showDialog(dialog);
}
private void loadCurrentState() {
MryEditText mryEditText;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", 0);
String nickName = preferences.getString(getCurrentSpKey("user_name"), null);
if (nickName != null && (mryEditText = this.etNickName) != null) {
mryEditText.setText(nickName);
}
int i = preferences.getInt(getCurrentSpKey("user_birth"), 0);
this.mBirth = i;
MryTextView mryTextView = this.tvSelectDateOfBirth;
if (mryTextView != null && i != 0) {
mryTextView.setText(TimeUtils.millis2String(this.mBirth * 1000, "yyyy-MM-dd") + "");
}
this.mGender = preferences.getInt(getCurrentSpKey("user_gender"), 0);
long user_avatar_id = preferences.getLong(getCurrentSpKey("user_avatar_id"), -1L);
int user_avatar_parts = preferences.getInt(getCurrentSpKey("user_avatar_parts"), -1);
String user_avatar_name = preferences.getString(getCurrentSpKey("user_avatar_name"), null);
String user_avatar_md5_checksum = preferences.getString(getCurrentSpKey("user_avatar_md5_checksum"), null);
String string = preferences.getString(getCurrentSpKey("current_select_photo_path"), null);
this.mCurrentSelectPhotoPath = string;
if (user_avatar_id != -1 && user_avatar_parts != -1 && user_avatar_name != null && user_avatar_md5_checksum != null && string != null) {
if (this.mAvatarFile == null) {
this.mAvatarFile = new TLRPC.TL_inputFile();
}
this.mAvatarFile.id = user_avatar_id;
this.mAvatarFile.parts = user_avatar_parts;
this.mAvatarFile.name = user_avatar_name;
this.mAvatarFile.md5_checksum = user_avatar_md5_checksum;
}
}
private void saveCurrentState() {
if (this.mIsLoginSuccess || this.pwdHash == null) {
return;
}
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", 0);
SharedPreferences.Editor editor = preferences.edit();
if (this.etNickName != null) {
if (!TextUtils.isEmpty(((Object) this.etNickName.getText()) + "")) {
editor.putString(getCurrentSpKey("user_name"), this.etNickName.getText().toString().trim());
}
}
if (this.mBirth != 0) {
editor.putInt(getCurrentSpKey("user_birth"), this.mBirth);
}
if (this.mGender != 0) {
editor.putInt(getCurrentSpKey("user_gender"), this.mGender);
}
if (this.mAvatarFile != null && this.mCurrentSelectPhotoPath != null) {
editor.putLong(getCurrentSpKey("user_avatar_id"), this.mAvatarFile.id);
editor.putInt(getCurrentSpKey("user_avatar_parts"), this.mAvatarFile.parts);
editor.putString(getCurrentSpKey("user_avatar_name"), this.mAvatarFile.name);
editor.putString(getCurrentSpKey("user_avatar_md5_checksum"), this.mAvatarFile.md5_checksum);
editor.putString(getCurrentSpKey("current_select_photo_path"), this.mCurrentSelectPhotoPath);
}
editor.apply();
}
private void clearCurrentState() {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", 0);
SharedPreferences.Editor editor = preferences.edit();
editor.clear();
editor.apply();
}
private String getCurrentSpKey(String key) {
if (this.accoutName == null) {
return key;
}
return this.accoutName + key;
}
private void showSelectBirthDialog() {
if (this.mTimePickerBuilder == null) {
this.mTimePickerBuilder = TimeWheelPickerDialog.getDefaultBuilder(getParentActivity(), new OnTimeSelectListener() {
@Override
public final void onTimeSelect(Date date, View view) {
ChangePersonalInformationActivity.this.lambda$showSelectBirthDialog$16$ChangePersonalInformationActivity(date, view);
}
});
}
if (!TextUtils.isEmpty(((Object) this.tvSelectDateOfBirth.getText()) + "")) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(TimeUtils.string2Date(this.tvSelectDateOfBirth.getText().toString().trim(), LocaleController.getString(R.string.formatterStandardYearMonthDay)));
this.mTimePickerBuilder.setDate(calendar);
} else {
this.mTimePickerBuilder.setDate(Calendar.getInstance());
}
showDialog(this.mTimePickerBuilder.build());
}
public void lambda$showSelectBirthDialog$16$ChangePersonalInformationActivity(Date date, View v) {
String dateStr = TimeUtils.date2String(date, "yyyy-MM-dd");
this.tvSelectDateOfBirth.setText(dateStr);
long mills = TimeUtils.string2Millis(dateStr, "yyyy-MM-dd");
this.mBirth = (int) (mills / 1000);
dismissCurrentDialog();
changeBtnEnbale();
}
public void changeBtnEnbale() {
MryEditText mryEditText;
if (this.btnDone == null || (mryEditText = this.etNickName) == null) {
return;
}
boolean tag = true;
if (this.isRegisterUser) {
if (this.accoutName != null && this.pwdHash != null && (mryEditText == null || mryEditText.getText() == null || this.etNickName.length() == 0)) {
tag = false;
}
} else if (this.mUser != null && (mryEditText == null || mryEditText.getText() == null || this.etNickName.length() == 0)) {
tag = false;
}
this.btnDone.setEnabled(tag);
}
public boolean back() {
if (!this.mCanGoBack) {
return true;
}
if (this.mAvatarFile == null && this.mBirth == 0 && this.mGender == 0) {
if (TextUtils.isEmpty(((Object) this.etNickName.getText()) + "")) {
return false;
}
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("AreYouSureRegistration", R.string.AreYouSureRegistration));
builder.setNegativeButton(LocaleController.getString("Stop", R.string.Stop), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
ChangePersonalInformationActivity.this.lambda$back$17$ChangePersonalInformationActivity(dialogInterface, i);
}
});
builder.setPositiveButton(LocaleController.getString("Continue", R.string.Continue), null);
showDialog(builder.create());
return true;
}
public void lambda$back$17$ChangePersonalInformationActivity(DialogInterface dialogInterface, int i) {
saveCurrentState();
finishFragment();
}
@Override
public AnimatorSet onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) {
AnimatorSet set = new AnimatorSet();
final int parentHeight = getParentLayout().getHeight();
final int actionBarHeight = this.actionBar.getHeight();
if (isOpen) {
set.playTogether(ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.TRANSLATION_Y, parentHeight, 0.0f), ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.fragmentView, (Property<View, Float>) View.TRANSLATION_Y, parentHeight + actionBarHeight, 0.0f), ObjectAnimator.ofFloat(this.fragmentView, (Property<View, Float>) View.ALPHA, 0.0f, 1.0f));
} else {
set.playTogether(ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.TRANSLATION_Y, 0.0f, parentHeight), ObjectAnimator.ofFloat(this.actionBar, (Property<ActionBar, Float>) View.ALPHA, 1.0f, 0.0f), ObjectAnimator.ofFloat(this.fragmentView, (Property<View, Float>) View.TRANSLATION_Y, 0.0f, parentHeight + actionBarHeight), ObjectAnimator.ofFloat(this.fragmentView, (Property<View, Float>) View.ALPHA, 1.0f, 0.0f));
}
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
if (isOpen) {
ChangePersonalInformationActivity.this.actionBar.setTranslationY(parentHeight);
ChangePersonalInformationActivity.this.fragmentView.setTranslationY(parentHeight + actionBarHeight);
}
}
});
set.setInterpolator(new AccelerateDecelerateInterpolator());
set.setDuration(300L);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
Runnable runnable = callback;
if (runnable != null) {
runnable.run();
}
}
});
set.start();
return set;
}
@Override
public boolean onBackPressed() {
if (back()) {
return false;
}
return super.onBackPressed();
}
@Override
public void saveSelfArgs(Bundle args) {
ImageUpdater imageUpdater = this.mImageUpdater;
if (imageUpdater != null && imageUpdater.currentPicturePath != null) {
args.putString("path", this.mImageUpdater.currentPicturePath);
}
}
@Override
public void restoreSelfArgs(Bundle args) {
ImageUpdater imageUpdater = this.mImageUpdater;
if (imageUpdater != null) {
imageUpdater.currentPicturePath = args.getString("path");
}
}
@Override
public boolean canBeginSlide() {
return false;
}
}