8 |
9 |
10 |
125 |
126 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | - Demonstrating empathy and kindness toward other people
21 | - Being respectful of differing opinions, viewpoints, and experiences
22 | - Giving and gracefully accepting constructive feedback
23 | - Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | - Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | - The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | - Trolling, insulting or derogatory comments, and personal or political attacks
33 | - Public or private harassment
34 | - Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | - Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | devrel@vonage.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tokbox/android/demo/learningopentok/ChatActivity.java:
--------------------------------------------------------------------------------
1 | package com.tokbox.android.demo.learningopentok;
2 |
3 | import android.support.v7.app.ActionBarActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 | import android.widget.FrameLayout;
9 |
10 | import com.opentok.android.Session;
11 | import com.opentok.android.Stream;
12 | import com.opentok.android.Publisher;
13 | import com.opentok.android.PublisherKit;
14 | import com.opentok.android.Subscriber;
15 | import com.opentok.android.SubscriberKit;
16 | import com.opentok.android.BaseVideoRenderer;
17 | import com.opentok.android.OpentokError;
18 |
19 |
20 | public class ChatActivity extends ActionBarActivity implements WebServiceCoordinator.Listener,
21 | Session.SessionListener, PublisherKit.PublisherListener, SubscriberKit.SubscriberListener {
22 |
23 | private static final String LOG_TAG = ChatActivity.class.getSimpleName();
24 |
25 | // Suppressing this warning. mWebServiceCoordinator will get GarbageCollected if it is local.
26 | @SuppressWarnings("FieldCanBeLocal")
27 | private WebServiceCoordinator mWebServiceCoordinator;
28 |
29 | private String mApiKey;
30 | private String mSessionId;
31 | private String mToken;
32 | private Session mSession;
33 | private Publisher mPublisher;
34 | private Subscriber mSubscriber;
35 |
36 | private FrameLayout mPublisherViewContainer;
37 | private FrameLayout mSubscriberViewContainer;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_chat);
43 |
44 | // initialize view objects from your layout
45 | mPublisherViewContainer = (FrameLayout)findViewById(R.id.publisher_container);
46 | mSubscriberViewContainer = (FrameLayout)findViewById(R.id.subscriber_container);
47 |
48 | // initialize WebServiceCoordinator and kick off request for necessary data
49 | mWebServiceCoordinator = new WebServiceCoordinator(this, this);
50 | mWebServiceCoordinator.fetchSessionConnectionData();
51 | }
52 |
53 | @Override
54 | public boolean onCreateOptionsMenu(Menu menu) {
55 | // Inflate the menu; this adds items to the action bar if it is present.
56 | getMenuInflater().inflate(R.menu.menu_chat, menu);
57 | return true;
58 | }
59 |
60 | @Override
61 | public boolean onOptionsItemSelected(MenuItem item) {
62 | // Handle action bar item clicks here. The action bar will
63 | // automatically handle clicks on the Home/Up button, so long
64 | // as you specify a parent activity in AndroidManifest.xml.
65 | int id = item.getItemId();
66 |
67 | //noinspection SimplifiableIfStatement
68 | if (id == R.id.action_settings) {
69 | return true;
70 | }
71 |
72 | return super.onOptionsItemSelected(item);
73 | }
74 |
75 | private void initializeSession() {
76 | mSession = new Session.Builder(this, mApiKey, mSessionId).build();
77 | mSession.setSessionListener(this);
78 | mSession.connect(mToken);
79 | }
80 |
81 | private void initializePublisher() {
82 | // initialize Publisher and set this object to listen to Publisher events
83 | mPublisher = new Publisher.Builder(this).build();
84 | mPublisher.setPublisherListener(this);
85 |
86 | // set publisher video style to fill view
87 | mPublisher.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE,
88 | BaseVideoRenderer.STYLE_VIDEO_FILL);
89 | mPublisherViewContainer.addView(mPublisher.getView());
90 | }
91 |
92 | private void logOpenTokError(OpentokError opentokError) {
93 | Log.e(LOG_TAG, "Error Domain: " + opentokError.getErrorDomain().name());
94 | Log.e(LOG_TAG, "Error Code: " + opentokError.getErrorCode().name());
95 | }
96 |
97 | /* Web Service Coordinator delegate methods */
98 |
99 | @Override
100 | public void onSessionConnectionDataReady(String apiKey, String sessionId, String token) {
101 | mApiKey = apiKey;
102 | mSessionId = sessionId;
103 | mToken = token;
104 |
105 | initializeSession();
106 | initializePublisher();
107 | }
108 |
109 | @Override
110 | public void onWebServiceCoordinatorError(Exception error) {
111 | Log.e(LOG_TAG, "Web Service error: " + error.getMessage());
112 | }
113 |
114 | /* Session Listener methods */
115 |
116 | @Override
117 | public void onConnected(Session session) {
118 | Log.i(LOG_TAG, "Session Connected");
119 |
120 | if (mPublisher != null) {
121 | mSession.publish(mPublisher);
122 | }
123 | }
124 |
125 | @Override
126 | public void onDisconnected(Session session) {
127 | Log.i(LOG_TAG, "Session Disconnected");
128 | }
129 |
130 | @Override
131 | public void onStreamReceived(Session session, Stream stream) {
132 | Log.i(LOG_TAG, "Stream Received");
133 |
134 | if (mSubscriber == null) {
135 | mSubscriber = new Subscriber.Builder(this, stream).build();
136 | mSubscriber.setSubscriberListener(this);
137 | mSubscriber.getRenderer().setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE,
138 | BaseVideoRenderer.STYLE_VIDEO_FILL);
139 | mSession.subscribe(mSubscriber);
140 | }
141 | }
142 |
143 | @Override
144 | public void onStreamDropped(Session session, Stream stream) {
145 | Log.i(LOG_TAG, "Stream Dropped");
146 |
147 | if (mSubscriber != null) {
148 | mSubscriber = null;
149 | mSubscriberViewContainer.removeAllViews();
150 | }
151 | }
152 |
153 | @Override
154 | public void onError(Session session, OpentokError opentokError) {
155 | logOpenTokError(opentokError);
156 | }
157 |
158 | /* Publisher Listener methods */
159 |
160 | @Override
161 | public void onStreamCreated(PublisherKit publisherKit, Stream stream) {
162 | Log.i(LOG_TAG, "Publisher Stream Created");
163 | }
164 |
165 | @Override
166 | public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) {
167 | Log.i(LOG_TAG, "Publisher Stream Destroyed");
168 | }
169 |
170 | @Override
171 | public void onError(PublisherKit publisherKit, OpentokError opentokError) {
172 | logOpenTokError(opentokError);
173 | }
174 |
175 | /* Subscriber Listener methods */
176 |
177 | @Override
178 | public void onConnected(SubscriberKit subscriberKit) {
179 | Log.i(LOG_TAG, "Subscriber Connected");
180 |
181 | mSubscriberViewContainer.addView(mSubscriber.getView());
182 | }
183 |
184 | @Override
185 | public void onDisconnected(SubscriberKit subscriberKit) {
186 | Log.i(LOG_TAG, "Subscriber Disconnected");
187 | }
188 |
189 | @Override
190 | public void onError(SubscriberKit subscriberKit, OpentokError opentokError) {
191 | logOpenTokError(opentokError);
192 | }
193 | }
194 |
--------------------------------------------------------------------------------