Rename compatibility field in ServerProfile
New name expresses the intent more clearly, and we don't have to do bit-manipulation everywhere.
This commit is contained in:
parent
f1179863ec
commit
8bba056b80
6 changed files with 13 additions and 23 deletions
|
|
@ -2,11 +2,11 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "d00ae8ded858b1d56d7565e660aac292",
|
||||
"identityHash": "ccb0ad6d8acbefcb44a49c07f353adc8",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "profiles",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `host` TEXT NOT NULL, `port` INTEGER NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `securityType` INTEGER NOT NULL, `channelType` INTEGER NOT NULL, `colorLevel` INTEGER NOT NULL, `imageQuality` INTEGER NOT NULL, `viewOnly` INTEGER NOT NULL, `useLocalCursor` INTEGER NOT NULL, `compatMode` INTEGER NOT NULL, `useRepeater` INTEGER NOT NULL, `idOnRepeater` INTEGER NOT NULL, `sshHost` TEXT NOT NULL, `sshPort` INTEGER NOT NULL, `sshUsername` TEXT NOT NULL, `sshAuthType` INTEGER NOT NULL, `sshPassword` TEXT NOT NULL, `sshPrivateKey` TEXT NOT NULL, `sshPrivateKeyPassword` TEXT NOT NULL)",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `host` TEXT NOT NULL, `port` INTEGER NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `securityType` INTEGER NOT NULL, `channelType` INTEGER NOT NULL, `colorLevel` INTEGER NOT NULL, `imageQuality` INTEGER NOT NULL, `viewOnly` INTEGER NOT NULL, `useLocalCursor` INTEGER NOT NULL, `keyCompatMode` INTEGER NOT NULL, `useRepeater` INTEGER NOT NULL, `idOnRepeater` INTEGER NOT NULL, `sshHost` TEXT NOT NULL, `sshPort` INTEGER NOT NULL, `sshUsername` TEXT NOT NULL, `sshAuthType` INTEGER NOT NULL, `sshPassword` TEXT NOT NULL, `sshPrivateKey` TEXT NOT NULL, `sshPrivateKeyPassword` TEXT NOT NULL)",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "ID",
|
||||
|
|
@ -81,8 +81,8 @@
|
|||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "compatMode",
|
||||
"columnName": "compatMode",
|
||||
"fieldPath": "keyCompatMode",
|
||||
"columnName": "keyCompatMode",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
|
|
@ -154,7 +154,7 @@
|
|||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'd00ae8ded858b1d56d7565e660aac292')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ccb0ad6d8acbefcb44a49c07f353adc8')"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -90,11 +90,10 @@ data class ServerProfile(
|
|||
var useLocalCursor: Boolean = false,
|
||||
|
||||
/**
|
||||
* Compatibility mode used for connection.
|
||||
* Currently, used to decide how key events are sent to server.
|
||||
* Set to 0 to disable compatibility mode.
|
||||
* Compatibility mode for key events.
|
||||
* If enabled, we will try to emit legacy X KeySym events.
|
||||
*/
|
||||
var compatMode: Int = COMPAT_MODE_LEGACY_KEYSYM,
|
||||
var keyCompatMode: Boolean = true,
|
||||
|
||||
/**
|
||||
* Whether UltraVNC Repeater is used for connections.
|
||||
|
|
@ -129,8 +128,5 @@ data class ServerProfile(
|
|||
// SSH auth types
|
||||
const val SSH_AUTH_KEY = 1
|
||||
const val SSH_AUTH_PASSWORD = 2
|
||||
|
||||
// Compatibility modes flags
|
||||
const val COMPAT_MODE_LEGACY_KEYSYM = 0x1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,6 @@ class ProfileEditorFragment : DialogFragment() {
|
|||
// We can't use Data Binding to initialize these because it breaks
|
||||
// the inter-dependency among views.
|
||||
useRepeater.isChecked = p.useRepeater
|
||||
keyCompatMode.isChecked = (p.compatMode and ServerProfile.COMPAT_MODE_LEGACY_KEYSYM != 0)
|
||||
useSshTunnel.isChecked = (p.channelType == CHANNEL_SSH_TUNNEL)
|
||||
sshAuthTypePassword.isChecked = (p.sshAuthType == SSH_AUTH_PASSWORD)
|
||||
sshAuthTypeKey.isChecked = (p.sshAuthType == SSH_AUTH_KEY)
|
||||
|
|
@ -198,11 +197,6 @@ class ProfileEditorFragment : DialogFragment() {
|
|||
idOnRepeater = binding.idOnRepeater.text.toString().toIntOrNull() ?: 0
|
||||
channelType = if (binding.useSshTunnel.isChecked) CHANNEL_SSH_TUNNEL else CHANNEL_TCP
|
||||
sshAuthType = if (binding.sshAuthTypeKey.isChecked) SSH_AUTH_KEY else SSH_AUTH_PASSWORD
|
||||
|
||||
if (binding.keyCompatMode.isChecked)
|
||||
compatMode = compatMode or ServerProfile.COMPAT_MODE_LEGACY_KEYSYM
|
||||
else
|
||||
compatMode = compatMode and ServerProfile.COMPAT_MODE_LEGACY_KEYSYM.inv()
|
||||
}
|
||||
|
||||
saveProfile()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ package com.gaurav.avnc.ui.vnc
|
|||
|
||||
import android.os.Build
|
||||
import android.view.KeyEvent
|
||||
import com.gaurav.avnc.model.ServerProfile
|
||||
import com.gaurav.avnc.vnc.XKeySymAndroid
|
||||
import com.gaurav.avnc.vnc.XKeySymUnicode
|
||||
|
||||
|
|
@ -75,7 +74,7 @@ import com.gaurav.avnc.vnc.XKeySymUnicode
|
|||
* [X Windows System Protocol](https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#keysym_encoding)
|
||||
*
|
||||
*/
|
||||
class KeyHandler(private val dispatcher: Dispatcher, private val compatMode: Int) {
|
||||
class KeyHandler(private val dispatcher: Dispatcher, private val compatMode: Boolean) {
|
||||
|
||||
/**
|
||||
* Shortcut to send both up & down events. Useful for Virtual Keys.
|
||||
|
|
@ -172,7 +171,7 @@ class KeyHandler(private val dispatcher: Dispatcher, private val compatMode: Int
|
|||
private fun emitForUnicodeChar(uChar: Int, isDown: Boolean): Boolean {
|
||||
var uKeySym = 0
|
||||
|
||||
if (compatMode and ServerProfile.COMPAT_MODE_LEGACY_KEYSYM != 0)
|
||||
if (compatMode)
|
||||
uKeySym = XKeySymUnicode.getLegacyKeySymForUnicodeChar(uChar)
|
||||
|
||||
if (uKeySym == 0)
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class VncActivity : AppCompatActivity() {
|
|||
lateinit var binding: ActivityVncBinding
|
||||
private val dispatcher by lazy { Dispatcher(viewModel) }
|
||||
val touchHandler by lazy { TouchHandler(viewModel, dispatcher) }
|
||||
val keyHandler by lazy { KeyHandler(dispatcher, profile.compatMode) }
|
||||
val keyHandler by lazy { KeyHandler(dispatcher, profile.keyCompatMode) }
|
||||
private val virtualKeys by lazy { VirtualKeys(this) }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -156,10 +156,11 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/view_only" />
|
||||
|
||||
|
||||
<!--Compatibility mode-->
|
||||
<!--Key Compatibility mode-->
|
||||
<CheckBox
|
||||
android:id="@+id/key_compat_mode"
|
||||
style="@style/FormField.CheckBox"
|
||||
android:checked="@={profile.keyCompatMode}"
|
||||
android:text="@string/title_key_compat_mode"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue