use of android.service.quicksettings.Tile in project android_frameworks_base by crdroidandroid.
the class TileLifecycleManagerTests method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mThread = new HandlerThread("TestThread");
mThread.start();
mHandler = new Handler(mThread.getLooper());
ComponentName component = new ComponentName(mContext, FakeTileService.class);
mStateManager = new TileLifecycleManager(mHandler, getContext(), Mockito.mock(IQSService.class), new Tile(), new Intent().setComponent(component), new UserHandle(UserHandle.myUserId()));
mCallbacks.clear();
getContext().registerReceiver(mReceiver, new IntentFilter(TILE_UPDATE_BROADCAST));
}
use of android.service.quicksettings.Tile in project android_frameworks_base by AOSPA.
the class QSTileHost method changeTiles.
public void changeTiles(List<String> previousTiles, List<String> newTiles) {
final int NP = previousTiles.size();
final int NA = newTiles.size();
for (int i = 0; i < NP; i++) {
String tileSpec = previousTiles.get(i);
if (!tileSpec.startsWith(CustomTile.PREFIX))
continue;
if (!newTiles.contains(tileSpec)) {
ComponentName component = CustomTile.getComponentFromSpec(tileSpec);
Intent intent = new Intent().setComponent(component);
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(), mContext, mServices, new Tile(), intent, new UserHandle(ActivityManager.getCurrentUser()));
lifecycleManager.onStopListening();
lifecycleManager.onTileRemoved();
TileLifecycleManager.setTileAdded(mContext, component, false);
lifecycleManager.flushMessagesAndUnbind();
}
}
if (DEBUG)
Log.d(TAG, "saveCurrentTiles " + newTiles);
Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING, TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
}
use of android.service.quicksettings.Tile in project NetGuard by M66B.
the class ServiceTileFilter method update.
private void update() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean filter = prefs.getBoolean("filter", false);
Tile tile = getQsTile();
if (tile != null) {
tile.setState(filter ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
}
use of android.service.quicksettings.Tile in project android_frameworks_base by crdroidandroid.
the class QSTileHost method changeTiles.
public void changeTiles(List<String> previousTiles, List<String> newTiles) {
final int NP = previousTiles.size();
final int NA = newTiles.size();
for (int i = 0; i < NP; i++) {
String tileSpec = previousTiles.get(i);
if (!tileSpec.startsWith(CustomTile.PREFIX))
continue;
if (!newTiles.contains(tileSpec)) {
// Get the custom tile ready to be removed
ComponentName component = CustomTile.getComponentFromSpec(tileSpec);
Intent intent = new Intent().setComponent(component);
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(), mContext, mServices, new Tile(), intent, new UserHandle(ActivityManager.getCurrentUser()));
lifecycleManager.onStopListening();
lifecycleManager.onTileRemoved();
TileLifecycleManager.setTileAdded(mContext, component, false);
lifecycleManager.flushMessagesAndUnbind();
}
}
if (DEBUG)
Log.d(TAG, "saveCurrentTiles " + newTiles);
Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING, TextUtils.join(",", newTiles), ActivityManager.getCurrentUser());
}
use of android.service.quicksettings.Tile in project android_frameworks_base by crdroidandroid.
the class QSTileHost method removeTilesWithSamePkg.
/**
* Remove custom tiles with the same package name
**/
public void removeTilesWithSamePkg(String pkgName) {
List<String> newTileSpecs = new ArrayList<>();
newTileSpecs.addAll(mTileSpecs);
for (String spec : mTileSpecs) {
if (!spec.startsWith(CustomTile.PREFIX))
continue;
if (spec.contains(pkgName)) {
// Get the custom tile ready to be removed
ComponentName component = CustomTile.getComponentFromSpec(spec);
Intent intent = new Intent().setComponent(component);
TileLifecycleManager lifecycleManager = new TileLifecycleManager(new Handler(), mContext, mServices, new Tile(), intent, new UserHandle(ActivityManager.getCurrentUser()));
lifecycleManager.onStopListening();
lifecycleManager.onTileRemoved();
lifecycleManager.flushMessagesAndUnbind();
// Remove spec from newTileSpecs
newTileSpecs.remove(spec);
}
}
// Save into Settings
if (newTileSpecs.size() != mTileSpecs.size()) {
Secure.putStringForUser(getContext().getContentResolver(), QSTileHost.TILES_SETTING, TextUtils.join(",", newTileSpecs), ActivityManager.getCurrentUser());
}
}
Aggregations