summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-20 12:47:13 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-20 12:47:13 +0200
commit398d8a1e41c21e6c2d6bc6c260f37fc5ba59b285 (patch)
tree221e5a1ee7c584d1dd63f7d177bcb72d216a04be /ui/src/main/java
parentdfd8ca6f7983f1fd346bf219f0d643e5a1efc7d2 (diff)
AddTunnelsSheet: disable qrcode scanning if no camera
Part of the enhancements for Android TV. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt9
1 files changed, 8 insertions, 1 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt b/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt
index c0e013a4..8f56084b 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt
@@ -4,6 +4,7 @@
*/
package com.wireguard.android.fragment
+import android.content.pm.PackageManager
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.LayoutInflater
@@ -39,7 +40,13 @@ class AddTunnelsSheet : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
if (savedInstanceState != null) dismiss()
- return inflater.inflate(R.layout.add_tunnels_bottom_sheet, container, false)
+ val view = inflater.inflate(R.layout.add_tunnels_bottom_sheet, container, false)
+ if (activity?.packageManager?.hasSystemFeature(PackageManager.FEATURE_CAMERA) != true) {
+ val qrcode = view.findViewById<View>(R.id.create_from_qrcode)
+ qrcode.isEnabled = false
+ qrcode.visibility = View.GONE
+ }
+ return view
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {