[Android] Fix auto paste in streams fragment for Android 10
Nicolas Pomepuy
git at videolan.org
Wed Aug 5 14:25:24 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Aug 4 09:07:14 2020 +0200| [0d2e1ab24269f9ef00e828ce241e28103035020e] | committer: Nicolas Pomepuy
Fix auto paste in streams fragment for Android 10
> https://code.videolan.org/videolan/vlc-android/commit/0d2e1ab24269f9ef00e828ce241e28103035020e
---
.../src/org/videolan/vlc/gui/network/MRLPanelFragment.kt | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
index d225536e8..6f22beeff 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/network/MRLPanelFragment.kt
@@ -21,6 +21,7 @@
package org.videolan.vlc.gui.network
import android.content.ClipboardManager
+import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
@@ -33,9 +34,11 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.getSystemService
import androidx.core.net.toUri
+import androidx.core.view.doOnLayout
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
+import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
@@ -114,9 +117,12 @@ class MRLPanelFragment : Fragment(), View.OnKeyListener, TextView.OnEditorAction
override fun onResume() {
super.onResume()
- val clipBoardManager = requireContext().getSystemService<ClipboardManager>()!!
- val text = clipBoardManager.primaryClip?.getItemAt(0)?.text?.toString()
- if (text.isValidUrl()) viewModel.observableSearchText.set(text)
+ //Needed after privacy changes made in Android 10
+ editText.doOnLayout {
+ val clipBoardManager = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
+ val text = clipBoardManager?.primaryClip?.getItemAt(0)?.text?.toString()
+ if (text.isValidUrl()) viewModel.observableSearchText.set(text)
+ }
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
More information about the Android
mailing list