From 398d8a1e41c21e6c2d6bc6c260f37fc5ba59b285 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 20 Sep 2020 12:47:13 +0200 Subject: AddTunnelsSheet: disable qrcode scanning if no camera Part of the enhancements for Android TV. Signed-off-by: Jason A. Donenfeld --- .../main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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(R.id.create_from_qrcode) + qrcode.isEnabled = false + qrcode.visibility = View.GONE + } + return view } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { -- cgit v1.2.3