Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6097111 authored by Scott Warner's avatar Scott Warner Committed by Gerrit Code Review
Browse files

QuickSettings: Add long click support for all tiles

 * Add actions for the default tiles

 * Includes changes from :
     I47a6eea35a4d427c70fe3a6dee3c0d198a431082
     I1eb3c6d0933150084c3800f93b97531f1e51fa18

Change-Id: I327eca67a29cee2d1c839b83cc7067133b86dc63
parent e4c0797a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.provider.Settings;
import android.provider.Settings.Global;

import com.android.internal.logging.MetricsLogger;
@@ -30,6 +32,9 @@ import com.android.systemui.qs.QSTile;

/** Quick settings tile: Airplane mode **/
public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {

    private static final Intent WIRELESS_SETTINGS = new Intent(Settings.ACTION_WIRELESS_SETTINGS);

    private final AnimationIcon mEnable =
            new AnimationIcon(R.drawable.ic_signal_airplane_enable_animation);
    private final AnimationIcon mDisable =
@@ -62,6 +67,11 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
        mDisable.setAllowAnimation(true);
    }

    @Override
    public void handleLongClick() {
        mHost.startActivityDismissingKeyguard(WIRELESS_SETTINGS);
    }

    private void setEnabled(boolean enabled) {
        final ConnectivityManager mgr =
                (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+6 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -89,6 +90,11 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
        showDetail(true);
    }

    @Override
    protected void handleLongClick() {
        mHost.startActivityDismissingKeyguard(BLUETOOTH_SETTINGS);
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        final boolean supported = mController.isBluetoothSupported();
+6 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -90,6 +91,11 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
        showDetail(true);
    }

    @Override
    protected void handleLongClick() {
        mHost.startActivityDismissingKeyguard(CAST_SETTINGS);
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
        state.visible = !mKeyguard.isSecure() || !mKeyguard.isShowing()
+25 −3
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,12 +40,22 @@ import com.android.systemui.statusbar.policy.SignalCallbackAdapter;

/** Quick settings tile: Cellular **/
public class CellularTile extends QSTile<QSTile.SignalState> {
    private static final Intent CELLULAR_SETTINGS = new Intent().setComponent(new ComponentName(

    private static final Intent DATA_USAGE_SETTINGS = new Intent().setComponent(new ComponentName(
            "com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
    private static final Intent MOBILE_NETWORK_SETTINGS = new Intent(Intent.ACTION_MAIN)
            .setComponent(new ComponentName("com.android.phone",
                    "com.android.phone.MobileNetworkSettings"));
    private static final Intent MOBILE_NETWORK_SETTINGS_MSIM = new Intent(Intent.ACTION_MAIN)
            .setClassName("com.android.phone", "com.android.phone.msim.SelectSubscription")
            .putExtra("PACKAGE", "com.android.phone")
            .putExtra("TARGET_CLASS", "com.android.phone.MobileNetworkSettings")
            .putExtra("TARGET_THEME", "Theme.Material.Settings");

    private final NetworkController mController;
    private final MobileDataController mDataController;
    private final CellularDetailAdapter mDetailAdapter;
    private final TelephonyManager mTelephonyManager;

    private final CellSignalCallback mSignalCallback = new CellSignalCallback();

@@ -52,6 +64,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
        mController = host.getNetworkController();
        mDataController = mController.getMobileDataController();
        mDetailAdapter = new CellularDetailAdapter();
        mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
    }

    @Override
@@ -84,7 +97,16 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
        if (mDataController.isMobileDataSupported()) {
            showDetail(true);
        } else {
            mHost.startActivityDismissingKeyguard(CELLULAR_SETTINGS);
            mHost.startActivityDismissingKeyguard(DATA_USAGE_SETTINGS);
        }
    }

    @Override
    protected void handleLongClick() {
        if (mTelephonyManager.getDefault().getPhoneCount() > 1) {
            mHost.startActivityDismissingKeyguard(MOBILE_NETWORK_SETTINGS_MSIM);
        } else {
            mHost.startActivityDismissingKeyguard(MOBILE_NETWORK_SETTINGS);
        }
    }

@@ -230,7 +252,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {

        @Override
        public Intent getSettingsIntent() {
            return CELLULAR_SETTINGS;
            return DATA_USAGE_SETTINGS;
        }

        @Override
+18 −9
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2015 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -16,6 +17,8 @@

package com.android.systemui.qs.tiles;

import android.content.Intent;
import android.provider.Settings;
import android.provider.Settings.Secure;

import com.android.internal.logging.MetricsLogger;
@@ -28,6 +31,9 @@ import com.android.systemui.qs.UsageTracker;
/** Quick settings tile: Invert colors **/
public class ColorInversionTile extends QSTile<QSTile.BooleanState> {

    private static final Intent ACCESSIBILITY_SETTINGS = new Intent(
            Settings.ACTION_ACCESSIBILITY_SETTINGS);

    private final AnimationIcon mEnable
            = new AnimationIcon(R.drawable.ic_invert_colors_enable_animation);
    private final AnimationIcon mDisable
@@ -95,9 +101,11 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {

    @Override
    protected void handleLongClick() {
        if (mState.value) return;  // don't allow usage reset if inversion is active
        final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title,
                mState.label);
        if (mState.value) {
            mHost.startActivityDismissingKeyguard(ACCESSIBILITY_SETTINGS);
        } else {
            final String title = mContext.getString(
                    R.string.quick_settings_reset_confirmation_title, mState.label);
            mUsageTracker.showResetConfirmation(title, new Runnable() {
                @Override
                public void run() {
@@ -105,6 +113,7 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
                }
            });
        }
    }

    @Override
    protected void handleUpdateState(BooleanState state, Object arg) {
Loading