本文整理汇总了Java中android.service.quicksettings.Tile.setIcon方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.setIcon方法的具体用法?Java Tile.setIcon怎么用?Java Tile.setIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.service.quicksettings.Tile
的用法示例。
在下文中一共展示了Tile.setIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateState
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateState() {
Tile tile = getQsTile();
if(tile != null) {
SharedPreferences pref = U.getSharedPreferences(this);
tile.setIcon(Icon.createWithResource(this, pref.getBoolean("app_drawer_icon", false)
? R.drawable.ic_system
: R.drawable.ic_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();
}
}
示例2: refreshTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
/** <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();
}
}
示例3: setBat
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void setBat(Intent intent) {
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
mIsCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL;
// int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
mBatteryPercent = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
Tile battery = getQsTile();
int resId;
if (mBatteryPercent >= 95) {
resId = mIsCharging ? R.drawable.ic_battery_charging_full : R.drawable.ic_battery;
} else if (mBatteryPercent >= 85) {
resId = mIsCharging ? R.drawable.ic_battery_charging_90 : R.drawable.ic_battery_90;
} else if (mBatteryPercent >= 70) {
resId = mIsCharging ? R.drawable.ic_battery_charging_80 : R.drawable.ic_battery_80;
} else if (mBatteryPercent >= 55) {
resId = mIsCharging ? R.drawable.ic_battery_charging_60 : R.drawable.ic_battery_60;
} else if (mBatteryPercent >= 40) {
resId = mIsCharging ? R.drawable.ic_battery_charging_50 : R.drawable.ic_battery_50;
} else if (mBatteryPercent >= 25) {
resId = mIsCharging ? R.drawable.ic_battery_charging_30 : R.drawable.ic_battery_30;
} else if (mBatteryPercent >= 15) {
resId = mIsCharging ? R.drawable.ic_battery_charging_20 : R.drawable.ic_battery_20;
} else {
resId = mIsCharging ? R.drawable.ic_battery_charging_20 : R.drawable.ic_battery_alert;
}
battery.setIcon(Icon.createWithResource(this, resId));
battery.setLabel(String.valueOf(mBatteryPercent).concat("%"));
battery.updateTile();
}
示例4: _isRunning
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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));
}
}
示例5: updateTileUI
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
/**
* Updates the QSTile icon and label
* @param state - State of night light. True value means night light is on, and vice versa
*/
private void updateTileUI(boolean state) {
Tile tile = this.getQsTile();
if (tile == null) return;
Icon newIcon;
int newState;
String title;
// Change the tile to match the service status.
if (state) {
newIcon = Icon.createWithResource(getApplicationContext(), ic_lightbulb_outline);
newState = Tile.STATE_ACTIVE;
title = getString(R.string.on);
} else {
newIcon = Icon.createWithResource(getApplicationContext(), ic_lightbulb_outline_disabled);
newState = Tile.STATE_INACTIVE;
title = getString(R.string.off);
}
// Change the UI of the tile.
tile.setLabel(title);
tile.setIcon(newIcon);
tile.setState(newState);
// Need to call updateTile for the tile to pick up changes.
tile.updateTile();
}
示例6: toggleTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void toggleTile(boolean enable) {
Tile tile = getQsTile();
if (enable) {
tile.setLabel(getString(R.string.ui_enable));
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.qs_locked));
tile.updateTile();
} else {
tile.setLabel(getString(R.string.ui_disable));
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.qs_unlocked));
tile.updateTile();
}
}
示例7: updateView
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateView(boolean displayToast, boolean init) {
Tile tile = getQsTile();
if (BaseMethod.isAccessibilitySettingsOn(this)) {
boolean KeyBlocked = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Config.ENABLED_KEYBLOCK, false);
if (init) {
if (KeyBlocked) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
} else {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
}
} else {
if (tile.getState() == Tile.STATE_ACTIVE) {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
} else if (tile.getState() == Tile.STATE_INACTIVE) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
}
}
} else {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
if (displayToast) {
BaseMethod.RunAccessibilityService(this);
}
}
tile.updateTile();
}
示例8: onTileAdded
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
@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();
}
}
示例9: onStartListening
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
@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();
}
}
示例10: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTile() {
Tile tile = this.getQsTile();
boolean isActive = this.getServiceStatus();
String newLabel;
Icon newIcon;
int newState;
if (isActive) {
newLabel = "MyQs is active.";
newIcon = Icon.createWithResource(getApplicationContext(),
android.R.drawable.ic_dialog_alert);
newState = Tile.STATE_ACTIVE;
//open result activity
Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
} else {
newLabel = "MyQs is inactive.";
newIcon = Icon.createWithResource(getApplicationContext(),
R.mipmap.ic_tile_inactive);
newState = Tile.STATE_INACTIVE;
}
tile.setIcon(newIcon);
tile.setLabel(newLabel);
tile.setState(newState);
tile.updateTile();
}
示例11: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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();
}
示例12: updateInactiveTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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();
}
示例13: updateActiveTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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();
}
示例14: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTile() {
final boolean isDebugModeEnabled = getDebugModeState(getContentResolver());
Log.d(DebugModeToggle.class.getSimpleName(), "Checking USB Debugging state, it's enabled = " + isDebugModeEnabled);
final Tile tile = getQsTile();
tile.setIcon(Icon.createWithResource(getApplicationContext(), getIcon(isDebugModeEnabled)));
tile.updateTile();
}
示例15: updateTileWithPercentage
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTileWithPercentage()
{
Tile tile = getQsTile();
tile.setIcon(Icon.createWithBitmap(drawCircularProgressBarWhiteOnTransparent(trafficWastedPercentage)));
tile.setLabel(
String.format("%1s: %2s%%", getString(R.string.quick_settings_tile_label), trafficWastedPercentage));
tile.setState(Tile.STATE_ACTIVE); // leads to a standard 'active', white Tile
tile.updateTile();
}