mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-18 18:25:03 +01:00
Fix UI bug & avatar loading
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
83662d4ad9
commit
f84ae23f1c
@ -247,7 +247,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
if (!userEntity.getCurrent()) {
|
||||
userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||
userEntity.getToken(), userEntity.getBaseUrl(), null,
|
||||
null, true)
|
||||
null, true, null)
|
||||
.subscribe(new Observer<UserEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@ -1169,7 +1169,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
.PeerConnectionEventType.SENSOR_FAR) && videoOn;
|
||||
if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_CAMERA) && inCall &&
|
||||
enableVideo != videoOn) {
|
||||
toggleMedia(enableVideo, true);
|
||||
runOnUiThread(() -> toggleMedia(enableVideo, true));
|
||||
}
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.NICK_CHANGE)) {
|
||||
|
@ -187,7 +187,8 @@ public class AccountVerificationController extends BaseController {
|
||||
|
||||
if (!TextUtils.isEmpty(displayName)) {
|
||||
dbQueryDisposable = userUtils.createOrUpdateUser(username, token,
|
||||
baseUrl, displayName, null, true)
|
||||
baseUrl, displayName, null, true,
|
||||
userProfileOverall.getOcs().getData().getUserId())
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(userEntity -> {
|
||||
|
@ -270,17 +270,7 @@ public class SettingsController extends BaseController {
|
||||
displayNameTextView.setText(userEntity.getDisplayName());
|
||||
}
|
||||
|
||||
GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
userEntity.getUsername()), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiHelper.getUserAgent())
|
||||
.build());
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.load(glideUrl)
|
||||
.centerInside()
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||
.into(avatarImageView);
|
||||
loadAvatarImage();
|
||||
|
||||
profileQueryDisposable = ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(),
|
||||
userEntity.getToken()),
|
||||
@ -300,15 +290,23 @@ public class SettingsController extends BaseController {
|
||||
.getDisplayNameAlt();
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
|
||||
|
||||
boolean needsToUpdateUserId = !TextUtils.isEmpty(userProfileOverall.getOcs().getData().getUserId()) &&
|
||||
!userProfileOverall.getOcs().getData().getUserId().equals(userEntity.getUserId());
|
||||
if ((!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) ||
|
||||
needsToUpdateUserId) {
|
||||
|
||||
dbQueryDisposable = userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||
userEntity.getToken(),
|
||||
userEntity.getBaseUrl(), displayName, null, true)
|
||||
userEntity.getBaseUrl(), displayName, null, true,
|
||||
userProfileOverall.getOcs().getData().getUserId())
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(userEntityResult -> {
|
||||
displayNameTextView.setText(userEntityResult.getDisplayName());
|
||||
if (needsToUpdateUserId) {
|
||||
loadAvatarImage();
|
||||
}
|
||||
},
|
||||
throwable -> {
|
||||
dispose(dbQueryDisposable);
|
||||
@ -412,6 +410,27 @@ public class SettingsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAvatarImage() {
|
||||
String avatarId;
|
||||
if (!TextUtils.isEmpty(userEntity.getUserId())) {
|
||||
avatarId = userEntity.getUserId();
|
||||
} else {
|
||||
avatarId = userEntity.getUsername();
|
||||
}
|
||||
|
||||
GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
avatarId), new LazyHeaders.Builder()
|
||||
.setHeader("Accept", "image/*")
|
||||
.setHeader("User-Agent", ApiHelper.getUserAgent())
|
||||
.build());
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.load(glideUrl)
|
||||
.centerInside()
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||
.into(avatarImageView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
appPreferences.unregisterProxyTypeListener(proxyTypeChangeListener);
|
||||
|
@ -100,7 +100,7 @@ public class SwitchAccountController extends BaseController {
|
||||
UserEntity userEntity = ((AdvancedUserItem) userItems.get(position)).getEntity();
|
||||
userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||
userEntity.getToken(), userEntity.getBaseUrl(), null,
|
||||
null, true)
|
||||
null, true, null)
|
||||
.subscribe(new Observer<UserEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@ -164,7 +164,15 @@ public class SwitchAccountController extends BaseController {
|
||||
if (!userEntity.getCurrent()) {
|
||||
participant = new Participant();
|
||||
participant.setName(userEntity.getDisplayName());
|
||||
participant.setUserId(userEntity.getUsername());
|
||||
|
||||
String userId;
|
||||
|
||||
if (userEntity.getUserId() != null) {
|
||||
userId = userEntity.getUserId();
|
||||
} else {
|
||||
userId = userEntity.getUsername();
|
||||
}
|
||||
participant.setUserId(userId);
|
||||
userItems.add(new AdvancedUserItem(participant, userEntity, null));
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,8 @@ public class WebViewLoginController extends BaseController {
|
||||
// We use the URL user entered because one provided by the server is NOT reliable
|
||||
ErrorMessageHolder.ErrorMessageType finalErrorMessageType = errorMessageType;
|
||||
userQueryDisposable = userUtils.createOrUpdateUser(loginData.getUsername(), loginData.getToken(),
|
||||
loginData.getServerUrl(), null, null, true).
|
||||
loginData.getServerUrl(), null, null, true,
|
||||
null).
|
||||
subscribe(userEntity -> {
|
||||
cookieManager.getCookieStore().removeAll();
|
||||
if (!isPasswordUpdate && finalErrorMessageType == null) {
|
||||
|
@ -50,7 +50,7 @@ public class DatabaseModule {
|
||||
final SqlCipherDatabaseSource source = new SqlCipherDatabaseSource(context, Models.DEFAULT,
|
||||
context.getResources().getString(R.string.nc_app_name).toLowerCase()
|
||||
.replace(" ", "_").trim() + ".sqlite",
|
||||
context.getString(R.string.nc_talk_database_encryption_key), 1);
|
||||
context.getString(R.string.nc_talk_database_encryption_key), 2);
|
||||
final Configuration configuration = source.getConfiguration();
|
||||
return ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ public interface User extends Parcelable, Persistable, Serializable {
|
||||
@Generated
|
||||
long getId();
|
||||
|
||||
String getUserId();
|
||||
|
||||
String getUsername();
|
||||
|
||||
String getBaseUrl();
|
||||
|
@ -304,7 +304,8 @@ public class PushUtils {
|
||||
userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||
userEntity.getToken(), userEntity.getBaseUrl(),
|
||||
userEntity.getDisplayName(),
|
||||
LoganSquare.serialize(pushConfigurationState), null)
|
||||
LoganSquare.serialize(pushConfigurationState), null,
|
||||
null)
|
||||
.subscribe(new Consumer<UserEntity>() {
|
||||
@Override
|
||||
public void accept(UserEntity userEntity) throws Exception {
|
||||
|
@ -151,7 +151,8 @@ public class UserUtils {
|
||||
public Observable<UserEntity> createOrUpdateUser(String username, String token, String serverUrl,
|
||||
@Nullable String displayName,
|
||||
@Nullable String pushConfigurationState,
|
||||
@Nullable Boolean currentUser) {
|
||||
@Nullable Boolean currentUser,
|
||||
@Nullable String userId) {
|
||||
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.USERNAME.eq(username).
|
||||
and(UserEntity.BASE_URL.eq(serverUrl.toLowerCase()))).limit(1).get();
|
||||
|
||||
@ -171,9 +172,17 @@ public class UserUtils {
|
||||
user.setPushConfigurationState(pushConfigurationState);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(userId)) {
|
||||
user.setUserId(userId);
|
||||
}
|
||||
|
||||
user.setCurrent(true);
|
||||
|
||||
} else {
|
||||
if (userId != null && (user.getUserId() == null || !user.getUserId().equals(userId))) {
|
||||
user.setUserId(userId);
|
||||
}
|
||||
|
||||
if (!token.equals(user.getToken())) {
|
||||
user.setToken(token);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user