mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-06 03:49:58 +02:00
save avatar and name onPause() in InstantOnboardingActivity (#3067)
This commit is contained in:
parent
fd40de4914
commit
c99e6fc27f
1 changed files with 22 additions and 2 deletions
|
@ -114,7 +114,7 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
|||
avatarChanged = false;
|
||||
registerForEvents();
|
||||
initializeResources();
|
||||
initializeProfileAvatar();
|
||||
initializeProfile();
|
||||
handleIntent();
|
||||
updateProvider();
|
||||
}
|
||||
|
@ -199,6 +199,24 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
final String displayName = name.getText().toString();
|
||||
DcHelper.set(this, DcHelper.CONFIG_DISPLAY_NAME, TextUtils.isEmpty(displayName)? null : displayName);
|
||||
|
||||
if (avatarChanged) {
|
||||
try {
|
||||
AvatarHelper.setSelfAvatar(InstantOnboardingActivity.this, avatarBmp);
|
||||
Prefs.setProfileAvatarId(InstantOnboardingActivity.this, new SecureRandom().nextInt());
|
||||
avatarChanged = false;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to save avatar", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -315,7 +333,7 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeProfileAvatar() {
|
||||
private void initializeProfile() {
|
||||
File avatarFile = AvatarHelper.getSelfAvatarFile(this);
|
||||
if (avatarFile.exists() && avatarFile.length() > 0) {
|
||||
imageLoaded = true;
|
||||
|
@ -327,6 +345,8 @@ public class InstantOnboardingActivity extends BaseActionBarActivity implements
|
|||
avatar.setOnClickListener(view ->
|
||||
new AvatarSelector(this, LoaderManager.getInstance(this), new AvatarSelectedListener(), imageLoaded).show(this, avatar)
|
||||
);
|
||||
|
||||
name.setText(DcHelper.get(this, DcHelper.CONFIG_DISPLAY_NAME));
|
||||
}
|
||||
|
||||
private void registerForEvents() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue