我们开发的是视频电话,所以既可以视频通话,可以只有音频的通话,所以底部含有两个按钮,最后一个就是删除功能,如果输入错误,我们可以删除输入的内容。

这里我们要通过重写LinearLayout来实现这部份,对应着上面的功能我们可以写一个接口来实现这些功能,如下:

public interface OnDialActionListener {
/**
* The make call button has been pressed
*/
void placeCall(); /**
* The video button has been pressed
*/
void placeVideoCall();
/**
* The delete button has been pressed
*/
void deleteChar();
/**
* The delete button has been long pressed
*/
void deleteAll();
}

通过回调来在主界面实现这些功能。例如在OnClick函数中

 @Override
public void onClick(View v) {
if (actionListener != null) {
int viewId = v.getId();
if (viewId == R.id.dialVideoButton) {
actionListener.placeVideoCall();
}else if(viewId == R.id.dialButton) {
actionListener.placeCall();
}else if(viewId == R.id.deleteButton) {
actionListener.deleteChar();
}
}
}

我们可以通过本地的接口来实现内部函数,然后在主界面实例化这个接口并填写接口的实现方式。整体的代码如下:

package com.jwzhangjie.pjsip.widgets;

import com.jwzhangjie.pjsip.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.LinearLayout; public class DialerCallBar extends LinearLayout implements OnClickListener, OnLongClickListener { public interface OnDialActionListener {
/**
* The make call button has been pressed
*/
void placeCall(); /**
* The video button has been pressed
*/
void placeVideoCall();
/**
* The delete button has been pressed
*/
void deleteChar();
/**
* The delete button has been long pressed
*/
void deleteAll();
} private OnDialActionListener actionListener; public DialerCallBar(Context context) {
this(context, null, 0);
} public DialerCallBar(Context context, AttributeSet attrs) {
this(context, attrs, 0);
} public DialerCallBar(Context context, AttributeSet attrs, int style) {
super(context, attrs);
LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.dialpad_additional_buttons, this, true);
findViewById(R.id.dialVideoButton).setOnClickListener(this);
findViewById(R.id.dialButton).setOnClickListener(this);
findViewById(R.id.deleteButton).setOnClickListener(this);
findViewById(R.id.deleteButton).setOnLongClickListener(this); if(getOrientation() == LinearLayout.VERTICAL) {
LayoutParams lp;
for(int i=0; i < getChildCount(); i++) {
lp = (LayoutParams) getChildAt(i).getLayoutParams();
int w = lp.width;
lp.width = lp.height;
lp.height = w;
lp.gravity = Gravity.CENTER_HORIZONTAL;
// Added for clarity but not necessary
getChildAt(i).setLayoutParams(lp); }
}
} /**
* Set a listener for this widget actions
* @param l the listener called back when some user action is done on this widget
*/
public void setOnDialActionListener(OnDialActionListener l) {
actionListener = l;
} /**
* Set the action buttons enabled or not
*/
public void setEnabled(boolean enabled) {
findViewById(R.id.dialButton).setEnabled(enabled);
findViewById(R.id.dialVideoButton).setEnabled(enabled);
findViewById(R.id.deleteButton).setEnabled(enabled);
} @Override
public void onClick(View v) {
if (actionListener != null) {
int viewId = v.getId();
if (viewId == R.id.dialVideoButton) {
actionListener.placeVideoCall();
}else if(viewId == R.id.dialButton) {
actionListener.placeCall();
}else if(viewId == R.id.deleteButton) {
actionListener.deleteChar();
}
}
} @Override
public boolean onLongClick(View v) {
if (actionListener != null) {
int viewId = v.getId();
if(viewId == R.id.deleteButton) {
actionListener.deleteAll();
v.setPressed(false);
return true;
}
}
return false;
} }

