mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-28 14:15:08 +03:00
Click on a version row now opens URL of the project on GitHub.
This commit is contained in:
parent
3ddba8c9d6
commit
02a32935ba
5 changed files with 34 additions and 3 deletions
|
@ -4,6 +4,7 @@ import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.net.Uri
|
||||||
import android.net.VpnService
|
import android.net.VpnService
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
|
@ -20,6 +21,7 @@ import eu.neilalexander.yggdrasil.PacketTunnelProvider.Companion.STATE_INTENT
|
||||||
import mobile.Mobile
|
import mobile.Mobile
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
|
|
||||||
|
const val APP_WEB_URL = "https://github.com/yggdrasil-network/yggdrasil-android"
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
private lateinit var enabledSwitch: Switch
|
private lateinit var enabledSwitch: Switch
|
||||||
|
@ -31,6 +33,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
private lateinit var dnsLabel: TextView
|
private lateinit var dnsLabel: TextView
|
||||||
private lateinit var dnsRow: LinearLayoutCompat
|
private lateinit var dnsRow: LinearLayoutCompat
|
||||||
private lateinit var settingsRow: LinearLayoutCompat
|
private lateinit var settingsRow: LinearLayoutCompat
|
||||||
|
private lateinit var versionRow: LinearLayoutCompat
|
||||||
|
|
||||||
private fun start() {
|
private fun start() {
|
||||||
val intent = Intent(this, PacketTunnelProvider::class.java)
|
val intent = Intent(this, PacketTunnelProvider::class.java)
|
||||||
|
@ -59,6 +62,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
dnsLabel = findViewById(R.id.dnsValue)
|
dnsLabel = findViewById(R.id.dnsValue)
|
||||||
dnsRow = findViewById(R.id.dnsTableRow)
|
dnsRow = findViewById(R.id.dnsTableRow)
|
||||||
settingsRow = findViewById(R.id.settingsTableRow)
|
settingsRow = findViewById(R.id.settingsTableRow)
|
||||||
|
versionRow = findViewById(R.id.versionTableRow)
|
||||||
|
|
||||||
enabledLabel.setTextColor(Color.GRAY)
|
enabledLabel.setTextColor(Color.GRAY)
|
||||||
|
|
||||||
|
@ -106,6 +110,11 @@ class MainActivity : AppCompatActivity() {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versionRow.isClickable = true
|
||||||
|
versionRow.setOnClickListener {
|
||||||
|
openUrlInBrowser(APP_WEB_URL)
|
||||||
|
}
|
||||||
|
|
||||||
ipAddressLabel.setOnLongClickListener {
|
ipAddressLabel.setOnLongClickListener {
|
||||||
val clipboard: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
val clipboard: ClipboardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
val clip = ClipData.newPlainText("ip", ipAddressLabel.text)
|
val clip = ClipData.newPlainText("ip", ipAddressLabel.text)
|
||||||
|
@ -213,4 +222,16 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openUrlInBrowser(url: String) {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||||
|
data = Uri.parse(url)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
startActivity(intent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
// Handle the exception if no browser is found
|
||||||
|
Toast.makeText(this, getText(R.string.no_browser_found_toast), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -13,13 +12,20 @@ import android.view.ContextThemeWrapper
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.*
|
import android.widget.EditText
|
||||||
|
import android.widget.ImageButton
|
||||||
|
import android.widget.Switch
|
||||||
|
import android.widget.TableLayout
|
||||||
|
import android.widget.TableRow
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
|
||||||
class PeersActivity : AppCompatActivity() {
|
class PeersActivity : AppCompatActivity() {
|
||||||
private lateinit var config: ConfigurationProxy
|
private lateinit var config: ConfigurationProxy
|
||||||
private lateinit var inflater: LayoutInflater
|
private lateinit var inflater: LayoutInflater
|
||||||
|
|
|
@ -351,7 +351,9 @@
|
||||||
|
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/versionTableRow"
|
||||||
|
style="@style/SelectableItemStyle">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/versionLabel"
|
android:id="@+id/versionLabel"
|
||||||
|
|
|
@ -85,4 +85,5 @@
|
||||||
<string name="private_key_label">Приватный ключ:</string>
|
<string name="private_key_label">Приватный ключ:</string>
|
||||||
<string name="set_keys">Установить свой ключ</string>
|
<string name="set_keys">Установить свой ключ</string>
|
||||||
<string name="save">Сохранить</string>
|
<string name="save">Сохранить</string>
|
||||||
|
<string name="no_browser_found_toast">Не найден браузер для открытия ссылки!</string>
|
||||||
</resources>
|
</resources>
|
|
@ -85,4 +85,5 @@
|
||||||
<string name="private_key_label">Private key:</string>
|
<string name="private_key_label">Private key:</string>
|
||||||
<string name="set_keys">Set your own key</string>
|
<string name="set_keys">Set your own key</string>
|
||||||
<string name="save">Save</string>
|
<string name="save">Save</string>
|
||||||
|
<string name="no_browser_found_toast">No browser found to open the URL!</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue