android 8.1 下拉栏Systemui的修改

1.下拉开关的创建(哪些显示哪些不显示):
在vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/qs/tileimpl/QSFactoryImpl.java中进行开关的创建;不显示直接屏蔽就好 

  public QSTile createTile(String tileSpec) {
        /// M: Add extra tiles in quicksetting @{
        Context context = mHost.getContext();
        IQuickSettingsPlugin quickSettingsPlugin = OpSystemUICustomizationFactoryBase
                .getOpFactory(context).makeQuickSettings(context);
        /// @}
        if (tileSpec.equals("wifi")) return new WifiTile(mHost); //wifi
        else if (tileSpec.equals("bt")) return new BluetoothTile(mHost);//蓝牙
        else if (tileSpec.equals("cell")) return new CellularTile(mHost);//移动数据
        /**
         * 屏蔽状态栏功能  wanchengguo 20190527 begin
         * 
         */
       // else if (tileSpec.equals("dnd")) return new DndTile(mHost);
       // else if (tileSpec.equals("inversion")) return new ColorInversionTile(mHost);
        //else if (tileSpec.equals("airplane")) return new AirplaneModeTile(mHost);//飞行模式
        //else if (tileSpec.equals("work")) return new WorkModeTile(mHost);
        else if (tileSpec.equals("rotation")) return new RotationLockTile(mHost);//屏幕旋转 
        else if (tileSpec.equals("flashlight")) return new FlashlightTile(mHost);//手电筒
        else if (tileSpec.equals("location")) return new LocationTile(mHost);//位置信息
        //else if (tileSpec.equals("cast")) return new CastTile(mHost);
       // else if (tileSpec.equals("hotspot")) return new HotspotTile(mHost);
        //else if (tileSpec.equals("user")) return new UserTile(mHost);
        //else if (tileSpec.equals("battery")) return new BatterySaverTile(mHost);//省电模式 
       // else if (tileSpec.equals("saver")) return new DataSaverTile(mHost);
       // else if (tileSpec.equals("night")) return new NightDisplayTile(mHost);
       // else if (tileSpec.equals("nfc")) return new NfcTile(mHost);
        /// M: Customize the quick settings tiles for operator. @{
        /*else if (tileSpec.equals("dataconnection") && !SIMHelper.isWifiOnlyDevice())
            return new MobileDataTile(mHost);
       else if (tileSpec.equals("simdataconnection") && !SIMHelper.isWifiOnlyDevice() &&
                quickSettingsPlugin.customizeAddQSTile(new SimDataConnectionTile(mHost)) != null) {
            return (SimDataConnectionTile) quickSettingsPlugin.customizeAddQSTile(
                    new SimDataConnectionTile(mHost));
        } else if (tileSpec.equals("dulsimsettings") && !SIMHelper.isWifiOnlyDevice() &&
                quickSettingsPlugin.customizeAddQSTile(new DualSimSettingsTile(mHost)) != null) {
            return (DualSimSettingsTile) quickSettingsPlugin.customizeAddQSTile(
                    new DualSimSettingsTile(mHost));
        } */else if (tileSpec.equals("apnsettings") && !SIMHelper.isWifiOnlyDevice() &&
                quickSettingsPlugin.customizeAddQSTile(new ApnSettingsTile(mHost)) != null) {//设置
            return (ApnSettingsTile) quickSettingsPlugin.customizeAddQSTile(
                    new ApnSettingsTile(mHost));
        }
        //*/ freeme.gouzhouping, 20180120. FreemeAppTheme, add extra tiles.
        /*else if (tileSpec.equals("supershot")) {//超级截屏
            return new com.freeme.systemui.qs.tiles.FreemeSuperShot(mHost);
        }*/
        /**
         * 屏蔽状态栏功能  wanchengguo 20190527 end
         * 
         */
        else if (tileSpec.equals("audioprofile")) {//声音
            return new com.freeme.systemui.qs.tiles.FreemeAudioProfile(mHost);
        }
        //*/
        /// @}
        // Intent tiles.
        else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(mHost, tileSpec);
        else if (tileSpec.startsWith(CustomTile.PREFIX)) return CustomTile.create(mHost, tileSpec);
        else {
            Log.w(TAG, "Bad tile spec: " + tileSpec);
            return null;
        }
    }

2.显示两行三列还是两行四列:

由SystemUI\src\com\android\systemui\qs\PagedTileLayout.java中决定:详见如下:

 public static class TilePage extends TileLayout {
        private int mMaxRows = 3;//定义下拉栏行数的地方 wanchengguo 20190618


        public TilePage(Context context, AttributeSet attrs) {
            super(context, attrs);
            updateResources();
        }

        @Override
        public boolean updateResources() {
            final int rows = getRows();
            boolean changed = rows != mMaxRows;
            if (changed) {
                mMaxRows = rows;
                requestLayout();
            }
            return super.updateResources() || changed;
        }

        private int getRows() {
            final Resources res = getContext().getResources();
            if (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                return res.getInteger(R.integer.quick_settings_num_rows_portrait);
            }
            return Math.max(1, res.getInteger(R.integer.quick_settings_num_rows));
        }

        public void setMaxRows(int maxRows) {
            mMaxRows = maxRows;
        }

        public boolean isFull() {
            return mRecords.size() >= mColumns * mMaxRows;//mColumns决定列数,这个是在哪个地方来的
        }
    }

 根据代码可知mColumns是在TileLayout.java里定义的;具体方法如下:

public boolean updateResources() {
    final Resources res = mContext.getResources();
    final int columns = Math.max(1, res.getInteger(R.integer.quick_settings_num_columns));
    mCellHeight = mContext.getResources().getDimensionPixelSize(R.dimen.qs_tile_height);
    mCellMargin = res.getDimensionPixelSize(R.dimen.qs_tile_margin);
    mCellMarginTop = res.getDimensionPixelSize(R.dimen.qs_tile_margin_top);
    if (mColumns != columns) {
        mColumns = columns;
        requestLayout();
        return true;
    }
    return false;
}

所以列数只需要修改quick_settings_num_columns 即可

3.将亮度调节放在Viewpage的下面

修改SystemUI\src\com\android\systemui\qs\QSPanel.java 

 public QSPanel(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext = context;

        setOrientation(VERTICAL);
/**
 * 将亮度调节放在最末尾 20190618 begin wanchengguo
 */
       /* mBrightnessView = LayoutInflater.from(context).inflate(
                R.layout.quick_settings_brightness_dialog, this, false);
        addView(mBrightnessView);*/

        // M: @ {
        mQuickSettingsExt = OpSystemUICustomizationFactoryBase
                .getOpFactory(context).makeQuickSettings(context);
        if (mQuickSettingsExt != null) {
            mQuickSettingsExt.addOpViews(this);
        }
        // @ }

        setupTileLayout();

        mPageIndicator = LayoutInflater.from(context).inflate(
                R.layout.qs_page_indicator, this, false);
        addView(mPageIndicator);
        mBrightnessView = LayoutInflater.from(context).inflate(
                R.layout.quick_settings_brightness_dialog, this, false);
        addView(mBrightnessView);
        /**
         * 将亮度调节放在最末尾 20190618 end wanchengguo
         */
        if (mTileLayout instanceof PagedTileLayout) {
            ((PagedTileLayout) mTileLayout).setPageIndicator((PageIndicator) mPageIndicator);
        }

        addDivider();

        mFooter = new QSSecurityFooter(this, context);
        addView(mFooter.getView());

        updateResources();

        mBrightnessController = new BrightnessController(getContext(),
                findViewById(R.id.brightness_icon),
                findViewById(R.id.brightness_slider));
    }

你可能感兴趣的:(系统源码)