mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Display error message toast when updating profile picture fails
This commit is contained in:
committed by
Torsten Grote
parent
cbb87aa00c
commit
d3cf3d680e
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.bramble.api.FeatureFlags;
|
||||
import org.briarproject.briar.R;
|
||||
@@ -21,6 +22,7 @@ import androidx.appcompat.app.ActionBar;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_AVATAR_IMAGE;
|
||||
|
||||
public class SettingsActivity extends BriarActivity {
|
||||
@@ -59,6 +61,14 @@ public class SettingsActivity extends BriarActivity {
|
||||
us.getLocalAuthor().getId(), us.getAuthorInfo());
|
||||
});
|
||||
|
||||
settingsViewModel.getSetAvatarFailed().observe(this, failed -> {
|
||||
if (failed) {
|
||||
Toast.makeText(this,
|
||||
R.string.change_profile_picture_failed_message,
|
||||
LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
View avatarGroup = findViewById(R.id.avatarGroup);
|
||||
avatarGroup.setOnClickListener(e -> selectAvatarImage());
|
||||
} else {
|
||||
|
||||
@@ -51,6 +51,9 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
private final MutableLiveData<OwnIdentityInfo> ownIdentityInfo =
|
||||
new MutableLiveData<>();
|
||||
|
||||
private final MutableLiveData<Boolean> setAvatarFailed =
|
||||
new MutableLiveData<>();
|
||||
|
||||
@Inject
|
||||
SettingsViewModel(Application application,
|
||||
IdentityManager identityManager,
|
||||
@@ -74,6 +77,10 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
return ownIdentityInfo;
|
||||
}
|
||||
|
||||
public MutableLiveData<Boolean> getSetAvatarFailed() {
|
||||
return setAvatarFailed;
|
||||
}
|
||||
|
||||
private void loadOwnIdentityInfo() {
|
||||
dbExecutor.execute(() -> {
|
||||
try {
|
||||
@@ -93,6 +100,7 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
trySetAvatar(uri);
|
||||
} catch (IOException e) {
|
||||
LogUtils.logException(LOG, WARNING, e);
|
||||
setAvatarFailed.postValue(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -117,6 +125,7 @@ class SettingsViewModel extends AndroidViewModel {
|
||||
loadOwnIdentityInfo();
|
||||
} catch (IOException | DbException e) {
|
||||
LogUtils.logException(LOG, WARNING, e);
|
||||
setAvatarFailed.postValue(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -457,6 +457,7 @@
|
||||
<string name="change_profile_picture">Tap to change your profile picture</string>
|
||||
<string name="dialog_confirm_profile_picture_title">Change profile picture</string>
|
||||
<string name="dialog_confirm_profile_picture_remark">Only your contacts can see your profile image</string>
|
||||
<string name="change_profile_picture_failed_message">We\'re sorry, but something went wrong while updating your profile picture</string>
|
||||
|
||||
<!-- Settings Display -->
|
||||
<string name="pref_language_title">Language & region</string>
|
||||
|
||||
Reference in New Issue
Block a user