use of org.telegram.ui.LaunchActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class AlertsCreator method createDrawOverlayGroupCallPermissionDialog.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static AlertDialog.Builder createDrawOverlayGroupCallPermissionDialog(Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
String svg = RLottieDrawable.readRes(null, R.raw.pip_voice_request);
GroupCallPipButton button = new GroupCallPipButton(context, 0, true);
button.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
FrameLayout frameLayout = new FrameLayout(context) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
button.setTranslationY(getMeasuredHeight() * 0.28f - button.getMeasuredWidth() / 2f);
button.setTranslationX(getMeasuredWidth() * 0.82f - button.getMeasuredWidth() / 2f);
}
};
frameLayout.setBackground(new GradientDrawable(GradientDrawable.Orientation.BL_TR, new int[] { 0xFF192A3D, 0xFF19514E }));
frameLayout.setClipToOutline(true);
frameLayout.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight() + AndroidUtilities.dp(6), AndroidUtilities.dpf2(6));
}
});
float aspectRatio = 540f / 936f;
View background = new View(context);
background.setBackground(new BitmapDrawable(SvgHelper.getBitmap(svg, AndroidUtilities.dp(320), AndroidUtilities.dp(320 * aspectRatio), false)));
frameLayout.addView(background, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, -1, -1, -1, -1));
frameLayout.addView(button, LayoutHelper.createFrame(117, 117));
builder.setTopView(frameLayout);
builder.setTitle(LocaleController.getString("PermissionDrawAboveOtherAppsGroupCallTitle", R.string.PermissionDrawAboveOtherAppsGroupCallTitle));
builder.setMessage(LocaleController.getString("PermissionDrawAboveOtherAppsGroupCall", R.string.PermissionDrawAboveOtherAppsGroupCall));
builder.setPositiveButton(LocaleController.getString("Enable", R.string.Enable), (dialogInterface, i) -> {
if (context != null) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
Activity activity = AndroidUtilities.findActivity(context);
if (activity instanceof LaunchActivity) {
activity.startActivityForResult(intent, 105);
} else {
context.startActivity(intent);
}
}
} catch (Exception e) {
FileLog.e(e);
}
}
});
builder.notDrawBackgroundOnTopView(true);
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
builder.setTopViewAspectRatio(aspectRatio);
return builder;
}
Aggregations