Java Code Examples for android.service.quicksettings.Tile#setIcon()

The following examples show how to use android.service.quicksettings.Tile#setIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileService.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void refreshTile(Context context, Tile tile) {
    if (tile == null) {
        return;
    }
    Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
    Weather weather = DatabaseHelper.getInstance(context).readWeather(location);
    if (weather != null) {
        tile.setIcon(
                ResourceHelper.getMinimalIcon(
                        ResourcesProviderFactory.getNewInstance(),
                        weather.getCurrent().getWeatherCode(),
                        TimeManager.getInstance(context).isDayTime()
                )
        );
        tile.setLabel(
                weather.getCurrent().getTemperature().getTemperature(
                        context,
                        SettingsOptionManager.getInstance(context).getTemperatureUnit())
        );
        tile.setState(Tile.STATE_INACTIVE);
        tile.updateTile();
    }
}
 
Example 2
Source File: QuickSettingsTileService.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
private void updateState() {
    Tile tile = getQsTile();
    if(tile != null) {
        SharedPreferences pref = U.getSharedPreferences(this);
        tile.setIcon(Icon.createWithResource(this,
                pref.getString(PREF_START_BUTTON_IMAGE, U.getDefaultStartButtonImage(this)).equals("app_logo")
                        ? R.drawable.tb_system
                        : R.drawable.tb_allapps));

        if(U.canDrawOverlays(this))
            tile.setState(U.isServiceRunning(this, NotificationService.class)
                    ? Tile.STATE_ACTIVE
                    : Tile.STATE_INACTIVE);
        else
            tile.setState(Tile.STATE_UNAVAILABLE);

        tile.updateTile();
    }
}
 
Example 3
Source File: QuickSettingsTapService.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartListening() {
    Log.d(TAG, "onStartListening");
    boolean working = getServiceStatus();
    Tile tile = getQsTile();

    if (working) {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_on));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is On");
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_off));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is Off");
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();

}
 
Example 4
Source File: ServiceTileMain.java    From tracker-control-android with GNU General Public License v3.0 5 votes vote down vote up
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.setIcon(Icon.createWithResource(this, enabled ? R.drawable.ic_rocket_white : R.drawable.ic_rocket_white_60));
        tile.updateTile();
    }
}
 
Example 5
Source File: ToggleKeepActivities.java    From KeepActivitiesTile with Apache License 2.0 5 votes vote down vote up
private void updateTile() {
    final boolean keepActivities = getKeepActivities(getContentResolver());
    final Tile tile = getQsTile();
    tile.setIcon(Icon.createWithResource(getApplicationContext(), getIcon(keepActivities)));
    tile.setLabel(getString(getLabel(keepActivities)));
    tile.updateTile();
}
 
Example 6
Source File: QuickToggleService.java    From Status with Apache License 2.0 5 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setIcon(Icon.createWithResource(this, StaticUtils.isStatusServiceRunning(this) ? R.drawable.ic_check_box_enabled : R.drawable.ic_check_box_disabled));
        tile.updateTile();
    }
}
 
Example 7
Source File: QuickToggleService.java    From Status with Apache License 2.0 5 votes vote down vote up
@Override
public void onTileAdded() {
    super.onTileAdded();
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setIcon(Icon.createWithResource(this, StaticUtils.isStatusServiceRunning(this) ? R.drawable.ic_check_box_enabled : R.drawable.ic_check_box_disabled));
        tile.updateTile();
    }
}
 
Example 8
Source File: ServiceTileFilter.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
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.setIcon(Icon.createWithResource(this, filter ? R.drawable.ic_filter_list_white_24dp : R.drawable.ic_filter_list_white_24dp_60));
        tile.updateTile();
    }
}
 
Example 9
Source File: FavoriteAppTileService.java    From Taskbar with Apache License 2.0 5 votes vote down vote up
private void updateState() {
    Tile tile = getQsTile();
    if(tile == null) return;

    SharedPreferences pref = U.getSharedPreferences(this);
    if(pref.getBoolean(prefix + "added", false)) {
        tile.setState(Tile.STATE_ACTIVE);
        tile.setLabel(pref.getString(prefix + "label", getString(R.string.tb_new_shortcut)));

        String componentName = pref.getString(prefix + "component_name", null);
        float threshold = pref.getFloat(prefix + "icon_threshold", -1);

        if(componentName != null && threshold >= 0) {
            UserManager userManager = (UserManager) getSystemService(USER_SERVICE);
            LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE);
            long userId = pref.getLong(prefix + "user_id", userManager.getSerialNumberForUser(Process.myUserHandle()));

            Intent intent = new Intent();
            intent.setComponent(ComponentName.unflattenFromString(componentName));
            LauncherActivityInfo info = launcherApps.resolveActivity(intent, userManager.getUserForSerialNumber(userId));

            IconCache cache = IconCache.getInstance(this);
            BitmapDrawable icon = U.convertToMonochrome(this, cache.getIcon(this, info), threshold);

            tile.setIcon(Icon.createWithBitmap(icon.getBitmap()));
        } else
            tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile));
    } else {
        tile.setState(Tile.STATE_INACTIVE);
        tile.setLabel(getString(R.string.tb_new_shortcut));
        tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile));
    }

    tile.updateTile();
}
 
