Android9.0 SystemUI 网络信号栏定制修改的流程解析

前情提要

Android 8.1平台SystemUI 导航栏加载流程解析

9.0 改动点简要说明

1、新增 StatusBarMobileView 替代 SignalClusterView,用以控制信号栏显示

同时增加的还有 StatusBarIconView、StatusBarWifiView

2、整体流程和 8.1 类似

效果图

整体流程图

上代码

先来看初始赋值的地方 MobileSignalController.java,在 notifyListeners() 方法中进行我们对应的定制,

最后通过 callback.setMobileDataIndicators() 将状态值传递到 StatusBarSignalPolicy.java 解析显示

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\policy\MobileSignalController.java

@Override
 public void notifyListeners(SignalCallback callback) {
 MobileIconGroup icons = getIcons();
 String contentDescription = getStringIfExists(getContentDescription());
 String dataContentDescription = getStringIfExists(icons.mDataContentDescription);
 if (mCurrentState.inetCondition == 0) {
  dataContentDescription = mContext.getString(R.string.data_connection_no_internet);
 }
 final boolean dataDisabled = mCurrentState.iconGroup == TelephonyIcons.DATA_DISABLED
  && mCurrentState.userSetup;
 /// M: Customize the signal strength icon id. @ {
 int iconId = getCurrentIconId();
 iconId = mStatusBarExt.getCustomizeSignalStrengthIcon(
   mSubscriptionInfo.getSubscriptionId(),
   iconId,
   mSignalStrength,
   mDataNetType,
   mServiceState);
 /// @ }
 if (mSignalStrength != null) {
  /*int dbm = mSignalStrength.getDbm();
  int asu = mSignalStrength.getAsuLevel();
  Log.i("ccz","dbm="+dbm + " asu="+asu);*/
  Log.e("ccz", "isGSM=="+mSignalStrength.isGsm()
  + " connected=="+mCurrentState.connected+" dataConnected=="+mCurrentState.dataConnected);
 }
 if (mCurrentState.connected) {
  //cczheng add get signal icon [S]
  //通过 getSignalStrengthIcon 方法,根据自定义规则,返回要显示对应资源id
  iconId = TelephonyIcons.getSignalStrengthIcon(mSignalStrength != null ? mSignalStrength.getDbm() : -120,
  mSignalStrength != null ? mSignalStrength.getAsuLevel() : 0);
  //iconId = TelephonyIcons.getSignalStrengthIcon(mCurrentState.level);
  //cczheng add get signal icon [E]
 }else{//未连接成功时显示 X
  iconId = R.drawable.stat_sys_signal_disable;
 }
 // Show icon in QS when we are connected or data is disabled.
 boolean showDataIcon = mCurrentState.dataConnected || dataDisabled;
 Log.i("ccz","dataDisabled="+dataDisabled + " showDataIcon="+showDataIcon);
 IconState statusIcon = new IconState(mCurrentState.enabled && !mCurrentState.airplaneMode,
  iconId, contentDescription);
 int qsTypeIcon = 0;
 IconState qsIcon = null;
 String description = null;
 // Only send data sim callbacks to QS.
 if (mCurrentState.dataSim) {
  qsTypeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mQsDataType : 0;
  qsIcon = new IconState(mCurrentState.enabled
   && !mCurrentState.isEmergency, getQsCurrentIconId(), contentDescription);
  description = mCurrentState.isEmergency ? null : mCurrentState.networkName;
 }
 boolean activityIn = mCurrentState.dataConnected
  && !mCurrentState.carrierNetworkChangeMode
  && mCurrentState.activityIn;
 boolean activityOut = mCurrentState.dataConnected
  && !mCurrentState.carrierNetworkChangeMode
  && mCurrentState.activityOut;
 showDataIcon &= mCurrentState.isDefault || dataDisabled;
 int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon) ? icons.mDataType : 0;
 /// M: Add for lwa.
 typeIcon = mCurrentState.lwaRegState == NetworkTypeUtils.LWA_STATE_CONNCTED
  && showDataIcon ? NetworkTypeUtils.LWA_ICON : typeIcon;
 /** M: Support [Network Type on StatusBar], change the implement methods.
  * Get the network icon base on service state.
  * Add one more parameter for network type.
  * @ { **/
 int networkIcon = mCurrentState.networkIcon;
 /// M: Support volte icon.Bug fix when airplane mode is on go to hide volte icon
 int volteIcon = mCurrentState.airplaneMode && !isImsOverWfc()
  ? 0 : mCurrentState.volteIcon;
 /// M: when data disabled, common show data icon as x, but op do not need show it @ {
 mStatusBarExt.isDataDisabled(mSubscriptionInfo.getSubscriptionId(), dataDisabled);
 /// @ }
 /// M: Customize the data type icon id. @ {
 typeIcon = mStatusBarExt.getDataTypeIcon(
   mSubscriptionInfo.getSubscriptionId(),
   typeIcon,
   mDataNetType,
   mCurrentState.dataConnected ? TelephonyManager.DATA_CONNECTED :
    TelephonyManager.DATA_DISCONNECTED,
   mServiceState);
 /// @ }
 /// M: Customize the network type icon id. @ {
 networkIcon = mStatusBarExt.getNetworkTypeIcon(
   mSubscriptionInfo.getSubscriptionId(),
   networkIcon,
   mDataNetType,
   mServiceState);
 /// for operator
 //通过 description 传递运营商信息
 description = mCurrentState.operator;
 // for qsdatetype
 qsTypeIcon = mCurrentState.mQsDataType;
 /// @ }
 //cczheng add for when datadisable set mMobileDataActivity GONE [S]
 //数据网络关闭时,id 置为0,不显示上下行小箭头
 if (isDataDisabled()) {
  typeIcon = 0;
 }
 Log.d("ccz", "qsTypeIcon="+qsTypeIcon);
 //cczheng add for when datadisable set mMobileDataActivity GONE [E]
 Log.e("ccz", " showDataIcon="+showDataIcon+" activityIn="+activityIn
  +" activityOut="+activityOut);
 Log.i("ccz", "networkName="+mCurrentState.networkName + " description="+description);
 callback.setMobileDataIndicators(statusIcon, qsIcon, typeIcon, networkIcon, volteIcon,
  qsTypeIcon,activityIn, activityOut, dataContentDescription, description,
   icons.mIsWide, mSubscriptionInfo.getSubscriptionId(), mCurrentState.roaming,
   mCurrentState.isDefaultData, mCurrentState.customizedState);
 /// M: update plmn label @{
 mNetworkController.refreshPlmnCarrierLabel();
 /// @}
 }
 private final void updateTelephony() {
 .....
 /// M: For network type big icon.
 mCurrentState.networkIcon =
  NetworkTypeUtils.getNetworkTypeIcon(mServiceState, mConfig, hasService());
 /// M: For volte type icon.
 mCurrentState.volteIcon = getVolteIcon();
 //cczheng add for qsdatetype
 mCurrentState.mQsDataType = ((MobileIconGroup)mCurrentState.iconGroup).mQsDataType;
 //cczheng add for operator
 mCurrentState.operator = getOperatorType();
 notifyListenersIfNecessary();
 }
 private String getOperatorType(){
 if (!hasService()) {
  // Not in service, don't show operator
  return "0";
 }
 int operatorType = NetworkTypeUtils.getOperatorType(mPhone);
 if (operatorType == 0)
  return "0";
 else
  return mContext.getResources().getString(operatorType);
 }

