diff --git a/app/build.gradle b/app/build.gradle index 79189fb11..42fb76950 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,8 +15,8 @@ android { targetSdkVersion 27 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - versionCode 58 - versionName "3.0.0beta7" + versionCode 59 + versionName "3.0.0beta8" flavorDimensions "default" renderscriptTargetApi 19 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index 1f663a87d..005a0bd96 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -80,6 +80,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.glide.GlideApp; import com.nextcloud.talk.utils.preferences.AppPreferences; +import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder; import com.nextcloud.talk.webrtc.MagicAudioManager; import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper; @@ -182,7 +183,6 @@ public class CallController extends BaseController { @BindView(R.id.conversationRelativeLayoutView) RelativeLayout conversationView; - @Inject NcApi ncApi; @Inject EventBus eventBus; @@ -302,6 +302,8 @@ public class CallController extends BaseController { .setRepeatMode(PulseAnimation.REVERSE); + ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl); + try { cache.evictAll(); } catch (IOException e) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java index b016e7bd6..f9ffb0ade 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java @@ -83,6 +83,7 @@ import com.nextcloud.talk.utils.NotificationUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.database.user.UserUtils; import com.nextcloud.talk.utils.glide.GlideApp; +import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder; import com.otaliastudios.autocomplete.Autocomplete; import com.otaliastudios.autocomplete.AutocompleteCallback; @@ -99,7 +100,6 @@ import com.webianks.library.PopupBubble; import org.parceler.Parcels; -import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Date; @@ -117,7 +117,6 @@ import io.reactivex.Observer; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import okhttp3.Cache; import retrofit2.HttpException; import retrofit2.Response; @@ -125,12 +124,9 @@ import retrofit2.Response; public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener, MessagesListAdapter.Formatter, MessagesListAdapter.OnMessageLongClickListener, MessageHolders.ContentChecker { private static final String TAG = "ChatController"; - @Inject NcApi ncApi; @Inject UserUtils userUtils; - @Inject - Cache cache; @BindView(R.id.messagesListView) MessagesList messagesListView; @BindView(R.id.messageInputView) @@ -300,16 +296,12 @@ public class ChatController extends BaseController implements MessagesListAdapte sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources() .getString(R.string.nc_hello))); + ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl); + if (adapter == null) { loadingProgressBar.setVisibility(View.VISIBLE); - try { - cache.evictAll(); - } catch (IOException e) { - Log.e(TAG, "Failed to evict cache"); - } - adapterWasNull = true; MessageHolders messageHolders = new MessageHolders(); diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 076ebdc7b..a4ba65f28 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -56,6 +56,7 @@ import com.nextcloud.talk.models.json.participants.AddParticipantOverall; import com.nextcloud.talk.models.json.rooms.Conversation; import com.nextcloud.talk.models.json.rooms.RoomOverall; import com.nextcloud.talk.utils.ApiUtils; +import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder; import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder; import com.nextcloud.talk.utils.DisplayUtils; import com.nextcloud.talk.utils.bundle.BundleKeys; @@ -95,7 +96,6 @@ public class OperationsMenuController extends BaseController { @BindView(R.id.web_button) Button webButton; - @Inject NcApi ncApi; @Inject @@ -156,6 +156,8 @@ public class OperationsMenuController extends BaseController { super.onViewBound(view); NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); + ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userUtils.getCurrentUser().getId + (), null); processOperation(); } diff --git a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java index 9202e2e6e..f90939c69 100644 --- a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java +++ b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java @@ -69,6 +69,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter super(context); this.context = context; NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); + setupNcApi(); } public MentionAutocompletePresenter(Context context, String roomToken) { @@ -76,6 +77,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter this.roomToken = roomToken; this.context = context; NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); + setupNcApi(); } private void setupNcApi() { diff --git a/app/src/main/java/com/nextcloud/talk/utils/singletons/ApplicationWideApiHolder.java b/app/src/main/java/com/nextcloud/talk/utils/singletons/ApplicationWideApiHolder.java index 660567ee1..900d0be30 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/singletons/ApplicationWideApiHolder.java +++ b/app/src/main/java/com/nextcloud/talk/utils/singletons/ApplicationWideApiHolder.java @@ -66,7 +66,7 @@ public class ApplicationWideApiHolder { if (!ncApiHashMap.containsKey(accountId)) { UserEntity userAccount = userUtils.getUserWithId(accountId); - if (userAccount == null || !TextUtils.isEmpty(baseUrl)) { + if (userAccount == null || (userAccount.getId() == -1 && !TextUtils.isEmpty(baseUrl))) { retrofit = retrofit.newBuilder().baseUrl(baseUrl).build(); return retrofit.create(NcApi.class); } else {