Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class VncClientTest {
override fun onGotXCutText(text: String) {
cutText = text
}
override fun onBell() {}
}


Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/gaurav/avnc/util/AppPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package com.gaurav.avnc.util

import android.content.Context
import android.content.SharedPreferences
import android.media.ToneGenerator
import androidx.core.content.edit
import androidx.lifecycle.LiveData
import androidx.preference.PreferenceManager
Expand All @@ -24,6 +25,7 @@ class AppPreferences(context: Context) {

inner class UI {
val theme = StringLivePref("theme", "system")
var bell by BooleanPref("bell_enabled", true)
var preferAdvancedEditor by BooleanPref("prefer_advanced_editor", false)
val sortServerList = BooleanLivePref("sort_server_list", false)
}
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/gaurav/avnc/util/Tones.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.gaurav.avnc.util

import android.media.AudioManager
import android.media.ToneGenerator
import android.util.Log

object Tones {
private val notifications = ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100)

/**
* @param tone a `TONE_` constant from [ToneGenerator].
*/
fun notify(tone: Int) {
Log.i("Tones", "Notify with tone $tone")
notifications.startTone(tone)
}
}
11 changes: 10 additions & 1 deletion app/src/main/java/com/gaurav/avnc/viewmodel/VncViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package com.gaurav.avnc.viewmodel

import android.app.Application
import android.graphics.RectF
import android.media.ToneGenerator
import android.util.Log
import android.widget.Toast
import androidx.lifecycle.MutableLiveData
Expand All @@ -20,6 +21,7 @@ import com.gaurav.avnc.ui.vnc.FrameScroller
import com.gaurav.avnc.ui.vnc.FrameState
import com.gaurav.avnc.ui.vnc.FrameView
import com.gaurav.avnc.util.LiveRequest
import com.gaurav.avnc.util.Tones
import com.gaurav.avnc.util.broadcastWoLPackets
import com.gaurav.avnc.util.getClipboardText
import com.gaurav.avnc.util.getUnknownCertificateMessage
Expand Down Expand Up @@ -507,4 +509,11 @@ class VncViewModel(app: Application) : BaseViewModel(app), VncClient.Observer {
override fun onPointerMoved(x: Int, y: Int) {
frameViewRef.get()?.requestRender()
}
}

override fun onBell() {
if (pref.ui.bell) {
Tones.notify(ToneGenerator.TONE_PROP_BEEP)
}
}

}
5 changes: 2 additions & 3 deletions app/src/main/java/com/gaurav/avnc/vnc/VncClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class VncClient(private val observer: Observer) {
fun onFramebufferUpdated()
fun onFramebufferSizeChanged(width: Int, height: Int)
fun onPointerMoved(x: Int, y: Int)

//fun onBell()
fun onBell()
}

/**
Expand Down Expand Up @@ -428,7 +427,7 @@ class VncClient(private val observer: Observer) {


@Keep
private fun cbBell() = Unit // observer.onBell()
private fun cbBell() = observer.onBell()

@Keep
private fun cbHandleCursorPos(x: Int, y: Int) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,5 @@
<string name="msg_gesture_style_locked_to_touchpad">Style de geste \'Touchpad\' est actif</string>
<string name="pref_long_press_swipe_disabled_summary">Désactivé par la valeur actuelle du geste <b>Pression longue</b></string>
<string name="pref_toolbar_open_with_swipe">Faites glisser depuis le bord pour ouvrir</string>
<string name="pref_bell">Sonnerie</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@
<item>Item 2</item>
<item>Item 3</item>
</string-array>
</resources>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
<string name="pref_theme_option_system">System</string>
<string name="pref_theme_option_dark">Dark</string>
<string name="pref_theme_option_light">Light</string>
<string name="pref_bell">Bell</string>
<string name="pref_prefer_advanced_editor">Directly open advanced server options</string>
<string name="pref_sort_server_list">Sort saved servers by name</string>
<string name="pref_gesture">Gestures</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/pref_appearance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
app:title="@string/pref_theme"
app:useSimpleSummaryProvider="true" />

<SwitchPreference
app:defaultValue="true"
app:key="bell_enabled"
app:title="@string/pref_bell"/>

<SwitchPreference
app:defaultValue="false"
app:key="sort_server_list"
Expand Down