Java Code Examples for android.service.quicksettings.Tile#STATE_INACTIVE

The following examples show how to use android.service.quicksettings.Tile#STATE_INACTIVE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickSettingsToggle.java    From always-on-amoled with GNU General Public License v3.0 6 votes vote down vote up
@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");
    }
}
 
Example 2
Source File: QuickSettingService.java    From zephyr with MIT License 6 votes vote down vote up
private void updateTile() {
    boolean isServiceRunning = preferenceManager.getBoolean(PreferenceKeys.PREF_IS_SOCKET_SERVICE_RUNNING, false);
    boolean isJoinCodeSet = isJoinCodeSet();
    int tileState = isJoinCodeSet ? (isServiceRunning ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE) : Tile.STATE_UNAVAILABLE;

    logger.log(LogLevel.DEBUG, LOG_TAG, "updateTile - isServiceRunning: %b, isJoinCodeSet: %b, tileState: %d",
            isServiceRunning, isJoinCodeSet, tileState);

    Tile tile = getQsTile();
    if (tile != null) {
        tile.setState(tileState);
        tile.updateTile();
    } else {
        logger.log(LogLevel.WARNING, LOG_TAG, "Unable to update tile: null");
    }
}
 
Example 3
Source File: ServerService.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 4
Source File: ServerService.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 5
Source File: ServerService.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 6
Source File: ServerService.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 7
Source File: ServerService.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@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;
    }
}
 
Example 8
Source File: MaskTileService.java    From Blackbulb with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example 9
Source File: ProofModeTileService.java    From proofmode with GNU General Public License v3.0 5 votes vote down vote up
private void updateTile() {
    if (Tile.STATE_ACTIVE == getQsTile().getState()) {
        changeTileState(Tile.STATE_INACTIVE);
        mPrefs.edit().putBoolean("doProof",false).commit();

    } else if (Tile.STATE_INACTIVE == getQsTile().getState()) {
        changeTileState(Tile.STATE_ACTIVE);
        mPrefs.edit().putBoolean("doProof",true).commit();
    }
}
 
Example 10
Source File: QuickSettingsDislaogService.java    From ui with Apache License 2.0 5 votes vote down vote up
private void updateTile() {
    Tile tile = super.getQsTile();
    int activeState = isTileActive ?
            Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;

    tile.setState(activeState);
    tile.updateTile();
}
 
Example 11
Source File: WadbTileService.java    From WADB with Apache License 2.0 5 votes vote down vote up
private void showStateOff() {
    Log.d(TAG, "showStateOff");

    final Tile tile = getQsTile();
    if (tile.getState() == Tile.STATE_INACTIVE) {
        return;
    }
    final Context context = this;
    tile.setState(Tile.STATE_INACTIVE);
    tile.setIcon(Icon.createWithResource(context, R.drawable.ic_qs_network_adb_off));
    tile.setLabel(context.getString(R.string.app_name));
    tile.updateTile();
}
 
Example 12
Source File: QuickSettingsService.java    From android-samples with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 13
Source File: QuickSettingService.java    From KeyBlocker with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example 14
Source File: QuickRecordTile.java    From screenrecorder with GNU Affero General Public License v3.0 5 votes vote down vote up
private void changeTileState() {
    Tile tile = super.getQsTile();
    int activeState = isTileActive ?
            Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;

    if (!isTileActive)
        tile.setLabel(getString(R.string.quick_settings_tile_start_title));
    else
        tile.setLabel(getString(R.string.quick_settings_tile_stop_title));

    tile.setState(activeState);
    tile.updateTile();

}
 
Example 15
Source File: SpectrumTile.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 5 votes vote down vote up
private void resetTileStatus() {
      int profile = Utils.strToInt(Spectrum.getProfile());
      Tile tile = this.getQsTile();
      Icon newIcon;
      String newLabel;
      int newState;

      // Update tile
      if (!(Spectrum.supported())) {
          newLabel = "No Spectrum support";
          newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_logo);
          newState = Tile.STATE_INACTIVE;
      }else {
          if (profile == 3) {
newLabel = "Gaming";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_game);
newState = Tile.STATE_ACTIVE;
          } else if (profile == 2) {
newLabel = "Battery";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_battery);
newState = Tile.STATE_ACTIVE;
          } else if (profile == 1) {
newLabel = "Performance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_performance);
newState = Tile.STATE_ACTIVE;
          } else {
newLabel = "Balance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_balanced);
newState = Tile.STATE_ACTIVE;
          }
      }

      // Change the UI of the tile.
      tile.setLabel(newLabel);
      tile.setIcon(newIcon);
      tile.setState(newState);
      tile.updateTile();
  }
 
Example 16
Source File: KLapseTile.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 5 votes vote down vote up
private void resetTileStatus() {
int status = KLapse.getklapseEnable();
       Tile tile = this.getQsTile();
       String newLabel;
       int newState;

       // Update tile
       if (!(KLapse.supported())) {
           newLabel = "No K-Lapse support";
           newState = Tile.STATE_INACTIVE;
       } else {
           if (status == 2) {
	newLabel = "K-Lapse\nBrightness";
	newState = Tile.STATE_ACTIVE;
           } else if (status == 1){
	newLabel = "K-Lapse\nTime";
	newState = Tile.STATE_ACTIVE;
           } else {
	newLabel = "K-Lapse\nTurned-Off";
	newState = Tile.STATE_ACTIVE;
           }
       }

       // Change the UI of the tile.
       tile.setLabel(newLabel);
       tile.setState(newState);
       tile.updateTile();
   }
 
Example 17
Source File: ProfileTile.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
private void resetTileStatus() {
    int profile = Spectrum.getProfile(getApplicationContext());
    Tile tile = this.getQsTile();
    Icon newIcon;
    String newLabel;
    int newState;

    // Update tile
    if (!Spectrum.supported(getApplicationContext())){
        newLabel = "No Spectrum support";
        newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
        newState = Tile.STATE_INACTIVE;
    }else {
        if (profile == 3) {
            newLabel = "Spectrum Gaming";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_game);
            newState = Tile.STATE_ACTIVE;
            click = false;
        } else if (profile == 2) {
            newLabel = "Spectrum Battery";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_battery);
            newState = Tile.STATE_ACTIVE;
            click = true;
        } else if (profile == 1) {
            newLabel = "Spectrum Performance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_performance);
            newState = Tile.STATE_ACTIVE;
            click = true;
        } else if (profile == 0) {
            newLabel = "Spectrum Balance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_balanced);
            newState = Tile.STATE_ACTIVE;
            click = false;
        } else {
            newLabel = "Spectrum Custom";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
            newState = Tile.STATE_ACTIVE;
            click = false;
        }
    }

    // Change the UI of the tile.
    tile.setLabel(newLabel);
    tile.setIcon(newIcon);
    tile.setState(newState);
    tile.updateTile();
}
 
Example 18
Source File: ProfileTile.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
private void updateTile() {
    Tile tile = this.getQsTile();
    boolean isActive = getServiceStatus();
    Icon newIcon;
    String newLabel;
    int newState;

    // Update tile and set profile
    if (!Spectrum.supported(getApplicationContext())){
        newLabel = "No Spectrum support";
        newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_logo);
        newState = Tile.STATE_INACTIVE;
    }else {
        if (isActive && click) {
            newLabel = "Spectrum Gaming";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_game);
            newState = Tile.STATE_ACTIVE;
            click = false;
            Spectrum.setProfile(3, getApplicationContext());
        } else if (!isActive && click) {
            newLabel = "Spectrum Battery";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_battery);
            newState = Tile.STATE_ACTIVE;
            click = true;
            Spectrum.setProfile(2, getApplicationContext());
        } else if (isActive && !click) {
            newLabel = "Spectrum Performance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_performance);
            newState = Tile.STATE_ACTIVE;
            click = true;
            Spectrum.setProfile(1, getApplicationContext());
        } else {
            newLabel = "Spectrum Balance";
            newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_tile_balanced);
            newState = Tile.STATE_ACTIVE;
            click = false;
            Spectrum.setProfile(0, getApplicationContext());
        }
    }

    // Change the UI of the tile.
    tile.setLabel(newLabel);
    tile.setIcon(newIcon);
    tile.setState(newState);
    tile.updateTile();
}
 
Example 19
Source File: SpectrumTile.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 4 votes vote down vote up
private void updateTile() {
      Tile tile = this.getQsTile();
      Icon newIcon;
      String newLabel;
      int newState;

      // Update tile and set profile
      if (!(Spectrum.supported())) {
          newLabel = "No Spectrum support";
          newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_logo);
          newState = Tile.STATE_INACTIVE;
      } else {
          if (id == 0) {
newLabel = "Performance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_game);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(1);
Prefs.saveInt("spectrum_profile", 1, getApplicationContext());
          } else if (id == 1) {
newLabel = "Battery";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_battery);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(2);
Prefs.saveInt("spectrum_profile", 2, getApplicationContext());
          } else if (id == 2) {
newLabel = "Gaming";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_performance);
newState = Tile.STATE_ACTIVE;
id +=1;
Spectrum.setProfile(3);
Prefs.saveInt("spectrum_profile", 3, getApplicationContext());
          } else {
newLabel = "Balance";
newIcon = Icon.createWithResource(getApplicationContext(), R.drawable.ic_spectrum_balanced);
newState = Tile.STATE_ACTIVE;
id = 0;
Spectrum.setProfile(0);
Prefs.saveInt("spectrum_profile", 0, getApplicationContext());
          }
      }

      // Change the UI of the tile.
      tile.setLabel(newLabel);
      tile.setIcon(newIcon);
      tile.setState(newState);
      tile.updateTile();
  }
 
Example 20
Source File: QuickSettingsToggle.java    From always-on-amoled with GNU General Public License v3.0 4 votes vote down vote up
private int getState() {
    initPrefs();
    return prefs.enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
}