2.1如何隐藏有SIM卡1,2标记
KK上默认是显示1,2卡标识的。
如果隐藏它们,在文件SignalClusterView.java上由mMobileSlotIndicator变量控制
将mMobileSlotIndicator出现的地方屏蔽掉就可以
2.2 如何去掉状态栏G、3G图标
去掉方法很简单,就是把这个View隐藏就行了,具体修改如下
SignalClusterView.java
(frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar)
apply():
……
//hide network icon begin
/* int state = SIMHelper.getSimIndicatorStateGemini(i);//hide network icon
if (!mIsAirplaneMode
&& SIMHelper.isSimInserted(i)
&& PhoneConstants.SIM_INDICATOR_LOCKED != state
&& PhoneConstants.SIM_INDICATOR_SEARCHING != state
&& PhoneConstants.SIM_INDICATOR_INVALID != state
&& PhoneConstants.SIM_INDICATOR_RADIOOFF != state) {
……
} else {*/
mSignalNetworkType[i].setImageDrawable(null);
mSignalNetworkType[i].setVisibility(View.GONE);
//}
//hide network icon end
……
二 L版本上(5.0)如何增加有SIM卡1,2标记
L版本5.0默认是没有显示的1.2卡标识的!
如果要增加1,2标识,可按下面步骤添加:
1,Signal_Cluster_View.xml
<!-- M: Support "Default SIM Indicator". }@ -->
<LinearLayout
android:id="@+id/signal_cluster_combo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<View
android:layout_height="6dp"
android:layout_width="6dp"
android:visibility="invisible"
/>
<!-- M: Support "Service Network Type on Statusbar". @{ -->
<ImageView
android:id="@+id/network_type"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
/>
<!-- M: Support "Service Network Type on Statusbar". }@ -->
<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>
</LinearLayout>
<!-- the 2nd sim card start -->
<View
android:layout_height="1dp"
android:layout_width="1dp"
android:tag="spacer_2"
android:visibility="gone"
android:id="@+id/spacer_2"
/>
<View
android:layout_height="1dp"
android:layout_width="1dp"
android:visibility="invisible"
/>
<LinearLayout
android:id="@+id/signal_cluster_combo_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="signal_cluster_combo_2"
>
<!-- M: Support "Service Network Type on Statusbar". @{ -->
<ImageView
android:id="@+id/network_type_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
android:tag="network_type_2"
/>
<!-- M: Support "Service Network Type on Statusbar". }@ -->
<FrameLayout
android:id="@+id/mobile_combo_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="mobile_combo_2"
>
<ImageView
android:id="@+id/mobile_signal_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="mobile_signal_2"
/>
<ImageView
android:id="@+id/mobile_type_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="mobile_type_2"
/>
<!-- add :mobile_slot_indicateor". }@ -->
<ImageView
android:id="@+id/mobile_slot_indicator_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
</LinearLayout>
<!-- the 2nd sim card end -->
2.SignalClusterView.java
文件添加
// add
private ImageView[] mMobileSlotIndicator;
//add
int[] slots_indicators=new int[]{R.drawable.sim1_indicator,R.drawable.sim2_indicator};
// 图片sim1_indicator,sim2_indicator是你制作的sim1,sim2标识
public SignalClusterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mSlotCount = SIMHelper.getSlotCount();
........
// add
mMobileSlotIndicator= new ImageView[mSlotCount];
}
onAttachedToWindow()那里
//add
for (int i = SIMHelper.SLOT_INDEX_DEFAULT ; i < mSlotCount; i++) {
final int k = i + 1;
if (i == SIMHelper.SLOT_INDEX_DEFAULT) {
// load views for first SIM card
mMobile[i] = (ImageView) findViewById(R.id.mobile_signal);
mMobileGroup[i] = (ViewGroup) findViewById(R.id.mobile_combo);
mMobileType[i] = (ImageView) findViewById(R.id.mobile_type);
mSpacer[i] = findViewById(R.id.spacer);
mSignalClusterCombo[i] = (ViewGroup) findViewById(R.id.signal_cluster_combo);
/// M: Support "Service Network Type on Statusbar"
mSignalNetworkType[i] = (ImageView) findViewById(R.id.network_type);
//tdp add
mMobileSlotIndicator[i] = (ImageView) findViewById(R.id.mobile_slot_indicator);
} else {
mMobile[i] = (ImageView) findViewWithTag("mobile_signal_" + k);
mMobileGroup[i] = (ViewGroup) findViewWithTag("mobile_combo_" + k);
mMobileType[i] = (ImageView) findViewWithTag("mobile_type_" + k);
mSpacer[i] = findViewWithTag("spacer_" + k);
mSignalClusterCombo[i] = (ViewGroup) findViewWithTag("signal_cluster_combo_" + k);
/// M: Support "Service Network Type on Statusbar"
mSignalNetworkType[i] = (ImageView) findViewWithTag("network_type_" + k);
//tdp add
mMobileSlotIndicator[i] = (ImageView) findViewWithTag("mobile_slot_indicator_"+k);
}
//add
mMobileSlotIndicator[i].setImageDrawable(slots_indicators[i]);
mMobileSlotIndicator[i].setVisibility(View.VISIBLE);
}
onDetachedFromWindow()那里
//add
@Override
protected void onDetachedFromWindow() {
mVpn = null;
mWifiGroup = null;
mWifi = null;
/// M: WifiActivityIcon
mWifiActivity = null;
for (int i = SIMHelper.SLOT_INDEX_DEFAULT; i < mSlotCount ; i++) {
mMobileGroup[i] = null;
mMobile[i] = null;
mMobileType[i] = null;
mSpacer[i] = null;
//add
mMobileSlotIndicator[i] = null;
}
添加方法如下:关注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;
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);
}
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);
}
添加方法如下:关注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;
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);
}
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);
}