根据通用标准自定义显示规则

dbm >= -107 4格

-107 > dbm >= -111 3格

-111 > dbm >= -114 2格

-114 > dbm >= -117 1格

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\policy\TelephonyIcons.java

 static final int[] TELEPHONY_SIGNAL_STRENGTH_FULL = {
  R.drawable.stat_sys_signal_0_fully,
  R.drawable.stat_sys_signal_1_fully,
  R.drawable.stat_sys_signal_2_fully,
  R.drawable.stat_sys_signal_3_fully,
  R.drawable.stat_sys_signal_4_fully,
 };
 /**
 * Customize Signal strength icon.
 * @param level telephony signal strength leve.
 * @return Signal strength icon id.
 */
 static final int getSignalStrengthIcon(int level) {
 android.util.Log.e("ccz", "getSignalStrengthIcon() level=="+level);
 if (level >= 0 && level < TELEPHONY_SIGNAL_STRENGTH_FULL.length) {
  return TELEPHONY_SIGNAL_STRENGTH_FULL[level];
 }
 return 0;
 }
 static final int getSignalStrengthIcon(int dbm, int asu) {
 int level = 0;
 if(dbm >= -107) level = 4;
 else if (dbm >= -111) level = 3;
 else if (dbm >= -114) level = 2;
 else if (dbm >= -117) level = 1;
 android.util.Log.e("ccz", "getSignalStrengthIcon() dbm=="+dbm + " asu=="+asu + " level=="+level);
 return TELEPHONY_SIGNAL_STRENGTH_FULL[level];
 }

