| | |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.graphics.Color; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.Window; |
| | | import android.view.WindowManager; |
| | | import android.widget.Button; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | |
| | | public class QRCodeDialog extends DialogFragment { |
| | | private static final String TAG = "QRCodeDialog"; |
| | | private String message="正在加载..."; |
| | | private boolean canCancel= true; |
| | | private boolean canCancel= false; |
| | | private ImageView iv_qrCode; |
| | | private Button btn; |
| | | private Bitmap qrBitmap; |
| | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | if (getDialog() != null) { |
| | | Window window = getDialog().getWindow(); |
| | | |
| | | if (window != null) { |
| | | window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); |
| | | window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); |
| | | |
| | | getDialog().setOnShowListener(dialog -> { |
| | | window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); |
| | | hideBottomUIMenu(); |
| | | }); |
| | | } |
| | | } |
| | | View view = inflater.inflate(R.layout.layout_dialog_qrcode,container,false); |
| | | initView(view); |
| | | setCancelable(canCancel); |
| | | |
| | | Message message = Message.obtain(); |
| | | message.what = 1; |
| | | handler.sendMessageDelayed(message,15*1000); |
| | | handler.sendMessageDelayed(message,25*1000); |
| | | return view; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 隐藏虚拟按键,并且全屏 |
| | | */ |
| | | protected void hideBottomUIMenu() { |
| | | //隐藏虚拟按键,并且全屏 |
| | | if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api |
| | | View v = this.getDialog().getWindow().getDecorView(); |
| | | v.setSystemUiVisibility(View.GONE); |
| | | } else if (Build.VERSION.SDK_INT >= 19) { |
| | | //for new api versions. |
| | | View decorView = getDialog().getWindow().getDecorView(); |
| | | int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
| | | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN; |
| | | decorView.setSystemUiVisibility(uiOptions); |
| | | } |
| | | } |
| | | } |