mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-27 21:55:08 +03:00
Fixed UI for Android TV (for d-pad usage). (#47)
This commit is contained in:
parent
ce50b01781
commit
9df80c0612
7 changed files with 70 additions and 42 deletions
|
@ -6,11 +6,11 @@ import android.graphics.Color
|
|||
import android.net.VpnService
|
||||
import android.os.Bundle
|
||||
import android.widget.Switch
|
||||
import android.widget.TableRow
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.core.content.edit
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.preference.PreferenceManager
|
||||
|
@ -26,10 +26,10 @@ class MainActivity : AppCompatActivity() {
|
|||
private lateinit var subnetLabel: TextView
|
||||
private lateinit var coordinatesLabel: TextView
|
||||
private lateinit var peersLabel: TextView
|
||||
private lateinit var peersRow: TableRow
|
||||
private lateinit var peersRow: LinearLayoutCompat
|
||||
private lateinit var dnsLabel: TextView
|
||||
private lateinit var dnsRow: TableRow
|
||||
private lateinit var settingsRow: TableRow
|
||||
private lateinit var dnsRow: LinearLayoutCompat
|
||||
private lateinit var settingsRow: LinearLayoutCompat
|
||||
|
||||
private fun start() {
|
||||
val intent = Intent(this, PacketTunnelProvider::class.java)
|
||||
|
@ -82,7 +82,7 @@ class MainActivity : AppCompatActivity() {
|
|||
preferences.edit(commit = true) { putBoolean(PREF_KEY_ENABLED, isChecked) }
|
||||
}
|
||||
|
||||
val enableYggdrasilPanel = findViewById<TableRow>(R.id.enableYggdrasilPanel)
|
||||
val enableYggdrasilPanel = findViewById<LinearLayoutCompat>(R.id.enableYggdrasilPanel)
|
||||
enableYggdrasilPanel.setOnClickListener {
|
||||
enabledSwitch.toggle()
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class PeersActivity : AppCompatActivity() {
|
|||
view.findViewById<ImageButton>(R.id.deletePeerButton).tag = i
|
||||
|
||||
view.findViewById<ImageButton>(R.id.deletePeerButton).setOnClickListener { button ->
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog))
|
||||
builder.setTitle(getString(R.string.peers_remove_title, peer))
|
||||
builder.setPositiveButton(getString(R.string.peers_remove)) { dialog, _ ->
|
||||
config.updateJSON { json ->
|
||||
|
|
|
@ -5,10 +5,13 @@ import android.content.ClipData
|
|||
import android.content.ClipboardManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import org.json.JSONObject
|
||||
|
||||
|
@ -18,7 +21,7 @@ class SettingsActivity : AppCompatActivity() {
|
|||
|
||||
private lateinit var deviceNameEntry: EditText
|
||||
private lateinit var publicKeyLabel: TextView
|
||||
private lateinit var resetConfigurationRow: TableRow
|
||||
private lateinit var resetConfigurationRow: LinearLayoutCompat
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -41,6 +44,24 @@ class SettingsActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
deviceNameEntry.setOnKeyListener { view, keyCode, event ->
|
||||
(keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER)
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.deviceNameTableRow).setOnKeyListener { view, keyCode, event ->
|
||||
Log.i("Key", keyCode.toString())
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
deviceNameEntry.requestFocus()
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
resetConfigurationRow.setOnClickListener {
|
||||
val view = inflater.inflate(R.layout.dialog_resetconfig, null)
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(ContextThemeWrapper(this, R.style.Theme_MaterialComponents_DayNight_Dialog))
|
||||
|
|
|
@ -223,6 +223,7 @@
|
|||
android:layout_marginStart="16pt"
|
||||
android:layout_marginLeft="16pt"
|
||||
android:layout_marginTop="4pt"
|
||||
android:layout_marginBottom="4pt"
|
||||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:alpha="0.7"
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TableLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/connectedPeersTableLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8pt"
|
||||
|
@ -70,7 +71,7 @@
|
|||
android:paddingBottom="2pt"
|
||||
android:showDividers="middle">
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/enableYggdrasilPanel"
|
||||
style="@style/SelectableSwitchItemStyle">
|
||||
|
||||
|
@ -92,9 +93,9 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow style="@style/SelectableItemStyle">
|
||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/yggdrasilStatusLabel"
|
||||
|
@ -106,9 +107,9 @@
|
|||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</TableLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
|
@ -130,8 +131,9 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TableLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/configuredPeersTableLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8pt"
|
||||
|
@ -148,7 +150,7 @@
|
|||
android:paddingBottom="2pt"
|
||||
android:showDividers="middle">
|
||||
|
||||
<TableRow style="@style/SelectableItemStyle">
|
||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ipAddressLabel"
|
||||
|
@ -172,9 +174,9 @@
|
|||
android:textAlignment="viewEnd"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="14sp" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow style="@style/SelectableItemStyle">
|
||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subnetLabel"
|
||||
|
@ -199,9 +201,9 @@
|
|||
android:textIsSelectable="true"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow style="@style/SelectableItemStyle">
|
||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/coordinatesLabel"
|
||||
|
@ -225,9 +227,9 @@
|
|||
android:text="[]"
|
||||
android:textAlignment="viewEnd"
|
||||
android:textIsSelectable="true" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</TableLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
|
@ -249,8 +251,9 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TableLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/configurationTableLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8pt"
|
||||
|
@ -258,7 +261,6 @@
|
|||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:background="@drawable/rounded"
|
||||
android:clickable="true"
|
||||
android:divider="#46878787"
|
||||
android:dividerPadding="4pt"
|
||||
android:paddingLeft="4pt"
|
||||
|
@ -267,7 +269,7 @@
|
|||
android:paddingBottom="2pt"
|
||||
android:showDividers="middle">
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/peersTableRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -302,9 +304,9 @@
|
|||
android:scaleX="1.2"
|
||||
android:scaleY="1.2"
|
||||
app:srcCompat="@drawable/ic_baseline_chevron_right_24" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/dnsTableRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -339,9 +341,9 @@
|
|||
android:scaleX="1.2"
|
||||
android:scaleY="1.2"
|
||||
app:srcCompat="@drawable/ic_baseline_chevron_right_24" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/settingsTableRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -373,9 +375,9 @@
|
|||
android:scaleY="1.2"
|
||||
app:srcCompat="@drawable/ic_baseline_chevron_right_24" />
|
||||
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow style="@style/SelectableItemStyle">
|
||||
<androidx.appcompat.widget.LinearLayoutCompat style="@style/SelectableItemStyle">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/versionLabel"
|
||||
|
@ -397,9 +399,9 @@
|
|||
android:text="@string/main_unknown"
|
||||
android:textAlignment="textEnd" />
|
||||
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</TableLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -407,6 +409,7 @@
|
|||
android:layout_marginStart="16pt"
|
||||
android:layout_marginLeft="16pt"
|
||||
android:layout_marginTop="4pt"
|
||||
android:layout_marginBottom="4pt"
|
||||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:alpha="0.7"
|
||||
|
|
|
@ -225,6 +225,7 @@
|
|||
android:layout_marginStart="16pt"
|
||||
android:layout_marginLeft="16pt"
|
||||
android:layout_marginTop="4pt"
|
||||
android:layout_marginBottom="4pt"
|
||||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:alpha="0.7"
|
||||
|
|
|
@ -173,6 +173,7 @@
|
|||
android:id="@+id/publicKeyLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
android:fontFamily="monospace"
|
||||
android:text="@string/public_key"
|
||||
android:textSize="14sp" />
|
||||
|
@ -216,8 +217,9 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TableLayout
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/backupTableLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8pt"
|
||||
|
@ -225,7 +227,6 @@
|
|||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:background="@drawable/rounded"
|
||||
android:clickable="true"
|
||||
android:divider="#46878787"
|
||||
android:dividerPadding="4pt"
|
||||
android:paddingLeft="4pt"
|
||||
|
@ -234,7 +235,7 @@
|
|||
android:paddingBottom="2pt"
|
||||
android:showDividers="middle">
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/resetKeysRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -242,9 +243,9 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/regenerate_keys" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/setKeysRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -252,9 +253,9 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_keys" />
|
||||
</TableRow>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TableRow
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/resetConfigurationRow"
|
||||
style="@style/SelectableItemStyle">
|
||||
|
||||
|
@ -263,15 +264,16 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/reset_configuration"
|
||||
android:textColor="@android:color/holo_red_dark" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16pt"
|
||||
android:layout_marginLeft="16pt"
|
||||
android:layout_marginTop="2pt"
|
||||
android:layout_marginTop="4pt"
|
||||
android:layout_marginBottom="4pt"
|
||||
android:layout_marginEnd="8pt"
|
||||
android:layout_marginRight="8pt"
|
||||
android:alpha="0.7"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue