Search in sources :

Example 6 with LaunchActivity

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;
}
Also used : AlertDialog(org.telegram.ui.ActionBar.AlertDialog) SpannableStringBuilder(android.text.SpannableStringBuilder) CacheControlActivity(org.telegram.ui.CacheControlActivity) LaunchActivity(org.telegram.ui.LaunchActivity) ChatActivity(org.telegram.ui.ChatActivity) ThemePreviewActivity(org.telegram.ui.ThemePreviewActivity) NotificationsCustomSettingsActivity(org.telegram.ui.NotificationsCustomSettingsActivity) ProfileNotificationsActivity(org.telegram.ui.ProfileNotificationsActivity) LanguageSelectActivity(org.telegram.ui.LanguageSelectActivity) TooManyCommunitiesActivity(org.telegram.ui.TooManyCommunitiesActivity) NotificationsSettingsActivity(org.telegram.ui.NotificationsSettingsActivity) LoginActivity(org.telegram.ui.LoginActivity) Activity(android.app.Activity) Outline(android.graphics.Outline) Intent(android.content.Intent) SpannableString(android.text.SpannableString) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View) TextView(android.widget.TextView) GradientDrawable(android.graphics.drawable.GradientDrawable) LaunchActivity(org.telegram.ui.LaunchActivity) FrameLayout(android.widget.FrameLayout) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

LaunchActivity (org.telegram.ui.LaunchActivity)6 Intent (android.content.Intent)3 Activity (android.app.Activity)2 SharedPreferences (android.content.SharedPreferences)2 Bitmap (android.graphics.Bitmap)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 View (android.view.View)2 TLRPC (org.telegram.tgnet.TLRPC)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Canvas (android.graphics.Canvas)1 Color (android.graphics.Color)1 ComposeShader (android.graphics.ComposeShader)1 LinearGradient (android.graphics.LinearGradient)1 Outline (android.graphics.Outline)1 Paint (android.graphics.Paint)1