@@ -79,6 +79,11 @@ class PdfReaderActivity : AppCompatActivity() {
7979 private val profilesController =
8080 this .services.requireService(ProfilesControllerType ::class .java)
8181
82+ private lateinit var toolbarTOC: View
83+ private lateinit var toolbarSettings: View
84+ private lateinit var toolbarBack: View
85+ private lateinit var toolbarText: TextView
86+ private lateinit var toolbar: ViewGroup
8287 private lateinit var account: AccountType
8388 private lateinit var accountId: AccountID
8489 private lateinit var bookFormat: BookFormat .BookFormatPDF
@@ -91,7 +96,8 @@ class PdfReaderActivity : AppCompatActivity() {
9196
9297 private var backgroundThread: ExecutorService ? = null
9398 private var pdfServer: PdfServer ? = null
94- private var isSidebarOpen = false
99+ private var isSidebarOpen = true
100+ private var isSettingsOpen: Boolean = false
95101 private var documentPageIndex: Int = 0
96102
97103 override fun onCreate (savedInstanceState : Bundle ? ) {
@@ -199,28 +205,28 @@ class PdfReaderActivity : AppCompatActivity() {
199205 private fun createToolbar (
200206 title : String
201207 ) {
202- val toolbar =
203- this .findViewById< ViewGroup > (R .id.pdfToolbar)
204- val toolbarText =
205- toolbar.findViewById< TextView > (R .id.pdfToolbarText)
206- val toolbarBack =
207- toolbar.findViewById< View > (R .id.pdfToolbarLogoTouch)
208- val toolbarSettings =
209- toolbar.findViewById< View > (R .id.pdfToolbarSettingsIconTouch)
210- val toolbarTOC =
211- toolbar.findViewById< View > (R .id.pdfToolbarTOCIconTouch)
212-
213- toolbarBack.setOnClickListener {
208+ this . toolbar =
209+ this .findViewById(R .id.pdfToolbar)
210+ this . toolbarText =
211+ this . toolbar.findViewById(R .id.pdfToolbarText)
212+ this . toolbarBack =
213+ this . toolbar.findViewById(R .id.pdfToolbarLogoTouch)
214+ this . toolbarSettings =
215+ this . toolbar.findViewById(R .id.pdfToolbarSettingsIconTouch)
216+ this . toolbarTOC =
217+ this . toolbar.findViewById(R .id.pdfToolbarTOCIconTouch)
218+
219+ this . toolbarBack.setOnClickListener {
214220 this .finish()
215221 }
216- toolbarSettings.setOnClickListener {
222+ this . toolbarSettings.setOnClickListener {
217223 this .onReaderMenuSettingsSelected()
218224 }
219- toolbarTOC.setOnClickListener {
225+ this . toolbarTOC.setOnClickListener {
220226 this .onReaderMenuTOCSelected()
221227 }
222- toolbarText.text = title
223- toolbarBack.requestFocus()
228+ this . toolbarText.text = title
229+ this . toolbarBack.requestFocus()
224230 }
225231
226232 private fun createWebView () {
@@ -314,20 +320,44 @@ class PdfReaderActivity : AppCompatActivity() {
314320 }
315321
316322 private fun toggleSidebar () {
317- if (::webView.isInitialized) {
323+ if (this ::webView.isInitialized) {
318324 this .webView.evaluateJavascript(" toggleSidebar()" ) { result ->
319325 this .isSidebarOpen = (result == " true" )
326+ this .setSidebarButtonContentDescription()
320327 }
321328 }
322329 }
323330
331+ private fun setSidebarButtonContentDescription () {
332+ if (this .isSidebarOpen) {
333+ this .toolbarTOC.contentDescription =
334+ this .resources.getString(R .string.accessibility_toc_close)
335+ } else {
336+ this .toolbarTOC.contentDescription =
337+ this .resources.getString(R .string.accessibility_toc_open)
338+ }
339+ }
340+
324341 private fun onReaderMenuSettingsSelected (): Boolean {
325- if (::webView.isInitialized) {
326- this .webView.evaluateJavascript(" toggleSecondaryToolbar()" , null )
342+ if (this ::webView.isInitialized) {
343+ this .webView.evaluateJavascript(" toggleSecondaryToolbar()" ) { result ->
344+ this .isSettingsOpen = (result == " true" )
345+ this .setSettingsButtonContentDescription()
346+ }
327347 }
328348 return true
329349 }
330350
351+ private fun setSettingsButtonContentDescription () {
352+ if (this .isSettingsOpen) {
353+ this .toolbarTOC.contentDescription =
354+ this .resources.getString(R .string.accessibility_settings_close)
355+ } else {
356+ this .toolbarTOC.contentDescription =
357+ this .resources.getString(R .string.accessibility_settings_open)
358+ }
359+ }
360+
331361 override fun onDestroy () {
332362 try {
333363 this .pdfServer?.stop()
0 commit comments