Sahifa fonini berish misoli
Foydalanilgan adabiyotlar ro’yhati
Download 394.23 Kb.
|
Ikki o’lchovli tasvirlarni harakatli tasvirlar orqali vizuallashtirish
Foydalanilgan adabiyotlar ro’yhati
Oʻzbekiston Respublikasi Prezidentining 2020 – yil 5 – oktyabrdagi PF-6079-son “Raqamli Oʻzbekiston – 2030” strategiyasi tasdiqlash va uni samarali amalga oshirish chora – tadbirlari toʻgʻrisidagi farmoni. Java Programming For Beginners – A simple Start to Java Programming by SCOTT SANDERSON,221 pages,Bestsellor book. Easy Java Programming for Beginners, Your Step-By-Step Guide to Learning Java Programming by Felix Alvaro (2016) Mark L. Murphy (2012). The Busy Coder's Guide To Android Development Reto Meier (2012). Professional Android 4 Application Development Marko Gargenta (2012). Learning Android Jeff Friesen (2012). Learn Java for Android Development The Restaurant Manager’s Handbook: How to Set Up, Operate, and Manage a Financially Successful Food Service Operation by Douglas Robert Brown (2019). Mario Zechner, Robert Green (2012). Beginning Android Games Reto Meier (2008). Professional Android Application Development Raximov O.D Hayot faoliyat xavfsizligi. O’quv-uslubiy majmua. Qarshi, 2012, 857bet. https://fayllar.org/iv-hayot-faoliyati-va-xavfsizligi https://docs.oracle.com/en/java/javase/18/ https://docs.oracle.com/en/java/ Ilova: package com.example.qr_scanner.ui import android.Manifest import android.app.Activity import android.app.AlertDialog import android.content.ActivityNotFoundException import android.content.Context import android.content.DialogInterface import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Build import android.os.Bundle import android.provider.Settings import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.test.core.app.ApplicationProvider import com.budiyev.android.codescanner.* import com.example.qr_scanner.R import com.example.qr_scanner.WebviewActivity import com.example.qr_scanner.databinding.FragmentFirstBinding import com.karumi.dexter.Dexter import com.karumi.dexter.PermissionToken import com.karumi.dexter.listener.PermissionDeniedResponse import com.karumi.dexter.listener.PermissionGrantedResponse import com.karumi.dexter.listener.PermissionRequest import com.karumi.dexter.listener.single.PermissionListener private const val ARG_PARAM1 = "param1" private const val ARG_PARAM2 = "param2" private const val PERMISSION_REQUEST_CODE = 200 class FirstFragment : Fragment() { private var _binding: FragmentFirstBinding? = null private val binding get() = _binding!! private lateinit var codeScanner: CodeScanner override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { if(!checkPermission()) { // showPermissionDialog() } _binding = FragmentFirstBinding.inflate(inflater, container, false) return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) // showPermissionDialog() try { Dexter.withContext(requireActivity()) .withPermission(Manifest.permission.CAMERA) .withListener(object : PermissionListener { override fun onPermissionGranted(response: PermissionGrantedResponse) { codeScanner = CodeScanner(requireActivity(), binding.scannerView) loadQrCodeScanner() } override fun onPermissionDenied(response: PermissionDeniedResponse) { // showSettingsDialog() } override fun onPermissionRationaleShouldBeShown( permission: PermissionRequest?, token: PermissionToken? ) { // showSettingsDialog() } }).check() }catch(er:java.lang.Exception) { } } private fun checkPermission(): Boolean { return if (context?.let { ContextCompat.checkSelfPermission(it, Manifest.permission.CAMERA) } != PackageManager.PERMISSION_GRANTED ) { // Permission is not granted false } else true } private val permissionsResultCallback = registerForActivityResult( ActivityResultContracts.RequestPermission()){ when (it) { true -> { println("Permission has been granted by user") } false -> { Toast.makeText(requireContext(), "Permission denied", Toast.LENGTH_SHORT).show() //show your custom dialog and naviage to Permission seetings } } } private fun showPermissionDialog() { val builder = AlertDialog.Builder(requireContext()) builder.setTitle("Permission required") builder.setMessage("Some permissions are needed to be allowed to use this app without any problems.") builder.setPositiveButton("Grant") { dialog, which -> dialog.cancel() val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) val uri = Uri.fromParts("package", requireActivity().packageName, null) intent.data = uri startActivity(intent) } builder.setNegativeButton("Cancel") { dialog, which -> dialog.dismiss() } builder.show() } private fun showMessageOKCancel(message: String, okListener: DialogInterface.OnClickListener) { AlertDialog.Builder(context) .setMessage(message) .setPositiveButton("OK", okListener) .setNegativeButton("Cancel", null) .create() .show() } private fun showSettingsDialog() { val builder: AlertDialog.Builder = AlertDialog.Builder(requireActivity()) builder.setTitle("Bu dastur ishlashi uchun cameraga ruhsat kerak !") builder.setMessage("Sozlamalar bo'limdan kamerga ruhsat bering.") builder.setIcon(R.drawable.baseline_camera_alt_24) builder.setPositiveButton("GOTO SETTINGS") { dialog, which -> dialog.cancel() val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) val uri = Uri.fromParts("package", activity?.packageName, null) intent.data = uri startActivityForResult(intent, 101) } builder.setNegativeButton("Cancel") { dialog, which -> dialog.cancel() } builder.show() } private fun loadQrCodeScanner() { // Parameters (default values) codeScanner.camera = CodeScanner.CAMERA_BACK // or CAMERA_FRONT or specific camera id codeScanner.formats = CodeScanner.ALL_FORMATS // list of type BarcodeFormat, // ex. listOf(BarcodeFormat.QR_CODE) codeScanner.autoFocusMode = AutoFocusMode.SAFE // or CONTINUOUS codeScanner.scanMode = ScanMode.SINGLE // or CONTINUOUS or PREVIEW codeScanner.isAutoFocusEnabled = true // Whether to enable auto focus or not codeScanner.isFlashEnabled = false // Whether to enable flash or not codeScanner.decodeCallback = DecodeCallback { activity?.runOnUiThread { try { val intent = Intent(context,WebviewActivity::class.java) intent.putExtra("url", it.text) startActivity(intent) } catch (e: ActivityNotFoundException) { Toast.makeText( requireActivity(), "No application can handle this request." + " Please install a webbrowser", Toast.LENGTH_LONG ).show() e.printStackTrace() } } } codeScanner.errorCallback = ErrorCallback { // or ErrorCallback.SUPPRESS activity?.runOnUiThread { Toast.makeText( requireActivity(), "Camera initialization error: ${it.message}", Toast.LENGTH_LONG ).show() } } binding.scannerView.setOnClickListener { codeScanner.startPreview() } } override fun onResume() { super.onResume() if(checkPermission()) codeScanner.startPreview() } override fun onPause() { super.onPause() // if(checkPermission()) // codeScanner.startPreview() } } package com.example.qr_scanner import android.Manifest import android.app.AlertDialog import android.content.DialogInterface import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.provider.Settings import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) // Toast.makeText(this,"salom",Toast.LENGTH_LONG).show() if(!checkPermission()) { // showPermissionDialog() } } private fun checkPermission(): Boolean { return if (this.let { ContextCompat.checkSelfPermission(it, Manifest.permission.CAMERA) } != PackageManager.PERMISSION_GRANTED ) { // Permission is not granted false } else true } private val permissionsResultCallback = registerForActivityResult( ActivityResultContracts.RequestPermission()){ when (it) { true -> { println("Permission has been granted by user") } false -> { Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show() //show your custom dialog and naviage to Permission seetings } } } private fun showPermissionDialog() { val builder = AlertDialog.Builder(this) builder.setTitle("Permission required") builder.setMessage("Some permissions are needed to be allowed to use this app without any problems.") builder.setPositiveButton("Grant") { dialog, which -> dialog.cancel() val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) val uri = Uri.fromParts("package", this.packageName, null) intent.data = uri startActivity(intent) } builder.setNegativeButton("Cancel") { dialog, which -> dialog.dismiss() } builder.show() } private fun showMessageOKCancel(message: String, okListener: DialogInterface.OnClickListener) { AlertDialog.Builder(this) .setMessage(message) .setPositiveButton("OK", okListener) .setNegativeButton("Cancel", null) .create() .show() } } Download 394.23 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling