Skip to content

Commit

Permalink
Merge pull request #4 from ai03-2725/master
Browse files Browse the repository at this point in the history
Add Android 12 style subtitles
  • Loading branch information
rostopira authored Nov 11, 2021
2 parents debefe5 + fad9e10 commit f7b5b65
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions app/src/main/java/n/eus/wifiqs/WifiTileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.net.wifi.WifiManager;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.os.Build;

public class WifiTileService extends TileService implements WifiStateListener {
WifiStateReceiver wifiStateReceiver;
Expand All @@ -25,17 +26,32 @@ public void onWifiStateChanged(WifiState state, String ssid) {
switch (state) {
case DISABLED:
tile.setIcon(Icon.createWithResource(this, R.drawable.disabled));
tile.setLabel("OFF");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
tile.setLabel("Wi-Fi");
tile.setSubtitle(("Off"));
} else {
tile.setLabel("OFF");
}
tile.setState(Tile.STATE_INACTIVE);
break;
case ENABLED:
tile.setIcon(Icon.createWithResource(this, R.drawable.enabled));
tile.setLabel("ON");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
tile.setLabel("Wi-Fi");
tile.setSubtitle(("Disconnected"));
} else {
tile.setLabel("ON");
}
tile.setState(Tile.STATE_ACTIVE);
break;
case CONNECTED:
tile.setIcon(Icon.createWithResource(this, R.drawable.connected));
tile.setLabel(ssid != null ? ssid : "CONNECTED");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
tile.setLabel(("Wi-Fi"));
tile.setSubtitle(ssid != null ? ssid : "Connected");
} else {
tile.setLabel(ssid != null ? ssid : "Connected");
}
tile.setState(Tile.STATE_ACTIVE);
break;
}
Expand Down

0 comments on commit f7b5b65

Please sign in to comment.