android.service.quicksettings.Tile Java Examples

The following examples show how to use android.service.quicksettings.Tile. 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: FakeOperatorTile.java    From LocationReportEnabler with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: ShadowsocksTileService.java    From Maying with Apache License 2.0 6 votes vote down vote up
@Override
public void stateChanged(int state, String profileName, String msg) throws RemoteException {
    Tile tile = getQsTile();
    if (tile != null) {
        switch (state) {
            case Constants.State.STOPPED:
                tile.setIcon(iconIdle);
                tile.setLabel(getString(R.string.app_name));
                tile.setState(Tile.STATE_INACTIVE);
                break;
            case Constants.State.CONNECTED:
                tile.setIcon(iconConnected);
                String label = profileName == null ? getString(R.string.app_name) : profileName;
                tile.setLabel(label);
                tile.setState(Tile.STATE_ACTIVE);
                break;
            default:
                tile.setIcon(iconBusy);
                tile.setLabel(getString(R.string.app_name));
                tile.setState(Tile.STATE_UNAVAILABLE);
                break;
        }
        tile.updateTile();
    }
}
 
Example #3
Source File: QuickSettingsTapService.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartListening() {
    Log.d(TAG, "onStartListening");
    boolean working = getServiceStatus();
    Tile tile = getQsTile();

    if (working) {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_on));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is On");
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_off));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is Off");
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();

}
 
Example #4
Source File: HyperionGrabberTileService.java    From hyperion-android-grabber with MIT License 6 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();
    mHandle.removeCallbacksAndMessages(null);
    if (!mIsListening) {
        LocalBroadcastManager.getInstance(this).registerReceiver(
                mMessageReceiver, new IntentFilter(HyperionScreenService.BROADCAST_FILTER));
        mIsListening = true;
    }
    if (isServiceRunning()) {
        Intent intent = new Intent(this, HyperionScreenService.class);
        intent.setAction(HyperionScreenService.GET_STATUS);
        startService(intent);
    } else {
        Tile tile = getQsTile();
        tile.setState(Tile.STATE_INACTIVE);
        tile.updateTile();
    }
}
 
Example #5
Source File: AN2LinuxTileService.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();

    Context c = getApplicationContext();
    boolean an2linuxEnabled = PreferenceManager.getDefaultSharedPreferences(c)
            .getBoolean(c.getString(R.string.preference_enable_an2linux), false);

    Tile tile = getQsTile();

    if (an2linuxEnabled) {
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
Example #6
Source File: IgniterTileService.java    From igniter with GNU General Public License v3.0 6 votes vote down vote up
private void updateTile(final @ProxyService.ProxyState int state) {
    Tile tile = getQsTile();
    if (tile == null) {
        return;
    }
    LogHelper.i(TAG, "updateTile with state: " + state);
    switch (state) {
        case ProxyService.STATE_NONE:
            tile.setState(Tile.STATE_INACTIVE);
            break;
        case ProxyService.STOPPED:
            break;
        case ProxyService.STARTED:
            tile.setState(Tile.STATE_ACTIVE);
            break;
        case ProxyService.STARTING:
        case ProxyService.STOPPING:
            tile.setState(Tile.STATE_UNAVAILABLE);
            break;
        default:
            LogHelper.e(TAG, "Unknown state: " + state);
            break;
    }
    tile.updateTile();
}
 
Example #7
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 #8
Source File: WadbTileService.java    From WADB with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick() {
    super.onClick();

    Log.d(TAG, "onClick");
    boolean enableScreenLockSwitch = WadbApplication.getDefaultSharedPreferences().getBoolean(WadbPreferences.KEY_SCREEN_LOCK_SWITCH, false);
    if (getQsTile().getState() == Tile.STATE_ACTIVE) {
        if (enableScreenLockSwitch) {
            STOP_WADB.run();
        } else {
            unlockAndRun(STOP_WADB);
        }
    } else {
        if (enableScreenLockSwitch) {
            mStartWadbRunnable.run();
        } else {
            unlockAndRun(mStartWadbRunnable);
        }
    }
}
 
Example #9
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 #10
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 #11
Source File: AN2LinuxTileService.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick() {
    super.onClick();

    Context c = getApplicationContext();

    SharedPreferences sharedPrefsDefault = PreferenceManager.getDefaultSharedPreferences(c);
    boolean an2linuxEnabled = sharedPrefsDefault.getBoolean(c.getString(R.string.preference_enable_an2linux), false);

    Tile tile = getQsTile();
    SharedPreferences.Editor edit = sharedPrefsDefault.edit();

    if (an2linuxEnabled) {
        tile.setState(Tile.STATE_INACTIVE);
        edit.putBoolean(c.getString(R.string.preference_enable_an2linux), false);
    } else {
        tile.setState(Tile.STATE_ACTIVE);
        edit.putBoolean(c.getString(R.string.preference_enable_an2linux), true);
    }
    tile.updateTile();
    edit.apply();
}
 
Example #12
Source File: ToggleService.java    From Greyscale with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick() {
    super.onClick();

    if (!Util.hasPermission(this)) {
        showDialog(Util.createTipsDialog(this));
        return;
    }

    int oldState = getQsTile().getState();
    if (oldState == Tile.STATE_ACTIVE) {
        setState(Tile.STATE_INACTIVE);
    } else {
        setState(Tile.STATE_ACTIVE);
    }

    Util.toggleGreyscale(this, oldState == Tile.STATE_INACTIVE);
}
 
Example #13
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 #14
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 #15
Source File: TileService.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void refreshTile(Context context, Tile tile) {
    if (tile == null) {
        return;
    }
    Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
    Weather weather = DatabaseHelper.getInstance(context).readWeather(location);
    if (weather != null) {
        tile.setIcon(
                ResourceHelper.getMinimalIcon(
                        ResourcesProviderFactory.getNewInstance(),
                        weather.getCurrent().getWeatherCode(),
                        TimeManager.getInstance(context).isDayTime()
                )
        );
        tile.setLabel(
                weather.getCurrent().getTemperature().getTemperature(
                        context,
                        SettingsOptionManager.getInstance(context).getTemperatureUnit())
        );
        tile.setState(Tile.STATE_INACTIVE);
        tile.updateTile();
    }
}
 
Example #16
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 #17
Source File: QuickSettingsToggle.java    From always-on-amoled with GNU General Public License v3.0 6 votes vote down vote up
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();
    }
}
 
