Home / Specs / Quick Settings Tile
Settings v1.2.8

Quick Settings Tile

Android Quick Settings tile for keyboard switching

Quick Settings Tile

Overview

CleverKeys provides an Android Quick Settings tile that allows users to quickly access the keyboard switcher from the notification shade. Tapping the tile opens the system input method picker, providing a convenient way to switch between keyboards without navigating to system settings.

Key Files

FileClass/FunctionPurpose
src/main/kotlin/tribixbite/cleverkeys/KeyboardTileService.ktKeyboardTileServiceTileService implementation
AndroidManifest.xmlService registrationDeclares tile service

Architecture

Quick Settings Panel
       |
       v (user taps tile)
+------------------+
| KeyboardTile     | -- Android calls onClick()
| Service          |
+------------------+
       |
       v
+------------------+
| showInputMethod  | -- Opens system IME picker
| Picker()         |
+------------------+
       |
       v (fallback)
+------------------+
| Open Input       | -- If picker fails, opens settings
| Method Settings  |
+------------------+

Public API

KeyboardTileService

@RequiresApi(Build.VERSION_CODES.N)
class KeyboardTileService : TileService() {

    // Called when Quick Settings panel opens
    override fun onStartListening() {
        updateTileState()
    }

    // Called when user taps the tile
    override fun onClick() {
        showInputMethodPicker()
    }

    // Called when user adds tile to panel
    override fun onTileAdded() {
        updateTileState()
    }

    // Update tile visual state
    private fun updateTileState() {
        qsTile?.apply {
            state = if (isCleverKeysActive()) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
            updateTile()
        }
    }

    // Show system input method picker
    private fun showInputMethodPicker() {
        val imm = getSystemService(InputMethodManager::class.java)
        imm?.showInputMethodPicker()
    }
}

Implementation Details

Tile States

StateConditionVisual
STATE_ACTIVECleverKeys is current input methodHighlighted/colored
STATE_INACTIVEAnother keyboard is activeDimmed/gray

Input Method Detection

private fun isCleverKeysActive(): Boolean {
    val currentIme = Settings.Secure.getString(
        contentResolver,
        Settings.Secure.DEFAULT_INPUT_METHOD
    )
    return currentIme?.contains(packageName) == true
}

Fallback Behavior

If InputMethodManager.showInputMethodPicker() fails:

private fun showInputMethodPicker() {
    try {
        val imm = getSystemService(InputMethodManager::class.java)
        imm?.showInputMethodPicker()
    } catch (e: Exception) {
        // Fallback: open system input method settings
        val intent = Intent(Settings.ACTION_INPUT_METHOD_SETTINGS)
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
        startActivity(intent)
    }
}

AndroidManifest Registration

<service
    android:name="tribixbite.cleverkeys.KeyboardTileService"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
    android:exported="true">
  <intent-filter>
    <action android:name="android.service.quicksettings.action.QS_TILE"/>
  </intent-filter>
</service>

Requirements

User Flow