android p状态栏,插入sim卡,关闭数据流量,状态栏卡图标右下角有X图标

需要修改的文件
SettingsLib 模块下的SignalDrawable.java

   @Override
    public void draw(@NonNull Canvas canvas) {
        final float width = getBounds().width();
        final float height = getBounds().height();

        boolean isRtl = getLayoutDirection() == LayoutDirection.RTL;
        if (isRtl) {
            canvas.save();
            // Mirror the drawable
            canvas.translate(width, 0);
            canvas.scale(-1.0f, 1.0f);
        }
        mFullPath.reset();
        mFullPath.setFillType(FillType.WINDING);

        final float padding = Math.round(PAD * width);
        final float cornerRadius = RADIUS_RATIO * height;
        // Offset from circle where the hypotenuse meets the circle
        final float diagOffset = DIAG_OFFSET_MULTIPLIER * cornerRadius;

        // 1 - Bottom right, above corner
        mFullPath.moveTo(width - padding, height - padding - cornerRadius);
        // 2 - Line to top right, below corner
        mFullPath.lineTo(width - padding, padding + cornerRadius + mAppliedCornerInset);
        // 3 - Arc to top right, on hypotenuse
        mFullPath.arcTo(
                width - padding - (2 * cornerRadius),
                padding + mAppliedCornerInset,
                width - padding,
                padding + mAppliedCornerInset + (2 * cornerRadius),
                0.f, -135.f, false
        );
        // 4 - Line to bottom left, on hypotenuse
        mFullPath.lineTo(padding + mAppliedCornerInset + cornerRadius - diagOffset,
                height - padding - cornerRadius - diagOffset);
        // 5 - Arc to bottom left, on leg
        mFullPath.arcTo(
                padding + mAppliedCornerInset,
                height - padding - (2 * cornerRadius),
                padding + mAppliedCornerInset + ( 2 * cornerRadius),
                height - padding,
                -135.f, -135.f, false
        );
        // 6 - Line to bottom rght, before corner
        mFullPath.lineTo(width - padding - cornerRadius, height - padding);
        // 7 - Arc to beginning (bottom right, above corner)
        mFullPath.arcTo(
                width - padding - (2 * cornerRadius),
                height - padding - (2 * cornerRadius),
                width - padding,
                height - padding,
                90.f, -90.f, false
        );
        Log.d(TAG,"wjc mState = "+mState);
		
        if (mState == STATE_CARRIER_CHANGE) {
            float cutWidth = (DOT_CUT_WIDTH * width);
            float cutHeight = (DOT_CUT_HEIGHT * width);
            float dotSize = (DOT_SIZE * height);
            float dotPadding = (DOT_PADDING * height);

            mFullPath.moveTo(width - padding, height - padding);
            mFullPath.rLineTo(-cutWidth, 0);
            mFullPath.rLineTo(0, -cutHeight);
            mFullPath.rLineTo(cutWidth, 0);
            mFullPath.rLineTo(0, cutHeight);
            float dotSpacing = dotPadding * 2 + dotSize;
            float x = width - padding - dotSize;
            float y = height - padding - dotSize;
            mForegroundPath.reset();
            drawDot(mFullPath, mForegroundPath, x, y, dotSize, 2);
            drawDot(mFullPath, mForegroundPath, x - dotSpacing, y, dotSize, 1);
            drawDot(mFullPath, mForegroundPath, x - dotSpacing * 2, y, dotSize, 0);
        } else if (mState == STATE_CUT) {
/*            float cut = (CUT_OUT * width);
            mFullPath.moveTo(width - padding, height - padding);
            mFullPath.rLineTo(-cut, 0);
            mFullPath.rLineTo(0, -cut);
            mFullPath.rLineTo(cut, 0);
            mFullPath.rLineTo(0, cut);*/
        }

        if (mState == STATE_EMPTY) {
            // Where the corners would be if this were a real triangle
            mVirtualTop.set(
                    width - padding,
                    (padding + cornerRadius + mAppliedCornerInset) - (INV_TAN * cornerRadius));
            mVirtualLeft.set(
                    (padding + cornerRadius + mAppliedCornerInset) - (INV_TAN * cornerRadius),
                    height - padding);

            final float cutWidth = CUT_WIDTH_DP * height;
            final float cutDiagInset = cutWidth * INV_TAN;

            // Cut out a smaller triangle from the center of mFullPath
            mCutPath.reset();
            mCutPath.setFillType(FillType.WINDING);
            mCutPath.moveTo(width - padding - cutWidth, height - padding - cutWidth);
            mCutPath.lineTo(width - padding - cutWidth, mVirtualTop.y + cutDiagInset);
            mCutPath.lineTo(mVirtualLeft.x + cutDiagInset, height - padding - cutWidth);
            mCutPath.lineTo(width - padding - cutWidth, height - padding - cutWidth);

            // Draw empty state as only background
            mForegroundPath.reset();
            mFullPath.op(mCutPath, Path.Op.DIFFERENCE);
        } else if (mState == STATE_AIRPLANE) {
            // Airplane mode is slashed, fully drawn background
            mForegroundPath.reset();
            mSlash.draw((int) height, (int) width, canvas, mPaint);
        } else if (mState != STATE_CARRIER_CHANGE) {
            /*mForegroundPath.reset();
            int sigWidth = Math.round(calcFit(mLevel / (mNumLevels - 1)) * (width - 2 * padding));
            mForegroundPath.addRect(padding, padding, padding + sigWidth, height - padding,
                    Direction.CW);
            mForegroundPath.op(mFullPath, Op.INTERSECT);*/
        }

        canvas.drawPath(mFullPath, mPaint);
        canvas.drawPath(mForegroundPath, mForegroundPaint);
        if (mState == STATE_CUT) {
            mXPath.reset();
            mXPath.moveTo(X_PATH[0][0] * width, X_PATH[0][1] * height);
            for (int i = 1; i < X_PATH.length; i++) {
                mXPath.rLineTo(X_PATH[i][0] * width, X_PATH[i][1] * height);
            }
            canvas.drawPath(mXPath, mForegroundPaint);
        }
        if (isRtl) {
            canvas.restore();
        }
    }

上述代码块中的

        } else if (mState == STATE_CUT) {
            float cut = (CUT_OUT * width);
            mFullPath.moveTo(width - padding, height - padding);
            mFullPath.rLineTo(-cut, 0);
            mFullPath.rLineTo(0, -cut);
            mFullPath.rLineTo(cut, 0);
            mFullPath.rLineTo(0, cut);
        }
        if (mState == STATE_CUT) {
            mXPath.reset();
            mXPath.moveTo(X_PATH[0][0] * width, X_PATH[0][1] * height);
            for (int i = 1; i < X_PATH.length; i++) {
                mXPath.rLineTo(X_PATH[i][0] * width, X_PATH[i][1] * height);
            }
            canvas.drawPath(mXPath, mForegroundPaint);
        }        

注释调就可以了

你可能感兴趣的:(Android)