Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-01-22 00:11:28 +01:00
parent 2ab027cfc6
commit 7a26e1d069
3 changed files with 21 additions and 10 deletions

View File

@ -50,6 +50,7 @@ import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences; import com.nextcloud.talk.utils.preferences.AppPreferences;
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
import io.reactivex.android.schedulers.AndroidSchedulers;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
@ -181,6 +182,7 @@ public class AccountVerificationController extends BaseController {
ncApi.getServerStatus(queryUrl) ncApi.getServerStatus(queryUrl)
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<Status>() { .subscribe(new Observer<Status>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
@ -195,8 +197,13 @@ public class AccountVerificationController extends BaseController {
baseUrl = "http://" + baseUrl; baseUrl = "http://" + baseUrl;
} }
if (isAccountImport) {
getRouter().pushController(RouterTransaction.with(new WebViewLoginController(baseUrl,
false, username, "")));
} else {
checkEverything(); checkEverything();
} }
}
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
@ -248,7 +255,7 @@ public class AccountVerificationController extends BaseController {
}); });
} }
private void storeProfile(String credentials, String displayName, String userId) { private void storeProfile(String displayName, String userId) {
userUtils.createOrUpdateUser(username, token, userUtils.createOrUpdateUser(username, token,
baseUrl, displayName, null, true, baseUrl, displayName, null, true,
userId, null, null, userId, null, null,
@ -314,7 +321,7 @@ public class AccountVerificationController extends BaseController {
} }
if (!TextUtils.isEmpty(displayName)) { if (!TextUtils.isEmpty(displayName)) {
storeProfile(credentials, displayName, userProfileOverall.getOcs().getData().getUserId()); storeProfile(displayName, userProfileOverall.getOcs().getData().getUserId());
} else { } else {
if (getActivity() != null) { if (getActivity() != null) {
getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" + getActivity().runOnUiThread(() -> progressText.setText(progressText.getText().toString() + "\n" +

View File

@ -168,6 +168,10 @@ public class SwitchAccountController extends BaseController {
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
swipeRefreshLayout.setEnabled(false); swipeRefreshLayout.setEnabled(false);
if (getActionBar() != null) {
getActionBar().show();
}
if (adapter == null) { if (adapter == null) {
adapter = new FlexibleAdapter<>(userItems, getActivity(), false); adapter = new FlexibleAdapter<>(userItems, getActivity(), false);
@ -196,9 +200,6 @@ public class SwitchAccountController extends BaseController {
adapter.addListener(onSwitchItemClickListener); adapter.addListener(onSwitchItemClickListener);
adapter.updateDataSet(userItems, false); adapter.updateDataSet(userItems, false);
} else { } else {
if (getActionBar() != null) {
getActionBar().show();
}
Account account; Account account;
ImportAccount importAccount; ImportAccount importAccount;
for (Object accountObject : AccountUtils.findAccounts(userUtils.getUsers())) { for (Object accountObject : AccountUtils.findAccounts(userUtils.getUsers())) {
@ -239,8 +240,12 @@ public class SwitchAccountController extends BaseController {
private void reauthorizeFromImport(Account account) { private void reauthorizeFromImport(Account account) {
ImportAccount importAccount = AccountUtils.getInformationFromAccount(account); ImportAccount importAccount = AccountUtils.getInformationFromAccount(account);
getRouter().pushController(RouterTransaction.with(new WebViewLoginController(importAccount.getBaseUrl(), Bundle bundle = new Bundle();
false, importAccount.getUsername(), "")) bundle.putString(BundleKeys.KEY_BASE_URL, importAccount.getBaseUrl());
bundle.putString(BundleKeys.KEY_USERNAME, importAccount.getUsername());
bundle.putString(BundleKeys.KEY_TOKEN, importAccount.getToken());
bundle.putBoolean(BundleKeys.KEY_IS_ACCOUNT_IMPORT, true);
getRouter().pushController(RouterTransaction.with(new AccountVerificationController(bundle))
.pushChangeHandler(new HorizontalChangeHandler()) .pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler())); .popChangeHandler(new HorizontalChangeHandler()));
} }

View File

@ -214,8 +214,7 @@ public class WebViewLoginController extends BaseController {
} else if (!automatedLoginAttempted) { } else if (!automatedLoginAttempted) {
automatedLoginAttempted = true; automatedLoginAttempted = true;
if (TextUtils.isEmpty(password)) { if (TextUtils.isEmpty(password)) {
webView.loadUrl("javascript: {" + webView.loadUrl("javascript:var justStore = document.getElementById('user').value = '" + username + "';");
"document.getElementById('user').value = '" + username + "'; };");
} else { } else {
webView.loadUrl("javascript: {" + webView.loadUrl("javascript: {" +
"document.getElementById('user').value = '" + username + "';" + "document.getElementById('user').value = '" + username + "';" +