From af48bc9a502d70105ce79dd04d62c3b2bb51a9de Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 28 Nov 2017 15:21:38 +0100 Subject: [PATCH] Progress in account switching Signed-off-by: Mario Danic --- .../talk/api/helpers/api/ApiHelper.java | 4 ++-- .../AccountVerificationController.java | 6 +++++- .../talk/controllers/ContactsController.java | 21 ++----------------- .../talk/controllers/SettingsController.java | 6 ++---- app/src/main/res/layout/rv_item_call.xml | 3 ++- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java b/app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java index ff66b1b8d..bbad8f515 100644 --- a/app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java +++ b/app/src/main/java/com/nextcloud/talk/api/helpers/api/ApiHelper.java @@ -130,8 +130,8 @@ public class ApiHelper { return baseUrl + ocsApiVersion + spreedApiVersion + "/signaling"; } - public static String getUrlForUserProfile(String baseUrl) { - return baseUrl + ocsApiVersion + "/cloud/user"; + public static String getUrlForUserProfile(String baseUrl, String username) { + return baseUrl + ocsApiVersion + "/cloud/users/" + username; } public static String getUrlPostfixForStatus() { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java index a3d583442..33b7e03fa 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.java @@ -114,7 +114,7 @@ public class AccountVerificationController extends BaseController { R.string.nc_nextcloud_talk_app_installed), getResources().getString(R.string.nc_app_name))); profileQueryDisposable = ncApi.getUserProfile(credentials, - ApiHelper.getUrlForUserProfile(baseUrl)) + ApiHelper.getUrlForUserProfile(baseUrl, username)) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(userProfileOverall -> { @@ -126,6 +126,10 @@ 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)) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java index 6bb5c068a..6d8fb49b8 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java @@ -80,7 +80,7 @@ import retrofit2.HttpException; @AutoInjector(NextcloudTalkApplication.class) public class ContactsController extends BaseController implements SearchView.OnQueryTextListener, - ActionMode.Callback, FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemLongClickListener { + ActionMode.Callback, FlexibleAdapter.OnItemClickListener { public static final String TAG = "ContactsController"; @@ -411,16 +411,10 @@ public class ContactsController extends BaseController implements SearchView.OnQ if (count == 0) { actionMode.finish(); } else { - setContextTitle(count); + //setContextTitle(count); } } - private void setContextTitle(int count) { - actionMode.setTitle(String.valueOf(count) + " " + (count == 1 ? - getResources().getString(R.string.one_contact_selected) : - getResources().getString(R.string.more_contacts_selected))); - } - @Override public void onSaveInstanceState(@NonNull Bundle outState) { adapter.onSaveInstanceState(outState); @@ -432,18 +426,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ super.onRestoreInstanceState(savedInstanceState); if (adapter != null) { adapter.onRestoreInstanceState(savedInstanceState); - if (adapter.getSelectedItemCount() > 0) { - actionMode = getActivity().startActionMode(this); - setContextTitle(adapter.getSelectedItemCount()); - } } } - @Override - public void onItemLongClick(int position) { - if (actionMode == null) { - actionMode = getActivity().startActionMode(this); - } - toggleSelection(position); - } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java index c6efd596e..3337bed4f 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java @@ -74,7 +74,6 @@ import cn.carbs.android.avatarimageview.library.AvatarImageView; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import okhttp3.Credentials; @AutoInjector(NextcloudTalkApplication.class) public class SettingsController extends BaseController { @@ -281,10 +280,9 @@ public class SettingsController extends BaseController { .centerInside() .into(avatarImageView); - - profileQueryDisposable = ncApi.getUserProfile(Credentials.basic(userEntity.getUsername(), + profileQueryDisposable = ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()), - ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl())) + ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl(), userEntity.getUsername())) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(userProfileOverall -> { diff --git a/app/src/main/res/layout/rv_item_call.xml b/app/src/main/res/layout/rv_item_call.xml index 1eeffb8e5..21e1ad50d 100644 --- a/app/src/main/res/layout/rv_item_call.xml +++ b/app/src/main/res/layout/rv_item_call.xml @@ -75,6 +75,7 @@ android:layout_centerVertical="true" android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginStart="@dimen/margin_between_elements" - android:background="@drawable/ic_more_horiz_black_24dp"/> + android:background="@drawable/ic_more_horiz_black_24dp" + android:visibility="invisible"/>