Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>

<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name="ShareActivity"
Expand Down Expand Up @@ -89,6 +93,14 @@
<data android:mimeType="video/*" />
</intent-filter>
</activity>
<activity
android:name=".EnableVpnShortcutActivity"
android:exported="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
android:name=".DisableVpnShortcutActivity"
android:exported="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />

<receiver
android:name="IPNReceiver"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

package com.tailscale.ipn;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

/**
* Activity to disable the Tailscale VPN via app shortcut.
* Sends a broadcast to IPNReceiver and finishes immediately.
*/
public class DisableVpnShortcutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent broadcastIntent = new Intent(IPNReceiver.INTENT_DISCONNECT_VPN);
broadcastIntent.setClass(this, IPNReceiver.class);
sendBroadcast(broadcastIntent);

finish(); // Close the activity immediately
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

package com.tailscale.ipn;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

/**
* Activity to enable the Tailscale VPN via app shortcut.
* Sends a broadcast to IPNReceiver and finishes immediately.
*/
public class EnableVpnShortcutActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent broadcastIntent = new Intent(IPNReceiver.INTENT_CONNECT_VPN);
broadcastIntent.setClass(this, IPNReceiver.class);
sendBroadcast(broadcastIntent);

finish(); // Close the activity immediately
}
}
6 changes: 6 additions & 0 deletions android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,10 @@
<string name="taildrop_directory_picker_info">What is taildrop?</string>
<string name="taildrop_directory_picker_button">Open Directory Picker</string>

<!-- Strings for shortcuts -->
<string name="shortcut_enable_vpn_short">Enable VPN</string>
<string name="shortcut_enable_vpn_long">Enable Tailscale VPN</string>
<string name="shortcut_disable_vpn_short">Disable VPN</string>
<string name="shortcut_disable_vpn_long">Disable Tailscale VPN</string>

</resources>
25 changes: 25 additions & 0 deletions android/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="enable_vpn"
android:enabled="true"
android:icon="@mipmap/ic_launcher"
android:shortcutShortLabel="@string/shortcut_enable_vpn_short"
android:shortcutLongLabel="@string/shortcut_enable_vpn_long">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.tailscale.ipn"
android:targetClass="com.tailscale.ipn.EnableVpnShortcutActivity" />
</shortcut>
<shortcut
android:shortcutId="disable_vpn"
android:enabled="true"
android:icon="@mipmap/ic_launcher"
android:shortcutShortLabel="@string/shortcut_disable_vpn_short"
android:shortcutLongLabel="@string/shortcut_disable_vpn_long">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.tailscale.ipn"
android:targetClass="com.tailscale.ipn.DisableVpnShortcutActivity" />
</shortcut>
</shortcuts>