mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-26 07:00:02 +01:00
Some stuff
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
a49cab9b84
commit
53580378d1
@ -126,10 +126,6 @@ public class AccountVerificationController extends BaseController {
|
|||||||
.getDisplayName())) {
|
.getDisplayName())) {
|
||||||
displayName = userProfileOverall.getOcs().getData()
|
displayName = userProfileOverall.getOcs().getData()
|
||||||
.getDisplayName();
|
.getDisplayName();
|
||||||
} else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData()
|
|
||||||
.getDisplayNameAlt())) {
|
|
||||||
displayName = userProfileOverall.getOcs().getData()
|
|
||||||
.getDisplayNameAlt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(displayName)) {
|
if (!TextUtils.isEmpty(displayName)) {
|
||||||
|
@ -159,6 +159,8 @@ public class SettingsController extends BaseController {
|
|||||||
super.onViewBound(view);
|
super.onViewBound(view);
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
|
userEntity = userUtils.getCurrentUser();
|
||||||
|
|
||||||
appPreferences.registerProxyTypeListener(proxyTypeChangeListener = new ProxyTypeChangeListener());
|
appPreferences.registerProxyTypeListener(proxyTypeChangeListener = new ProxyTypeChangeListener());
|
||||||
appPreferences.registerProxyCredentialsListener(proxyCredentialsChangeListener = new
|
appPreferences.registerProxyCredentialsListener(proxyCredentialsChangeListener = new
|
||||||
ProxyCredentialsChangeListener());
|
ProxyCredentialsChangeListener());
|
||||||
@ -209,21 +211,6 @@ public class SettingsController extends BaseController {
|
|||||||
|
|
||||||
versionInfo.setSummary("v" + BuildConfig.VERSION_NAME);
|
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.setOnClickListener(view15 -> {
|
||||||
addAccountButton.setEnabled(false);
|
addAccountButton.setEnabled(false);
|
||||||
getParentController().getRouter().pushController(RouterTransaction.with(new
|
getParentController().getRouter().pushController(RouterTransaction.with(new
|
||||||
@ -247,6 +234,9 @@ public class SettingsController extends BaseController {
|
|||||||
protected void onAttach(@NonNull View view) {
|
protected void onAttach(@NonNull View view) {
|
||||||
super.onAttach(view);
|
super.onAttach(view);
|
||||||
|
|
||||||
|
dispose(null);
|
||||||
|
userEntity = userUtils.getCurrentUser();
|
||||||
|
|
||||||
if ("No proxy".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
|
if ("No proxy".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
|
||||||
hideProxySettings();
|
hideProxySettings();
|
||||||
} else {
|
} else {
|
||||||
@ -259,8 +249,19 @@ public class SettingsController extends BaseController {
|
|||||||
hideProxyCredentials();
|
hideProxyCredentials();
|
||||||
}
|
}
|
||||||
|
|
||||||
userEntity = userUtils.getCurrentUser();
|
|
||||||
if (userEntity != null) {
|
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
|
// Awful hack
|
||||||
if (userEntity.getDisplayName() != null) {
|
if (userEntity.getDisplayName() != null) {
|
||||||
avatarImageView.setTextAndColorSeed(String.valueOf(userEntity.getDisplayName().
|
avatarImageView.setTextAndColorSeed(String.valueOf(userEntity.getDisplayName().
|
||||||
@ -300,6 +301,7 @@ public class SettingsController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
|
if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
|
||||||
|
|
||||||
dbQueryDisposable = userUtils.createOrUpdateUser(userEntity.getUsername(),
|
dbQueryDisposable = userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||||
userEntity.getToken(),
|
userEntity.getToken(),
|
||||||
userEntity.getBaseUrl(), displayName, null, true)
|
userEntity.getBaseUrl(), displayName, null, true)
|
||||||
@ -320,8 +322,8 @@ public class SettingsController extends BaseController {
|
|||||||
removeAccountButton.setOnClickListener(view1 -> {
|
removeAccountButton.setOnClickListener(view1 -> {
|
||||||
boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());
|
boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());
|
||||||
if (otherUserExists && getView() != null) {
|
if (otherUserExists && getView() != null) {
|
||||||
onViewBound(getView());
|
|
||||||
onAttach(getView());
|
onAttach(getView());
|
||||||
|
onViewBound(getView());
|
||||||
} else if (!otherUserExists) {
|
} else if (!otherUserExists) {
|
||||||
getParentController().getRouter().setRoot(RouterTransaction.with(
|
getParentController().getRouter().setRoot(RouterTransaction.with(
|
||||||
new ServerSelectionController())
|
new ServerSelectionController())
|
||||||
@ -423,11 +425,15 @@ public class SettingsController extends BaseController {
|
|||||||
if (profileQueryDisposable != null && !profileQueryDisposable.isDisposed()) {
|
if (profileQueryDisposable != null && !profileQueryDisposable.isDisposed()) {
|
||||||
profileQueryDisposable.dispose();
|
profileQueryDisposable.dispose();
|
||||||
profileQueryDisposable = null;
|
profileQueryDisposable = null;
|
||||||
|
} else if (profileQueryDisposable != null) {
|
||||||
|
profileQueryDisposable = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbQueryDisposable != null && !dbQueryDisposable.isDisposed()) {
|
if (dbQueryDisposable != null && !dbQueryDisposable.isDisposed()) {
|
||||||
dbQueryDisposable.dispose();
|
dbQueryDisposable.dispose();
|
||||||
dbQueryDisposable = null;
|
dbQueryDisposable = null;
|
||||||
|
} else if (dbQueryDisposable != null) {
|
||||||
|
dbQueryDisposable = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,11 +116,10 @@ public class SwitchAccountController extends BaseController {
|
|||||||
|
|
||||||
UserEntity userEntity;
|
UserEntity userEntity;
|
||||||
User user;
|
User user;
|
||||||
UserEntity currentUserEntity = userUtils.getCurrentUser();
|
|
||||||
|
|
||||||
for (Object userEntityObject : userUtils.getUsers()) {
|
for (Object userEntityObject : userUtils.getUsers()) {
|
||||||
userEntity = (UserEntity) userEntityObject;
|
userEntity = (UserEntity) userEntityObject;
|
||||||
if (!userEntity.equals(currentUserEntity)) {
|
if (!userEntity.getCurrent()) {
|
||||||
user = new User();
|
user = new User();
|
||||||
user.setName(userEntity.getDisplayName());
|
user.setName(userEntity.getDisplayName());
|
||||||
user.setUserId(userEntity.getUsername());
|
user.setUserId(userEntity.getUsername());
|
||||||
|
@ -46,12 +46,13 @@ public class UserUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean anyUserExists() {
|
public boolean anyUserExists() {
|
||||||
return (dataStore.count(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.eq(false)).
|
return (dataStore.count(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true))
|
||||||
limit(1).get().value() > 0);
|
.limit(1).get().value() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getUsers() {
|
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();
|
.get();
|
||||||
|
|
||||||
return findUsersQueryResult.toList();
|
return findUsersQueryResult.toList();
|
||||||
@ -67,7 +68,7 @@ public class UserUtils {
|
|||||||
|
|
||||||
public UserEntity getAnyUserAndSetAsActive() {
|
public UserEntity getAnyUserAndSetAsActive() {
|
||||||
Result findUserQueryResult = dataStore.select(User.class)
|
Result findUserQueryResult = dataStore.select(User.class)
|
||||||
.where(UserEntity.SCHEDULED_FOR_DELETION.eq(false))
|
.where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true))
|
||||||
.limit(1).get();
|
.limit(1).get();
|
||||||
|
|
||||||
UserEntity userEntity;
|
UserEntity userEntity;
|
||||||
@ -82,7 +83,7 @@ public class UserUtils {
|
|||||||
|
|
||||||
public UserEntity getCurrentUser() {
|
public UserEntity getCurrentUser() {
|
||||||
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.CURRENT.eq(true)
|
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();
|
.limit(1).get();
|
||||||
|
|
||||||
return (UserEntity) findUserQueryResult.firstOrNull();
|
return (UserEntity) findUserQueryResult.firstOrNull();
|
||||||
@ -101,8 +102,7 @@ public class UserUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disableAllUsersWithoutId(long userId) {
|
public void disableAllUsersWithoutId(long userId) {
|
||||||
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.notEqual(userId))
|
Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.notEqual(userId)).get();
|
||||||
.and(UserEntity.CURRENT.eq(true)).get();
|
|
||||||
|
|
||||||
for (Object object : findUserQueryResult) {
|
for (Object object : findUserQueryResult) {
|
||||||
UserEntity userEntity = (UserEntity) object;
|
UserEntity userEntity = (UserEntity) object;
|
||||||
@ -178,7 +178,8 @@ public class UserUtils {
|
|||||||
user.setToken(token);
|
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);
|
user.setDisplayName(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user