binSaed / flutter_cached_pdfview

Enhanced PDF view for Flutter.
https://pub.dev/packages/flutter_cached_pdfview
MIT License
118 stars 67 forks source link

Black Screen in oppo devices only because of FLAG_SECURE #55

Closed Zeyad-Amr closed 3 years ago

Zeyad-Amr commented 3 years ago

Hi , I am using FLAG_SECURE to avoid screenshots the package works good with FLAG_SECURE in all devices expect in oppo devices it display a black screen i use a native code in android to set FLAG_SECURE i have tryed to use flutter_windowmanager package but i have the same black screen problem in oppo devices only

This my native code in MainActivity.kt ` package com.online.education.mostafa.elsheikh import android.os.Bundle import android.util.Log import android.view.SurfaceView import android.view.View import android.view.ViewGroup import android.view.WindowManager import androidx.annotation.NonNull import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { GeneratedPluginRegistrant.registerWith(flutterEngine); }

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (!setSecureSurfaceView()) { Log.e("MainActivity", "Could not secure the MainActivity!") // React as appropriate. } }

private fun setSecureSurfaceView(): Boolean { val content = findViewById(android.R.id.content) if (!isNonEmptyContainer(content)) { return false } val splashView = content.getChildAt(0) if (!isNonEmptyContainer(splashView)) { return false } val flutterView = (splashView as ViewGroup).getChildAt(0) if (!isNonEmptyContainer(flutterView)) { return false } val surfaceView = (flutterView as ViewGroup).getChildAt(0) if (surfaceView !is SurfaceView) { return false } surfaceView.setSecure(true) this.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) return true }

private fun isNonEmptyContainer(view: View): Boolean { if (view !is ViewGroup) { return false } if (view.childCount < 1) { return false } return true } } ` Any help please ??

binSaed commented 3 years ago

hi @Zeyad-Amr i see u open an issue in flutter_pdfview

sorry but now I don't have time to check for ur issue I will follow up ur opened issue at flutter_pdfview

Thanks