android.service.quicksettings.Tile.setState()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中android.service.quicksettings.Tile.setState()方法的一些代码示例,展示了Tile.setState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tile.setState()方法的具体详情如下:
包路径:android.service.quicksettings.Tile
类名称:Tile
方法名:setState

Tile.setState介绍

暂无

代码示例

代码示例来源: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: iTXTech/Daedalus

@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();
}

代码示例来源:origin: iTXTech/Daedalus

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();
  }
}

代码示例来源: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: abrenoch/hyperion-android-grabber

@Override
  public void onReceive(Context context, Intent intent) {
    Tile tile = getQsTile();
    boolean running = intent.getBooleanExtra(HyperionScreenService.BROADCAST_TAG, false);
    String error = intent.getStringExtra(HyperionScreenService.BROADCAST_ERROR);
    tile.setState(running ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
    tile.updateTile();
    if (error != null) {
      Toast.makeText(getBaseContext(), error, Toast.LENGTH_LONG).show();
    }
  }
};

代码示例来源:origin: haruue/WADB

private void showStateUnavailable() {
  Tile tile = getQsTile();
  tile.setState(Tile.STATE_UNAVAILABLE);
  tile.updateTile();
}

代码示例来源:origin: by-syk/NetUpDown

private void switchState(boolean isActive) {
  Tile tile = getQsTile();
  if (tile != null) {
    tile.setLabel(getString(R.string.tile_run));
    if (isActive) {
      tile.setState(Tile.STATE_ACTIVE);
    } else {
      tile.setState(Tile.STATE_INACTIVE);
    }
    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: 109021017/android-TopActivity

private void updateTile() {
  if (WatchingAccessibilityService.getInstance() == null) {
    getQsTile().setState(Tile.STATE_INACTIVE);
  } else {
    getQsTile().setState(SPHelper.isShowWindow(this) ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
  }
  getQsTile().updateTile();
}

代码示例来源: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: AzimoLabs/Language-Switcher-Tile

public void enable() {
  getQsTile().setState(Tile.STATE_ACTIVE);
  if (prefs.getLastLanguage() != null) {
    getQsTile().setLabel(prefs.getLastLanguage().toUpperCase());
  } else {
    getQsTile().setLabel(Locale.getDefault().getLanguage().toUpperCase());
  }
  getQsTile().updateTile();
}

代码示例来源: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: 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: 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: 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: fgl27/isu

@Override
public void onStartListening() {
  super.onStartListening();
  mTile = getQsTile();
  if (Tools.rootAccess(this) && Tools.SuVersionBool(Tools.SuVersion(this))) {
      su = Tools.SuBinary();
      mTile.setLabel((su ? this.getString(R.string.activated) : this.getString(R.string.deactivated)));
      mTile.setState(su ? mTile.STATE_ACTIVE : mTile.STATE_INACTIVE);
  } else {
    mTile.setLabel(this.getString(R.string.not_available));
    mTile.setState(mTile.STATE_UNAVAILABLE);
  }
  mTile.updateTile();
}

代码示例来源: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();
}

相关文章