From 3f63c0a81ad04d9261579099f4f7c73ee9a5a049 Mon Sep 17 00:00:00 2001 From: sounddrill31 Date: Sat, 17 Aug 2024 03:27:28 +0530 Subject: [PATCH] Give Reason during Login Screen - Also fix Compatibility with Kitkat - Give multiple Reasons --- .../com/zeusinstitute/upiapp/FirstFragment.kt | 27 +++++++++++-------- .../java/com/zeusinstitute/upiapp/Login.kt | 26 ++++++++++++++---- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/zeusinstitute/upiapp/FirstFragment.kt b/app/src/main/java/com/zeusinstitute/upiapp/FirstFragment.kt index 01f452b..c972732 100644 --- a/app/src/main/java/com/zeusinstitute/upiapp/FirstFragment.kt +++ b/app/src/main/java/com/zeusinstitute/upiapp/FirstFragment.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.SharedPreferences import android.graphics.Bitmap import android.graphics.Color +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -33,12 +34,14 @@ class FirstFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList savedInstanceState: Bundle? ): View? { _binding = FragmentFirstBinding.inflate(inflater, container, false) - qrCodeImageView = binding.qrCodeImageView // Initialize qrCodeImageView + qrCodeImageView = binding.qrCodeImageView - // Make status bar transparent - val window = requireActivity().window - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - window.statusBarColor = Color.TRANSPARENT + // Make status bar transparent (conditionally for Lollipop and above) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + val window = requireActivity().window + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + window.statusBarColor = Color.TRANSPARENT + } return binding.root } @@ -81,12 +84,14 @@ class FirstFragment : Fragment(), SharedPreferences.OnSharedPreferenceChangeList override fun onDestroyView() { super.onDestroyView() sharedPref.unregisterOnSharedPreferenceChangeListener(this) // Unregister listener - val windowInsetsController = - ViewCompat.getWindowInsetsController(requireActivity().window.decorView) - windowInsetsController?.show(WindowInsetsCompat.Type.systemBars()) - val window = requireActivity().window - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - window.statusBarColor = Color.TRANSPARENT // or any other color you want + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + val windowInsetsController = + ViewCompat.getWindowInsetsController(requireActivity().window.decorView) + windowInsetsController?.show(WindowInsetsCompat.Type.systemBars()) + val window = requireActivity().window + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + window.statusBarColor = Color.TRANSPARENT // or any other color you want + } _binding = null } } \ No newline at end of file diff --git a/app/src/main/java/com/zeusinstitute/upiapp/Login.kt b/app/src/main/java/com/zeusinstitute/upiapp/Login.kt index 48fa42f..0479382 100644 --- a/app/src/main/java/com/zeusinstitute/upiapp/Login.kt +++ b/app/src/main/java/com/zeusinstitute/upiapp/Login.kt @@ -9,12 +9,12 @@ import android.view.View import android.view.ViewGroup import android.view.inputmethod.EditorInfo import android.widget.Button -import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import com.google.android.material.textfield.TextInputEditText +import com.google.android.material.textfield.TextInputLayout class Login : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -30,6 +30,7 @@ class Login : Fragment() { ): View? { val view = inflater.inflate(R.layout.fragment_login, container, false) + val apikeyLayout = view.findViewById(R.id.apikeyLayout) val apikey = view.findViewById(R.id.apikey) val submitButton = view.findViewById