Example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

List of usage examples for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.

Prototype

int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

To view the source code for android.view View SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View would like its window to be laid out as if it has requested #SYSTEM_UI_FLAG_FULLSCREEN , even if it currently hasn't.

Usage

From source file:jmri.enginedriver.throttle.java

protected void setImmersiveModeOn(View webView) {
    immersiveModeIsOn = false;/*  w  ww  .jav a 2 s .  c  o m*/

    if (prefThrottleViewImmersiveMode) { // if the preference is set use Immersive mode
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
            immersiveModeIsOn = true;
            webView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

@TargetApi(16)
private void openCamera() {
    if (cameraView == null) {
        return;//from  ww w. j a  v  a 2s  . co  m
    }
    animateCameraValues[0] = 0;
    animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX;
    animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY;
    cameraAnimationInProgress = true;
    cameraPanel.setVisibility(View.VISIBLE);
    cameraPanel.setTag(null);
    ArrayList<Animator> animators = new ArrayList<>();
    animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f, 1.0f));
    animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f));
    for (int a = 0; a < 2; a++) {
        if (flashModeButton[a].getVisibility() == View.VISIBLE) {
            animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 1.0f));
            break;
        }
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    animatorSet.setDuration(200);
    animatorSet.addListener(new AnimatorListenerAdapterProxy() {
        @Override
        public void onAnimationEnd(Animator animator) {
            cameraAnimationInProgress = false;
        }
    });
    animatorSet.start();
    if (Build.VERSION.SDK_INT >= 21) {
        cameraView
                .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);
    }
    cameraOpened = true;
}

From source file:org.telegram.ui.Components.ChatAttachAlert.java

