Merge changes Iaf1ee1e6,I861cb65d into nyc-dev
am: d2308771f0
* commit 'd2308771f011c6277fc2e5e2e5f78e35d2cf22e6':
Add TileService settings API
Add QS long-press -> Settings
This commit is contained in:
@@ -34579,6 +34579,7 @@ package android.service.quicksettings {
|
||||
method public final void startActivityAndCollapse(android.content.Intent);
|
||||
method public final void unlockAndRun(java.lang.Runnable);
|
||||
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
|
||||
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
|
||||
field public static final int TILE_MODE_ACTIVE = 2; // 0x2
|
||||
field public static final int TILE_MODE_PASSIVE = 1; // 0x1
|
||||
}
|
||||
|
||||
@@ -37134,6 +37134,7 @@ package android.service.quicksettings {
|
||||
method public final void startActivityAndCollapse(android.content.Intent);
|
||||
method public final void unlockAndRun(java.lang.Runnable);
|
||||
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
|
||||
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
|
||||
field public static final int TILE_MODE_ACTIVE = 2; // 0x2
|
||||
field public static final int TILE_MODE_PASSIVE = 1; // 0x1
|
||||
}
|
||||
|
||||
@@ -34594,6 +34594,7 @@ package android.service.quicksettings {
|
||||
method public final void startActivityAndCollapse(android.content.Intent);
|
||||
method public final void unlockAndRun(java.lang.Runnable);
|
||||
field public static final java.lang.String ACTION_QS_TILE = "android.service.quicksettings.action.QS_TILE";
|
||||
field public static final java.lang.String ACTION_QS_TILE_PREFERENCES = "android.service.quicksettings.action.QS_TILE_PREFERENCES";
|
||||
field public static final int TILE_MODE_ACTIVE = 2; // 0x2
|
||||
field public static final int TILE_MODE_PASSIVE = 1; // 0x1
|
||||
}
|
||||
|
||||
@@ -113,6 +113,21 @@ public final class Settings {
|
||||
public static final String ACTION_LOCATION_SOURCE_SETTINGS =
|
||||
"android.settings.LOCATION_SOURCE_SETTINGS";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of users.
|
||||
* <p>
|
||||
* In some cases, a matching Activity may not exist, so ensure you
|
||||
* safeguard against this.
|
||||
* <p>
|
||||
* Input: Nothing.
|
||||
* <p>
|
||||
* Output: Nothing.
|
||||
* @hide
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||
public static final String ACTION_USER_SETTINGS =
|
||||
"android.settings.USER_SETTINGS";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of wireless controls
|
||||
* such as Wi-Fi, Bluetooth and Mobile networks.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
package android.service.quicksettings;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.Dialog;
|
||||
import android.app.Service;
|
||||
@@ -73,6 +75,14 @@ import android.view.WindowManager;
|
||||
*/
|
||||
public class TileService extends Service {
|
||||
|
||||
/**
|
||||
* An activity that provides a user interface for adjusting TileService preferences.
|
||||
* Optional but recommended for apps that implement a TileService.
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
|
||||
public static final String ACTION_QS_TILE_PREFERENCES
|
||||
= "android.service.quicksettings.action.QS_TILE_PREFERENCES";
|
||||
|
||||
/**
|
||||
* Action that identifies a Service as being a TileService.
|
||||
*/
|
||||
|
||||
@@ -329,7 +329,8 @@ public class QSPanel extends FrameLayout implements Tunable {
|
||||
final View.OnLongClickListener longClick = new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
r.tile.longClick();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
r.tileView.init(click, longClick);
|
||||
|
||||
@@ -212,9 +212,11 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
}
|
||||
|
||||
protected void handleLongClick() {
|
||||
// optional
|
||||
mHost.startActivityDismissingKeyguard(getLongClickIntent());
|
||||
}
|
||||
|
||||
public abstract Intent getLongClickIntent();
|
||||
|
||||
protected void handleClearState() {
|
||||
mTmpState = newTileState();
|
||||
mState = newTileState();
|
||||
|
||||
@@ -77,6 +77,7 @@ public class QSTileBaseView extends LinearLayout {
|
||||
public void init(OnClickListener click, OnLongClickListener longClick) {
|
||||
setClickable(true);
|
||||
setOnClickListener(click);
|
||||
setOnLongClickListener(longClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,11 +84,6 @@ public class QSTileView extends QSTileBaseView {
|
||||
addView(view);
|
||||
}
|
||||
|
||||
public void init(OnClickListener clickPrimary, OnLongClickListener longClick) {
|
||||
setOnClickListener(clickPrimary);
|
||||
setOnLongClickListener(longClick);
|
||||
}
|
||||
|
||||
protected void handleStateChanged(QSTile.State state) {
|
||||
super.handleStateChanged(state);
|
||||
mLabel.setText(state.label);
|
||||
|
||||
@@ -15,13 +15,18 @@
|
||||
*/
|
||||
package com.android.systemui.qs.external;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
import android.service.quicksettings.IQSTileService;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
@@ -156,8 +161,22 @@ public class CustomTile extends QSTile<QSTile.State> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleUserSwitch(int newUserId) {
|
||||
super.handleUserSwitch(newUserId);
|
||||
public Intent getLongClickIntent() {
|
||||
Intent i = new Intent(TileService.ACTION_QS_TILE_PREFERENCES);
|
||||
i.setPackage(mComponent.getPackageName());
|
||||
i = resolveIntent(i);
|
||||
if (i != null) {
|
||||
return i;
|
||||
}
|
||||
return new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(
|
||||
Uri.fromParts("package", mComponent.getPackageName(), null));
|
||||
}
|
||||
|
||||
private Intent resolveIntent(Intent i) {
|
||||
ResolveInfo result = mContext.getPackageManager().resolveActivityAsUser(i, 0,
|
||||
ActivityManager.getCurrentUser());
|
||||
return result != null ? new Intent(TileService.ACTION_QS_TILE_PREFERENCES)
|
||||
.setClassName(result.activityInfo.packageName, result.activityInfo.name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,10 +202,6 @@ public class CustomTile extends QSTile<QSTile.State> {
|
||||
MetricsLogger.action(mContext, getMetricsCategory(), mComponent.getPackageName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleLongClick() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(State state, Object arg) {
|
||||
Drawable drawable = mTile.getIcon().loadDrawable(mContext);
|
||||
|
||||
@@ -21,6 +21,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;
|
||||
@@ -67,6 +68,11 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
|
||||
mgr.setAirplaneMode(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleUpdateState(BooleanState state, Object arg) {
|
||||
final int value = arg instanceof Integer ? (Integer)arg : mSetting.getValue();
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
@@ -90,6 +91,11 @@ public class BatteryTile extends QSTile<QSTile.State> implements BatteryControll
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
showDetail(true);
|
||||
|
||||
@@ -77,6 +77,11 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
|
||||
mController.setBluetoothEnabled(!isEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (!mController.canConfigBluetooth()) {
|
||||
|
||||
@@ -85,6 +85,11 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
|
||||
mController.setCurrentUserId(newUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_CAST_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (mKeyguard.isSecure() && !mKeyguard.canSkipBouncer()) {
|
||||
|
||||
@@ -37,7 +37,7 @@ 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(
|
||||
static final Intent CELLULAR_SETTINGS = new Intent().setComponent(new ComponentName(
|
||||
"com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
|
||||
|
||||
private final NetworkController mController;
|
||||
@@ -77,6 +77,11 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
|
||||
return new SignalTileView(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return CELLULAR_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
MetricsLogger.action(mContext, getMetricsCategory());
|
||||
|
||||
@@ -16,6 +16,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;
|
||||
@@ -69,6 +71,11 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
|
||||
handleRefreshState(mSetting.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSTile;
|
||||
@@ -43,6 +44,11 @@ public class DataSaverTile extends QSTile<QSTile.BooleanState> implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return CellularTile.CELLULAR_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
mState.value = !mDataSaverController.isDataSaverEnabled();
|
||||
|
||||
@@ -100,6 +100,11 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
|
||||
return new BooleanState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return ZEN_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClick() {
|
||||
if (mController.isVolumeRestricted()) {
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.provider.MediaStore;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
@@ -59,6 +61,11 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
|
||||
protected void handleUserSwitch(int newUserId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (ActivityManager.isUserAMonkey()) {
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.UserManager;
|
||||
|
||||
import android.provider.Settings;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
@@ -57,6 +59,11 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_WIRELESS_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
final boolean isEnabled = (Boolean) mState.value;
|
||||
|
||||
@@ -91,6 +91,11 @@ public class IntentTile extends QSTile<QSTile.State> {
|
||||
sendIntent("click", mOnClick, mOnClickUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleLongClick() {
|
||||
sendIntent("long-click", mOnLongClick, mOnLongClickUri);
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.UserManager;
|
||||
|
||||
import android.provider.Settings;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
@@ -60,6 +62,11 @@ public class LocationTile extends QSTile<QSTile.BooleanState> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (mKeyguard.isSecure() && mKeyguard.isShowing()) {
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import android.provider.Settings;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
@@ -59,6 +61,11 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_DISPLAY_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
if (mController == null) return;
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.provider.Settings;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
@@ -41,6 +43,11 @@ public class UserTile extends QSTile<QSTile.State> implements UserInfoController
|
||||
return new QSTile.State();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_USER_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
showDetail(true);
|
||||
|
||||
@@ -92,6 +92,11 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
|
||||
return new SignalTileView(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return WIFI_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleSecondaryClick() {
|
||||
// Secondary clicks are header clicks, just toggle.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.qs.tiles;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.systemui.R;
|
||||
@@ -51,6 +53,11 @@ public class WorkModeTile extends QSTile<QSTile.BooleanState> implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(Settings.ACTION_SYNC_SETTINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClick() {
|
||||
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
|
||||
|
||||
@@ -688,7 +688,7 @@ public class UserSwitcherController {
|
||||
}
|
||||
|
||||
public final QSTile.DetailAdapter userDetailAdapter = new QSTile.DetailAdapter() {
|
||||
private final Intent USER_SETTINGS_INTENT = new Intent("android.settings.USER_SETTINGS");
|
||||
private final Intent USER_SETTINGS_INTENT = new Intent(Settings.ACTION_USER_SETTINGS);
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
|
||||
@@ -42,6 +42,9 @@ public class NightModeFragment extends PreferenceFragment implements Tunable,
|
||||
Listener, OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "NightModeFragment";
|
||||
|
||||
public static final String EXTRA_SHOW_NIGHT_MODE = "show_night_mode";
|
||||
|
||||
private static final CharSequence KEY_AUTO = "auto";
|
||||
private static final CharSequence KEY_DARK_THEME = "dark_theme";
|
||||
private static final CharSequence KEY_ADJUST_TINT = "adjust_tint";
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.systemui.tuner;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
@@ -59,6 +60,12 @@ public class NightModeTile extends QSTile<QSTile.State> implements NightModeCont
|
||||
return new State();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getLongClickIntent() {
|
||||
return new Intent(mContext, TunerActivity.class)
|
||||
.putExtra(NightModeFragment.EXTRA_SHOW_NIGHT_MODE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClick() {
|
||||
mNightModeController.setNightMode(!mNightModeController.isEnabled());
|
||||
|
||||
@@ -36,7 +36,10 @@ public class TunerActivity extends SettingsDrawerActivity implements
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (getFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
|
||||
getFragmentManager().beginTransaction().replace(R.id.content_frame, new TunerFragment(),
|
||||
boolean showNightMode = getIntent().getBooleanExtra(
|
||||
NightModeFragment.EXTRA_SHOW_NIGHT_MODE, false);
|
||||
getFragmentManager().beginTransaction().replace(R.id.content_frame,
|
||||
showNightMode ? new NightModeFragment() : new TunerFragment(),
|
||||
TAG_TUNER).commit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user