florent37 / TutoShowcase

A simple and Elegant Showcase view for Android
Apache License 2.0
508 stars 89 forks source link

Displaced circle and round rect when activity in full screen. #12

Open alexandrucaraus opened 7 years ago

alexandrucaraus commented 7 years ago

The circle or rect is displaced when the activity is in full screen. I copied the project over and fixed it in the following way.

`public final class TutoShowcase {

public static final float DEFAULT_ADDITIONAL_RADIUS_RATIO = 1.5f;
private static final String SHARED_TUTO = "SHARED_TUTO";
private FrameLayout container;
private TutoView tutoView;
private SharedPreferences sharedPreferences;
private boolean isFullScreen = false;

private TutoShowcase(@NonNull Activity activity) {
    this.sharedPreferences = activity.getSharedPreferences(SHARED_TUTO, Context.MODE_PRIVATE);
    this.container = new FrameLayout(activity);
    this.tutoView = new TutoView(activity);
    Window window = activity.getWindow();
    if (window != null) {
        ViewGroup decorView = (ViewGroup) window.getDecorView();
        if (decorView != null) {
            ViewGroup content = (ViewGroup) decorView.findViewById(android.R.id.content);
            if (content != null) {
                content.addView(container, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                this.container.addView(tutoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            }
        }
    }

    int flg = activity.getWindow().getAttributes().flags;
    if ((flg & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
        isFullScreen = true;
    }

    this.container.setVisibility(View.GONE);
    ViewCompat.setAlpha(container, 0f);
}`

`public static class ViewActions { private final TutoShowcase tutoShowcase; private final View view; private final ViewActionsSettings settings; private final boolean isFullScreen;

    public ViewActions(final TutoShowcase tutoShowcase, View view, boolean fullScreen) {
        this.tutoShowcase = tutoShowcase;
        this.view = view;
        this.settings = new ViewActionsSettings();
        this.isFullScreen = fullScreen;
    }`

` private int getStatusBarHeight() { int result = 0; Context context = view.getContext(); Resources resources = context.getResources(); int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = resources.getDimensionPixelSize(resourceId); } if( isFullScreen ) { result = 0; }

        return result;
    }`