[FAQ13734]状态栏中的信号栏添加上下行标识

DESCRIPTION]
 状态栏中的信号栏默认无上下行标识。
若要在信号栏添加上下行标识,如下图。实现添加上下行标识,可以采用下面的办法:
 
  
[SOLUTION]
 
 
 添加方法如下:
一,M0版本添加上下行图标如下:

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,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 = getState(subId);
state.mDataActivityId = imgDataActivityID;
}
//add end 


@Override
281 public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
282 int networkType, int qsType, boolean activityIn, boolean activityOut,
283 /// M: Add for CT6M. add activity icon @{
284 int dataActivity,
285 int primarySimIcon,
286 /// @}
287 String typeContentDescription, String description, boolean isWide, int subId) {
288 PhoneState state = getState(subId);
289 if (state == null) {
290 return;
291 }
292 state.mMobileVisible = statusIcon.visible && !mBlockMobile;
293 state.mMobileStrengthId = statusIcon.icon;
294 ....................
312 setDataActivityMTK(activityIn, activityOut, subId);
313 apply();
314 }

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

}
private class PhoneState {
.......................


public boolean apply(boolean isSecondaryIcon) {
private final int mSubId;
private boolean mMobileVisible = false;
...............................
public boolean apply(boolean isSecondaryIcon) {
686 if (mMobileVisible && !mIsAirplaneMode) {
687 mMobile.setImageResource(mMobileStrengthId);
688 Drawable mobileDrawable = mMobile.getDrawable();
689 ...................

// 添加:
if (mDataActivityId!=0) {
mDataActivityInOut.setImageResource(mDataActivityId);
mDataActivityInOut.setVisibility(View.VISIBLE);
} else {
mDataActivityInOut.setImageDrawable(null);
mDataActivityInOut.setVisibility(View.GONE);
 
 
 
二,L0实现添加上下行标识
第一步:修改XML文件。
打开alps\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\systemui\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[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);
     // add
    mDataActivity[i]            = (ImageView) findViewById(R.id.data_inout);
            } 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);
    // add
    mDataActivity[i]              = (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[i]          = null;
            mMobile[i]               = null;
            mMobileType[i]           = null;
            mSpacer[i]               = null;
   //add
    mDataActivity[i] = null;
        }
  
  2.5.
apply()方法里:
 
// Run after each indicator change.
    public void apply() {
.........................
..........................................
                if (getNullIconIdGemini(i) == mMobileStrengthId[i][0].getIconId()
                    || mMobileStrengthId[i][0].getIconId() == R.drawable.stat_sys_signal_null) {
                    mMobileType[i].setVisibility(View.GONE);
                }
                Xlog.d(TAG, "apply(), slot=" + i + ", "
                        + " mIsAirplaneMode is " + mIsAirplaneMode
                        + ", mRoaming=" + mRoaming[i]
                        + " mMobileActivityId=" + mMobileActivityId[i].getIconId()
                        + " mMobileTypeId=" + mMobileTypeId[i].getIconId()
                        + " mMobileTypeRes=" + mMobileTypeId[i].getResources()
                        + " mMobileVisible=" + mMobileType[i].getVisibility()
                        + " mMobileStrengthId[0] = " + mMobileStrengthId[i][0].getIconId()
                        + " mMobileStrengthId[1] = " + mMobileStrengthId[i][1].getIconId());

// add
     if (mMobileActivityId[i].getIconId() != 0) {
    
      if (mDataActivity[i] != null) {
            mDataActivity[i].setImageResource(mMobileActivityId[i].getIconId());
           }
      
        } else {
        
        if (mMobileActivityId[i].getIconId() == 0) {
          if (mDataActivity[i] != null) {
           mDataActivity[i].setImageDrawable(null);
          }
         
         } 
        }
 //add end  
            } else {
                mSignalClusterCombo[i].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_default_sim_indicator);
} else {
mMobileGroup.setBackgroundDrawable(null);
}
 
}


711 mMobileType.setImageResource(mMobileTypeId);
712 mMobileGroup.setContentDescription(mMobileTypeDescription
713 + " " + mMobileDescription);
714 mMobileGroup.setVisibility(View.VISIBLE);
715 } else {
716 mMobileGroup.setVisibility(View.GONE);
717 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值