mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +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.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.FeatureFlags;
|
import org.briarproject.bramble.api.FeatureFlags;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -21,6 +22,7 @@ import androidx.appcompat.app.ActionBar;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import de.hdodenhof.circleimageview.CircleImageView;
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
|
import static android.widget.Toast.LENGTH_LONG;
|
||||||
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_AVATAR_IMAGE;
|
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_AVATAR_IMAGE;
|
||||||
|
|
||||||
public class SettingsActivity extends BriarActivity {
|
public class SettingsActivity extends BriarActivity {
|
||||||
@@ -59,6 +61,14 @@ public class SettingsActivity extends BriarActivity {
|
|||||||
us.getLocalAuthor().getId(), us.getAuthorInfo());
|
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);
|
View avatarGroup = findViewById(R.id.avatarGroup);
|
||||||
avatarGroup.setOnClickListener(e -> selectAvatarImage());
|
avatarGroup.setOnClickListener(e -> selectAvatarImage());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ class SettingsViewModel extends AndroidViewModel {
|
|||||||
private final MutableLiveData<OwnIdentityInfo> ownIdentityInfo =
|
private final MutableLiveData<OwnIdentityInfo> ownIdentityInfo =
|
||||||
new MutableLiveData<>();
|
new MutableLiveData<>();
|
||||||
|
|
||||||
|
private final MutableLiveData<Boolean> setAvatarFailed =
|
||||||
|
new MutableLiveData<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SettingsViewModel(Application application,
|
SettingsViewModel(Application application,
|
||||||
IdentityManager identityManager,
|
IdentityManager identityManager,
|
||||||
@@ -74,6 +77,10 @@ class SettingsViewModel extends AndroidViewModel {
|
|||||||
return ownIdentityInfo;
|
return ownIdentityInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<Boolean> getSetAvatarFailed() {
|
||||||
|
return setAvatarFailed;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadOwnIdentityInfo() {
|
private void loadOwnIdentityInfo() {
|
||||||
dbExecutor.execute(() -> {
|
dbExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -93,6 +100,7 @@ class SettingsViewModel extends AndroidViewModel {
|
|||||||
trySetAvatar(uri);
|
trySetAvatar(uri);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogUtils.logException(LOG, WARNING, e);
|
LogUtils.logException(LOG, WARNING, e);
|
||||||
|
setAvatarFailed.postValue(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -117,6 +125,7 @@ class SettingsViewModel extends AndroidViewModel {
|
|||||||
loadOwnIdentityInfo();
|
loadOwnIdentityInfo();
|
||||||
} catch (IOException | DbException e) {
|
} catch (IOException | DbException e) {
|
||||||
LogUtils.logException(LOG, WARNING, 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="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_title">Change profile picture</string>
|
||||||
<string name="dialog_confirm_profile_picture_remark">Only your contacts can see your profile image</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 -->
|
<!-- Settings Display -->
|
||||||
<string name="pref_language_title">Language & region</string>
|
<string name="pref_language_title">Language & region</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user