本文整理匯總了Java中android.service.quicksettings.Tile.setLabel方法的典型用法代碼示例。如果您正苦於以下問題:Java Tile.setLabel方法的具體用法?Java Tile.setLabel怎麽用?Java Tile.setLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.service.quicksettings.Tile
的用法示例。
在下文中一共展示了Tile.setLabel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
super.onClick();
Log("Clicked");
initPrefs();
Tile tile = getQsTile();
if (tile != null) {
switch (tile.getState()) {
case Tile.STATE_ACTIVE:
prefs.setBool(Prefs.KEYS.ENABLED.toString(), false);
setCurrentState(Tile.STATE_INACTIVE);
break;
case Tile.STATE_INACTIVE:
prefs.setBool(Prefs.KEYS.ENABLED.toString(), true);
setCurrentState(Tile.STATE_ACTIVE);
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;
}
} else {
Log("Tile is null");
}
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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);
}
示例8: 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();
}
示例9: _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));
}
}
示例10: 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();
}
示例11: 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();
}
}
示例12: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
Tile tile = getQsTile();
tile.setLabel(getString(R.string.quick_toggle));
tile.setContentDescription(getString(R.string.app_name));
tile.setState(Daedalus.switchService() ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
tile.updateTile();
}
示例13: 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();
}
示例14: onStopListening
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onStopListening() {
super.onStopListening();
if (volumePollingSubscription != null) {
volumePollingSubscription.unsubscribe();
}
Tile tile = getQsTile();
tile.setLabel(getString(R.string.tile_label));
tile.updateTile();
}
示例15: 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();
}