Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ba3de77
Showing
31 changed files
with
1,700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "23.0.3" | ||
defaultConfig { | ||
applicationId "com.gwelldemo" | ||
minSdkVersion 15 | ||
targetSdkVersion 22 | ||
versionCode 1 | ||
versionName "00.00.00.01" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:24.2.1' | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.p2p.core:p2p-core:0.0.5' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/dansesshou/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/example/dansesshou/jcentertest/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.dansesshou.jcentertest; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.example.dansesshou.jcentertest", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.gwelldemo"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:name="com.example.dansesshou.jcentertest.MyApp" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name="com.example.dansesshou.jcentertest.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="com.example.dansesshou.jcentertest.MonitoerActivity"> | ||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/example/dansesshou/jcentertest/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.example.dansesshou.jcentertest; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.Toast; | ||
|
||
import com.gwelldemo.R; | ||
import com.p2p.core.P2PSpecial.P2PSpecial; | ||
import com.p2p.core.network.LoginResult; | ||
|
||
public class MainActivity extends AppCompatActivity implements View.OnClickListener{ | ||
private Button btnIn; | ||
private Context mContext; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
mContext=this; | ||
setContentView(R.layout.activity_main); | ||
initUI(); | ||
initData(); | ||
} | ||
private void initUI() { | ||
btnIn= (Button) findViewById(R.id.btn_in); | ||
btnIn.setOnClickListener(this); | ||
} | ||
|
||
private void initData() { | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()){ | ||
case R.id.btn_in: | ||
P2PSpecial.getInstance().P2PConnect(MyApp.APPID,MyApp.APPToken,MyApp.APPVersion,callBack); | ||
break; | ||
} | ||
} | ||
private P2PSpecial.P2PConnectCallBack callBack=new P2PSpecial.P2PConnectCallBack() { | ||
@Override | ||
public void P2PConnectResult(boolean connectState, LoginResult result) { | ||
if(connectState){ | ||
Intent callIntent=new Intent(mContext,MonitoerActivity.class); | ||
callIntent.putExtra("LoginID",result.contactId); | ||
startActivity(callIntent); | ||
}else{ | ||
if(result!=null){ | ||
Toast.makeText(mContext,"error_code:"+result.error_code, Toast.LENGTH_LONG).show(); | ||
}else{ | ||
Toast.makeText(mContext,"error_code:result==null", Toast.LENGTH_LONG).show(); | ||
} | ||
|
||
} | ||
} | ||
}; | ||
} |
136 changes: 136 additions & 0 deletions
136
app/src/main/java/com/example/dansesshou/jcentertest/MonitoerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.example.dansesshou.jcentertest; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.TextView; | ||
|
||
import com.gwelldemo.R; | ||
import com.p2p.core.BaseMonitorActivity; | ||
import com.p2p.core.P2PHandler; | ||
import com.p2p.core.P2PView; | ||
|
||
public class MonitoerActivity extends BaseMonitorActivity implements View.OnClickListener{ | ||
public static String P2P_ACCEPT = "com.yoosee.P2P_ACCEPT"; | ||
public static String P2P_READY = "com.yoosee.P2P_READY"; | ||
public static String P2P_REJECT = "com.yoosee.P2P_REJECT"; | ||
private Button btnCall; | ||
private EditText et_callId; | ||
private EditText et_callPwd ; | ||
private String callID,CallPwd; | ||
private TextView tv_content,tx_acount; | ||
private String LoginID; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_monitoer); | ||
LoginID=getIntent().getStringExtra("LoginID"); | ||
initUI(); | ||
regFilter(); | ||
initData(); | ||
} | ||
|
||
private void initUI() { | ||
btnCall= (Button) findViewById(R.id.btn_call); | ||
pView= (P2PView) findViewById(R.id.p2pview); | ||
tv_content = (TextView) findViewById(R.id.tv_content); | ||
et_callId = (EditText) findViewById(R.id.et_id); | ||
et_callPwd = (EditText) findViewById(R.id.et_pwd); | ||
tx_acount= (TextView) findViewById(R.id.tx_acount); | ||
initP2PView(7, P2PView.LAYOUTTYPE_TOGGEDER);//7是设备类型(技威定义的) | ||
btnCall.setOnClickListener(this); | ||
} | ||
|
||
private void initData() { | ||
tx_acount.setText(LoginID); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()){ | ||
case R.id.btn_call: | ||
callID = et_callId.getText().toString().trim();//设备号 | ||
CallPwd = et_callPwd.getText().toString().trim(); | ||
String pwd = P2PHandler.getInstance().EntryPassword(CallPwd);//经过转换后的设备密码 | ||
Log.e("dxsTest","LoginID:"+LoginID+"callID:"+callID); | ||
P2PHandler.getInstance().call(LoginID, pwd, true, 1,callID, "", "", 2,callID); | ||
break; | ||
} | ||
} | ||
|
||
public void regFilter() { | ||
IntentFilter filter = new IntentFilter(); | ||
filter.addAction(P2P_REJECT); | ||
filter.addAction(P2P_ACCEPT); | ||
filter.addAction(P2P_READY); | ||
registerReceiver(mReceiver, filter); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
unregisterReceiver(mReceiver); | ||
P2PHandler.getInstance().reject(); | ||
P2PHandler.getInstance().p2pDisconnect(); | ||
super.onDestroy(); | ||
|
||
} | ||
|
||
public BroadcastReceiver mReceiver = new BroadcastReceiver() { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
if(intent.getAction().equals(P2P_ACCEPT)){ | ||
tv_content.append("\n 监控数据接收"); | ||
Log.e("dxsTest","监控数据接收:"+callID); | ||
P2PHandler.getInstance().openAudioAndStartPlaying(1);//打开音频并准备播放,calllType与call时type一致 | ||
}else if(intent.getAction().equals(P2P_READY)){ | ||
tv_content.append("\n 监控准备,开始监控"); | ||
Log.e("dxsTest","监控准备,开始监控"+callID); | ||
pView.sendStartBrod(); | ||
setMute(true); //设置手机静音 | ||
}else if(intent.getAction().equals(P2P_REJECT)){ | ||
tv_content.append("\n 监控挂断"); | ||
} | ||
} | ||
}; | ||
|
||
@Override | ||
protected void onP2PViewSingleTap() { | ||
|
||
} | ||
|
||
@Override | ||
protected void onCaptureScreenResult(boolean isSuccess, int prePoint) { | ||
|
||
} | ||
|
||
@Override | ||
protected void onVideoPTS(long videoPTS) { | ||
|
||
} | ||
|
||
@Override | ||
public int getActivityInfo() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
protected void onGoBack() { | ||
|
||
} | ||
|
||
@Override | ||
protected void onGoFront() { | ||
|
||
} | ||
|
||
@Override | ||
protected void onExit() { | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/example/dansesshou/jcentertest/MyApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.dansesshou.jcentertest; | ||
|
||
import android.app.Application; | ||
|
||
import com.p2p.core.P2PSpecial.P2PSpecial; | ||
|
||
|
||
/** | ||
* Created by dxs on 2016/11/29. | ||
*/ | ||
|
||
public class MyApp extends Application { | ||
public static MyApp app; | ||
//two parems come frome Gwell , the value below just test | ||
public final static String APPID="1e9a2c3ead108413e8218a639c540e44"; | ||
public final static String APPToken="7db7b2bff80a025a3dad546a4d5a6c3ee545568d4e0ce9609c0585c71c287d08"; | ||
public final static String APPVersion="00.00.00.01"; | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
app = this; | ||
initP2P(app); | ||
} | ||
|
||
private void initP2P(MyApp app) { | ||
P2PSpecial.getInstance().init(app,new P2PListener(),new SettingListener()); | ||
} | ||
} |
Oops, something went wrong.