use of android.service.quicksettings.Tile in project android_frameworks_base by DirtyUnicorns.
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());
}
}
use of android.service.quicksettings.Tile in project android_frameworks_base by AOSPA.
the class NekoTile method updateState.
private void updateState() {
Tile tile = getQsTile();
int foodState = mPrefs.getFoodState();
Food food = new Food(foodState);
if (foodState != 0) {
NekoService.registerJobIfNeeded(this, food.getInterval(this));
}
tile.setIcon(food.getIcon(this));
tile.setLabel(food.getName(this));
tile.setState(foodState != 0 ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
use of android.service.quicksettings.Tile in project android_frameworks_base by AOSPA.
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 NetGuard by M66B.
the class ServiceTileMain method update.
private void update() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean enabled = prefs.getBoolean("enabled", false);
Tile tile = getQsTile();
if (tile != null) {
tile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
}
use of android.service.quicksettings.Tile in project NetGuard by M66B.
the class ServiceTileLockdown method update.
private void update() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean lockdown = prefs.getBoolean("lockdown", false);
Tile tile = getQsTile();
if (tile != null) {
tile.setState(lockdown ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
}
Aggregations