微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > L上状态栏中的信号栏添加上下行标识

L上状态栏中的信号栏添加上下行标识

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
L状态栏中的信号栏默认无上下行标识。
若要在信号栏添加上下行标识,如下图。L0和L1分别实现添加上下
行标识。可以采用下面的办法:


[SOLUTION]
添加方法如下:
一,L0实现添加上下行标识
第一步:修改XML文件。
打开alps\php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks\base\packages\SystemUI\res\Layout\
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 -->
<ImageView
android:id="@+id/data_inout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="data_inout"
/>
</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 -->
<ImageView
android:id="@+id/data_inout_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="data_inout_2"
/>
</FrameLayout>
</LinearLayout>
<!-- the 2nd sim card end -->
第二步:修改或添加代码。
打开
alps\frameworks\base\packages\SystemUI\src\com\android\sys
temui\statusbar\SignalClusterView.java
2.1 添加新的成员变量
private ImageView[] mDataActivity;
2.2.
public SignalClusterView(Context context, AttributeSet
attrs, int defStyle) {
super(context, attrs, defStyle);
mSlotCount = SIMHelper.getSlotCount();
// add
mDataActivity= new ImageView[mSlotCount];
}
2.3.
onAttachedToWindow()方法里:
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 = (ImageView) findViewById(R.id.mobile_signal);
mMobileGroup = (ViewGroup)
findViewById(R.id.mobile_combo);
mMobileType = (ImageView)
findViewById(R.id.mobile_type);
mSpacer = findViewById(R.id.spacer);
mSignalClusterCombo = (ViewGroup)
findViewById(R.id.signal_cluster_combo);
/// M: Support "Service Network Type on Statusbar"
mSignalNetworkType = (ImageView)
findViewById(R.id.network_type);
// add
mDataActivity = (ImageView)
findViewById(R.id.data_inout);
} else {
mMobile = (ImageView) findViewWithTag("mobile_signal_"
+ k);
mMobileGroup = (ViewGroup)
findViewWithTag("mobile_combo_" + k);
mMobileType = (ImageView)
findViewWithTag("mobile_type_" + k);
mSpacer = findViewWithTag("spacer_" + k);
mSignalClusterCombo = (ViewGroup)
findViewWithTag("signal_cluster_combo_" + k);
/// M: Support "Service Network Type on Statusbar"
mSignalNetworkType = (ImageView)
findViewWithTag("network_type_" + k);
// add
mDataActivity = (ImageView)
findViewWithTag("data_inout_"+k);
}
}
2.4
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 = null;
mMobile = null;
mMobileType = null;
mSpacer = null;
//add
mDataActivity = null;
}
2.5.
apply()方法里:
// Run after each indicator change.
public void apply() {
.........................
..........................................
if (getNullIconIdGemini(i) ==
mMobileStrengthId[0].getIconId()
|| mMobileStrengthId[0].getIconId() ==
R.drawable.stat_sys_signal_null) {
mMobileType.setVisibility(View.GONE);
}
Xlog.d(TAG, "apply(), slot=" + i + ", "
+ " mIsAirplaneMode is " + mIsAirplaneMode
+ ", mRoaming=" + mRoaming
+ " mMobileActivityId=" + mMobileActivityId.getIconId()
+ " mMobileTypeId=" + mMobileTypeId.getIconId()
+ " mMobileTypeRes=" + mMobileTypeId.getResources()
+ " mMobileVisible=" + mMobileType.getVisibility()
+ " mMobileStrengthId[0] = " +
mMobileStrengthId[0].getIconId()
+ " mMobileStrengthId[1] = " +
mMobileStrengthId[1].getIconId());
// add
if (mMobileActivityId.getIconId() != 0) {
if (mDataActivity != null) {
mDataActivity.setImageResource(mMobileActivityId.get
IconId());
}
} else {
if (mMobileActivityId.getIconId() == 0) {
if (mDataActivity != null) {
mDataActivity.setImageDrawable(null);
}
}
}
//add end
} else {
mSignalClusterCombo.setVisibility(View.GONE);
}
}
二,L1实现添加上下行标识
1,mobile_signal_group.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mobile_network_combo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
>
<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"
/>
<!-- mobile_type ps }@ -->
<!-- add in,out data 位置可以调整根据需要-->
<ImageView
android:id="@+id/data_inout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:tag="data_inout"
/>
</FrameLayout>
</LinearLayout>
2,NetworkControllerImpl.java
public interface SignalCluster {
void setNetworkType(NetworkType networkType, int subId);
// add 添加方法:
void setDataActivitymtk(boolean in, boolean out,int subId)
;
//add end
@Override
public void onDataActivity(int direction) {
if (DEBUG) {
Log.d(mTag, "onDataActivity: direction=" + direction);
}
///M: Support SVLTE. @{
mSvLteController.onDataActivity(direction);
///M: Support SVLTE. @}
setActivity(direction);
//添加语句:
int signalClustersLength = mSignalClusters.size();
for (int i = 0; i < signalClustersLength; i++) {
// add inout
mSignalClusters.get(i).setDataActivityMTK(
mCurrentState.dataConnected && mCurrentState.activityIn,
mCurrentState.dataConnected && mCurrentState.activityOut
,mSubscriptionInfo.getSubscriptionId());
}
//add end
}
};
3, SignalClusterView.java
//add
static final int[] DATA_ACTIVITY = {
R.drawable.stat_sys_signal_in,
R.drawable.stat_sys_signal_out,
R.drawable.stat_sys_signal_inout
};
//add end
//add
public void setDataActivityMTK(boolean in, boolean out,
int subId) {
Log.d(TAG, "setDataActivityMTK(in= " + in + "), out= " +
out);
int imgDataActivityID=0;
if(in&&out){
imgDataActivityID=DATA_ACTIVITY[2];
}else if(out){
imgDataActivityID=DATA_ACTIVITY[1];
}else if(in){
imgDataActivityID=DATA_ACTIVITY[0];
}else {
imgDataActivityID=0;
}
PhoneState state = getOrInflateState(subId);
state.mDataActivityId = imgDataActivityID;
}
//add end
private class PhoneState {
.................
private boolean mShowSimIndicator;
// 添加:
private ImageView mDataActivityInOut;
private int mDataActivityId = 0;
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
mDataActivityInOut = (ImageView)
root.findViewById(R.id.data_inout);
//add end
}
public boolean apply(boolean isSecondaryIcon) {
...............................
// 添加:
if (mDataActivityId!=0) {
mDataActivityInOut.setImageResource(mDataActivityId);
mDataActivityInOut.setVisibility(View.VISIBLE);
} else {
mDataActivityInOut.setImageDrawable(null);
mDataActivityInOut.setVisibility(View.GONE);
}
/// M: Support "Default SIM Indicator". @{
if (mShowSimIndicator) {
mMobileGroup.setBackgroundResource(R.drawable.stat_sys_def
ault_sim_indicator);
} else {
mMobileGroup.setBackgroundDrawable(null);
}

赞一个

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

网站地图

Top