Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release/21.5 into trunk #13425

Merged
merged 5 commits into from
Jan 30, 2025
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 @@ -18,6 +18,7 @@ import com.woocommerce.android.ui.base.BaseFragment
import com.woocommerce.android.ui.base.UIMessageResolver
import com.woocommerce.android.util.PrintHtmlHelper
import com.woocommerce.android.util.UiHelpers
import com.woocommerce.android.util.WooLog
import com.woocommerce.android.viewmodel.MultiLiveEvent.Event.ShowSnackbar
import dagger.hilt.android.AndroidEntryPoint
import java.io.IOException
Expand All @@ -38,6 +39,8 @@ class ReceiptPreviewFragment : BaseFragment(R.layout.fragment_receipt_preview),
private var _binding: FragmentReceiptPreviewBinding? = null
private val binding get() = _binding!!

private var urlToLoad: String? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand All @@ -58,10 +61,12 @@ class ReceiptPreviewFragment : BaseFragment(R.layout.fragment_receipt_preview),
viewModel.onPrintClicked()
true
}

R.id.menu_send -> {
viewModel.onShareClicked()
true
}

else -> false
}
}
Expand Down Expand Up @@ -101,9 +106,12 @@ class ReceiptPreviewFragment : BaseFragment(R.layout.fragment_receipt_preview),
override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
return interceptAndModifyReceiptResponse(request)
}
): WebResourceResponse? =
if (request.url.toString() == urlToLoad) {
interceptAndModifyReceiptResponse(request)
} else {
null
}

override fun onPageFinished(view: WebView, url: String) {
viewModel.onReceiptLoaded()
Expand All @@ -129,7 +137,8 @@ class ReceiptPreviewFragment : BaseFragment(R.layout.fragment_receipt_preview),
} catch (e: MalformedURLException) {
throw IllegalArgumentException("Invalid receipt URL: ${request.url}", e)
} catch (e: IOException) {
throw IOException("Failed to read content from receipt URL: ${request.url}", e)
WooLog.e(WooLog.T.ORDERS, "Failed to read content from receipt URL: ${request.url}", e)
null
}
}

Expand All @@ -140,7 +149,10 @@ class ReceiptPreviewFragment : BaseFragment(R.layout.fragment_receipt_preview),
}
viewModel.event.observe(viewLifecycleOwner) {
when (it) {
is LoadUrl -> binding.receiptPreviewPreviewWebview.loadUrl(it.url)
is LoadUrl -> {
urlToLoad = it.url
binding.receiptPreviewPreviewWebview.loadUrl(it.url)
}
is PrintReceipt -> printHtmlHelper.printReceipt(requireActivity(), it.receiptUrl, it.documentName)
is ShowSnackbar -> uiMessageResolver.showSnack(it.message)
else -> it.isHandled = false
Expand Down
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=21.5-rc-1
versionCode=638
versionName=21.5-rc-2
versionCode=639
Loading