Example 10
Source File: MaskTileService.java    From Blackbulb with GNU General Public License v3.0 5 votes vote down vote up
private void updateInactiveTile(Tile tile) {
    Icon inActiveIcon = Icon
            .createWithResource(getApplicationContext(),
                    R.drawable.ic_qs_night_mode_off);

    tile.setIcon(inActiveIcon);
    tile.setState(Tile.STATE_INACTIVE);
    tile.updateTile();
}
 
Example 11
Source File: FtpTileService.java    From ProjectX with Apache License 2.0 5 votes vote down vote up
private void updateTile() {
    final Tile tile = getQsTile();
    if (FtpServiceHelper.getInstance().isStarted()) {
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_tile_ftp));
        tile.setLabel(getString(R.string.ftp_tile_label_active));
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        tile.setIcon(Icon.createWithResource(this, R.drawable.ic_tile_ftp));
        tile.setLabel(getString(R.string.ftp_tile_label_inactive));
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
Example 12
Source File: MaskTileService.java    From Blackbulb with GNU General Public License v3.0 5 votes vote down vote up
private void updateActiveTile(Tile tile) {
    Icon activeIcon = Icon
            .createWithResource(getApplicationContext(),
                    R.drawable.ic_qs_night_mode_on);

    tile.setIcon(activeIcon);
    tile.setState(Tile.STATE_ACTIVE);
    tile.updateTile();
}
 
Example 13
Source File: ServiceTileLockdown.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
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.setIcon(Icon.createWithResource(this, lockdown ? R.drawable.ic_lock_outline_white_24dp : R.drawable.ic_lock_outline_white_24dp_60));
        tile.updateTile();
    }
}
 
Example 14
Source File: ServiceTileGraph.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
private void update() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean stats = prefs.getBoolean("show_stats", false);
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setState(stats ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
        tile.setIcon(Icon.createWithResource(this, stats ? R.drawable.ic_equalizer_white_24dp : R.drawable.ic_equalizer_white_24dp_60));
        tile.updateTile();
    }
}
 
Example 15
Source File: WadbTileService.java    From WADB with Apache License 2.0 5 votes vote down vote up
private void showStateOff() {
    Log.d(TAG, "showStateOff");

    final Tile tile = getQsTile();
    if (tile.getState() == Tile.STATE_INACTIVE) {
        return;
    }
    final Context context = this;
    tile.setState(Tile.STATE_INACTIVE);
    tile.setIcon(Icon.createWithResource(context, R.drawable.ic_qs_network_adb_off));
    tile.setLabel(context.getString(R.string.app_name));
    tile.updateTile();
}
 
Example 16
Source File: ProfileTile.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
private void resetTileStatus() {
    int profile = Spectrum.getProfile(getApplicationContext());
    Tile tile = this.getQsTile();
    Icon newIcon;
    String newLabel;
    int newState;

    // Update tile
    if (!Spectrum.supported(getApplicationContext())){
        newLabel = "No Spectrum support";
        newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
        newState = Tile.STATE_INACTIVE;
    }else {
        if (profile == 3) {
            newLabel = "Spectrum Gaming";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_game);
            newState = Tile.STATE_ACTIVE;
            click = false;
        } else if (profile == 2) {
            newLabel = "Spectrum Battery";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_battery);
            newState = Tile.STATE_ACTIVE;
            click = true;
        } else if (profile == 1) {
            newLabel = "Spectrum Performance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_performance);
            newState = Tile.STATE_ACTIVE;
            click = true;
        } else if (profile == 0) {
            newLabel = "Spectrum Balance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_balanced);
            newState = Tile.STATE_ACTIVE;
            click = false;
        } else {
            newLabel = "Spectrum Custom";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
            newState = Tile.STATE_ACTIVE;
            click = false;
        }
    }

    // Change the UI of the tile.
    tile.setLabel(newLabel);
    tile.setIcon(newIcon);
    tile.setState(newState);
    tile.updateTile();
}
 
