Search in sources :

Example 16 with Tile

use of android.service.quicksettings.Tile in project muzei by romannurik.

the class NextArtworkTileService method updateTile.

private void updateTile() {
    Tile tile = getQsTile();
    if (tile == null) {
        // We'll update the tile next time onStartListening is called.
        return;
    }
    if (!mWallpaperActive) {
        // If the wallpaper isn't active, the quick tile will activate it
        tile.setState(Tile.STATE_INACTIVE);
        tile.setLabel(getString(R.string.action_activate));
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_stat_muzei));
        tile.updateTile();
        return;
    }
    // Else, the wallpaper is active so we query on whether the 'Next Artwork' command
    // is available
    Cursor data = getContentResolver().query(MuzeiContract.Sources.CONTENT_URI, new String[] { MuzeiContract.Sources.COLUMN_NAME_SUPPORTS_NEXT_ARTWORK_COMMAND }, MuzeiContract.Sources.COLUMN_NAME_IS_SELECTED + "=1", null, null);
    if (data == null) {
        return;
    }
    boolean supportsNextArtwork = false;
    if (data.moveToFirst()) {
        supportsNextArtwork = data.getInt(0) != 0;
    }
    data.close();
    if (supportsNextArtwork) {
        tile.setState(Tile.STATE_ACTIVE);
        tile.setLabel(getString(R.string.action_next_artwork));
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notif_full_next_artwork));
    } else {
        tile.setState(Tile.STATE_UNAVAILABLE);
        tile.setLabel(getString(R.string.action_next_artwork));
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notif_full_next_artwork));
    }
    tile.updateTile();
}
Also used : Tile(android.service.quicksettings.Tile) Cursor(android.database.Cursor)

Example 17 with Tile

use of android.service.quicksettings.Tile in project platform_frameworks_base by android.

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));
}
Also used : IntentFilter(android.content.IntentFilter) HandlerThread(android.os.HandlerThread) UserHandle(android.os.UserHandle) Handler(android.os.Handler) Tile(android.service.quicksettings.Tile) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

Example 18 with Tile

use of android.service.quicksettings.Tile in project Telecine by JakeWharton.

the class TelecineTileService method onStartListening.

@Override
public void onStartListening() {
    Timber.i("Quick tile started listening");
    Tile tile = getQsTile();
    tile.setState(Tile.STATE_ACTIVE);
    tile.updateTile();
}
Also used : Tile(android.service.quicksettings.Tile)

Example 19 with Tile

use of android.service.quicksettings.Tile in project platform_frameworks_base by android.

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());
}
Also used : TileLifecycleManager(com.android.systemui.qs.external.TileLifecycleManager) UserHandle(android.os.UserHandle) Handler(android.os.Handler) DndTile(com.android.systemui.qs.tiles.DndTile) WorkModeTile(com.android.systemui.qs.tiles.WorkModeTile) BatteryTile(com.android.systemui.qs.tiles.BatteryTile) AirplaneModeTile(com.android.systemui.qs.tiles.AirplaneModeTile) WifiTile(com.android.systemui.qs.tiles.WifiTile) CustomTile(com.android.systemui.qs.external.CustomTile) DataSaverTile(com.android.systemui.qs.tiles.DataSaverTile) IntentTile(com.android.systemui.qs.tiles.IntentTile) QSTile(com.android.systemui.qs.QSTile) NfcTile(com.android.systemui.qs.tiles.NfcTile) HotspotTile(com.android.systemui.qs.tiles.HotspotTile) ColorInversionTile(com.android.systemui.qs.tiles.ColorInversionTile) CellularTile(com.android.systemui.qs.tiles.CellularTile) FlashlightTile(com.android.systemui.qs.tiles.FlashlightTile) UserTile(com.android.systemui.qs.tiles.UserTile) CastTile(com.android.systemui.qs.tiles.CastTile) Tile(android.service.quicksettings.Tile) RotationLockTile(com.android.systemui.qs.tiles.RotationLockTile) LocationTile(com.android.systemui.qs.tiles.LocationTile) NightDisplayTile(com.android.systemui.qs.tiles.NightDisplayTile) BluetoothTile(com.android.systemui.qs.tiles.BluetoothTile) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 20 with Tile

use of android.service.quicksettings.Tile in project android_frameworks_base by DirtyUnicorns.

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());
}
Also used : TileLifecycleManager(com.android.systemui.qs.external.TileLifecycleManager) UserHandle(android.os.UserHandle) Handler(android.os.Handler) HeadsUpTile(com.android.systemui.qs.tiles.HeadsUpTile) DndTile(com.android.systemui.qs.tiles.DndTile) WorkModeTile(com.android.systemui.qs.tiles.WorkModeTile) BatteryTile(com.android.systemui.qs.tiles.BatteryTile) AirplaneModeTile(com.android.systemui.qs.tiles.AirplaneModeTile) WifiTile(com.android.systemui.qs.tiles.WifiTile) ExpandedDesktopTile(com.android.systemui.qs.tiles.ExpandedDesktopTile) CustomTile(com.android.systemui.qs.external.CustomTile) CaffeineTile(com.android.systemui.qs.tiles.CaffeineTile) DataSaverTile(com.android.systemui.qs.tiles.DataSaverTile) IntentTile(com.android.systemui.qs.tiles.IntentTile) SoundTile(com.android.systemui.qs.tiles.SoundTile) AndroidAutoTile(com.android.systemui.qs.tiles.AndroidAutoTile) WeatherTile(com.android.systemui.qs.tiles.WeatherTile) HardwareButtonTile(com.android.systemui.qs.tiles.HardwareButtonTile) QSTile(com.android.systemui.qs.QSTile) NfcTile(com.android.systemui.qs.tiles.NfcTile) AmbientLiftToWakeTile(com.android.systemui.qs.tiles.AmbientLiftToWakeTile) NavigationBarTile(com.android.systemui.qs.tiles.NavigationBarTile) HotspotTile(com.android.systemui.qs.tiles.HotspotTile) ColorInversionTile(com.android.systemui.qs.tiles.ColorInversionTile) CellularTile(com.android.systemui.qs.tiles.CellularTile) ScreenshotTile(com.android.systemui.qs.tiles.ScreenshotTile) FlashlightTile(com.android.systemui.qs.tiles.FlashlightTile) UserTile(com.android.systemui.qs.tiles.UserTile) CastTile(com.android.systemui.qs.tiles.CastTile) Tile(android.service.quicksettings.Tile) ImeTile(com.android.systemui.qs.tiles.ImeTile) SyncTile(com.android.systemui.qs.tiles.SyncTile) RotationLockTile(com.android.systemui.qs.tiles.RotationLockTile) LocationTile(com.android.systemui.qs.tiles.LocationTile) RebootTile(com.android.systemui.qs.tiles.RebootTile) MusicTile(com.android.systemui.qs.tiles.MusicTile) NightDisplayTile(com.android.systemui.qs.tiles.NightDisplayTile) AdbOverNetworkTile(com.android.systemui.qs.tiles.AdbOverNetworkTile) BluetoothTile(com.android.systemui.qs.tiles.BluetoothTile) ComponentName(android.content.ComponentName) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Aggregations

Tile (android.service.quicksettings.Tile)26 ComponentName (android.content.ComponentName)13 Intent (android.content.Intent)13 Handler (android.os.Handler)12 UserHandle (android.os.UserHandle)12 PendingIntent (android.app.PendingIntent)7 QSTile (com.android.systemui.qs.QSTile)7 CustomTile (com.android.systemui.qs.external.CustomTile)7 TileLifecycleManager (com.android.systemui.qs.external.TileLifecycleManager)7 AirplaneModeTile (com.android.systemui.qs.tiles.AirplaneModeTile)7 BatteryTile (com.android.systemui.qs.tiles.BatteryTile)7 BluetoothTile (com.android.systemui.qs.tiles.BluetoothTile)7 CastTile (com.android.systemui.qs.tiles.CastTile)7 CellularTile (com.android.systemui.qs.tiles.CellularTile)7 ColorInversionTile (com.android.systemui.qs.tiles.ColorInversionTile)7 DataSaverTile (com.android.systemui.qs.tiles.DataSaverTile)7 DndTile (com.android.systemui.qs.tiles.DndTile)7 FlashlightTile (com.android.systemui.qs.tiles.FlashlightTile)7 HotspotTile (com.android.systemui.qs.tiles.HotspotTile)7 IntentTile (com.android.systemui.qs.tiles.IntentTile)7