android app total redesign

This commit is contained in:
kulikov0 committed 2026-05-23 17:24:57 +02:00
1 parent c02843d6c3
commit c037fb211f
148 files changed
+5849 -1607

No files matched your search

+4 -2
View File
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<application
android:name=".App"
@@ -1,11 +1,25 @@
package bypass.whitelist
import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.ThemeMode
class App : Application() {
override fun onCreate() {
super.onCreate()
Prefs.init(this)
applyTheme(Prefs.themeMode)
}
companion object {
fun applyTheme(mode: ThemeMode) {
val target = when (mode) {
ThemeMode.SYSTEM -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
ThemeMode.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO
ThemeMode.DARK -> AppCompatDelegate.MODE_NIGHT_YES
}
AppCompatDelegate.setDefaultNightMode(target)
}
}
}
@@ -5,50 +5,68 @@ import android.content.pm.PackageManager
import android.net.VpnService
import android.os.Build
import android.os.Bundle
import android.util.TypedValue
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import bypass.whitelist.tunnel.CallConfig
import bypass.whitelist.tunnel.CallPlatform
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.HeadlessJoinController
import bypass.whitelist.tunnel.ProxyService
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.TunnelVpnService
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.ui.HeadlessDionFragment
import bypass.whitelist.ui.HeadlessTelemostFragment
import bypass.whitelist.ui.HeadlessWBStreamFragment
import bypass.whitelist.ui.LogsFragment
import bypass.whitelist.ui.HeadlessVkFragment
import bypass.whitelist.ui.JoinFragmentHost
import bypass.whitelist.ui.JsHookJoinFragment
import bypass.whitelist.ui.LogViewController
import bypass.whitelist.ui.SettingsDialogFragment
import bypass.whitelist.ui.StatusBarController
import bypass.whitelist.ui.MainActivityHost
import bypass.whitelist.ui.MainFragment
import bypass.whitelist.ui.SettingsScreenFragment
import bypass.whitelist.util.LogWriter
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.hideKeyboard
import bypass.whitelist.util.SocksAuth
import bypass.whitelist.util.maskUrl
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import bypass.whitelist.ui.CallsListener
import java.net.InetSocketAddress
import java.net.Socket
import kotlin.concurrent.thread
class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinFragmentHost {
class MainActivity :
AppCompatActivity(),
JoinFragmentHost,
MainActivityHost,
MainFragment.Host,
SettingsScreenFragment.Host,
LogsFragment.Host,
CallsListener {
private val logWriter by lazy { LogWriter(cacheDir) }
private lateinit var urlInput: EditText
private lateinit var logCtrl: LogViewController
private lateinit var statusCtrl: StatusBarController
private lateinit var logContainer: View
private lateinit var joinFragmentContainer: View
private lateinit var bottomNav: View
private lateinit var navMain: LinearLayout
private lateinit var navSettings: LinearLayout
private lateinit var navLogs: LinearLayout
private lateinit var tabContainer: View
private lateinit var subPageContainer: View
private lateinit var joinOverlayContainer: View
private lateinit var overlayLogs: View
private lateinit var overlayLogsText: TextView
private lateinit var overlayLogsScroll: android.widget.ScrollView
private var currentTabId: Int = 0
private var defaultLogHeightPx: Int = 0
private var previousUrl = ""
private var lastStatus: VpnStatus? = null
private var connected: Boolean = false
private var activeJoinUrl: String = ""
private var activeHeadlessController: HeadlessJoinController? = null
private val vpnPrepLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
@@ -58,53 +76,54 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == RESULT_OK) startVpnService()
else logCtrl.append("VPN permission denied")
else appendLog("VPN permission denied")
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
bottomNav = findViewById(R.id.bottomNav)
navMain = findViewById(R.id.navMain)
navSettings = findViewById(R.id.navSettings)
navLogs = findViewById(R.id.navLogs)
tabContainer = findViewById(R.id.tabContainer)
subPageContainer = findViewById(R.id.subPageContainer)
joinOverlayContainer = findViewById(R.id.joinOverlayContainer)
overlayLogs = findViewById(R.id.overlayLogs)
overlayLogsText = findViewById(R.id.overlayLogsText)
overlayLogsScroll = findViewById(R.id.overlayLogsScroll)
findViewById<View>(R.id.overlayCopyButton).setOnClickListener { copyLogs() }
findViewById<View>(R.id.overlayShareButton).setOnClickListener { shareLogs() }
val baseTabPaddingTop = tabContainer.paddingTop
val bottomWrap = findViewById<View>(R.id.bottomWrap)
val baseBottomWrapPaddingBottom = bottomWrap.paddingBottom
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { _, insets ->
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
tabContainer.setPadding(bars.left, baseTabPaddingTop + bars.top, bars.right, 0)
subPageContainer.setPadding(bars.left, bars.top, bars.right, 0)
joinOverlayContainer.setPadding(bars.left, bars.top, bars.right, 0)
bottomWrap.setPadding(
bars.left,
0,
bars.right,
baseBottomWrapPaddingBottom + bars.bottom
)
insets
}
urlInput = findViewById(R.id.urlInput)
logContainer = findViewById(R.id.logContainer)
joinFragmentContainer = findViewById(R.id.joinFragmentContainer)
defaultLogHeightPx = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 120f, resources.displayMetrics
).toInt()
navMain.setOnClickListener { selectNavTab(R.id.navMain) }
navSettings.setOnClickListener { selectNavTab(R.id.navSettings) }
navLogs.setOnClickListener { selectNavTab(R.id.navLogs) }
logCtrl = LogViewController(this, findViewById(R.id.logView), logWriter)
logCtrl.reset()
val restoredTabId =
savedInstanceState?.getInt(STATE_CURRENT_TAB_ID, R.id.navMain) ?: R.id.navMain
selectNavTab(restoredTabId)
statusCtrl = StatusBarController(
activity = this,
statusBar = findViewById(R.id.statusBar),
goButton = findViewById(R.id.goButton),
onConnect = ::onGoPressed,
onDisconnect = ::fullReset,
)
previousUrl = Prefs.lastUrl
urlInput.setText(previousUrl)
statusCtrl.tunnelMode = Prefs.tunnelMode
statusCtrl.setIdle()
logContainer.visibility = if (Prefs.showLogs) View.VISIBLE else View.GONE
findViewById<Button>(R.id.goButton).setOnClickListener { onGoPressed() }
findViewById<ImageButton>(R.id.shareLogsButton).setOnClickListener { logCtrl.shareLogs() }
findViewById<ImageButton>(R.id.copyLogsButton).setOnClickListener { logCtrl.copyLogs() }
findViewById<ImageButton>(R.id.gearButton).setOnClickListener {
SettingsDialogFragment().show(supportFragmentManager, SettingsDialogFragment.TAG)
}
findViewById<View>(R.id.clearButton).setOnClickListener { urlInput.setText("") }
TunnelVpnService.onDisconnect = { runOnUiThread { resetState() } }
ProxyService.onDisconnect = { runOnUiThread { resetState() } }
TunnelVpnService.onDisconnect = { runOnUiThread { onDisconnectFromService() } }
ProxyService.onDisconnect = { runOnUiThread { onDisconnectFromService() } }
VpnService.prepare(this)?.let { vpnPrepLauncher.launch(it) }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
@@ -114,79 +133,301 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
}
if (CALL_LINK.isNotEmpty()) {
urlInput.setText(CALL_LINK)
onGoPressed()
} else if (Prefs.connectOnStart && previousUrl.isNotEmpty()) {
onGoPressed()
startJoinFor(CallConfig.newWith(name = CallConfig.suggestNameFor(CALL_LINK), url = CALL_LINK))
} else if (Prefs.connectOnStart) {
val active = Prefs.activeDestination
if (active != null) startJoinFor(active)
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putInt(STATE_CURRENT_TAB_ID, currentTabId)
}
override fun onDestroy() {
TunnelVpnService.onDisconnect = null
TunnelVpnService.instance?.stop()
ProxyService.onDisconnect = null
ProxyService.instance?.stop()
logCtrl.close()
logWriter.close()
super.onDestroy()
}
override fun onTunnelModeChanged(mode: TunnelMode) {
statusCtrl.tunnelMode = mode
fullReset()
}
override fun onShowLogsChanged(visible: Boolean) {
logContainer.visibility = if (visible) View.VISIBLE else View.GONE
}
private fun setLogFullscreen(fullscreen: Boolean) {
val logLp = logContainer.layoutParams as LinearLayout.LayoutParams
val joinLp = joinFragmentContainer.layoutParams as LinearLayout.LayoutParams
if (fullscreen) {
logLp.height = 0
logLp.weight = 1f
joinLp.height = 0
joinLp.weight = 0f
logContainer.visibility = View.VISIBLE
} else {
logLp.height = defaultLogHeightPx
logLp.weight = 0f
joinLp.height = 0
joinLp.weight = 1f
logContainer.visibility = if (Prefs.showLogs) View.VISIBLE else View.GONE
private fun selectNavTab(itemId: Int) {
if (currentTabId == itemId) return
currentTabId = itemId
dismissSubPage()
when (itemId) {
R.id.navMain -> showTab(MainFragment::class.java)
R.id.navSettings -> showTab(SettingsScreenFragment::class.java)
R.id.navLogs -> showTab(LogsFragment::class.java)
}
logContainer.layoutParams = logLp
joinFragmentContainer.layoutParams = joinLp
updateNavSelection(itemId)
}
override fun onShareLogs() {
logCtrl.shareLogs()
private fun updateNavSelection(itemId: Int) {
val transparent = android.graphics.Color.TRANSPARENT
val activeBg = R.drawable.bg_nav_item_active
val accent = getColor(R.color.accent_emerald)
val ink3 = getColor(R.color.ink_3)
listOf(navMain, navSettings, navLogs).forEach { it.setBackgroundColor(transparent) }
findViewById<ImageView>(R.id.navMainIcon).setColorFilter(ink3)
findViewById<ImageView>(R.id.navSettingsIcon).setColorFilter(ink3)
findViewById<ImageView>(R.id.navLogsIcon).setColorFilter(ink3)
findViewById<TextView>(R.id.navMainLabel).apply {
setTextColor(ink3); setTypeface(typeface, android.graphics.Typeface.NORMAL)
}
findViewById<TextView>(R.id.navSettingsLabel).apply {
setTextColor(ink3); setTypeface(typeface, android.graphics.Typeface.NORMAL)
}
findViewById<TextView>(R.id.navLogsLabel).apply {
setTextColor(ink3); setTypeface(typeface, android.graphics.Typeface.NORMAL)
}
val activeContainer = when (itemId) {
R.id.navMain -> navMain
R.id.navSettings -> navSettings
R.id.navLogs -> navLogs
else -> null
} ?: return
activeContainer.setBackgroundResource(activeBg)
val activeIcon = when (itemId) {
R.id.navMain -> R.id.navMainIcon
R.id.navSettings -> R.id.navSettingsIcon
R.id.navLogs -> R.id.navLogsIcon
else -> 0
}
val activeLabel = when (itemId) {
R.id.navMain -> R.id.navMainLabel
R.id.navSettings -> R.id.navSettingsLabel
R.id.navLogs -> R.id.navLogsLabel
else -> 0
}
findViewById<ImageView>(activeIcon).setColorFilter(accent)
findViewById<TextView>(activeLabel).apply {
setTextColor(accent)
setTypeface(typeface, android.graphics.Typeface.BOLD)
}
}
override fun onReset() {
private fun showTab(cls: Class<out Fragment>) {
val tag = cls.name
val existing = supportFragmentManager.findFragmentByTag(tag)
val tx = supportFragmentManager.beginTransaction()
supportFragmentManager.fragments
.filter { it.id == R.id.tabContainer && it.tag != tag }
.forEach { tx.hide(it) }
if (existing == null) {
tx.add(R.id.tabContainer, cls.getDeclaredConstructor().newInstance(), tag)
} else {
tx.show(existing)
if (existing is LogsFragment) existing.refresh()
}
tx.commit()
}
private fun mainFragment(): MainFragment? =
supportFragmentManager.findFragmentByTag(MainFragment::class.java.name) as? MainFragment
private fun logsFragment(): LogsFragment? =
supportFragmentManager.findFragmentByTag(LogsFragment::class.java.name) as? LogsFragment
override fun onConnectPressed(config: CallConfig) {
startJoinFor(config)
}
override fun onDisconnectPressed() {
fullReset()
}
override fun onPingPressed(callback: (Boolean, Int) -> Unit) {
thread {
val started = System.nanoTime()
val ok = try {
probeViaSocks5(host = "ya.ru", port = 443)
} catch (_: Exception) {
false
}
val rtt = ((System.nanoTime() - started) / 1_000_000).toInt()
runOnUiThread { callback(ok, rtt) }
}
}
private fun probeViaSocks5(host: String, port: Int): Boolean {
Socket().use { socket ->
socket.connect(InetSocketAddress("127.0.0.1", Prefs.socksPort.toInt()), 5000)
socket.soTimeout = 15000
val output = socket.getOutputStream()
val input = socket.getInputStream()
output.write(byteArrayOf(0x05, 0x01, 0x02))
output.flush()
if (input.read() != 0x05 || input.read() != 0x02) return false
val userBytes = SocksAuth.user.toByteArray(Charsets.US_ASCII)
val passBytes = SocksAuth.pass.toByteArray(Charsets.US_ASCII)
val authPacket = ByteArray(3 + userBytes.size + passBytes.size)
authPacket[0] = 0x01
authPacket[1] = userBytes.size.toByte()
System.arraycopy(userBytes, 0, authPacket, 2, userBytes.size)
authPacket[2 + userBytes.size] = passBytes.size.toByte()
System.arraycopy(passBytes, 0, authPacket, 3 + userBytes.size, passBytes.size)
output.write(authPacket)
output.flush()
if (input.read() != 0x01 || input.read() != 0x00) return false
val hostBytes = host.toByteArray(Charsets.US_ASCII)
val request = ByteArray(4 + 1 + hostBytes.size + 2)
request[0] = 0x05; request[1] = 0x01; request[2] = 0x00; request[3] = 0x03
request[4] = hostBytes.size.toByte()
System.arraycopy(hostBytes, 0, request, 5, hostBytes.size)
request[5 + hostBytes.size] = ((port shr 8) and 0xff).toByte()
request[6 + hostBytes.size] = (port and 0xff).toByte()
output.write(request)
output.flush()
return input.read() == 0x05 && input.read() == 0x00
}
}
override fun isTunnelActive(): Boolean = connected
override fun currentStatus(): VpnStatus? = lastStatus
override fun onDestinationSelected(config: CallConfig) {
Prefs.activeDestinationId = config.id
mainFragment()?.onDestinationsChanged()
}
override fun onDestinationsChanged() {
mainFragment()?.onDestinationsChanged()
}
override fun onTunnelModeChanged(mode: TunnelMode) {
fullReset()
}
override fun onForgetAllDestinations() {
Prefs.savedDestinations = emptyList()
Prefs.activeDestinationId = ""
mainFragment()?.onDestinationsChanged()
Toast.makeText(this, R.string.settings_toast_destinations_cleared, Toast.LENGTH_SHORT)
.show()
}
override fun onResetAllSettings() {
Prefs.resetAllSettings()
App.applyTheme(Prefs.themeMode)
(supportFragmentManager.findFragmentByTag(SettingsScreenFragment::class.java.name) as? SettingsScreenFragment)?.refresh()
Toast.makeText(this, R.string.settings_toast_reset_done, Toast.LENGTH_SHORT).show()
}
override fun activityLogLines(): List<String> {
val text = logWriter.displayText()
if (text.isEmpty()) return emptyList()
return text.split('\n').filter { it.isNotBlank() }
}
override fun copyLogs() {
val contents =
if (logWriter.file.exists()) logWriter.file.readText() else logWriter.displayText()
val clipboard =
getSystemService(android.content.Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
clipboard.setPrimaryClip(android.content.ClipData.newPlainText("relay.log", contents))
Toast.makeText(this, R.string.copy_logs_toast, Toast.LENGTH_SHORT).show()
}
override fun shareLogs() {
val uri = androidx.core.content.FileProvider.getUriForFile(
this, "${packageName}.fileprovider", logWriter.file
)
val share = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_STREAM, uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
startActivity(Intent.createChooser(share, getString(R.string.share_logs)))
}
override fun appendLog(message: String) {
logCtrl.append(message)
val (line, _) = logWriter.append(message)
runOnUiThread {
logsFragment()?.onLineAppended(line)
if (overlayLogs.isVisible) {
overlayLogsText.append("$line\n")
overlayLogsScroll.post { overlayLogsScroll.fullScroll(View.FOCUS_DOWN) }
}
}
}
override fun onJoinStatusText(text: String) {
runOnUiThread { statusCtrl.setStatusText(text) }
runOnUiThread { mainFragment()?.onStatusTextChanged(text) }
}
override fun onJoinStatus(status: VpnStatus) {
TunnelVpnService.instance?.updateStatus(status)
ProxyService.instance?.updateStatus(status)
lastStatus = status
runOnUiThread {
statusCtrl.setStatus(status)
if (status == VpnStatus.TUNNEL_ACTIVE) statusCtrl.setConnected(true)
mainFragment()?.onStatusChanged(status)
if (status == VpnStatus.TUNNEL_ACTIVE) {
connected = true
mainFragment()?.onConnectedChanged(true)
}
}
}
override fun pushSubPage(fragment: Fragment) {
subPageContainer.visibility = View.VISIBLE
supportFragmentManager.beginTransaction()
.replace(R.id.subPageContainer, fragment, SUB_PAGE_TAG)
.addToBackStack(SUB_PAGE_TAG)
.commit()
}
override fun popSubPage() {
if (supportFragmentManager.popBackStackImmediate(
SUB_PAGE_TAG,
androidx.fragment.app.FragmentManager.POP_BACK_STACK_INCLUSIVE
)
) {
// popped
}
subPageContainer.visibility = View.GONE
}
private fun dismissSubPage() {
if (supportFragmentManager.backStackEntryCount > 0) {
supportFragmentManager.popBackStack(
SUB_PAGE_TAG,
androidx.fragment.app.FragmentManager.POP_BACK_STACK_INCLUSIVE
)
}
subPageContainer.visibility = View.GONE
}
override fun onJoinCancel() {
runOnUiThread { fullReset() }
}
override fun setJoinUiVisible(visible: Boolean) {
runOnUiThread { setJoinOverlayVisible(visible) }
}
private fun setJoinOverlayVisible(visible: Boolean) {
joinOverlayContainer.visibility = if (visible) View.VISIBLE else View.GONE
overlayLogs.visibility = if (visible) View.VISIBLE else View.GONE
bottomNav.visibility = if (visible) View.GONE else View.VISIBLE
if (visible) {
overlayLogsText.text = logWriter.displayText()
overlayLogsScroll.post { overlayLogsScroll.fullScroll(View.FOCUS_DOWN) }
}
}
override fun requestVpn() {
if (Prefs.proxyOnly) {
logCtrl.append("Proxy only mode, skipping VPN")
appendLog("Proxy only mode, skipping VPN")
startService(Intent(this, ProxyService::class.java))
onJoinStatus(VpnStatus.TUNNEL_ACTIVE)
return
@@ -195,69 +436,85 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
if (intent != null) vpnLauncher.launch(intent) else startVpnService()
}
private fun onGoPressed() {
val url = urlInput.text.toString().trim()
private fun startJoinFor(config: CallConfig) {
val url = config.url.trim()
if (url.isEmpty()) return
val platform = CallPlatform.fromUrl(url)
val platform = config.platform
if (Prefs.tunnelMode == TunnelMode.DC && (platform == CallPlatform.TELEMOST || platform == CallPlatform.DION)) {
Prefs.tunnelMode = TunnelMode.VIDEO
statusCtrl.tunnelMode = TunnelMode.VIDEO
Toast.makeText(this, R.string.dc_mode_not_supported, Toast.LENGTH_SHORT).show()
}
logCtrl.reset()
hideKeyboard()
urlInput.clearFocus()
statusCtrl.setConnected(false)
statusCtrl.setStatus(VpnStatus.CONNECTING)
logCtrl.append("Loading: ${maskUrl(url)}")
if (previousUrl != url) {
previousUrl = url
Prefs.lastUrl = url
if (connected) {
fullReset()
}
val headlessMode = Prefs.headless || platform == CallPlatform.WBSTREAM || platform == CallPlatform.DION
val fragment = if (headlessMode) {
when (platform) {
CallPlatform.VK -> HeadlessVkFragment.newInstance(url)
CallPlatform.TELEMOST -> HeadlessTelemostFragment.newInstance(url)
CallPlatform.WBSTREAM -> HeadlessWBStreamFragment.newInstance(url)
CallPlatform.DION -> HeadlessDionFragment.newInstance(url)
}
activeJoinUrl = url
logWriter.reset()
runOnUiThread { logsFragment()?.refresh() }
appendLog("Loading: ${maskUrl(url)}")
lastStatus = VpnStatus.CONNECTING
mainFragment()?.onStatusChanged(VpnStatus.CONNECTING)
mainFragment()?.onConnectedChanged(false)
val headlessMode =
Prefs.headless || platform == CallPlatform.WBSTREAM || platform == CallPlatform.DION
if (headlessMode && platform != CallPlatform.VK) {
setJoinOverlayVisible(false)
activeHeadlessController = HeadlessJoinController(
applicationInfo.nativeLibraryDir, this, platform, url,
).also { it.start() }
return
}
val joinFragment = if (headlessMode) {
HeadlessVkFragment.newInstance(url)
} else {
JsHookJoinFragment.newInstance(url)
}
setLogFullscreen(headlessMode && platform != CallPlatform.VK)
setJoinOverlayVisible(!headlessMode)
supportFragmentManager.beginTransaction()
.replace(R.id.joinFragmentContainer, fragment)
.replace(R.id.joinOverlayContainer, joinFragment)
.commit()
}
private fun startVpnService() {
startService(Intent(this, TunnelVpnService::class.java))
logCtrl.append("VPN started")
appendLog("VPN started")
onJoinStatus(VpnStatus.TUNNEL_ACTIVE)
}
private fun resetState() {
private fun onDisconnectFromService() {
connected = false
lastStatus = null
closeActiveHeadlessController()
removeJoinFragment()
setLogFullscreen(false)
logCtrl.reset()
statusCtrl.setConnected(false)
statusCtrl.setIdle()
setJoinOverlayVisible(false)
mainFragment()?.onConnectedChanged(false)
mainFragment()?.onStatusChanged(VpnStatus.CALL_DISCONNECTED)
}
private fun fullReset() {
resetState()
connected = false
lastStatus = null
closeActiveHeadlessController()
removeJoinFragment()
setJoinOverlayVisible(false)
mainFragment()?.onConnectedChanged(false)
TunnelVpnService.instance?.stop()
ProxyService.instance?.stop()
}
private fun closeActiveHeadlessController() {
activeHeadlessController?.close()
activeHeadlessController = null
}
private fun removeJoinFragment() {
val fragment = supportFragmentManager.findFragmentById(R.id.joinFragmentContainer)
val fragment = supportFragmentManager.findFragmentById(R.id.joinOverlayContainer)
if (fragment != null) {
supportFragmentManager.beginTransaction()
.remove(fragment)
@@ -266,6 +523,8 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
}
companion object {
private const val SUB_PAGE_TAG = "sub_page"
private const val STATE_CURRENT_TAB_ID = "current_tab_id"
private const val CALL_LINK = "" // Open call page on app start (do not delete - I need it for debug)
}
}
@@ -0,0 +1,73 @@
package bypass.whitelist.tunnel
import org.json.JSONArray
import org.json.JSONObject
import java.util.UUID
data class CallConfig(
val id: String,
val name: String,
val url: String,
) {
val platform: CallPlatform get() = CallPlatform.fromUrl(url)
val platformGlyph: String get() = when (platform) {
CallPlatform.VK -> "VK"
CallPlatform.TELEMOST -> "TM"
CallPlatform.WBSTREAM -> "WB"
CallPlatform.DION -> "DN"
}
val platformLabel: String get() = when (platform) {
CallPlatform.VK -> "VK"
CallPlatform.TELEMOST -> "Telemost"
CallPlatform.WBSTREAM -> "WB Stream"
CallPlatform.DION -> "DION"
}
fun toJson(): JSONObject = JSONObject().apply {
put("id", id)
put("name", name)
put("url", url)
}
companion object {
fun newWith(name: String, url: String): CallConfig =
CallConfig(id = UUID.randomUUID().toString(), name = name, url = url)
fun fromJson(obj: JSONObject): CallConfig = CallConfig(
id = obj.getString("id"),
name = obj.getString("name"),
url = obj.getString("url"),
)
fun listToJson(items: List<CallConfig>): String {
val arr = JSONArray()
items.forEach { arr.put(it.toJson()) }
return arr.toString()
}
fun listFromJson(raw: String): List<CallConfig> {
if (raw.isBlank()) return emptyList()
return try {
val arr = JSONArray(raw)
buildList(arr.length()) {
for (i in 0 until arr.length()) add(fromJson(arr.getJSONObject(i)))
}
} catch (_: Exception) {
emptyList()
}
}
fun suggestNameFor(url: String): String {
val platform = CallPlatform.fromUrl(url)
val label = when (platform) {
CallPlatform.VK -> "VK call"
CallPlatform.TELEMOST -> "Telemost"
CallPlatform.WBSTREAM -> "WB Stream"
CallPlatform.DION -> "DION"
}
return label
}
}
}
@@ -0,0 +1,61 @@
package bypass.whitelist.tunnel
import android.os.Handler
import android.os.Looper
import android.util.Log
import bypass.whitelist.ui.JoinFragmentHost
import bypass.whitelist.util.Prefs
import org.json.JSONObject
class HeadlessJoinController(
nativeLibraryDir: String,
private val host: JoinFragmentHost,
private val platform: CallPlatform,
private val url: String,
) : AutoCloseable {
private val mainHandler = Handler(Looper.getMainLooper())
private val relay: HeadlessRelayController = HeadlessRelayController(
nativeLibraryDir,
relayMode = "${platform.id}-headless-joiner",
onLog = { host.appendLog(it) },
onStatus = ::handleStatus,
)
fun start() {
relay.start()
}
private fun handleStatus(status: VpnStatus) {
Log.d(LOG_TAG, "status: $status")
host.onJoinStatus(status)
when (status) {
VpnStatus.STARTING -> relay.sendJoinParams(buildJoinParams().toString())
VpnStatus.TUNNEL_ACTIVE -> mainHandler.post { host.requestVpn() }
else -> {}
}
}
private fun buildJoinParams(): JSONObject = JSONObject().apply {
put("displayName", Prefs.autofillName)
put("vp8Fps", Prefs.vp8Fps)
put("vp8Batch", Prefs.vp8Batch)
when (platform) {
CallPlatform.TELEMOST -> put("joinLink", url)
CallPlatform.WBSTREAM -> {
put("roomId", CallPlatform.extractRoomId(url))
put("tunnelMode", Prefs.tunnelMode.relayArg)
}
CallPlatform.DION -> put("roomId", CallPlatform.extractRoomId(url))
CallPlatform.VK -> error("VK headless flow uses HeadlessVkFragment for captcha UI")
}
}
override fun close() {
relay.stop()
}
private companion object {
const val LOG_TAG = "HeadlessJoinController"
}
}
@@ -8,4 +8,11 @@ enum class TunnelMode(val label: String, val relayArg: String, val isPion: Boole
if (!isPion) return "dc-joiner"
return "${platform.id}-$relayArg-joiner"
}
fun effectiveFor(platform: CallPlatform): TunnelMode {
if (this == DC && (platform == CallPlatform.TELEMOST || platform == CallPlatform.DION)) {
return VIDEO
}
return this
}
}
@@ -0,0 +1,87 @@
package bypass.whitelist.ui
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.fragment.app.FragmentManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.CallConfig
import bypass.whitelist.util.Prefs
class AddDestinationSheet : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_add_destination, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val inputName = view.findViewById<EditText>(R.id.inputName)
val inputLink = view.findViewById<EditText>(R.id.inputLink)
val pasteChip = view.findViewById<LinearLayout>(R.id.pasteChip)
val pasteChipLabel = view.findViewById<TextView>(R.id.pasteChipLabel)
val buttonCancel = view.findViewById<Button>(R.id.buttonCancel)
val buttonSave = view.findViewById<Button>(R.id.buttonSave)
pasteChip.setOnClickListener {
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = clipboard.primaryClip
val text = clip?.takeIf { it.itemCount > 0 }?.getItemAt(0)?.coerceToText(requireContext())?.toString().orEmpty().trim()
if (text.isEmpty()) {
Toast.makeText(requireContext(), R.string.clipboard_empty, Toast.LENGTH_SHORT).show()
return@setOnClickListener
}
inputLink.setText(text)
if (inputName.text.toString().trim().isEmpty()) {
inputName.setText(CallConfig.suggestNameFor(text))
}
flashChip(pasteChip, pasteChipLabel)
}
buttonCancel.setOnClickListener { dismiss() }
buttonSave.setOnClickListener {
val link = inputLink.text.toString().trim()
if (link.isEmpty()) {
inputLink.requestFocus()
return@setOnClickListener
}
val name = inputName.text.toString().trim().ifEmpty { CallConfig.suggestNameFor(link) }
val config = CallConfig.newWith(name = name, url = link)
Prefs.addDestination(config)
(parentFragment as? CallsListener)?.onDestinationsChanged()
(activity as? CallsListener)?.onDestinationsChanged()
(activity as? CallsListener)?.onDestinationSelected(config)
dismiss()
}
}
private fun flashChip(chip: LinearLayout, label: TextView) {
chip.setBackgroundResource(R.drawable.bg_paste_chip_flash)
label.setTextColor(requireContext().getColor(R.color.accent_emerald))
chip.postDelayed({
if (isAdded) {
chip.setBackgroundResource(R.drawable.bg_paste_chip)
label.setTextColor(requireContext().getColor(R.color.ink_2))
}
}, 320)
}
companion object {
const val TAG = "AddDestinationSheet"
fun show(manager: FragmentManager) {
AddDestinationSheet().show(manager, TAG)
}
}
}
@@ -0,0 +1,57 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import bypass.whitelist.util.Prefs
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
import com.google.android.material.materialswitch.MaterialSwitch
class AutofillActionSheet : BottomSheetDialogFragment() {
private var onSaved: Callback? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_autofill, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
view.findViewById<View>(R.id.autofillNameCard).clipToOutline = true
val switch = view.findViewById<MaterialSwitch>(R.id.autofillSwitch)
val nameInput = view.findViewById<EditText>(R.id.autofillNameInput)
val randomBtn = view.findViewById<MaterialButton>(R.id.autofillRandomButton)
val cancelBtn = view.findViewById<MaterialButton>(R.id.autofillCancelButton)
val saveBtn = view.findViewById<MaterialButton>(R.id.autofillSaveButton)
switch.isChecked = Prefs.autofillEnabled
nameInput.setText(Prefs.autofillName)
randomBtn.setOnClickListener {
val names = requireContext().assets.open("names.txt").bufferedReader().readLines()
if (names.isNotEmpty()) nameInput.setText(names.random())
}
cancelBtn.setOnClickListener { dismiss() }
saveBtn.setOnClickListener {
Prefs.autofillEnabled = switch.isChecked
Prefs.autofillName = nameInput.text.toString().trim()
onSaved?.invoke()
dismiss()
}
}
companion object {
fun show(manager: FragmentManager, onSaved: Callback) {
AutofillActionSheet().apply {
this.onSaved = onSaved
}.show(manager, "AutofillActionSheet")
}
}
}
@@ -0,0 +1,8 @@
package bypass.whitelist.ui
import bypass.whitelist.tunnel.CallConfig
interface CallsListener {
fun onDestinationSelected(config: CallConfig)
fun onDestinationsChanged()
}
@@ -0,0 +1,95 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.ParamCallback
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
class ChoiceActionSheet : BottomSheetDialogFragment() {
data class Option(val id: String, val title: String, val sub: String? = null)
private var titleText: String = ""
private var subtitleText: String? = null
private var options: List<Option> = emptyList()
private var selectedId: String? = null
private var onSelect: ParamCallback<Option>? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_choice, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val titleView = view.findViewById<TextView>(R.id.sheetTitle)
val subtitleView = view.findViewById<TextView>(R.id.sheetSubtitle)
val optionsContainer = view.findViewById<LinearLayout>(R.id.optionsContainer)
titleView.text = titleText
if (subtitleText.isNullOrBlank()) {
subtitleView.visibility = View.GONE
} else {
subtitleView.text = subtitleText
subtitleView.visibility = View.VISIBLE
}
val inflater = LayoutInflater.from(requireContext())
options.forEach { option ->
val row = inflater.inflate(R.layout.item_action_option, optionsContainer, false)
row.clipToOutline = true
val rowTitle = row.findViewById<TextView>(R.id.actionOptionTitle)
val rowSub = row.findViewById<TextView>(R.id.actionOptionSub)
val checkBox = row.findViewById<View>(R.id.actionOptionCheckBox)
val checkIcon = row.findViewById<ImageView>(R.id.actionOptionCheckIcon)
rowTitle.text = option.title
if (option.sub.isNullOrBlank()) {
rowSub.visibility = View.GONE
} else {
rowSub.text = option.sub
rowSub.visibility = View.VISIBLE
}
val isSelected = option.id == selectedId
if (isSelected) {
row.setBackgroundResource(R.drawable.bg_destination_card_active)
checkBox.setBackgroundResource(R.drawable.bg_action_check_active)
checkIcon.visibility = View.VISIBLE
rowTitle.setTextColor(requireContext().getColor(R.color.accent_emerald))
}
row.setOnClickListener {
onSelect?.invoke(option)
dismiss()
}
optionsContainer.addView(row)
}
}
companion object {
fun show(
manager: FragmentManager,
title: String,
subtitle: String? = null,
options: List<Option>,
selectedId: String?,
onSelect: ParamCallback<Option>,
) {
ChoiceActionSheet().apply {
this.titleText = title
this.subtitleText = subtitle
this.options = options
this.selectedId = selectedId
this.onSelect = onSelect
}.show(manager, "ChoiceActionSheet")
}
}
}
@@ -0,0 +1,75 @@
package bypass.whitelist.ui
import android.content.res.ColorStateList
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
class ConfirmActionSheet : BottomSheetDialogFragment() {
private var titleText: String = ""
private var subtitleText: String = ""
private var confirmLabel: String = ""
private var cancelLabel: String = ""
private var destructive: Boolean = false
private var onConfirm: Callback? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_confirm, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val titleView = view.findViewById<TextView>(R.id.sheetTitle)
val subView = view.findViewById<TextView>(R.id.sheetSubtitle)
val cancel = view.findViewById<MaterialButton>(R.id.buttonCancel)
val confirm = view.findViewById<MaterialButton>(R.id.buttonConfirm)
titleView.text = titleText
subView.text = subtitleText
cancel.text = cancelLabel
confirm.text = confirmLabel
if (destructive) {
val context = requireContext()
titleView.setTextColor(context.getColor(R.color.error_red))
confirm.backgroundTintList = ColorStateList.valueOf(context.getColor(R.color.error_red))
confirm.setTextColor(context.getColor(R.color.panel_bg))
}
cancel.setOnClickListener { dismiss() }
confirm.setOnClickListener {
onConfirm?.invoke()
dismiss()
}
}
companion object {
fun show(
manager: FragmentManager,
title: String,
subtitle: String,
confirmLabel: String,
cancelLabel: String = "Cancel",
destructive: Boolean = false,
onConfirm: Callback,
) {
ConfirmActionSheet().apply {
this.titleText = title
this.subtitleText = subtitle
this.confirmLabel = confirmLabel
this.cancelLabel = cancelLabel
this.destructive = destructive
this.onConfirm = onConfirm
}.show(manager, "ConfirmActionSheet")
}
}
}
@@ -0,0 +1,96 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import bypass.whitelist.util.DnsMode
import bypass.whitelist.util.Prefs
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
class DnsActionSheet : BottomSheetDialogFragment() {
private var onSaved: Callback? = null
private var selectedMode: DnsMode = DnsMode.SYSTEM
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_dns, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
selectedMode = Prefs.dnsMode
val modeContainer = view.findViewById<LinearLayout>(R.id.dnsModeContainer)
val customFields = view.findViewById<LinearLayout>(R.id.dnsCustomFields)
val primary = view.findViewById<EditText>(R.id.dnsPrimaryInput)
val secondary = view.findViewById<EditText>(R.id.dnsSecondaryInput)
primary.setText(Prefs.dnsPrimary)
secondary.setText(Prefs.dnsSecondary)
customFields.visibility = if (selectedMode == DnsMode.CUSTOM) View.VISIBLE else View.GONE
val inflater = LayoutInflater.from(requireContext())
val rowViews = mutableMapOf<DnsMode, View>()
DnsMode.entries.forEach { mode ->
val row = inflater.inflate(R.layout.item_action_option, modeContainer, false)
row.clipToOutline = true
row.findViewById<TextView>(R.id.actionOptionTitle).text = mode.label
row.findViewById<TextView>(R.id.actionOptionSub).visibility = View.GONE
row.setOnClickListener {
selectedMode = mode
updateModeSelection(rowViews)
customFields.visibility = if (mode == DnsMode.CUSTOM) View.VISIBLE else View.GONE
}
modeContainer.addView(row)
rowViews[mode] = row
}
updateModeSelection(rowViews)
view.findViewById<MaterialButton>(R.id.dnsCancelButton).setOnClickListener { dismiss() }
view.findViewById<MaterialButton>(R.id.dnsSaveButton).setOnClickListener {
Prefs.dnsMode = selectedMode
if (selectedMode == DnsMode.CUSTOM) {
Prefs.dnsPrimary = primary.text.toString().trim()
Prefs.dnsSecondary = secondary.text.toString().trim()
}
onSaved?.invoke()
dismiss()
}
}
private fun updateModeSelection(rowViews: Map<DnsMode, View>) {
val context = requireContext()
rowViews.forEach { (mode, row) ->
val isActive = mode == selectedMode
val titleView = row.findViewById<TextView>(R.id.actionOptionTitle)
val checkBox = row.findViewById<View>(R.id.actionOptionCheckBox)
val checkIcon = row.findViewById<ImageView>(R.id.actionOptionCheckIcon)
if (isActive) {
row.setBackgroundResource(R.drawable.bg_destination_card_active)
checkBox.setBackgroundResource(R.drawable.bg_action_check_active)
checkIcon.visibility = View.VISIBLE
titleView.setTextColor(context.getColor(R.color.accent_emerald))
} else {
row.setBackgroundResource(R.drawable.bg_destination_card)
checkBox.setBackgroundResource(R.drawable.bg_action_check_idle)
checkIcon.visibility = View.GONE
titleView.setTextColor(context.getColor(R.color.ink))
}
}
}
companion object {
fun show(manager: FragmentManager, onSaved: Callback) {
DnsActionSheet().apply { this.onSaved = onSaved }.show(manager, "DnsActionSheet")
}
}
}
@@ -1,56 +0,0 @@
package bypass.whitelist.ui
import android.app.Dialog
import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import bypass.whitelist.R
import bypass.whitelist.util.DnsMode
import bypass.whitelist.util.Prefs
class DnsSettingsDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val view = layoutInflater.inflate(R.layout.dialog_dns_settings, null)
val dnsModeGroup = view.findViewById<RadioGroup>(R.id.dnsModeGroup)
val dnsModeSystem = view.findViewById<RadioButton>(R.id.dnsModeSystem)
val dnsModeCustom = view.findViewById<RadioButton>(R.id.dnsModeCustom)
val customDnsContainer = view.findViewById<View>(R.id.customDnsContainer)
val primaryInput = view.findViewById<EditText>(R.id.dnsPrimaryInput)
val secondaryInput = view.findViewById<EditText>(R.id.dnsSecondaryInput)
when (Prefs.dnsMode) {
DnsMode.SYSTEM -> dnsModeSystem.isChecked = true
DnsMode.CUSTOM -> dnsModeCustom.isChecked = true
}
customDnsContainer.visibility = if (Prefs.dnsMode == DnsMode.CUSTOM) View.VISIBLE else View.GONE
primaryInput.setText(Prefs.dnsPrimary)
secondaryInput.setText(Prefs.dnsSecondary)
dnsModeGroup.setOnCheckedChangeListener { _, checkedId ->
customDnsContainer.visibility = if (checkedId == R.id.dnsModeCustom) View.VISIBLE else View.GONE
}
return AlertDialog.Builder(requireContext())
.setTitle(R.string.dns_settings_title)
.setView(view)
.setPositiveButton(android.R.string.ok) { _, _ ->
Prefs.dnsMode = if (dnsModeCustom.isChecked) DnsMode.CUSTOM else DnsMode.SYSTEM
if (dnsModeCustom.isChecked) {
Prefs.dnsPrimary = primaryInput.text.toString()
Prefs.dnsSecondary = secondaryInput.text.toString()
}
}
.setNegativeButton(android.R.string.cancel, null)
.create()
}
companion object {
const val TAG = "DnsSettingsDialog"
}
}
@@ -1,75 +0,0 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.CallPlatform
import bypass.whitelist.tunnel.HeadlessRelayController
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Prefs
import org.json.JSONObject
class HeadlessDionFragment : Fragment() {
private lateinit var relay: HeadlessRelayController
private val host: JoinFragmentHost?
get() = activity as? JoinFragmentHost
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.fragment_headless_dion, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val rawUrl = requireArguments().getString(ARG_URL, "")
val roomId = CallPlatform.extractRoomId(rawUrl)
val displayName = Prefs.autoclickName
relay = HeadlessRelayController(
requireContext().applicationInfo.nativeLibraryDir,
relayMode = "dion-headless-joiner",
onLog = { host?.appendLog(it) },
onStatus = { status ->
Log.d("DION-HEADLESS", "status: $status")
host?.onJoinStatus(status)
when (status) {
VpnStatus.STARTING -> {
val params = JSONObject().apply {
put("roomId", roomId)
put("displayName", displayName)
put("vp8Fps", Prefs.vp8Fps)
put("vp8Batch", Prefs.vp8Batch)
}
relay.sendJoinParams(params.toString())
}
VpnStatus.TUNNEL_ACTIVE -> activity?.runOnUiThread { host?.requestVpn() }
else -> {}
}
},
)
relay.start()
}
override fun onDestroyView() {
if (::relay.isInitialized) relay.stop()
super.onDestroyView()
}
companion object {
const val ARG_URL = "url"
fun newInstance(url: String): HeadlessDionFragment {
return HeadlessDionFragment().apply {
arguments = Bundle().apply {
putString(ARG_URL, url)
}
}
}
}
}
@@ -1,73 +0,0 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.HeadlessRelayController
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Prefs
import org.json.JSONObject
class HeadlessTelemostFragment : Fragment() {
private lateinit var relay: HeadlessRelayController
private val host: JoinFragmentHost?
get() = activity as? JoinFragmentHost
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.fragment_headless_telemost, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val joinLink = requireArguments().getString(ARG_URL, "")
val displayName = Prefs.autoclickName
relay = HeadlessRelayController(
requireContext().applicationInfo.nativeLibraryDir,
relayMode = "telemost-headless-joiner",
onLog = { host?.appendLog(it) },
onStatus = { status ->
Log.d("TM-HEADLESS", "status: $status")
host?.onJoinStatus(status)
when (status) {
VpnStatus.STARTING -> {
val params = JSONObject().apply {
put("joinLink", joinLink)
put("displayName", displayName)
put("vp8Fps", Prefs.vp8Fps)
put("vp8Batch", Prefs.vp8Batch)
}
relay.sendJoinParams(params.toString())
}
VpnStatus.TUNNEL_ACTIVE -> activity?.runOnUiThread { host?.requestVpn() }
else -> {}
}
},
)
relay.start()
}
override fun onDestroyView() {
if (::relay.isInitialized) relay.stop()
super.onDestroyView()
}
companion object {
const val ARG_URL = "url"
fun newInstance(url: String): HeadlessTelemostFragment {
return HeadlessTelemostFragment().apply {
arguments = Bundle().apply {
putString(ARG_URL, url)
}
}
}
}
}
@@ -7,12 +7,13 @@ import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ImageButton
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.util.BLANK_URL
import bypass.whitelist.tunnel.HeadlessRelayController
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.BLANK_URL
import bypass.whitelist.util.Prefs
class HeadlessVkFragment : Fragment() {
@@ -31,12 +32,16 @@ class HeadlessVkFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
webView = view.findViewById(R.id.captchaWebView)
view.findViewById<ImageButton>(R.id.captchaBackButton).setOnClickListener {
host?.onJoinCancel()
}
val url = requireArguments().getString(ARG_URL, "")
val displayName = Prefs.autoclickName
val displayName = Prefs.autofillName
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
webView.webViewClient = WebViewClient()
webView.setBackgroundColor(android.graphics.Color.WHITE)
webView.isVisible = false
relay = HeadlessRelayController(
@@ -55,6 +60,7 @@ class HeadlessVkFragment : Fragment() {
webView.stopLoading()
webView.loadUrl(BLANK_URL)
webView.isVisible = false
host?.setJoinUiVisible(false)
host?.requestVpn()
}
}
@@ -62,6 +68,7 @@ class HeadlessVkFragment : Fragment() {
onCaptchaUrl = { captchaUrl ->
Log.d("HEADLESS-VK", "captcha URL: $captchaUrl")
activity?.runOnUiThread {
host?.setJoinUiVisible(true)
webView.isVisible = true
webView.loadUrl(captchaUrl)
}
@@ -1,76 +0,0 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.CallPlatform
import bypass.whitelist.tunnel.HeadlessRelayController
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Prefs
import org.json.JSONObject
class HeadlessWBStreamFragment : Fragment() {
private lateinit var relay: HeadlessRelayController
private val host: JoinFragmentHost?
get() = activity as? JoinFragmentHost
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.fragment_headless_wbstream, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val rawUrl = requireArguments().getString(ARG_URL, "")
val roomId = CallPlatform.extractRoomId(rawUrl)
val displayName = Prefs.autoclickName
relay = HeadlessRelayController(
requireContext().applicationInfo.nativeLibraryDir,
relayMode = "wbstream-headless-joiner",
onLog = { host?.appendLog(it) },
onStatus = { status ->
Log.d("WB-HEADLESS", "status: $status")
host?.onJoinStatus(status)
when (status) {
VpnStatus.STARTING -> {
val params = JSONObject().apply {
put("roomId", roomId)
put("displayName", displayName)
put("tunnelMode", Prefs.tunnelMode.relayArg)
put("vp8Fps", Prefs.vp8Fps)
put("vp8Batch", Prefs.vp8Batch)
}
relay.sendJoinParams(params.toString())
}
VpnStatus.TUNNEL_ACTIVE -> activity?.runOnUiThread { host?.requestVpn() }
else -> {}
}
},
)
relay.start()
}
override fun onDestroyView() {
if (::relay.isInitialized) relay.stop()
super.onDestroyView()
}
companion object {
const val ARG_URL = "url"
fun newInstance(url: String): HeadlessWBStreamFragment {
return HeadlessWBStreamFragment().apply {
arguments = Bundle().apply {
putString(ARG_URL, url)
}
}
}
}
}
@@ -0,0 +1,140 @@
package bypass.whitelist.ui
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Canvas
import android.graphics.Matrix
import android.graphics.Paint
import android.graphics.RenderEffect
import android.graphics.Shader
import android.graphics.SweepGradient
import android.os.Build
import android.util.AttributeSet
import android.view.View
import androidx.core.content.ContextCompat
import bypass.whitelist.R
class HeroRingOuterView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0,
) : View(context, attrs, defStyle) {
enum class State { IDLE, CONNECTING, CONNECTED }
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL }
private val matrix = Matrix()
private var sweepRotationDegrees = 0f
private var spinAnimator: ValueAnimator? = null
private var currentState: State = State.IDLE
private val accent = ContextCompat.getColor(context, R.color.accent_emerald)
private val accentSoft = ContextCompat.getColor(context, R.color.accent_emerald_soft)
private val transparent = 0
private var cachedGradient: SweepGradient? = null
private var cachedGradientState: State? = null
private var cachedGradientWidth = 0
private var cachedGradientHeight = 0
init {
applyState(State.IDLE)
}
fun applyState(state: State) {
if (currentState == state) return
currentState = state
when (state) {
State.IDLE -> {
stopSpin()
visibility = GONE
setBlur(0f)
}
State.CONNECTING -> {
visibility = VISIBLE
setBlur(2f)
startSpin(durationMs = 6_000L)
}
State.CONNECTED -> {
visibility = VISIBLE
setBlur(0.5f)
startSpin(durationMs = 18_000L)
}
}
invalidate()
}
private fun startSpin(durationMs: Long) {
spinAnimator?.cancel()
spinAnimator = ValueAnimator.ofFloat(0f, 360f).apply {
duration = durationMs
repeatCount = ValueAnimator.INFINITE
interpolator = android.view.animation.LinearInterpolator()
addUpdateListener {
sweepRotationDegrees = it.animatedValue as Float
invalidate()
}
start()
}
}
private fun stopSpin() {
spinAnimator?.cancel()
spinAnimator = null
sweepRotationDegrees = 0f
}
private fun setBlur(radiusPx: Float) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
setRenderEffect(
if (radiusPx > 0f) RenderEffect.createBlurEffect(radiusPx, radiusPx, Shader.TileMode.CLAMP)
else null
)
}
}
fun release() {
stopSpin()
}
override fun onDetachedFromWindow() {
stopSpin()
super.onDetachedFromWindow()
}
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
if (currentState == State.IDLE) return
val cx = width / 2f
val cy = height / 2f
val radius = (minOf(width, height) / 2f) - 1f
val gradient = obtainGradient(cx, cy) ?: return
matrix.reset()
matrix.postRotate(sweepRotationDegrees, cx, cy)
gradient.setLocalMatrix(matrix)
paint.shader = gradient
paint.alpha = if (currentState == State.CONNECTED) (0.9f * 255).toInt() else 255
canvas.drawCircle(cx, cy, radius, paint)
}
private fun obtainGradient(cx: Float, cy: Float): SweepGradient? {
val cached = cachedGradient
if (cached != null &&
cachedGradientState == currentState &&
cachedGradientWidth == width &&
cachedGradientHeight == height
) {
return cached
}
val fresh = when (currentState) {
State.CONNECTING -> SweepGradient(cx, cy, intArrayOf(accentSoft, transparent, accentSoft), floatArrayOf(0f, 0.5f, 1f))
State.CONNECTED -> SweepGradient(cx, cy, intArrayOf(transparent, accent, accent, transparent), floatArrayOf(0f, 0.3f, 0.7f, 1f))
State.IDLE -> return null
}
cachedGradient = fresh
cachedGradientState = currentState
cachedGradientWidth = width
cachedGradientHeight = height
return fresh
}
}
@@ -0,0 +1,78 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.ParamCallback
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
class InputActionSheet : BottomSheetDialogFragment() {
private var titleText: String = ""
private var subtitleText: String? = null
private var fieldLabel: String = ""
private var initialValue: String = ""
private var onSave: ParamCallback<String>? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_input, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val titleView = view.findViewById<TextView>(R.id.sheetTitle)
val subView = view.findViewById<TextView>(R.id.sheetSubtitle)
val labelView = view.findViewById<TextView>(R.id.inputFieldLabel)
val input = view.findViewById<EditText>(R.id.inputField)
val cancel = view.findViewById<MaterialButton>(R.id.buttonCancel)
val save = view.findViewById<MaterialButton>(R.id.buttonSave)
titleView.text = titleText
if (subtitleText.isNullOrBlank()) {
subView.visibility = View.GONE
} else {
subView.text = subtitleText
subView.visibility = View.VISIBLE
}
labelView.text = fieldLabel
input.setText(initialValue)
input.setSelection(input.text.length)
cancel.setOnClickListener { dismiss() }
save.setOnClickListener {
val value = input.text.toString().trim()
if (value.isNotEmpty()) {
onSave?.invoke(value)
dismiss()
} else {
input.requestFocus()
}
}
}
companion object {
fun show(
manager: FragmentManager,
title: String,
subtitle: String? = null,
fieldLabel: String,
initialValue: String,
onSave: ParamCallback<String>,
) {
InputActionSheet().apply {
this.titleText = title
this.subtitleText = subtitle
this.fieldLabel = fieldLabel
this.initialValue = initialValue
this.onSave = onSave
}.show(manager, "InputActionSheet")
}
}
}
@@ -7,4 +7,6 @@ interface JoinFragmentHost {
fun onJoinStatus(status: VpnStatus)
fun onJoinStatusText(text: String)
fun requestVpn()
fun setJoinUiVisible(visible: Boolean)
fun onJoinCancel()
}
@@ -25,8 +25,8 @@ import bypass.whitelist.tunnel.RelayController
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.BLANK_URL
import bypass.whitelist.util.Ports
import bypass.whitelist.util.DESKTOP_USER_AGENT
import bypass.whitelist.util.Ports
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.maskUrl
import java.net.HttpURLConnection
@@ -60,7 +60,7 @@ class JsHookJoinFragment : Fragment() {
HookKey(true, CallPlatform.TELEMOST) to lazy { loadAsset("video-telemost.js") },
)
private val autoclickers = mapOf(
private val autofillers = mapOf(
CallPlatform.VK to lazy { loadAsset("autoclick-vk.js") },
CallPlatform.TELEMOST to lazy { loadAsset("autoclick-telemost.js") },
)
@@ -82,6 +82,9 @@ class JsHookJoinFragment : Fragment() {
toggleButton = view.findViewById(R.id.toggleWebViewButton)
toggleArrow = view.findViewById(R.id.toggleWebViewArrow)
toggleLabel = view.findViewById(R.id.toggleWebViewLabel)
view.findViewById<android.widget.ImageButton>(R.id.webviewBackButton).setOnClickListener {
host?.onJoinCancel()
}
relay = RelayController(
nativeLibDir = requireContext().applicationInfo.nativeLibraryDir,
@@ -165,10 +168,10 @@ class JsHookJoinFragment : Fragment() {
view.evaluateJavascript("window.WS_PORT=${androidbind.Androidbind.activeWsPort()}", null)
view.evaluateJavascript("window.PION_PORT=${Ports.PION_SIGNALING}", null)
view.evaluateJavascript(hookForPlatform(platform), null)
if (Prefs.autoclickEnabled) {
host?.appendLog("Injecting autoclick for ${maskUrl(url)}")
view.evaluateJavascript("window.autofillName='${Prefs.autoclickName}'", null)
view.evaluateJavascript(autoclickers[platform]!!.value, null)
if (Prefs.autofillEnabled) {
host?.appendLog("Injecting autofill for ${maskUrl(url)}")
view.evaluateJavascript("window.autofillName='${Prefs.autofillName}'", null)
view.evaluateJavascript(autofillers[platform]!!.value, null)
}
}
}
@@ -1,67 +0,0 @@
package bypass.whitelist.ui
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.text.method.ScrollingMovementMethod
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.FileProvider
import bypass.whitelist.R
import bypass.whitelist.util.LogWriter
class LogViewController(
private val activity: AppCompatActivity,
private val logView: TextView,
private val logWriter: LogWriter,
) {
init {
logView.movementMethod = ScrollingMovementMethod.getInstance()
}
fun append(msg: String) {
val (line, evicted) = logWriter.append(msg)
activity.runOnUiThread {
if (evicted) {
logView.text = logWriter.displayText()
} else {
logView.append("$line\n")
}
val scrollAmount = logView.layout?.let {
it.getLineTop(logView.lineCount) - logView.height
} ?: 0
if (scrollAmount > 0) logView.scrollTo(0, scrollAmount)
}
}
fun reset() {
logWriter.reset()
logView.text = ""
logView.scrollTo(0, 0)
}
fun copyLogs() {
val contents = if (logWriter.file.exists()) logWriter.file.readText() else logWriter.displayText()
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText("relay.log", contents))
Toast.makeText(activity, R.string.copy_logs_toast, Toast.LENGTH_SHORT).show()
}
fun shareLogs() {
val uri = FileProvider.getUriForFile(
activity, "${activity.packageName}.fileprovider", logWriter.file
)
val share = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_STREAM, uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
activity.startActivity(Intent.createChooser(share, activity.getString(R.string.share_logs)))
}
fun close() {
logWriter.close()
}
}
@@ -0,0 +1,163 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
import androidx.fragment.app.Fragment
import bypass.whitelist.R
class LogsFragment : Fragment(R.layout.fragment_logs_screen) {
interface Host {
fun activityLogLines(): List<String>
fun copyLogs()
fun shareLogs()
}
private var container: LinearLayout? = null
private var scrollView: ScrollView? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
container = view.findViewById(R.id.eventsContainer)
scrollView = view.findViewById(R.id.activityScroll)
renderLines(host()?.activityLogLines().orEmpty())
view.findViewById<Button>(R.id.buttonCopyRaw).setOnClickListener { host()?.copyLogs() }
view.findViewById<Button>(R.id.buttonShareFile).setOnClickListener { host()?.shareLogs() }
}
override fun onDestroyView() {
container = null
scrollView = null
super.onDestroyView()
}
fun refresh() {
renderLines(host()?.activityLogLines().orEmpty())
}
fun onLineAppended(line: String) {
val parent = container ?: return
if (parent.childCount == 1 && parent.getChildAt(0) is TextView && (parent.getChildAt(0) as TextView).text == getString(R.string.activity_empty)) {
parent.removeAllViews()
}
appendRow(parent, line)
scrollToBottom()
}
private fun renderLines(lines: List<String>) {
val parent = container ?: return
parent.removeAllViews()
if (lines.isEmpty()) {
val empty = TextView(requireContext()).apply {
text = getString(R.string.activity_empty)
setTextColor(requireContext().getColor(R.color.ink_3))
setPadding(dp(20), dp(24), dp(20), dp(24))
gravity = Gravity.CENTER
}
parent.addView(empty)
return
}
lines.forEach { appendRow(parent, it) }
}
private fun appendRow(parent: LinearLayout, rawLine: String) {
val inflater = LayoutInflater.from(parent.context)
val row = inflater.inflate(R.layout.item_log_line, parent, false)
bindRow(row, parseLine(rawLine))
parent.addView(row)
}
private fun bindRow(row: View, parsed: ParsedLine) {
val context = row.context
val time = row.findViewById<TextView>(R.id.lineTime)
val comp = row.findViewById<TextView>(R.id.lineComp)
val message = row.findViewById<TextView>(R.id.lineMessage)
val icon = row.findViewById<ImageView>(R.id.lineIcon)
val iconBox = row.findViewById<View>(R.id.lineIconBox)
time.text = parsed.time
message.text = parsed.message
if (parsed.component.isNotEmpty()) {
comp.text = parsed.component
comp.visibility = View.VISIBLE
} else {
comp.visibility = View.GONE
}
icon.setImageResource(iconFor(parsed.component))
val (boxBg, iconColor, msgColor) = when (parsed.level) {
Level.OK -> Triple(R.drawable.bg_log_box_ok, R.color.accent_emerald, R.color.ink)
Level.WARN -> Triple(R.drawable.bg_log_box_warn, R.color.warn_amber, R.color.ink)
Level.ERR -> Triple(R.drawable.bg_log_box_err, R.color.error_red, R.color.error_red)
Level.INFO -> Triple(R.drawable.bg_settings_row_icon, R.color.ink_2, R.color.ink)
}
iconBox.setBackgroundResource(boxBg)
icon.setColorFilter(context.getColor(iconColor))
message.setTextColor(context.getColor(msgColor))
}
private enum class Level { INFO, OK, WARN, ERR }
private data class ParsedLine(val time: String, val component: String, val level: Level, val message: String)
private fun parseLine(line: String): ParsedLine {
var rest = line.trim()
var time = ""
val firstSpace = rest.indexOf(' ')
if (firstSpace > 0 && rest.substring(0, firstSpace).matches(TS_REGEX)) {
time = rest.substring(0, minOf(firstSpace, 8))
rest = rest.substring(firstSpace + 1).trim()
}
var component = ""
if (rest.startsWith("[")) {
val close = rest.indexOf(']')
if (close > 0) {
component = rest.substring(1, close).trim()
rest = rest.substring(close + 1).trim()
}
}
val lower = rest.lowercase()
val level = when {
lower.contains("error:") || lower.startsWith("error ") || lower.contains("failed") -> Level.ERR
lower.contains("warn") || lower.contains("throttle") || lower.contains("drift") || lower.contains("late") || lower.contains("captcha") -> Level.WARN
lower.contains("connected") || lower.contains("established") || lower.contains("ready") || lower.contains("active") -> Level.OK
else -> Level.INFO
}
return ParsedLine(time = time, component = component, level = level, message = rest)
}
private fun iconFor(component: String): Int = when (component.lowercase()) {
"boot" -> R.drawable.ic_log_boot
"ws" -> R.drawable.ic_log_ws
"sfu" -> R.drawable.ic_log_sfu
"tunnel" -> R.drawable.ic_log_tunnel
"vp8" -> R.drawable.ic_log_vp8
"sctp" -> R.drawable.ic_log_sctp
"relay" -> R.drawable.ic_log_relay
"heartbeat" -> R.drawable.ic_log_heartbeat
"captcha" -> R.drawable.ic_log_captcha
"error" -> R.drawable.ic_log_error
else -> R.drawable.ic_log_info
}
private fun scrollToBottom() {
scrollView?.post { scrollView?.fullScroll(View.FOCUS_DOWN) }
}
private fun dp(value: Int): Int = (value * resources.displayMetrics.density).toInt()
private fun host(): Host? = activity as? Host
companion object {
private val TS_REGEX = Regex("^\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,3})?$")
}
}
@@ -0,0 +1,8 @@
package bypass.whitelist.ui
import androidx.fragment.app.Fragment
interface MainActivityHost {
fun pushSubPage(fragment: Fragment)
fun popSubPage()
}
@@ -0,0 +1,190 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.View
import android.widget.PopupMenu
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.CallConfig
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Prefs
class MainFragment : Fragment(R.layout.fragment_main_screen) {
private var content: MainFragmentView? = null
private var pendingStatus: VpnStatus? = null
private var connectedSinceMs: Long = 0L
private val tickHandler = Handler(Looper.getMainLooper())
private val tickRunnable = object : Runnable {
override fun run() {
refreshStats()
tickHandler.postDelayed(this, 1000L)
}
}
interface Host {
fun onConnectPressed(config: CallConfig)
fun onDisconnectPressed()
fun onPingPressed(callback: (success: Boolean, rttMs: Int) -> Unit)
fun isTunnelActive(): Boolean
fun currentStatus(): VpnStatus?
}
override fun onViewCreated(rootView: View, savedInstanceState: Bundle?) {
val container = MainFragmentView(rootView)
content = container
container.bindCalls(Prefs.savedDestinations, Prefs.activeDestinationId)
container.bindHero(connected = isHostConnected(), status = hostStatus())
container.onAddCallClicked = {
AddDestinationSheet.show(parentFragmentManager)
}
container.onHeroPressed = {
if (isHostConnected()) {
host()?.onDisconnectPressed()
} else {
val active = Prefs.activeDestination
if (active != null) {
host()?.onConnectPressed(active)
}
}
}
container.onPingPressed = {
container.showPingRunning()
host()?.onPingPressed { success, rttMs ->
container.showPingResult(success, rttMs)
}
}
container.onCallSelected = { config ->
Prefs.activeDestinationId = config.id
container.bindCalls(Prefs.savedDestinations, Prefs.activeDestinationId)
}
container.onCallLongPressed = { config, anchor ->
showRowMenu(config, anchor)
}
pendingStatus?.let { container.bindStatus(it) }
pendingStatus = null
}
override fun onResume() {
super.onResume()
content?.bindCalls(Prefs.savedDestinations, Prefs.activeDestinationId)
content?.bindHero(connected = isHostConnected(), status = hostStatus())
}
override fun onDestroyView() {
tickHandler.removeCallbacks(tickRunnable)
content?.detach()
content = null
super.onDestroyView()
}
fun onStatusChanged(status: VpnStatus) {
val container = content
if (container != null) {
container.bindStatus(status)
} else {
pendingStatus = status
}
if (isHostConnected()) refreshStats()
}
fun onStatusTextChanged(text: String) {
content?.bindStatusText(text)
}
fun onConnectedChanged(connected: Boolean) {
content?.bindHero(connected = connected, status = hostStatus())
if (connected) {
if (connectedSinceMs == 0L) connectedSinceMs = System.currentTimeMillis()
refreshStats()
tickHandler.removeCallbacks(tickRunnable)
tickHandler.postDelayed(tickRunnable, 1000L)
} else {
connectedSinceMs = 0L
tickHandler.removeCallbacks(tickRunnable)
}
}
fun onDestinationsChanged() {
content?.bindCalls(Prefs.savedDestinations, Prefs.activeDestinationId)
}
private fun showRowMenu(config: CallConfig, anchor: View) {
MenuActionSheet.show(
manager = parentFragmentManager,
title = config.name,
subtitle = config.url,
items = listOf(
MenuActionSheet.MenuItem("rename", getString(R.string.destination_menu_rename), R.drawable.ic_action_pencil),
MenuActionSheet.MenuItem("delete", getString(R.string.destination_menu_delete), R.drawable.ic_setting_trash, danger = true),
),
) { item ->
when (item.id) {
"rename" -> promptRename(config)
"delete" -> confirmDelete(config)
}
}
}
private fun promptRename(config: CallConfig) {
InputActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.destination_rename_title),
fieldLabel = getString(R.string.sheet_field_name),
initialValue = config.name,
) { newName ->
if (newName != config.name) {
Prefs.renameDestination(config.id, newName)
onDestinationsChanged()
}
}
}
private fun confirmDelete(config: CallConfig) {
ConfirmActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.destination_delete_title),
subtitle = getString(R.string.destination_delete_confirm, config.name),
confirmLabel = getString(R.string.confirm_delete),
cancelLabel = getString(R.string.sheet_cancel),
destructive = true,
) {
Prefs.removeDestination(config.id)
onDestinationsChanged()
}
}
private fun refreshStats() {
val view = content ?: return
val uptimeMs = if (connectedSinceMs > 0L) System.currentTimeMillis() - connectedSinceMs else 0L
val active = Prefs.activeDestination
val effectiveMode = if (active != null) Prefs.tunnelMode.effectiveFor(active.platform) else Prefs.tunnelMode
view.setStats(uptimeText = formatUptime(uptimeMs), mode = effectiveMode.label)
}
private fun formatUptime(ms: Long): String {
if (ms <= 0L) return "00:00:00"
val totalSeconds = ms / 1000L
val hours = totalSeconds / 3600L
val minutes = (totalSeconds / 60L) % 60L
val seconds = totalSeconds % 60L
return "%02d:%02d:%02d".format(hours, minutes, seconds)
}
private fun host(): Host? = activity as? Host
private fun isHostConnected(): Boolean = host()?.isTunnelActive() ?: false
private fun hostStatus(): VpnStatus? = host()?.currentStatus()
companion object {
private const val MENU_RENAME = 1
private const val MENU_DELETE = 2
}
}
@@ -0,0 +1,269 @@
package bypass.whitelist.ui
import android.animation.ValueAnimator
import android.view.LayoutInflater
import android.view.View
import android.view.animation.AlphaAnimation
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import bypass.whitelist.R
import bypass.whitelist.tunnel.CallConfig
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Callback
import bypass.whitelist.util.ParamCallback
class MainFragmentView(private val root: View) {
private val headerSub: TextView = root.findViewById(R.id.headerSub)
private val addButton: View = root.findViewById(R.id.headerAddButton)
private val hero: View = root.findViewById(R.id.heroButton)
private val heroLabel: TextView = root.findViewById(R.id.heroLabel)
private val heroPowerIcon: ImageView = root.findViewById(R.id.heroPowerIcon)
private val heroRingOuter: HeroRingOuterView = root.findViewById(R.id.heroRingOuter)
private val heroRingMid: View = root.findViewById(R.id.heroRingMid)
private val heroPulse: View = root.findViewById(R.id.heroPulse)
private val statusHeadline: TextView = root.findViewById(R.id.statusHeadline)
private val statusDot: View = root.findViewById(R.id.statusDot)
private val statusDetail: TextView = root.findViewById(R.id.statusDetail)
private val callsList: LinearLayout = root.findViewById(R.id.callsList)
private val emptyCta: View = root.findViewById(R.id.emptyCta)
private val statsCard: View = root.findViewById(R.id.statsCard)
private val pingRow: LinearLayout = root.findViewById(R.id.pingRow)
private val pingButton: View = root.findViewById(R.id.pingButton)
private val pingButtonLabel: TextView = root.findViewById(R.id.pingButtonLabel)
private val pingResult: View = root.findViewById(R.id.pingResult)
private val pingResultHost: TextView = root.findViewById(R.id.pingResultHost)
private val pingResultRtt: TextView = root.findViewById(R.id.pingResultRtt)
private val statUptime: TextView = root.findViewById(R.id.statUptime)
private val statMode: TextView = root.findViewById(R.id.statMode)
var onAddCallClicked: Callback? = null
var onHeroPressed: Callback? = null
var onPingPressed: Callback? = null
var onCallSelected: ParamCallback<CallConfig>? = null
var onCallLongPressed: ((CallConfig, View) -> Unit)? = null
private var pulseAnimator: ValueAnimator? = null
private var collapsedToActive: Boolean = false
private var currentCalls: List<CallConfig> = emptyList()
private var activeCallId: String = ""
init {
emptyCta.clipToOutline = true
pingButton.clipToOutline = true
addButton.setOnClickListener { onAddCallClicked?.invoke() }
emptyCta.setOnClickListener { onAddCallClicked?.invoke() }
hero.setOnClickListener { onHeroPressed?.invoke() }
pingButton.setOnClickListener { onPingPressed?.invoke() }
}
fun bindCalls(calls: List<CallConfig>, activeId: String) {
currentCalls = calls
activeCallId = activeId
renderCalls()
updateHeaderSubForList(calls.size)
}
private fun renderCalls() {
callsList.removeAllViews()
val inflater = LayoutInflater.from(root.context)
val visibleCalls = if (collapsedToActive) {
currentCalls.filter { it.id == activeCallId }
} else {
currentCalls
}
if (currentCalls.isEmpty()) {
emptyCta.visibility = View.VISIBLE
callsList.visibility = View.GONE
return
}
emptyCta.visibility = View.GONE
callsList.visibility = View.VISIBLE
visibleCalls.forEach { config ->
val row = inflater.inflate(R.layout.item_call_row, callsList, false)
row.clipToOutline = true
bindRow(row, config, isActive = config.id == activeCallId)
row.setOnClickListener { onCallSelected?.invoke(config) }
row.setOnLongClickListener {
onCallLongPressed?.invoke(config, row)
true
}
callsList.addView(row)
}
}
private fun bindRow(row: View, config: CallConfig, isActive: Boolean) {
val context = row.context
val nameView = row.findViewById<TextView>(R.id.rowName)
val linkView = row.findViewById<TextView>(R.id.rowLink)
val glyphView = row.findViewById<TextView>(R.id.rowGlyph)
val glyphBox = row.findViewById<View>(R.id.rowGlyphBox)
val statusDot = row.findViewById<View>(R.id.rowStatusDot)
nameView.text = config.name
linkView.text = config.url
glyphView.text = config.platformGlyph
if (isActive) {
row.setBackgroundResource(R.drawable.bg_destination_card_active)
statusDot.setBackgroundResource(R.drawable.bg_status_dot_active)
glyphBox.setBackgroundResource(R.drawable.bg_glyph_chip_active)
glyphView.setTextColor(context.getColor(R.color.panel_bg))
} else {
row.setBackgroundResource(R.drawable.bg_destination_card)
statusDot.setBackgroundResource(R.drawable.bg_status_dot_idle)
glyphBox.setBackgroundResource(R.drawable.bg_glyph_chip)
glyphView.setTextColor(context.getColor(R.color.ink))
}
}
private fun updateHeaderSubForList(count: Int) {
if (collapsedToActive) return
headerSub.text = when (count) {
0 -> root.context.getString(R.string.main_sub_no_configs)
else -> root.context.resources.getQuantityString(R.plurals.main_sub_count, count, count)
}
}
fun bindHero(connected: Boolean, status: VpnStatus?) {
val context = root.context
if (connected) {
heroLabel.text = context.getString(R.string.hero_disconnect)
hero.setBackgroundResource(R.drawable.bg_hero_connected)
heroLabel.setTextColor(context.getColor(R.color.panel_bg))
heroPowerIcon.setColorFilter(context.getColor(R.color.panel_bg))
statusHeadline.text = context.getString(R.string.status_headline_connected)
headerSub.text = context.getString(R.string.main_sub_live)
statsCard.visibility = View.VISIBLE
pingRow.visibility = View.VISIBLE
heroRingOuter.applyState(HeroRingOuterView.State.CONNECTED)
heroRingMid.setBackgroundResource(R.drawable.bg_hero_ring_dashed_active)
statusDot.setBackgroundResource(R.drawable.bg_status_dot_active)
collapsedToActive = true
renderCalls()
stopPulse()
} else if (status == VpnStatus.CONNECTING || status == VpnStatus.STARTING || status == VpnStatus.CALL_CONNECTED || status == VpnStatus.DATACHANNEL_OPEN) {
heroLabel.text = context.getString(R.string.hero_cancel)
hero.setBackgroundResource(R.drawable.bg_hero_active)
heroLabel.setTextColor(context.getColor(R.color.accent_emerald))
heroPowerIcon.setColorFilter(context.getColor(R.color.accent_emerald))
statusHeadline.text = context.getString(R.string.status_headline_connecting)
statsCard.visibility = View.GONE
pingRow.visibility = View.GONE
heroRingOuter.applyState(HeroRingOuterView.State.CONNECTING)
heroRingMid.setBackgroundResource(R.drawable.bg_hero_ring_dashed)
statusDot.setBackgroundResource(R.drawable.bg_status_dot_warn)
collapsedToActive = true
renderCalls()
startPulse()
} else {
heroLabel.text = context.getString(R.string.hero_connect)
hero.setBackgroundResource(R.drawable.bg_hero_idle)
heroLabel.setTextColor(context.getColor(R.color.ink_3))
heroPowerIcon.setColorFilter(context.getColor(R.color.ink_3))
statusHeadline.text = context.getString(R.string.status_headline_disconnected)
statusDot.setBackgroundResource(R.drawable.bg_status_dot_idle)
statusDetail.text = if (currentCalls.isEmpty()) {
context.getString(R.string.status_detail_no_calls)
} else {
context.getString(R.string.status_detail_pick_call)
}
statsCard.visibility = View.GONE
pingRow.visibility = View.GONE
heroRingOuter.applyState(HeroRingOuterView.State.IDLE)
heroRingMid.setBackgroundResource(R.drawable.bg_hero_ring_dashed)
collapsedToActive = false
renderCalls()
updateHeaderSubForList(currentCalls.size)
stopPulse()
resetPingState()
}
}
fun bindStatus(status: VpnStatus) {
val labelRes = status.labelRes
statusDetail.text = root.context.getString(labelRes)
}
fun bindStatusText(text: String) {
statusDetail.text = text
}
fun setStats(uptimeText: String, mode: String) {
statUptime.text = uptimeText
statMode.text = mode
}
fun showPingRunning() {
pingButtonLabel.text = root.context.getString(R.string.ping_running)
val anim = AlphaAnimation(0.5f, 1.0f).apply {
duration = 450
repeatMode = AlphaAnimation.REVERSE
repeatCount = AlphaAnimation.INFINITE
}
pingButton.startAnimation(anim)
}
fun showPingResult(success: Boolean, rttMs: Int) {
pingButton.clearAnimation()
pingButtonLabel.text = root.context.getString(R.string.ping_run)
pingResult.visibility = View.VISIBLE
val host = "ya.ru"
if (success) {
pingResult.setBackgroundResource(R.drawable.bg_ping_result_ok)
pingResultHost.setTextColor(root.context.getColor(R.color.accent_emerald))
pingResultRtt.setTextColor(root.context.getColor(R.color.accent_emerald))
pingResultHost.text = root.context.getString(R.string.ping_ok, host)
pingResultRtt.text = root.context.getString(R.string.ping_ms, rttMs)
} else {
pingResult.setBackgroundResource(R.drawable.bg_ping_result_fail)
pingResultHost.setTextColor(root.context.getColor(R.color.error_red))
pingResultRtt.setTextColor(root.context.getColor(R.color.error_red))
pingResultHost.text = root.context.getString(R.string.ping_fail, host)
pingResultRtt.text = root.context.getString(R.string.ping_timeout)
}
}
fun detach() {
heroRingOuter.release()
stopPulse()
pingButton.clearAnimation()
}
private fun startPulse() {
if (pulseAnimator?.isStarted == true) return
heroPulse.visibility = View.VISIBLE
heroPulse.scaleX = 1f
heroPulse.scaleY = 1f
heroPulse.alpha = 1f
pulseAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
duration = 1600L
repeatCount = ValueAnimator.INFINITE
repeatMode = ValueAnimator.RESTART
addUpdateListener {
val progress = it.animatedValue as Float
val scale = 1f + progress * 0.18f
heroPulse.scaleX = scale
heroPulse.scaleY = scale
heroPulse.alpha = 1f - progress
}
start()
}
}
private fun stopPulse() {
pulseAnimator?.cancel()
pulseAnimator = null
heroPulse.visibility = View.GONE
heroPulse.scaleX = 1f
heroPulse.scaleY = 1f
heroPulse.alpha = 1f
}
private fun resetPingState() {
pingButton.clearAnimation()
pingButtonLabel.text = root.context.getString(R.string.ping_run)
pingResult.visibility = View.GONE
}
}
@@ -0,0 +1,87 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.ParamCallback
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
class MenuActionSheet : BottomSheetDialogFragment() {
data class MenuItem(
val id: String,
val title: String,
val iconRes: Int,
val danger: Boolean = false,
)
private var titleText: String = ""
private var subtitleText: String? = null
private var items: List<MenuItem> = emptyList()
private var onSelect: ParamCallback<MenuItem>? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_menu, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val titleView = view.findViewById<TextView>(R.id.sheetTitle)
val subView = view.findViewById<TextView>(R.id.sheetSubtitle)
val menuContainer = view.findViewById<LinearLayout>(R.id.menuContainer)
titleView.text = titleText
if (subtitleText.isNullOrBlank()) {
subView.visibility = View.GONE
} else {
subView.text = subtitleText
subView.visibility = View.VISIBLE
}
val inflater = LayoutInflater.from(requireContext())
items.forEach { item ->
val row = inflater.inflate(R.layout.item_action_menu_row, menuContainer, false)
row.clipToOutline = true
val label = row.findViewById<TextView>(R.id.menuLabel)
val icon = row.findViewById<ImageView>(R.id.menuIcon)
val iconBox = row.findViewById<View>(R.id.menuIconBox)
label.text = item.title
icon.setImageResource(item.iconRes)
if (item.danger) {
label.setTextColor(requireContext().getColor(R.color.error_red))
iconBox.setBackgroundResource(R.drawable.bg_settings_row_icon_danger)
icon.setColorFilter(requireContext().getColor(R.color.error_red))
}
row.setOnClickListener {
onSelect?.invoke(item)
dismiss()
}
menuContainer.addView(row)
}
}
companion object {
fun show(
manager: FragmentManager,
title: String,
subtitle: String? = null,
items: List<MenuItem>,
onSelect: ParamCallback<MenuItem>,
) {
MenuActionSheet().apply {
this.titleText = title
this.subtitleText = subtitle
this.items = items
this.onSelect = onSelect
}.show(manager, "MenuActionSheet")
}
}
}
@@ -0,0 +1,116 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.SocksAuthMode
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
import com.google.android.material.materialswitch.MaterialSwitch
class ProxyActionSheet : BottomSheetDialogFragment() {
private var onSaved: Callback? = null
private var selectedAuth: SocksAuthMode = SocksAuthMode.AUTO
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_proxy, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
selectedAuth = Prefs.socksAuthMode
view.findViewById<View>(R.id.proxyPortCard).clipToOutline = true
val portInput = view.findViewById<EditText>(R.id.proxyPortInput)
val authContainer = view.findViewById<LinearLayout>(R.id.proxyAuthContainer)
val manualContainer = view.findViewById<LinearLayout>(R.id.proxyManualContainer)
val userInput = view.findViewById<EditText>(R.id.proxyUserInput)
val passInput = view.findViewById<EditText>(R.id.proxyPassInput)
val proxyOnly = view.findViewById<MaterialSwitch>(R.id.proxyOnlySwitch)
portInput.setText(Prefs.socksPort.toString())
userInput.setText(Prefs.socksUser)
passInput.setText(Prefs.socksPass)
proxyOnly.isChecked = Prefs.proxyOnly
manualContainer.visibility = if (selectedAuth == SocksAuthMode.MANUAL) View.VISIBLE else View.GONE
val inflater = LayoutInflater.from(requireContext())
val rowViews = mutableMapOf<SocksAuthMode, View>()
val context = requireContext()
SocksAuthMode.entries.forEach { mode ->
val row = inflater.inflate(R.layout.item_action_option, authContainer, false)
row.clipToOutline = true
val title = when (mode) {
SocksAuthMode.AUTO -> context.getString(R.string.proxy_auth_auto)
SocksAuthMode.MANUAL -> context.getString(R.string.proxy_auth_manual)
}
val sub = when (mode) {
SocksAuthMode.AUTO -> context.getString(R.string.proxy_auth_auto_sub)
SocksAuthMode.MANUAL -> context.getString(R.string.proxy_auth_manual_sub)
}
row.findViewById<TextView>(R.id.actionOptionTitle).text = title
row.findViewById<TextView>(R.id.actionOptionSub).apply {
text = sub
visibility = View.VISIBLE
}
row.setOnClickListener {
selectedAuth = mode
updateAuthSelection(rowViews)
manualContainer.visibility = if (mode == SocksAuthMode.MANUAL) View.VISIBLE else View.GONE
}
authContainer.addView(row)
rowViews[mode] = row
}
updateAuthSelection(rowViews)
view.findViewById<MaterialButton>(R.id.proxyCancelButton).setOnClickListener { dismiss() }
view.findViewById<MaterialButton>(R.id.proxySaveButton).setOnClickListener {
portInput.text.toString().toLongOrNull()?.takeIf { it in 1L..65535L }?.let { Prefs.socksPort = it }
Prefs.socksAuthMode = selectedAuth
if (selectedAuth == SocksAuthMode.MANUAL) {
Prefs.socksUser = userInput.text.toString().trim()
Prefs.socksPass = passInput.text.toString()
}
Prefs.proxyOnly = proxyOnly.isChecked
onSaved?.invoke()
dismiss()
}
}
private fun updateAuthSelection(rowViews: Map<SocksAuthMode, View>) {
val context = requireContext()
rowViews.forEach { (mode, row) ->
val isActive = mode == selectedAuth
val titleView = row.findViewById<TextView>(R.id.actionOptionTitle)
val checkBox = row.findViewById<View>(R.id.actionOptionCheckBox)
val checkIcon = row.findViewById<ImageView>(R.id.actionOptionCheckIcon)
if (isActive) {
row.setBackgroundResource(R.drawable.bg_destination_card_active)
checkBox.setBackgroundResource(R.drawable.bg_action_check_active)
checkIcon.visibility = View.VISIBLE
titleView.setTextColor(context.getColor(R.color.accent_emerald))
} else {
row.setBackgroundResource(R.drawable.bg_destination_card)
checkBox.setBackgroundResource(R.drawable.bg_action_check_idle)
checkIcon.visibility = View.GONE
titleView.setTextColor(context.getColor(R.color.ink))
}
}
}
companion object {
fun show(manager: FragmentManager, onSaved: Callback) {
ProxyActionSheet().apply { this.onSaved = onSaved }.show(manager, "ProxyActionSheet")
}
}
}
@@ -1,87 +0,0 @@
package bypass.whitelist.ui
import android.app.Dialog
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.CheckBox
import android.widget.EditText
import android.widget.RadioButton
import android.widget.RadioGroup
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.SocksAuthMode
class ProxySettingsDialogFragment(
private val onChanged: Callback? = null,
) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val view = layoutInflater.inflate(R.layout.dialog_proxy_settings, null)
val portInput = view.findViewById<EditText>(R.id.proxyPortInput)
val authModeGroup = view.findViewById<RadioGroup>(R.id.authModeGroup)
val authModeAuto = view.findViewById<RadioButton>(R.id.authModeAuto)
val authModeManual = view.findViewById<RadioButton>(R.id.authModeManual)
val manualAuthContainer = view.findViewById<View>(R.id.manualAuthContainer)
val userInput = view.findViewById<EditText>(R.id.proxyUserInput)
val passInput = view.findViewById<EditText>(R.id.proxyPassInput)
val copyButton = view.findViewById<Button>(R.id.copyProxyButton)
val proxyOnlyCheckbox = view.findViewById<CheckBox>(R.id.proxyOnlyCheckbox)
portInput.setText(Prefs.socksPort.toString())
proxyOnlyCheckbox.isChecked = Prefs.proxyOnly
when (Prefs.socksAuthMode) {
SocksAuthMode.AUTO -> authModeAuto.isChecked = true
SocksAuthMode.MANUAL -> authModeManual.isChecked = true
}
manualAuthContainer.visibility = if (Prefs.socksAuthMode == SocksAuthMode.MANUAL) View.VISIBLE else View.GONE
userInput.setText(Prefs.socksUser)
passInput.setText(Prefs.socksPass)
authModeGroup.setOnCheckedChangeListener { _, checkedId ->
manualAuthContainer.visibility = if (checkedId == R.id.authModeManual) View.VISIBLE else View.GONE
}
copyButton.setOnClickListener {
val port = portInput.text.toString()
val user = userInput.text.toString()
val pass = passInput.text.toString()
val proxyUrl = "socks5://$user:$pass@127.0.0.1:$port"
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText("proxy", proxyUrl))
Toast.makeText(requireContext(), R.string.proxy_copied, Toast.LENGTH_SHORT).show()
}
return AlertDialog.Builder(requireContext())
.setTitle(R.string.proxy_settings_title)
.setView(view)
.setPositiveButton(android.R.string.ok) { _, _ ->
val port = portInput.text.toString().toLongOrNull()
if (port != null && port in 1..65535) {
Prefs.socksPort = port
}
Prefs.socksAuthMode = if (authModeManual.isChecked) SocksAuthMode.MANUAL else SocksAuthMode.AUTO
if (authModeManual.isChecked) {
Prefs.socksUser = userInput.text.toString()
Prefs.socksPass = passInput.text.toString()
}
Prefs.proxyOnly = proxyOnlyCheckbox.isChecked
onChanged?.invoke()
}
.setNegativeButton(android.R.string.cancel, null)
.create()
}
companion object {
const val TAG = "ProxySettingsDialog"
}
}
@@ -1,313 +0,0 @@
package bypass.whitelist.ui
import android.app.Dialog
import android.content.pm.ApplicationInfo
import android.text.Editable
import android.text.TextWatcher
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.CheckBox
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.ListView
import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.SplitTunnelingMode
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.TunnelVpnService
import bypass.whitelist.util.Prefs
class SettingsDialogFragment : DialogFragment() {
interface Listener {
fun onTunnelModeChanged(mode: TunnelMode)
fun onShowLogsChanged(visible: Boolean)
fun onShareLogs()
fun onReset()
}
private var listener: Listener? = null
private var tunnelMode: TunnelMode = Prefs.tunnelMode
private var splitTunnelingMode: SplitTunnelingMode = Prefs.splitTunnelingMode
private var splitTunnelingPackages: MutableSet<String> = Prefs.splitTunnelingPackages.toMutableSet()
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.setTitle(R.string.cd_settings)
return dialog
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.fragment_settings, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
listener = activity as? Listener
val tunnelModeItem = view.findViewById<TextView>(R.id.tunnelModeItem)
val splitTunnelingItem = view.findViewById<TextView>(R.id.splitTunnelingItem)
val splitTunnelingAppsItem = view.findViewById<TextView>(R.id.splitTunnelingAppsItem)
val proxyItem = view.findViewById<TextView>(R.id.proxyItem)
val dnsItem = view.findViewById<TextView>(R.id.dnsItem)
val vp8PacingItem = view.findViewById<TextView>(R.id.vp8PacingItem)
val autoclickItem = view.findViewById<TextView>(R.id.autoclickItem)
val headlessCheckbox = view.findViewById<CheckBox>(R.id.headlessCheckbox)
val reconnectCheckbox = view.findViewById<CheckBox>(R.id.reconnectOnStartCheckbox)
val showLogsCheckbox = view.findViewById<CheckBox>(R.id.showLogsCheckbox)
val shareLogsItem = view.findViewById<TextView>(R.id.shareLogsItem)
val resetItem = view.findViewById<TextView>(R.id.resetItem)
val closeButton = view.findViewById<Button>(R.id.closeButton)
updateTunnelModeLabel(tunnelModeItem)
updateSplitTunnelingLabel(splitTunnelingItem)
updateSplitTunnelingAppsEnabled(splitTunnelingAppsItem)
headlessCheckbox.isChecked = Prefs.headless
reconnectCheckbox.isChecked = Prefs.connectOnStart
showLogsCheckbox.isChecked = Prefs.showLogs
tunnelModeItem.setOnClickListener {
showModeDialog(tunnelModeItem)
}
splitTunnelingItem.setOnClickListener {
showSplitTunnelingDialog(splitTunnelingItem, splitTunnelingAppsItem)
}
splitTunnelingAppsItem.setOnClickListener {
if (splitTunnelingMode != SplitTunnelingMode.NONE) {
showSplitTunnelingAppSelection()
}
}
proxyItem.setOnClickListener {
ProxySettingsDialogFragment {
listener?.onReset()
dismiss()
}.show(childFragmentManager, ProxySettingsDialogFragment.TAG)
}
dnsItem.setOnClickListener {
DnsSettingsDialogFragment().show(childFragmentManager, DnsSettingsDialogFragment.TAG)
}
vp8PacingItem.setOnClickListener {
Vp8PacingSettingsDialogFragment().show(childFragmentManager, Vp8PacingSettingsDialogFragment.TAG)
}
autoclickItem.setOnClickListener {
showAutoclickSettingsDialog()
}
headlessCheckbox.setOnCheckedChangeListener { _, checked ->
Prefs.headless = checked
listener?.onReset()
}
reconnectCheckbox.setOnCheckedChangeListener { _, checked ->
Prefs.connectOnStart = checked
}
showLogsCheckbox.setOnCheckedChangeListener { _, checked ->
Prefs.showLogs = checked
listener?.onShowLogsChanged(checked)
}
shareLogsItem.setOnClickListener {
listener?.onShareLogs()
dismiss()
}
resetItem.setOnClickListener {
listener?.onReset()
dismiss()
}
closeButton.setOnClickListener {
dismiss()
}
}
private fun updateTunnelModeLabel(textView: TextView) {
textView.text = getString(R.string.menu_tunnel, tunnelMode.label)
}
private fun updateSplitTunnelingLabel(textView: TextView) {
textView.text = getString(R.string.menu_split_tunneling, splitTunnelingMode.label)
}
private fun updateSplitTunnelingAppsEnabled(textView: TextView) {
val enabled = splitTunnelingMode != SplitTunnelingMode.NONE
textView.isEnabled = enabled
textView.alpha = if (enabled) 1.0f else 0.4f
}
private fun showModeDialog(tunnelModeItem: TextView) {
val modes = TunnelMode.entries
val labels = modes.map { it.label }.toTypedArray()
val current = modes.indexOf(tunnelMode)
AlertDialog.Builder(requireContext())
.setSingleChoiceItems(labels, current) { dialog, which ->
dialog.dismiss()
val mode = modes[which]
if (mode != tunnelMode) {
tunnelMode = mode
Prefs.tunnelMode = mode
updateTunnelModeLabel(tunnelModeItem)
listener?.onTunnelModeChanged(mode)
}
}
.show()
}
private fun showSplitTunnelingDialog(
splitTunnelingItem: TextView,
splitTunnelingAppsItem: TextView,
) {
val modes = SplitTunnelingMode.entries.toTypedArray()
val labels = modes.map { it.label }.toTypedArray()
val selectedIndex = modes.indexOf(splitTunnelingMode)
AlertDialog.Builder(requireContext())
.setTitle(R.string.split_tunneling_mode_prompt)
.setSingleChoiceItems(labels, selectedIndex) { dialog, which ->
splitTunnelingMode = modes[which]
Prefs.splitTunnelingMode = splitTunnelingMode
updateSplitTunnelingLabel(splitTunnelingItem)
updateSplitTunnelingAppsEnabled(splitTunnelingAppsItem)
dialog.dismiss()
if (TunnelVpnService.instance?.isRunning == true) {
Toast.makeText(requireContext(), R.string.split_tunneling_mode_changed, Toast.LENGTH_SHORT).show()
}
}
.setNegativeButton(android.R.string.cancel, null)
.show()
}
private fun showSplitTunnelingAppSelection() {
val dialogLayout = layoutInflater.inflate(R.layout.split_tunneling_app_list_dialog, null)
val loadingProgressBar = dialogLayout.findViewById<ProgressBar>(R.id.loading_progress_bar)
val appListContainer = dialogLayout.findViewById<LinearLayout>(R.id.app_list_container)
val searchEditText = dialogLayout.findViewById<EditText>(R.id.search_input)
val systemAppsCheckbox = dialogLayout.findViewById<CheckBox>(R.id.system_apps_checkbox)
val listView = dialogLayout.findViewById<ListView>(R.id.app_list_view)
AlertDialog.Builder(requireContext())
.setTitle(R.string.split_tunneling_apps_prompt)
.setView(dialogLayout)
.setPositiveButton(android.R.string.ok) { _, _ ->
Prefs.splitTunnelingMode = splitTunnelingMode
Prefs.splitTunnelingPackages = splitTunnelingPackages
if (TunnelVpnService.instance?.isRunning == true) {
Toast.makeText(requireContext(), R.string.split_tunneling_mode_changed, Toast.LENGTH_SHORT).show()
}
}
.setNegativeButton(android.R.string.cancel, null)
.show()
loadingProgressBar.visibility = View.VISIBLE
appListContainer.visibility = View.GONE
Thread {
var includeSystemApps = false
val context = requireContext()
val pm = context.packageManager
val ownPackage = context.packageName
val installedApps = pm.getInstalledApplications(PackageManager.GET_META_DATA)
.filter { it.packageName != ownPackage }
.mapNotNull { appInfo ->
val pkg = appInfo.packageName
if (pkg.isBlank()) return@mapNotNull null
val label = appInfo.loadLabel(pm).toString().takeIf { it.isNotBlank() } ?: pkg
SplitTunnelingAppItem(
pkg, label, pm.getApplicationIcon(pkg),
splitTunnelingPackages.contains(pkg),
(appInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 0,
)
}
.distinctBy { it.packageName }
.sortedWith(compareByDescending<SplitTunnelingAppItem> { it.isSelected }.thenBy { it.label.lowercase() })
activity?.runOnUiThread {
loadingProgressBar.visibility = View.GONE
appListContainer.visibility = View.VISIBLE
fun buildAppList(query: String, includeSystemApps: Boolean): List<SplitTunnelingAppItem> {
val baseList = installedApps.filter { includeSystemApps || it.isUserApp }
return if (query.isBlank()) {
baseList
} else {
baseList.filter {
it.label.contains(query, ignoreCase = true) ||
it.packageName.contains(query, ignoreCase = true)
}
}
}
val adapter = SplitTunnelingAdapter(layoutInflater, splitTunnelingPackages)
adapter.items = buildAppList("", includeSystemApps)
if (adapter.items.isEmpty()) return@runOnUiThread
listView.choiceMode = ListView.CHOICE_MODE_MULTIPLE
listView.adapter = adapter
systemAppsCheckbox.isChecked = includeSystemApps
systemAppsCheckbox.setOnCheckedChangeListener { _, checked ->
includeSystemApps = checked
adapter.items = buildAppList(searchEditText.text.toString(), includeSystemApps)
}
searchEditText.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
adapter.items = buildAppList(s.toString(), includeSystemApps)
}
override fun afterTextChanged(s: Editable?) {}
})
}
}.start()
}
private fun showAutoclickSettingsDialog() {
val dialogLayout = layoutInflater.inflate(R.layout.autoclick_settings_dialog, null)
val autoclickCheckbox = dialogLayout.findViewById<CheckBox>(R.id.autoclick_checkbox)
val nameInput = dialogLayout.findViewById<EditText>(R.id.autoclick_name_input)
val generateButton = dialogLayout.findViewById<Button>(R.id.autoclick_generate_random_button)
autoclickCheckbox.isChecked = Prefs.autoclickEnabled
nameInput.setText(Prefs.autoclickName)
generateButton.setOnClickListener {
val names = requireContext().assets.open("names.txt").bufferedReader().readLines()
val randomName = names.random()
nameInput.setText(randomName)
}
AlertDialog.Builder(requireContext())
.setTitle(R.string.autoclick_settings_title)
.setView(dialogLayout)
.setPositiveButton(android.R.string.ok) { _, _ ->
Prefs.autoclickEnabled = autoclickCheckbox.isChecked
Prefs.autoclickName = nameInput.text.toString()
}
.setNegativeButton(android.R.string.cancel, null)
.show()
}
companion object {
const val TAG = "SettingsDialogFragment"
}
}
@@ -0,0 +1,244 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.view.isNotEmpty
import androidx.fragment.app.Fragment
import com.google.android.material.materialswitch.MaterialSwitch
import bypass.whitelist.App
import bypass.whitelist.R
import bypass.whitelist.tunnel.SplitTunnelingMode
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.TunnelVpnService
import bypass.whitelist.util.Prefs
import bypass.whitelist.util.ThemeMode
class SettingsScreenFragment : Fragment(R.layout.fragment_settings_screen) {
interface Host {
fun onTunnelModeChanged(mode: TunnelMode)
fun onForgetAllDestinations()
fun onResetAllSettings()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val root = view.findViewById<LinearLayout>(R.id.settingsContent)
root.removeAllViews()
root.addView(buildAppearanceSection())
root.addView(buildTunnelSection())
root.addView(buildNetworkSection())
root.addView(buildBehaviorSection())
root.addView(buildDangerSection())
}
fun refresh() {
rebuild()
}
private fun host(): Host? = activity as? Host
private fun buildAppearanceSection(): View {
val section = newSection(R.string.settings_section_appearance)
val card = section.findViewById<LinearLayout>(R.id.sectionCard)
addRow(card, R.drawable.ic_setting_theme, getString(R.string.settings_row_theme), getString(R.string.settings_row_theme_sub), Prefs.themeMode.label) {
ChoiceActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.settings_row_theme),
subtitle = getString(R.string.settings_row_theme_sub),
options = ThemeMode.entries.map { ChoiceActionSheet.Option(it.name, it.label) },
selectedId = Prefs.themeMode.name,
) { picked ->
val mode = ThemeMode.valueOf(picked.id)
if (mode != Prefs.themeMode) {
Prefs.themeMode = mode
App.applyTheme(mode)
rebuild()
}
}
}
return section
}
private fun buildTunnelSection(): View {
val section = newSection(R.string.settings_section_tunnel)
val card = section.findViewById<LinearLayout>(R.id.sectionCard)
addRow(card, R.drawable.ic_setting_tunnel, getString(R.string.settings_row_tunnel_mode), null, Prefs.tunnelMode.label) {
ChoiceActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.settings_row_tunnel_mode),
options = TunnelMode.entries.map { ChoiceActionSheet.Option(it.name, it.label) },
selectedId = Prefs.tunnelMode.name,
) { picked ->
val newMode = TunnelMode.valueOf(picked.id)
if (newMode != Prefs.tunnelMode) {
Prefs.tunnelMode = newMode
host()?.onTunnelModeChanged(newMode)
rebuild()
}
}
}
addRow(card, R.drawable.ic_setting_vp8, getString(R.string.settings_row_vp8), getString(R.string.settings_row_vp8_sub, Prefs.vp8Fps, Prefs.vp8Batch), null) {
Vp8ActionSheet.show(parentFragmentManager) { rebuild() }
}
addRow(card, R.drawable.ic_setting_autofill, getString(R.string.settings_row_autofill), if (Prefs.autofillEnabled) Prefs.autofillName else getString(R.string.settings_row_autofill_off), null) {
AutofillActionSheet.show(parentFragmentManager) { rebuild() }
}
return section
}
private fun buildNetworkSection(): View {
val section = newSection(R.string.settings_section_network)
val card = section.findViewById<LinearLayout>(R.id.sectionCard)
val splitSummary = if (Prefs.splitTunnelingMode == SplitTunnelingMode.NONE) {
Prefs.splitTunnelingMode.label
} else {
resources.getQuantityString(R.plurals.split_tunneling_summary_count, Prefs.splitTunnelingPackages.size, Prefs.splitTunnelingMode.label, Prefs.splitTunnelingPackages.size)
}
addRow(card, R.drawable.ic_setting_split, getString(R.string.settings_row_split), splitSummary, null) {
(activity as? MainActivityHost)?.pushSubPage(SplitTunnelingScreenFragment())
}
addRow(card, R.drawable.ic_setting_proxy, getString(R.string.settings_row_proxy), getString(R.string.settings_row_proxy_sub, Prefs.socksPort), null) {
ProxyActionSheet.show(parentFragmentManager) { rebuild() }
}
addRow(card, R.drawable.ic_setting_dns, getString(R.string.settings_row_dns), Prefs.dnsMode.label, null) {
DnsActionSheet.show(parentFragmentManager) { rebuild() }
}
return section
}
private fun buildBehaviorSection(): View {
val section = newSection(R.string.settings_section_behavior)
val card = section.findViewById<LinearLayout>(R.id.sectionCard)
addSwitchRow(card, R.drawable.ic_setting_headless, getString(R.string.settings_row_headless), getString(R.string.settings_row_headless_sub), Prefs.headless) { checked ->
Prefs.headless = checked
}
addSwitchRow(card, R.drawable.ic_setting_reconnect, getString(R.string.settings_row_reconnect), getString(R.string.settings_row_reconnect_sub), Prefs.connectOnStart) { checked ->
Prefs.connectOnStart = checked
}
return section
}
private fun buildDangerSection(): View {
val section = newSection(R.string.settings_section_danger)
val card = section.findViewById<LinearLayout>(R.id.sectionCard)
addRow(card, R.drawable.ic_setting_reset, getString(R.string.settings_reset_all), getString(R.string.settings_reset_all_sub), null, danger = true) {
ConfirmActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.settings_reset_all),
subtitle = getString(R.string.settings_reset_all_sub),
confirmLabel = getString(R.string.confirm_reset),
cancelLabel = getString(R.string.sheet_cancel),
destructive = true,
) { host()?.onResetAllSettings() }
}
addRow(card, R.drawable.ic_setting_trash, getString(R.string.settings_forget_all_destinations), getString(R.string.settings_forget_all_destinations_sub), null, danger = true) {
ConfirmActionSheet.show(
manager = parentFragmentManager,
title = getString(R.string.settings_forget_all_destinations),
subtitle = getString(R.string.settings_forget_all_destinations_sub),
confirmLabel = getString(R.string.confirm_forget),
cancelLabel = getString(R.string.sheet_cancel),
destructive = true,
) { host()?.onForgetAllDestinations() }
}
return section
}
private fun newSection(labelRes: Int): View {
val parent = view as ViewGroup?
val v = layoutInflater.inflate(R.layout.item_settings_section, parent, false)
v.findViewById<TextView>(R.id.sectionLabel).setText(labelRes)
v.findViewById<View>(R.id.sectionCard).clipToOutline = true
return v
}
private fun addRow(
card: LinearLayout,
iconRes: Int,
title: String,
sub: String?,
trail: String?,
danger: Boolean = false,
onClick: () -> Unit,
) {
val row = layoutInflater.inflate(R.layout.item_settings_row, card, false)
row.findViewById<ImageView>(R.id.rowIcon).setImageResource(iconRes)
if (danger) {
row.findViewById<View>(R.id.rowIconBox).setBackgroundResource(R.drawable.bg_settings_row_icon_danger)
row.findViewById<ImageView>(R.id.rowIcon).setColorFilter(requireContext().getColor(R.color.error_red))
row.findViewById<TextView>(R.id.rowTitle).setTextColor(requireContext().getColor(R.color.error_red))
}
row.findViewById<TextView>(R.id.rowTitle).text = title
row.findViewById<TextView>(R.id.rowSub).apply {
if (sub.isNullOrBlank()) { visibility = View.GONE } else { text = sub; visibility = View.VISIBLE }
}
row.findViewById<TextView>(R.id.rowTrail).apply {
if (trail.isNullOrBlank()) { visibility = View.GONE } else { text = trail; visibility = View.VISIBLE }
}
row.findViewById<ImageView>(R.id.rowChev).visibility = View.VISIBLE
row.setOnClickListener { onClick() }
if (card.isNotEmpty()) addDividerTo(card)
card.addView(row)
}
private fun addSwitchRow(
card: LinearLayout,
iconRes: Int,
title: String,
sub: String?,
initial: Boolean,
onToggled: (Boolean) -> Unit,
) {
val row = layoutInflater.inflate(R.layout.item_settings_row, card, false)
row.findViewById<ImageView>(R.id.rowIcon).setImageResource(iconRes)
row.findViewById<TextView>(R.id.rowTitle).text = title
row.findViewById<TextView>(R.id.rowSub).apply {
if (sub.isNullOrBlank()) { visibility = View.GONE } else { text = sub; visibility = View.VISIBLE }
}
val sw = row.findViewById<MaterialSwitch>(R.id.rowSwitch)
sw.visibility = View.VISIBLE
sw.isChecked = initial
row.setOnClickListener {
sw.isChecked = !sw.isChecked
onToggled(sw.isChecked)
}
if (card.isNotEmpty()) addDividerTo(card)
card.addView(row)
}
private fun addDividerTo(card: LinearLayout) {
val divider = View(requireContext()).apply {
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1).apply {
marginStart = (14 * resources.displayMetrics.density).toInt()
marginEnd = (14 * resources.displayMetrics.density).toInt()
}
setBackgroundColor(requireContext().getColor(R.color.hair))
}
card.addView(divider)
}
private fun rebuild() {
if (!isAdded) return
val rootView = view ?: return
onViewCreated(rootView, null)
}
companion object {
const val TAG = "SettingsScreenFragment"
}
}
@@ -0,0 +1,175 @@
package bypass.whitelist.ui
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.EditText
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.ListView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.fragment.app.Fragment
import bypass.whitelist.R
import bypass.whitelist.tunnel.SplitTunnelingMode
import bypass.whitelist.tunnel.TunnelVpnService
import bypass.whitelist.util.Prefs
class SplitTunnelingScreenFragment : Fragment() {
private var mode: SplitTunnelingMode = Prefs.splitTunnelingMode
private var packages: MutableSet<String> = Prefs.splitTunnelingPackages.toMutableSet()
private lateinit var summary: TextView
private lateinit var appsHeader: View
private lateinit var appsArea: View
private lateinit var appsListContainer: View
private lateinit var loadingBar: ProgressBar
private lateinit var searchInput: EditText
private lateinit var systemAppsCheckbox: CheckBox
private lateinit var appsList: ListView
private lateinit var modeOffRow: View
private lateinit var modeBypassRow: View
private lateinit var modeOnlyRow: View
private lateinit var modeOffCheck: View
private lateinit var modeBypassCheck: View
private lateinit var modeOnlyCheck: View
private var allApps: List<SplitTunnelingAppItem> = emptyList()
private var includeSystemApps: Boolean = false
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.fragment_split_tunneling, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
view.findViewById<View>(R.id.modeCard).clipToOutline = true
summary = view.findViewById(R.id.splitSummary)
appsHeader = view.findViewById(R.id.appsHeader)
appsArea = view.findViewById(R.id.appsArea)
appsListContainer = view.findViewById(R.id.appsListContainer)
loadingBar = view.findViewById(R.id.loadingBar)
searchInput = view.findViewById(R.id.searchInput)
systemAppsCheckbox = view.findViewById(R.id.systemAppsCheckbox)
appsList = view.findViewById(R.id.appsListView)
modeOffRow = view.findViewById(R.id.modeOff)
modeBypassRow = view.findViewById(R.id.modeBypass)
modeOnlyRow = view.findViewById(R.id.modeOnly)
modeOffCheck = view.findViewById(R.id.modeOffCheck)
modeBypassCheck = view.findViewById(R.id.modeBypassCheck)
modeOnlyCheck = view.findViewById(R.id.modeOnlyCheck)
view.findViewById<ImageButton>(R.id.backButton).setOnClickListener { popSelf() }
modeOffRow.setOnClickListener { applyMode(SplitTunnelingMode.NONE) }
modeBypassRow.setOnClickListener { applyMode(SplitTunnelingMode.BYPASS) }
modeOnlyRow.setOnClickListener { applyMode(SplitTunnelingMode.ONLY) }
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
isEnabled = false
popSelf()
}
})
applyMode(mode, persist = false)
refreshAppsList(initial = true)
}
private fun popSelf() {
Prefs.splitTunnelingMode = mode
Prefs.splitTunnelingPackages = packages
if (TunnelVpnService.instance?.isRunning == true) {
android.widget.Toast.makeText(requireContext(), R.string.split_tunneling_mode_changed, android.widget.Toast.LENGTH_SHORT).show()
}
(activity as? MainActivityHost)?.popSubPage()
}
private fun applyMode(newMode: SplitTunnelingMode, persist: Boolean = true) {
mode = newMode
if (persist) Prefs.splitTunnelingMode = newMode
modeOffCheck.visibility = if (newMode == SplitTunnelingMode.NONE) View.VISIBLE else View.INVISIBLE
modeBypassCheck.visibility = if (newMode == SplitTunnelingMode.BYPASS) View.VISIBLE else View.INVISIBLE
modeOnlyCheck.visibility = if (newMode == SplitTunnelingMode.ONLY) View.VISIBLE else View.INVISIBLE
val showApps = newMode != SplitTunnelingMode.NONE
appsHeader.visibility = if (showApps) View.VISIBLE else View.GONE
appsArea.visibility = if (showApps) View.VISIBLE else View.GONE
updateSummary()
}
private fun updateSummary() {
summary.text = if (mode == SplitTunnelingMode.NONE) {
getString(R.string.split_tunneling_summary_off)
} else {
resources.getQuantityString(R.plurals.split_tunneling_summary_count, packages.size, mode.label, packages.size)
}
}
private fun refreshAppsList(initial: Boolean) {
if (!initial && allApps.isNotEmpty()) {
applyFilters()
return
}
loadingBar.visibility = View.VISIBLE
appsListContainer.visibility = View.GONE
Thread {
val context = context ?: return@Thread
val pm = context.packageManager
val ownPackage = context.packageName
val loaded = pm.getInstalledApplications(PackageManager.GET_META_DATA)
.filter { it.packageName != ownPackage }
.mapNotNull { info ->
val pkg = info.packageName
if (pkg.isBlank()) return@mapNotNull null
val label = info.loadLabel(pm).toString().takeIf { it.isNotBlank() } ?: pkg
SplitTunnelingAppItem(
pkg, label, pm.getApplicationIcon(pkg),
packages.contains(pkg),
(info.flags and ApplicationInfo.FLAG_SYSTEM) == 0,
)
}
.distinctBy { it.packageName }
.sortedWith(compareByDescending<SplitTunnelingAppItem> { it.isSelected }.thenBy { it.label.lowercase() })
activity?.runOnUiThread {
if (!isAdded) return@runOnUiThread
allApps = loaded
loadingBar.visibility = View.GONE
appsListContainer.visibility = View.VISIBLE
val adapter = SplitTunnelingAdapter(layoutInflater, packages)
appsList.adapter = adapter
applyFilters()
systemAppsCheckbox.isChecked = includeSystemApps
systemAppsCheckbox.setOnCheckedChangeListener { _, checked ->
includeSystemApps = checked
applyFilters()
}
searchInput.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { applyFilters() }
override fun afterTextChanged(s: Editable?) { updateSummary() }
})
}
}.start()
}
private fun applyFilters() {
val adapter = appsList.adapter as? SplitTunnelingAdapter ?: return
val query = searchInput.text.toString()
val base = allApps.filter { includeSystemApps || it.isUserApp }
val filtered = if (query.isBlank()) base else base.filter {
it.label.contains(query, ignoreCase = true) || it.packageName.contains(query, ignoreCase = true)
}
adapter.items = filtered
updateSummary()
}
}
@@ -1,64 +0,0 @@
package bypass.whitelist.ui
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import bypass.whitelist.R
import bypass.whitelist.tunnel.TunnelMode
import bypass.whitelist.tunnel.VpnStatus
import bypass.whitelist.util.Callback
import bypass.whitelist.util.Prefs
class StatusBarController(
private val activity: AppCompatActivity,
private val statusBar: TextView,
private val goButton: Button,
private val onConnect: Callback,
private val onDisconnect: Callback,
) {
var connected = false
private set
var tunnelMode: TunnelMode = TunnelMode.DC
fun setConnected(value: Boolean) {
connected = value
goButton.setText(if (value) R.string.btn_disconnect else R.string.btn_go)
goButton.setOnClickListener {
if (connected) onDisconnect() else onConnect()
}
}
fun setStatus(status: VpnStatus) {
val label = if (status == VpnStatus.PORT_BUSY) {
activity.getString(status.labelRes, Prefs.socksPort)
} else {
activity.getString(status.labelRes)
}
statusBar.text = activity.getString(R.string.status_format, tunnelMode.label, label)
val colorRes = when (status) {
VpnStatus.TUNNEL_ACTIVE -> R.color.status_active
VpnStatus.CONNECTING,
VpnStatus.CALL_CONNECTED,
VpnStatus.DATACHANNEL_OPEN -> R.color.status_connecting
VpnStatus.TUNNEL_LOST,
VpnStatus.DATACHANNEL_LOST,
VpnStatus.ACTION_REQUIRED_CAPTCHA -> R.color.status_warning
VpnStatus.CALL_DISCONNECTED,
VpnStatus.CALL_FAILED,
VpnStatus.PORT_BUSY -> R.color.status_error
VpnStatus.STARTING -> R.color.status_idle
}
statusBar.setBackgroundColor(activity.getColor(colorRes))
}
fun setStatusText(text: String) {
statusBar.text = text
statusBar.setBackgroundColor(activity.getColor(R.color.status_connecting))
}
fun setIdle() {
statusBar.text = activity.getString(R.string.status_format, tunnelMode.label, activity.getString(R.string.status_idle))
statusBar.setBackgroundColor(activity.getColor(R.color.status_idle))
}
}
@@ -0,0 +1,45 @@
package bypass.whitelist.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import androidx.fragment.app.FragmentManager
import bypass.whitelist.R
import bypass.whitelist.util.Callback
import bypass.whitelist.util.Prefs
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.button.MaterialButton
class Vp8ActionSheet : BottomSheetDialogFragment() {
private var onSaved: Callback? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View = inflater.inflate(R.layout.sheet_action_vp8, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val fps = view.findViewById<EditText>(R.id.vp8FpsInput)
val batch = view.findViewById<EditText>(R.id.vp8BatchInput)
fps.setText(Prefs.vp8Fps.toString())
batch.setText(Prefs.vp8Batch.toString())
view.findViewById<MaterialButton>(R.id.vp8CancelButton).setOnClickListener { dismiss() }
view.findViewById<MaterialButton>(R.id.vp8SaveButton).setOnClickListener {
fps.text.toString().toIntOrNull()?.takeIf { it in 1..240 }?.let { Prefs.vp8Fps = it }
batch.text.toString().toIntOrNull()?.takeIf { it in 1..256 }?.let { Prefs.vp8Batch = it }
onSaved?.invoke()
dismiss()
}
}
companion object {
fun show(manager: FragmentManager, onSaved: Callback) {
Vp8ActionSheet().apply { this.onSaved = onSaved }.show(manager, "Vp8ActionSheet")
}
}
}
@@ -1,38 +0,0 @@
package bypass.whitelist.ui
import android.app.Dialog
import android.os.Bundle
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import bypass.whitelist.R
import bypass.whitelist.util.Prefs
class Vp8PacingSettingsDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val view = layoutInflater.inflate(R.layout.dialog_vp8_pacing_settings, null)
val fpsInput = view.findViewById<EditText>(R.id.vp8FpsInput)
val batchInput = view.findViewById<EditText>(R.id.vp8BatchInput)
fpsInput.setText(Prefs.vp8Fps.toString())
batchInput.setText(Prefs.vp8Batch.toString())
return AlertDialog.Builder(requireContext())
.setTitle(R.string.vp8_pacing_title)
.setView(view)
.setPositiveButton(android.R.string.ok) { _, _ ->
val fps = fpsInput.text.toString().toIntOrNull()
if (fps != null && fps in 1..240) Prefs.vp8Fps = fps
val batch = batchInput.text.toString().toIntOrNull()
if (batch != null && batch in 1..256) Prefs.vp8Batch = batch
}
.setNegativeButton(android.R.string.cancel, null)
.create()
}
companion object {
const val TAG = "Vp8PacingSettingsDialog"
}
}
@@ -36,15 +36,20 @@ enum class DnsMode(val label: String) {
CUSTOM("Custom"),
}
enum class ThemeMode(val label: String) {
SYSTEM("System"),
LIGHT("Light"),
DARK("Dark"),
}
object PrefsKeys {
const val CONNECT_ON_START = "connect_on_start"
const val URL = "url"
const val TUNNEL_MODE = "tunnel_mode"
const val SHOW_LOGS = "show_logs"
const val SPLIT_TUNNELING_MODE = "split_tunneling_mode"
const val SPLIT_TUNNELING_PACKAGES = "split_tunneling_packages"
const val AUTOCLICK_ENABLED = "autoclick_enabled"
const val AUTOCLICK_NAME = "autoclick_name"
const val AUTOFILL_ENABLED = "autofill_enabled"
const val AUTOFILL_NAME = "autofill_name"
const val HEADLESS = "headless"
const val SOCKS_PORT = "socks_port"
const val SOCKS_AUTH_MODE = "socks_auth_mode"
@@ -56,6 +61,9 @@ object PrefsKeys {
const val DNS_SECONDARY = "dns_secondary"
const val VP8_FPS = "vp8_fps"
const val VP8_BATCH = "vp8_batch"
const val SAVED_DESTINATIONS = "saved_destinations"
const val ACTIVE_DESTINATION_ID = "active_destination_id"
const val THEME_MODE = "theme_mode"
}
object VP8Defaults {
@@ -3,6 +3,7 @@ package bypass.whitelist.util
import android.content.Context
import android.content.SharedPreferences
import androidx.core.content.edit
import bypass.whitelist.tunnel.CallConfig
import bypass.whitelist.tunnel.SplitTunnelingMode
import bypass.whitelist.tunnel.TunnelMode
@@ -18,10 +19,6 @@ object Prefs {
get() = prefs.getBoolean(PrefsKeys.CONNECT_ON_START, false)
set(value) = prefs.edit { putBoolean(PrefsKeys.CONNECT_ON_START, value) }
var lastUrl: String
get() = prefs.getString(PrefsKeys.URL, "")!!
set(value) = prefs.edit { putString(PrefsKeys.URL, value) }
var tunnelMode: TunnelMode
get() {
val name = prefs.getString(PrefsKeys.TUNNEL_MODE, TunnelMode.VIDEO.name)!!
@@ -52,13 +49,13 @@ object Prefs {
get() = prefs.getStringSet(PrefsKeys.SPLIT_TUNNELING_PACKAGES, emptySet()) ?: emptySet()
set(value) = prefs.edit { putStringSet(PrefsKeys.SPLIT_TUNNELING_PACKAGES, value) }
var autoclickEnabled: Boolean
get() = prefs.getBoolean(PrefsKeys.AUTOCLICK_ENABLED, true)
set(value) = prefs.edit { putBoolean(PrefsKeys.AUTOCLICK_ENABLED, value) }
var autofillEnabled: Boolean
get() = prefs.getBoolean(PrefsKeys.AUTOFILL_ENABLED, true)
set(value) = prefs.edit { putBoolean(PrefsKeys.AUTOFILL_ENABLED, value) }
var autoclickName: String
get() = prefs.getString(PrefsKeys.AUTOCLICK_NAME, "Hello")!!
set(value) = prefs.edit { putString(PrefsKeys.AUTOCLICK_NAME, value) }
var autofillName: String
get() = prefs.getString(PrefsKeys.AUTOFILL_NAME, "Hello")!!
set(value) = prefs.edit { putString(PrefsKeys.AUTOFILL_NAME, value) }
var headless: Boolean
get() = prefs.getBoolean(PrefsKeys.HEADLESS, true)
@@ -117,4 +114,57 @@ object Prefs {
var vp8Batch: Int
get() = prefs.getInt(PrefsKeys.VP8_BATCH, VP8Defaults.BATCH)
set(value) = prefs.edit { putInt(PrefsKeys.VP8_BATCH, value) }
var savedDestinations: List<CallConfig>
get() = CallConfig.listFromJson(prefs.getString(PrefsKeys.SAVED_DESTINATIONS, "") ?: "")
set(value) = prefs.edit { putString(PrefsKeys.SAVED_DESTINATIONS, CallConfig.listToJson(value)) }
var activeDestinationId: String
get() = prefs.getString(PrefsKeys.ACTIVE_DESTINATION_ID, "") ?: ""
set(value) = prefs.edit { putString(PrefsKeys.ACTIVE_DESTINATION_ID, value) }
var themeMode: ThemeMode
get() {
val name = prefs.getString(PrefsKeys.THEME_MODE, ThemeMode.SYSTEM.name) ?: ThemeMode.SYSTEM.name
return try { ThemeMode.valueOf(name) } catch (_: IllegalArgumentException) { ThemeMode.SYSTEM }
}
set(value) = prefs.edit { putString(PrefsKeys.THEME_MODE, value.name) }
val activeDestination: CallConfig?
get() {
val id = activeDestinationId
if (id.isEmpty()) return null
return savedDestinations.firstOrNull { it.id == id }
}
fun addDestination(config: CallConfig) {
val list = savedDestinations.toMutableList()
list.removeAll { it.id == config.id }
list.add(0, config)
savedDestinations = list
activeDestinationId = config.id
}
fun removeDestination(id: String) {
val list = savedDestinations.filter { it.id != id }
savedDestinations = list
if (activeDestinationId == id) {
activeDestinationId = list.firstOrNull()?.id ?: ""
}
}
fun renameDestination(id: String, newName: String) {
val list = savedDestinations.map { if (it.id == id) it.copy(name = newName) else it }
savedDestinations = list
}
fun resetAllSettings() {
val keepDestinations = prefs.getString(PrefsKeys.SAVED_DESTINATIONS, null)
val keepActiveId = prefs.getString(PrefsKeys.ACTIVE_DESTINATION_ID, null)
prefs.edit {
clear()
if (keepDestinations != null) putString(PrefsKeys.SAVED_DESTINATIONS, keepDestinations)
if (keepActiveId != null) putString(PrefsKeys.ACTIVE_DESTINATION_ID, keepActiveId)
}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/accent_emerald" />
<stroke android:width="2dp" android:color="@color/accent_emerald" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke android:width="2dp" android:color="@color/hair_strong" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#1FB07A1D" />
<stroke android:width="1dp" android:color="@color/warn_amber" />
<corners android:radius="999dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="16dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="14dp" />
</shape>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke
android:width="1dp"
android:color="@color/hair_strong"
android:dashWidth="4dp"
android:dashGap="3dp" />
<corners android:radius="16dp" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<corners android:radius="10dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/surface_bg" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="10dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="10dp" />
</shape>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@color/accent_emerald_soft" />
</shape>
</item>
<item
android:left="6dp"
android:top="6dp"
android:right="6dp"
android:bottom="6dp">
<shape android:shape="oval">
<solid android:color="@color/panel_bg" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
</shape>
</item>
</layer-list>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<solid android:color="@color/accent_emerald_soft" />
</shape>
</item>
<item
android:left="8dp"
android:top="8dp"
android:right="8dp"
android:bottom="8dp">
<shape android:shape="oval">
<solid android:color="@color/accent_emerald" />
</shape>
</item>
</layer-list>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/panel_bg" />
<stroke android:width="1dp" android:color="@color/hair_strong" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
</shape>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/accent_emerald_soft" />
</shape>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/hair_strong"
android:dashWidth="4dp"
android:dashGap="3dp" />
</shape>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="@color/accent_emerald_soft"
android:dashWidth="4dp"
android:dashGap="3dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="10dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="12dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="999dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#1FC24A2C" />
<stroke android:width="1dp" android:color="@color/error_red" />
<corners android:radius="9dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="9dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#1FB07A1D" />
<stroke android:width="1dp" android:color="@color/warn_amber" />
<corners android:radius="9dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="4dp" />
</shape>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<corners android:radius="14dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="999dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="999dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="14dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#14C24A2C" />
<stroke android:width="1dp" android:color="@color/error_red" />
<corners android:radius="12dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/accent_emerald_soft" />
<stroke android:width="1dp" android:color="@color/accent_emerald" />
<corners android:radius="12dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/surface_bg" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="9dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#14C24A2C" />
<stroke android:width="1dp" android:color="#33C24A2C" />
<corners android:radius="9dp" />
</shape>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/panel_2" />
<stroke android:width="1dp" android:color="@color/hair" />
<corners android:radius="18dp" />
</shape>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/accent_emerald" />
</shape>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/ink_3" />
</shape>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/warn_amber" />
</shape>
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M9,9 L20,9 L20,20 L9,20 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M5,15 L5,5 A2,2 0 0,1 7,3 L17,3" />
</vector>
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,20 L8,19 L20,7 L17,4 L5,16 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M14,7 L17,10" />
</vector>
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,12 L4,19 A1,1 0 0,0 5,20 L19,20 A1,1 0 0,0 20,19 L20,12" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M16,6 L12,2 L8,6 M12,2 L12,16" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="2.4"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M5,12 L10,17 L19,7" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="2.2"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M16,5 L8,12 L16,19" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="2.2"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M8,5 L17,12 L8,19" />
</vector>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,4 L12,12" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M7,7 A7,7 0 1,0 17,7" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M6,11 L18,11 L18,20 L6,20 Z M8,11 L8,7 A4,4 0 0,1 16,7 L16,11" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,2 L22,20 L2,20 Z M12,9 L12,14 M12,17 L12,17.5" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,12 L8,12 L10,7 L14,17 L16,12 L21,12" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,12 A8,8 0 1,1 20,12 A8,8 0 1,1 4,12 Z M12,8 L12,8.5 M12,11 L12,16" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,12 A8,8 0 1,1 20,12 A8,8 0 1,1 4,12 Z M8,12 L11,15 L16,9" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,12 L7,12 L9,7 L13,17 L15,12 L21,12" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,7 L15,7 A2,2 0 0,1 17,9 L17,15 A2,2 0 0,1 15,17 L3,17 A2,2 0 0,1 1,15 L1,9 A2,2 0 0,1 3,7 Z M17,10 L22,7 L22,17 L17,14" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,3 L20,7 L20,12 A8,8 0 0,1 12,21 A8,8 0 0,1 4,12 L4,7 Z" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,4 L20,4 L20,20 L4,20 Z M4,4 L4,8 L8,8 M16,4 L16,8 L20,8 M4,12 L20,12 M4,16 L8,16 L8,20 M16,16 L20,16 M16,16 L16,20" />
</vector>
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,12 A9,9 0 1,1 21,12 A9,9 0 1,1 3,12 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,12 L21,12 M12,3 A14,14 0 0,1 12,21 M12,3 A14,14 0 0,0 12,21" />
</vector>
@@ -0,0 +1,19 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M5,4 L19,4 A2,2 0 0,1 21,6 L21,18 A2,2 0 0,1 19,20 L5,20 A2,2 0 0,1 3,18 L3,6 A2,2 0 0,1 5,4 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M7,9 L13,9 M7,13 L17,13 M7,17 L15,17" />
</vector>
@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?android:attr/textColorSecondary">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,3 L12,13" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M6.8,6.8 A8,8 0 1,0 17.2,6.8" />
</vector>
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,15 A3,3 0 1,0 12,9 A3,3 0 1,0 12,15 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M19.4,15 a1.7,1.7 0 0 0 0.3,1.8 l0.1,0.1 a2,2 0 1 1 -2.8,2.8 l-0.1,-0.1 a1.7,1.7 0 0 0 -2.8,1.2 V21 a2,2 0 0 1 -4,0 v-0.1 a1.7,1.7 0 0 0 -2.8,-1.2 l-0.1,0.1 a2,2 0 1 1 -2.8,-2.8 l0.1,-0.1 a1.7,1.7 0 0 0 -1.2,-2.8 H3 a2,2 0 0 1 0,-4 h0.1 a1.7,1.7 0 0 0 1.2,-2.8 l-0.1,-0.1 a2,2 0 1 1 2.8,-2.8 l0.1,0.1 a1.7,1.7 0 0 0 2.8,-1.2 V3 a2,2 0 0 1 4,0 v0.1 a1.7,1.7 0 0 0 2.8,1.2 l0.1,-0.1 a2,2 0 1 1 2.8,2.8 l-0.1,0.1 a1.7,1.7 0 0 0 1.2,2.8 H21 a2,2 0 0 1 0,4 h-0.1 a1.7,1.7 0 0 0 -1.5,1" />
</vector>
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M8,3 L16,3 L16,7 L8,7 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M8,5 L6,5 A2,2 0 0,0 4,7 L4,19 A2,2 0 0,0 6,21 L18,21 A2,2 0 0,0 20,19 L20,7 A2,2 0 0,0 18,5 L16,5" />
</vector>
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,5 L12,19 M5,12 L19,12" />
</vector>
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="44dp"
android:height="44dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.6"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M12,3 L12,13" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.6"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M6.8,6.8 A8,8 0 1,0 17.2,6.8" />
</vector>
@@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="18dp"
android:height="18dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M3,12 A9,9 0 0,1 21,12" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M6,12 A6,6 0 0,1 18,12" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M9,12 A3,3 0 0,1 15,12" />
<path
android:fillColor="@android:color/white"
android:pathData="M11.4,12 A0.6,0.6 0 1,1 12.6,12 A0.6,0.6 0 1,1 11.4,12 Z" />
</vector>
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M9,3 L9,12 L5,12 L12,21 L19,12 L15,12 L15,3 Z" />
</vector>
Loaded 100 of 148 files, more files were not shown because too many files have changed in this diff. Show more