微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > android5.1添加sim1,sim2标识

android5.1添加sim1,sim2标识

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
本次针对的是android5.1(即L1)版本添加SIM1,sim2标识。
[SOLUTION]
L1添加sim1,sim2标识
添加方法如下:关注add
1,mobile_signal_group.xml
.....
<FrameLayout
android:id="@+id/mobile_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/mobile_signal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<ImageView
android:id="@+id/mobile_type"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<!-- add :mobile_slot_indicateor". }@ -->
<ImageView
android:id="@+id/mobile_slot_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
2,SignalClusterView.java
//add
int mIndicatorSlot=0;
//add end
private ArrayList<PhoneState> mPhoneStates = new ArrayList<PhoneState>();
//add
int[] slots_indicators=new int[]{R.drawable.sim1_indicator,R.drawable.sim2_indicator};
// 图片sim1_indicator,sim2_indicator是你制作的sim1,sim2标识
//add end
@Override
public void setSubs(List<SubscriptionInfo> subs) {
Xlog.d(TAG, "setSubs(), subs= " + subs);
// Clear out all old subIds.
mPhoneStates.clear();
if (mMobileSignalGroup != null) {
mMobileSignalGroup.removeAllViews();
}
final int n = subs.size();
for (int i = 0; i < n; i++) {
//add
mIndicatorSlot=subs.get(i).getSimSlotIndex();
//add end
inflatePhoneState(subs.get(i).getSubscriptionId());
}
private PhoneState inflatePhoneState(int subId) {
PhoneState state = new PhoneState(subId, mContext);
//add
state.mSlotIndicator=mIndicatorSlot;
//add end
if (mMobileSignalGroup != null) {
mMobileSignalGroup.addView(state.mMobileGroup);
}
mPhoneStates.add(state);
return state;
}
private class PhoneState {
private final int mSubId;
private boolean mMobileVisible = false;
private int mMobileStrengthId = 0, mMobileTypeId = 0;
private boolean mIsMobileTypeIconWide;
private String mMobileDescription, mMobileTypeDescription;
private ViewGroup mMobileGroup;
//add
private ImageView mMobile, mMobileType,mMobileSlotIndicator;// add mMobileSlotIndicator
//add
private int mSlotIndicator;
public void setViews(ViewGroup root) {
mMobileGroup = root;
mMobile = (ImageView) root.findViewById(R.id.mobile_signal);
mMobileType = (ImageView) root.findViewById(R.id.mobile_type);
/// M: Support "Service Network Type on Statusbar".
mSignalNetworkType = (ImageView) root.findViewById(R.id.network_type);
// add
mMobileSlotIndicator= (ImageView) root.findViewById(R.id.mobile_slot_indicator);
//add end
}
public boolean apply(boolean isSecondaryIcon) {
Xlog.d(TAG, "apply(" + mSubId + ")," + " mMobileVisible= " + mMobileVisible +
", mIsAirplaneMode= " + mIsAirplaneMode);
if (mMobileVisible && !mIsAirplaneMode) {
mMobile.setImageResource(mMobileStrengthId);
mMobileType.setImageResource(mMobileTypeId);
mMobileGroup.setContentDescription(mMobileTypeDescription
+ " " + mMobileDescription);
mMobileGroup.setVisibility(View.VISIBLE);
//add
mMobileSlotIndicator.setImageResource(slots_indicators[mSlotIndicator]);
//add end
} else {
mMobileGroup.setVisibility(View.GONE);
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top