mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Back to regular inject :(
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
3a83a1783e
commit
e514c24316
@ -80,7 +80,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys;
|
|||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
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.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||||
import com.nextcloud.talk.webrtc.MagicAudioManager;
|
import com.nextcloud.talk.webrtc.MagicAudioManager;
|
||||||
import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper;
|
import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper;
|
||||||
@ -182,6 +181,7 @@ public class CallController extends BaseController {
|
|||||||
@BindView(R.id.conversationRelativeLayoutView)
|
@BindView(R.id.conversationRelativeLayoutView)
|
||||||
RelativeLayout conversationView;
|
RelativeLayout conversationView;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
@ -299,8 +299,6 @@ public class CallController extends BaseController {
|
|||||||
.setRepeatMode(PulseAnimation.REVERSE);
|
.setRepeatMode(PulseAnimation.REVERSE);
|
||||||
|
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl);
|
|
||||||
|
|
||||||
if (isVoiceOnlyCall) {
|
if (isVoiceOnlyCall) {
|
||||||
callControlEnableSpeaker.setVisibility(View.VISIBLE);
|
callControlEnableSpeaker.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ import com.nextcloud.talk.utils.MagicFlipView;
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
|
import com.nextcloud.talk.utils.singletons.AvatarStatusCodeHolder;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -103,7 +102,8 @@ public class CallNotificationController extends BaseController {
|
|||||||
|
|
||||||
private static final String TAG = "CallNotificationController";
|
private static final String TAG = "CallNotificationController";
|
||||||
|
|
||||||
private NcApi ncApi;
|
@Inject
|
||||||
|
NcApi ncApi;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AppPreferences appPreferences;
|
AppPreferences appPreferences;
|
||||||
@ -297,7 +297,6 @@ public class CallNotificationController extends BaseController {
|
|||||||
|
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userBeingCalled.getId(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentConversation == null) {
|
if (currentConversation == null) {
|
||||||
|
@ -83,7 +83,6 @@ import com.nextcloud.talk.utils.NotificationUtils;
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||||
import com.otaliastudios.autocomplete.Autocomplete;
|
import com.otaliastudios.autocomplete.Autocomplete;
|
||||||
import com.otaliastudios.autocomplete.AutocompleteCallback;
|
import com.otaliastudios.autocomplete.AutocompleteCallback;
|
||||||
@ -124,6 +123,7 @@ import retrofit2.Response;
|
|||||||
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
|
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
|
||||||
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener, MessageHolders.ContentChecker {
|
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener, MessageHolders.ContentChecker {
|
||||||
private static final String TAG = "ChatController";
|
private static final String TAG = "ChatController";
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
@Inject
|
@Inject
|
||||||
UserUtils userUtils;
|
UserUtils userUtils;
|
||||||
@ -296,8 +296,6 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources()
|
sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources()
|
||||||
.getString(R.string.nc_hello)));
|
.getString(R.string.nc_hello)));
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(conversationUser.getId(), baseUrl);
|
|
||||||
|
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
|
|
||||||
loadingProgressBar.setVisibility(View.VISIBLE);
|
loadingProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
@ -68,7 +68,6 @@ import com.nextcloud.talk.models.json.sharees.ShareesOverall;
|
|||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -129,7 +128,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
@BindView(R.id.fast_scroller)
|
@BindView(R.id.fast_scroller)
|
||||||
FastScroller fastScroller;
|
FastScroller fastScroller;
|
||||||
|
|
||||||
private NcApi ncApi;
|
@Inject
|
||||||
|
NcApi ncApi;
|
||||||
private String credentials;
|
private String credentials;
|
||||||
private UserEntity currentUser;
|
private UserEntity currentUser;
|
||||||
private Disposable contactsQueryDisposable;
|
private Disposable contactsQueryDisposable;
|
||||||
@ -208,7 +208,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(currentUser.getId(), null);
|
|
||||||
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ import com.nextcloud.talk.utils.ApiUtils;
|
|||||||
import com.nextcloud.talk.utils.KeyboardUtils;
|
import com.nextcloud.talk.utils.KeyboardUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.CompareToBuilder;
|
import org.apache.commons.lang3.builder.CompareToBuilder;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@ -107,6 +106,7 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
@ -155,7 +155,6 @@ public class ConversationsListController extends BaseController implements Searc
|
|||||||
currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
|
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(currentUser.getId(), null);
|
|
||||||
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ import com.nextcloud.talk.utils.database.user.UserUtils;
|
|||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
import com.nextcloud.talk.utils.preferences.MagicUserInputModule;
|
import com.nextcloud.talk.utils.preferences.MagicUserInputModule;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
|
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
|
||||||
import com.yarolegovich.mp.MaterialChoicePreference;
|
import com.yarolegovich.mp.MaterialChoicePreference;
|
||||||
import com.yarolegovich.mp.MaterialEditTextPreference;
|
import com.yarolegovich.mp.MaterialEditTextPreference;
|
||||||
@ -161,7 +160,8 @@ public class SettingsController extends BaseController {
|
|||||||
@Inject
|
@Inject
|
||||||
AppPreferences appPreferences;
|
AppPreferences appPreferences;
|
||||||
|
|
||||||
private NcApi ncApi;
|
@Inject
|
||||||
|
NcApi ncApi;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
UserUtils userUtils;
|
UserUtils userUtils;
|
||||||
@ -183,7 +183,6 @@ public class SettingsController extends BaseController {
|
|||||||
private void getCurrentUser() {
|
private void getCurrentUser() {
|
||||||
currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
credentials = ApiUtils.getCredentials(currentUser.getUserId(), currentUser.getToken());
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(currentUser.getId(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,11 +56,10 @@ import com.nextcloud.talk.models.json.participants.AddParticipantOverall;
|
|||||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||||
import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
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.DisplayUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
|
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
@ -96,6 +95,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
@BindView(R.id.web_button)
|
@BindView(R.id.web_button)
|
||||||
Button webButton;
|
Button webButton;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -156,8 +156,6 @@ public class OperationsMenuController extends BaseController {
|
|||||||
super.onViewBound(view);
|
super.onViewBound(view);
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userUtils.getCurrentUser().getId
|
|
||||||
(), null);
|
|
||||||
processOperation();
|
processOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ import com.nextcloud.talk.utils.ssl.MagicKeyManager;
|
|||||||
import com.nextcloud.talk.utils.ssl.MagicTrustManager;
|
import com.nextcloud.talk.utils.ssl.MagicTrustManager;
|
||||||
import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat;
|
import com.nextcloud.talk.utils.ssl.SSLSocketFactoryCompat;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.CookieManager;
|
import java.net.CookieManager;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@ -47,7 +46,6 @@ import java.security.KeyStoreException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.UnrecoverableKeyException;
|
import java.security.UnrecoverableKeyException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@ -77,6 +75,7 @@ public class RestModule {
|
|||||||
|
|
||||||
private static final String TAG = "RestModule";
|
private static final String TAG = "RestModule";
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
NcApi provideNcApi(Retrofit retrofit) {
|
NcApi provideNcApi(Retrofit retrofit) {
|
||||||
return retrofit.create(NcApi.class);
|
return retrofit.create(NcApi.class);
|
||||||
@ -102,6 +101,7 @@ public class RestModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
Retrofit provideRetrofit(OkHttpClient httpClient) {
|
||||||
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
|
||||||
@ -152,25 +152,18 @@ public class RestModule {
|
|||||||
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
return new SSLSocketFactoryCompat(keyManager, magicTrustManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
CookieManager provideCookieManager() {
|
CookieManager provideCookieManager() {
|
||||||
return new CookieManager();
|
return new CookieManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
Cache provideCache(UserUtils userUtils) {
|
Cache provideCache() {
|
||||||
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
int cacheSize = 128 * 1024 * 1024; // 128 MB
|
||||||
String userId = "";
|
|
||||||
|
|
||||||
if (userUtils.getCurrentUser() != null) {
|
return new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(), cacheSize);
|
||||||
userId = Long.toString(userUtils.getCurrentUser().getId());
|
|
||||||
} else {
|
|
||||||
Random r = new Random( System.currentTimeMillis() );
|
|
||||||
userId = "nc-temp-" + (10000 + r.nextInt(20000));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Cache(new File(NextcloudTalkApplication.getSharedApplication().getCacheDir() + "/" +
|
|
||||||
userId), cacheSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -182,6 +175,7 @@ public class RestModule {
|
|||||||
return dispatcher;
|
return dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences,
|
||||||
MagicTrustManager magicTrustManager,
|
MagicTrustManager magicTrustManager,
|
||||||
|
@ -37,7 +37,6 @@ import com.nextcloud.talk.models.json.generic.GenericOverall;
|
|||||||
import com.nextcloud.talk.models.json.push.PushConfigurationState;
|
import com.nextcloud.talk.models.json.push.PushConfigurationState;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -66,6 +65,7 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
@Inject
|
@Inject
|
||||||
OkHttpClient okHttpClient;
|
OkHttpClient okHttpClient;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -83,7 +83,6 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
PushConfigurationState.class);
|
PushConfigurationState.class);
|
||||||
PushConfigurationState finalPushConfigurationState = pushConfigurationState;
|
PushConfigurationState finalPushConfigurationState = pushConfigurationState;
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userEntity.getId(), null);
|
|
||||||
credentials = ApiUtils.getCredentials(userEntity.getUserId(), userEntity.getToken());
|
credentials = ApiUtils.getCredentials(userEntity.getUserId(), userEntity.getToken());
|
||||||
|
|
||||||
String finalCredentials = credentials;
|
String finalCredentials = credentials;
|
||||||
@ -107,7 +106,7 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
|
|
||||||
ncApi.unregisterDeviceForNotificationsWithProxy
|
ncApi.unregisterDeviceForNotificationsWithProxy
|
||||||
(finalCredentials, ApiUtils.getUrlPushProxy(), queryMap)
|
(finalCredentials, ApiUtils.getUrlPushProxy(), queryMap)
|
||||||
.blockingSubscribe(new Observer<Void>() {
|
.subscribe(new Observer<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
@ -116,8 +115,6 @@ public class AccountRemovalWorker extends Worker {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(Void aVoid) {
|
public void onNext(Void aVoid) {
|
||||||
|
|
||||||
ApplicationWideApiHolder.getInstance().removeNcApiInstanceForAccountId(userEntity.getId());
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
String groupName = String.format(getApplicationContext().getResources()
|
String groupName = String.format(getApplicationContext().getResources()
|
||||||
.getString(R.string
|
.getString(R.string
|
||||||
|
@ -32,7 +32,6 @@ import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
|||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@ -66,6 +65,7 @@ public class CapabilitiesWorker extends Worker {
|
|||||||
@Inject
|
@Inject
|
||||||
OkHttpClient okHttpClient;
|
OkHttpClient okHttpClient;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
private void updateUser(CapabilitiesOverall capabilitiesOverall, UserEntity internalUserEntity) {
|
private void updateUser(CapabilitiesOverall capabilitiesOverall, UserEntity internalUserEntity) {
|
||||||
@ -124,8 +124,6 @@ public class CapabilitiesWorker extends Worker {
|
|||||||
for (Object userEntityObject : userEntityObjectList) {
|
for (Object userEntityObject : userEntityObjectList) {
|
||||||
UserEntity internalUserEntity = (UserEntity) userEntityObject;
|
UserEntity internalUserEntity = (UserEntity) userEntityObject;
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(internalUserEntity.getId(), null);
|
|
||||||
|
|
||||||
ncApi.getCapabilities(ApiUtils.getCredentials(internalUserEntity.getUsername(),
|
ncApi.getCapabilities(ApiUtils.getCredentials(internalUserEntity.getUsername(),
|
||||||
internalUserEntity.getToken()), ApiUtils.getUrlForCapabilities(internalUserEntity.getBaseUrl()))
|
internalUserEntity.getToken()), ApiUtils.getUrlForCapabilities(internalUserEntity.getBaseUrl()))
|
||||||
.retry(3)
|
.retry(3)
|
||||||
|
@ -60,7 +60,6 @@ import com.nextcloud.talk.utils.PushUtils;
|
|||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
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.ApplicationWideApiHolder;
|
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideStateHolder;
|
import com.nextcloud.talk.utils.singletons.ApplicationWideStateHolder;
|
||||||
|
|
||||||
@ -94,6 +93,7 @@ public class NotificationWorker extends Worker {
|
|||||||
@Inject
|
@Inject
|
||||||
AppPreferences appPreferences;
|
AppPreferences appPreferences;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
private DecryptedPushMessage decryptedPushMessage;
|
private DecryptedPushMessage decryptedPushMessage;
|
||||||
@ -392,7 +392,6 @@ public class NotificationWorker extends Worker {
|
|||||||
decryptedPushMessage = LoganSquare.parse(new String(decryptedSubject),
|
decryptedPushMessage = LoganSquare.parse(new String(decryptedSubject),
|
||||||
DecryptedPushMessage.class);
|
DecryptedPushMessage.class);
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(signatureVerification.getUserEntity().getId(), null);
|
|
||||||
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUserId(),
|
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUserId(),
|
||||||
signatureVerification.getUserEntity().getToken());
|
signatureVerification.getUserEntity().getToken());
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ import com.nextcloud.talk.models.json.mention.Mention;
|
|||||||
import com.nextcloud.talk.models.json.mention.MentionOverall;
|
import com.nextcloud.talk.models.json.mention.MentionOverall;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideApiHolder;
|
|
||||||
import com.otaliastudios.autocomplete.RecyclerViewPresenter;
|
import com.otaliastudios.autocomplete.RecyclerViewPresenter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -52,7 +51,8 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention> implements FlexibleAdapter.OnItemClickListener {
|
public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention> implements FlexibleAdapter.OnItemClickListener {
|
||||||
private NcApi ncApi;
|
@Inject
|
||||||
|
NcApi ncApi;
|
||||||
private UserEntity currentUser;
|
private UserEntity currentUser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -69,7 +69,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
super(context);
|
super(context);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
setupNcApi();
|
currentUser = userUtils.getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MentionAutocompletePresenter(Context context, String roomToken) {
|
public MentionAutocompletePresenter(Context context, String roomToken) {
|
||||||
@ -77,12 +77,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
this.roomToken = roomToken;
|
this.roomToken = roomToken;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||||
setupNcApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupNcApi() {
|
|
||||||
currentUser = userUtils.getCurrentUser();
|
currentUser = userUtils.getCurrentUser();
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(currentUser.getId(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,6 @@ import com.nextcloud.talk.models.json.push.PushConfigurationState;
|
|||||||
import com.nextcloud.talk.models.json.push.PushRegistrationOverall;
|
import com.nextcloud.talk.models.json.push.PushRegistrationOverall;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
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.ApplicationWideApiHolder;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@ -82,6 +81,7 @@ public class PushUtils {
|
|||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
private File keysFile;
|
private File keysFile;
|
||||||
@ -260,7 +260,6 @@ public class PushUtils {
|
|||||||
queryMap.put("devicePublicKey", publicKey);
|
queryMap.put("devicePublicKey", publicKey);
|
||||||
queryMap.put("proxyServer", proxyServer);
|
queryMap.put("proxyServer", proxyServer);
|
||||||
|
|
||||||
ncApi = ApplicationWideApiHolder.getInstance().getNcApiInstanceForAccountId(userEntity.getId(), null);
|
|
||||||
credentials = ApiUtils.getCredentials(userEntity.getUserId(), userEntity.getToken());
|
credentials = ApiUtils.getCredentials(userEntity.getUserId(), userEntity.getToken());
|
||||||
|
|
||||||
String finalCredentials = credentials;
|
String finalCredentials = credentials;
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.nextcloud.talk.utils.singletons;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.nextcloud.talk.api.NcApi;
|
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import autodagger.AutoInjector;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
|
||||||
public class ApplicationWideApiHolder {
|
|
||||||
private static final String TAG = "ApplicationWideApiHolder";
|
|
||||||
|
|
||||||
@SuppressLint("UseSparseArrays")
|
|
||||||
private Map<Long, NcApi> ncApiHashMap;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
UserUtils userUtils;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
Retrofit retrofit;
|
|
||||||
|
|
||||||
private static final ApplicationWideApiHolder holder = new ApplicationWideApiHolder();
|
|
||||||
|
|
||||||
public static ApplicationWideApiHolder getInstance() {
|
|
||||||
return holder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("UseSparseArrays")
|
|
||||||
public NcApi getNcApiInstanceForAccountId(long accountId, @Nullable String baseUrl) {
|
|
||||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
|
||||||
|
|
||||||
if (ncApiHashMap == null) {
|
|
||||||
ncApiHashMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ncApiHashMap.containsKey(accountId)) {
|
|
||||||
UserEntity userAccount = userUtils.getUserWithId(accountId);
|
|
||||||
if (userAccount == null || (userAccount.getId() == -1 && !TextUtils.isEmpty(baseUrl))) {
|
|
||||||
retrofit = retrofit.newBuilder().baseUrl(baseUrl).build();
|
|
||||||
return retrofit.create(NcApi.class);
|
|
||||||
} else {
|
|
||||||
retrofit = retrofit.newBuilder().baseUrl(userAccount.getBaseUrl() + "/").build();
|
|
||||||
ncApiHashMap.put(accountId, retrofit.create(NcApi.class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ncApiHashMap.get(accountId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeNcApiInstanceForAccountId(long accountId) {
|
|
||||||
ncApiHashMap.remove(accountId);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user