diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt index dc79acb..af70595 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt @@ -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(R.id.enableYggdrasilPanel) + val enableYggdrasilPanel = findViewById(R.id.enableYggdrasilPanel) enableYggdrasilPanel.setOnClickListener { enabledSwitch.toggle() } diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt index 2f5acce..a3f4e08 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/PeersActivity.kt @@ -121,7 +121,7 @@ class PeersActivity : AppCompatActivity() { view.findViewById(R.id.deletePeerButton).tag = i view.findViewById(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 -> diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt index b4e8779..acb2b54 100644 --- a/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt +++ b/app/src/main/java/eu/neilalexander/yggdrasil/SettingsActivity.kt @@ -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(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)) diff --git a/app/src/main/res/layout/activity_dns.xml b/app/src/main/res/layout/activity_dns.xml index eb00e02..d0061e8 100644 --- a/app/src/main/res/layout/activity_dns.xml +++ b/app/src/main/res/layout/activity_dns.xml @@ -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" diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 8ff639a..bf7028c 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -52,8 +52,9 @@ android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textSize="12sp" /> - - @@ -92,9 +93,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> - + - + - + - + - - + - + - + - + - + - + - + - - @@ -302,9 +304,9 @@ android:scaleX="1.2" android:scaleY="1.2" app:srcCompat="@drawable/ic_baseline_chevron_right_24" /> - + - @@ -339,9 +341,9 @@ android:scaleX="1.2" android:scaleY="1.2" app:srcCompat="@drawable/ic_baseline_chevron_right_24" /> - + - @@ -373,9 +375,9 @@ android:scaleY="1.2" app:srcCompat="@drawable/ic_baseline_chevron_right_24" /> - + - + - + - + @@ -216,8 +217,9 @@ android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textSize="12sp" /> - - @@ -242,9 +243,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/regenerate_keys" /> - + - @@ -252,9 +253,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/set_keys" /> - + - @@ -263,15 +264,16 @@ android:layout_height="wrap_content" android:text="@string/reset_configuration" android:textColor="@android:color/holo_red_dark" /> - - + +