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

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

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

Tile.getState介绍

暂无

代码示例

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

@Override
public void onClick() {
  super.onClick();
  boolean enableScreenLockSwitch = PreferenceManager.getDefaultSharedPreferences(StandardUtils.getApplication()).getBoolean("pref_key_screen_lock_switch", false);
  if (getQsTile().getState() == Tile.STATE_ACTIVE) {
    if (enableScreenLockSwitch) {
      stopWadbRunnable.run();
    } else {
      unlockAndRun(stopWadbRunnable);
    }
  } else {
    if (enableScreenLockSwitch) {
      startWadbRunnable.run();
    } else {
      unlockAndRun(startWadbRunnable);
    }
  }
}

代码示例来源:origin: abrenoch/hyperion-android-grabber

@Override
public void onClick() {
  Tile tile = getQsTile();
  tile.updateTile();
  int tileState = tile.getState();
  if (tileState == Tile.STATE_ACTIVE) {
    Intent intent = new Intent(this, HyperionScreenService.class);
    intent.setAction(HyperionScreenService.ACTION_EXIT);
    startService(intent);
  } else {
    Runnable runner = () -> {
      boolean setupStarted = startSetupIfNeeded();
      if (!setupStarted){
        final Intent i = new Intent(this, BootActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION
            |Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
            |Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(i);
      }
    };
    if (isLocked()) {
      unlockAndRun(runner);
    } else {
      runner.run();
    }
  }
}

代码示例来源:origin: fython/Blackbulb

@Override
public void onClick(){
  Log.d(TAG, "Tile service onClick method called");
  super.onClick();
  Tile tile = getQsTile();
  if (tile == null) return;
  int status = tile.getState();
  Log.d(TAG, "status:" + status + "\t receive");
  switch (status) {
    case Tile.STATE_INACTIVE:
      ActionReceiver.sendActionStart(this);
      updateActiveTile(tile);
      break;
    case Tile.STATE_ACTIVE:
      ActionReceiver.sendActionStop(this);
      updateInactiveTile(tile);
      break;
  }
}

代码示例来源:origin: gigabytedevelopers/FireFiles

@Override
public void onClick() {
  super.onClick();
  Tile tile = getQsTile();
  switch (tile.getState()) {
    case Tile.STATE_INACTIVE:
      startServer();
      updateTileState(Tile.STATE_ACTIVE);
      break;
    case Tile.STATE_ACTIVE:
      stopServer();
    default:
      updateTileState(Tile.STATE_INACTIVE);
      break;
  }
}

代码示例来源:origin: Omico/CurrentActivity

@Override
public void onClick() {
  super.onClick();
  if (Objects.equals(SettingsProvider.getString(SettingsProvider.Mode.SELECTION, SettingsProvider.Mode.NONE), SettingsProvider.Mode.NONE)) {
    intentGuideActivity();
  } else {
    switch (tile.getState()) {
      case Tile.STATE_ACTIVE:
        setDisableTile();
        setAction(ACTION_FLOAT_VIEW_SERVICE_STOP);
        break;
      case Tile.STATE_INACTIVE:
        setEnableTile();
        setAction(ACTION_FLOAT_VIEW_SERVICE_START);
        break;
    }
    StatusBarUtils.collapseStatusBar(this);
  }
  tile.updateTile();
}

代码示例来源:origin: XFY9326/KeyBlocker

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

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

相关文章