Some stuff

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-11-19 17:38:31 +01:00
parent a49cab9b84
commit 53580378d1
5 changed files with 34 additions and 32 deletions

View File

@ -614,7 +614,7 @@ public class CallActivity extends AppCompatActivity {
//we have remote video stream. add to the renderer.
if (stream.videoTracks.size() == 1 && stream.audioTracks.size() == 1) {
final VideoTrack videoTrack = stream.videoTracks.get(0);
AudioTrack audioTrack = stream.audioTracks.get(0);
AudioTrack audioTrack = stream.audioTracks.get(0);
runOnUiThread(new Runnable() {
@Override
public void run() {

View File

@ -126,10 +126,6 @@ public class AccountVerificationController extends BaseController {
.getDisplayName())) {
displayName = userProfileOverall.getOcs().getData()
.getDisplayName();
} else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
.getDisplayNameAlt())) {
displayName = userProfileOverall.getOcs().getData()
.getDisplayNameAlt();
}
if (!TextUtils.isEmpty(displayName)) {

View File

@ -159,6 +159,8 @@ public class SettingsController extends BaseController {
super.onViewBound(view);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
userEntity = userUtils.getCurrentUser();
appPreferences.registerProxyTypeListener(proxyTypeChangeListener = new ProxyTypeChangeListener());
appPreferences.registerProxyCredentialsListener(proxyCredentialsChangeListener = new
ProxyCredentialsChangeListener());
@ -209,21 +211,6 @@ public class SettingsController extends BaseController {
versionInfo.setSummary("v" + BuildConfig.VERSION_NAME);
userEntity = userUtils.getCurrentUser();
if (userEntity != null) {
baseUrlTextView.setText(userEntity.getBaseUrl());
reauthorizeButton.setOnClickListener(view14 -> {
reauthorizeButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(
new WebViewLoginController(userEntity.getBaseUrl(), true))
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
reauthorizeButton.setEnabled(true);
});
}
addAccountButton.setOnClickListener(view15 -> {
addAccountButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(new
@ -247,6 +234,9 @@ public class SettingsController extends BaseController {
protected void onAttach(@NonNull View view) {
super.onAttach(view);
dispose(null);
userEntity = userUtils.getCurrentUser();
if ("No proxy".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
hideProxySettings();
} else {
@ -259,8 +249,19 @@ public class SettingsController extends BaseController {
hideProxyCredentials();
}
userEntity = userUtils.getCurrentUser();
if (userEntity != null) {
baseUrlTextView.setText(userEntity.getBaseUrl());
reauthorizeButton.setOnClickListener(view14 -> {
reauthorizeButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(
new WebViewLoginController(userEntity.getBaseUrl(), true))
.pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
reauthorizeButton.setEnabled(true);
});
// Awful hack
if (userEntity.getDisplayName() != null) {
avatarImageView.setTextAndColorSeed(String.valueOf(userEntity.getDisplayName().
@ -300,6 +301,7 @@ public class SettingsController extends BaseController {
}
if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
dbQueryDisposable = userUtils.createOrUpdateUser(userEntity.getUsername(),
userEntity.getToken(),
userEntity.getBaseUrl(), displayName, null, true)
@ -320,8 +322,8 @@ public class SettingsController extends BaseController {
removeAccountButton.setOnClickListener(view1 -> {
boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());
if (otherUserExists && getView() != null) {
onViewBound(getView());
onAttach(getView());
onViewBound(getView());
} else if (!otherUserExists) {
getParentController().getRouter().setRoot(RouterTransaction.with(
new ServerSelectionController())
@ -423,11 +425,15 @@ public class SettingsController extends BaseController {
if (profileQueryDisposable != null && !profileQueryDisposable.isDisposed()) {
profileQueryDisposable.dispose();
profileQueryDisposable = null;
} else if (profileQueryDisposable != null) {
profileQueryDisposable = null;
}
if (dbQueryDisposable != null && !dbQueryDisposable.isDisposed()) {
dbQueryDisposable.dispose();
dbQueryDisposable = null;
} else if (dbQueryDisposable != null) {
dbQueryDisposable = null;
}
}
}

View File

@ -116,11 +116,10 @@ public class SwitchAccountController extends BaseController {
UserEntity userEntity;
User user;
UserEntity currentUserEntity = userUtils.getCurrentUser();
for (Object userEntityObject : userUtils.getUsers()) {
userEntity = (UserEntity) userEntityObject;
if (!userEntity.equals(currentUserEntity)) {
if (!userEntity.getCurrent()) {
user = new User();
user.setName(userEntity.getDisplayName());
user.setUserId(userEntity.getUsername());

View File

@ -46,12 +46,13 @@ public class UserUtils {
}
public boolean anyUserExists() {
return (dataStore.count(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.eq(false)).
limit(1).get().value() > 0);
return (dataStore.count(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true))
.limit(1).get().value() > 0);
}
public List getUsers() {
Result findUsersQueryResult = dataStore.select(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.eq(false))
Result findUsersQueryResult = dataStore.select(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.notEqual
(true))
.get();
return findUsersQueryResult.toList();
@ -67,7 +68,7 @@ public class UserUtils {
public UserEntity getAnyUserAndSetAsActive() {
Result findUserQueryResult = dataStore.select(User.class)
.where(UserEntity.SCHEDULED_FOR_DELETION.eq(false))
.where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true))
.limit(1).get();
UserEntity userEntity;
@ -82,7 +83,7 @@ public class UserUtils {
public UserEntity getCurrentUser() {
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.CURRENT.eq(true)
.and(UserEntity.SCHEDULED_FOR_DELETION.eq(false)))
.and(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true)))
.limit(1).get();
return (UserEntity) findUserQueryResult.firstOrNull();
@ -101,8 +102,7 @@ public class UserUtils {
}
public void disableAllUsersWithoutId(long userId) {
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.notEqual(userId))
.and(UserEntity.CURRENT.eq(true)).get();
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.notEqual(userId)).get();
for (Object object : findUserQueryResult) {
UserEntity userEntity = (UserEntity) object;
@ -178,7 +178,8 @@ public class UserUtils {
user.setToken(token);
}
if (!TextUtils.isEmpty(displayName) && !displayName.equals(user.getDisplayName())) {
if ((displayName != null && user.getDisplayName() == null) || (displayName != null && user.getDisplayName()
!= null && !displayName.equals(user.getDisplayName()))) {
user.setDisplayName(displayName);
}