Compare commits

..

3 Commits

Author SHA1 Message Date
Zane Schepke ca3f3fd439 fix: file selection AndroidTV
Closes #35 Closes #34
2023-09-28 09:52:35 -04:00
Zane Schepke 235170508b docs: Update README.md 2023-09-26 17:06:12 -04:00
Zane Schepke 11aea3f1c4 fix: trusted SSIDs bug
Fixes bugs where trusted SSIDs were getting whitespace added every time they were saved to the DB.

Fixes file explorer bug on AndroidTV where the app crashes if they do not have a file explorer installed on the device.
2023-09-25 06:49:07 -04:00
7 changed files with 48 additions and 15 deletions
+12 -10
View File
@@ -2,35 +2,37 @@
WG Tunnel
</h1>
<span align="center">
<div align="center">
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Discord Chat](https://img.shields.io/discord/1108285024631001111.svg)](https://discord.gg/rbRRNh6H7V)
</span>
</div>
<span align="center">
<div align="center">
[![Google Play](https://img.shields.io/badge/Google_Play-414141?style=for-the-badge&logo=google-play&logoColor=white)](https://play.google.com/store/apps/details?id=com.zaneschepke.wireguardautotunnel)
[![Fire TV](https://img.shields.io/badge/fire%20tv-fc3b2d?style=for-the-badge&logo=amazon%20fire%20tv&logoColor=white)](https://www.amazon.com/gp/product/B0CFGGL7WK)
[![F-Droid](https://img.shields.io/static/v1?style=for-the-badge&message=F-Droid&color=1976D2&logo=F-Droid&logoColor=FFFFFF&label=)](https://f-droid.org/packages/com.zaneschepke.wireguardautotunnel/)
</span>
<span align="center">
</div>
<div align="center">
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/N4N8NMJN2)
</span>
</div>
<span align="left">
<div align="left">
This is an alternative Android Application for [WireGuard](https://www.wireguard.com/) with added features. Built using the [wireguard-android](https://github.com/WireGuard/wireguard-android) library and [Jetpack Compose](https://developer.android.com/jetpack/compose), this application was inspired by the official [WireGuard Android](https://github.com/WireGuard/wireguard-android) app.
</span>
</div>
<span align="center">
<div align="center">
## Screenshots
@@ -41,7 +43,7 @@ This is an alternative Android Application for [WireGuard](https://www.wireguard
<img label="Support" style="padding-left:25px" src="asset/support_screen.png" width="200" />
</p>
<span align="left">
<div align="left">
## Inspiration
+2 -2
View File
@@ -14,8 +14,8 @@ android {
applicationId = "com.zaneschepke.wireguardautotunnel"
minSdk = 26
targetSdk = 34
versionCode = 30001
versionName = "3.0.1"
versionCode = 30003
versionName = "3.0.3"
multiDexEnabled = true
@@ -12,4 +12,6 @@ object Constants {
const val URI_CONTENT_SCHEME = "content"
const val URI_PACKAGE_SCHEME = "package"
const val ALLOWED_FILE_TYPES = "*/*"
const val FILES_SHOW_ADVANCED = "android.content.extra.SHOW_ADVANCED"
const val ANDROID_TV_STUBS = "com.google.android.tv.frameworkpackagestubs"
}
@@ -5,7 +5,7 @@ import androidx.room.TypeConverter
class DatabaseListConverters {
@TypeConverter
fun listToString(value: MutableList<String>): String {
return value.joinToString()
return value.joinToString(",")
}
@TypeConverter
fun <T> stringToList(value: String): MutableList<String> {
@@ -210,10 +210,19 @@ fun MainScreen(
.fillMaxWidth()
.clickable {
showBottomSheet = false
val fileSelectionIntent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
val fileSelectionIntent = Intent(Intent.ACTION_GET_CONTENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
putExtra(Constants.FILES_SHOW_ADVANCED, true)
type = Constants.ALLOWED_FILE_TYPES
}
if(!viewModel.isIntentAvailable(fileSelectionIntent)) {
fileSelectionIntent.action = Intent.ACTION_OPEN_DOCUMENT
fileSelectionIntent.setPackage(null)
if (!viewModel.isIntentAvailable(fileSelectionIntent)) {
viewModel.showSnackBarMessage(context.getString(R.string.no_file_app))
return@clickable
}
}
pickFileLauncher.launch(fileSelectionIntent)
}
.padding(10.dp)
@@ -271,7 +280,7 @@ fun MainScreen(
.nestedScroll(nestedScrollConnection),
) {
items(tunnels, key = { tunnel -> tunnel.id }) {tunnel ->
val focusRequester = FocusRequester()
val focusRequester = remember { FocusRequester() }
RowListItem(leadingIcon = Icons.Rounded.Circle,
leadingIconColor = if (tunnelName == tunnel.name) when (handshakeStatus) {
HandshakeStatus.HEALTHY -> mint
@@ -2,6 +2,8 @@ package com.zaneschepke.wireguardautotunnel.ui.screens.main
import android.app.Application
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.database.Cursor
import android.net.Uri
import android.provider.OpenableColumns
@@ -207,6 +209,23 @@ class MainViewModel @Inject constructor(private val application : Application,
return columnIndex
}
fun isIntentAvailable(i: Intent?): Boolean {
val packageManager = application.packageManager
val list = packageManager.queryIntentActivities(
i!!,
PackageManager.MATCH_DEFAULT_ONLY
)
// Ignore the Android TV framework app in the list
var size = list.size
for (ri in list) {
// Ignore stub apps
if (Constants.ANDROID_TV_STUBS == ri.activityInfo.packageName) {
size--
}
}
return size > 0
}
private fun getDisplayNameByCursor(cursor: Cursor) : String {
if(cursor.moveToFirst()) {
val index = getDisplayNameColumnIndex(cursor)
+1
View File
@@ -96,4 +96,5 @@
<string name="never">Never</string>
<string name="stream_failed">Failed to open file stream.</string>
<string name="unknown_error_message">An unknown error occurred.</string>
<string name="no_file_app">No file app installed.</string>
</resources>