diff options
author | Scott Warner <Tortel1210@gmail.com> | 2015-11-29 10:47:48 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-11-30 10:08:58 -0800 |
commit | b6097111f46ef200533fa9d5e51324530287ce93 (patch) | |
tree | 824e2c62747206cde231efd1087f364f76dc7299 | |
parent | e4c0797ac0dc5ee3fe9abb34e5054390954061d0 (diff) | |
download | frameworks_base-b6097111f46ef200533fa9d5e51324530287ce93.zip frameworks_base-b6097111f46ef200533fa9d5e51324530287ce93.tar.gz frameworks_base-b6097111f46ef200533fa9d5e51324530287ce93.tar.bz2 |
QuickSettings: Add long click support for all tiles
* Add actions for the default tiles
* Includes changes from :
I47a6eea35a4d427c70fe3a6dee3c0d198a431082
I1eb3c6d0933150084c3800f93b97531f1e51fa18
Change-Id: I327eca67a29cee2d1c839b83cc7067133b86dc63
10 files changed, 118 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java index 49f8d1c..bf28dbf 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java @@ -1,5 +1,6 @@ /* * 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); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java index 4502ccc..5cc3f3f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BluetoothTile.java @@ -1,5 +1,6 @@ /* * 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 BluetoothTile extends QSTile<QSTile.BooleanState> { } @Override + protected void handleLongClick() { + mHost.startActivityDismissingKeyguard(BLUETOOTH_SETTINGS); + } + + @Override protected void handleUpdateState(BooleanState state, Object arg) { final boolean supported = mController.isBluetoothSupported(); final boolean enabled = mController.isBluetoothEnabled(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java index 61695b2..75503f6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CastTile.java @@ -1,5 +1,6 @@ /* * 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. @@ -91,6 +92,11 @@ public class CastTile extends QSTile<QSTile.BooleanState> { } @Override + protected void handleLongClick() { + mHost.startActivityDismissingKeyguard(CAST_SETTINGS); + } + + @Override protected void handleUpdateState(BooleanState state, Object arg) { state.visible = !mKeyguard.isSecure() || !mKeyguard.isShowing() || mKeyguard.canSkipBouncer(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java index fb46729..91e92c8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java @@ -1,5 +1,6 @@ /* * 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 diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java index c6fc6ff..04cc5dc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java @@ -1,5 +1,6 @@ /* * 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,15 +101,18 @@ 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); - mUsageTracker.showResetConfirmation(title, new Runnable() { - @Override - public void run() { - refreshState(); - } - }); + 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() { + refreshState(); + } + }); + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java index 781ab1c..ccf9887 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2015 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. @@ -121,6 +122,11 @@ public class DndTile extends QSTile<QSTile.BooleanState> { } @Override + public void handleLongClick() { + mHost.startActivityDismissingKeyguard(ZEN_SETTINGS); + } + + @Override protected void handleUpdateState(BooleanState state, Object arg) { final int zen = arg instanceof Integer ? (Integer) arg : mController.getZen(); final boolean newValue = zen != Global.ZEN_MODE_OFF; diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 7b83e6a..4173efc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -1,5 +1,6 @@ /* * 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. @@ -17,6 +18,7 @@ package com.android.systemui.qs.tiles; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -29,6 +31,10 @@ import com.android.systemui.statusbar.policy.HotspotController; /** Quick settings tile: Hotspot **/ public class HotspotTile extends QSTile<QSTile.BooleanState> { + + private static final Intent TETHER_SETTINGS = new Intent().setComponent(new ComponentName( + "com.android.settings", "com.android.settings.TetherSettings")); + private final AnimationIcon mEnable = new AnimationIcon(R.drawable.ic_hotspot_enable_animation); private final AnimationIcon mDisable = @@ -75,15 +81,18 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { @Override protected void handleLongClick() { - if (mState.value) return; // don't allow usage reset if hotspot is active - final String title = mContext.getString(R.string.quick_settings_reset_confirmation_title, - mState.label); - mUsageTracker.showResetConfirmation(title, new Runnable() { - @Override - public void run() { - refreshState(); - } - }); + if (mState.value) { + mHost.startActivityDismissingKeyguard(TETHER_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() { + refreshState(); + } + }); + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java index e6fade4..347d079 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java @@ -1,5 +1,6 @@ /* * 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. @@ -17,6 +18,9 @@ package com.android.systemui.qs.tiles; import com.android.internal.logging.MetricsLogger; +import android.content.Intent; +import android.provider.Settings; + import com.android.systemui.R; import com.android.systemui.qs.QSTile; import com.android.systemui.statusbar.policy.KeyguardMonitor; @@ -26,6 +30,9 @@ import com.android.systemui.statusbar.policy.LocationController.LocationSettings /** Quick settings tile: Location **/ public class LocationTile extends QSTile<QSTile.BooleanState> { + private static final Intent LOCATION_SETTINGS = new Intent( + Settings.ACTION_LOCATION_SOURCE_SETTINGS); + private final AnimationIcon mEnable = new AnimationIcon(R.drawable.ic_signal_location_enable_animation); private final AnimationIcon mDisable = @@ -67,6 +74,11 @@ public class LocationTile extends QSTile<QSTile.BooleanState> { } @Override + protected void handleLongClick() { + mHost.startActivityDismissingKeyguard(LOCATION_SETTINGS); + } + + @Override protected void handleUpdateState(BooleanState state, Object arg) { final boolean locationEnabled = mController.isLocationEnabled(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java index 1a26a4d..f074d9d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java @@ -1,5 +1,6 @@ /* * 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,7 @@ package com.android.systemui.qs.tiles; +import android.content.Intent; import android.content.res.Configuration; import com.android.internal.logging.MetricsLogger; @@ -26,6 +28,10 @@ import com.android.systemui.statusbar.policy.RotationLockController.RotationLock /** Quick settings tile: Rotation **/ public class RotationLockTile extends QSTile<QSTile.BooleanState> { + + private static final Intent DISPLAY_ROTATION_SETTINGS = + new Intent("android.settings.DISPLAY_ROTATION_SETTINGS"); + private final AnimationIcon mPortraitToAuto = new AnimationIcon(R.drawable.ic_portrait_to_auto_rotate_animation); private final AnimationIcon mAutoToPortrait @@ -67,6 +73,11 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> { } @Override + protected void handleLongClick() { + mHost.startActivityDismissingKeyguard(DISPLAY_ROTATION_SETTINGS); + } + + @Override protected void handleUpdateState(BooleanState state, Object arg) { if (mController == null) return; final boolean rotationLocked = arg != null ? ((UserBoolean) arg).value diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java index 30ebacd..d90072e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java @@ -1,5 +1,6 @@ /* * 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. @@ -116,6 +117,11 @@ public class WifiTile extends QSTile<QSTile.SignalState> { } @Override + protected void handleLongClick() { + mHost.startActivityDismissingKeyguard(WIFI_SETTINGS); + } + + @Override protected void handleUpdateState(SignalState state, Object arg) { state.visible = true; if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg); |