Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
vfite committed Jan 11, 2017
2 parents 56c3074 + af80d46 commit 61fa6ff
Show file tree
Hide file tree
Showing 114 changed files with 1,305 additions and 424 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
Expand Down Expand Up @@ -32,15 +32,15 @@ ext {
lintAbortOnError = false

// QuickBlox SDK version
qbSdkVersion = '3.2.0'
qbSdkVersion = '3.3.0'

versionName = '3.2.0'
versionName = '3.3.0'

testRunnerVersion = '0.4.1'
testRunnerVersion = "0.4.1"


// Dependency versions
playServicesVersion = '9.8.0'
playServicesVersion = '10.0.1'
supportV4Version = '23.1.1'
appcompatV7Version = '23.1.1'
recyclerviewV7Version = '23.2.1'
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ org.gradle.daemon=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.parallel=true
org.gradle.configureondemand=true
10 changes: 10 additions & 0 deletions sample-chat/src/main/assets/qb_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app_id": "92",
"auth_key": "wJHdOcQSxXQGWx5",
"auth_secret": "BTFsj7Rtt27DAmT",
"account_key": "rz2sXxBt5xgSxGjALDW6",
"api_domain": "https://api.quickblox.com",
"chat_domain": "chat.quickblox.com",
"gcm_sender_id": "761750217637"
}

13 changes: 13 additions & 0 deletions sample-chat/src/main/assets/sample_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"users_tag": "webrtcusers",
"users_password": "x6Bt0VDy5",
"port": 5223,
"socket_timeout": 120,
"keep_alive": true,
"use_tls": true,
"auto_join": false,
"auto_mark_delivered": true,
"reconnection_allowed": true,
"allow_listen_network": true
}

19 changes: 18 additions & 1 deletion sample-chat/src/main/java/com/quickblox/sample/chat/App.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
package com.quickblox.sample.chat;

import com.quickblox.sample.chat.models.SampleConfigs;
import com.quickblox.sample.chat.utils.Consts;
import com.quickblox.sample.chat.utils.configs.ConfigUtils;
import com.quickblox.sample.core.CoreApp;
import com.quickblox.sample.core.utils.ActivityLifecycle;

import java.io.IOException;