Example #18
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 #19
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 #20
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 #21
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 #22
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 #23
Source File: ForceDozeTileService.java    From ForceDoze with GNU General Public License v3.0 6 votes vote down vote up
public void updateTileState(final boolean active) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Tile tile = getQsTile();
            if (tile != null) {
                tile.setLabel(active ? "ForceDoze on" : "ForceDoze off");
                tile.setState(active ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
                tile.updateTile();
            }
            if (active) {
                settings.edit().putBoolean("serviceEnabled", true).apply();
                sendBroadcastToApp(active);

            } else {
                settings.edit().putBoolean("serviceEnabled", false).apply();
                sendBroadcastToApp(active);
            }
        }
    }, 1500);
}
 
Example #24
Source File: QuickSettingsTapService.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick() {
    Log.d(TAG, "onClick");
    boolean working = getServiceStatus();

    Tile tile = getQsTile();
    if (working) {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_on));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is On");
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        //turn on the tile here.
        tile.setIcon(Icon.createWithResource(this, R.drawable.cooltile_off));
        tile.setLabel("Cool tile");
        tile.setContentDescription("cool tile is Off");
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
Example #25
Source File: AN2LinuxTileService.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStartListening() {
    super.onStartListening();

    Context c = getApplicationContext();
    boolean an2linuxEnabled = PreferenceManager.getDefaultSharedPreferences(c)
            .getBoolean(c.getString(R.string.preference_enable_an2linux), false);

    Tile tile = getQsTile();

    if (an2linuxEnabled) {
        tile.setState(Tile.STATE_ACTIVE);
    } else {
        tile.setState(Tile.STATE_INACTIVE);
    }
    tile.updateTile();
}
 
Example #26
Source File: AN2LinuxTileService.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick() {
    super.onClick();

    Context c = getApplicationContext();

    SharedPreferences sharedPrefsDefault = PreferenceManager.getDefaultSharedPreferences(c);
    boolean an2linuxEnabled = sharedPrefsDefault.getBoolean(c.getString(R.string.preference_enable_an2linux), false);

    Tile tile = getQsTile();
    SharedPreferences.Editor edit = sharedPrefsDefault.edit();

    if (an2linuxEnabled) {
        tile.setState(Tile.STATE_INACTIVE);
        edit.putBoolean(c.getString(R.string.preference_enable_an2linux), false);
    } else {
        tile.setState(Tile.STATE_ACTIVE);
        edit.putBoolean(c.getString(R.string.preference_enable_an2linux), true);
    }
    tile.updateTile();
    edit.apply();
}
 
Example #27
Source File: ki4aQuickSettingsService.java    From ki4a with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #28
Source File: ShadowsocksTileService.java    From ShadowsocksRR with Apache License 2.0 6 votes vote down vote up
@Override
public void stateChanged(int state, String profileName, String msg) throws RemoteException {
    Tile tile = getQsTile();
    if (tile != null) {
        switch (state) {
            case Constants.State.STOPPED:
                tile.setIcon(iconIdle);
                tile.setLabel(getString(R.string.app_name));
                tile.setState(Tile.STATE_INACTIVE);
                break;
            case Constants.State.CONNECTED:
                tile.setIcon(iconConnected);
                String label = profileName == null ? getString(R.string.app_name) : profileName;
                tile.setLabel(label);
                tile.setState(Tile.STATE_ACTIVE);
                break;
            default:
                tile.setIcon(iconBusy);
                tile.setLabel(getString(R.string.app_name));
                tile.setState(Tile.STATE_UNAVAILABLE);
                break;
        }
        tile.updateTile();
    }
}
 
Example #29
Source File: ServiceTileMain.java    From NetGuard with GNU General Public License v3.0 5 votes vote down vote up
private void update() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean enabled = prefs.getBoolean("enabled", false);
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
        tile.setIcon(Icon.createWithResource(this, enabled ? R.drawable.ic_security_white_24dp : R.drawable.ic_security_white_24dp_60));
        tile.updateTile();
    }
}
 
Example #30
Source File: MaskTileService.java    From Blackbulb with GNU General Public License v3.0 5 votes vote down vote up
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();
}