Java Code Examples for android.service.quicksettings.Tile#getState()

The following examples show how to use android.service.quicksettings.Tile#getState() . 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: 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 2
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 3
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 4
Source File: QuickStartTileService.java    From Virtual-Hosts with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick() {
    Tile tile = getQsTile();
    if (tile==null)return;
    int state = tile.getState();
    if (state == Tile.STATE_ACTIVE) {
        tile.setState(Tile.STATE_INACTIVE);
        VhostsService.stopVService(this.getApplicationContext());
   } else if(state == Tile.STATE_INACTIVE){
        tile.setState(Tile.STATE_ACTIVE);
        VhostsService.startVService(this.getApplicationContext(),1);
    }else{
        tile.setState(Tile.STATE_UNAVAILABLE);
    }
    tile.updateTile();
}
 
Example 5
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 6
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 7
Source File: QuickService.java    From LLApp with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example 8
Source File: MyTileService.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();

    Tile tile = getQsTile();

    if (tile.getState() == Tile.STATE_ACTIVE) {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        int counter = mSharedPreferences.getInt("counter", 0);

        mSharedPreferences.edit().putInt("counter", ++counter).apply();
        tile.setLabel("Count " + counter);
    }

    tile.updateTile();

}
 
Example 9
Source File: MyTileService.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public void onClick() {
    super.onClick();

    Tile tile = getQsTile();

    boolean isActive = (tile.getState() == Tile.STATE_ACTIVE);
    if (isActive) {
        tile.setState(Tile.STATE_INACTIVE);
        startActivityAndCollapse(new Intent(this, MainActivity.class));
        tile.setLabel("Disabled");
        tile.setContentDescription("Test App");
        tile.setIcon(Icon.createWithResource(this, android.R.drawable.ic_media_play));
    } else {
        mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        int counter = mSharedPreferences.getInt("counter", 0);
        tile.setState(Tile.STATE_ACTIVE);
        tile.setIcon(Icon.createWithResource(this, android.R.drawable.ic_media_pause));
        tile.setLabel("Count " + counter);
    }
    tile.updateTile();
}
 
Example 10
Source File: QuickService.java    From LLApp with Apache License 2.0 5 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();
    Log.d(TAG, "onStartListening");
    Tile tile = getQsTile();
    if (tile != null) {
        if (tile.getState() == Tile.STATE_ACTIVE) {
            tile.setLabel("Running...");
        } else {
            tile.setLabel("QuickStart");
        }
        tile.updateTile();
    }
}
 
Example 11
Source File: QSIntentService.java    From ui with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick() {

    // Check to see if the device is currently locked.
    boolean isCurrentlyLocked = this.isLocked();

    if (!isCurrentlyLocked) {

        Resources resources = getApplication().getResources();

        Tile tile = getQsTile();
        String tileLabel = tile.getLabel().toString();
        String tileState = (tile.getState() == Tile.STATE_ACTIVE) ?
                resources.getString(R.string.service_active) :
                resources.getString(R.string.service_inactive);

        Intent intent = new Intent(getApplicationContext(),
                ResultActivity.class);

        intent.putExtra(ResultActivity.RESULT_ACTIVITY_NAME_KEY,
                tileLabel);
        intent.putExtra(ResultActivity.RESULT_ACTIVITY_INFO_KEY,
                tileState);

        startActivityAndCollapse(intent);
    }
}
 
Example 12
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 13
Source File: WadbTileService.java    From WADB with Apache License 2.0 5 votes vote down vote up
private void showStateOn(String ip, int port) {
    Log.d(TAG, "showStateOn");

    final Tile tile = getQsTile();
    final String label = ip + ":" + port;
    if (tile.getState() == Tile.STATE_ACTIVE
            && label.equals(tile.getLabel().toString())) {
        return;
    }
    final Context context = this;
    tile.setState(Tile.STATE_ACTIVE);
    tile.setIcon(Icon.createWithResource(context, R.drawable.ic_qs_network_adb_on));
    tile.setLabel(label);
    tile.updateTile();
}
 
Example 14
Source File: QuickRecordTile.java    From screenrecorder with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onClick() {
    Tile tile = getQsTile();
    isTileActive = !(tile.getState() == Tile.STATE_ACTIVE);
    changeTileState();
    if (isTileActive) {
        startActivity(new Intent(this, MainActivity.class).setAction(getString(R.string.app_shortcut_action)));
    } else {
        startService(new Intent(this, RecorderService.class).setAction(Const.SCREEN_RECORDING_STOP));
    }
    isTileActive = !isTileActive;
}
 
Example 15
Source File: QSIntentService.java    From android-n-quick-settings with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick() {

    // Check to see if the device is currently locked.
    boolean isCurrentlyLocked = this.isLocked();

    if (!isCurrentlyLocked) {

        Resources resources = getApplication().getResources();

        Tile tile = getQsTile();
        String tileLabel = tile.getLabel().toString();
        String tileState = (tile.getState() == Tile.STATE_ACTIVE) ?
                resources.getString(R.string.service_active) :
                resources.getString(R.string.service_inactive);

        Intent intent = new Intent(getApplicationContext(),
                ResultActivity.class);

        intent.putExtra(ResultActivity.RESULT_ACTIVITY_NAME_KEY,
                tileLabel);
        intent.putExtra(ResultActivity.RESULT_ACTIVITY_INFO_KEY,
                tileState);

        startActivityAndCollapse(intent);
    }
}
 
Example 16
Source File: HyperionGrabberTileService.java    From hyperion-android-grabber with MIT License 5 votes vote down vote up
@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();
        }
    }
}
 
Example 17
Source File: MainTileEntry.java    From rebootmenu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStartListening() {
    boolean isLocked = isLocked();
    Tile tile = getQsTile();
    if (tile == null) return;
    int qsTileState = tile.getState();
    new DebugLog("MainTileEntry.onStartListening: isLocked=" + isLocked + " qsTileState=" + qsTileState, DebugLog.LogLevel.I);
    if (!isLocked && qsTileState != Tile.STATE_ACTIVE) {
        tile.setState(Tile.STATE_ACTIVE);
        tile.updateTile();
    }
}
 
Example 18
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 19
Source File: NightModeTileService.java    From SystemUITuner2 with MIT License 5 votes vote down vote up
@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();
}