Skip to content

Commit 56c3074

Browse files
committed
Merge branch 'development'
2 parents 3c15ebd + a0d988e commit 56c3074

File tree

42 files changed

+301
-619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+301
-619
lines changed

build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55

66
dependencies {
77
classpath 'com.android.tools.build:gradle:2.2.0'
8-
classpath 'com.google.gms:google-services:2.0.0-beta2'
8+
classpath 'com.google.gms:google-services:3.0.0'
99
}
1010
}
1111

@@ -32,15 +32,15 @@ ext {
3232
lintAbortOnError = false
3333

3434
// QuickBlox SDK version
35-
qbSdkVersion = '3.1.0'
35+
qbSdkVersion = '3.2.0'
3636

37-
versionName = "3.0"
37+
versionName = '3.2.0'
3838

39-
testRunnerVersion = "0.4.1"
39+
testRunnerVersion = '0.4.1'
4040

4141

4242
// Dependency versions
43-
playServicesVersion = '8.4.0'
43+
playServicesVersion = '9.8.0'
4444
supportV4Version = '23.1.1'
4545
appcompatV7Version = '23.1.1'
4646
recyclerviewV7Version = '23.2.1'

sample-chat/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ dependencies {
7474

7575
compile(project(":sample-core"))
7676
compile 'com.github.orangegangsters:swipy:1.2.2@aar'
77-
compile "com.google.android.gms:play-services-gcm:${rootProject.playServicesVersion}"
7877
compile "com.github.bumptech.glide:glide:${rootProject.glideVersion}"
7978
compile "se.emilsjolander:stickylistheaders:${rootProject.stickyListHeaders}"
8079
}

sample-chat/google-services.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@
7777
}
7878
},
7979
"oauth_client": [],
80-
"api_key": [],
80+
"api_key": [
81+
{
82+
"current_key": ""
83+
}
84+
],
8185
"services": {
8286
"analytics_service": {
8387
"status": 1

sample-chat/src/main/AndroidManifest.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@
8383
</service>
8484

8585
<service
86-
android:name=".gcm.GcmPushInstanceIDService"
86+
android:name="com.quickblox.messages.services.gcm.QBGcmPushInstanceIDService"
8787
android:exported="false">
8888
<intent-filter>
8989
<action android:name="com.google.android.gms.iid.InstanceID" />
9090
</intent-filter>
9191
</service>
9292

93+
<meta-data android:name="com.quickblox.messages.TYPE" android:value="GCM" />
94+
<meta-data android:name="com.quickblox.messages.SENDER_ID" android:value="@string/sender_id" />
95+
<meta-data android:name="com.quickblox.messages.QB_ENVIRONMENT" android:value="DEVELOPMENT" />
96+
9397
<meta-data
9498
android:name="com.google.android.gms.version"
9599
android:value="@integer/google_play_services_version" />

sample-chat/src/main/java/com/quickblox/sample/chat/gcm/GcmPushInstanceIDService.java

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package com.quickblox.sample.chat.gcm;
22

3-
import android.content.Intent;
4-
import android.support.v4.content.LocalBroadcastManager;
5-
63
import com.quickblox.sample.chat.R;
74
import com.quickblox.sample.chat.ui.activity.SplashActivity;
85
import com.quickblox.sample.core.gcm.CoreGcmPushListenerService;
96
import com.quickblox.sample.core.utils.NotificationUtils;
107
import com.quickblox.sample.core.utils.ResourceUtils;
11-
import com.quickblox.sample.core.utils.constant.GcmConsts;
128

139
public class GcmPushListenerService extends CoreGcmPushListenerService {
1410
private static final int NOTIFICATION_ID = 1;
@@ -19,12 +15,4 @@ protected void showNotification(String message) {
1915
ResourceUtils.getString(R.string.notification_title), message,
2016
R.mipmap.ic_launcher, NOTIFICATION_ID);
2117
}
22-
23-
@Override
24-
protected void sendPushMessageBroadcast(String message) {
25-
Intent gcmBroadcastIntent = new Intent(GcmConsts.ACTION_NEW_GCM_EVENT);
26-
gcmBroadcastIntent.putExtra(GcmConsts.EXTRA_GCM_MESSAGE, message);
27-
28-
LocalBroadcastManager.getInstance(this).sendBroadcast(gcmBroadcastIntent);
29-
}
3018
}

sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/DialogsActivity.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
import com.quickblox.chat.exception.QBChatException;
2929
import com.quickblox.chat.listeners.QBChatDialogMessageListener;
3030
import com.quickblox.chat.listeners.QBSystemMessageListener;
31-
import com.quickblox.chat.model.QBChatMessage;
3231
import com.quickblox.chat.model.QBChatDialog;
32+
import com.quickblox.chat.model.QBChatMessage;
3333
import com.quickblox.core.QBEntityCallback;
3434
import com.quickblox.core.exception.QBResponseException;
3535
import com.quickblox.core.request.QBRequestGetBuilder;
36+
import com.quickblox.messages.services.SubscribeService;
3637
import com.quickblox.sample.chat.R;
38+
import com.quickblox.sample.chat.managers.DialogsManager;
3739
import com.quickblox.sample.chat.ui.adapter.DialogsAdapter;
38-
import com.quickblox.sample.chat.utils.Consts;
3940
import com.quickblox.sample.chat.utils.SharedPreferencesUtil;
40-
import com.quickblox.sample.chat.managers.DialogsManager;
4141
import com.quickblox.sample.chat.utils.chat.ChatHelper;
4242
import com.quickblox.sample.chat.utils.qb.QbChatDialogMessageListenerImp;
4343
import com.quickblox.sample.chat.utils.qb.QbDialogHolder;
@@ -85,9 +85,6 @@ protected void onCreate(Bundle savedInstanceState) {
8585
setContentView(R.layout.activity_dialogs);
8686

8787
googlePlayServicesHelper = new GooglePlayServicesHelper();
88-
if (googlePlayServicesHelper.checkPlayServicesAvailable(this)) {
89-
googlePlayServicesHelper.registerForGcm(Consts.GCM_SENDER_ID);
90-
}
9188

9289
pushBroadcastReceiver = new PushBroadcastReceiver();
9390

@@ -177,7 +174,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
177174
ArrayList<QBUser> selectedUsers = (ArrayList<QBUser>) data
178175
.getSerializableExtra(SelectUsersActivity.EXTRA_QB_USERS);
179176

180-
if (isPrivateDialogExist(selectedUsers)){
177+
if (isPrivateDialogExist(selectedUsers)) {
181178
selectedUsers.remove(ChatHelper.getCurrentUser());
182179
QBChatDialog existingPrivateDialog = QbDialogHolder.getInstance().getPrivateDialogWithUser(selectedUsers.get(0));
183180
isProcessingResultInProgress = false;
@@ -200,7 +197,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
200197
}
201198
}
202199

203-
private boolean isPrivateDialogExist(ArrayList<QBUser> allSelectedUsers){
200+
private boolean isPrivateDialogExist(ArrayList<QBUser> allSelectedUsers) {
204201
ArrayList<QBUser> selectedUsers = new ArrayList<>();
205202
selectedUsers.addAll(allSelectedUsers);
206203
selectedUsers.remove(ChatHelper.getCurrentUser());
@@ -238,9 +235,8 @@ private void userLogout() {
238235
ChatHelper.getInstance().logout(new QBEntityCallback<Void>() {
239236
@Override
240237
public void onSuccess(Void aVoid, Bundle bundle) {
241-
if (googlePlayServicesHelper.checkPlayServicesAvailable()) {
242-
googlePlayServicesHelper.unregisterFromGcm(Consts.GCM_SENDER_ID);
243-
}
238+
SubscribeService.unSubscribeFromPushes(DialogsActivity.this);
239+
244240
SharedPreferencesUtil.removeQbUser();
245241
LoginActivity.start(DialogsActivity.this);
246242
QbDialogHolder.getInstance().clear();
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package com.quickblox.sample.chat.ui.activity;
22

33
import android.os.Bundle;
4-
import android.view.View;
54

6-
import com.quickblox.auth.QBAuth;
7-
import com.quickblox.auth.model.QBSession;
8-
import com.quickblox.core.QBEntityCallback;
9-
import com.quickblox.core.exception.QBResponseException;
105
import com.quickblox.sample.chat.R;
116
import com.quickblox.sample.chat.utils.SharedPreferencesUtil;
127
import com.quickblox.sample.core.ui.activity.CoreSplashActivity;
@@ -17,12 +12,7 @@ public class SplashActivity extends CoreSplashActivity {
1712
protected void onCreate(Bundle savedInstanceState) {
1813
super.onCreate(savedInstanceState);
1914

20-
if (SharedPreferencesUtil.hasQbUser()) {
21-
proceedToTheNextActivityWithDelay();
22-
return;
23-
}
24-
25-
createSession();
15+
proceedToTheNextActivityWithDelay();
2616
}
2717

2818
@Override
@@ -39,23 +29,4 @@ protected void proceedToTheNextActivity() {
3929
}
4030
finish();
4131
}
42-
43-
private void createSession() {
44-
QBAuth.createSession().performAsync(new QBEntityCallback<QBSession>() {
45-
@Override
46-
public void onSuccess(QBSession result, Bundle params) {
47-
proceedToTheNextActivity();
48-
}
49-
50-
@Override
51-
public void onError(QBResponseException e) {
52-
showSnackbarError(null, R.string.splash_create_session_error, e, new View.OnClickListener() {
53-
@Override
54-
public void onClick(View v) {
55-
createSession();
56-
}
57-
});
58-
}
59-
});
60-
}
6132
}

sample-chat/src/main/java/com/quickblox/sample/chat/utils/chat/ChatHelper.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import android.os.Bundle;
44
import android.util.Log;
55

6-
import com.quickblox.auth.QBAuth;
7-
import com.quickblox.auth.model.QBSession;
6+
import com.quickblox.auth.session.QBSettings;
87
import com.quickblox.chat.QBChatService;
98
import com.quickblox.chat.QBRestChatService;
109
import com.quickblox.chat.model.QBAttachment;
11-
import com.quickblox.chat.model.QBChatMessage;
1210
import com.quickblox.chat.model.QBChatDialog;
11+
import com.quickblox.chat.model.QBChatMessage;
1312
import com.quickblox.chat.model.QBDialogType;
1413
import com.quickblox.chat.request.QBDialogRequestBuilder;
1514
import com.quickblox.chat.utils.DialogUtils;
@@ -18,7 +17,6 @@
1817
import com.quickblox.core.LogLevel;
1918
import com.quickblox.core.QBEntityCallback;
2019
import com.quickblox.core.QBProgressCallback;
21-
import com.quickblox.core.QBSettings;
2220
import com.quickblox.core.exception.QBResponseException;
2321
import com.quickblox.core.helper.StringifyArrayList;
2422
import com.quickblox.core.request.QBPagedRequestBuilder;
@@ -79,7 +77,7 @@ private ChatHelper() {
7977
qbChatService.setUseStreamManagement(true);
8078
}
8179

82-
private static QBChatService.ConfigurationBuilder buildChatConfigs(){
80+
private static QBChatService.ConfigurationBuilder buildChatConfigs() {
8381
QBChatService.ConfigurationBuilder configurationBuilder = new QBChatService.ConfigurationBuilder();
8482
configurationBuilder.setKeepAlive(true)
8583
.setSocketTimeout(CHAT_SOCKET_TIMEOUT)
@@ -98,10 +96,10 @@ public void removeConnectionListener(ConnectionListener listener) {
9896

9997
public void login(final QBUser user, final QBEntityCallback<Void> callback) {
10098
// Create REST API session on QuickBlox
101-
QBAuth.createSession(user).performAsync(new QbEntityCallbackTwoTypeWrapper<QBSession, Void>(callback) {
99+
QBUsers.signIn(user).performAsync(new QbEntityCallbackTwoTypeWrapper<QBUser, Void>(callback) {
102100
@Override
103-
public void onSuccess(QBSession session, Bundle args) {
104-
user.setId(session.getUserId());
101+
public void onSuccess(QBUser qbUser, Bundle args) {
102+
user.setId(qbUser.getId());
105103
loginToChat(user, new QbEntityCallbackWrapper<>(callback));
106104
}
107105
});
@@ -126,7 +124,7 @@ public void onError(QBResponseException e) {
126124
});
127125
}
128126

129-
public void join(QBChatDialog chatDialog, final QBEntityCallback<Void> callback){
127+
public void join(QBChatDialog chatDialog, final QBEntityCallback<Void> callback) {
130128
DiscussionHistory history = new DiscussionHistory();
131129
history.setMaxStanzas(0);
132130

@@ -165,7 +163,7 @@ public void deleteDialogs(Collection<QBChatDialog> dialogs, final QBEntityCallba
165163
}
166164

167165
public void deleteDialog(QBChatDialog qbDialog, QBEntityCallback<Void> callback) {
168-
if (qbDialog.getType() == QBDialogType.PUBLIC_GROUP){
166+
if (qbDialog.getType() == QBDialogType.PUBLIC_GROUP) {
169167
Toaster.shortToast(R.string.public_group_chat_cannot_be_deleted);
170168
} else {
171169
QBRestChatService.deleteDialog(qbDialog.getDialogId(), false)
@@ -258,7 +256,7 @@ public void onSuccess(ArrayList<QBChatDialog> dialogs, Bundle args) {
258256
});
259257
}
260258

261-
public void getDialogById(String dialogId, final QBEntityCallback <QBChatDialog> callback) {
259+
public void getDialogById(String dialogId, final QBEntityCallback<QBChatDialog> callback) {
262260
QBRestChatService.getChatDialogById(dialogId).performAsync(callback);
263261
}
264262

sample-chat/src/main/res/values/strings.xml

+2
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,6 @@
6767
<string name="group_chat_join_error">Could not join chat, errors:</string>
6868
<string name="public_group_chat_cannot_be_deleted">Public Group chat can be deleted only by owner</string>
6969
<string name="error_leave_chat">Error leaving room</string>
70+
71+
<string name="sender_id">761750217637</string>
7072
</resources>

sample-content/src/main/java/com/quickblox/sample/content/activities/SplashActivity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import android.view.View;
55

66
import com.quickblox.auth.QBAuth;
7-
import com.quickblox.auth.model.QBSession;
7+
import com.quickblox.auth.session.QBSession;
88
import com.quickblox.core.QBEntityCallback;
99
import com.quickblox.core.exception.QBResponseException;
1010
import com.quickblox.sample.content.R;

sample-core/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ android {
1919
dependencies {
2020
compile ("com.quickblox:quickblox-android-sdk-messages:$rootProject.qbSdkVersion" )
2121

22-
compile "com.google.android.gms:play-services-gcm:${rootProject.playServicesVersion}"
2322
compile "com.android.support:design:${rootProject.designVersion}"
2423
compile "com.github.johnkil.android-robototextview:robototextview:${rootProject.robotoTextViewVersion}"
2524

sample-core/src/main/java/com/quickblox/sample/core/CoreApp.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import android.app.Application;
44

5-
import com.quickblox.core.QBSettings;
5+
import com.quickblox.auth.session.QBSettings;
6+
67

78
public class CoreApp extends Application {
89

sample-core/src/main/java/com/quickblox/sample/core/gcm/CoreGcmPushInstanceIDService.java

-16
This file was deleted.

sample-core/src/main/java/com/quickblox/sample/core/gcm/CoreGcmPushListenerService.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@
33
import android.os.Bundle;
44
import android.util.Log;
55

6-
import com.google.android.gms.gcm.GcmListenerService;
7-
import com.quickblox.sample.core.CoreApp;
6+
import com.quickblox.messages.services.gcm.QBGcmPushListenerService;
87
import com.quickblox.sample.core.utils.ActivityLifecycle;
9-
import com.quickblox.sample.core.utils.constant.GcmConsts;
108

11-
public abstract class CoreGcmPushListenerService extends GcmListenerService {
9+
public abstract class CoreGcmPushListenerService extends QBGcmPushListenerService {
1210
private static final String TAG = CoreGcmPushListenerService.class.getSimpleName();
1311

1412
@Override
15-
public void onMessageReceived(String from, Bundle data) {
16-
String message = data.getString(GcmConsts.EXTRA_GCM_MESSAGE);
13+
public void sendPushMessage(Bundle data, String from, String message) {
14+
super.sendPushMessage(data, from, message);
1715
Log.v(TAG, "From: " + from);
1816
Log.v(TAG, "Message: " + message);
1917

2018
if (ActivityLifecycle.getInstance().isBackground()) {
2119
showNotification(message);
2220
}
23-
24-
sendPushMessageBroadcast(message);
2521
}
2622

2723
protected abstract void showNotification(String message);
28-
29-
protected abstract void sendPushMessageBroadcast(String message);
3024
}

0 commit comments

Comments
 (0)