@TargetApi(16)
public void closeCamera(boolean animated) {
    if (takingPhoto || cameraView == null) {
        return;//from ww w  . j av  a  2  s.com
    }
    animateCameraValues[1] = AndroidUtilities.dp(80) - cameraViewOffsetX;
    animateCameraValues[2] = AndroidUtilities.dp(80) - cameraViewOffsetY;
    if (animated) {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) cameraView.getLayoutParams();
        animateCameraValues[0] = layoutParams.topMargin = (int) cameraView.getTranslationY();
        cameraView.setLayoutParams(layoutParams);
        cameraView.setTranslationY(0);

        cameraAnimationInProgress = true;
        ArrayList<Animator> animators = new ArrayList<>();
        animators.add(ObjectAnimator.ofFloat(ChatAttachAlert.this, "cameraOpenProgress", 0.0f));
        animators.add(ObjectAnimator.ofFloat(cameraPanel, "alpha", 0.0f));
        for (int a = 0; a < 2; a++) {
            if (flashModeButton[a].getVisibility() == View.VISIBLE) {
                animators.add(ObjectAnimator.ofFloat(flashModeButton[a], "alpha", 0.0f));
                break;
            }
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.setDuration(200);
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animator) {
                cameraAnimationInProgress = false;
                cameraPanel.setVisibility(View.GONE);
                cameraOpened = false;
                if (Build.VERSION.SDK_INT >= 21) {
                    cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
                }
            }
        });
        animatorSet.start();
    } else {
        animateCameraValues[0] = 0;
        setCameraOpenProgress(0);
        cameraPanel.setAlpha(0);
        cameraPanel.setVisibility(View.GONE);
        for (int a = 0; a < 2; a++) {
            if (flashModeButton[a].getVisibility() == View.VISIBLE) {
                flashModeButton[a].setAlpha(0.0f);
                break;
            }
        }
        cameraOpened = false;
        if (Build.VERSION.SDK_INT >= 21) {
            cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Finds all the views we need and configure them properly.
 *///  w ww. j  a v  a2 s .  c o m
private void setupViews() {
    mLauncherView = findViewById(R.id.launcher);
    mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
    mFocusHandler = mDragLayer.getFocusIndicatorHelper();
    mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
    mQsbContainer = mDragLayer.findViewById(
            mDeviceProfile.isVerticalBarLayout() ? R.id.workspace_blocked_row : R.id.qsb_container);
    mWorkspace.initParentViews(mDragLayer);

    mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);

    // Setup the drag layer
    mDragLayer.setup(this, mDragController, mAllAppsController);

    // Setup the hotseat
    mHotseat = (Hotseat) findViewById(R.id.hotseat);
    if (mHotseat != null) {
        mHotseat.setOnLongClickListener(this);
    }

    // Setup the overview panel
    setupOverviewPanel();

    setuphome();

    // Setup the workspace
    mWorkspace.setHapticFeedbackEnabled(false);
    mWorkspace.setOnLongClickListener(this);
    mWorkspace.setup(mDragController);
    // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
    // default state, otherwise we will update to the wrong offsets in RTL
    mWorkspace.lockWallpaperToDefaultPage();
    mDragController.addDragListener(mWorkspace);

    // Get the search/delete/uninstall bar
    mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar);

    // Setup Apps and Widgets
    mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view);
    mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view);
    if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) {
        mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController());
    } else {
        mAppsView.setSearchBarController(new DefaultAppSearchController());
    }

    // Setup the drag controller (drop targets have to be added in reverse order in priority)
    mDragController.setDragScoller(mWorkspace);
    mDragController.setScrollView(mDragLayer);
    mDragController.setMoveTarget(mWorkspace);
    mDragController.addDropTarget(mWorkspace);
    mDropTargetBar.setup(mDragController);

    if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) {
        mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace);
    }

    if (TestingUtils.MEMORY_DUMP_ENABLED) {
        TestingUtils.addWeightWatcher(this);
    }

    FrameLayout gBar = (FrameLayout) findViewById(R.id.g_bar);

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams();
        gBarLayout.width = Utils.getScreenXDimension(this) - Utils.getScreenXDimension(this) / 6;
        gBar.setLayoutParams(gBarLayout);
    } else {
        FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams();
        gBarLayout.width = Utils.getScreenYDimension(this) - Utils.getScreenYDimension(this) / 12;
        gBar.setLayoutParams(gBarLayout);
    }

    gBar.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            startSearch("", false, null, true);
        }
    });

    ImageView gSearch = (ImageView) findViewById(R.id.g_search);
    gSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            startSearch("", false, null, true);
        }
    });

    FrameLayout.LayoutParams gSearchLayout = (FrameLayout.LayoutParams) gSearch.getLayoutParams();
    gSearchLayout.leftMargin = 30;
    gSearch.setLayoutParams(gSearchLayout);

    ImageView gSearchMic = (ImageView) findViewById(R.id.g_search_mic);
    if (IS_ALLOW_MIC) {
        gSearchMic.setVisibility(View.VISIBLE);
        gSearchMic.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                startActivityForResult(intent, RECOGNIZER_REQ_CODE);
            }
        });
    } else {
        gSearchMic.setVisibility(View.GONE);
    }

    FrameLayout.LayoutParams gSearchMicLayout = (FrameLayout.LayoutParams) gSearchMic.getLayoutParams();
    gSearchMicLayout.rightMargin = 30;
    gSearchMic.setLayoutParams(gSearchMicLayout);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (Utilities.isAllowNightModePrefEnabled(getApplicationContext())) {
            gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape_night));
            gSearch.setImageDrawable(
                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon_night));
            gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color));
            gSearchMic
                    .setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic_night));
            gSearchMic.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color));
        } else {
            gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape));
            gSearch.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon));
            gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white));
            gSearchMic.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic));
            gSearchMic
                    .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white));
        }
    }

    if (!Utilities.isAllowPersisentSearchBarPrefEnabled(getApplicationContext())) {
        gBar.setVisibility(View.GONE);
        gSearch.setVisibility(View.GONE);
        gSearchMic.setVisibility(View.GONE);
    } else {
        gBar.setVisibility(View.VISIBLE);
        gSearch.setVisibility(View.VISIBLE);
        if (IS_ALLOW_MIC) {
            gSearchMic.setVisibility(View.VISIBLE);
        } else {
            gSearchMic.setVisibility(View.GONE);
        }
    }

}

From source file:g7.bluesky.launcher3.Launcher.java

/**
 * Finds all the views we need and configure them properly.
 *///from w w w. j ava 2s.  co  m
private void setupViews() {
    final DragController dragController = mDragController;

    mLauncherView = findViewById(R.id.launcher);
    mFocusHandler = (FocusIndicatorView) findViewById(R.id.focus_indicator);
    mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
    mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
    mWorkspace.setPageSwitchListener(this);
    mPageIndicators = mDragLayer.findViewById(R.id.page_indicator);

    mLauncherView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    mWorkspaceBackgroundDrawable = getResources().getDrawable(R.drawable.workspace_bg);

    // Setup the drag layer
    mDragLayer.setup(this, dragController);

    // Setup the hotseat
    mHotseat = (Hotseat) findViewById(R.id.hotseat);
    if (mHotseat != null) {
        mHotseat.setup(this);
        mHotseat.setOnLongClickListener(this);
    }

    mOverviewPanel = (ViewGroup) findViewById(R.id.overview_panel);
    View widgetButton = findViewById(R.id.widget_button);
    widgetButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (!mWorkspace.isSwitchingState()) {
                onClickAddWidgetButton(arg0);
            }
        }
    });
    widgetButton.setOnTouchListener(getHapticFeedbackTouchListener());

    View wallpaperButton = findViewById(R.id.wallpaper_button);
    wallpaperButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (!mWorkspace.isSwitchingState()) {
                onClickWallpaperPicker(arg0);
            }
        }
    });
    wallpaperButton.setOnTouchListener(getHapticFeedbackTouchListener());

    View settingsButton = findViewById(R.id.settings_button);
    if (hasSettings()) {
        settingsButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                if (!mWorkspace.isSwitchingState()) {
                    onClickSettingsButton(arg0);
                }
            }
        });
        settingsButton.setOnTouchListener(getHapticFeedbackTouchListener());
    } else {
        settingsButton.setVisibility(View.GONE);
    }

    mOverviewPanel.setAlpha(0f);

    // Setup the workspace
    mWorkspace.setHapticFeedbackEnabled(false);
    mWorkspace.setOnLongClickListener(this);
    mWorkspace.setup(dragController);
    dragController.addDragListener(mWorkspace);

    // Get the search/delete bar
    mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.search_drop_target_bar);

    // Setup AppsCustomize
    mAppsCustomizeTabHost = (AppsCustomizeTabHost) findViewById(R.id.apps_customize_pane);
    mAppsCustomizeContent = (AppsCustomizePagedView) mAppsCustomizeTabHost
            .findViewById(R.id.apps_customize_pane_content);
    mAppsCustomizeContent.setup(this, dragController);

    // Set up list view
    appsListViewIntent = new Intent(this, AppsListViewActivity.class);

    // Set up filter input text
    editTextFilterApps = (EditText) findViewById(R.id.editTextFilterApps);
    layoutFilterAndSortApps = (LinearLayout) findViewById(R.id.layoutFilterAndSortApps);

    // Set custom theme
    setCustomTheme();

    // Setup the drag controller (drop targets have to be added in reverse order in priority)
    dragController.setDragScoller(mWorkspace);
    dragController.setScrollView(mDragLayer);
    dragController.setMoveTarget(mWorkspace);
    dragController.addDropTarget(mWorkspace);
    if (mSearchDropTargetBar != null) {
        mSearchDropTargetBar.setup(this, dragController);
        mSearchDropTargetBar.setQsbSearchBar(getQsbBar());
    }

    if (getResources().getBoolean(R.bool.debug_memory_enabled)) {
        Log.v(TAG, "adding WeightWatcher");
        mWeightWatcher = new WeightWatcher(this);
        mWeightWatcher.setAlpha(0.5f);
        ((FrameLayout) mLauncherView).addView(mWeightWatcher, new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));

        boolean show = shouldShowWeightWatcher();
        mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
    }
}

From source file:org.telegram.ui.ArticleViewer.java

public void setParentActivity(Activity activity) {
    if (parentActivity == activity) {
        return;// w  w  w.ja va 2  s.c  o m
    }
    parentActivity = activity;

    backgroundPaint = new Paint();
    backgroundPaint.setColor(0xffffffff);

    layerShadowDrawable = activity.getResources().getDrawable(R.drawable.layer_shadow);
    slideDotDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_small);
    slideDotBigDrawable = activity.getResources().getDrawable(R.drawable.slide_dot_big);
    scrimPaint = new Paint();

    windowView = new WindowView(activity);
    windowView.setWillNotDraw(false);
    windowView.setClipChildren(true);
    windowView.setFocusable(false);

    containerView = new FrameLayout(activity);
    windowView.addView(containerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
    containerView.setFitsSystemWindows(true);
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @SuppressLint("NewApi")
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                WindowInsets oldInsets = (WindowInsets) lastInsets;
                lastInsets = insets;
                if (oldInsets == null || !oldInsets.toString().equals(insets.toString())) {
                    windowView.requestLayout();
                }
                return insets.consumeSystemWindowInsets();
            }
        });
    }
    containerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);

    photoContainerBackground = new View(activity);
    photoContainerBackground.setVisibility(View.INVISIBLE);
    photoContainerBackground.setBackgroundDrawable(photoBackgroundDrawable);
    windowView.addView(photoContainerBackground, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    animatingImageView = new ClippingImageView(activity);
    animatingImageView.setAnimationValues(animationValues);
    animatingImageView.setVisibility(View.GONE);
    windowView.addView(animatingImageView, LayoutHelper.createFrame(40, 40));

    photoContainerView = new FrameLayoutDrawer(activity) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            int y = bottom - top - captionTextView.getMeasuredHeight();
            if (bottomLayout.getVisibility() == VISIBLE) {
                y -= bottomLayout.getMeasuredHeight();
            }
            captionTextView.layout(0, y, captionTextView.getMeasuredWidth(),
                    y + captionTextView.getMeasuredHeight());
        }
    };
    photoContainerView.setVisibility(View.INVISIBLE);
    photoContainerView.setWillNotDraw(false);
    windowView.addView(photoContainerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    fullscreenVideoContainer = new FrameLayout(activity);
    fullscreenVideoContainer.setBackgroundColor(0xff000000);
    fullscreenVideoContainer.setVisibility(View.INVISIBLE);
    windowView.addView(fullscreenVideoContainer,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    fullscreenAspectRatioView = new AspectRatioFrameLayout(activity);
    fullscreenAspectRatioView.setVisibility(View.GONE);
    fullscreenVideoContainer.addView(fullscreenAspectRatioView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));

    fullscreenTextureView = new TextureView(activity);

    if (Build.VERSION.SDK_INT >= 21) {
        barBackground = new View(activity);
        barBackground.setBackgroundColor(0xff000000);
        windowView.addView(barBackground);
    }

    listView = new RecyclerListView(activity);
    listView.setLayoutManager(
            layoutManager = new LinearLayoutManager(parentActivity, LinearLayoutManager.VERTICAL, false));
    listView.setAdapter(adapter = new WebpageAdapter(parentActivity));
    listView.setClipToPadding(false);
    listView.setPadding(0, AndroidUtilities.dp(56), 0, 0);
    listView.setTopGlowOffset(AndroidUtilities.dp(56));
    listView.setGlowColor(0xfff5f6f7);
    containerView.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
        @Override
        public boolean onItemClick(View view, int position) {
            return false;
        }
    });
    listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (position == blocks.size() && currentPage != null) {
                if (previewsReqId != 0) {
                    return;
                }
                TLRPC.User user = MessagesController.getInstance().getUser("previews");
                if (user != null) {
                    openPreviewsChat(user, currentPage.id);
                } else {
                    final long pageId = currentPage.id;
                    showProgressView(true);
                    TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
                    req.username = "previews";
                    previewsReqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                        @Override
                        public void run(final TLObject response, final TLRPC.TL_error error) {
                            AndroidUtilities.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (previewsReqId == 0) {
                                        return;
                                    }
                                    previewsReqId = 0;
                                    showProgressView(false);
                                    if (response != null) {
                                        TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
                                        MessagesController.getInstance().putUsers(res.users, false);
                                        MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats,
                                                false, true);
                                        if (!res.users.isEmpty()) {
                                            openPreviewsChat(res.users.get(0), pageId);
                                        }
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
    });
    listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (listView.getChildCount() == 0) {
                return;
            }
            checkScroll(dy);
        }
    });
    headerView = new FrameLayout(activity);
    headerView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
    headerView.setBackgroundColor(0xff000000);
    containerView.addView(headerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 56));

    backButton = new ImageView(activity);
    backButton.setScaleType(ImageView.ScaleType.CENTER);
    backDrawable = new BackDrawable(false);
    backDrawable.setAnimationTime(200.0f);
    backDrawable.setColor(0xffb3b3b3);
    backDrawable.setRotated(false);
    backButton.setImageDrawable(backDrawable);
    backButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
    headerView.addView(backButton, LayoutHelper.createFrame(54, 56));
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*if (collapsed) {
            uncollapse();
            } else {
            collapse();
            }*/
            close(true, true);
        }
    });

    shareContainer = new FrameLayout(activity);
    headerView.addView(shareContainer, LayoutHelper.createFrame(48, 56, Gravity.TOP | Gravity.RIGHT));
    shareContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (currentPage == null || parentActivity == null) {
                return;
            }
            showDialog(new ShareAlert(parentActivity, null, currentPage.url, false, currentPage.url, true));
            hideActionBar();
        }
    });

    shareButton = new ImageView(activity);
    shareButton.setScaleType(ImageView.ScaleType.CENTER);
    shareButton.setImageResource(R.drawable.ic_share_article);
    shareButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR));
    shareContainer.addView(shareButton, LayoutHelper.createFrame(48, 56));

    progressView = new ContextProgressView(activity, 2);
    progressView.setVisibility(View.GONE);
    shareContainer.addView(progressView, LayoutHelper.createFrame(48, 56));

    windowLayoutParams = new WindowManager.LayoutParams();
    windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
    windowLayoutParams.format = PixelFormat.TRANSLUCENT;
    windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    windowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
    if (Build.VERSION.SDK_INT >= 21) {
        windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
    } else {
        windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
    }

    if (progressDrawables == null) {
        progressDrawables = new Drawable[4];
        progressDrawables[0] = parentActivity.getResources().getDrawable(R.drawable.circle_big);
        progressDrawables[1] = parentActivity.getResources().getDrawable(R.drawable.cancel_big);
        progressDrawables[2] = parentActivity.getResources().getDrawable(R.drawable.load_big);
        progressDrawables[3] = parentActivity.getResources().getDrawable(R.drawable.play_big);
    }

    scroller = new Scroller(activity);

    blackPaint.setColor(0xff000000);

    actionBar = new ActionBar(activity);
    actionBar.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR);
    actionBar.setOccupyStatusBar(false);
    actionBar.setTitleColor(0xffffffff);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_WHITE_SELECTOR_COLOR, false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
    photoContainerView.addView(actionBar,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                closePhoto(true);
            } else if (id == gallery_menu_save) {
                if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    parentActivity
                            .requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 4);
                    return;
                }
                File f = getMediaFile(currentIndex);
                if (f != null && f.exists()) {
                    MediaController.saveFile(f.toString(), parentActivity, isMediaVideo(currentIndex) ? 1 : 0,
                            null, null);
                } else {
                    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
                    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                    builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload));
                    showDialog(builder.create());
                }
            } else if (id == gallery_menu_share) {
                onSharePressed();
            } else if (id == gallery_menu_openin) {
                try {
                    AndroidUtilities.openForView(getMedia(currentIndex), parentActivity);
                    closePhoto(false);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        }

        @Override
        public boolean canOpenMenu() {
            File f = getMediaFile(currentIndex);
            return f != null && f.exists();
        }
    });

    ActionBarMenu menu = actionBar.createMenu();

    menu.addItem(gallery_menu_share, R.drawable.share);
    menuItem = menu.addItem(0, R.drawable.ic_ab_other);
    menuItem.setLayoutInScreen(true);
    menuItem.addSubItem(gallery_menu_openin,
            LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
    //menuItem.addSubItem(gallery_menu_share, LocaleController.getString("ShareFile", R.string.ShareFile), 0);
    menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery));

    bottomLayout = new FrameLayout(parentActivity);
    bottomLayout.setBackgroundColor(0x7f000000);
    photoContainerView.addView(bottomLayout,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT));

    captionTextViewOld = new TextView(activity);
    captionTextViewOld.setMaxLines(10);
    captionTextViewOld.setBackgroundColor(0x7f000000);
    captionTextViewOld.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(8), AndroidUtilities.dp(20),
            AndroidUtilities.dp(8));
    captionTextViewOld.setLinkTextColor(0xffffffff);
    captionTextViewOld.setTextColor(0xffffffff);
    captionTextViewOld.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    captionTextViewOld.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    captionTextViewOld.setVisibility(View.INVISIBLE);
    photoContainerView.addView(captionTextViewOld, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT));

    captionTextView = captionTextViewNew = new TextView(activity);
    captionTextViewNew.setMaxLines(10);
    captionTextViewNew.setBackgroundColor(0x7f000000);
    captionTextViewNew.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(8), AndroidUtilities.dp(20),
            AndroidUtilities.dp(8));
    captionTextViewNew.setLinkTextColor(0xffffffff);
    captionTextViewNew.setTextColor(0xffffffff);
    captionTextViewNew.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    captionTextViewNew.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    captionTextViewNew.setVisibility(View.INVISIBLE);
    photoContainerView.addView(captionTextViewNew, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT));

    radialProgressViews[0] = new RadialProgressView(activity, photoContainerView);
    radialProgressViews[0].setBackgroundState(0, false);
    radialProgressViews[1] = new RadialProgressView(activity, photoContainerView);
    radialProgressViews[1].setBackgroundState(0, false);
    radialProgressViews[2] = new RadialProgressView(activity, photoContainerView);
    radialProgressViews[2].setBackgroundState(0, false);

    videoPlayerSeekbar = new SeekBar(activity);
    videoPlayerSeekbar.setColors(0x66ffffff, 0xffffffff, 0xffffffff);
    videoPlayerSeekbar.setDelegate(new SeekBar.SeekBarDelegate() {
        @Override
        public void onSeekBarDrag(float progress) {
            if (videoPlayer != null) {
                videoPlayer.seekTo((int) (progress * videoPlayer.getDuration()));
            }
        }
    });

    videoPlayerControlFrameLayout = new FrameLayout(activity) {
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            int x = (int) event.getX();
            int y = (int) event.getY();
            if (videoPlayerSeekbar.onTouch(event.getAction(), event.getX() - AndroidUtilities.dp(48),
                    event.getY())) {
                getParent().requestDisallowInterceptTouchEvent(true);
                invalidate();
                return true;
            }
            return super.onTouchEvent(event);
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            long duration;
            if (videoPlayer != null) {
                duration = videoPlayer.getDuration();
                if (duration == C.TIME_UNSET) {
                    duration = 0;
                }
            } else {
                duration = 0;
            }
            duration /= 1000;
            int size = (int) Math
                    .ceil(videoPlayerTime.getPaint().measureText(String.format("%02d:%02d / %02d:%02d",
                            duration / 60, duration % 60, duration / 60, duration % 60)));
            videoPlayerSeekbar.setSize(getMeasuredWidth() - AndroidUtilities.dp(48 + 16) - size,
                    getMeasuredHeight());
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            float progress = 0;
            if (videoPlayer != null) {
                progress = videoPlayer.getCurrentPosition() / (float) videoPlayer.getDuration();
            }
            videoPlayerSeekbar.setProgress(progress);
        }

        @Override
        protected void onDraw(Canvas canvas) {
            canvas.save();
            canvas.translate(AndroidUtilities.dp(48), 0);
            videoPlayerSeekbar.draw(canvas);
            canvas.restore();
        }
    };
    videoPlayerControlFrameLayout.setWillNotDraw(false);
    bottomLayout.addView(videoPlayerControlFrameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    videoPlayButton = new ImageView(activity);
    videoPlayButton.setScaleType(ImageView.ScaleType.CENTER);
    videoPlayerControlFrameLayout.addView(videoPlayButton,
            LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
    videoPlayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (videoPlayer != null) {
                if (isPlaying) {
                    videoPlayer.pause();
                } else {
                    videoPlayer.play();
                }
            }
        }
    });

    videoPlayerTime = new TextView(activity);
    videoPlayerTime.setTextColor(0xffffffff);
    videoPlayerTime.setGravity(Gravity.CENTER_VERTICAL);
    videoPlayerTime.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    videoPlayerControlFrameLayout.addView(videoPlayerTime, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 8, 0));

    gestureDetector = new GestureDetector(activity, this);
    gestureDetector.setOnDoubleTapListener(this);

    ImageReceiver.ImageReceiverDelegate imageReceiverDelegate = new ImageReceiver.ImageReceiverDelegate() {
        @Override
        public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
            if (imageReceiver == centerImage && set && scaleToFill()) {
                if (!wasLayout) {
                    dontResetZoomOnFirstLayout = true;
                } else {
                    setScaleToFill();
                }
            }
        }
    };

    centerImage.setParentView(photoContainerView);
    centerImage.setCrossfadeAlpha((byte) 2);
    centerImage.setInvalidateAll(true);
    centerImage.setDelegate(imageReceiverDelegate);
    leftImage.setParentView(photoContainerView);
    leftImage.setCrossfadeAlpha((byte) 2);
    leftImage.setInvalidateAll(true);
    leftImage.setDelegate(imageReceiverDelegate);
    rightImage.setParentView(photoContainerView);
    rightImage.setCrossfadeAlpha((byte) 2);
    rightImage.setInvalidateAll(true);
    rightImage.setDelegate(imageReceiverDelegate);
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

