本文整理汇总了Java中android.service.quicksettings.Tile.updateTile方法的典型用法代码示例。如果您正苦于以下问题:Java Tile.updateTile方法的具体用法?Java Tile.updateTile怎么用?Java Tile.updateTile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.service.quicksettings.Tile
的用法示例。
在下文中一共展示了Tile.updateTile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTileState
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTileState(int state) {
Tile tile = getQsTile();
if (tile != null) {
tile.setState(state);
Icon icon = tile.getIcon();
switch (state) {
case Tile.STATE_ACTIVE:
icon.setTint(Color.WHITE);
break;
case Tile.STATE_INACTIVE:
case Tile.STATE_UNAVAILABLE:
default:
icon.setTint(Color.GRAY);
break;
}
tile.updateTile();
}
}
示例2: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
protected static void updateTile(TileService context) {
if(context == null) return;
Tile tile = context.getQsTile();
if (ki4aService.current_status == Util.STATUS_SOCKS) {
tile.setLabel(context.getString(R.string.text_status_connected));
tile.setState(Tile.STATE_ACTIVE);
}
else if (ki4aService.current_status == Util.STATUS_CONNECTING) {
tile.setLabel(context.getString(R.string.text_status_connecting));
tile.setState(Tile.STATE_INACTIVE);
}
else if (ki4aService.current_status == Util.STATUS_DISCONNECT) {
tile.setLabel(context.getString(R.string.text_status_disconnected));
tile.setState(Tile.STATE_INACTIVE);
}
tile.updateTile();
}
示例3: 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();
}
}
示例4: setCurrentState
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void setCurrentState(int state) {
initPrefs();
Tile tile = getQsTile();
if (tile != null) {
tile.setState(state);
switch (state) {
case Tile.STATE_ACTIVE:
tile.setLabel(getString(R.string.quick_settings_title) + " " + getString(R.string.quick_settings_service_active));
Log("Active");
break;
case Tile.STATE_INACTIVE:
tile.setLabel(getString(R.string.quick_settings_title) + " " + getString(R.string.quick_settings_service_inactive));
Log("Inactive");
break;
default:
tile.setLabel(getString(R.string.quick_settings_title) + " " + (prefs.enabled ? getString(R.string.quick_settings_service_active) : getString(R.string.quick_settings_service_inactive)));
Log("Active");
break;
}
tile.updateTile();
}
}
示例5: 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();
}
}
示例6: updateTileState
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTileState(int state)
{
Tile tile = getQsTile();
if (tile != null) {
tile.setState(state);
Icon icon = tile.getIcon();
switch (state) {
case Tile.STATE_ACTIVE:
icon.setTint(Color.WHITE);
break;
case Tile.STATE_INACTIVE:
case Tile.STATE_UNAVAILABLE:
default:
icon.setTint(Color.GRAY);
break;
}
tile.updateTile();
}
}
示例7: onClick
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
@Override
public void onClick() {
super.onClick();
Log.d(TAG, "onClick");
Tile tile = getQsTile();
if (tile != null) {
if (tile.getState() == Tile.STATE_ACTIVE) {
tile.setLabel("QuickStart");
tile.setState(Tile.STATE_INACTIVE);
} else {
tile.setLabel("Running...");
tile.setState(Tile.STATE_ACTIVE);
}
tile.updateTile();
}
}
示例8: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTile() {
TelephonyManager manager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String code = manager.getSimOperator();
String country = manager.getSimCountryIso();
SharedPreferences preferences = PropUtil.getProtecredSharedPreferences(this);
Tile tile = getQsTile();
tile.setLabel(String.format("%s %s", code, country));
if (preferences.getBoolean(PropUtil.PREFERENCE_ENABLED, PropUtil.PREFERENCE_ENABLED_DEFAULT)) {
tile.setState(Tile.STATE_ACTIVE);
}
else {
tile.setState(Tile.STATE_INACTIVE);
}
tile.updateTile();
}
示例9: onStartListening
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
@Override
public void onStartListening() {
final Tile nightMode = getQsTile();
boolean isActive;
if (Build.VERSION.SDK_INT == 24) isActive = Settings.Secure.getInt(getContentResolver(), "twilight_mode", 0) == 1;
else {
isActive = Settings.Secure.getInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 0) == 1;
nightMode.setLabel(getResources().getText(R.string.night_display));
}
nightMode.setState(isActive ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
nightMode.updateTile();
// service = this;
mToggleIntent = new Intent("toggle_night");
mToggleReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("toggle_night")) {
boolean state = intent.getBooleanExtra("state", false);
nightMode.setState(state ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
nightMode.updateTile();
}
}
};
IntentFilter filter = new IntentFilter("toggle_night");
registerReceiver(mToggleReceiver, filter);
}
示例10: onClick
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
@Override
public void onClick() {
Tile nightMode = getQsTile();
int state;
try {
state = nightMode.getState();
if (state == Tile.STATE_ACTIVE) {
if (Build.VERSION.SDK_INT == 24) {
Settings.Secure.putInt(getContentResolver(), "twilight_mode", 0);
} else {
Settings.Secure.putInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 0);
}
nightMode.setState(Tile.STATE_INACTIVE);
} else {
if (Build.VERSION.SDK_INT == 24) {
Settings.Secure.putInt(getContentResolver(), "twilight_mode", 1);
} else {
Settings.Secure.putInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 1);
}
nightMode.setState(Tile.STATE_ACTIVE);
}
mToggleIntent.putExtra("state", state == Tile.STATE_INACTIVE);
sendBroadcast(mToggleIntent);
} catch (Exception e) {
e.printStackTrace();
}
nightMode.updateTile();
}
示例11: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTile() {
boolean activate = DaedalusVpnService.isActivated();
Tile tile = getQsTile();
tile.setLabel(getString(R.string.quick_toggle));
tile.setContentDescription(getString(R.string.app_name));
tile.setState(activate ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
示例12: 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();
}
示例13: updateTile
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
private void updateTile() {
Tile tile = getQsTile();
boolean isRunning = (mExecutor != null && !mExecutor.isShutdown());
if (tile != null) {
if (isRunning) {
_isRunning(tile);
} else {
_isNotRunning(tile);
}
}
tile.updateTile();
}
示例14: update
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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();
}
}
示例15: update
import android.service.quicksettings.Tile; //导入方法依赖的package包/类
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.updateTile();
}
}