public class App extends CoreApp {
private static final String TAG = App.class.getSimpleName();
private static SampleConfigs sampleConfigs;

@Override
public void onCreate() {
super.onCreate();
ActivityLifecycle.init(this);
initCredentials(Consts.QB_APP_ID, Consts.QB_AUTH_KEY, Consts.QB_AUTH_SECRET, Consts.QB_ACCOUNT_KEY);
initSampleConfigs();
}

private void initSampleConfigs() {
try {
sampleConfigs = ConfigUtils.getSampleConfigs(Consts.SAMPLE_CONFIG_FILE_NAME);
} catch (IOException e) {
e.printStackTrace();
}
}

public static SampleConfigs getSampleConfigs() {
return sampleConfigs;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.quickblox.sample.chat.managers;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

import com.quickblox.chat.QBChatService;
import com.quickblox.chat.QBSystemMessagesManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package com.quickblox.sample.chat.models;

import com.google.gson.annotations.SerializedName;

public class SampleConfigs {

public SampleConfigs() {
}

@SerializedName("users_tag")
private String usersTag;

@SerializedName("users_password")
private String usersPassword;

@SerializedName("port")
private int chatPort;

@SerializedName("socket_timeout")
private int chatSocketTimeout;

@SerializedName("keep_alive")
private boolean keepAlive;

@SerializedName("use_tls")
private boolean useTls;

@SerializedName("auto_join")
private boolean autoJoinEnabled;

@SerializedName("auto_mark_delivered")
private boolean autoMarkDelivered;

@SerializedName("reconnection_allowed")
private boolean reconnectionAllowed;

@SerializedName("allow_listen_network")
private boolean allowListenNetwork;

public String getUsersTag() {
return usersTag;
}

public void setUsersTag(String usersTag) {
this.usersTag = usersTag;
}

public String getUsersPassword() {
return usersPassword;
}

public void setUsersPassword(String usersPassword) {
this.usersPassword = usersPassword;
}

public int getChatPort() {
return chatPort;
}

public void setChatPort(int chatPort) {
this.chatPort = chatPort;
}

public int getChatSocketTimeout() {
return chatSocketTimeout;
}

public void setChatSocketTimeout(int chatSocketTimeout) {
this.chatSocketTimeout = chatSocketTimeout;
}

public boolean isKeepAlive() {
return keepAlive;
}

public void setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
}

public boolean isUseTls() {
return useTls;
}

public void setUseTls(boolean useTls) {
this.useTls = useTls;
}

public boolean isAutoJoinEnabled() {
return autoJoinEnabled;
}

public void setAutoJoinEnabled(boolean autoJoinEnabled) {
this.autoJoinEnabled = autoJoinEnabled;
}

public boolean isAutoMarkDelivered() {
return autoMarkDelivered;
}

public void setAutoMarkDelivered(boolean autoMarkDelivered) {
this.autoMarkDelivered = autoMarkDelivered;
}

public boolean isReconnectionAllowed() {
return reconnectionAllowed;
}

public void setReconnectionAllowed(boolean reconnectionAllowed) {
this.reconnectionAllowed = reconnectionAllowed;
}

public boolean isAllowListenNetwork() {
return allowListenNetwork;
}

public void setAllowListenNetwork(boolean allowListenNetwork) {
this.allowListenNetwork = allowListenNetwork;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.quickblox.chat.QBChatService;
import com.quickblox.chat.model.QBAttachment;
import com.quickblox.chat.model.QBChatMessage;
import com.quickblox.chat.model.QBChatDialog;
Expand Down Expand Up @@ -74,7 +75,7 @@ public class ChatActivity extends BaseActivity implements OnImagePickedListener
private int skipPagination = 0;
private ChatMessageListener chatMessageListener;

public static void startForResult(Activity activity, int code, String dialogId) {
public static void startForResult(Activity activity, int code, QBChatDialog dialogId) {
Intent intent = new Intent(activity, ChatActivity.class);
intent.putExtra(ChatActivity.EXTRA_DIALOG_ID, dialogId);
activity.startActivityForResult(intent, code);
Expand All @@ -85,10 +86,13 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);

Log.v("ChatHelper", "onCreate ChatActivity on Thread ID = " + Thread.currentThread().getId());
Log.v(TAG, "onCreate ChatActivity on Thread ID = " + Thread.currentThread().getId());

qbChatDialog = (QBChatDialog) getIntent().getSerializableExtra(EXTRA_DIALOG_ID);

Log.v(TAG, "deserialized dialog = " + qbChatDialog);
qbChatDialog.initForChat(QBChatService.getInstance());

qbChatDialog = QbDialogHolder.getInstance().getChatDialogById(
getIntent().getStringExtra(EXTRA_DIALOG_ID));
chatMessageListener = new ChatMessageListener();

qbChatDialog.addMessageListener(chatMessageListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.quickblox.sample.chat.utils.qb.QbUsersHolder;
import com.quickblox.users.model.QBUser;

import java.util.ArrayList;
import java.util.List;

public class ChatInfoActivity extends BaseActivity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
selectedUsers.remove(ChatHelper.getCurrentUser());
QBChatDialog existingPrivateDialog = QbDialogHolder.getInstance().getPrivateDialogWithUser(selectedUsers.get(0));
isProcessingResultInProgress = false;
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, existingPrivateDialog.getDialogId());
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, existingPrivateDialog);
} else {
ProgressDialogFragment.show(getSupportFragmentManager(), R.string.create_chat);
createDialog(selectedUsers);
Expand Down Expand Up @@ -310,7 +310,7 @@ private void initUi() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
QBChatDialog selectedDialog = (QBChatDialog) parent.getItemAtPosition(position);
if (currentActionMode == null) {
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, selectedDialog.getDialogId());
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, selectedDialog);
} else {
dialogsAdapter.toggleSelection(selectedDialog);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ private void createDialog(final ArrayList<QBUser> selectedUsers) {
public void onSuccess(QBChatDialog dialog, Bundle args) {
isProcessingResultInProgress = false;
dialogsManager.sendSystemMessageAboutCreatingDialog(systemMessagesManager, dialog);
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, dialog.getDialogId());
ChatActivity.startForResult(DialogsActivity.this, REQUEST_DIALOG_ID_FOR_UPDATE, dialog);
ProgressDialogFragment.hide(getSupportFragmentManager());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

import com.quickblox.core.QBEntityCallback;
import com.quickblox.core.exception.QBResponseException;
import com.quickblox.sample.chat.App;
import com.quickblox.sample.chat.R;
import com.quickblox.sample.chat.ui.adapter.UsersAdapter;
import com.quickblox.sample.chat.utils.Consts;
import com.quickblox.sample.chat.utils.SharedPreferencesUtil;
import com.quickblox.sample.chat.utils.chat.ChatHelper;
import com.quickblox.sample.core.ui.activity.CoreBaseActivity;
Expand Down Expand Up @@ -53,7 +53,8 @@ protected void onCreate(Bundle savedInstanceState) {

private void buildUsersList() {
List<String> tags = new ArrayList<>();
tags.add(Consts.QB_USERS_TAG);

tags.add(App.getSampleConfigs().getUsersTag());

QBUsers.getUsersByTags(tags, null).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
@Override
Expand Down Expand Up @@ -116,7 +117,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
final QBUser user = (QBUser) parent.getItemAtPosition(position);
// We use hardcoded password for all users for test purposes
// Of course you shouldn't do that in your app
user.setPassword(Consts.QB_USERS_PASSWORD);
user.setPassword(App.getSampleConfigs().getUsersPassword());

login(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import com.quickblox.chat.model.QBChatDialog;
import com.quickblox.core.QBEntityCallback;
import com.quickblox.core.exception.QBResponseException;
import com.quickblox.sample.chat.App;
import com.quickblox.sample.chat.R;
import com.quickblox.sample.chat.ui.adapter.CheckboxUsersAdapter;
import com.quickblox.sample.chat.utils.Consts;
import com.quickblox.sample.core.utils.Toaster;
import com.quickblox.users.QBUsers;
import com.quickblox.users.model.QBUser;
Expand Down Expand Up @@ -136,7 +136,7 @@ private void passResultToCallerActivity() {

private void loadUsersFromQb() {
List<String> tags = new ArrayList<>();
tags.add(Consts.QB_USERS_TAG);
tags.add(App.getSampleConfigs().getUsersTag());

progressBar.setVisibility(View.VISIBLE);
QBUsers.getUsersByTags(tags, null).performAsync(new QBEntityCallback<ArrayList<QBUser>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;

import com.quickblox.sample.chat.App;
import com.quickblox.sample.chat.R;
import com.quickblox.sample.chat.utils.SharedPreferencesUtil;
import com.quickblox.sample.core.ui.activity.CoreSplashActivity;
Expand All @@ -12,7 +13,9 @@ public class SplashActivity extends CoreSplashActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

proceedToTheNextActivityWithDelay();
if (checkConfigsWithSnackebarError()){
proceedToTheNextActivityWithDelay();
}
}

@Override
Expand All @@ -29,4 +32,11 @@ protected void proceedToTheNextActivity() {
}
finish();
}

@Override
protected boolean sampleConfigIsCorrect() {
boolean result = super.sampleConfigIsCorrect();
result = result && App.getSampleConfigs() != null;
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
import com.quickblox.sample.core.utils.ResourceUtils;

public interface Consts {
// In GCM, the Sender ID is a project ID that you acquire from the API console
String GCM_SENDER_ID = "761750217637";

String QB_APP_ID = "92";
String QB_AUTH_KEY = "wJHdOcQSxXQGWx5";
String QB_AUTH_SECRET = "BTFsj7Rtt27DAmT";
String QB_ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6";

String QB_USERS_TAG = "webrtcusers";
String QB_USERS_PASSWORD = "x6Bt0VDy5";
String SAMPLE_CONFIG_FILE_NAME = "sample_config.json";

int PREFERRED_IMAGE_SIZE_PREVIEW = ResourceUtils.getDimen(R.dimen.chat_attachment_preview_size);
int PREFERRED_IMAGE_SIZE_FULL = ResourceUtils.dpToPx(320);
Expand Down
Loading

0 comments on commit 61fa6ff

Please sign in to comment.