diff --git a/app/src/main/java/dev/lowrespalmtree/comet/PageFragment.kt b/app/src/main/java/dev/lowrespalmtree/comet/PageFragment.kt index 9e37ed3..9561592 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/PageFragment.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/PageFragment.kt @@ -3,6 +3,7 @@ package dev.lowrespalmtree.comet import android.app.Activity import android.content.ActivityNotFoundException import android.content.Intent +import android.graphics.Typeface import android.net.Uri import android.os.Bundle import android.text.InputType @@ -136,9 +137,13 @@ class PageFragment : Fragment(), ContentAdapterListener { PageViewModel.State.IDLE -> { binding.contentProgressBar.hide() binding.contentSwipeLayout.isRefreshing = false + binding.addressBar.setText(vm.currentUrl) + binding.addressBar.setTypeface(null, Typeface.NORMAL) } PageViewModel.State.CONNECTING -> { binding.contentProgressBar.show() + binding.addressBar.setText(vm.loadingUrl?.toString() ?: "") + binding.addressBar.setTypeface(null, Typeface.ITALIC) } PageViewModel.State.RECEIVING -> { binding.appBarLayout.setExpanded(true, true) diff --git a/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt b/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt index 5034ab9..2288e77 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt @@ -18,6 +18,8 @@ class PageViewModel(@Suppress("unused") private val savedStateHandle: SavedState ViewModel() { /** Currently viewed page URL. */ var currentUrl: String = "" + /** Latest Uri requested using `sendGeminiRequest`. */ + var loadingUrl: Uri? = null /** Observable page viewer state. */ val state: MutableLiveData by lazy { MutableLiveData(State.IDLE) } /** Observable page viewer lines (backed up by `linesList` but updated less often). */ @@ -52,6 +54,7 @@ class PageViewModel(@Suppress("unused") private val savedStateHandle: SavedState */ fun sendGeminiRequest(uri: Uri, connectionTimeout: Int, readTimeout: Int, redirects: Int = 0) { Log.d(TAG, "sendRequest: URI \"$uri\"") + loadingUrl = uri state.postValue(State.CONNECTING) requestJob?.apply { if (isActive) cancel() } requestJob = viewModelScope.launch(Dispatchers.IO) {