diff --git a/build.gradle b/build.gradle index d8849a0ce..48ad3aded 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } @@ -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' diff --git a/gradle.properties b/gradle.properties index 6fbd269e3..ba5806c05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +org.gradle.parallel=true +org.gradle.configureondemand=true \ No newline at end of file diff --git a/sample-chat/src/main/assets/qb_config.json b/sample-chat/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-chat/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-chat/src/main/assets/sample_config.json b/sample-chat/src/main/assets/sample_config.json new file mode 100644 index 000000000..6729de9fc --- /dev/null +++ b/sample-chat/src/main/assets/sample_config.json @@ -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 +} + diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/App.java b/sample-chat/src/main/java/com/quickblox/sample/chat/App.java index a6afca4d1..188abe4eb 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/App.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/App.java @@ -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; } } \ No newline at end of file diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/managers/DialogsManager.java b/sample-chat/src/main/java/com/quickblox/sample/chat/managers/DialogsManager.java index b9dcf7621..f967e92fe 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/managers/DialogsManager.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/managers/DialogsManager.java @@ -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; diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/models/SampleConfigs.java b/sample-chat/src/main/java/com/quickblox/sample/chat/models/SampleConfigs.java new file mode 100644 index 000000000..5e40d7fe9 --- /dev/null +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/models/SampleConfigs.java @@ -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; + } +} diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatActivity.java index 5d185a6f4..157a015db 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatActivity.java @@ -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; @@ -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); @@ -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); diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatInfoActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatInfoActivity.java index f9076d7a2..539412e76 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatInfoActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/ChatInfoActivity.java @@ -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 { diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/DialogsActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/DialogsActivity.java index a65511a94..fb3cc0c25 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/DialogsActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/DialogsActivity.java @@ -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); @@ -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); } @@ -372,7 +372,7 @@ private void createDialog(final ArrayList 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()); } diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/LoginActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/LoginActivity.java index 8ed6f775e..603e0edd5 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/LoginActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/LoginActivity.java @@ -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; @@ -53,7 +53,8 @@ protected void onCreate(Bundle savedInstanceState) { private void buildUsersList() { List tags = new ArrayList<>(); - tags.add(Consts.QB_USERS_TAG); + + tags.add(App.getSampleConfigs().getUsersTag()); QBUsers.getUsersByTags(tags, null).performAsync(new QBEntityCallback>() { @Override @@ -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); } diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SelectUsersActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SelectUsersActivity.java index b5ad733c2..aa305693b 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SelectUsersActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SelectUsersActivity.java @@ -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; @@ -136,7 +136,7 @@ private void passResultToCallerActivity() { private void loadUsersFromQb() { List 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>() { diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SplashActivity.java b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SplashActivity.java index 714ab6304..ca3879e64 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SplashActivity.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/ui/activity/SplashActivity.java @@ -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; @@ -12,7 +13,9 @@ public class SplashActivity extends CoreSplashActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - proceedToTheNextActivityWithDelay(); + if (checkConfigsWithSnackebarError()){ + proceedToTheNextActivityWithDelay(); + } } @Override @@ -29,4 +32,11 @@ protected void proceedToTheNextActivity() { } finish(); } + + @Override + protected boolean sampleConfigIsCorrect() { + boolean result = super.sampleConfigIsCorrect(); + result = result && App.getSampleConfigs() != null; + return result; + } } \ No newline at end of file diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/utils/Consts.java b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/Consts.java index b474c3911..c6e662efb 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/utils/Consts.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/Consts.java @@ -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); diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/utils/chat/ChatHelper.java b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/chat/ChatHelper.java index 2b4f21cf2..d9389fe82 100644 --- a/sample-chat/src/main/java/com/quickblox/sample/chat/utils/chat/ChatHelper.java +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/chat/ChatHelper.java @@ -21,7 +21,9 @@ import com.quickblox.core.helper.StringifyArrayList; import com.quickblox.core.request.QBPagedRequestBuilder; import com.quickblox.core.request.QBRequestGetBuilder; +import com.quickblox.sample.chat.App; import com.quickblox.sample.chat.R; +import com.quickblox.sample.chat.models.SampleConfigs; import com.quickblox.sample.chat.utils.SharedPreferencesUtil; import com.quickblox.sample.chat.utils.qb.QbDialogHolder; import com.quickblox.sample.chat.utils.qb.QbDialogUtils; @@ -48,8 +50,6 @@ public class ChatHelper { private static final String TAG = ChatHelper.class.getSimpleName(); - private static final int CHAT_SOCKET_TIMEOUT = 0; - public static final int DIALOG_ITEMS_PER_PAGE = 100; public static final int CHAT_HISTORY_ITEMS_PER_PAGE = 50; private static final String CHAT_HISTORY_ITEMS_SORT_FIELD = "date_sent"; @@ -77,11 +77,32 @@ private ChatHelper() { qbChatService.setUseStreamManagement(true); } - private static QBChatService.ConfigurationBuilder buildChatConfigs() { + private static QBChatService.ConfigurationBuilder buildChatConfigs(){ QBChatService.ConfigurationBuilder configurationBuilder = new QBChatService.ConfigurationBuilder(); - configurationBuilder.setKeepAlive(true) - .setSocketTimeout(CHAT_SOCKET_TIMEOUT) - .setAutojoinEnabled(false); + SampleConfigs sampleConfigs = App.getSampleConfigs(); + + if (sampleConfigs != null) { + int port = sampleConfigs.getChatPort(); + int socketTimeout = sampleConfigs.getChatSocketTimeout(); + boolean useTls = sampleConfigs.isUseTls(); + boolean keepAlive = sampleConfigs.isKeepAlive(); + boolean autoJoinEnabled = sampleConfigs.isAutoJoinEnabled(); + boolean autoMarkDelivered = sampleConfigs.isAutoMarkDelivered(); + boolean reconnectionAllowed = sampleConfigs.isReconnectionAllowed(); + boolean allowListenNetwork = sampleConfigs.isAllowListenNetwork(); + + if (port != 0) { + configurationBuilder.setPort(port); + } + + configurationBuilder.setSocketTimeout(socketTimeout); + configurationBuilder.setUseTls(useTls); + configurationBuilder.setKeepAlive(keepAlive); + configurationBuilder.setAutojoinEnabled(autoJoinEnabled); + configurationBuilder.setAutoMarkDelivered(autoMarkDelivered); + configurationBuilder.setReconnectionAllowed(reconnectionAllowed); + configurationBuilder.setAllowListenNetwork(allowListenNetwork); + } return configurationBuilder; } @@ -111,17 +132,7 @@ private void loginToChat(final QBUser user, final QBEntityCallback callbac return; } - qbChatService.login(user, new QbEntityCallbackWrapper(callback) { - @Override - public void onSuccess(Void o, Bundle bundle) { - super.onSuccess(o, bundle); - } - - @Override - public void onError(QBResponseException e) { - super.onError(e); - } - }); + qbChatService.login(user, callback); } public void join(QBChatDialog chatDialog, final QBEntityCallback callback) { @@ -163,7 +174,7 @@ public void deleteDialogs(Collection dialogs, final QBEntityCallba } public void deleteDialog(QBChatDialog qbDialog, QBEntityCallback callback) { - if (qbDialog.getType() == QBDialogType.PUBLIC_GROUP) { + if (qbDialog.getType() == QBDialogType.PUBLIC_GROUP){ Toaster.shortToast(R.string.public_group_chat_cannot_be_deleted); } else { QBRestChatService.deleteDialog(qbDialog.getDialogId(), false) @@ -256,7 +267,7 @@ public void onSuccess(ArrayList dialogs, Bundle args) { }); } - public void getDialogById(String dialogId, final QBEntityCallback callback) { + public void getDialogById(String dialogId, final QBEntityCallback callback) { QBRestChatService.getChatDialogById(dialogId).performAsync(callback); } diff --git a/sample-chat/src/main/java/com/quickblox/sample/chat/utils/configs/ConfigUtils.java b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/configs/ConfigUtils.java new file mode 100644 index 000000000..62f18831f --- /dev/null +++ b/sample-chat/src/main/java/com/quickblox/sample/chat/utils/configs/ConfigUtils.java @@ -0,0 +1,17 @@ +package com.quickblox.sample.chat.utils.configs; + +import com.google.gson.Gson; +import com.quickblox.sample.chat.models.SampleConfigs; +import com.quickblox.sample.core.utils.configs.ConfigParser; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; + +import java.io.IOException; + +public class ConfigUtils extends CoreConfigUtils { + + public static SampleConfigs getSampleConfigs(String fileName) throws IOException { + ConfigParser configParser = new ConfigParser(); + Gson gson = new Gson(); + return gson.fromJson(configParser.getConfigsAsJsonString(fileName), SampleConfigs.class); + } +} diff --git a/sample-content/src/main/assets/qb_config.json b/sample-content/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-content/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-content/src/main/assets/sample_config.json b/sample-content/src/main/assets/sample_config.json new file mode 100644 index 000000000..235f452e0 --- /dev/null +++ b/sample-content/src/main/assets/sample_config.json @@ -0,0 +1,4 @@ +{ + "user_login": "bobbobbob", + "user_password": "bobbobbob" +} \ No newline at end of file diff --git a/sample-content/src/main/java/com/quickblox/sample/content/App.java b/sample-content/src/main/java/com/quickblox/sample/content/App.java index dbea8256c..f5c5dd734 100644 --- a/sample-content/src/main/java/com/quickblox/sample/content/App.java +++ b/sample-content/src/main/java/com/quickblox/sample/content/App.java @@ -1,6 +1,5 @@ package com.quickblox.sample.content; -import com.quickblox.sample.content.utils.Consts; import com.quickblox.sample.core.CoreApp; public class App extends CoreApp { @@ -8,6 +7,5 @@ public class App extends CoreApp { @Override public void onCreate() { super.onCreate(); - initCredentials(Consts.QB_APP_ID, Consts.QB_AUTH_KEY, Consts.QB_AUTH_SECRET, Consts.QB_ACCOUNT_KEY); } } diff --git a/sample-content/src/main/java/com/quickblox/sample/content/activities/SplashActivity.java b/sample-content/src/main/java/com/quickblox/sample/content/activities/SplashActivity.java index ef38f60c5..c9097a60a 100644 --- a/sample-content/src/main/java/com/quickblox/sample/content/activities/SplashActivity.java +++ b/sample-content/src/main/java/com/quickblox/sample/content/activities/SplashActivity.java @@ -10,6 +10,7 @@ import com.quickblox.sample.content.R; import com.quickblox.sample.content.utils.Consts; import com.quickblox.sample.core.ui.activity.CoreSplashActivity; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.users.model.QBUser; public class SplashActivity extends CoreSplashActivity { @@ -17,12 +18,15 @@ public class SplashActivity extends CoreSplashActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - createSession(); + + if (checkConfigsWithSnackebarError()){ + createSession(); + } } private void createSession() { + QBUser qbUser = CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME); - QBUser qbUser = new QBUser(Consts.USER_LOGIN, Consts.USER_PASSWORD); QBAuth.createSession(qbUser).performAsync(new QBEntityCallback() { @Override public void onSuccess(QBSession qbSession, Bundle bundle) { @@ -51,4 +55,11 @@ protected void proceedToTheNextActivity() { GalleryActivity.start(this); finish(); } + + @Override + protected boolean sampleConfigIsCorrect() { + boolean result = super.sampleConfigIsCorrect(); + result = result && CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME) != null; + return result; + } } \ No newline at end of file diff --git a/sample-content/src/main/java/com/quickblox/sample/content/utils/Consts.java b/sample-content/src/main/java/com/quickblox/sample/content/utils/Consts.java index e98bb0ff1..2b88634e3 100644 --- a/sample-content/src/main/java/com/quickblox/sample/content/utils/Consts.java +++ b/sample-content/src/main/java/com/quickblox/sample/content/utils/Consts.java @@ -5,13 +5,9 @@ public interface Consts { - String QB_APP_ID = "92"; - String QB_AUTH_KEY = "wJHdOcQSxXQGWx5"; - String QB_AUTH_SECRET = "BTFsj7Rtt27DAmT"; - String QB_ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6"; - - String USER_LOGIN = "bobbobbob"; - String USER_PASSWORD = "bobbobbob"; + String USER_LOGIN_FIELD_NAME = "user_login"; + String USER_PASSWORD_FIELD_NAME = "user_password"; + String SAMPLE_CONFIG_FILE_NAME = "sample_config.json"; int PREFERRED_IMAGE_WIDTH_PREVIEW = ResourceUtils.getDimen(R.dimen.item_gallery_width); int PREFERRED_IMAGE_HEIGHT_PREVIEW = ResourceUtils.getDimen(R.dimen.item_gallery_height); diff --git a/sample-content/src/main/res/values/strings.xml b/sample-content/src/main/res/values/strings.xml index d14cf055e..3d6d60978 100644 --- a/sample-content/src/main/res/values/strings.xml +++ b/sample-content/src/main/res/values/strings.xml @@ -3,6 +3,7 @@ Content Content Sample Errors + Initializing configs error Upload image errors: Pick image errors: diff --git a/sample-core/src/main/assets/qb_config.json b/sample-core/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-core/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-core/src/main/java/com/quickblox/sample/core/CoreApp.java b/sample-core/src/main/java/com/quickblox/sample/core/CoreApp.java index e6a77a1fe..d17c5f13a 100644 --- a/sample-core/src/main/java/com/quickblox/sample/core/CoreApp.java +++ b/sample-core/src/main/java/com/quickblox/sample/core/CoreApp.java @@ -1,26 +1,55 @@ package com.quickblox.sample.core; import android.app.Application; +import android.text.TextUtils; +import android.util.Log; import com.quickblox.auth.session.QBSettings; - +import com.quickblox.core.ServiceZone; +import com.quickblox.sample.core.models.QbConfigs; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; public class CoreApp extends Application { + public static final String TAG = CoreApp.class.getSimpleName(); private static CoreApp instance; + private static final String QB_CONFIG_DEFAULT_FILE_NAME = "qb_config.json"; + private QbConfigs qbConfigs; @Override public void onCreate() { super.onCreate(); instance = this; + initQbConfigs(); + initCredentials(); + } + + private void initQbConfigs() { + Log.e(TAG, "QB CONFIG FILE NAME: " + getQbConfigFileName()); + qbConfigs = CoreConfigUtils.getCoreConfigsOrNull(getQbConfigFileName()); } public static synchronized CoreApp getInstance() { return instance; } - public void initCredentials(String APP_ID, String AUTH_KEY, String AUTH_SECRET, String ACCOUNT_KEY) { - QBSettings.getInstance().init(getApplicationContext(), APP_ID, AUTH_KEY, AUTH_SECRET); - QBSettings.getInstance().setAccountKey(ACCOUNT_KEY); + public void initCredentials(){ + if (qbConfigs != null) { + QBSettings.getInstance().init(getApplicationContext(), qbConfigs.getAppId(), qbConfigs.getAuthKey(), qbConfigs.getAuthSecret()); + QBSettings.getInstance().setAccountKey(qbConfigs.getAccountKey()); + + if (!TextUtils.isEmpty(qbConfigs.getApiDomain()) && !TextUtils.isEmpty(qbConfigs.getChatDomain())) { + QBSettings.getInstance().setEndpoints(qbConfigs.getApiDomain(), qbConfigs.getChatDomain(), ServiceZone.PRODUCTION); + QBSettings.getInstance().setZone(ServiceZone.PRODUCTION); + } + } + } + + public QbConfigs getQbConfigs(){ + return qbConfigs; + } + + protected String getQbConfigFileName(){ + return QB_CONFIG_DEFAULT_FILE_NAME; } } \ No newline at end of file diff --git a/sample-core/src/main/java/com/quickblox/sample/core/models/QbConfigs.java b/sample-core/src/main/java/com/quickblox/sample/core/models/QbConfigs.java new file mode 100644 index 000000000..33c0d49d6 --- /dev/null +++ b/sample-core/src/main/java/com/quickblox/sample/core/models/QbConfigs.java @@ -0,0 +1,90 @@ +package com.quickblox.sample.core.models; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class QbConfigs implements Serializable{ + + public QbConfigs() { + } + + @SerializedName("app_id") + private String appId; + + @SerializedName("auth_key") + private String authKey; + + @SerializedName("auth_secret") + private String authSecret; + + @SerializedName("account_key") + private String accountKey; + + @SerializedName("api_domain") + private String apiDomain; + + @SerializedName("chat_domain") + private String chatDomain; + + @SerializedName("gcm_sender_id") + private String gcmSenderId; + + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getAuthKey() { + return authKey; + } + + public void setAuthKey(String authKey) { + this.authKey = authKey; + } + + public String getAuthSecret() { + return authSecret; + } + + public void setAuthSecret(String authSecret) { + this.authSecret = authSecret; + } + + public String getAccountKey() { + return accountKey; + } + + public void setAccountKey(String accountKey) { + this.accountKey = accountKey; + } + + public String getApiDomain() { + return apiDomain; + } + + public void setApiDomain(String apiDomain) { + this.apiDomain = apiDomain; + } + + public String getChatDomain() { + return chatDomain; + } + + public void setChatDomain(String chatDomain) { + this.chatDomain = chatDomain; + } + + public String getGcmSenderId() { + return gcmSenderId; + } + + public void setGcmSenderId(String gcmSenderId) { + this.gcmSenderId = gcmSenderId; + } + +} diff --git a/sample-core/src/main/java/com/quickblox/sample/core/ui/activity/CoreSplashActivity.java b/sample-core/src/main/java/com/quickblox/sample/core/ui/activity/CoreSplashActivity.java index 44a77d93e..fa92b4eb3 100644 --- a/sample-core/src/main/java/com/quickblox/sample/core/ui/activity/CoreSplashActivity.java +++ b/sample-core/src/main/java/com/quickblox/sample/core/ui/activity/CoreSplashActivity.java @@ -9,6 +9,7 @@ import android.widget.TextView; import com.quickblox.core.exception.QBResponseException; +import com.quickblox.sample.core.CoreApp; import com.quickblox.sample.core.R; import com.quickblox.sample.core.utils.ErrorUtils; import com.quickblox.sample.core.utils.VersionUtils; @@ -39,6 +40,10 @@ protected void onCreate(Bundle savedInstanceState) { protected abstract void proceedToTheNextActivity(); + protected boolean sampleConfigIsCorrect(){ + return CoreApp.getInstance().getQbConfigs() != null; + } + protected void proceedToTheNextActivityWithDelay() { mainThreadHandler.postDelayed(new Runnable() { @Override @@ -48,9 +53,22 @@ public void run() { }, SPLASH_DELAY); } + protected boolean checkConfigsWithSnackebarError(){ + if (!sampleConfigIsCorrect()){ + showSnackbarErrorParsingConfigs(); + return false; + } + + return true; + } + @Override protected void showSnackbarError(View rootLayout, @StringRes int resId, QBResponseException e, View.OnClickListener clickListener) { rootLayout = findViewById(R.id.layout_root); ErrorUtils.showSnackbar(rootLayout, resId, e, R.string.dlg_retry, clickListener); } + + protected void showSnackbarErrorParsingConfigs(){ + ErrorUtils.showSnackbar(findViewById(R.id.layout_root), R.string.error_parsing_configs, R.string.dlg_ok, null); + } } diff --git a/sample-core/src/main/java/com/quickblox/sample/core/utils/AssetsUtils.java b/sample-core/src/main/java/com/quickblox/sample/core/utils/AssetsUtils.java new file mode 100644 index 000000000..316758d5d --- /dev/null +++ b/sample-core/src/main/java/com/quickblox/sample/core/utils/AssetsUtils.java @@ -0,0 +1,28 @@ +package com.quickblox.sample.core.utils; + +import android.content.Context; +import android.content.res.AssetManager; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public class AssetsUtils { + + public static String getJsonAsString(String filename, Context context) throws IOException { + AssetManager manager = context.getAssets(); + StringBuilder buf = new StringBuilder(); + InputStream json = manager.open(filename); + BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8")); + String str; + + while ((str=in.readLine()) != null) { + buf.append(str); + } + + in.close(); + + return buf.toString(); + } +} diff --git a/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/ConfigParser.java b/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/ConfigParser.java new file mode 100644 index 000000000..219ef1f9a --- /dev/null +++ b/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/ConfigParser.java @@ -0,0 +1,32 @@ +package com.quickblox.sample.core.utils.configs; + +import android.content.Context; + +import com.quickblox.sample.core.CoreApp; +import com.quickblox.sample.core.utils.AssetsUtils; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class ConfigParser { + + private Context context; + + public ConfigParser() { + context = CoreApp.getInstance().getApplicationContext(); + } + + public String getConfigsAsJsonString(String fileName) throws IOException { + return AssetsUtils.getJsonAsString(fileName, context); + } + + public JSONObject getConfigsAsJson(String fileName) throws IOException, JSONException { + return new JSONObject(getConfigsAsJsonString(fileName)); + } + + public String getConfigByName(JSONObject jsonObject, String fieldName) throws JSONException { + return jsonObject.getString(fieldName); + } +} diff --git a/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/CoreConfigUtils.java b/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/CoreConfigUtils.java new file mode 100644 index 000000000..9606fae44 --- /dev/null +++ b/sample-core/src/main/java/com/quickblox/sample/core/utils/configs/CoreConfigUtils.java @@ -0,0 +1,75 @@ +package com.quickblox.sample.core.utils.configs; + +import android.text.TextUtils; + +import com.google.gson.Gson; +import com.quickblox.sample.core.models.QbConfigs; +import com.quickblox.users.model.QBUser; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; + +public class CoreConfigUtils { + + public static final String USER_LOGIN_FIELD_NAME = "user_login"; + public static final String USER_PASSWORD_FIELD_NAME = "user_password"; + + public static QbConfigs getCoreConfigs(String fileName) throws IOException { + ConfigParser configParser = new ConfigParser(); + Gson gson = new Gson(); + return gson.fromJson(configParser.getConfigsAsJsonString(fileName), QbConfigs.class); + } + + public static QbConfigs getCoreConfigsOrNull(String fileName){ + QbConfigs qbConfigs = null; + + try { + qbConfigs = getCoreConfigs(fileName); + } catch (IOException e) { + e.printStackTrace(); + } + + return qbConfigs; + } + + public static String getStringConfigFromFile(String fileName, String fieldName) throws IOException, JSONException { + JSONObject appConfigs = new ConfigParser().getConfigsAsJson(fileName); + return appConfigs.getString(fieldName); + } + + public static String getStringConfigFromFileOrNull(String fileName, String fieldName) { + String fieldValue = null; + + try { + fieldValue = getStringConfigFromFile(fileName, fieldName); + } catch (IOException | JSONException e) { + e.printStackTrace(); + } + + return fieldValue; + } + + public static boolean isStringConfigFromFileNotEmpty(String fileName, String fieldName){ + return !TextUtils.isEmpty(getStringConfigFromFileOrNull(fileName, fieldName)); + } + + public static QBUser getUserFromConfig(String fileName){ + QBUser qbUser = null; + + String userLogin; + String userPassword; + + try { + JSONObject configs = new ConfigParser().getConfigsAsJson(fileName); + userLogin = configs.getString(USER_LOGIN_FIELD_NAME); + userPassword = configs.getString(USER_PASSWORD_FIELD_NAME); + qbUser = new QBUser(userLogin, userPassword); + } catch (IOException | JSONException e) { + e.printStackTrace(); + } + + return qbUser; + } +} diff --git a/sample-core/src/main/res/values/strings.xml b/sample-core/src/main/res/values/strings.xml index ff5efdbb8..ffa79d6e0 100644 --- a/sample-core/src/main/res/values/strings.xml +++ b/sample-core/src/main/res/values/strings.xml @@ -9,8 +9,12 @@ Select photo from… Retry + Initializing configs error + No internet connection v %s + Parsing sample\'s configs error + diff --git a/sample-custom-objects/src/main/assets/qb_config.json b/sample-custom-objects/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-custom-objects/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-custom-objects/src/main/assets/sample_config.json b/sample-custom-objects/src/main/assets/sample_config.json new file mode 100644 index 000000000..b67fc068c --- /dev/null +++ b/sample-custom-objects/src/main/assets/sample_config.json @@ -0,0 +1,4 @@ +{ + "user_login": "igorquickblox44", + "user_password": "igorquickblox44" +} \ No newline at end of file diff --git a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/App.java b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/App.java index 2fb6e163b..af6481538 100644 --- a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/App.java +++ b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/App.java @@ -8,6 +8,5 @@ public class App extends CoreApp { @Override public void onCreate() { super.onCreate(); - initCredentials(Consts.QB_APP_ID, Consts.QB_AUTH_KEY, Consts.QB_AUTH_SECRET, Consts.QB_ACCOUNT_KEY); } } diff --git a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/activities/SplashActivity.java b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/activities/SplashActivity.java index 0984b1c18..6d07f4920 100644 --- a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/activities/SplashActivity.java +++ b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/activities/SplashActivity.java @@ -9,6 +9,7 @@ import com.quickblox.core.server.Performer; import com.quickblox.extensions.RxJavaPerformProcessor; import com.quickblox.sample.core.ui.activity.CoreSplashActivity; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.sample.customobjects.R; import com.quickblox.sample.customobjects.utils.Consts; import com.quickblox.sample.customobjects.utils.QBCustomObjectsUtils; @@ -27,12 +28,14 @@ public class SplashActivity extends CoreSplashActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - signInQB(); + if (checkConfigsWithSnackebarError()){ + signInQB(); + } } private void signInQB() { if (!checkSignIn()) { - QBUser qbUser = new QBUser(Consts.USER_LOGIN, Consts.USER_PASSWORD); + QBUser qbUser = CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME); Performer performer = QBUsers.signIn(qbUser); Observable observable = @@ -82,4 +85,11 @@ protected void proceedToTheNextActivity() { MovieListActivity.start(this); finish(); } + + @Override + protected boolean sampleConfigIsCorrect() { + boolean result = super.sampleConfigIsCorrect(); + result = result && CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME) != null; + return result; + } } \ No newline at end of file diff --git a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/utils/Consts.java b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/utils/Consts.java index d7abf8a24..a0c427eca 100644 --- a/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/utils/Consts.java +++ b/sample-custom-objects/src/main/java/com/quickblox/sample/customobjects/utils/Consts.java @@ -2,13 +2,9 @@ public interface Consts { - String QB_APP_ID = "92"; - String QB_AUTH_KEY = "wJHdOcQSxXQGWx5"; - String QB_AUTH_SECRET = "BTFsj7Rtt27DAmT"; - String QB_ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6"; - - String USER_LOGIN = "igorquickblox44"; - String USER_PASSWORD = "igorquickblox44"; + String USER_LOGIN_FIELD_NAME = "user_login"; + String USER_PASSWORD_FIELD_NAME = "user_password"; + String SAMPLE_CONFIG_FILE_NAME = "sample_config.json"; String CLASS_NAME = "Movie"; String EXTRA_MOVIE_ID = "id"; diff --git a/sample-custom-objects/src/main/res/values/strings.xml b/sample-custom-objects/src/main/res/values/strings.xml index 8faf70155..c6ef95be4 100644 --- a/sample-custom-objects/src/main/res/values/strings.xml +++ b/sample-custom-objects/src/main/res/values/strings.xml @@ -5,6 +5,7 @@ Custom Objects Sample @string/movie_sample Errors + Initializing configs error Add Movie Movie Details diff --git a/sample-location/src/main/assets/qb_config.json b/sample-location/src/main/assets/qb_config.json new file mode 100644 index 000000000..8b105dd37 --- /dev/null +++ b/sample-location/src/main/assets/qb_config.json @@ -0,0 +1,10 @@ +{ + "app_id": "99", + "auth_key": "63ebrp5VZt7qTOv", + "auth_secret": "YavMAxm5T59-BRw", + "account_key": "rz2sXxBt5xgSxGjALDW6", + "api_domain": "https://api.quickblox.com", + "chat_domain": "chat.quickblox.com", + "gcm_sender_id": "761750217637" +} + diff --git a/sample-location/src/main/assets/sample_config.json b/sample-location/src/main/assets/sample_config.json new file mode 100644 index 000000000..235f452e0 --- /dev/null +++ b/sample-location/src/main/assets/sample_config.json @@ -0,0 +1,4 @@ +{ + "user_login": "bobbobbob", + "user_password": "bobbobbob" +} \ No newline at end of file diff --git a/sample-location/src/main/java/com/quickblox/sample/location/App.java b/sample-location/src/main/java/com/quickblox/sample/location/App.java index 60850a6b9..26be78766 100644 --- a/sample-location/src/main/java/com/quickblox/sample/location/App.java +++ b/sample-location/src/main/java/com/quickblox/sample/location/App.java @@ -1,17 +1,11 @@ package com.quickblox.sample.location; -import com.quickblox.auth.session.QBSettings; import com.quickblox.sample.core.CoreApp; -import com.quickblox.sample.location.utils.Consts; public class App extends CoreApp { @Override public void onCreate() { super.onCreate(); - - // Initialize QuickBlox application with credentials. - QBSettings.getInstance().init(this, Consts.APP_ID, Consts.AUTH_KEY, Consts.AUTH_SECRET); - QBSettings.getInstance().setAccountKey(Consts.ACCOUNT_KEY); } } diff --git a/sample-location/src/main/java/com/quickblox/sample/location/activities/SplashActivity.java b/sample-location/src/main/java/com/quickblox/sample/location/activities/SplashActivity.java index 8968df18b..338cf3ff2 100644 --- a/sample-location/src/main/java/com/quickblox/sample/location/activities/SplashActivity.java +++ b/sample-location/src/main/java/com/quickblox/sample/location/activities/SplashActivity.java @@ -7,6 +7,7 @@ import com.quickblox.core.exception.QBResponseException; import com.quickblox.sample.core.ui.activity.CoreSplashActivity; import com.quickblox.sample.core.utils.Toaster; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.sample.location.R; import com.quickblox.sample.location.utils.Consts; import com.quickblox.users.QBUsers; @@ -18,13 +19,16 @@ public class SplashActivity extends CoreSplashActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - signInQB(); + if (checkConfigsWithSnackebarError()){ + signInQB(); + } } private void signInQB() { if (!checkSignIn()) { - QBUser qbUser = new QBUser(Consts.USER_LOGIN, Consts.USER_PASSWORD); + QBUser qbUser = CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME); + QBUsers.signIn(qbUser).performAsync(new QBEntityCallback() { @Override public void onSuccess(QBUser qbUser, Bundle bundle) { @@ -55,4 +59,11 @@ protected void proceedToTheNextActivity() { MapActivity.start(this); finish(); } + + @Override + protected boolean sampleConfigIsCorrect() { + boolean result = super.sampleConfigIsCorrect(); + result = result && CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME) != null; + return result; + } } \ No newline at end of file diff --git a/sample-location/src/main/java/com/quickblox/sample/location/utils/Consts.java b/sample-location/src/main/java/com/quickblox/sample/location/utils/Consts.java index f7f96df66..9063c2fc7 100644 --- a/sample-location/src/main/java/com/quickblox/sample/location/utils/Consts.java +++ b/sample-location/src/main/java/com/quickblox/sample/location/utils/Consts.java @@ -2,13 +2,9 @@ public class Consts { - public static final String APP_ID = "99"; - public static final String AUTH_KEY = "63ebrp5VZt7qTOv"; - public static final String AUTH_SECRET = "YavMAxm5T59-BRw"; - public static final String ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6"; - - public static final String USER_LOGIN = "bobbobbob"; - public static final String USER_PASSWORD = "bobbobbob"; + public static final String USER_LOGIN_FIELD_NAME = "user_login"; + public static final String USER_PASSWORD_FIELD_NAME = "user_password"; + public static final String SAMPLE_CONFIG_FILE_NAME = "sample_config.json"; public static int LOCATION_MIN_TIME = 20000; public static int LOCATION_PER_PAGE = 100; diff --git a/sample-pushnotifications/src/main/assets/qb_config.json b/sample-pushnotifications/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-pushnotifications/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-pushnotifications/src/main/assets/sample_config.json b/sample-pushnotifications/src/main/assets/sample_config.json new file mode 100644 index 000000000..235f452e0 --- /dev/null +++ b/sample-pushnotifications/src/main/assets/sample_config.json @@ -0,0 +1,4 @@ +{ + "user_login": "bobbobbob", + "user_password": "bobbobbob" +} \ No newline at end of file diff --git a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/App.java b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/App.java index 41ad0411e..1dd38a5a8 100644 --- a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/App.java +++ b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/App.java @@ -20,7 +20,6 @@ public void onCreate() { instance = this; ActivityLifecycle.init(this); - initCredentials(Consts.QB_APP_ID, Consts.QB_AUTH_KEY, Consts.QB_AUTH_SECRET, Consts.QB_ACCOUNT_KEY); initPushManager(); } diff --git a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/activities/SplashActivity.java b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/activities/SplashActivity.java index 6a74423ae..5764ed401 100644 --- a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/activities/SplashActivity.java +++ b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/activities/SplashActivity.java @@ -7,6 +7,7 @@ import com.quickblox.core.QBEntityCallback; import com.quickblox.core.exception.QBResponseException; import com.quickblox.sample.core.ui.activity.CoreSplashActivity; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.sample.core.utils.constant.GcmConsts; import com.quickblox.sample.pushnotifications.R; import com.quickblox.sample.pushnotifications.utils.Consts; @@ -25,12 +26,15 @@ protected void onCreate(Bundle savedInstanceState) { message = getIntent().getExtras().getString(GcmConsts.EXTRA_GCM_MESSAGE); } - signInQB(); + if (checkConfigsWithSnackebarError()){ + signInQB(); + } } private void signInQB() { if (!checkSignIn()) { - QBUser qbUser = new QBUser(Consts.USER_LOGIN, Consts.USER_PASSWORD); + QBUser qbUser = CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME); + QBUsers.signIn(qbUser).performAsync(new QBEntityCallback() { @Override public void onSuccess(QBUser qbUser, Bundle bundle) { @@ -63,6 +67,13 @@ protected void proceedToTheNextActivity() { finish(); } + @Override + protected boolean sampleConfigIsCorrect() { + boolean result = super.sampleConfigIsCorrect(); + result = result && CoreConfigUtils.getUserFromConfig(Consts.SAMPLE_CONFIG_FILE_NAME) != null; + return result; + } + private boolean checkSignIn() { return QBSessionManager.getInstance().getSessionParameters() != null; } diff --git a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/utils/Consts.java b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/utils/Consts.java index 6764e87d5..e0a2059cf 100644 --- a/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/utils/Consts.java +++ b/sample-pushnotifications/src/main/java/com/quickblox/sample/pushnotifications/utils/Consts.java @@ -2,15 +2,7 @@ public interface Consts { - // QuickBlox credentials - String QB_APP_ID = "92"; - String QB_AUTH_KEY = "wJHdOcQSxXQGWx5"; - String QB_AUTH_SECRET = "BTFsj7Rtt27DAmT"; - String QB_ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6"; - - String USER_LOGIN = "bobbobbob"; - String USER_PASSWORD = "bobbobbob"; - - // In GCM, the Sender ID is a project ID that you acquire from the API console - String GCM_SENDER_ID = "761750217637"; + String USER_LOGIN_FIELD_NAME = "user_login"; + String USER_PASSWORD_FIELD_NAME = "user_password"; + String SAMPLE_CONFIG_FILE_NAME = "sample_config.json"; } \ No newline at end of file diff --git a/sample-users/src/main/assets/qb_config.json b/sample-users/src/main/assets/qb_config.json new file mode 100644 index 000000000..6858f6742 --- /dev/null +++ b/sample-users/src/main/assets/qb_config.json @@ -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" +} + diff --git a/sample-users/src/main/java/com/quickblox/sample/user/App.java b/sample-users/src/main/java/com/quickblox/sample/user/App.java index 7111d672f..a874a0f10 100644 --- a/sample-users/src/main/java/com/quickblox/sample/user/App.java +++ b/sample-users/src/main/java/com/quickblox/sample/user/App.java @@ -6,7 +6,6 @@ import com.quickblox.auth.session.QBSessionManager; import com.quickblox.auth.session.QBSessionParameters; import com.quickblox.sample.core.CoreApp; -import com.quickblox.sample.user.utils.Consts; public class App extends CoreApp { private static final String TAG = App.class.getSimpleName(); @@ -14,7 +13,6 @@ public class App extends CoreApp { @Override public void onCreate() { super.onCreate(); - initCredentials(Consts.QB_APP_ID, Consts.QB_AUTH_KEY, Consts.QB_AUTH_SECRET, Consts.QB_ACCOUNT_KEY); initQBSessionManager(); } diff --git a/sample-users/src/main/java/com/quickblox/sample/user/activities/SplashActivity.java b/sample-users/src/main/java/com/quickblox/sample/user/activities/SplashActivity.java index e80e97893..e07c89f1a 100644 --- a/sample-users/src/main/java/com/quickblox/sample/user/activities/SplashActivity.java +++ b/sample-users/src/main/java/com/quickblox/sample/user/activities/SplashActivity.java @@ -11,7 +11,9 @@ public class SplashActivity extends CoreSplashActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - proceedToTheNextActivityWithDelay(); + if (checkConfigsWithSnackebarError()) { + proceedToTheNextActivityWithDelay(); + } } @Override diff --git a/sample-users/src/main/java/com/quickblox/sample/user/utils/Consts.java b/sample-users/src/main/java/com/quickblox/sample/user/utils/Consts.java deleted file mode 100644 index aabce3a3f..000000000 --- a/sample-users/src/main/java/com/quickblox/sample/user/utils/Consts.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.quickblox.sample.user.utils; - -public interface Consts { - - String QB_APP_ID = "92"; - String QB_AUTH_KEY = "wJHdOcQSxXQGWx5"; - String QB_AUTH_SECRET = "BTFsj7Rtt27DAmT"; - String QB_ACCOUNT_KEY = "rz2sXxBt5xgSxGjALDW6"; - -} \ No newline at end of file diff --git a/sample-videochat-webrtc/build.gradle b/sample-videochat-webrtc/build.gradle index be8e9c33b..7253729e6 100755 --- a/sample-videochat-webrtc/build.gradle +++ b/sample-videochat-webrtc/build.gradle @@ -23,8 +23,9 @@ android { applicationId "com.quickblox.sample.groupchatwebrtc" minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion - versionCode 200 - versionName "2.0.0" + versionCode 204 + versionName "2.0.4-scr-share" + } productFlavors { @@ -77,6 +78,7 @@ dependencies { compile("com.crashlytics.sdk.android:crashlytics:${rootProject.crashlyticsVersion}@aar") { transitive = true; } + compile 'com.github.bumptech.glide:glide:3.6.1' } apply from: "../artifacts.gradle" \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/AndroidManifest.xml b/sample-videochat-webrtc/src/main/AndroidManifest.xml index 3056efbac..9ee47c367 100755 --- a/sample-videochat-webrtc/src/main/AndroidManifest.xml +++ b/sample-videochat-webrtc/src/main/AndroidManifest.xml @@ -21,7 +21,7 @@ opponentsList; @@ -83,7 +87,6 @@ public class CallActivity extends BaseActivity implements QBRTCClientSessionCall private String hangUpReason; private boolean isInCommingCall; private QBRTCClient rtcClient; - private QBRTCSessionUserCallback sessionUserCallback; private OnChangeDynamicToggle onChangeDynamicCallback; private ConnectionListener connectionListener; private boolean wifiEnabled = true; @@ -104,6 +107,7 @@ public class CallActivity extends BaseActivity implements QBRTCClientSessionCall private boolean previousDeviceEarPiece; private boolean showToastAfterHeadsetPlugged = true; private PermissionsChecker checker; + private MediaProjectionManager mMediaProjectionManager; public static void start(Context context, boolean isIncomingCall) { @@ -140,11 +144,40 @@ protected void onCreate(Bundle savedInstanceState) { ringtonePlayer = new RingtonePlayer(this, R.raw.beep); connectionView = (LinearLayout) View.inflate(this, R.layout.connection_popup, null); - checker = new PermissionsChecker(getApplicationContext()); + startSuitableFragment(isInCommingCall); } + + private void startScreenSharing(final Intent data){ + ScreenShareFragment screenShareFragment = ScreenShareFragment.newIntstance(); + FragmentExecuotr.addFragmentWithBackStack(getSupportFragmentManager(), R.id.fragment_container, screenShareFragment, ScreenShareFragment.TAG); + currentSession.getMediaStreamManager().setVideoCapturer(new QBRTCScreenCapturer(data, null)); + } + + private void returnToCamera() { + try { + currentSession.getMediaStreamManager().setVideoCapturer(new QBRTCCameraVideoCapturer(this, null)); + } catch (QBRTCCameraVideoCapturer.QBRTCCameraCapturerException e) { + e.printStackTrace(); + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode,final Intent data) { + Log.i(TAG, "onActivityResult requestCode="+requestCode +", resultCode= " + resultCode); + if (requestCode == QBRTCScreenCapturer.REQUEST_MEDIA_PROJECTION) { + if (resultCode == Activity.RESULT_OK) { + startScreenSharing(data); + Log.i(TAG, "Starting screen capture"); + } + else { + + } + } + } + private void startSuitableFragment(boolean isInComingCall) { if (isInComingCall) { initIncomingCallTask(); @@ -273,13 +306,18 @@ public void run() { private void initQBRTCClient() { rtcClient = QBRTCClient.getInstance(this); - rtcClient.setCameraErrorHendler(new VideoCapturerAndroid.CameraEventsHandler() { + rtcClient.setCameraErrorHendler(new CameraVideoCapturer.CameraEventsHandler() { @Override public void onCameraError(final String s) { showToast("Camera error: " + s); } + @Override + public void onCameraDisconnected() { + showToast("Camera onCameraDisconnected: "); + } + @Override public void onCameraFreezed(String s) { showToast("Camera freezed: " + s); @@ -287,11 +325,13 @@ public void onCameraFreezed(String s) { } @Override - public void onCameraOpening(int i) { + public void onCameraOpening(String s) { + showToast("Camera aOpening: " + s); } @Override public void onFirstFrameAvailable() { + showToast("onFirstFrameAvailable: "); } @Override @@ -397,13 +437,13 @@ public void hangUpCurrentSession() { private void setAudioEnabled(boolean isAudioEnabled) { if (currentSession != null && currentSession.getMediaStreamManager() != null) { - currentSession.getMediaStreamManager().setAudioEnabled(isAudioEnabled); + currentSession.getMediaStreamManager().getLocalAudioTrack().setEnabled(isAudioEnabled); } } private void setVideoEnabled(boolean isVideoEnabled) { if (currentSession != null && currentSession.getMediaStreamManager() != null) { - currentSession.getMediaStreamManager().setVideoEnabled(isVideoEnabled); + currentSession.getMediaStreamManager().getLocalVideoTrack().setEnabled(isVideoEnabled); } } @@ -476,9 +516,6 @@ public void onUserNotAnswer(QBRTCSession session, Integer userID) { if (!session.equals(getCurrentSession())) { return; } - if (sessionUserCallback != null) { - sessionUserCallback.onUserNotAnswer(session, userID); - } ringtonePlayer.stop(); } @@ -487,19 +524,11 @@ public void onUserNoActions(QBRTCSession qbrtcSession, Integer integer) { startIncomeCallTimer(0); } - @Override - public void onStartConnectToUser(QBRTCSession session, Integer userID) { - - } - @Override public void onCallAcceptByUser(QBRTCSession session, Integer userId, Map userInfo) { if (!session.equals(getCurrentSession())) { return; } - if (sessionUserCallback != null) { - sessionUserCallback.onCallAcceptByUser(session, userId, userInfo); - } ringtonePlayer.stop(); } @@ -508,9 +537,6 @@ public void onCallRejectByUser(QBRTCSession session, Integer userID, Map userInfo); - - void onCallAcceptByUser(QBRTCSession session, Integer userId, Map userInfo); - - void onReceiveHangUpFromUser(QBRTCSession session, Integer userId); - } public interface CurrentCallStateCallback { void onCallStarted(); diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/LoginActivity.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/LoginActivity.java index b52ba4ad7..d185bb82f 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/LoginActivity.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/LoginActivity.java @@ -20,6 +20,7 @@ import com.quickblox.sample.core.utils.KeyboardUtils; import com.quickblox.sample.core.utils.SharedPrefsHelper; import com.quickblox.sample.core.utils.Toaster; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.sample.groupchatwebrtc.R; import com.quickblox.sample.groupchatwebrtc.services.CallService; import com.quickblox.sample.groupchatwebrtc.utils.Consts; @@ -28,9 +29,6 @@ import com.quickblox.sample.groupchatwebrtc.utils.ValidationUtils; import com.quickblox.users.model.QBUser; -/** - * Created by tereha on 12.04.16. - */ public class LoginActivity extends BaseActivity { private String TAG = LoginActivity.class.getSimpleName(); diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/OpponentsActivity.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/OpponentsActivity.java index c6e842a82..97afbce85 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/OpponentsActivity.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/OpponentsActivity.java @@ -16,6 +16,7 @@ import com.quickblox.messages.services.SubscribeService; import com.quickblox.sample.core.utils.SharedPrefsHelper; import com.quickblox.sample.core.utils.Toaster; +import com.quickblox.sample.core.utils.configs.CoreConfigUtils; import com.quickblox.sample.groupchatwebrtc.R; import com.quickblox.sample.groupchatwebrtc.adapters.OpponentsAdapter; import com.quickblox.sample.groupchatwebrtc.db.QbUsersDbManager; diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/SplashActivity.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/SplashActivity.java index cc5537ee0..dd21b7a4d 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/SplashActivity.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/activities/SplashActivity.java @@ -8,9 +8,6 @@ import com.quickblox.sample.groupchatwebrtc.services.CallService; import com.quickblox.users.model.QBUser; -/** - * Created by tereha on 12.04.16. - */ public class SplashActivity extends CoreSplashActivity { private SharedPrefsHelper sharedPrefsHelper; @@ -26,7 +23,10 @@ protected void onCreate(Bundle savedInstanceState) { startOpponentsActivity(); return; } - proceedToTheNextActivityWithDelay(); + + if (checkConfigsWithSnackebarError()) { + proceedToTheNextActivityWithDelay(); + } } @Override @@ -40,7 +40,6 @@ protected void proceedToTheNextActivity() { finish(); } - protected void startLoginService(QBUser qbUser) { CallService.start(this, qbUser); } diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/adapters/OpponentsFromCallAdapter.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/adapters/OpponentsFromCallAdapter.java index d4165cffd..d6359ae24 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/adapters/OpponentsFromCallAdapter.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/adapters/OpponentsFromCallAdapter.java @@ -96,6 +96,7 @@ public void onBindViewHolder(ViewHolder holder, int position) { int userID = user.getId(); holder.opponentsName.setText(user.getFullName()); + holder.getOpponentView().setId(user.getId()); holder.setUserId(userID); QBRTCTypes.QBRTCConnectionState state = session.getPeerChannel(userID).getState(); Log.d(TAG, "state ordinal= " + state.ordinal()); diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseConversationFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseConversationFragment.java index de134aca7..2f3584b77 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseConversationFragment.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseConversationFragment.java @@ -1,15 +1,9 @@ package com.quickblox.sample.groupchatwebrtc.fragments; import android.app.Activity; -import android.app.Fragment; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; import android.os.SystemClock; import android.support.annotation.Nullable; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -34,10 +28,7 @@ import java.util.ArrayList; -/** - * Created by tereha on 24.05.16. - */ -public abstract class BaseConversationFragment extends Fragment implements CallActivity.CurrentCallStateCallback { +public abstract class BaseConversationFragment extends BaseToolBarFragment implements CallActivity.CurrentCallStateCallback { private static final String TAG = BaseConversationFragment.class.getSimpleName(); protected QbUsersDbManager dbManager; @@ -53,14 +44,10 @@ public abstract class BaseConversationFragment extends Fragment implements CallA protected Chronometer timerChronometer; private boolean isMessageProcessed; protected boolean isStarted; - protected FragmentLifeCycleHandler mainHandler; protected View outgoingOpponentsRelativeLayout; protected TextView allOpponentsTextView; protected TextView ringingTextView; protected QBUser currentUser; - protected Toolbar toolbar; - protected ActionBar actionBar; - public static BaseConversationFragment newInstance(BaseConversationFragment baseConversationFragment, boolean isIncomingCall) { Log.d(TAG, "isIncomingCall = " + isIncomingCall); @@ -87,16 +74,14 @@ public void onAttach(Activity activity) { @Override public void onCreate(Bundle savedInstanceState) { - setHasOptionsMenu(true); - mainHandler = new FragmentLifeCycleHandler(); - conversationFragmentCallbackListener.addCurrentCallStateCallback(this); super.onCreate(savedInstanceState); + conversationFragmentCallbackListener.addCurrentCallStateCallback(this); } @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(getFragmentLayout(), container, false); + View view = super.onCreateView(inflater, container, savedInstanceState); sessionManager = WebRtcSessionManager.getInstance(getActivity()); currentSession = sessionManager.getCurrentSession(); if (currentSession == null) { @@ -120,13 +105,7 @@ private void prepareAndShowOutgoingScreen() { protected abstract void configureOutgoingScreen(); private void initActionBar() { - toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar_call); - configureToolbar(); - - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - actionBar = ((AppCompatActivity) getActivity()).getDelegate().getSupportActionBar(); - configureActionBar(); } @@ -134,8 +113,6 @@ private void initActionBar() { protected abstract void configureToolbar(); - abstract int getFragmentLayout(); - protected void initFields() { currentUser = QBChatService.getInstance().getUser(); dbManager = QbUsersDbManager.getInstance(getActivity().getApplicationContext()); @@ -160,8 +137,10 @@ public void onStart() { if (currentSession == null) { Log.d(TAG, "currentSession = null onStart"); return; + } - if (!isMessageProcessed) { + + if (currentSession.getState() != QBRTCSession.QBRTCSessionState.QB_RTC_SESSION_ACTIVE) { if (isIncomingCall) { currentSession.acceptCall(null); } else { @@ -278,15 +257,4 @@ private void initOpponentsList() { } } - class FragmentLifeCycleHandler extends Handler { - - @Override - public void dispatchMessage(Message msg) { - if (isAdded() && getActivity() != null) { - super.dispatchMessage(msg); - } else { - Log.d(TAG, "Fragment under destroying"); - } - } - } } \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseToolBarFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseToolBarFragment.java new file mode 100644 index 000000000..f0cb711e8 --- /dev/null +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/BaseToolBarFragment.java @@ -0,0 +1,74 @@ +package com.quickblox.sample.groupchatwebrtc.fragments; + +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.quickblox.sample.groupchatwebrtc.R; + +import java.lang.ref.WeakReference; + +public abstract class BaseToolBarFragment extends Fragment { + + private static final String TAG = BaseToolBarFragment.class.getSimpleName(); + protected Handler mainHandler; + protected Toolbar toolbar; + protected ActionBar actionBar; + + abstract int getFragmentLayout(); + + @Override + public void onCreate(Bundle savedInstanceState) { + setHasOptionsMenu(true); + mainHandler = new FragmentLifeCycleHandler(this); + super.onCreate(savedInstanceState); + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = inflater.inflate(getFragmentLayout(), container, false); + initActionBar(); + return view; + } + + private void initActionBar() { + toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar_call); + + ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); + actionBar = ((AppCompatActivity) getActivity()).getDelegate().getSupportActionBar(); + } + + + static class FragmentLifeCycleHandler extends Handler { + + private WeakReference fragmentRef; + + FragmentLifeCycleHandler(Fragment fragment){ + + this.fragmentRef = new WeakReference<>(fragment); + } + + @Override + public void dispatchMessage(Message msg) { + Fragment fragment = fragmentRef.get(); + if (fragment == null){ + return; + } + if (fragment.isAdded() && (fragment.getActivity() != null)) { + super.dispatchMessage(msg); + } else { + Log.d(TAG, "Fragment under destroying"); + } + } + } +} diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ConversationFragmentCallbackListener.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ConversationFragmentCallbackListener.java index c316b52b1..0c2328e88 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ConversationFragmentCallbackListener.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ConversationFragmentCallbackListener.java @@ -1,18 +1,21 @@ package com.quickblox.sample.groupchatwebrtc.fragments; import com.quickblox.sample.groupchatwebrtc.activities.CallActivity; -import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionConnectionCallbacks; +import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionEventsCallback; +import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionStateCallback; + +import org.webrtc.CameraVideoCapturer; /** * Created by tereha on 23.05.16. */ public interface ConversationFragmentCallbackListener { - void addTCClientConnectionCallback(QBRTCSessionConnectionCallbacks clientConnectionCallbacks); - void removeRTCClientConnectionCallback(QBRTCSessionConnectionCallbacks clientConnectionCallbacks); + void addTCClientConnectionCallback(QBRTCSessionStateCallback clientConnectionCallbacks); + void removeRTCClientConnectionCallback(QBRTCSessionStateCallback clientConnectionCallbacks); - void addRTCSessionUserCallback(CallActivity.QBRTCSessionUserCallback sessionUserCallback); - void removeRTCSessionUserCallback(CallActivity.QBRTCSessionUserCallback sessionUserCallback); + void addRTCSessionEventsCallback(QBRTCSessionEventsCallback eventsCallback); + void removeRTCSessionEventsCallback(QBRTCSessionEventsCallback eventsCallback); void addCurrentCallStateCallback (CallActivity.CurrentCallStateCallback currentCallStateCallback); void removeCurrentCallStateCallback (CallActivity.CurrentCallStateCallback currentCallStateCallback); @@ -28,4 +31,7 @@ public interface ConversationFragmentCallbackListener { void onHangUpCurrentSession(); + void onStartScreenSharing(); + + void onSwitchCamera(CameraVideoCapturer.CameraSwitchHandler cameraSwitchHandler); } diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/IncomeCallFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/IncomeCallFragment.java index 88eff0466..e22dc62db 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/IncomeCallFragment.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/IncomeCallFragment.java @@ -1,7 +1,7 @@ package com.quickblox.sample.groupchatwebrtc.fragments; import android.app.Activity; -import android.app.Fragment; +import android.support.v4.app.Fragment; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/PreviewFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/PreviewFragment.java new file mode 100644 index 000000000..b038d427a --- /dev/null +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/PreviewFragment.java @@ -0,0 +1,43 @@ +package com.quickblox.sample.groupchatwebrtc.fragments; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.quickblox.sample.core.utils.ResourceUtils; +import com.quickblox.sample.groupchatwebrtc.R; + +public class PreviewFragment extends Fragment{ + + public static final String PREVIEW_IMAGE = "preview_image"; + + + public static Fragment newInstance(int imageResourceId) { + PreviewFragment previewFragment = new PreviewFragment(); + Bundle bundle = new Bundle(); + bundle.putInt(PREVIEW_IMAGE, imageResourceId); + previewFragment.setArguments(bundle); + return previewFragment; + + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + + View view = inflater.inflate(R.layout.fragment_item_screen_share, container, false); + Glide.with(this) + .load(getArguments().getInt(PREVIEW_IMAGE)) + .diskCacheStrategy(DiskCacheStrategy.ALL) + .override(ResourceUtils.getDimen(R.dimen.pager_image_width), + ResourceUtils.getDimen(R.dimen.pager_image_height)) + .into((ImageView) view.findViewById(R.id.image_preview)); + return view; + } +} diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ScreenShareFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ScreenShareFragment.java new file mode 100644 index 000000000..0637e226b --- /dev/null +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/ScreenShareFragment.java @@ -0,0 +1,108 @@ +package com.quickblox.sample.groupchatwebrtc.fragments; + +import android.annotation.TargetApi; +import android.content.Context; +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.content.ContextCompat; +import android.support.v4.view.ViewPager; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import com.quickblox.sample.groupchatwebrtc.R; + + +public class ScreenShareFragment extends BaseToolBarFragment { + + public static final String TAG = ScreenShareFragment.class.getSimpleName(); + private OnSharingEvents onSharingEvents; + + @Override + int getFragmentLayout() { + return R.layout.fragment_pager; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View view = super.onCreateView(inflater, container, savedInstanceState); + + MyAdapter adapter = new MyAdapter(getChildFragmentManager()); + + ViewPager pager = (ViewPager) view.findViewById(R.id.pager); + pager.setAdapter(adapter); + + toolbar.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.white)); + return view; + } + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.screen_share_fragment, menu); + super.onCreateOptionsMenu(menu, inflater); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.stop_screen_share: + Log.d(TAG, "stop_screen_share"); + if (onSharingEvents != null) { + onSharingEvents.onStopPreview(); + } + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + public void onAttach(Context context) { + super.onAttach(context); + onSharingEvents = (OnSharingEvents) context; + } + + @Override + public void onDetach() { + super.onDetach(); + onSharingEvents = null; + } + + public interface OnSharingEvents{ + void onStopPreview(); + } + + public static ScreenShareFragment newIntstance() { + return new ScreenShareFragment(); + } + + public static class MyAdapter extends FragmentPagerAdapter { + private static final int NUM_ITEMS = 4; + + private int[] images = {R.drawable.pres_img, R.drawable.p2p, R.drawable.group_call, R.drawable.opponents}; + + public MyAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public int getCount() { + return NUM_ITEMS; + } + + @Override + public Fragment getItem(int position) { + return PreviewFragment.newInstance(images[position]); + } + } + +} diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/VideoConversationFragment.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/VideoConversationFragment.java index 7b45d48a3..4719c971e 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/VideoConversationFragment.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/fragments/VideoConversationFragment.java @@ -28,16 +28,16 @@ import android.widget.TextView; import android.widget.ToggleButton; +import com.quickblox.sample.core.utils.Toaster; import com.quickblox.sample.groupchatwebrtc.R; import com.quickblox.sample.groupchatwebrtc.activities.CallActivity; import com.quickblox.sample.groupchatwebrtc.adapters.OpponentsFromCallAdapter; import com.quickblox.users.model.QBUser; -import com.quickblox.videochat.webrtc.QBMediaStreamManager; import com.quickblox.videochat.webrtc.QBRTCSession; import com.quickblox.videochat.webrtc.QBRTCTypes; import com.quickblox.videochat.webrtc.callbacks.QBRTCClientVideoTracksCallbacks; -import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionConnectionCallbacks; -import com.quickblox.videochat.webrtc.exception.QBRTCException; +import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionEventsCallback; +import com.quickblox.videochat.webrtc.callbacks.QBRTCSessionStateCallback; import com.quickblox.videochat.webrtc.view.QBRTCSurfaceView; import com.quickblox.videochat.webrtc.view.QBRTCVideoTrack; @@ -50,6 +50,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -60,7 +61,7 @@ * QuickBlox team */ public class VideoConversationFragment extends BaseConversationFragment implements Serializable, QBRTCClientVideoTracksCallbacks, - QBRTCSessionConnectionCallbacks, CallActivity.QBRTCSessionUserCallback, OpponentsFromCallAdapter.OnAdapterEventListener { + QBRTCSessionStateCallback, QBRTCSessionEventsCallback, OpponentsFromCallAdapter.OnAdapterEventListener { private static final int DEFAULT_ROWS_COUNT = 2; private static final int DEFAULT_COLS_COUNT = 3; @@ -69,19 +70,18 @@ public class VideoConversationFragment extends BaseConversationFragment implemen private static final int RECYCLE_VIEW_PADDING = 2; private static final long UPDATING_USERS_DELAY = 2000; private static final long FULL_SCREEN_CLICK_DELAY = 1000; + private static final int REQUEST_CODE_ATTACHMENT = 100; private String TAG = VideoConversationFragment.class.getSimpleName(); private ToggleButton cameraToggle; private View view; - private boolean isVideoCall = false; private LinearLayout actionVideoButtonsLayout; private QBRTCSurfaceView remoteFullScreenVideoView; private QBRTCSurfaceView localVideoView; - private CameraState cameraState = CameraState.NONE; + private CameraState cameraState = CameraState.DISABLED_FROM_USER; private RecyclerView recyclerView; private SparseArray opponentViewHolders; - private List viewHolders; private boolean isPeerToPeerCall; private QBRTCVideoTrack localVideoTrack; private TextView connectionStatusLocal; @@ -90,22 +90,19 @@ public class VideoConversationFragment extends BaseConversationFragment implemen private OpponentsFromCallAdapter opponentsAdapter; private LocalViewOnClickListener localViewOnClickListener; private boolean isRemoteShown; - private boolean headsetPlugged; private int amountOpponents; private int userIDFullScreen; private List allOpponents; private boolean connectionEstablished; - private boolean previousDeviceEarPiece; private boolean allCallbacksInit; - private boolean isCurrentCameraFront = true; + private boolean isCurrentCameraFront; private boolean isLocalVideoFullScreen; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = super.onCreateView(inflater, container, savedInstanceState); - initVideoTrackSListener(); return view; } @@ -146,7 +143,6 @@ protected void initFields() { timerChronometer = (Chronometer) getActivity().findViewById(R.id.timer_chronometer_action_bar); isPeerToPeerCall = opponents.size() == 1; - isVideoCall = (QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_VIDEO.equals(currentSession.getConferenceType())); } public void setDuringCallActionBar() { @@ -184,9 +180,11 @@ protected void actionButtonsEnabled(boolean inability) { @Override public void onStart() { super.onStart(); + Log.i(TAG, "onStart"); if (!allCallbacksInit) { conversationFragmentCallbackListener.addTCClientConnectionCallback(this); - conversationFragmentCallbackListener.addRTCSessionUserCallback(this); + conversationFragmentCallbackListener.addRTCSessionEventsCallback(this); + initVideoTrackSListener(); allCallbacksInit = true; } } @@ -194,19 +192,24 @@ public void onStart() { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Log.i(TAG, "onCreate"); setHasOptionsMenu(true); } @Override protected void initViews(View view) { super.initViews(view); - + Log.i(TAG, "initViews"); opponentViewHolders = new SparseArray<>(opponents.size()); - + isRemoteShown = false; + isCurrentCameraFront = true; localVideoView = (QBRTCSurfaceView) view.findViewById(R.id.local_video_view); initCorrectSizeForLocalView(); localVideoView.setZOrderMediaOverlay(true); + remoteFullScreenVideoView = (QBRTCSurfaceView) view.findViewById(R.id.remote_video_view); + remoteFullScreenVideoView.setOnClickListener(localViewOnClickListener); + if (!isPeerToPeerCall) { recyclerView = (RecyclerView) view.findViewById(R.id.grid_opponents); @@ -235,6 +238,37 @@ public void onGlobalLayout() { actionVideoButtonsLayout = (LinearLayout) view.findViewById(R.id.element_set_video_buttons); actionButtonsEnabled(false); + restoreSession(); + } + + private void restoreSession() { + Log.d(TAG, "restoreSession "); + if (currentSession.getState() != QBRTCSession.QBRTCSessionState.QB_RTC_SESSION_ACTIVE) { + return; + } + onCallStarted(); + Map videoTrackMap = getVideoTrackMap(); + if (!videoTrackMap.isEmpty()) { + for (final Iterator> entryIterator + = videoTrackMap.entrySet().iterator(); entryIterator.hasNext();){ + final Map.Entry entry = entryIterator.next(); + Log.d(TAG, "check ability to restoreSession for user:"+entry.getKey()); + //if connection with peer wasn't closed do restore it otherwise remove from collection + if (currentSession.getPeerChannel(entry.getKey()).getState()!= + QBRTCTypes.QBRTCConnectionState.QB_RTC_CONNECTION_CLOSED){ + Log.d(TAG, "execute restoreSession for user:"+entry.getKey()); + mainHandler.postDelayed(new Runnable() { + @Override + public void run() { + onConnectedToUser(currentSession, entry.getKey()); + onRemoteVideoTrackReceive(currentSession, entry.getValue(), entry.getKey()); + } + }, LOCAL_TRACk_INITIALIZE_DELAY); + } else { + entryIterator.remove(); + } + } + } } private void initCorrectSizeForLocalView() { @@ -271,23 +305,15 @@ private int defineSize(int measuredWidth, int columnsCount, float padding) { return measuredWidth / columnsCount - (int) (padding * 2) - RECYCLE_VIEW_PADDING; } - private int defineRowCount() { - int result = DEFAULT_ROWS_COUNT; - int opponentsCount = opponents.size(); - if (opponentsCount < 3) { - result = opponentsCount; - } - return result; - } - private int defineColumnsCount() { return opponents.size() - 1; } + @Override public void onResume() { super.onResume(); - + Log.d(TAG, "onResume"); // If user changed camera state few times and last state was CameraState.ENABLED_FROM_USER // than we turn on cam, else we nothing change if (cameraState != CameraState.DISABLED_FROM_USER) { @@ -295,6 +321,7 @@ public void onResume() { } } + @Override public void onPause() { // If camera state is CameraState.ENABLED_FROM_USER or CameraState.NONE @@ -309,19 +336,69 @@ public void onPause() { @Override public void onStop() { super.onStop(); + Log.d(TAG, "onStop"); if (connectionEstablished) { - conversationFragmentCallbackListener.removeRTCClientConnectionCallback(this); - conversationFragmentCallbackListener.removeRTCSessionUserCallback(this); allCallbacksInit = false; } else { Log.d(TAG, "We are in dialing process yet!"); } } + private void removeVideoTrackRenderers() { + Log.d(TAG, "removeVideoTrackRenderers"); + Log.d(TAG, "remove opponents video Tracks"); + Map videoTrackMap = getVideoTrackMap(); + for (QBRTCVideoTrack videoTrack : videoTrackMap.values()) { + if (videoTrack.getRenderer() != null) { + Log.d(TAG, "remove opponent video Tracks"); + videoTrack.removeRenderer(videoTrack.getRenderer()); + } + } + } + @Override public void onDetach() { super.onDetach(); + Log.d(TAG, "onDetach"); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + Log.d(TAG, "onDestroyView"); + releaseViewHolders(); + removeConnectionStateListeners(); removeVideoTrackSListener(); + removeVideoTrackRenderers(); + releaseViews(); + } + + private void releaseViewHolders() { + opponentViewHolders.clear(); + } + + private void removeConnectionStateListeners(){ + conversationFragmentCallbackListener.removeRTCClientConnectionCallback(this); + conversationFragmentCallbackListener.removeRTCSessionEventsCallback(this); + } + + private void releaseViews() { + if (localVideoView != null){ + localVideoView.release(); + } + if (remoteFullScreenVideoView != null) { + remoteFullScreenVideoView.release(); + } + remoteFullScreenVideoView = null; + if (!isPeerToPeerCall){ + releseOpponentsViews(); + } + } + + @Override + public void onCallStopped() { + super.onCallStopped(); + Log.i(TAG, "onCallStopped"); } protected void initButtonsListener() { @@ -330,24 +407,19 @@ protected void initButtonsListener() { cameraToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - cameraState = isChecked ? CameraState.ENABLED_FROM_USER : CameraState.DISABLED_FROM_USER; - toggleCamera(isChecked); + if (cameraState != CameraState.DISABLED_FROM_USER) { + toggleCamera(isChecked); + } } }); } private void switchCamera(final MenuItem item) { - if (currentSession == null || cameraState == CameraState.DISABLED_FROM_USER) { - return; - } - final QBMediaStreamManager mediaStreamManager = currentSession.getMediaStreamManager(); - if (mediaStreamManager == null) { + if (cameraState == CameraState.DISABLED_FROM_USER) { return; } -// disable cameraToggle while processing switchCamera cameraToggle.setEnabled(false); - - mediaStreamManager.switchCameraInput(new CameraVideoCapturer.CameraSwitchHandler() { + conversationFragmentCallbackListener.onSwitchCamera(new CameraVideoCapturer.CameraSwitchHandler() { @Override public void onCameraSwitchDone(boolean b) { Log.d(TAG, "camera switched, bool = " + b); @@ -359,6 +431,7 @@ public void onCameraSwitchDone(boolean b) { @Override public void onCameraSwitchError(String s) { Log.d(TAG, "camera switch error " + s); + Toaster.shortToast(getString(R.string.camera_swicth_failed) + s); cameraToggle.setEnabled(true); } }); @@ -393,53 +466,32 @@ private void toggleCamera(boolean isNeedEnableCam) { } } - private void setOpponentsVisibility(int visibility) { - for (OpponentsFromCallAdapter.ViewHolder RTCView : getAllOpponentsView()) { - RTCView.getOpponentView().setVisibility(visibility); - } - } - //////////////////////////// callbacks from QBRTCClientVideoTracksCallbacks /////////////////// @Override public void onLocalVideoTrackReceive(QBRTCSession qbrtcSession, final QBRTCVideoTrack videoTrack) { Log.d(TAG, "onLocalVideoTrackReceive() run"); localVideoTrack = videoTrack; isLocalVideoFullScreen = true; + cameraState = CameraState.NONE; + if (remoteFullScreenVideoView != null) { fillVideoView(remoteFullScreenVideoView, localVideoTrack, false); } - - if (isPeerToPeerCall) { - if (remoteFullScreenVideoView != null) { - return; - } - Log.d(TAG, "onLocalVideoTrackReceive init localView"); - remoteFullScreenVideoView = (QBRTCSurfaceView) view.findViewById(R.id.remote_video_view); - remoteFullScreenVideoView.setOnClickListener(localViewOnClickListener); - - if (localVideoTrack != null) { - fillVideoView(remoteFullScreenVideoView, localVideoTrack, false); - } - } - //in other case localVideoView hasn't been inflated yet. Will set track while OnBindLastViewHolder } @Override public void onRemoteVideoTrackReceive(QBRTCSession session, final QBRTCVideoTrack videoTrack, final Integer userID) { Log.d(TAG, "onRemoteVideoTrackReceive for opponent= " + userID); - fillVideoView(localVideoView, localVideoTrack, false); + if (localVideoTrack != null) { + fillVideoView(localVideoView, localVideoTrack, false); + } isLocalVideoFullScreen = false; - if (isPeerToPeerCall) { setDuringCallActionBar(); - if (remoteFullScreenVideoView == null) { - remoteFullScreenVideoView = (QBRTCSurfaceView) view.findViewById(R.id.remote_video_view); - } - - fillVideoView(remoteFullScreenVideoView, videoTrack, true); + fillVideoView(userID, remoteFullScreenVideoView, videoTrack, true); updateVideoView(remoteFullScreenVideoView, false); } else { mainHandler.postDelayed(new Runnable() { @@ -456,31 +508,7 @@ public void run() { @Override public void OnBindLastViewHolder(final OpponentsFromCallAdapter.ViewHolder holder, final int position) { Log.i(TAG, "OnBindLastViewHolder position=" + position); - if (!isVideoCall) { - return; - } - if (isPeerToPeerCall) { - } else { - //on group call we postpone initialization of VideoView due to set it on Gui renderer. - // Refer to RTCGlVIew - mainHandler.postDelayed(new Runnable() { - @Override - public void run() { - if (remoteFullScreenVideoView != null) { - return; - } - setOpponentsVisibility(View.GONE); - Log.i(TAG, "OnBindLastViewHolder init localView"); - remoteFullScreenVideoView = (QBRTCSurfaceView) view.findViewById(R.id.remote_video_view); - remoteFullScreenVideoView.setOnClickListener(localViewOnClickListener); - if (localVideoTrack != null) { - Log.d(TAG, "OnBindLastViewHolder.fillVideoView localVideoTrack"); - fillVideoView(isLocalVideoFullScreen ? remoteFullScreenVideoView : localVideoView, localVideoTrack, false); - } - } - }, LOCAL_TRACk_INITIALIZE_DELAY); - } } @@ -512,7 +540,7 @@ private void replaceUsersInAdapter(int position) { private void updateViewHolders(int position) { View childView = recyclerView.getChildAt(position); OpponentsFromCallAdapter.ViewHolder childViewHolder = (OpponentsFromCallAdapter.ViewHolder) recyclerView.getChildViewHolder(childView); - viewHolders.set(position, childViewHolder); + opponentViewHolders.put(position, childViewHolder); } @SuppressWarnings("ConstantConditions") @@ -535,14 +563,6 @@ private void swapUsersFullscreenToPreview(int userId) { } } - private void setLocalVideoView(int userId, QBRTCVideoTrack videoTrack) { - if (remoteFullScreenVideoView == null) { - Log.d(TAG, "setLocalVideoView VideoView = null"); - remoteFullScreenVideoView = (QBRTCSurfaceView) view.findViewById(R.id.remote_video_view); - } - - fillVideoView(userId, remoteFullScreenVideoView, videoTrack); - } private void setRemoteViewMultiCall(int userID, QBRTCVideoTrack videoTrack) { Log.d(TAG, "setRemoteViewMultiCall fillVideoView"); @@ -553,8 +573,6 @@ private void setRemoteViewMultiCall(int userID, QBRTCVideoTrack videoTrack) { } final QBRTCSurfaceView remoteVideoView = itemHolder.getOpponentView(); - getVideoTrackMap().put(userID, videoTrack); - if (remoteVideoView != null) { remoteVideoView.setZOrderMediaOverlay(true); updateVideoView(remoteVideoView, false); @@ -562,13 +580,13 @@ private void setRemoteViewMultiCall(int userID, QBRTCVideoTrack videoTrack) { Log.d(TAG, "onRemoteVideoTrackReceive fillVideoView"); if (isRemoteShown) { Log.d(TAG, "USer onRemoteVideoTrackReceive = " + userID); - fillVideoView(remoteVideoView, videoTrack, true); + fillVideoView(userID, remoteVideoView, videoTrack, true); } else { isRemoteShown = true; opponentsAdapter.removeItem(itemHolder.getAdapterPosition()); setDuringCallActionBar(); setRecyclerViewVisibleState(); - setOpponentsVisibility(View.VISIBLE); + //setOpponentsVisibility(View.VISIBLE); fillVideoView(userID, remoteFullScreenVideoView, videoTrack); updateVideoView(remoteFullScreenVideoView, false); } @@ -585,6 +603,7 @@ private void setRecyclerViewVisibleState() { private OpponentsFromCallAdapter.ViewHolder getViewHolderForOpponent(Integer userID) { OpponentsFromCallAdapter.ViewHolder holder = opponentViewHolders.get(userID); if (holder == null) { + Log.d(TAG, "holder not found in cache"); holder = findHolder(userID); if (holder != null) { opponentViewHolders.append(userID, holder); @@ -593,44 +612,51 @@ private OpponentsFromCallAdapter.ViewHolder getViewHolderForOpponent(Integer use return holder; } - private List getAllOpponentsView() { - if (viewHolders != null) { - return viewHolders; - } + private OpponentsFromCallAdapter.ViewHolder findHolder(Integer userID) { + Log.d(TAG, "findHolder for "+userID); int childCount = recyclerView.getChildCount(); - viewHolders = new ArrayList<>(); for (int i = 0; i < childCount; i++) { View childView = recyclerView.getChildAt(i); OpponentsFromCallAdapter.ViewHolder childViewHolder = (OpponentsFromCallAdapter.ViewHolder) recyclerView.getChildViewHolder(childView); - viewHolders.add(childViewHolder); - } - return viewHolders; - } - - private OpponentsFromCallAdapter.ViewHolder findHolder(Integer userID) { - if (viewHolders == null) { - Log.d(TAG, "viewHolders == null"); - return null; - } - for (OpponentsFromCallAdapter.ViewHolder childViewHolder : viewHolders) { - Log.d(TAG, "getViewForOpponent holder user id is : " + childViewHolder.getUserId()); if (userID.equals(childViewHolder.getUserId())) { return childViewHolder; } } return null; + }; + + private void releseOpponentsViews(){ + RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); + int childCount = layoutManager.getChildCount(); + Log.d(TAG, " releseOpponentsViews for "+childCount + " views"); + for (int i = 0; i < childCount; i++) { + View childView = layoutManager.getChildAt(i); + Log.d(TAG, " relese View for " + i +", "+childView); + OpponentsFromCallAdapter.ViewHolder childViewHolder = (OpponentsFromCallAdapter.ViewHolder) recyclerView.getChildViewHolder(childView); + childViewHolder.getOpponentView().release(); + } } - private void fillVideoView(QBRTCSurfaceView videoView, QBRTCVideoTrack videoTrack, boolean remoteRenderer) { + /** + * @param userId set userId if it from fullscreen videoTrack + */ + private void fillVideoView(int userId, QBRTCSurfaceView videoView, QBRTCVideoTrack videoTrack, + boolean remoteRenderer) { videoTrack.removeRenderer(videoTrack.getRenderer()); videoTrack.addRenderer(new VideoRenderer(videoView)); - + if (userId != 0) { + getVideoTrackMap().put(userId, videoTrack); + } if (!remoteRenderer) { updateVideoView(videoView, isCurrentCameraFront); } Log.d(TAG, (remoteRenderer ? "remote" : "local") + " Track is rendering"); } + private void fillVideoView(QBRTCSurfaceView videoView, QBRTCVideoTrack videoTrack, boolean remoteRenderer) { + fillVideoView(0, videoView, videoTrack, remoteRenderer); + } + /** * @param userId set userId if it from fullscreen videoTrack */ @@ -638,7 +664,7 @@ private void fillVideoView(int userId, QBRTCSurfaceView videoView, QBRTCVideoTra if (userId != 0) { userIDFullScreen = userId; } - fillVideoView(videoView, videoTrack, true); + fillVideoView(userId, videoView, videoTrack, true); } protected void updateVideoView(SurfaceViewRenderer surfaceViewRenderer, boolean mirror) { @@ -667,14 +693,18 @@ private void setStatusForOpponent(int userId, final String status) { } private void updateNameForOpponent(int userId, String newUserName) { - OpponentsFromCallAdapter.ViewHolder holder = findHolder(userId); - if (holder == null) { - Log.d("UPDATE_USERS", "holder == null"); - return; - } + if (isPeerToPeerCall) { + actionBar.setSubtitle(getString(R.string.opponent, newUserName)); + } else { + OpponentsFromCallAdapter.ViewHolder holder = findHolder(userId); + if (holder == null) { + Log.d("UPDATE_USERS", "holder == null"); + return; + } - Log.d("UPDATE_USERS", "holder != null"); - holder.setUserName(newUserName); + Log.d("UPDATE_USERS", "holder != null"); + holder.setUserName(newUserName); + } } private void setProgressBarForOpponentGone(int userId) { @@ -685,12 +715,9 @@ private void setProgressBarForOpponentGone(int userId) { if (holder == null) { return; } - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - holder.getProgressBar().setVisibility(View.GONE); - } - }); + + holder.getProgressBar().setVisibility(View.GONE); + } private void setBackgroundOpponentView(final Integer userId) { @@ -706,11 +733,6 @@ private void setBackgroundOpponentView(final Integer userId) { /////////////////////////////// QBRTCSessionConnectionCallbacks /////////////////////////// - @Override - public void onStartConnectToUser(QBRTCSession qbrtcSession, Integer userId) { - setStatusForOpponent(userId, getString(R.string.text_status_checking)); - } - @Override public void onConnectedToUser(QBRTCSession qbrtcSession, final Integer userId) { connectionEstablished = true; @@ -733,20 +755,6 @@ public void onDisconnectedFromUser(QBRTCSession qbrtcSession, Integer integer) { setStatusForOpponent(integer, getString(R.string.text_status_disconnected)); } - @Override - public void onDisconnectedTimeoutFromUser(QBRTCSession qbrtcSession, Integer integer) { - setStatusForOpponent(integer, getString(R.string.text_status_time_out)); - } - - @Override - public void onConnectionFailedWithUser(QBRTCSession qbrtcSession, Integer integer) { - setStatusForOpponent(integer, getString(R.string.text_status_failed)); - } - - @Override - public void onError(QBRTCSession qbrtcSession, QBRTCException e) { - - } ////////////////////////////////// end ////////////////////////////////////////// @@ -768,7 +776,7 @@ public void onCallAcceptByUser(QBRTCSession session, Integer userId, Map userInfo) { setStatusForOpponent(userId, getString(R.string.text_status_hang_up)); Log.d(TAG, "onReceiveHangUpFromUser userId= " + userId); if (!isPeerToPeerCall) { @@ -778,6 +786,12 @@ public void onReceiveHangUpFromUser(QBRTCSession session, Integer userId) { } } } + + @Override + public void onSessionClosed(QBRTCSession session) { + + } + ////////////////////////////////// end ////////////////////////////////////////// private void setAnotherUserToFullScreen() { @@ -817,16 +831,23 @@ public boolean onOptionsItemSelected(MenuItem item) { Log.d("Conversation", "camera_switch"); switchCamera(item); return true; + case R.id.screen_share: + startScreenSharing(); + return true; default: return super.onOptionsItemSelected(item); } } + private void startScreenSharing() { + conversationFragmentCallbackListener.onStartScreenSharing(); + } + @Override public void onOpponentsListUpdated(ArrayList newUsers) { super.onOpponentsListUpdated(newUsers); updateAllOpponentsList(newUsers); - Log.d("UPDATE_USERS", "updateOpponentsList(), newUsers = " + newUsers); + Log.d(TAG, "updateOpponentsList(), newUsers = " + newUsers); runUpdateUsersNames(newUsers); } @@ -847,7 +868,7 @@ private void runUpdateUsersNames(final ArrayList newUsers) { @Override public void run() { for (QBUser user : newUsers) { - Log.d("UPDATE_USERS", "foreach, user = " + user.getFullName()); + Log.d(TAG, "runUpdateUsersNames. foreach, user = " + user.getFullName()); updateNameForOpponent(user.getId(), user.getFullName()); } } diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/services/CallService.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/services/CallService.java index 30e6d4f3b..cb3626fa0 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/services/CallService.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/services/CallService.java @@ -89,7 +89,6 @@ private void startSuitableActions() { private void createChatService() { if (chatService == null) { QBChatService.setDebugEnabled(true); - QBChatService.setDefaultAutoSendPresenceInterval(60); chatService = QBChatService.getInstance(); } } diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/ChatPingAlarmManager.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/ChatPingAlarmManager.java index 5cdd2be9a..56f8d0dcc 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/ChatPingAlarmManager.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/ChatPingAlarmManager.java @@ -23,7 +23,7 @@ public class ChatPingAlarmManager { //Change interval for your behaviour - private static final long PING_INTERVAL = TimeUnit.SECONDS.toMillis(30); + private static final long PING_INTERVAL = TimeUnit.SECONDS.toMillis(60); private static final String TAG = ChatPingAlarmManager.class.getSimpleName(); private static final String PING_ALARM_ACTION = "com.quickblox.chat.ping.ACTION"; diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/QBResRequestExecutor.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/QBResRequestExecutor.java index 68536d301..8992523be 100644 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/QBResRequestExecutor.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/util/QBResRequestExecutor.java @@ -1,5 +1,10 @@ package com.quickblox.sample.groupchatwebrtc.util; +import android.os.Bundle; +import android.util.Log; + +import com.quickblox.auth.QBAuth; +import com.quickblox.auth.session.QBSession; import com.quickblox.core.QBEntityCallback; import com.quickblox.core.request.QBPagedRequestBuilder; import com.quickblox.users.QBUsers; diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/Consts.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/Consts.java index 094c5e91c..097d0544a 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/Consts.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/Consts.java @@ -7,13 +7,7 @@ */ public interface Consts { - String APP_ID = "39854"; - String AUTH_KEY = "JtensAa9y4AM5Yk"; - String AUTH_SECRET = "AsDFwwwxpr3LN5w"; - String ACCOUNT_KEY = "7yvNe17TnjNUqDoPwfqp"; - - // In GCM, the Sender ID is a project ID that you acquire from the API console - String GCM_SENDER_ID = "761750217637"; + String QB_CONFIG_FILE_NAME = "qb_config.json"; String DEFAULT_USER_PASSWORD = "x6Bt0VDy5"; diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/FragmentExecuotr.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/FragmentExecuotr.java index d93d65553..e12807fbd 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/FragmentExecuotr.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/FragmentExecuotr.java @@ -1,7 +1,7 @@ package com.quickblox.sample.groupchatwebrtc.utils; -import android.app.Fragment; -import android.app.FragmentManager; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; /** * QuickBlox team @@ -12,6 +12,14 @@ public static void addFragment(FragmentManager fragmentManager, int containerId, fragmentManager.beginTransaction().replace(containerId, fragment, tag).commitAllowingStateLoss(); } + public static void addFragmentAtTop(FragmentManager fragmentManager, int containerId, Fragment fragment, String tag) { + fragmentManager.beginTransaction().add(containerId, fragment, tag).commitAllowingStateLoss(); + } + + public static void addFragmentWithBackStack(FragmentManager fragmentManager, int containerId, Fragment fragment, String tag) { + fragmentManager.beginTransaction().replace(containerId, fragment, tag).addToBackStack(null).commitAllowingStateLoss(); + } + public static void removeFragment(FragmentManager fragmentManager, Fragment fragment) { fragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss(); } diff --git a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/SettingsUtil.java b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/SettingsUtil.java index c073fda8c..ed14a5d0f 100755 --- a/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/SettingsUtil.java +++ b/sample-videochat-webrtc/src/main/java/com/quickblox/sample/groupchatwebrtc/utils/SettingsUtil.java @@ -20,10 +20,7 @@ public class SettingsUtil { private static void setSettingsForMultiCall(List users) { if (users.size() <= 4) { - int width = QBRTCMediaConfig.getVideoWidth(); - if (width > QBRTCMediaConfig.VideoQuality.VGA_VIDEO.width) { - setDefaultVideoQuality(); - } + setDefaultVideoQuality(); } else { //set to minimum settings QBRTCMediaConfig.setVideoWidth(QBRTCMediaConfig.VideoQuality.QBGA_VIDEO.width); @@ -167,6 +164,7 @@ private static String getPreferenceString(SharedPreferences sharedPref, Context public static int getPreferenceInt(SharedPreferences sharedPref, Context context, int strResKey, int strResDefValue) { return sharedPref.getInt(context.getString(strResKey), Integer.valueOf(context.getString(strResDefValue))); } + private static boolean getPreferenceBoolean(SharedPreferences sharedPref, Context context, int StrRes, int strResDefValue) { return sharedPref.getBoolean(context.getString(StrRes), Boolean.valueOf(context.getString(strResDefValue))); } diff --git a/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libboringssl.cr.so b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libboringssl.cr.so new file mode 100644 index 000000000..8a0fb2fea Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libboringssl.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libc++_shared.so b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libc++_shared.so new file mode 100644 index 000000000..ff1dfe94e Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libc++_shared.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libjingle_peerconnection_so.so b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libjingle_peerconnection_so.so old mode 100755 new mode 100644 index 7f4d3c5e7..1318c521a Binary files a/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libjingle_peerconnection_so.so and b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libjingle_peerconnection_so.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libprotobuf_lite.cr.so b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libprotobuf_lite.cr.so new file mode 100644 index 000000000..adf12d693 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/arm64-v8a/libprotobuf_lite.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libboringssl.cr.so b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libboringssl.cr.so new file mode 100644 index 000000000..ee36b9ff1 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libboringssl.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libc++_shared.so b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libc++_shared.so new file mode 100644 index 000000000..67c6565a4 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libc++_shared.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libjingle_peerconnection_so.so b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libjingle_peerconnection_so.so old mode 100755 new mode 100644 index 22cc55dc4..332e23c09 Binary files a/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libjingle_peerconnection_so.so and b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libjingle_peerconnection_so.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libprotobuf_lite.cr.so b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libprotobuf_lite.cr.so new file mode 100644 index 000000000..6bca02bf2 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/armeabi-v7a/libprotobuf_lite.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86/libboringssl.cr.so b/sample-videochat-webrtc/src/main/jniLibs/x86/libboringssl.cr.so new file mode 100644 index 000000000..557094686 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86/libboringssl.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86/libc++_shared.so b/sample-videochat-webrtc/src/main/jniLibs/x86/libc++_shared.so new file mode 100644 index 000000000..3517ee443 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86/libc++_shared.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86/libjingle_peerconnection_so.so b/sample-videochat-webrtc/src/main/jniLibs/x86/libjingle_peerconnection_so.so old mode 100755 new mode 100644 index 7bebf09cd..2f40f3403 Binary files a/sample-videochat-webrtc/src/main/jniLibs/x86/libjingle_peerconnection_so.so and b/sample-videochat-webrtc/src/main/jniLibs/x86/libjingle_peerconnection_so.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86/libprotobuf_lite.cr.so b/sample-videochat-webrtc/src/main/jniLibs/x86/libprotobuf_lite.cr.so new file mode 100644 index 000000000..6321138a4 Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86/libprotobuf_lite.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86_64/libboringssl.cr.so b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libboringssl.cr.so new file mode 100644 index 000000000..0317900ee Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libboringssl.cr.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86_64/libc++_shared.so b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libc++_shared.so new file mode 100644 index 000000000..f236917cd Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libc++_shared.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86_64/libjingle_peerconnection_so.so b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libjingle_peerconnection_so.so old mode 100755 new mode 100644 index 6eb72712f..fbfec10b5 Binary files a/sample-videochat-webrtc/src/main/jniLibs/x86_64/libjingle_peerconnection_so.so and b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libjingle_peerconnection_so.so differ diff --git a/sample-videochat-webrtc/src/main/jniLibs/x86_64/libprotobuf_lite.cr.so b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libprotobuf_lite.cr.so new file mode 100644 index 000000000..ec4e0033f Binary files /dev/null and b/sample-videochat-webrtc/src/main/jniLibs/x86_64/libprotobuf_lite.cr.so differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-hdpi/ic_stop_screenshare.png b/sample-videochat-webrtc/src/main/res/drawable-hdpi/ic_stop_screenshare.png new file mode 100644 index 000000000..97a78b8cd Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-hdpi/ic_stop_screenshare.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-hdpi/pres_img.png b/sample-videochat-webrtc/src/main/res/drawable-hdpi/pres_img.png new file mode 100644 index 000000000..83b44d291 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-hdpi/pres_img.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-mdpi/ic_stop_screenshare.png b/sample-videochat-webrtc/src/main/res/drawable-mdpi/ic_stop_screenshare.png new file mode 100644 index 000000000..a10098fcf Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-mdpi/ic_stop_screenshare.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-mdpi/pres_img.png b/sample-videochat-webrtc/src/main/res/drawable-mdpi/pres_img.png new file mode 100644 index 000000000..b7d005d8b Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-mdpi/pres_img.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xhdpi/ic_stop_screenshare.png b/sample-videochat-webrtc/src/main/res/drawable-xhdpi/ic_stop_screenshare.png new file mode 100644 index 000000000..5f05b6c85 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xhdpi/ic_stop_screenshare.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xhdpi/pres_img.png b/sample-videochat-webrtc/src/main/res/drawable-xhdpi/pres_img.png new file mode 100644 index 000000000..15f9884cd Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xhdpi/pres_img.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/ic_stop_screenshare.png b/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/ic_stop_screenshare.png new file mode 100644 index 000000000..5599e5a35 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/ic_stop_screenshare.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/pres_img.png b/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/pres_img.png new file mode 100644 index 000000000..eb493e057 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xxhdpi/pres_img.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/ic_stop_screenshare.png b/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/ic_stop_screenshare.png new file mode 100644 index 000000000..bac4d67b3 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/ic_stop_screenshare.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/pres_img.png b/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/pres_img.png new file mode 100644 index 000000000..10e73171d Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable-xxxhdpi/pres_img.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable/group_call.png b/sample-videochat-webrtc/src/main/res/drawable/group_call.png new file mode 100644 index 000000000..1cef7d925 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable/group_call.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable/login_screen.png b/sample-videochat-webrtc/src/main/res/drawable/login_screen.png new file mode 100644 index 000000000..6ebbaab05 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable/login_screen.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable/opponents.png b/sample-videochat-webrtc/src/main/res/drawable/opponents.png new file mode 100644 index 000000000..ccf01bdc6 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable/opponents.png differ diff --git a/sample-videochat-webrtc/src/main/res/drawable/p2p.png b/sample-videochat-webrtc/src/main/res/drawable/p2p.png new file mode 100644 index 000000000..f04edb804 Binary files /dev/null and b/sample-videochat-webrtc/src/main/res/drawable/p2p.png differ diff --git a/sample-videochat-webrtc/src/main/res/layout/activity_show_image.xml b/sample-videochat-webrtc/src/main/res/layout/activity_show_image.xml new file mode 100644 index 000000000..bbcf3b211 --- /dev/null +++ b/sample-videochat-webrtc/src/main/res/layout/activity_show_image.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/layout/fragment_item_screen_share.xml b/sample-videochat-webrtc/src/main/res/layout/fragment_item_screen_share.xml new file mode 100644 index 000000000..9c822ffed --- /dev/null +++ b/sample-videochat-webrtc/src/main/res/layout/fragment_item_screen_share.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/layout/fragment_pager.xml b/sample-videochat-webrtc/src/main/res/layout/fragment_pager.xml new file mode 100644 index 000000000..c6c1aa8ec --- /dev/null +++ b/sample-videochat-webrtc/src/main/res/layout/fragment_pager.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/layout/fragment_video_conversation.xml b/sample-videochat-webrtc/src/main/res/layout/fragment_video_conversation.xml index 07d8380a7..00c51ba9c 100755 --- a/sample-videochat-webrtc/src/main/res/layout/fragment_video_conversation.xml +++ b/sample-videochat-webrtc/src/main/res/layout/fragment_video_conversation.xml @@ -5,6 +5,7 @@ style="@style/MatchParent" android:background="@color/background_fragment_conversation"> + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/layout/view_action_buttons_conversation_fragment.xml b/sample-videochat-webrtc/src/main/res/layout/view_action_buttons_conversation_fragment.xml index c633f4ef4..fed2e8754 100755 --- a/sample-videochat-webrtc/src/main/res/layout/view_action_buttons_conversation_fragment.xml +++ b/sample-videochat-webrtc/src/main/res/layout/view_action_buttons_conversation_fragment.xml @@ -53,5 +53,4 @@ android:textOff="" android:textOn="" /> - \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/menu/conversation_fragment.xml b/sample-videochat-webrtc/src/main/res/menu/conversation_fragment.xml index 46819669b..dd0167cb6 100644 --- a/sample-videochat-webrtc/src/main/res/menu/conversation_fragment.xml +++ b/sample-videochat-webrtc/src/main/res/menu/conversation_fragment.xml @@ -8,4 +8,11 @@ android:icon="@drawable/ic_camera_front" android:title="@string/action_settings" app:showAsAction="ifRoom" /> + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/menu/screen_share_fragment.xml b/sample-videochat-webrtc/src/main/res/menu/screen_share_fragment.xml new file mode 100644 index 000000000..1b2f22692 --- /dev/null +++ b/sample-videochat-webrtc/src/main/res/menu/screen_share_fragment.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/sample-videochat-webrtc/src/main/res/values/dimens.xml b/sample-videochat-webrtc/src/main/res/values/dimens.xml index afff3f0e3..cdcff8af5 100755 --- a/sample-videochat-webrtc/src/main/res/values/dimens.xml +++ b/sample-videochat-webrtc/src/main/res/values/dimens.xml @@ -59,4 +59,10 @@ 200dp 50dp + + + 400dp + 500dp + + diff --git a/sample-videochat-webrtc/src/main/res/values/strings.xml b/sample-videochat-webrtc/src/main/res/values/strings.xml index d296495e1..be5e3d3d4 100755 --- a/sample-videochat-webrtc/src/main/res/values/strings.xml +++ b/sample-videochat-webrtc/src/main/res/values/strings.xml @@ -18,7 +18,7 @@ - You can select up to %s opponents + You can select up to %d opponents Error creating new user, please try again Sign In error. Error Sign In error @@ -41,6 +41,7 @@ Done Settings + Screen share Update opponents list Logout Video call @@ -200,6 +201,8 @@ and %s other and %s Ringing + Stop + \"Failed switch camera\" 761750217637 diff --git a/screenshots/Qb_config_screen.png b/screenshots/Qb_config_screen.png new file mode 100644 index 000000000..30efbf329 Binary files /dev/null and b/screenshots/Qb_config_screen.png differ diff --git a/sdk-settings.gradle b/sdk-settings.gradle index eeed37b78..330ed1d43 100644 --- a/sdk-settings.gradle +++ b/sdk-settings.gradle @@ -2,6 +2,14 @@ //// include ':quickblox-android-sdk-chat' project(':quickblox-android-sdk-chat').projectDir = new File( '../SDK-android/quickblox-android-sdk-chat') +/* + +include ':quickblox-android-sdk-chat-extensions' +project(':quickblox-android-sdk-chat-extensions').projectDir = new File( '../SDK-android/quickblox-android-sdk-chat-extensions') +*/ + +/*include ':jbosh' +project(':jbosh').projectDir = new File( '../SDK-android/jbosh')*/ include ':quickblox-android-sdk-content' project(':quickblox-android-sdk-content').projectDir = new File('../SDK-android/quickblox-android-sdk-content') @@ -9,14 +17,14 @@ project(':quickblox-android-sdk-content').projectDir = new File('../SDK-android/ include ':quickblox-android-sdk-core' project(':quickblox-android-sdk-core').projectDir = new File('../SDK-android/quickblox-android-sdk-core') -include ':quickblox-android-sdk-customobjects' +/*include ':quickblox-android-sdk-customobjects' project(':quickblox-android-sdk-customobjects').projectDir = new File( '../SDK-android/quickblox-android-sdk-customobjects') include ':quickblox-android-sdk-location' -project(':quickblox-android-sdk-location').projectDir = new File('../SDK-android/quickblox-android-sdk-location') +project(':quickblox-android-sdk-location').projectDir = new File('../SDK-android/quickblox-android-sdk-location')*/ include ':quickblox-android-sdk-messages' project(':quickblox-android-sdk-messages').projectDir = new File( '../SDK-android/quickblox-android-sdk-messages') include ':quickblox-android-sdk-videochat-webrtc' -project(':quickblox-android-sdk-videochat-webrtc').projectDir = new File( '../SDK-android/quickblox-android-sdk-videochat-webrtc') \ No newline at end of file +project(':quickblox-android-sdk-videochat-webrtc').projectDir = new File( '../SDK-android/quickblox-android-sdk-videochat-webrtc') diff --git a/snippets/src/main/java/com/sdk/snippets/modules/SnippetsChat.java b/snippets/src/main/java/com/sdk/snippets/modules/SnippetsChat.java index f713920d6..8086cc01a 100644 --- a/snippets/src/main/java/com/sdk/snippets/modules/SnippetsChat.java +++ b/snippets/src/main/java/com/sdk/snippets/modules/SnippetsChat.java @@ -22,15 +22,14 @@ import com.quickblox.chat.listeners.QBSubscriptionListener; import com.quickblox.chat.listeners.QBSystemMessageListener; import com.quickblox.chat.model.QBAttachment; -import com.quickblox.chat.model.QBChatMessage; import com.quickblox.chat.model.QBChatDialog; +import com.quickblox.chat.model.QBChatMessage; import com.quickblox.chat.model.QBDialogCustomData; import com.quickblox.chat.model.QBDialogType; import com.quickblox.chat.model.QBPresence; import com.quickblox.chat.model.QBPrivacyList; import com.quickblox.chat.model.QBPrivacyListItem; import com.quickblox.chat.model.QBRosterEntry; -import com.quickblox.chat.utils.DialogUtils; import com.quickblox.core.QBEntityCallback; import com.quickblox.core.exception.QBResponseException; import com.quickblox.core.helper.StringifyArrayList;