日前主要工作是,继续跟进宇朔的智能服务终端的项目。随着项目的推进,对系统的定制越来越深入,对系统底层的GPIO再到到应用层APP,进行了一次深层次的定制。现在讲述一下对通话界面(应用层APP)进行的部分定制。
本次任务是:通话界面去除接听键的动画效果,增加简约的电话键button
定制前的界面:
定制后的界面:
实施步骤:
1. 首先,需要将定之前的接听键动画效果去掉
在packages/apps/InCallUI/src/com/android/incallui/AnswerFragment.java文件中去掉showAnswerUi方法中的内容,屏蔽动画效果
复制代码
2. 添加button控件的xml资源文件
在packages/apps/InCallUI/res/layout/answer_fragment.xml资源文件中添加:
在packages/apps/InCallUI/res/values/dimens.xml文件中设置参数,方便参数的统一修改,代码中前面的加号代表新添加的
3. 添加执行的逻辑,当有button被触发,执行相应的操作——接听、挂断、发短息
在packages/apps/InCallUI/src/com/android/incallui/AnswerFragment.java文件中添加语句,‘+’号代表新添加的
至此,就完成了“通话界面去除接听键的动画效果和增加简约的电话button”。本次修改,比较费时的是在button排布和图标大小的协调上面,其他方面直接引用系统原有的内容。
本次任务是:通话界面去除接听键的动画效果,增加简约的电话键button
定制前的界面:
定制后的界面:
实施步骤:
1. 首先,需要将定之前的接听键动画效果去掉
在packages/apps/InCallUI/src/com/android/incallui/AnswerFragment.java文件中去掉showAnswerUi方法中的内容,屏蔽动画效果
- @Override
- public void showAnswerUi(boolean show) {
- /* mGlowpad.setVisibility(show ? View.VISIBLE : View.GONE);
- Log.d(this, "Show answer UI: " + show);
- if (show) {
- mGlowpad.startPing();
- } else {
- mGlowpad.stopPing();
- }*/
- }
2. 添加button控件的xml资源文件
在packages/apps/InCallUI/res/layout/answer_fragment.xml资源文件中添加:
- + <!-- Add by LCJ for answer call 20180125 BEGIN -->
- + <FrameLayout
- + android:id="@+id/in_call_reject"
- + android:layout_width="@dimen/end_call_floating_action_button_diameter"
- + android:layout_height="@dimen/end_call_floating_action_button_diameter"
- + android:background="@drawable/fab_green"
- + android:layout_centerHorizontal="true"
- + android:layout_marginBottom="@dimen/answer_fragment_layout_marginBottom"
- + android:layout_alignParentBottom="true"
- + android:visibility="gone" >
- +
- + <ImageButton android:id="@+id/in_call_reject_button"
- + android:layout_width="match_parent"
- + android:layout_height="match_parent"
- + android:background="@drawable/end_call_background"
- + android:src="@drawable/fab_ic_call_xhdpi"
- + android:scaleType="center"
- + android:contentDescription="@string/onscreenEndCallText" />
- + </FrameLayout>
- +
- + <FrameLayout
- + android:id="@+id/end_call_reject"
- + android:layout_width="@dimen/end_call_floating_action_button_diameter"
- + android:layout_height="@dimen/end_call_floating_action_button_diameter"
- + android:background="@drawable/fab_red"
- + android:layout_toLeftOf="@id/in_call_reject"
- + android:layout_marginRight="@dimen/answer_fragment_layout_marginLeft"
- + android:layout_marginBottom="@dimen/answer_fragment_layout_marginBottom"
- + android:layout_alignParentBottom="true"
- + android:visibility="gone" >
- +
- + <ImageButton android:id="@+id/end_call_reject_button"
- + android:layout_width="match_parent"
- + android:layout_height="match_parent"
- + android:background="@drawable/end_call_background"
- + android:src="@drawable/fab_ic_end_call_xhdpi"
- + android:scaleType="center"
- + android:contentDescription="@string/onscreenEndCallText" />
- + </FrameLayout>
- +
- + <FrameLayout
- + android:id="@+id/text_message_reject"
- + android:layout_width="@dimen/end_call_floating_action_button_diameter"
- + android:layout_height="@dimen/end_call_floating_action_button_diameter"
- + android:background="@drawable/fab_blue"
- + android:layout_toRightOf="@id/in_call_reject"
- + android:layout_marginLeft="@dimen/answer_fragment_layout_marginLeft"
- + android:layout_marginBottom="@dimen/answer_fragment_layout_marginBottom"
- + android:layout_alignParentBottom="true"
- + android:visibility="gone" >
- +
- + <ImageButton android:id="@+id/text_message_reject_button"
- + android:layout_width="match_parent"
- + android:layout_height="match_parent"
- + android:background="@drawable/end_call_background"
- + android:src="@drawable/fab_ic_message_xhdpi"
- + android:scaleType="center"
- + android:contentDescription="@string/onscreenEndCallText" />
- + </FrameLayout>
- + <!-- Add by LCJ for answer call 20180125 END -->
- - <dimen name="end_call_floating_action_button_diameter">72dp</dimen>
- + <dimen name="end_call_floating_action_button_diameter">112dp</dimen>
- <dimen name="end_call_floating_action_button_small_diameter">56dp</dimen>
- + <dimen name="answer_fragment_layout_marginLeft">100dp</dimen>
- + <dimen name="answer_fragment_layout_marginBottom">36dp</dimen>
- +
- <dimen name="conference_call_manager_padding_top">64dp</dimen>
- <dimen name="conference_call_manager_button_dimension">46dp</dimen>
3. 添加执行的逻辑,当有button被触发,执行相应的操作——接听、挂断、发短息
在packages/apps/InCallUI/src/com/android/incallui/AnswerFragment.java文件中添加语句,‘+’号代表新添加的
- import android.widget.EditText;
- import android.widget.ListView;
- import android.widget.TextView;
- +import android.widget.ImageButton;
- import com.google.common.base.Preconditions;
- import com.google.common.collect.Lists;
- +import android.telecom.VideoProfile;
- import java.util.ArrayList;
- import java.util.List;
- private TextView mPromptView;
- + private View mEndCall;
- + private View mInCall;
- + private View mTextMessage;
- + private ImageButton mEndCallButton;
- + private ImageButton mInCallButton;
- + private ImageButton mTextMessageButton;
- public AnswerFragment() {
- }
- mGlowpad = (GlowPadWrapper) parent.findViewById(R.id.glow_pad_view);
- mPromptView = (TextView) parent.findViewById(R.id.incoming_call_prompt_view);
- + mInCall = parent.findViewById(R.id.in_call_reject);
- + mInCallButton = (ImageButton) parent.findViewById(R.id.in_call_reject_button);
- +
- + mEndCall = parent.findViewById(R.id.end_call_reject);
- + mEndCallButton = (ImageButton) parent.findViewById(R.id.end_call_reject_button);
- +
- + mTextMessage = parent.findViewById(R.id.text_message_reject);
- + mTextMessageButton = (ImageButton) parent.findViewById(R.id.text_message_reject_button);
- +
- + mInCallButton.setOnClickListener(new View.OnClickListener() {
- + @Override
- + public void onClick(View v) {
- + getPresenter().onAnswer(VideoProfile.VideoState.AUDIO_ONLY, getContext());
- + }
- + });
- +
- + mEndCallButton.setOnClickListener(new View.OnClickListener() {
- + @Override
- + public void onClick(View v) {
- + getPresenter().onDecline();
- + }
- + });
- +
- + mTextMessageButton.setOnClickListener(new View.OnClickListener() {
- + @Override
- + public void onClick(View v) {
- + getPresenter().onText();
- + }
- + });
- +
- Log.d(this, "Creating view for answer fragment ", this);
- Log.d(this, "Created from activity", getActivity());
- mGlowpad.setAnswerListener(this);
4. button图片和图片背景的使用
button图片使的是:packages/apps/InCallUI/res/drawable-mdpi文件下的 fab_ic_call.png(接听)、fab_ic_end_call.png(挂断)、fab_ic_message.png(短信);图片背景使用的是:packages/apps/InCallUI/res/drawable-mdpi文件下的fab_red.png、fab_green.png、fab_blue.png。
关于图片的大小问题,button图片需要用大或者小的一点图片,则需要的图片packages/apps/InCallUI/res/drawable-mdpi文件下,并在packages/apps/InCallUI/res/layout/answer_fragment.xml文件下android:src="@drawable/fab_ic_call_xxx"指定该图片文件。button背景图片的大小,只需要修改packages/apps/InCallUI/res/values/dimens.xml中的<dimen name="end_call_floating_action_button_diameter">112dp</dimen>,比如将112dp改小为72dp,则button背景图片就会减小。至此,就完成了“通话界面去除接听键的动画效果和增加简约的电话button”。本次修改,比较费时的是在button排布和图标大小的协调上面,其他方面直接引用系统原有的内容。