/**
 * Sets up transparent navigation and status bars in LMP.
 * This method is a no-op for other platform versions.
 *//*from  w w w .j a v  a2s. c  om*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupTransparentSystemBarsForLmp() {
    if (Utilities.isLmpOrAbove()) {
        Window window = getWindow();
        window.getAttributes().systemUiVisibility |= (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }
}

From source file:g7.bluesky.launcher3.Launcher.java

/**
 * Sets up transparent navigation and status bars in LMP.
 * This method is a no-op for other platform versions.
 *//*from w w w . j  av a 2  s .c  om*/
@TargetApi(19)
private void setupTransparentSystemBarsForLmp() {
    // TODO(sansid): use the APIs directly when compiling against L sdk.
    // Currently we use reflection to access the flags and the API to set the transparency
    // on the System bars.
    if (Utilities.isLmpOrAbove()) {
        try {
            getWindow().getAttributes().systemUiVisibility |= (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            Field drawsSysBackgroundsField = WindowManager.LayoutParams.class
                    .getField("FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS");
            getWindow().addFlags(drawsSysBackgroundsField.getInt(null));

            Method setStatusBarColorMethod = Window.class.getDeclaredMethod("setStatusBarColor", int.class);
            Method setNavigationBarColorMethod = Window.class.getDeclaredMethod("setNavigationBarColor",
                    int.class);
            setStatusBarColorMethod.invoke(getWindow(), Color.TRANSPARENT);
            setNavigationBarColorMethod.invoke(getWindow(), Color.TRANSPARENT);
        } catch (NoSuchFieldException e) {
            Log.w(TAG, "NoSuchFieldException while setting up transparent bars");
        } catch (NoSuchMethodException ex) {
            Log.w(TAG, "NoSuchMethodException while setting up transparent bars");
        } catch (IllegalAccessException e) {
            Log.w(TAG, "IllegalAccessException while setting up transparent bars");
        } catch (IllegalArgumentException e) {
            Log.w(TAG, "IllegalArgumentException while setting up transparent bars");
        } catch (InvocationTargetException e) {
            Log.w(TAG, "InvocationTargetException while setting up transparent bars");
        } finally {
        }
    }
}

From source file:com.grass.caishi.cc.activity.main.MainActivity.java

/**
 * ???//from  www.  ja v  a2  s  .co  m
 */
public void hideNavigationBar() {
    int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN; // hide status bar

    if (android.os.Build.VERSION.SDK_INT >= 19) {
        uiFlags |= 0x00001000; // SYSTEM_UI_FLAG_IMMERSIVE_STICKY: hide navigation bars - compatibility: building API level is lower thatn 19, use magic number directly for higher API target level
    } else {
        uiFlags |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    }

    getWindow().getDecorView().setSystemUiVisibility(uiFlags);
}

From source file:android.support.design.widget.CoordinatorLayout.java

private void setupForInsets() {
    if (Build.VERSION.SDK_INT < 21) {
        return;//w ww .  j  a  v a 2s. c  om
    }

    if (ViewCompat.getFitsSystemWindows(this)) {
        if (mApplyWindowInsetsListener == null) {
            mApplyWindowInsetsListener = new android.support.v4.view.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                    return setWindowInsets(insets);
                }
            };
        }
        // First apply the insets listener
        ViewCompat.setOnApplyWindowInsetsListener(this, mApplyWindowInsetsListener);

        // Now set the sys ui flags to enable us to lay out in the window insets
        setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    } else {
        ViewCompat.setOnApplyWindowInsetsListener(this, null);
    }
}