舍弃原来的网络大图标,新增网络小图标,这样可以在下方显示网络数据图标

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\mediatek\systemui\statusbar\networktype\NetworkTypeUtils.java

//cczheng add show small networkType
static final Map<Integer, Integer> sNetworkTypeSmallIcons = new HashMap<Integer, Integer>() {
 {
  // For CDMA 3G
  put(TelephonyManager.NETWORK_TYPE_EVDO_0, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_EVDO_A, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_EVDO_B, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_EHRPD, R.drawable.stat_sys_data_fully_connected_3g);
  // For CDMA 1x
  put(TelephonyManager.NETWORK_TYPE_CDMA, R.drawable.stat_sys_data_fully_connected_1x);
  put(TelephonyManager.NETWORK_TYPE_1xRTT, R.drawable.stat_sys_data_fully_connected_1x);
  // Edge
  put(TelephonyManager.NETWORK_TYPE_EDGE, R.drawable.stat_sys_data_fully_connected_e);
  // 3G
  put(TelephonyManager.NETWORK_TYPE_UMTS, R.drawable.stat_sys_data_fully_connected_3g);
  // For 4G
  put(TelephonyManager.NETWORK_TYPE_LTE, R.drawable.stat_sys_data_fully_connected_4g);
  // 3G
  put(TelephonyManager.NETWORK_TYPE_HSDPA, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_HSUPA, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_HSPA, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_HSPAP, R.drawable.stat_sys_data_fully_connected_3g);
  put(TelephonyManager.NETWORK_TYPE_IWLAN, 0);
 }
 };
public static int getNetworkTypeIcon(ServiceState serviceState, Config config,
  boolean hasService) {
 if (!hasService) {
  // Not in service, no network type.
  return 0;
 }
 int tempNetworkType = getNetworkType(serviceState);
 //cczheng change sNetworkTypeIcons to sNetworkTypeSmallIcons, show small networkType
 //Integer iconId = sNetworkTypeIcons.get(tempNetworkType);
 Integer iconId = sNetworkTypeSmallIcons.get(tempNetworkType);//add
 if (iconId == null) {
  iconId = tempNetworkType == TelephonyManager.NETWORK_TYPE_UNKNOWN ? 0 :
   config.showAtLeast3G ? R.drawable.stat_sys_network_type_3g :
      R.drawable.stat_sys_network_type_g;
 }
 Log.i("ccz", "Operator=="+ serviceState.getOperatorAlphaLong());
 return iconId.intValue();
 }
//cczheng add for operatortype
static final int[] OPERATOR_TYPE = {
 R.string.operator_cmcc,//CHINA_MOBILE
 R.string.operator_cucc,//CHINA_UNICOM
 R.string.operator_ctcc//CHINA_TELECOM
};
public static int getOperatorType(TelephonyManager telephonyManager) {
 int type = 0;
 String operator = telephonyManager.getSimOperator();
 switch (operator) {
 case "46000":
 case "46002":
 case "46007":
 case "41004":
  type = OPERATOR_TYPE[0];
  break;
 case "46001":
 case "46006":
  type = OPERATOR_TYPE[1];
  break;
 case "46003":
 case "46011":
  type = OPERATOR_TYPE[2];
  break;
 default:
  break;
 }
 return type;
}

