public static void createShareDialog(Context context, String fileName, Uri uri) {
Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog_sharefile);
dialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.getWindow().setBackgroundDrawable(context.getDrawable(R.drawable.drawable_round_corners));
dialog.findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
dialog.findViewById(R.id.mb_addPassword).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
editFileSettings(context, uri, fileName,false);
dialog.dismiss();
}
});
dialog.findViewById(R.id.tv_shareWithoutPassword).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
// Grant temporary read permission
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// Launch the intent
context.startActivity(Intent.createChooser(shareIntent, "Share File"));
}
});
dialog.show();
}
Comments
Post a Comment