pjsip视频通信开发(上层应用)之拨号键盘下部份拨号和删除功能的更多相关文章

  1. pjsip视频通信开发(上层应用)之数字键盘的制作

    在pjsip视频通信开发(上层应用)之EditText重写中我制作了一个显示输入内容的EditText,这里将制作一个数字键盘,其实跟计算器一样,最多的就是用TableLayout来实现,内部通过权重 ...

  2. pjsip视频通信开发(上层应用)之拨号界面整体界面功能实现

    在前面的几章里面写了显示.键盘.拨号.删除功能,这里我将他们进行组合,形成一个拨号键盘全部功能.首先是布局 <LinearLayout xmlns:android="http://sc ...

  3. pjsip视频通信开发(上层应用)之EditText重写

    我们经常使用手机的打电话功能,当我们按键盘的时候,有一个地方显示我们按键的内容,当我们的手点击那个地方的时候,并没有弹出软件盘,所以我们再有数字键盘的时候,要屏蔽系统的软件盘. 我们分析一下,软件盘弹 ...

  4. pjsip视频通信开发(底层实现)之用户注册(1)

    一.PJSIP简介 对于pjsip的介绍可以看http://www.cnblogs.com/my_life/articles/2175462.html 文章,里面详细介绍了它的组成框架以及各部份的组成 ...

  5. Android IOS WebRTC 音视频开发总结(七五)-- WebRTC视频通信中的错误恢复机制

    本文主要介绍WebRTC视频通信中的错误恢复机制(我们翻译和整理的,译者:jiangpeng),最早发表在[这里] 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信ID:blac ...

  6. Web实现音频、视频通信

    Google开源实时通信项目WebRTC Google正式开源了WebRTC实时通信项目,希望浏览器厂商能够将该技术内建在浏览器中,从而使Web应用开发人员能够通过HTML标签和JavaScript ...

  7. Android 串口蓝牙通信开发Java版本

    Android串口BLE蓝牙通信Java版 0. 导语 Qt on Android 蓝牙通信开发 我们都知道,在物联网中,BLE蓝牙是通信设备的关键设备.在传统的物联网应用中,无线WIFI.蓝牙和Zi ...

  8. p2p音视频通信

    今年音频没事干了,根据业务需求,调研音视频p2p通信,减小服务器压力,一切从0开始. 需要信令服务器,打洞服务器,帮助链接打通双方,实现p2p音视频通信. 服务器和客服端交互等都需要实现. 谷歌web ...

  9. 《转》iOS音频视频初级开发

    代码改变世界 Posts - 73, Articles - 0, Comments - 1539 Cnblogs Dashboard Logout HOME CONTACT GALLERY RSS   ...

随机推荐

  1. android学习笔记五

    Android中的category大全 Api Level 3(SDK 1.5)和Api Level 4(SDK 1.6): android.intent.category.ALTERNATIVE a ...

  2. hdu 3518(后缀数组)

    题意:容易理解... 分析:这是我做的后缀数组第一题,做这个题只需要知道后缀数组中height数组代表的是什么就差不多会做了,height[i]表示排名第i的后缀与排名第i-1的后缀的最长公共前缀,然 ...

  3. logback.xml配置

    一:根节点<configuration>包含的属性: scan: 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true. scanPeriod: 设置监测配置文 ...

  4. 滑动菜单栏开源项目SlidingMenu的使用

    一.SlidingMenu简介相信大家对SlidingMenu都不陌生了,它是一种比较新的设置界面或配置界面的效果,在主界面左滑或者右滑出现设置界面效果,能方便的进行各种操作.很多优秀的应用都采用了这 ...

  5. Dev gridControl 添加表标题

    1.OptionsView ->ShowViewCaption = True 2.ViewCaption = "标题"

  6. Delphi 使用串口模拟工具进行串口程序开发调试

      版权声明:本文为博主原创文章,如需转载请注明出处及作者. 本文由小李专栏原创,转载需注明出处:[http://blog.csdn.net/softwave/article/details/8907 ...

  7. Matlab编程实例(2) 同期平均

    %多点同期平均 close all; clear all; pi = 3.14159; Samp2=input('您需要几组信号做同期平均?') Samp1=1000 %设置采样精度 t = lins ...

  8. Fixing the Great Wall

    题意: 在一条线上,有n个坏的地方要修机器人修,机器人的移动速度V,若坏的地方立即被修花费ci,若没修,每单位时间增加d,出去机器人的开始位置,求修完n个地方的最小花费. 分析: 非常经典,求解“未来 ...

  9. 细雨学习笔记:Jmeter测试计划最基本的元素

    测试计划-用户组下最基本的元素: 1)HTTP请求默认值 2)HTTP Cookie 管理器(有些操作需要登录后才能访问,用户信息记录在Cookie中,各请求之间就可以共享Cookie了) 3)请求S ...

  10. LINQ to SQL语句之Join和Order By

    Join操作 适用场景:在我们表关系中有一对一关系,一对多关系,多对多关系等.对各个表之间的关系,就用这些实现对多个表的操作. 说明:在Join操作中,分别为Join(Join查询), SelectM ...