android: add quick setting tile support
Fixes tailscale/tailscale#516 Signed-off-by: Elias Naur <mail@eliasnaur.com>pull/3/head
parent
df1d8b338b
commit
bae9b8394a
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package com.tailscale.ipn;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.service.quicksettings.Tile;
|
||||||
|
import android.service.quicksettings.TileService;
|
||||||
|
|
||||||
|
public class QuickToggleService extends TileService {
|
||||||
|
private static boolean active;
|
||||||
|
|
||||||
|
@Override public void onStartListening() {
|
||||||
|
Tile t = getQsTile();
|
||||||
|
t.setState(active ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||||
|
t.updateTile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onClick() {
|
||||||
|
onTileClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setStatus(Context ctx, boolean wantRunning) {
|
||||||
|
active = wantRunning;
|
||||||
|
requestListeningState(ctx, new ComponentName(ctx, QuickToggleService.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void onTileClick();
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="60"
|
||||||
|
android:viewportHeight="60">
|
||||||
|
<group>
|
||||||
|
<path
|
||||||
|
android:pathData="M15,30.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#FFFDFA"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M30,30.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#FFFDFA"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M15,45.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#54514D"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M45,45.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#54514D"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M30,45.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#FFFDFA"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M45,30.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#FFFDFA"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M15,15.0002m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#54514D"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M30,14.9999m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#54514D"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M45,14.9999m-5,0a5,5 0,1 1,10 0a5,5 0,1 1,-10 0"
|
||||||
|
android:fillColor="#54514D"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Tailscale</string>
|
||||||
|
<string name="tile_name">Tailscale</string>
|
||||||
|
</resources>
|
||||||
Loading…
Reference in New Issue