本文整理了Java中android.service.quicksettings.Tile.setIcon()
方法的一些代码示例,展示了Tile.setIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tile.setIcon()
方法的具体详情如下:
包路径:android.service.quicksettings.Tile
类名称:Tile
方法名:setIcon
暂无
代码示例来源:origin: commonsguy/cw-omnibus
private void updateTile() {
Tile tile=getQsTile();
if (tile!=null) {
boolean isEnabled=getPrefs().getBoolean(MonitorApp.PREF_ENABLED, false);
int state=isEnabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
tile.setIcon(Icon.createWithResource(this,
R.drawable.ic_new_releases_24dp));
tile.setLabel(getString(R.string.app_name));
tile.setState(state);
tile.updateTile();
}
}
代码示例来源:origin: ukanth/afwall
public void cbFunc(RootCommand state) {
Api.setEnabled(context, state.exitCode != 0, true);
tile.setState(Tile.STATE_INACTIVE);// e() method form java, used in Kotlin as a property
tile.setLabel(getString(R.string.inactive));
tile.setIcon(Icon.createWithResource(context, R.drawable.notification_error));
tile.updateTile();
}
}));
代码示例来源:origin: ukanth/afwall
public void cbFunc(RootCommand state) {
// setEnabled always sends us a STATUS_CHANGED_MSG intent to update the icon
Api.setEnabled(context, state.exitCode == 0, true);
tile.setState(Tile.STATE_ACTIVE);
tile.setLabel(getString(R.string.active));
tile.setIcon(Icon.createWithResource(context, R.drawable.notification));
tile.updateTile();
}
}));
代码示例来源:origin: ukanth/afwall
@Override
public void onStartListening() {
super.onStartListening();
boolean status = Api.isEnabled(this);
Tile tile = getQsTile(); // this is getQsTile() method form java, used in Kotlin as a property
if (tile != null) {
if (!status) {
tile.setLabel(getString(R.string.inactive));
tile.setIcon(Icon.createWithResource(this, R.drawable.notification_error));
tile.setState(Tile.STATE_INACTIVE);
} else {
tile.setLabel(getString(R.string.active));
tile.setIcon(Icon.createWithResource(this, R.drawable.notification));
tile.setState(Tile.STATE_ACTIVE);
}
tile.updateTile();
}
}
代码示例来源:origin: Omico/CurrentActivity
private void setTile(Icon icon, String label, int state) {
tile.setIcon(icon);
tile.setLabel(label);
tile.setContentDescription(label);
tile.setState(state);
}
}
代码示例来源:origin: r3bl-org/stay-awake-app
private void _isNotRunning(Tile tile) {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(mIconEyeClosed);
tile.setLabel(getString(R.string.tile_inactive_text));
}
代码示例来源:origin: fython/Blackbulb
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();
}
代码示例来源:origin: WireGuard/wireguard-android
@Override
public void onClick() {
if (tunnel != null) {
final Tile tile = getQsTile();
if (tile != null) {
tile.setIcon(tile.getIcon() == iconOn ? iconOff : iconOn);
tile.updateTile();
}
tunnel.setState(State.TOGGLE).whenComplete(this::onToggleFinished);
} else {
final Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityAndCollapse(intent);
}
}
代码示例来源:origin: r3bl-org/stay-awake-app
private void _isRunning(Tile tile) {
if (isCharging()) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(mIconEyeOpen);
tile.setLabel(getString(R.string.tile_active_charging_text));
} else {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(mIconEyeOpen);
long timeRemaining = MAX_TIME_SEC - mTimeRunning_sec;
final String formatTime = formatTime(timeRemaining);
tile.setLabel(getString(R.string.tile_active_text, formatTime));
}
}
代码示例来源:origin: fython/Blackbulb
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();
}
代码示例来源:origin: fennifith/Status
@Override
public void onClick() {
super.onClick();
Tile tile = getQsTile();
if (tile != null) {
if (StaticUtils.isStatusServiceRunning(this)) {
PreferenceData.STATUS_ENABLED.setValue(this, false);
Intent intent = new Intent(StatusServiceImpl.ACTION_STOP);
intent.setClass(this, StatusServiceImpl.class);
stopService(intent);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_check_box_disabled));
} else if (StaticUtils.isReady(this)) {
PreferenceData.STATUS_ENABLED.setValue(this, true);
Intent intent = new Intent(StatusServiceImpl.ACTION_START);
intent.setClass(this, StatusServiceImpl.class);
startService(intent);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_check_box_enabled));
}
tile.updateTile();
}
}
}
代码示例来源:origin: fennifith/Status
@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();
}
}
代码示例来源:origin: fennifith/Status
@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();
}
}
代码示例来源:origin: AlexMofer/ProjectX
private void updateTile(boolean active) {
final Tile tile = getQsTile();
if (active) {
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();
}
}
代码示例来源:origin: WangDaYeeeeee/GeometricWeather
/** <br> UI. */
@RequiresApi(api = Build.VERSION_CODES.N)
public static void refreshTile(Context context, Tile tile) {
if (tile == null) {
return;
}
Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
location.weather = DatabaseHelper.getInstance(context).readWeather(location);
if (location.weather != null) {
boolean f = PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.key_fahrenheit), false);
tile.setIcon(
Icon.createWithResource(
context,
WeatherHelper.getNotificationWeatherIcon(
location.weather.realTime.weatherKind,
TimeManager.getInstance(context).isDayTime())));
tile.setLabel(
ValueUtils.buildCurrentTemp(
location.weather.realTime.temp,
false,
f));
tile.updateTile();
}
}
}
代码示例来源:origin: haruue/WADB
private void showStateOff() {
Tile tile = getQsTile();
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(getApplication(), R.drawable.ic_qs_network_adb_off));
tile.setLabel(getApplication().getResources().getString(R.string.app_name));
tile.updateTile();
}
代码示例来源:origin: haruue/WADB
private void showStateOn(String ip, int port) {
Tile tile = getQsTile();
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(getApplication(), R.drawable.ic_qs_network_adb_on));
tile.setLabel(ip + ":" + port);
tile.updateTile();
}
代码示例来源:origin: franciscofranco/Demo-Mode-tile
@Override
public void onClick() {
super.onClick();
if (!Utils.isDumpPermissionGranted() || !Utils.isWriteSecureSettingsPermissionGranted()) {
Intent mainActivity = new Intent(getApplicationContext(), MainActivity.class);
mainActivity.setAction(Utils.MISSING_PERMISSION);
mainActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainActivity);
} else {
if (getQsTile().getState() == Tile.STATE_ACTIVE) {
getQsTile().setState(Tile.STATE_INACTIVE);
getQsTile().setIcon(Icon.createWithResource(getApplicationContext(), R.drawable.ic_off));
getQsTile().updateTile();
Utils.disableDemoMode();
} else {
getQsTile().setState(Tile.STATE_ACTIVE);
getQsTile().setIcon(Icon.createWithResource(getApplicationContext(), R.drawable.ic_on));
getQsTile().updateTile();
Utils.enableDemoMode();
}
}
}
}
代码示例来源:origin: franciscofranco/Demo-Mode-tile
@Override
public void onStartListening() {
super.onStartListening();
getQsTile().setState(Utils.isDemoModeOn() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
getQsTile().setIcon(Utils.isDemoModeOn() ?
Icon.createWithResource(getApplicationContext(), R.drawable.ic_on) :
Icon.createWithResource(getApplicationContext(), R.drawable.ic_off));
getQsTile().updateTile();
}
代码示例来源:origin: WireGuard/wireguard-android
private void updateTile() {
// Update the tunnel.
final Tunnel newTunnel = Application.getTunnelManager().getLastUsedTunnel();
if (newTunnel != tunnel) {
if (tunnel != null)
tunnel.removeOnPropertyChangedCallback(onStateChangedCallback);
tunnel = newTunnel;
if (tunnel != null)
tunnel.addOnPropertyChangedCallback(onStateChangedCallback);
}
// Update the tile contents.
final String label;
final int state;
final Tile tile = getQsTile();
if (tunnel != null) {
label = tunnel.getName();
state = tunnel.getState() == Tunnel.State.UP ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
} else {
label = getString(R.string.app_name);
state = Tile.STATE_INACTIVE;
}
if (tile == null)
return;
tile.setLabel(label);
if (tile.getState() != state) {
tile.setIcon(state == Tile.STATE_ACTIVE ? iconOn : iconOff);
tile.setState(state);
}
tile.updateTile();
}
内容来源于网络,如有侵权,请联系作者删除!