StatusBarSignalPolicy 通过 description 传递运营商类型

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\phone\StatusBarSignalPolicy.java
@Override
 public void setMobileDataIndicators(IconState statusIcon, IconState qsIcon, int statusType,
  int networkType, int volteIcon, int qsType, boolean activityIn, boolean activityOut,
  String typeContentDescription, String description, boolean isWide, int subId,
  boolean roaming, boolean isDefaultData, int customizedState) {
 Log.i("ccz","StatusBarSignalPolicy setMobileDataIndicators()");
 MobileIconState state = getState(subId);
 if (state == null) {
  return;
 }
 .....
 //cczheng add for operator because description is unless
 state.mOperator = description;
 Log.e("ccz","mMobileStrengthId="+statusIcon.icon);
 // Always send a copy to maintain value type semantics
 mIconController.setMobileIcons(mSlotMobile, MobileIconState.copyStates(mMobileStates));
}

StatusBarMobileView 获取传递的资源id值显示对应的图标

vendor\mediatek\proprietary\packages\apps\SystemUI\src\com\android\systemui\statusbar\StatusBarMobileView.java
public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
 StatusIconDisplayable {
 private static final String TAG = "StatusBarMobileView";
 ....
 //cczheng add
 private ImageView mMobileDataActivity;
 private TextView mOperatorType;
 private void init() {
 ....
 mNetworkType = findViewById(R.id.network_type);
 mVolteType = findViewById(R.id.volte_indicator_ext);
 /// @}
 mMobileDataActivity = findViewById(R.id.data_inout);
 mOperatorType = findViewById(R.id.tv_operator);
 mMobileDrawable = new SignalDrawable(getContext());
 //cczheng annotaion don't use system full style
 //mMobile.setImageDrawable(mMobileDrawable);
 initDotView();
 mIsWfcEnable = SystemProperties.get("persist.vendor.mtk_wfc_support").equals("1");
 /// M: Add for Plugin feature @ {
 mStatusBarExt = OpSystemUICustomizationFactoryBase.getOpFactory(mContext)
     .makeSystemUIStatusBar(mContext);
 /// @ }
 }
 private void initViewState() {
 setContentDescription(mState.contentDescription);
 if (!mState.visible) {
  mMobileGroup.setVisibility(View.GONE);
 } else {
  mMobileGroup.setVisibility(View.VISIBLE);
 }
 //cczheng don't use system style change empty line style 注释原来的实心信号格
 //mMobileDrawable.setLevel(mState.strengthId);
 mMobile.setImageResource(mState.strengthId);
 //show date in out icon 数据流量小箭头
 mMobileDataActivity.setImageResource(getDataActivityIcon(mState.activityIn, mState.activityOut));
 if (mState.typeId > 0) {
  if (!mStatusBarExt.disableHostFunction()) {
  mMobileType.setContentDescription(mState.typeContentDescription);
  mMobileType.setImageResource(mState.typeId);
  }
  //cczheng hide small datatype icon x or 4G
  mMobileType.setVisibility(View.GONE /*View.VISIBLE*/);
 } else {
  mMobileType.setVisibility(View.GONE);
 }
 mMobileRoaming.setVisibility(mState.roaming ? View.VISIBLE : View.GONE);
 mIn.setVisibility(mState.activityIn ? View.VISIBLE : View.GONE);
 mOut.setVisibility(mState.activityIn ? View.VISIBLE : View.GONE);
 //mInoutContainer.setVisibility((mState.activityIn || mState.activityOut)
 // ? View.VISIBLE : View.GONE);
 mMobileDataActivity.setVisibility(mState.typeId != 0 ? View.VISIBLE : View.GONE);
 /// M: Add for [Network Type and volte on Statusbar] @{
 setCustomizeViewProperty();
 /// @}
 showWfcIfAirplaneMode();
 /// M: Add data group for plugin feature. @ {
 mStatusBarExt.addCustomizedView(mState.subId, mContext, mMobileGroup);
 setCustomizedOpViews();
 /// @ }
 }
 private void updateState(MobileIconState state) {
 setContentDescription(state.contentDescription);
 if (mState.visible != state.visible) {
  mMobileGroup.setVisibility(state.visible ? View.VISIBLE : View.GONE);
  // To avoid StatusBarMobileView will not show in extreme case,
  // force request layout once if visible state changed.
  requestLayout();
 }
 if (mState.strengthId != state.strengthId) {
  //cczheng don't use system style change empty line style
  //mMobileDrawable.setLevel(state.strengthId);
  mMobile.setImageResource(state.strengthId);
 }
 //show date in out icon
 mMobileDataActivity.setImageResource(getDataActivityIcon(state.activityIn, state.activityOut));
 if (mState.typeId != state.typeId) {
  if (state.typeId != 0) {
  if (!mStatusBarExt.disableHostFunction()) {
   mMobileType.setContentDescription(state.typeContentDescription);
   mMobileType.setImageResource(state.typeId);
  }
  //cczheng hide small datatype icon x or 4G
  //数据流量标识 mMobileDataActivity 替代 mMobileType
  mMobileType.setVisibility(View.GONE /*View.VISIBLE*/);
  } else {
  mMobileType.setVisibility(View.GONE);
  }
 }
 mMobileRoaming.setVisibility(state.roaming ? View.VISIBLE : View.GONE);
 mIn.setVisibility(state.activityIn ? View.VISIBLE : View.GONE);
 mOut.setVisibility(state.activityIn ? View.VISIBLE : View.GONE);
 //mInoutContainer.setVisibility((state.activityIn || state.activityOut)
 // ? View.VISIBLE : View.GONE);
 mMobileDataActivity.setVisibility(state.typeId != 0 ? View.VISIBLE : View.GONE);
 /// M: Add for [Network Type and volte on Statusbar] @{
 if (mState.networkIcon != state.networkIcon) {
  setNetworkIcon(state.networkIcon);
 }
 if (mState.volteIcon != state.volteIcon) {
  setVolteIcon(state.volteIcon);
 }
 if (mState.mOperator != state.mOperator) {
  setOperatorText(state.mOperator);
 }
 if (mState.mCustomizedState != state.mCustomizedState
  || mState.networkIcon != state.networkIcon) {
  // if cs reg state has changed or network icon change to LTE,need to update.
  mStatusBarExt.setDisVolteView(mState.subId, state.volteIcon, mVolteType);
 }
 /// @}
 mState = state;
 // should added after set mState
 showWfcIfAirplaneMode();
 setCustomizedOpViews();
 }
 //cczheng add for data in out icon [S]
 final int DATA_ACTIVITY_NONE = R.drawable.ct_stat_sys_signal_not_inout;
 final int DATA_ACTIVITY_IN = R.drawable.ct_stat_sys_signal_in;
 final int DATA_ACTIVITY_OUT = R.drawable.ct_stat_sys_signal_out;
 final int DATA_ACTIVITY_INOUT = R.drawable.ct_stat_sys_signal_inout;
 /**
 * M: getDataActivityIcon: Get DataActivity icon by dataActivity type.
 * @param activityIn : dataActivity Type
 * @param activityOut : dataActivity Type
 * @return dataActivity icon ID
 */
 public int getDataActivityIcon(boolean activityIn, boolean activityOut) {
 Log.i("ccz", "mActivityIn="+activityIn+" mActivityOut="+activityOut);
 int icon = DATA_ACTIVITY_NONE;
 if (activityIn && activityOut) {
  icon = DATA_ACTIVITY_INOUT;
 }else if (activityIn) {
  icon = DATA_ACTIVITY_IN;
 }else if (activityOut) {
  icon = DATA_ACTIVITY_OUT;
 }
 return icon;
 }
 //cczheng add for data in out icon [S]
 private void setOperatorText(String mOperator){
 if ("0".equals(mOperator)) {
  mOperatorType.setVisibility(View.GONE);
 } else {
  mOperatorType.setText(mOperator);
  mOperatorType.setVisibility(View.VISIBLE);
 }
 }

StatusBarMobileView 对应布局文件 status_bar_mobile_signal_group 修改

vendor\mediatek\proprietary\packages\apps\SystemUI\res\layout\status_bar_mobile_signal_group.xml

<com.android.systemui.statusbar.StatusBarMobileView
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:systemui="http://schemas.android.com/apk/res-auto"
 android:id="@+id/mobile_combo"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:gravity="center_vertical" >
 <com.android.keyguard.AlphaOptimizedLinearLayout
 android:id="@+id/mobile_group"
 android:layout_width="wrap_content"
 android:layout_height="match_parent"
 android:gravity="center_vertical"
 android:orientation="horizontal" >
 <ImageView
  android:id="@+id/volte_indicator_ext"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center_vertical"
  android:visibility="gone"
  />
 <!-- <ImageView
  android:id="@+id/network_type"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:layout_gravity="center_vertical"
  android:visibility="gone"
  /> -->
 <!-- cczheng annotaion network_type and add data in out view-->
 <FrameLayout
  android:layout_height="17dp"
  android:layout_width="wrap_content">
  <ImageView
  android:id="@+id/network_type"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:paddingEnd="2dp"
  android:visibility="gone"/>
  <ImageView
  android:id="@+id/data_inout"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:paddingEnd="2dp"
  android:visibility="gone"/>
 </FrameLayout>
 <!-- end -->
 .......
 <ImageView
  android:id="@+id/mobile_roaming"
  android:layout_width="wrap_content"
  android:layout_height="17dp"
  android:paddingStart="1dp"
  android:paddingTop="1.5dp"
  android:paddingBottom="3dp"
  android:paddingEnd="1dp"
  android:scaleType="fitCenter"
  android:src="@drawable/stat_sys_roaming_ext"
  android:contentDescription="@string/data_connection_roaming"
  android:visibility="gone" />
 <!-- cczheng add for sim operator -->
 <TextView
  android:id="@+id/tv_operator"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:visibility="gone"/>
 </com.android.keyguard.AlphaOptimizedLinearLayout>
</com.android.systemui.statusbar.StatusBarMobileView>

总结

以上所述是小编给大家介绍的Android9.0 SystemUI 网络信号栏定制修改,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

(0)

相关推荐

  • Android实现简单底部导航栏 Android仿微信滑动切换效果

    Android仿微信滑动切换最终实现效果: 大体思路: 1. 主要使用两个自定义View配合实现; 底部图标加文字为一个自定义view,底部导航栏为一个载体,根据需要来添加底部图标; 2. 底部导航栏的设置方法类似于TabLayout的关联,View需要创建关联方法,用来关联VIewPager; 3. 通过关联方法获取ViewPager实例后,根据ViewPager页面数创建底部导航栏的图标按钮; 代码实现: 1. 新建第一个自定义View, 图标 + 文字 的底部按钮; /** * 自定义控件

  • Android开发之判断有无虚拟按键(导航栏)的实例

    判断有无虚拟按键(导航栏) 现在很大一部分手机没有虚拟按键,一部分有.我们在做适配的时候可能会用到这方面的知识. 例如:屏幕填充整个屏幕的时候,没办法只能连导航栏一起填充了,但是这个不是我们想要的,我们要给布局试着paddingbottom,这个时候我们就要判断有么有导航栏,导航栏高度是多少了. /** * 获取是否存在NavigationBar * @param context * @return */ public boolean checkDeviceHasNavigationBar(Co

  • 解析Android 8.1平台SystemUI 导航栏加载流程

    需求 基于MTK8163 8.1平台定制导航栏部分,在左边增加音量减,右边增加音量加 思路 需求开始做之前,一定要研读SystemUI Navigation模块的代码流程!!!不要直接去网上copy别人改的需求代码,盲改的话很容易出现问题,然而无从解决.网上有老平台(8.0-)的讲解System UI的导航栏模块的博客,自行搜索.8.0对System UI还是做了不少细节上的改动,代码改动体现上也比较多,但是总体基本流程并没变. 源码阅读可以沿着一条线索去跟代码,不要过分在乎代码细节!例如我客制

  • Android自定义ViewPagerIndicator实现炫酷导航栏指示器(ViewPager+Fragment)

    ViewPagerIndicator导航栏指示器运行效果: 实现这个效果,我是看了很多大神写的博客和视频后自己敲的,欢迎指正 github地址:https://github.com/dl10210950/TabViewPagerIndicator 自定义一个ViewPagerIndicator 自定义一个Indicator继承LinearLayout,在构造方法里面设置画笔的一些属性 public ViewPagerIndicator(Context context, AttributeSet

  • Android中TabLayout+ViewPager 简单实现app底部Tab导航栏

    前言 在谷歌发布Android Design Support Library之前,app底部tab布局的实现方法就有很多种,其中有RadioGroup+FrameLayout.TabHost+Fragment.FragmentPagerAdapter+ViewPager等方法,虽然这些方法虽然能达到同样的效果,但我个人总觉得有些繁琐.然而,Google在2015的IO大会上,给开发者们带来了全新的Android Design Support Library,里面包含了许多新控件,这些新控件有许多

  • 超简单的几行代码搞定Android底部导航栏功能

    超简单,几行代码搞定Android底部导航栏-–应项目需求以及小伙伴的留言,新加了两个方法: 设置底部导航栏背景图片 添加底部导航栏选项卡切换监听事件 底部导航栏的实现也不难,就是下边是几个Tab切换,上边一般是一个FrameLayout,然后FrameLayout中切换fragment. 网上有不少关于Android底部导航栏的文章,不过好像都只是关于下边Tab切的,没有实现Tab与fragment的联动,用的时候还要自己手写这部分代码,对我这个比较懒(据说,懒是程序员的一种美德_#)得程序员

  • Android自定义顶部导航栏控件实例代码

    下面一段代码给大家介绍了android 自定义顶部导航栏控件功能,具体代码如下所示: class HeaderBar @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr) { //重写构造方法 在java里面 我们一般是重写三个构造方法//在kotlin中 我们可以使用

  • Android虚拟导航栏遮挡底部的输入框的解决方法

    1.场景还原 最近忙着app的适配,在这个过程问题中,各种机型的奇葩问题都出来了,适配真尼玛痛苦!今天就oppo机型虚拟导航栏遮挡底部的输入框的问题作个记录. 2.解决方法 ① 在该Activity的根layout配置如下属性: android:fitsSystemWindows="true" android:clipToPadding="false" 第一个属性: 如果为true,将调整系统窗口布局以适应你自定义的布局. 第二个属性: 控件的绘制区域是否在padd

  • Android 沉浸式状态栏与隐藏导航栏实例详解

    1 前言 一般我们在Android的APP开发中,APP的界面如下: 可以看到,有状态栏.ActionBar(ToolBar).导航栏等,一般来说,APP实现沉浸式有三种需求:沉浸式状态栏,隐藏导航栏,APP全屏 沉浸式状态栏是指状态栏与ActionBar颜色相匹配, 隐藏导航栏不用多说,就是将导航栏隐藏,去掉下面的黑条. APP全屏是指将状态栏与导航栏都隐藏,例如很多游戏界面,都是APP全屏. 所以,在做这一步时,关键要问清楚产品狗的需求,免得白费功夫. 下面,分别来介绍这三种方式的实现. 2

  • Android9.0 SystemUI 网络信号栏定制修改的流程解析

    前情提要 Android 8.1平台SystemUI 导航栏加载流程解析 9.0 改动点简要说明 1.新增 StatusBarMobileView 替代 SignalClusterView,用以控制信号栏显示 同时增加的还有 StatusBarIconView.StatusBarWifiView 2.整体流程和 8.1 类似 效果图 整体流程图 上代码 先来看初始赋值的地方 MobileSignalController.java,在 notifyListeners() 方法中进行我们对应的定制,

  • 解决iOS11图片下拉放大出现信号栏白条的bug问题

    废话不多说了,具体解决方法如下所示: if(@available(iOS11.0, *)) { self.tableView.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever; }else{ // Fallback on earlier versions self.automaticallyAdjustsScrollViewInsets=NO; } 项目中很多下拉图片放大的效果,使用上面官方给出的iOS1

  • Java C++题解leetcode1620网络信号最好的坐标

    目录 题目 思路:暴力模拟 Java C++ Rust 题目 题目要求 思路:暴力模拟 因为数据范围小,所以是万万没想到的逐个遍历…… 遍历每个塔,然后找每个塔辐射的范围,用一个大矩阵记录每个点对应的信号大小,同时维护当前最大的信号及其对应坐标. Java class Solution { public int[] bestCoordinate(int[][] towers, int radius) { int[][] grid = new int[110][110]; int cx = 0,

  • vue2.0中goods选购栏滚动算法的实现代码

    不多说,直接代码,以便以后重复利用: <script type="text/ecmascript-6"> import BScroll from 'better-scroll'; const ERR_OK = 0; export default { props: { sell: { type: Object } }, data() { return { goods: [], listHeight: [], scrollY: 0 }; }, computed: { curre

  • Android9.0 静默安装源码的实现

    网上基本都停在8.0就没人开始分析Android9.0如何静默apk的代码,这是我自己之前研究9.0的framework整理出来的,真实源码整理 import android.content.BroadcastReceiver; import android.content.Context; import android.content.IIntentReceiver; import android.content.IIntentSender; import android.content.In

  • Android9.0上针对Toast的特殊处理图文详解

    前言 我们都清楚,Toast显示时长有两个选择,长显示是3.5秒,端显示是2秒.那如果想要做到长时间显示,该怎么做呢?有个历史遗留的app通过开一个线程,不断调用show方法进行实现,这些年也没出过问题,直到系统版本更新到了Android9.0. 实现方式大概如下: mToast = new Toast(context); mToast.setDuration(Toast.LENGTH_LONG); mToast.setView(layout); ... mToast.show(); //在线程

  • android9.0 默认apk权限添加方法

    1.默认赋予全部权限: 安卓动态要求用户允许添加权限,直接将如下代码中的final boolean grantPermissions = (args.installFlags & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0;改为final boolean grantPermissions=true便可. 文件路径:framework\base\services\core\java\com\android\server\pm\Pac

  • Python轮播图与导航栏功能的实现流程全讲解

    目录 轮播图功能 安装依赖模块 上传文件相关配置 注册home子应用 创建轮播图的model模型 创建Banner的序列化器 创建Banner的视图类 配置Banner的路由 配置Xadmin 配置文件注册Xadmin应用 在总路由中添加xadmin的路由信息 给Xadmin配置基本的站点信息 注册轮播图模型到xadmin中 修改后端Xadmin中子应用名称 给轮播图添加测试数据 web端代码获取数据 导航栏的实现 前端导航栏子组件Header的代码 后端导航栏的实现 设计导航栏的model模型

  • Ubuntu/Linux 有关权限修改的命令解析

    chmod更改文件权限命令 最常用的基础命令chmod chmod 777 目录名(路径名) 777 三位数字分别代表 user.group.others 的权限,可读(r).可写(w).可执行(x)的权限分别用数字 4.2.1 表示,数字7是权限 4.2.1 的和,777 即代表 user.group.others 均具有可读(r).可写(w).可执行(x)的权限,为最高权限. 用ls -l 可以查看当前目录 例: -rwxr--r- Sep 06 09:23 CO_00Z02AUG2016_

  • Centos7.0安装ceph(JEWEL)及以上版本的实例解析

    背景 由于docker的Ceph插件rexray对Ceph版本有一定的要求,当Ceph版本为hammer (0.94.10)时,rexray无法成功创建rbd设备.CentOS 7及以上版本,默认安装的就是hammer版本,因此,我们需要安装更高的jewel版本.Ceph的版本可参见. 安装 为了安装速度,我们可以选用国内源.通常大家使用的国内源包括: 网易 http://mirrors.163.com/ceph 中科大 http://mirrors.ustc.edu.cn/ceph 阿里 ht

随机推荐