N0 通话界面增加录音计时功能

客户需求:在点击录音按钮之后 需要显示计时 简单的计时器
首先 增加布局文件 资源文件中有多个layout 只要有call_card_fragment都增加
packages\apps\Dialer\InCallUI\res\layout\call_card_fragment.xml

            <!-- M:fix ALPS02297097,recording icon still at the right
            side as Arabic,correct layout_gravity from right to end -->
            <ImageView android:id="@+id/voiceRecorderIcon"
                       android:layout_width="@dimen/incall_record_icon_size"
                       android:layout_height="@dimen/incall_record_icon_size"
                       android:layout_gravity="end"
                       android:layout_marginEnd="10dip"
                       android:layout_marginTop="10dip"
                       android:visibility="gone" />
             <!--add start-->         
              <TextView
                       android:id="@+id/record_time"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_alignBottom="@+id/voiceRecorderIcon"
                       android:layout_centerVertical="true"
                       android:text="@string/roco_record_time" />
            <!--end-->

然后初始化布局 加载资源
packages\apps\Dialer\InCallUI\src\com\android\incallui\CallCardFragment.java

    /// M: [Voice Record]recording indication icon @{
    private ImageView mVoiceRecorderIcon;
    private TextView mRecordTime;//add by chch
    private void initVoiceRecorderIcon(View view) {
        mVoiceRecorderIcon = (ImageView) view.findViewById(R.id.voiceRecorderIcon);
        mVoiceRecorderIcon.setImageResource(R.drawable.voice_record);
        mRecordTime = (TextView) view.findViewById(R.id.record_time);//add by chch
        mVoiceRecorderIcon.setVisibility(View.INVISIBLE);
        mRecordTime.setVisibility(View.INVISIBLE);//add by chch

    }

实现业务逻辑

    @Override
    public void updateVoiceRecordIcon(boolean show) {
        mVoiceRecorderIcon.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
        mRecordTime.setVisibility(show ? View.VISIBLE : View.INVISIBLE);//add by chch
        AnimationDrawable ad = (AnimationDrawable) mVoiceRecorderIcon.getDrawable();
        if (ad != null) {
            if (show && !ad.isRunning()) {
                ad.start();
            //add chch start
        task=new TimerTask() {

            @Override
            public void run() {
                // TODO Auto-generated method stub
                Message message = new Message();
                message.what = 1;
                handler.sendMessage(message);
            }
        };
        timer.schedule(task, 1000, 1000);
        //add chch end
            } else if (!show && ad.isRunning()) {
                ad.stop();
                //add chch start
        timer.cancel();
        i=1;
        //add chch end
            }
        }
        /// M:[RCS] plugin API @{
        ExtensionManager.getRCSeCallCardExt().updateVoiceRecordIcon(show);
        /// @}
    }
    /// @}
//add  chch  start
    public Timer timer=new Timer();
    public TimerTask task;
    public int hour=1;
    public int i=1;
    Handler handler=new Handler(){
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
            case 1:
                //do your thing.
                String RecordTimeElapsed = DateUtils.formatElapsedTime(i);
                        mRecordTime.setText(RecordTimeElapsed);
                i=i+1;
                break;

            default:
                break;
            }
            super.handleMessage(msg);
        };
    };
    //add chch end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值