Merge "QS: Use current tile state when removing custom tiles" into nyc-dev
This commit is contained in:
@@ -54,7 +54,7 @@ public class TileQueryHelper {
|
|||||||
// TODO: Live?
|
// TODO: Live?
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSystemTiles(QSTileHost host) {
|
private void addSystemTiles(final QSTileHost host) {
|
||||||
String possible = mContext.getString(R.string.quick_settings_tiles_default)
|
String possible = mContext.getString(R.string.quick_settings_tiles_default)
|
||||||
+ ",hotspot,inversion,saver,work,cast,night";
|
+ ",hotspot,inversion,saver,work,cast,night";
|
||||||
String[] possibleTiles = possible.split(",");
|
String[] possibleTiles = possible.split(",");
|
||||||
@@ -93,7 +93,7 @@ public class TileQueryHelper {
|
|||||||
mainHandler.post(new Runnable() {
|
mainHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
new QueryTilesTask().execute();
|
new QueryTilesTask().execute(host.getTiles());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -133,9 +133,10 @@ public class TileQueryHelper {
|
|||||||
public boolean isSystem;
|
public boolean isSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class QueryTilesTask extends AsyncTask<Void, Void, Collection<TileInfo>> {
|
private class QueryTilesTask extends
|
||||||
|
AsyncTask<Collection<QSTile<?>>, Void, Collection<TileInfo>> {
|
||||||
@Override
|
@Override
|
||||||
protected Collection<TileInfo> doInBackground(Void... params) {
|
protected Collection<TileInfo> doInBackground(Collection<QSTile<?>>... params) {
|
||||||
List<TileInfo> tiles = new ArrayList<>();
|
List<TileInfo> tiles = new ArrayList<>();
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
List<ResolveInfo> services = pm.queryIntentServicesAsUser(
|
List<ResolveInfo> services = pm.queryIntentServicesAsUser(
|
||||||
@@ -143,7 +144,13 @@ public class TileQueryHelper {
|
|||||||
for (ResolveInfo info : services) {
|
for (ResolveInfo info : services) {
|
||||||
String packageName = info.serviceInfo.packageName;
|
String packageName = info.serviceInfo.packageName;
|
||||||
ComponentName componentName = new ComponentName(packageName, info.serviceInfo.name);
|
ComponentName componentName = new ComponentName(packageName, info.serviceInfo.name);
|
||||||
|
final CharSequence appLabel = info.serviceInfo.applicationInfo.loadLabel(pm);
|
||||||
String spec = CustomTile.toSpec(componentName);
|
String spec = CustomTile.toSpec(componentName);
|
||||||
|
State state = getState(params[0], spec);
|
||||||
|
if (state != null) {
|
||||||
|
addTile(spec, appLabel, state, false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (info.serviceInfo.icon == 0) {
|
if (info.serviceInfo.icon == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -157,12 +164,22 @@ public class TileQueryHelper {
|
|||||||
icon.mutate();
|
icon.mutate();
|
||||||
icon.setTint(mContext.getColor(android.R.color.white));
|
icon.setTint(mContext.getColor(android.R.color.white));
|
||||||
CharSequence label = info.serviceInfo.loadLabel(pm);
|
CharSequence label = info.serviceInfo.loadLabel(pm);
|
||||||
final CharSequence appLabel = info.serviceInfo.applicationInfo.loadLabel(pm);
|
|
||||||
addTile(spec, icon, label != null ? label.toString() : "null", appLabel, mContext);
|
addTile(spec, icon, label != null ? label.toString() : "null", appLabel, mContext);
|
||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private State getState(Collection<QSTile<?>> tiles, String spec) {
|
||||||
|
for (QSTile<?> tile : tiles) {
|
||||||
|
if (spec.equals(tile.getTileSpec())) {
|
||||||
|
final QSTile.State state = tile.newTileState();
|
||||||
|
tile.getState().copyTo(state);
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Collection<TileInfo> result) {
|
protected void onPostExecute(Collection<TileInfo> result) {
|
||||||
mTiles.addAll(result);
|
mTiles.addAll(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user