Skip to content

Commit

Permalink
adopt new S4D/spark-android-sdk. commit c0fc17e8ae111666f8e71ac062810…
Browse files Browse the repository at this point in the history
…76de96c5239
  • Loading branch information
xionxiao committed Aug 29, 2017
1 parent 5cb2e68 commit 256e243
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 279 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 10 additions & 91 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ android {
multiDexEnabled true
}



packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}

buildTypes {
release {
Expand All @@ -36,16 +41,12 @@ android {
abi {
enable true
reset()
include 'armeabi-v7a'
include 'armeabi-v7a', 'x86'
universalApk false
}
}
}

dependencies {
compile project(':common-prod-debug')
compile project(':sdk-dev-debug')
}

repositories {
flatDir {
Expand All @@ -63,7 +64,7 @@ dependencies {
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
testCompile 'junit:junit:4.12'

compile project(':sdk-debug')
}


Expand All @@ -85,87 +86,6 @@ dependencies {
}
dependencies {

//old
/*
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//lm
compile libs.ln
compile 'com.android.support:multidex:1.0.1'
compile libs.dagger
provided libs.daggercompiler
compile libs.eventbus
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile libs.supportv13
compile libs.supportannotation
compile libs.appcompatv7
compile libs.recyclerviewv7
compile libs.cardviewv7
compile libs.supportdesign
compile libs.gridlayout
compile libs.gson
compile libs.retrofit
compile libs.retrofit_gsonconverter
compile libs.retrofit_deprecated
compile libs.okhttp3_for_retrofit1
compile libs.retrofit_rxjava
compile libs.okhttp
compile libs.okhttp_logging
compile libs.websocket
compile libs.dagger
provided libs.daggercompiler
compile libs.eventbus
compile 'com.jakewharton:butterknife:7.0.1'
compile libs.spongycastle_prov
compile libs.spongycastle_core
compile libs.kms
compile libs.wmeaar
compile libs.rxjava
compile libs.rxandroid
compile libs.will
debugCompile libs.leak_canary
releaseCompile libs.leak_canary_disabled
testCompile libs.leak_canary_disabled
androidTestCompile libs.leak_canary_disabled
compile libs.rxrelay
testCompile libs.junit
testCompile libs.robolectric
testCompile libs.robolectric_multidex
testCompile libs.mockito
compile 'joda-time:joda-time:2.9.2'
*/

compile fileTree(dir: 'libs', include: ['*.jar'])

testCompile 'junit:junit:4.12'
Expand Down Expand Up @@ -207,11 +127,9 @@ dependencies {

compile libs.sqlcipher

/*
compile libs.fasterxml_annotations
compile libs.fasterxml_databind
compile libs.fasterxml_core
*/

debugCompile libs.leak_canary
releaseCompile libs.leak_canary_disabled
Expand All @@ -228,6 +146,7 @@ dependencies {
compile 'com.cisco.wx2:diagnostic-events-gson:1.0.86'

compile 'com.segment.analytics.android:analytics:4.3.0-RC1'
compile 'com.cisco.spark.android:common-lib:2.0.3886@aar'


}
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<activity
android:name=".dialActivity"
android:configChanges="orientation|screenSize"></activity>
<provider
android:name="com.cisco.spark.android.sync.ConversationContentProvider"
android:authorities="com.cisco.spark.android.sync.conversation"
android:exported="false"
/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.ciscospark.common.SparkError;
import com.ciscospark.SparkError;
import com.ciscospark.phone.Call;
import com.ciscospark.phone.CallOption;
import com.ciscospark.phone.DialObserver;
Expand All @@ -36,7 +36,7 @@ public class CallActivity extends AppCompatActivity {
public Call mActiveCall;
private MyCallObserver mActiveCallObserver;

private KitchenSinkApplication myapplication;
private KitchenSinkApplication myApplication;

Button hangupButton;

Expand All @@ -54,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
localView = (WseSurfaceView) findViewById(R.id.localView);
remoteView = (WseSurfaceView) findViewById(R.id.remoteView);

myapplication = (KitchenSinkApplication)getApplication();
myApplication = (KitchenSinkApplication)getApplication();

mActiveCallObserver = new MyCallObserver(this);

Expand Down Expand Up @@ -105,9 +105,8 @@ private void setupWaitingCallFragment() {

private void waitForIncomingCall() {
KitchenSinkApplication application = (KitchenSinkApplication) getApplication();
if (application.mSpark.getStrategy().isAuthorized()) {
Phone phone = application.mSpark.phone();
phone.setIncomingCallObserver(new IncomingCallObserver() {
if (application.mSpark.getAuthenticator().isAuthorized()) {
application.mPhone.setIncomingCallObserver(new IncomingCallObserver() {
@Override
public void onIncomingCall(Call call) {
mActiveCall = call;
Expand Down Expand Up @@ -143,8 +142,8 @@ public void answerCall() {
private void call(){
Log.i(TAG, "call: ->start");

this.dialCallee = myapplication.callee;
this.isAudioCall = myapplication.isAudioCall;
this.dialCallee = myApplication.callee;
this.isAudioCall = myApplication.isAudioCall;

if(this.isAudioCall){
this.audioCall(this.dialCallee);
Expand Down Expand Up @@ -177,7 +176,7 @@ private void videoCall(String dialstring) {

CallOption options = new CallOption(CallOption.CallType.VIDEO, this.remoteView, this.localView);

this.myapplication.mSpark.phone().dial(dialstring, options, new DialObserver() {
this.myApplication.mPhone.dial(dialstring, options, new DialObserver() {
@Override
public void onSuccess(Call call) {
Log.i(TAG, "DialObserver-> onSuccess");
Expand Down Expand Up @@ -206,7 +205,7 @@ public void onPermissionRequired(List<String> list) {
private void audioCall(String dialstring) {
Log.i(TAG, "audioCall: ->start");
CallOption options = new CallOption(CallOption.CallType.AUDIO, null, null);
this.myapplication.mSpark.phone().dial(dialstring, options, new DialObserver() {
this.myApplication.mSpark.phone().dial(dialstring, options, new DialObserver() {
@Override
public void onSuccess(Call call) {
Log.i(TAG, "DialObserver-> onSuccess");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.cisco.sparksdk.sparkkitchensink;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.cisco.spark.android.authenticator.OAuth2AccessToken;
import com.ciscospark.CompletionHandler;
import com.ciscospark.SparkError;
import com.ciscospark.auth.Authenticator;
import com.ciscospark.auth.AuthorizeListener;
import com.ciscospark.auth.JWTAuthenticator;
import com.ciscospark.common.SparkError;

public class JWTActivity extends AppCompatActivity {

Expand All @@ -25,15 +24,15 @@ public class JWTActivity extends AppCompatActivity {

private Authenticator strategy;

private KitchenSinkApplication myapplication;
private KitchenSinkApplication myApplication;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_jwt);

myapplication = (KitchenSinkApplication)getApplication();
myApplication = (KitchenSinkApplication) getApplication();

Log.i(TAG, "onCreate: ->start");

Expand All @@ -45,58 +44,51 @@ public void onClick(View v) {

String jwtKey = editTextJWT.getText().toString();
if (jwtKey.isEmpty()) {
/*
Toast.makeText(JWTActivity.this, "JWT Token cannot be empty", Toast
.LENGTH_SHORT).show();
return;
*/
jwtKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMSIsIm5hbWUiOiJ1c2VyICMxIiwiaXNzIjoiY2Q1YzlhZjctOGVkMy00ZTE1LTk3MDUtMDI1ZWYzMGIxYjZhIn0.nQTlT_WwkHdWZTCNi4tVl2IA476nAWo34oxtuTlLSDk";
}

Toast.makeText(JWTActivity.this, "JWT authoring", Toast.LENGTH_SHORT).show();

JWTAuthenticator authenticator = new JWTAuthenticator();
JWTAuthenticator authenticator = new JWTAuthenticator(jwtKey);
strategy = authenticator;



JWTActivity.this.myapplication.mSpark.init(strategy);

authenticator.authorize(jwtKey);
if (strategy.isAuthorized()) {
strategy.accessToken(new AuthorizeListener() {
@Override
public void onSuccess(OAuth2AccessToken token) {
Log.d(TAG, token.getAccessToken());
Toast.makeText(JWTActivity.this, "JWT auth success", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(JWTActivity.this, RegistryActivity.class);

JWTActivity.this.startActivity(intent);

}

@Override
public void onFailed(SparkError<AuthError> error) {
Toast.makeText(JWTActivity.this, "JWT auth failed", Toast.LENGTH_SHORT).show();
}
});
}

myApplication.mSpark.setAuthenticator(strategy);

myApplication.mSpark.authorize(new CompletionHandler<String>() {
@Override
public void onComplete(String s) {
Log.d(TAG, s);
Toast.makeText(JWTActivity.this, "JWT auth success", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(JWTActivity.this, RegistryActivity.class);
JWTActivity.this.startActivity(intent);
}

@Override
public void onError(SparkError sparkError) {
Toast.makeText(JWTActivity.this, "JWT auth failed", Toast.LENGTH_SHORT).show();
}
});
}



});


}

private boolean exit = false;

@Override
public void onBackPressed() {
if (exit) {
this.finish();
}
else {
Toast.makeText(this, "Press Back again to Exit.",Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Press Back again to Exit.", Toast.LENGTH_SHORT).show();
exit = true;
new Handler().postDelayed(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class KitchenSinkApplication extends SparkApplication {

public Spark mSpark;
public Phone mPhone;

public OAuth2AccessToken token;

Expand Down
Loading

0 comments on commit 256e243

Please sign in to comment.