Example 17
Source File: ProfileTile.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
private void updateTile() {
    Tile tile = this.getQsTile();
    boolean isActive = getServiceStatus();
    Icon newIcon;
    String newLabel;
    int newState;

    // Update tile and set profile
    if (!Spectrum.supported(getApplicationContext())){
        newLabel = "No Spectrum support";
        newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
        newState = Tile.STATE_INACTIVE;
    }else {
        if (isActive && click) {
            newLabel = "Spectrum Gaming";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_game);
            newState = Tile.STATE_ACTIVE;
            click = false;
            Spectrum.setProfile(3, getApplicationContext());
        } else if (!isActive && click) {
            newLabel = "Spectrum Battery";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_battery);
            newState = Tile.STATE_ACTIVE;
            click = true;
            Spectrum.setProfile(2, getApplicationContext());
        } else if (isActive && !click) {
            newLabel = "Spectrum Performance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_performance);
            newState = Tile.STATE_ACTIVE;
            click = true;
            Spectrum.setProfile(1, getApplicationContext());
        } else {
            newLabel = "Spectrum Balance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_balanced);
            newState = Tile.STATE_ACTIVE;
            click = false;
            Spectrum.setProfile(0, getApplicationContext());
        }
    }

    // Change the UI of the tile.
    tile.setLabel(newLabel);
    tile.setIcon(newIcon);
    tile.setState(newState);
    tile.updateTile();
}
 
Example 18
Source File: SpectrumTile.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
private void updateTile() {
      Tile tile = this.getQsTile();
      Icon newIcon;
      String newLabel;
      int newState;

      // Update tile and set profile
      if (!(Spectrum.supported())) {
          newLabel = "No Spectrum support";
          newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_logo);
          newState = Tile.STATE_INACTIVE;
      } else {
          if (id == 0) {
newLabel = "Performance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_game);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(1);
Prefs.saveInt("spectrum_profile", 1, getApplicationContext());
          } else if (id == 1) {
newLabel = "Battery";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_battery);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(2);
Prefs.saveInt("spectrum_profile", 2, getApplicationContext());
          } else if (id == 2) {
newLabel = "Gaming";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_performance);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(3);
Prefs.saveInt("spectrum_profile", 3, getApplicationContext());
          } else {
newLabel = "Balance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_balanced);
newState = Tile.STATE_ACTIVE;
id = 0;
Spectrum.setProfile(0);
Prefs.saveInt("spectrum_profile", 0, getApplicationContext());
          }
      }

      // Change the UI of the tile.
      tile.setLabel(newLabel);
      tile.setIcon(newIcon);
      tile.setState(newState);
      tile.updateTile();
  }
 
Example 19
Source File: QuickSettingsService.java    From android-n-quick-settings with Apache License 2.0 4 votes vote down vote up
private void updateTile() {

        Tile tile = this.getQsTile();
        boolean isActive = getServiceStatus();

        Icon newIcon;
        String newLabel;
        int newState;

        // Change the tile to match the service status.
        if (isActive) {

            newLabel = String.format(Locale.US,
                    "%s %s",
                    getString(R.string.tile_label),
                    getString(R.string.service_active));

            newIcon = Icon.createWithResource(getApplicationContext(),
                    ic_android_black_24dp);

            newState = Tile.STATE_ACTIVE;

        } else {
            newLabel = String.format(Locale.US,
                    "%s %s",
                    getString(R.string.tile_label),
                    getString(R.string.service_inactive));

            newIcon =
                    Icon.createWithResource(getApplicationContext(),
                            android.R.drawable.ic_dialog_alert);

            newState = Tile.STATE_INACTIVE;
        }

        // Change the UI of the tile.
        tile.setLabel(newLabel);
        tile.setIcon(newIcon);
        tile.setState(newState);

        // Need to call updateTile for the tile to pick up changes.
        tile.updateTile();
    }
 
Example 20
Source File: MyTileService.java    From journaldev with MIT License 4 votes vote down vote up
@Override
public void onTileAdded() {
    super.onTileAdded();


    Tile tile = getQsTile();
    tile.setState(Tile.STATE_ACTIVE);


    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    int counter = mSharedPreferences.getInt("counter", 0);

    tile.setLabel("Count " + counter);

    tile.setIcon(Icon.createWithResource(this, android.R.drawable.ic_media_pause));
    tile.updateTile();

    Toast.makeText(getApplicationContext(), "tile added", Toast.LENGTH_SHORT).show();
}