修改状态栏快捷方式跳转问题

状态栏快捷方式具体代码位置在SystemUI/src/com/android/systemui/qs/tiles这个目录下
我们以飞行模式AirplaneModeTile.java为例展开说明

首先是单点效果:

    @Override
    public void handleClick(@Nullable View view) {
        boolean airplaneModeEnabled = mState.value;
       Log.d("ycxq", "airplaneMode = "+!airplaneModeEnabled);
       Intent intent = new Intent();
       intent.setAction("com.ycxq.device.function.state");
       intent.putExtra("airplane",!airplaneModeEnabled);
       mContext.sendBroadcast(intent); 

        MetricsLogger.action(mContext, getMetricsCategory(), !airplaneModeEnabled);
        if (!airplaneModeEnabled && TelephonyProperties.in_ecm_mode().orElse(false)) {
            mActivityStarter.postStartActivityDismissingKeyguard(
                    new Intent(TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS), 0);
            if (DEBUG) {
                Log.w(TAG, "AirplaneModeTile click not work!");
            }
            return;
        }
        setEnabled(!airplaneModeEnabled);
    }

可以看到是通过发送广播的形式去打开或关闭飞行模式并记录更新飞行模式状态。

接下来看长按处理逻辑,有一个可以重写的方法

@Override
protected void handleLongClick(@Nullable View view)

这个方法如果没有重写,长按则直接调用父类的逻辑:

   protected void handleLongClick(@Nullable View view) {
        ActivityLaunchAnimator.Controller animationController =
                view != null ? ActivityLaunchAnimator.Controller.fromView(view,
                        InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_QS_TILE) : null;
        mActivityStarter.postStartActivityDismissingKeyguard(getLongClickIntent(), 0,
                animationController);
    }

可以看到,这里将做一个跳转,跳转的Action是通过子类getLongClickIntent()得到的,查看子类这个方法:
 

@Override
public Intent getLongClickIntent() {
    return new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
}

那跳转的逻辑就一目了然了。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值