.DS_StoreBinary files differ
HDLLinphoneSDKDemoNew/.DS_StoreBinary files differ
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/.DS_StoreBinary files differ
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/AndroidManifest.xml
@@ -21,7 +21,11 @@ android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true"> <activity android:name=".activity.HDLLinphoneReverseCallActivity"></activity> <activity android:name=".activity.HDLLinphoneReverseCallActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".activity.HDLLinphoneMonitorActivity" /> <activity android:name=".activity.HDLLinphoneIntercomActivity" /> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/HDLLinphoneKit.java
@@ -2,10 +2,12 @@ import android.content.Context; import android.content.Intent; import android.util.Log; import android.view.TextureView; import android.widget.Toast; import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity; import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity; import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener; import com.hdl.hdllinphonesdk.callback.OnLPOpenDoorCallBack; import com.hdl.hdllinphonesdk.core.callback.PhoneCallback; @@ -25,12 +27,36 @@ import org.linphone.core.ProxyConfig; import org.linphone.core.TransportType; import java.io.FileOutputStream; import java.io.InputStream; import static java.lang.Thread.sleep; /** * Created by jlchen on 2021/8/4. */ public class HDLLinphoneKit { /** * 丰林可视对讲 */ public static final String INTER_PHONE_TYPE_FLVI = "FLVI"; /** * 大华可视对讲 */ public static final String INTER_PHONE_TYPE_IMOUVISIAL = "IMOUVISIAL"; /** * 萤石猫眼 */ public static final String INTER_PHONE_TYPE_EZVIZ = "EZVIZ"; /** * HDL可视对讲 */ public static final String INTER_PHONE_TYPE_HDL = "HDL"; /** * 全视通可视对讲 */ public static final String INTER_PHONE_TYPE_FREEVIEW = "FREEVIEW"; public static final String KEY_TITLE_NAME = "lpTitleName"; public static final String KEY_SIP_ACCOUNT = "lpSipAccount"; public static final String HDLLinphoneKitNAME = "HDLLinphoneKit"; @@ -38,7 +64,7 @@ private Context viewContext; private ServiceWaitThread mServiceWaitThread; private String mUsername, mPassword, mServerIP; // private TextureView mRenderingView, mPreviewView; // private TextureView mRenderingView, mPreviewView; private boolean isAutoJumpCallView;//是否自动跳转呼叫页面 private HDLLinphoneKit() { @@ -47,6 +73,7 @@ /** * getInstance * * @return HDLLinphoneKit */ public static synchronized HDLLinphoneKit getInstance() { @@ -66,16 +93,17 @@ * @return Core */ public Core getCore() { if(!HDLLinphoneService.isReady()){ if (!HDLLinphoneService.isReady()) { CheckIfNeedstartService(); return null; }else { } else { return HDLLinphoneService.getCore(); } } /** * 初始化Linphone * * @param context */ public void initLinphone(Context context) { @@ -83,14 +111,13 @@ if (!HDLLinphoneService.isReady()) { CheckIfNeedstartService(); } else { } } /** * startService */ private synchronized void CheckIfNeedstartService(){ private synchronized void CheckIfNeedstartService() { startService(viewContext); addCallback(new RegistrationCallback() { @Override @@ -98,7 +125,6 @@ super.registrationOk(); HDLLog.e(HDLLinphoneKitNAME, "registrationOk: "); callBackRegistrationOk(viewContext); } @Override @@ -159,9 +185,13 @@ * 跳转打开呼叫页面 */ public void gotoHDLLinphoneIntercomActivity() { Intent intent = new Intent(viewContext, HDLLinphoneIntercomActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); viewContext.startActivity(intent); try { Intent intent = new Intent(viewContext, HDLLinphoneIntercomActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); viewContext.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } } /** @@ -215,11 +245,11 @@ * @param password 密码 * @param serverIP sip 服务器 */ public void setAccountAndLogin(String username, String password, String serverIP) { public void setAccountAndLogin(String username, String password, String serverIP, String inter_type) { mUsername = username; mPassword = password; mServerIP = serverIP; login(); login(inter_type); } /** @@ -228,8 +258,7 @@ * @param phoneCallback 通话回调 * @param registrationCallback 注册状态回调 */ public void addCallback(RegistrationCallback registrationCallback, PhoneCallback phoneCallback) { public void addCallback(RegistrationCallback registrationCallback, PhoneCallback phoneCallback) { if (HDLLinphoneService.isReady()) { HDLLinphoneService.addRegistrationCallback(registrationCallback); HDLLinphoneService.addPhoneCallback(phoneCallback); @@ -242,19 +271,16 @@ /** * 登录到 SIP 服务器 */ public void login() { new Thread(new Runnable() { @Override public void run() { while (!HDLLinphoneService.isReady()) { try { sleep(80); } catch (InterruptedException e) { e.printStackTrace(); } public void login(String inter_type) { new Thread(() -> { while (!HDLLinphoneService.isReady()) { try { sleep(80); } catch (InterruptedException e) { e.printStackTrace(); } loginToServer(); } loginToServer(inter_type); }).start(); } @@ -283,7 +309,7 @@ /** * 清除配置表, 切换账号时会用到 */ public void clearProxyConfig(){ public void clearProxyConfig() { Core core = HDLLinphoneService.getCore(); if (core != null) { core.setDefaultProxyConfig(null); @@ -323,16 +349,23 @@ /** * 登录 SIP 服务器 */ private void loginToServer() { private void loginToServer(String inter_type) { try { if (mUsername == null || mPassword == null || mServerIP == null) { throw new RuntimeException("The sip account is not configured."); } registerUserAuth(mUsername, mPassword, mServerIP); if (inter_type.equals(INTER_PHONE_TYPE_FREEVIEW)) { // 全视通可视对讲注册 freeViewRegisterUserAuth(mUsername, mPassword, mServerIP); } else { // 其他可视对讲注册 registerUserAuth(mUsername, mPassword, mServerIP); } } catch (CoreException e) { e.printStackTrace(); } } /** * 提交账号和密码注册到服务器 * @@ -343,11 +376,9 @@ */ public void registerUserAuth(String name, String password, String host) throws CoreException { Core mLinphoneCore = HDLLinphoneService.getCore(); if(mLinphoneCore == null) return; if (mLinphoneCore == null) return; AuthInfo authInfo = Factory.instance().createAuthInfo(name, null, password, null, null, host); AuthInfo authInfo = Factory.instance().createAuthInfo(name, null, password, null, null, host); AccountCreator mAccountCreator = mLinphoneCore.createAccountCreator(null); mAccountCreator.setUsername(name); mAccountCreator.setDomain(host); @@ -365,15 +396,45 @@ } /** * 呼叫 * 提交账号和密码注册到全视通服务器 * * @throws CoreException */ public void freeViewRegisterUserAuth(String userName, String password, String domain) throws CoreException { Core mLinphoneCore = HDLLinphoneService.getCore(); if (mLinphoneCore == null) return; AuthInfo authInfo = Factory.instance().createAuthInfo(userName, "", password, null, null, domain); AccountCreator mAccountCreator = mLinphoneCore.createAccountCreator(null); mAccountCreator.setUsername(userName); mAccountCreator.setDomain("yun"); mAccountCreator.setPassword(password); mAccountCreator.setTransport(TransportType.Udp); ProxyConfig prxCfg = mAccountCreator.createProxyConfig(); prxCfg.enableQualityReporting(false); prxCfg.setQualityReportingCollector(null); prxCfg.setQualityReportingInterval(0); prxCfg.enableRegister(true); prxCfg.setServerAddr("sip:139.159.157.75:46000;transport=udp"); mLinphoneCore.addProxyConfig(prxCfg);//添加代理配置。如果启用了注册,这将开始在代理上注册。 mLinphoneCore.addAuthInfo(authInfo);//添加认证信息到,该信息片段将在所有需要的SIP事务中使用身份验证 mLinphoneCore.setDefaultProxyConfig(prxCfg);//设置默认代理。 } /** * 呼叫,全视通可视对讲需要将 外出代理服务器打开,才能使用 空间号呼叫; * 暂时没找到怎么打开,所以需要手动加上proxy */ public Call startSingleCallingTo(String userName, boolean isVideoCall) { Core mLinphoneCore = HDLLinphoneService.getCore(); if(mLinphoneCore == null) return null; if (mLinphoneCore == null) return null; Call call = null; Core core = HDLLinphoneService.getCore(); if(core != null) { if (core != null) { Address addressToCall = core.interpretUrl(userName); CallParams params = core.createCallParams(null); @@ -412,7 +473,7 @@ */ public void acceptCall() { try { if(HDLLinphoneService.getCore() == null) return; if (HDLLinphoneService.getCore() == null) return; Call currentCall = HDLLinphoneService.getCore().getCurrentCall(); CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall); params.enableVideo(true); @@ -428,7 +489,7 @@ */ public void acceptCallWithVideo(boolean enableVideo) { try { if(HDLLinphoneService.getCore() == null) return; if (HDLLinphoneService.getCore() == null) return; Call currentCall = HDLLinphoneService.getCore().getCurrentCall(); CallParams params = HDLLinphoneService.getCore().createCallParams(currentCall); params.enableVideo(enableVideo); @@ -444,7 +505,7 @@ */ public void hangUp() { Core mLinphoneCore = HDLLinphoneService.getCore(); if(mLinphoneCore == null) return; if (mLinphoneCore == null) return; Call currentCall = mLinphoneCore.getCurrentCall(); if (currentCall != null) { // mLinphoneCore.terminateCall(currentCall); @@ -463,7 +524,7 @@ */ public void toggleMicro(boolean isMicMuted) { Core mLinphoneCore = HDLLinphoneService.getCore(); if(mLinphoneCore == null) return; if (mLinphoneCore == null) return; mLinphoneCore.enableMic(!isMicMuted); } @@ -482,7 +543,7 @@ private void routeAudioToSpeakerHelper(boolean speakerOn) { org.linphone.core.tools.Log.w("[Audio Manager] Routing audio to " + (speakerOn ? "speaker" : "earpiece")); try { if(HDLLinphoneService.getCore() == null) return; if (HDLLinphoneService.getCore() == null) return; if (HDLLinphoneService.getCore().getCallsNb() == 0) return; Call currentCall = HDLLinphoneService.getCore().getCurrentCall(); if (currentCall == null) currentCall = HDLLinphoneService.getCore().getCalls()[0]; @@ -518,6 +579,7 @@ /** * 设置播放View * * @param o */ private void setVideoWindow(Object o) { @@ -526,6 +588,7 @@ linphoneCore.setNativeVideoWindowId(o); } } /** * 移除播放View */ @@ -538,6 +601,7 @@ /** * 设置本机摄像头采集的View * * @param o */ private void setPreviewWindow(Object o) { @@ -546,6 +610,7 @@ linphoneCore.setNativePreviewWindowId(o); } } /** * 移除视频采集View */ @@ -560,9 +625,9 @@ * 获取当前通话状态 */ public Call.State getCallState() { if(HDLLinphoneService.getInstance() == null) { if (HDLLinphoneService.getInstance() == null) { return null; }else { } else { return HDLLinphoneService.getInstance().getCurrentCallState(); } } @@ -571,9 +636,9 @@ * 获取当前通话状态是否为来电中 */ public boolean isIncomingReceivedCallState() { if(HDLLinphoneService.getInstance() == null || HDLLinphoneService.getInstance().getCurrentCallState() == null){ if (HDLLinphoneService.getInstance() == null || HDLLinphoneService.getInstance().getCurrentCallState() == null) { return false; }else{ } else { return (HDLLinphoneService.getInstance().getCurrentCallState() == Call.State.IncomingReceived); } } @@ -587,6 +652,7 @@ /** * 设置是否自动跳转呼叫页面标志 * * @param autoJumpCallView */ public void setAutoJumpCallView(boolean autoJumpCallView) { @@ -631,6 +697,7 @@ /** * 获取onHDLLinphoneCallListener * 接听、挂断、开锁等 Listener实现 * * @return OnHDLLinphoneCallListener */ public OnHDLLinphoneCallListener getOnHDLLinphoneCallListener() { @@ -639,6 +706,7 @@ /** * 设置onHDLLinphoneCallListener * * @param onHDLLinphoneCallListener */ public void setOnHDLLinphoneCallListener(OnHDLLinphoneCallListener onHDLLinphoneCallListener) { HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneIntercomActivity.java
@@ -139,8 +139,6 @@ timer_lp_calltime = (Chronometer) findViewById(R.id.timer_lp_calltime); tv_lp_calltime = findViewById(R.id.tv_lp_calltime); setWidthHeightWithRatio(ll_video_lp_rendering, 16, 9); } /** @@ -261,7 +259,6 @@ showToast(getString(R.string.lp_operationFailedStr)); } } /** * 开锁点击事件 @@ -419,7 +416,6 @@ video_lp_rendering2 = null; } /** * 初始化震动器 */ @@ -445,8 +441,8 @@ /** * 关闭震动器 */ void cancelVibrator(){ if(mVibrator != null){ void cancelVibrator() { if (mVibrator != null) { mVibrator.cancel(); mVibrator = null; } HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/activity/HDLLinphoneMonitorActivity.java
@@ -195,9 +195,7 @@ // showToast("开锁onFinish"); iv_lp_unlock.setEnabled(true); } }; // } @Override HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/callback/PhoneCallback.java
@@ -36,5 +36,5 @@ /** * 连接失败 */ public void error() {} public void error(String error) {} } HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/core/service/HDLLinphoneService.java
@@ -18,6 +18,8 @@ import com.hdl.hdllinphonesdk.R; import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity; import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity; import com.hdl.hdllinphonesdk.core.callback.PhoneCallback; import com.hdl.hdllinphonesdk.core.callback.RegistrationCallback; import com.hdl.hdllinphonesdk.core.linphone.KeepAliveHandler; @@ -76,12 +78,11 @@ } public static Core getCore() { if(sInstance == null){ if (sInstance == null) { return null; } return sInstance.mCore; } @Override public IBinder onBind(Intent intent) { @@ -90,11 +91,13 @@ /** * 添加通话状态回调 * * @param phoneCallback */ public static void addPhoneCallback(PhoneCallback phoneCallback) { sPhoneCallback = phoneCallback; } public static void removePhoneCallback() { if (sPhoneCallback != null) { sPhoneCallback = null; @@ -103,11 +106,13 @@ /** * 添加注册状态回调 * * @param registrationCallback */ public static void addRegistrationCallback(RegistrationCallback registrationCallback) { sRegistrationCallback = registrationCallback; } public static void removeRegistrationCallback() { if (sRegistrationCallback != null) { sRegistrationCallback = null; @@ -154,15 +159,11 @@ new TimerTask() { @Override public void run() { mHandler.post( new Runnable() { @Override public void run() { if (mCore != null) { mCore.iterate(); } } }); mHandler.post(() -> { if (mCore != null) { mCore.iterate(); } }); } }; mTimer = new Timer("Linphone scheduler"); @@ -176,11 +177,11 @@ removeAllCallback(); logout(); if(mTimer != null) { if (mTimer != null) { mTimer.cancel(); } if(mCore != null){ if (mCore != null) { mCore.removeListener(mCoreListener); mCore.stop(); // A stopped Core can be started again @@ -222,8 +223,8 @@ initCoreListener(); copyAssetsFromPackage(basePath); // Create the Core and add our listener mCore = Factory.instance() .createCore(basePath + "/.linphonerc", basePath + "/linphonerc", this); mCore = Factory.instance().createCore(basePath + "/.linphonerc", basePath + "/linphonerc", this); mCore.addListener(mCoreListener); // Core is ready to be configured configureCore(); @@ -237,6 +238,7 @@ @Override public void onCallStateChanged(Core core, Call linphoneCall, Call.State state, String message) { HDLLog.e(START_LINPHONE_LOGS, "callState: " + state.toString()); HDLLog.e(START_LINPHONE_LOGS, "state.toInt()=" + state.toInt() + "==============message=========: " + message); currentCallState = state; if (sPhoneCallback != null) { if (state == Call.State.IncomingReceived) { @@ -246,7 +248,7 @@ } else if (state == Call.State.Connected) { sPhoneCallback.callConnected(); } else if (state == Call.State.Error) { sPhoneCallback.error(); sPhoneCallback.error(message); } else if (state == Call.State.End) { sPhoneCallback.callEnd(); } else if (state == Call.State.Released) { @@ -261,11 +263,11 @@ HDLLog.i(START_LINPHONE_LOGS, "registrationState: " + state); if (state.equals(RegistrationState.None.toString())) { if (sRegistrationCallback != null){ if (sRegistrationCallback != null) { sRegistrationCallback.registrationNone(); } } else if (state.equals(RegistrationState.Progress.toString())) { if (sRegistrationCallback != null){ if (sRegistrationCallback != null) { sRegistrationCallback.registrationProgress(); } } else if (state.equals(RegistrationState.Ok.toString())) { @@ -288,6 +290,7 @@ /** * 收到注销成功后移除当前代理 * * @param core * @param proxyConfig */ @@ -318,7 +321,8 @@ } //1.设置存储用户x509证书的目录的路径 mCore.setUserCertificatesPath(userCerts); //mCore.setUserCertificatesPath(userCerts); mCore.setUserCertificatesPath(basePath); //2.设置UserAgent setUserAgent(); //3.设置播放铃声 @@ -353,6 +357,9 @@ mCore.setVideoActivationPolicy(vap); //11.设置编码格式 setCodecMime(); // 全视通sip设置ca证书 //mCore.setRootCa(basePath + "/rootca.pem"); } /** @@ -381,6 +388,7 @@ /** * 设置是否启用铃声,目前发现设置无效待分析原因 * * @param use */ public void enableDeviceRingtone(boolean use) { @@ -460,6 +468,9 @@ // mPauseSoundFile = basePath + "/toy_mono.wav"; // copyIfNotExist(R.raw.toy_mono, basePath + "/toy_mono.wav"); // String mRootca = basePath + "/rootca.pem"; // 2022-05-23 对接全视通可视对讲添加的证书 // copyIfNotExist(R.raw.freeview_rootca, mRootca); String mLPConfigXsd = basePath + "/lpconfig.xsd"; copyIfNotExist(R.raw.lpconfig, mLPConfigXsd); @@ -471,6 +482,7 @@ /** * copyIfNotExist * * @param ressourceId * @param target * @throws IOException @@ -484,6 +496,7 @@ /** * copyFromPackage * * @param ressourceId * @param target * @throws IOException @@ -533,12 +546,14 @@ //通知ID public static final int NOTIFICATION_ID = 2; /** * 解决android8.0以上无法启动服务的问题 */ void hdlStartForeground() { } /** * stopForeground */ HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/dialog/LpTimeDialog.java
New file @@ -0,0 +1,222 @@ package com.hdl.hdllinphonesdk.dialog; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.res.Resources; import android.graphics.Point; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.Display; import android.view.Gravity; import android.view.View; import android.view.WindowManager; import android.widget.DatePicker; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.NumberPicker; import android.widget.TextView; import android.widget.TimePicker; import com.hdl.hdllinphonesdk.R; import java.lang.reflect.Field; public class LpTimeDialog extends Dialog { private Context mContext; private DatePicker datePicker; private TimePicker timePicker; private TextView cancelBtn, confirmBtn; private ClickListenerInterface mClickListener; public LpTimeDialog(Context context, ClickListenerInterface listener) { super(context, R.style.video_dialog); this.mContext = context; this.mClickListener = listener; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_lpsdk_time_select); initView(); initData(); Display display = ((Activity) mContext).getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams p = getWindow().getAttributes(); Point point = new Point(); display.getSize(point); p.width = point.x; getWindow().setGravity(Gravity.BOTTOM); } /** * initView */ private void initView() { datePicker = findViewById(R.id.lp_dialog_data_picker); timePicker = findViewById(R.id.lp_dialog_time_picker); cancelBtn = findViewById(R.id.lp_dialog_cancel_tv); cancelBtn.setOnClickListener(view -> { if (mClickListener != null) mClickListener.onCancelClick(this); }); confirmBtn = findViewById(R.id.lp_dialog_confirm_tv); confirmBtn.setOnClickListener(view -> { String time = datePicker.getYear() + "-" + getMonth(datePicker) + "-" + getDay(datePicker) + " " + getHour(timePicker) + ":" + getMinute(timePicker); if (mClickListener != null) mClickListener.onConfirmClick(this, time); }); } // 获取月份 private String getMonth(DatePicker _datePicker) { String moth_str = ""; int month_int = _datePicker.getMonth() + 1; if (month_int < 10) moth_str = "0" + month_int; else moth_str = month_int + ""; return moth_str; } // 获取日 private String getDay(DatePicker _datePicker) { String day_str = ""; int day_int = _datePicker.getDayOfMonth(); if (day_int < 10) day_str = "0" + day_int; else day_str = day_int + ""; return day_str; } // 获取小时 private String getHour(TimePicker _timePicker) { String hour_str = ""; int hour_int = _timePicker.getHour(); if (hour_int < 10) hour_str = "0" + hour_int; else hour_str = hour_int + ""; return hour_str; } // 获取分钟 private String getMinute(TimePicker _timePicker) { String minute_str = ""; int minute_int = _timePicker.getMinute(); if (minute_int < 10) minute_str = "0" + minute_int; else minute_str = minute_int + ""; return minute_str; } /** * initData */ private void initData() { timePicker.setIs24HourView(true); timePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS); // setDataPickerDividerColor(datePicker); //setTimePickerDividerColor(timePicker); } private void setDataPickerDividerColor(DatePicker timePicker) { LinearLayout llFirst = (LinearLayout) timePicker.getChildAt(0); LinearLayout mSpinners = (LinearLayout) llFirst.getChildAt(1); for (int i = 0; i < mSpinners.getChildCount(); i++) { if (mSpinners.getChildAt(i) instanceof NumberPicker) { Field[] pickerFields = NumberPicker.class.getDeclaredFields(); setPickerMargin((NumberPicker) mSpinners.getChildAt(i)); for (Field pf : pickerFields) { if (pf.getName().equals("mSelectionDivider")) { pf.setAccessible(true); try { pf.set(mSpinners.getChildAt(i), new ColorDrawable()); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } break; } } } } } private void setTimePickerDividerColor(TimePicker timePicker) { LinearLayout llFirst = (LinearLayout) timePicker.getChildAt(0); LinearLayout mSpinners = (LinearLayout) llFirst.getChildAt(1); for (int i = 0; i < mSpinners.getChildCount(); i++) { if (mSpinners.getChildAt(i) instanceof NumberPicker) { Field[] pickerFields = NumberPicker.class.getDeclaredFields(); setPickerMargin((NumberPicker) mSpinners.getChildAt(i)); for (Field pf : pickerFields) { if (pf.getName().equals("mSelectionDivider")) { pf.setAccessible(true); try { pf.set(mSpinners.getChildAt(i), new ColorDrawable()); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } break; } } } } } /** * 设置picker之间的间距 */ private void setPickerMargin(NumberPicker picker) { LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) picker.getLayoutParams(); p.setMargins(-getDensityValue(16, mContext), 0, -getDensityValue(16, mContext), 0); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) { p.setMarginStart(-getDensityValue(16, mContext)); p.setMarginEnd(-getDensityValue(16, mContext)); } setEditTextSize(picker); } /** * 设置picker字体大小 */ private void setEditTextSize(NumberPicker np) { if (null != np) { for (int i = 0; i < np.getChildCount(); i++) { View child = np.getChildAt(i); if (child instanceof EditText) { EditText editText = (EditText) child; editText.setTextSize(18); } } } } public interface ClickListenerInterface { void onCancelClick(LpTimeDialog dialog); void onConfirmClick(LpTimeDialog dialog, String startTime); } public static int getDensityValue(float value, Context activity) { DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics(); return (int) Math.ceil(value * displayMetrics.density); } } HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/dialog/LpTipDialog.java
New file @@ -0,0 +1,101 @@ package com.hdl.hdllinphonesdk.dialog; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.graphics.Point; import android.os.Bundle; import android.view.Display; import android.view.Gravity; import android.view.WindowManager; import android.widget.TextView; import com.hdl.hdllinphonesdk.R; public class LpTipDialog extends Dialog { private Context mContext; private ClickListenerInterface mClickListener; private String mTitleStr = getContext().getResources().getString(R.string.lp_tipStr); private String mMessageStr = ""; private TextView contentTv; private TextView titleTv; private TextView cancelTv; private TextView confirmTv; public LpTipDialog(Context context) { super(context, R.style.video_dialog); mContext = context; } public LpTipDialog(Context context, String title, String content) { super(context, R.style.video_dialog); mContext = context; this.mTitleStr = title; this.mMessageStr = content; } public LpTipDialog(Context context, String title, String content, ClickListenerInterface listener) { super(context, R.style.video_dialog); mContext = context; this.mTitleStr = title; this.mMessageStr = content; setClickListener(listener); } public void setClickListener(ClickListenerInterface clickListenerInterfacel) { this.mClickListener = clickListenerInterfacel; } public interface ClickListenerInterface { void SureClick(LpTipDialog dialog); void CancelClick(LpTipDialog dialog); } public void setTitle(String title) { this.mTitleStr = title; } public void setMessage(String message) { this.mMessageStr = message; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_lpsdk_tip); contentTv = findViewById(R.id.lpsdk_dialog_content_tv); contentTv.setText(mMessageStr); titleTv = findViewById(R.id.lpsdk_dialog_title_tv); titleTv.setText(mTitleStr); cancelTv = findViewById(R.id.lpsdk_dialog_cancel_tv); cancelTv.setOnClickListener(view -> { if (mClickListener != null) mClickListener.CancelClick(LpTipDialog.this); }); confirmTv = findViewById(R.id.lpsdk_dialog_confirm_tv); confirmTv.setOnClickListener(view -> { if (mClickListener != null) mClickListener.SureClick(LpTipDialog.this); }); } @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); try { Display display = ((Activity) mContext).getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams p = getWindow().getAttributes(); Point point = new Point(); display.getSize(point); p.width = (int) (point.x * 0.8); getWindow().setGravity(Gravity.CENTER); } catch (Exception e) { } } } HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/interfaces/AddressType.java
New file @@ -0,0 +1,11 @@ package com.hdl.hdllinphonesdk.interfaces; public interface AddressType { void setText(CharSequence var1); CharSequence getText(); void setDisplayedName(String var1); String getDisplayedName(); } HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/java/com/hdl/hdllinphonesdk/utils/HDLImageUtils.java
@@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.media.MediaScannerConnection; import android.net.Uri; @@ -18,12 +19,15 @@ import com.hdl.hdllinphonesdk.R; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.SoftReference; /** * Created by jlchen on 2021/8/16. @@ -101,6 +105,38 @@ } /** * 保存图片至相册 * 需要读写权限 */ public static boolean saveImageToGallery(Context context, byte[] image_bytes) { Bitmap bitmap = byteToBitmap(image_bytes); return saveImageToGallery(context, bitmap); } public static Bitmap byteToBitmap(byte[] imgByte) { InputStream input = null; Bitmap bitmap = null; BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 1; input = new ByteArrayInputStream(imgByte); SoftReference softRef = new SoftReference(BitmapFactory.decodeStream(input, null, options)); //软引用防止OOM bitmap = (Bitmap) softRef.get(); if (imgByte != null) { imgByte = null; } try { if (input != null) { input.close(); } } catch (IOException e) { // 异常捕获 e.printStackTrace(); } return bitmap; } /** * 将文件保存到公共的媒体文件夹 HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/drawable/lp_dialog_background.xml
New file @@ -0,0 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <corners android:radius="15dp" /> <solid android:color="@color/lpsdk_color_white" /> </shape> </item> </layer-list> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/drawable/lp_dialog_cancel_background.xml
New file @@ -0,0 +1,17 @@ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <corners android:bottomLeftRadius="15dp" /> <solid android:color="@color/lpsdk_color_white" /> <stroke android:width="1px" android:color="#2108141F" /> <padding android:bottom="2dp" android:left="2dp" android:right="2dp" /> </shape> </item> </layer-list> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/drawable/lp_dialog_confirm_background.xml
New file @@ -0,0 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <corners android:bottomRightRadius="15dp"/> <solid android:color="#4484F4" /> </shape> </item> </layer-list> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/layout/activity_hdllinphone_intercom.xml
@@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" @@ -9,21 +8,20 @@ <RelativeLayout android:id="@+id/rl_lp_topView" android:layout_width="match_parent" android:background="@color/lpsdk_app_bg" android:layout_height="44dp"> android:layout_height="44dp" android:background="@color/lpsdk_app_bg"> <TextView android:id="@+id/tv_lp_title" android:layout_width="match_parent" android:layout_height="25dp" android:layout_marginTop="10dp" android:layout_marginLeft="50dp" android:layout_marginTop="10dp" android:layout_marginRight="50dp" android:gravity="center" android:textColor="@color/lpsdk_textColor" android:textSize="18sp" android:text="室内机" ></TextView> android:textColor="@color/lpsdk_textColor" android:textSize="18sp"></TextView> </RelativeLayout> @@ -36,12 +34,12 @@ android:layout_width="wrap_content" android:layout_height="210dp" android:background="@android:color/black"> <TextureView android:id="@+id/video_lp_rendering" android:layout_width="match_parent" android:layout_height="match_parent"/> android:layout_height="match_parent" /> </LinearLayout> <LinearLayout @@ -51,16 +49,17 @@ <RelativeLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent"> android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:id="@+id/iv_lp_screenshot" android:layout_width="40dp" android:layout_height="40dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:scaleType="fitCenter" android:background="@drawable/btn_click_lp_screenshot"> android:background="@drawable/btn_click_lp_screenshot" android:scaleType="fitCenter"> </ImageView> @@ -68,25 +67,24 @@ <RelativeLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent"> android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:id="@+id/iv_lp_unlock" android:layout_width="40dp" android:layout_height="40dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:scaleType="fitCenter" android:background="@drawable/btn_click_lp_unlock"> </ImageView> android:background="@drawable/btn_click_lp_unlock" android:scaleType="fitCenter" /> </RelativeLayout> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/lpsdk_app_line" ></View> android:background="@color/lpsdk_app_line" /> <RelativeLayout android:layout_width="match_parent" @@ -95,57 +93,39 @@ <TextureView android:id="@+id/video_lp_rendering2" android:layout_width="1dp" android:layout_height="1dp"/> android:layout_height="1dp" /> <!-- <TextView--> <!-- android:id="@+id/tv_lp_calltime"--> <!-- android:layout_width="wrap_content"--> <!-- android:layout_centerHorizontal="true"--> <!-- android:text="00:00"--> <!-- android:textColor="@android:color/white"--> <!-- android:textSize="14sp"--> <!-- android:gravity="center_vertical"--> <!-- android:paddingLeft="38dp"--> <!-- android:paddingRight="38dp"--> <!-- android:layout_marginTop="38dp"--> <!-- android:background="@drawable/lp_calltime_shape"--> <!-- android:visibility="gone"--> <!-- android:layout_height="40dp">--> <!-- </TextView>--> <Chronometer android:id="@+id/timer_lp_calltime" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_centerHorizontal="true" android:layout_marginTop="38dp" android:background="@drawable/lp_calltime_shape" android:format="%s" android:textColor="@android:color/white" android:textSize="14sp" android:gravity="center_vertical" android:paddingLeft="38dp" android:paddingRight="38dp" android:layout_marginTop="38dp" android:background="@drawable/lp_calltime_shape" android:visibility="gone" android:layout_height="40dp"> android:textColor="@android:color/white" android:textSize="14sp" android:visibility="gone"> </Chronometer> <TextView android:id="@+id/tv_lp_calltime" android:layout_width="wrap_content" android:layout_height="40dp" android:layout_centerHorizontal="true" android:textColor="@android:color/white" android:textSize="14sp" android:layout_marginTop="38dp" android:background="@drawable/lp_calltime_shape_gray" android:gravity="center_vertical" android:paddingLeft="38dp" android:paddingRight="38dp" android:text="@string/lp_callingStr" android:layout_marginTop="38dp" android:background="@drawable/lp_calltime_shape_gray" android:visibility="visible" android:layout_height="40dp"> </TextView> android:textColor="@android:color/white" android:textSize="14sp" android:visibility="visible" /> <LinearLayout android:layout_width="match_parent" @@ -155,54 +135,53 @@ <RelativeLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent"> android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:id="@+id/iv_lp_hangUp" android:layout_width="66dp" android:layout_height="66dp" android:scaleType="fitCenter" android:src="@drawable/ic_esvideo_on_hangup" android:layout_centerHorizontal="true" ></ImageView> android:scaleType="fitCenter" android:src="@drawable/ic_esvideo_on_hangup" /> <TextView android:id="@+id/tv_lp_hangUp" android:layout_width="match_parent" android:layout_height="20dp" android:text="@string/lp_refuseStr" android:gravity="center" android:textColor="@color/lpsdk_textColor" android:textSize="14sp" android:layout_alignParentBottom="true" ></TextView> android:gravity="center" android:text="@string/lp_refuseStr" android:textColor="@color/lpsdk_textColor" android:textSize="14sp" /> </RelativeLayout> <RelativeLayout android:id="@+id/rl_lp_answerView" android:layout_width="0dp" android:layout_weight="1" android:layout_height="match_parent"> android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:id="@+id/iv_lp_answer" android:layout_width="66dp" android:layout_height="66dp" android:scaleType="fitCenter" android:src="@drawable/ic_esvideo_on_answer" android:layout_centerHorizontal="true" ></ImageView> android:scaleType="fitCenter" android:src="@drawable/ic_esvideo_on_answer" /> <TextView android:id="@+id/tv_lp_answer" android:layout_width="match_parent" android:layout_height="20dp" android:text="@string/lp_answerStr" android:gravity="center" android:textColor="@color/lpsdk_textColor" android:textSize="14sp" android:layout_alignParentBottom="true" ></TextView> android:gravity="center" android:text="@string/lp_answerStr" android:textColor="@color/lpsdk_textColor" android:textSize="14sp" /> </RelativeLayout> </LinearLayout> </RelativeLayout> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/layout/dialog_lpsdk_time_select.xml
New file @@ -0,0 +1,58 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFFFFF" android:orientation="vertical"> <RelativeLayout android:layout_width="match_parent" android:layout_height="44dp" android:background="#21C0C7D4"> <TextView android:id="@+id/lp_dialog_cancel_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginStart="10dp" android:text="@string/lp_cancel" android:textColor="@color/lpsdk_textColor" android:textSize="14sp" /> <TextView android:id="@+id/lp_dialog_confirm_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_marginEnd="10dp" android:text="@string/lp_confirm" android:textColor="#4484F4" android:textSize="14sp" /> </RelativeLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <DatePicker android:id="@+id/lp_dialog_data_picker" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:datePickerMode="spinner" android:calendarViewShown="false" android:theme="@style/time_picker_style" /> <TimePicker android:id="@+id/lp_dialog_time_picker" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.75" android:theme="@style/time_picker_style" android:timePickerMode="spinner" /> </LinearLayout> </LinearLayout> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/layout/dialog_lpsdk_tip.xml
New file @@ -0,0 +1,56 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/lp_dialog_background" android:orientation="vertical"> <TextView android:id="@+id/lpsdk_dialog_title_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:gravity="center" android:text="提示" android:textColor="#4484F4" android:textSize="16sp" /> <TextView android:id="@+id/lpsdk_dialog_content_tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="20dp" android:gravity="center" android:text="内容" android:textColor="@color/lpsdk_textColor" android:textSize="12sp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="44dp" android:layout_marginTop="10dp" android:orientation="horizontal"> <TextView android:id="@+id/lpsdk_dialog_cancel_tv" android:layout_width="0dp" android:layout_height="match_parent" android:text="@string/lp_cancel" android:gravity="center" android:textSize="16sp" android:background="@drawable/lp_dialog_cancel_background" android:textColor="@color/lpsdk_textColor" android:layout_weight="1" /> <TextView android:id="@+id/lpsdk_dialog_confirm_tv" android:layout_width="0dp" android:layout_height="match_parent" android:gravity="center" android:textColor="@color/lpsdk_color_white" android:text="@string/lp_confirm" android:background="@drawable/lp_dialog_confirm_background" android:layout_weight="1" /> </LinearLayout> </LinearLayout> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/raw/hdl_rootca.pem
HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/raw/lpconfig.xsd
@@ -1,45 +1,60 @@ <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.linphone.org/xsds/lpconfig.xsd" xmlns:tns="http://www.linphone.org/xsds/lpconfig.xsd" elementFormDefault="qualified"> <xs:schema xmlns:tns="http://www.linphone.org/xsds/lpconfig.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.linphone.org/xsds/lpconfig.xsd"> <xs:element name="config" type="tns:LPConfig"></xs:element> <xs:element name="config" type="tns:LPConfig"></xs:element> <xs:complexType name="LPConfig"> <xs:sequence> <xs:element name="section" type="tns:LPSection" minOccurs="0" maxOccurs="unbounded"></xs:element> </xs:sequence> <xs:sequence> <xs:element name="section" maxOccurs="unbounded" minOccurs="0" type="tns:LPSection"></xs:element> </xs:sequence> </xs:complexType> <xs:complexType name="LPSection"> <xs:sequence> <xs:element name="entry" type="tns:LPEntry" maxOccurs="unbounded" minOccurs="0"> </xs:element> </xs:sequence> <xs:attribute name="name" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"></xs:minLength> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:sequence> <xs:element name="entry" maxOccurs="unbounded" minOccurs="0" type="tns:LPEntry"></xs:element> </xs:sequence> <xs:attribute name="name" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"></xs:minLength> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> <xs:complexType name="LPEntry"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="overwrite" type="xs:boolean" use="optional" default="false"> </xs:attribute> <xs:attribute name="name" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"></xs:minLength> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:extension> </xs:simpleContent> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="overwrite" default="false" type="xs:boolean" use="optional"></xs:attribute> <xs:attribute name="name" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="1"></xs:minLength> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/values-zh/strings.xml
@@ -17,4 +17,8 @@ <string name="lp_unlockStr">开锁</string> <string name="lp_outdoorUnitStr">室外机</string> <string name="lp_sipAccount_null">接听失败,设备不存在</string> <!--访客记录--> <string name="lp_cancel">取消</string> <string name="lp_confirm">确认</string> </resources> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/values/colors.xml
@@ -4,5 +4,6 @@ <color name="lpsdk_app_bg">#ECEDEE</color> <color name="lpsdk_app_line">#6D798D</color> <color name="lpsdk_textColor">#1B2D4D</color> <color name="lpsdk_color_white">#FFFFFF</color> </resources> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/values/strings.xml
@@ -16,4 +16,7 @@ <string name="lp_unlockStr">Unlock</string> <string name="lp_outdoorUnitStr">Outdoor unit</string> <string name="lp_sipAccount_null">Failed to answer the call. The device does not exist.</string> <!--访客记录--> <string name="lp_cancel">Cancel</string> <string name="lp_confirm">Confirm</string> </resources> HDLLinphoneSDKDemoNew/HDLLinphoneSDK/src/main/res/values/styles.xml
@@ -1,5 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <style name="video_dialog" parent="@android:style/Theme.Dialog"> <!-- 背景颜色及和透明程度 --> <item name="android:windowBackground">@android:color/transparent</item> <!-- 是否去除标题 --> <item name="android:windowNoTitle">true</item> <!-- 是否去除边框 --> <item name="android:windowFrame">@null</item> <!-- 是否浮现在activity之上 --> <item name="android:windowIsFloating">true</item> <!-- 是否模糊 --> <item name="android:backgroundDimEnabled">true</item> </style> <style name="time_picker_style" parent="Theme.AppCompat"> <item name="android:textSize">14sp</item> <item name="android:textColorPrimary">@color/lpsdk_textColor</item> </style> </resources> HDLLinphoneSDKDemoNew/app/build.gradle
@@ -4,7 +4,6 @@ android { compileSdkVersion 28 buildToolsVersion "28.0.0" defaultConfig { applicationId "com.example.hdllinphonesdkdemo" @@ -26,12 +25,18 @@ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } repositories { flatDir { dirs 'libs' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:2.0.4' implementation project(path: ':HDLLinphoneSDK') // implementation project(path: ':HDLLinphoneSDK') testImplementation 'junit:junit:4.+' androidTestImplementation 'com.android.support.test:runner:1.0.2' HDLLinphoneSDKDemoNew/app/libs/HDLLinphoneSDK-V1.0.1.aarBinary files differ
HDLLinphoneSDKDemoNew/app/src/main/java/com/example/hdllinphonesdkdemo/MainActivity.java
@@ -4,111 +4,67 @@ import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; import com.hdl.hdllinphonesdk.HDLLinphoneKit; import com.hdl.hdllinphonesdk.activity.HDLLinphoneIntercomActivity; import com.hdl.hdllinphonesdk.activity.HDLLinphoneMonitorActivity; import com.hdl.hdllinphonesdk.activity.HDLLinphoneReverseCallActivity; import com.hdl.hdllinphonesdk.callback.OnHDLLinphoneCallListener; import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService; import com.hdl.hdllinphonesdk.utils.HDLLog; import org.linphone.core.Core; import org.linphone.core.ProxyConfig; import com.hdl.hdllinphonesdk.dialog.LpTipDialog; //import com.hdl.hdllinphonesdk.core.service.HDLLinphoneService; //import com.hdl.hdllinphonesdk.utils.HDLLog; // //import org.linphone.core.Core; //import org.linphone.core.ProxyConfig; public class MainActivity extends Activity { private static final String TAG = "MainActivity"; private TextView mTextView,mTextView2,mTextView3,mTextView4; private TextView mTextView, mMonitorText, mTextView3, mTextView4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.mDialog).setOnClickListener(view -> { new LpTipDialog(MainActivity.this, "sss", "ddd", new LpTipDialog.ClickListenerInterface() { @Override public void SureClick(LpTipDialog lpTipDialog) { lpTipDialog.dismiss(); } @Override public void CancelClick(LpTipDialog lpTipDialog) { lpTipDialog.dismiss(); } }).show(); }); mTextView = findViewById(R.id.tv_hello); mTextView2 = findViewById(R.id.mTextView2); mMonitorText = findViewById(R.id.mTextView2); mTextView3 = findViewById(R.id.mTextView3); mTextView4 = findViewById(R.id.mTextView4); mTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // startActivity(HDLLinphoneMonitorActivity.class); // EasyLinphone.callTo("0000",true); // EasyLinphone.setAccountAndLogin("44 EasyLinphone.setAccountAndLogin("4444", "85521566", "116.62.26.215:5060");44", "85521566", "116.62.26.215:5060"); mTextView.setOnClickListener(v -> HDLLinphoneKit.getInstance() .setAccountAndLogin( "A583853817423247", "763548", "139.159.157.75:46000", HDLLinphoneKit.INTER_PHONE_TYPE_FREEVIEW )); // {"data": "{\"sipPassword\":\"8ec02ce0\",\"sipAccount\":\"61723164995710}} // {"data": "{\"sipPassword\":\"cc6d73c1\",\"sipAccount\":\"61723164995779}} // EasyLinphone.setAccountAndLogin("61723164995710", "8ec02ce0", "47.94.42.230:25060"); // HDLLinphoneKit.getInstance().setAccountAndLogin("61723164995710", "8ec02ce0", "sipproxy.ucpaas.com:25060"); mTextView4.setOnClickListener(v -> HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "47.96.88.250:35060", HDLLinphoneKit.INTER_PHONE_TYPE_FREEVIEW)); // HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "116.62.26.215:5060"); // HDLLinphoneKit.getInstance().setAccountAndLogin("5555", "85521566", "test-gz.hdlcontrol.com:5060"); // HDLLinphoneKit.getInstance().setAccountAndLogin("6666", "85521566", "test-gz.hdlcontrol.com:5060"); HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "47.96.88.250:35060"); // // HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "test-gz.hdlcontrol.com:5060"); // // HDLLinphoneKit.getInstance().setAccountAndLogin("4444", "85521566", "test-gz.hdlcontrol.com:5060"); } mMonitorText.setOnClickListener(v -> { // String sip_account = "sip:D" + space_code + "@yun"; HDLLinphoneKit.getInstance().callTo("sip:D22-1-21-1@139.159.157.75:46000", true); // HDLLinphoneKit.getInstance().callTo("D22-1-21-1", true); startActivity(HDLLinphoneMonitorActivity.class); }); mTextView4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clearProxyConfig(); HDLLinphoneKit.getInstance().setAccountAndLogin("8888", "85521566", "47.96.88.250:35060"); } }); mTextView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // logoutLog(); // return; // HDLLinphoneKit.getInstance().callTo("61723164995779",true); // HDLcallTo("61723164995779",true); // HDLLinphoneKit.getInstance().callTo("1427186301744910338",true); HDLLinphoneKit.getInstance().callTo("1456490719927488513",true); startActivity(HDLLinphoneMonitorActivity.class); } }); mTextView3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // HDLLinphoneKit.getInstance().getCore().setNetworkReachable(true); // isOpen = !isOpen; // showToast("当前设置状态:"+isOpen); // HDLLinphoneKit.getInstance().getCore().enableVideoCapture(isOpen);//禁用手机摄像头视频采集 // //1.启用PCMA 8000 // PayloadType[] ptList = HDLLinphoneKit.getInstance().getCore().getAudioPayloadTypes(); // for (PayloadType pt : ptList) { //// HDLLog.i("payloadaudio", pt.getMimeType()); // if ((pt.getMimeType().equals("PCMA") || pt.getMimeType().equals("PCMU")) && pt.getClockRate() == 8000) { //// pt.enable(true); // HDLLog.i("payloadaudio true", pt.getMimeType() + ": "+ pt.getClockRate()+"HZ " + pt.enabled()); // } else { //// pt.enable(false); // HDLLog.i("payloadaudio false", pt.getMimeType() + ": "+ pt.getClockRate()+"HZ "+ pt.enabled()); // } // } // logout(); } mTextView3.setOnClickListener(v -> { HDLLinphoneKit.getInstance().callTo("D22-1-21-1", true); startActivity(HDLLinphoneMonitorActivity.class); }); //1.初始化SDK,并注册HDLLinphoneService @@ -117,105 +73,32 @@ HDLLinphoneKit.getInstance().setAutoJumpCallView(true); //3.监听呼叫和监控页面,用户操作的相关事件、接听、拒接、开锁等.... setOnHDLLinphoneCallListener(); } void all(){ Intent intent = new Intent(this, HDLLinphoneReverseCallActivity.class); intent. startActivity(intent); mTextView.performClick(); } boolean isOpen; /** * 退出清空账号 * enableRegister false */ public void logout() { try { Core core = HDLLinphoneService.getCore(); if (core != null) { ProxyConfig[] configs = core.getProxyConfigList(); for (ProxyConfig config : configs) { if (config != null) { config.edit(); config.enableRegister(false); config.done(); } } // core.clearAllAuthInfo();//清除所有认证信息。 // core.clearProxyConfig();//从配置中删除所有代理。 } } catch (Exception e) { e.printStackTrace(); } } public void clearProxyConfig() { Core core = HDLLinphoneService.getCore(); if (core != null) { core.setDefaultProxyConfig(null); core.clearAllAuthInfo(); core.clearProxyConfig(); // core.refreshRegisters();//强制在下一次迭代时启动注册刷新 // core.ensureRegistered(); } } // public void logoutLog() { // try { // Core core = HDLLinphoneService.getCore(); // ProxyConfig[] configs = core.getProxyConfigList(); // if(configs != null) { // HDLLog.E("registrationState账户length" + configs.length); // } // // for (ProxyConfig config : configs) { // HDLLog.E("registrationState账户"+config.getIdentityAddress().getUsername()); // } // // } catch (Exception e) { // e.printStackTrace(); // } // } boolean openSuccess; void setOnHDLLinphoneCallListener(){ HDLLinphoneKit.getInstance().setOnHDLLinphoneCallListener( new OnHDLLinphoneCallListener() { void setOnHDLLinphoneCallListener() { HDLLinphoneKit.getInstance().setOnHDLLinphoneCallListener(new OnHDLLinphoneCallListener() { @Override public void onAnswerAction() { showToast("接听"); // EasyLinphone.toggleMicro(true); } @Override public void onRejectCallAction() { showToast("拒接"); // EasyLinphone.hangUp(); } @Override public void onUnlockAction() { // // HDLLinphoneKit.getInstance().getCore().clearAllAuthInfo(); // showToast("开锁"); // EasyLinphone.callTo("61723164995779",true); // openSuccess = !openSuccess; // if(openSuccess){ // HDLLinphoneKit.getInstance().onOpenSuccess(); // }else{ // HDLLinphoneKit.getInstance().onOpenError("设备不在线"); // } // } @Override public void onHangUpAction(int callDuration) { showToast("挂断 通话时长:"+callDuration); // EasyLinphone.hangUp(); showToast("挂断 通话时长:" + callDuration); } @Override @@ -223,11 +106,11 @@ showToast("截图"); } @Override public void onIncomingCall(String s) { @Override public void onIncomingCall(String s) { } }); } }); } /** @@ -241,7 +124,6 @@ Intent intent = new Intent(this, clazz); startActivity(intent); } } HDLLinphoneSDKDemoNew/app/src/main/res/layout/activity_main.xml
@@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" @@ -11,39 +10,48 @@ android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:gravity="center" android:textColor="@android:color/white" android:background="@android:color/holo_blue_light" android:gravity="center" android:text="登录" android:textColor="@android:color/white" /> android:text="登录" ></TextView> <TextView android:id="@+id/mTextView4" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:gravity="center" android:textColor="@android:color/white" android:background="@android:color/holo_blue_light" android:text="登录2" ></TextView> android:gravity="center" android:text="登录2" android:textColor="@android:color/white" /> <TextView android:id="@+id/mTextView2" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:gravity="center" android:textColor="@android:color/white" android:background="@android:color/holo_blue_light" android:text="监视" ></TextView> android:gravity="center" android:text="监视" android:textColor="@android:color/white" /> <TextView android:id="@+id/mTextView3" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:gravity="center" android:textColor="@android:color/white" android:background="@android:color/holo_blue_light" android:text="清空账号" ></TextView> android:gravity="center" android:text="清空账号" android:textColor="@android:color/white" /> <TextView android:id="@+id/mDialog" android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginTop="30dp" android:background="@android:color/holo_blue_light" android:gravity="center" android:text="弹窗" android:textColor="@android:color/white" /> </LinearLayout> HDLLinphoneSDKDemoNew/app/src/main/res/values-night/themes.xml
File was deleted HDLLinphoneSDKDemoNew/app/src/main/res/values/colors.xml
@@ -1,10 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <color name="purple_200">#FFBB86FC</color> <color name="purple_500">#FF6200EE</color> <color name="purple_700">#FF3700B3</color> <color name="teal_200">#FF03DAC5</color> <color name="teal_700">#FF018786</color> <color name="black">#FF000000</color> <color name="white">#FFFFFFFF</color> <color name="lpsdk_app_bg">#ECEDEE</color> <color name="lpsdk_app_line">#6D798D</color> <color name="lpsdk_textColor">#1B2D4D</color> <color name="lpsdk_color_white">#FFFFFF</color> </resources> HDLLinphoneSDKDemoNew/app/src/main/res/values/dimens.xml
New file @@ -0,0 +1,15 @@ <resources> <!-- 顶部按钮栏高度 --> <dimen name="pickerview_topbar_height">44dp</dimen> <!-- 顶部按钮padding --> <dimen name="pickerview_topbar_padding">20dp</dimen> <!-- 顶部按钮文字大小 --> <dimen name="pickerview_topbar_btn_textsize">17sp</dimen> <dimen name="pickerview_topbar_title_textsize">18sp</dimen> <!-- 选项文字大小 --> <dimen name="pickerview_textsize">20sp</dimen> </resources> HDLLinphoneSDKDemoNew/app/src/main/res/values/integers.xml
New file @@ -0,0 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <integer name="animation_default_duration">300</integer> </resources> HDLLinphoneSDKDemoNew/app/src/main/res/values/strings.xml
@@ -1,3 +1,20 @@ <resources> <string name="app_name">HDLLinphoneSDKDemo</string> </resources> <string name="app_name">HDLLinphoneSDK</string> <string name="lp_tipStr">Prompt</string> <string name="lp_okStr">OK</string> <string name="lp_saveToTheAlbumsStr">Saved to the albums.</string> <string name="lp_operationFailedStr">Operation failed.</string> <string name="lp_refuseStr">Refuse</string> <string name="lp_answerStr">Answer</string> <string name="lp_hangupStr">Hang up</string> <string name="lp_unlockSuccessfullyStr">Unlock successfully</string> <string name="lp_unlockfailureStr">Unlock failure</string> <string name="lp_callingStr">Incoming call</string> <string name="lp_endOfCallStr">End of call</string> <string name="lp_endMonitoringStr">End of the monitor</string> <string name="lp_screenshotStr">Screenshot</string> <string name="lp_unlockStr">Unlock</string> <string name="lp_outdoorUnitStr">Outdoor unit</string> <string name="lp_sipAccount_null">Failed to answer the call. The device does not exist.</string> </resources> HDLLinphoneSDKDemoNew/app/src/main/res/values/styles.xml
New file @@ -0,0 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> </resources> HDLLinphoneSDKDemoNew/app/src/main/res/values/themes.xml
@@ -1,10 +1,8 @@ <resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Theme.HDLLinphoneSDKDemo" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="Theme.HDLLinphoneSDKDemo" parent="android:Theme.Light.NoTitleBar.Fullscreen"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_500</item> <item name="colorPrimaryDark">@color/purple_700</item> <item name="colorAccent">@color/teal_200</item> <!-- Customize your theme here. --> </style> </resources> Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Jars/HDLLinphoneSDK-V1.0.1.aarBinary files differ
Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone/Shared.Droid.HDLLinphone.csproj
@@ -53,13 +53,13 @@ <TransformFile Include="Transforms\EnumMethods.xml" /> </ItemGroup> <ItemGroup> <LibraryProjectZip Include="Jars\HDLLinphoneSDK-V1.0.1.aar" /> </ItemGroup> <ItemGroup> <PackageReference Include="Xamarin.Android.Support.v7.AppCompat"> <Version>28.0.0.3</Version> </PackageReference> </ItemGroup> <ItemGroup> <LibraryProjectZip Include="Jars\HDLLinphoneSDK-V1.0.1.aar" /> </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets.