Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
davixdedem committed Sep 26, 2024
1 parent 6d75553 commit 21334a2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId = "com.magix.pistarlink"
minSdk = 34
targetSdk = 34
versionCode = 4
versionName = "Pi-Starlink-0.0.4-Nebula"
versionCode = 6
versionName = "Pi-Starlink-0.0.6-Nebula"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"


Expand Down
61 changes: 61 additions & 0 deletions app/src/main/java/com/magix/pistarlink/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,11 @@ class HomeFragment : Fragment() {
binding.layoutDns.contentLayout.setBackgroundResource(R.drawable.border)
}
else{
dbHandler.addConfiguration("is_ddns_set", "1")
dbHandler.updateConfiguration("is_ddns_set", "1")

dbHandler.addConfiguration("lastDDNS", hostname)
dbHandler.updateConfiguration("lastDDNS", hostname)
}

/* Update resources */
Expand Down Expand Up @@ -3025,6 +3029,7 @@ class HomeFragment : Fragment() {
}
else{
val lastDDNS = dbHandler.getConfiguration("lastDDNS")
println("lastDDNS is $lastDDNS")
if (lastDDNS != null) {
if (lastDDNS != "N/D" && lastDDNS != "" ) {
binding.layoutDns.cardTitle.text = "DDNS"
Expand All @@ -3033,6 +3038,11 @@ class HomeFragment : Fragment() {
binding.layoutDns.contentLayout.background = null
}
}
else{
binding.layoutDns.cardTitle.text = "DDNS"
binding.layoutDns.cardDescription.text = "You haven't set up a DDNS yet."
binding.layoutDns.contentLayout.setBackgroundResource(R.drawable.border)
}
}
}

Expand Down Expand Up @@ -4235,6 +4245,57 @@ class HomeFragment : Fragment() {
}
}
}
else{
Log.d("VPN-Handler", "No DDNS has been set up, proceeding without.")
val executor = Executors.newSingleThreadExecutor()
context?.let {
val vpnList = listVPNs()
if (vpnList.isNotEmpty()) {
val matchingProfile = vpnList.find { it.contains("Pi-Starlink") }
if (matchingProfile != null) {
profileUUID = matchingProfile.split(":").getOrNull(1)?.trim()
if (profileUUID != null) {
profileUUID?.let {
dbHandler.updateConfiguration(
"lastUUID",
it
)
Log.d("VPN-Handler", "Updating the last VPN sync.")
val currentTimeStamp = System.currentTimeMillis().toString()
dbHandler.updateConfiguration("lastVPNSync", currentTimeStamp)
Log.d(
"VPN-Handler",
"All done! Connecting to VPN with UUID: $profileUUID."
)

/*Avoid OpenVPN For Android bug, check if is the first time*/
val isFirstVPN = dbHandler.getConfiguration("isFirstVPN")
Log.d("VPN-Handler", "isFirstVPN: $isFirstVPN")
if (isFirstVPN != null) {
if (isFirstVPN == "0") {
connectVPN(profileUUID!!)
} else if (isFirstVPN == "1") {
Log.d(
"VPN-Handler",
"This is the first VPN activation ever."
)
//startOpenVPNProfile(context!!,"Pi-Starlink")
dbHandler.updateConfiguration("isFirstVPN", "0")
connectVPN(profileUUID!!)
}
}
}
} else {
Log.e("VPN-Handler", "instance of profileUUID is null.")
}
} else {
Log.e("VPN-Handler", "No one of the profiles contain 'Pi-Starlink'")
}
} else {
Log.e("VPN-Handler", "The vpn list is empty.")
}
}
}
} else {
Log.d("VPN-Handler", "No DDNS has been set up, proceeding without.")
val executor = Executors.newSingleThreadExecutor()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<string name="system">System</string>
<string name="memory">Memory</string>
<string name="storage">Storage</string>
<string name="support_page">For more information, visit <a href="https://github.com/davixdedem/Pi-Starlink">\nhttps://github.com/davixdedem/Pi-Starlink</a>.</string>
<string name="support_page">For more information, visit <a href="https://github.com/davixdedem/Pi-Starlink">\nhttps://github.com/davixdedem/Pi-Starlink</a></string>
<string name="support_welcome">
Hey folks, I\'m Davide: a Software Engineer with a passion for Cyber Security coming from the beautiful country of Italy.\n\n

Expand Down

0 comments on commit 21334a2

Please sign in to comment.