Example usage for android.view Display getSize

List of usage examples for android.view Display getSize

Introduction

In this page you can find the example usage for android.view Display getSize.

Prototype

public void getSize(Point outSize) 

Source Link

Document

Gets the size of the display, in pixels.

Usage

From source file:com.auratech.launcher.Workspace.java

/**
 * Initializes various states for this workspace.
 *//*from w ww .j  a v  a 2s . c  om*/
protected void initWorkspace() {
    Context context = getContext();
    mCurrentPage = mDefaultPage;
    Launcher.setScreen(mCurrentPage);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mIconCache = app.getIconCache();
    mPageViewAnimation = app.getPageAnimation();
    setWillNotDraw(false);
    setClipChildren(false);
    setClipToPadding(false);
    setChildrenDrawnWithCacheEnabled(true);

    setMinScale(mOverviewModeShrinkFactor);
    setupLayoutTransition();

    final Resources res = getResources();
    try {
        mBackground = res.getDrawable(R.drawable.apps_customize_bg);
    } catch (Resources.NotFoundException e) {
        // In this case, we will skip drawing background protection
    }

    mWallpaperOffset = new WallpaperOffsetInterpolator();
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);

    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);

    // Set the wallpaper dimensions when Launcher starts up
    setWallpaperDimension();
}

From source file:com.phonemetra.turbo.launcher.Workspace.java

/**
 * Initializes various states for this workspace.
 *//*w  w w . j  a v  a  2 s . c om*/
protected void initWorkspace() {
    Context context = getContext();
    mCurrentPage = mDefaultPage;
    Launcher.setScreen(mCurrentPage);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mIconCache = app.getIconCache();
    setWillNotDraw(false);
    setClipChildren(false);
    setClipToPadding(false);
    setChildrenDrawnWithCacheEnabled(true);

    setMinScale(mOverviewModeShrinkFactor);
    setupLayoutTransition();

    final Resources res = getResources();
    try {
        mBackground = res.getDrawable(R.drawable.apps_customize_bg);
    } catch (Resources.NotFoundException e) {

    }

    mWallpaperOffset = new WallpaperOffsetInterpolator();
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);

    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);

    // Set the wallpaper dimensions when Launcher starts up
    setWallpaperDimension();
}

From source file:com.wb.launcher3.Workspace.java

/**
 * Initializes various states for this workspace.
 *//*  w w w .  jav a2 s . co  m*/
protected void initWorkspace() {
    Context context = getContext();
    //*/Modified by tyd Greg 2014-04-03,for set default page
    mOriginalDefaultPage = mDefaultPage = readDefaultPage();
    //*/
    mCurrentPage = mDefaultPage;
    Launcher.setScreen(mCurrentPage);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mIconCache = app.getIconCache();
    setWillNotDraw(false);
    setClipChildren(false);
    setClipToPadding(false);
    setChildrenDrawnWithCacheEnabled(true);

    // This is a bit of a hack to account for the fact that we translate the workspace
    // up a bit, and still need to draw the background covering the whole screen.
    setMinScale(mOverviewModeShrinkFactor - 0.2f);
    setupLayoutTransition();

    final Resources res = getResources();
    try {
        mBackground = res.getDrawable(R.drawable.apps_customize_bg);
    } catch (Resources.NotFoundException e) {
        // In this case, we will skip drawing background protection
    }

    mWallpaperOffset = new WallpaperOffsetInterpolator();
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);

    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
}

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

private void setupDrawer() {
    mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() {
        @Override/*w  w  w.  j a va 2 s .  co  m*/
        public void onPageChanged(int page) {
            if (mLauncherDrawer == null) {
                return;
            }

            if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED
                    && !mWorkspace.isSmall()) {
                lockLauncherDrawer(false);
            }

            if (page == 0) {
                // on the first page
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f);
            } else {
                // somewhere in the middle
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f);
            }
        }

        @Override
        public void onScrollStart() {
            lockLauncherDrawer(true);
        }

        @Override
        public void onScrollEnd() {

        }
    });

    mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mLauncherDrawer.setCurrentDrawerPage(position);
        }
    });

    mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            if (drawerView == mDrawerPager) {
                mDragLayer.setTranslationX(getScreenWidth() * slideOffset);
                ((PagesFragmentAdapter) mDrawerPager.getAdapter())
                        .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset);
            } else {
                mDragLayer.setTranslationX(getScreenWidth() * slideOffset * -1);
                for (View v : ((BaseLauncherPage) extraFragment).getBackground()) {
                    v.setAlpha(slideOffset);
                }
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (drawerView == mDrawerPager) {
                mDragLayer.setTranslationX(getScreenWidth());
            } else {
                mDragLayer.setTranslationX(getScreenWidth() * -1);
            }

            sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_OPENED"));
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            mDragLayer.setTranslationX(0);
            sendBroadcast(new Intent("com.klinker.android.launcher.FRAGMENTS_CLOSED"));

            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
        }

        private int screenWidth = -1;

        private int getScreenWidth() {
            if (screenWidth == -1) {
                Display display = getWindowManager().getDefaultDisplay();
                Point size = new Point();
                display.getSize(size);
                screenWidth = size.x;
            }

            return screenWidth;
        }
    });

}

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

/**
 * Initializes various states for this workspace.
 *//*from w  ww. ja  va 2 s.  co m*/
protected void initWorkspace() {
    mCurrentPage = mDefaultPage;
    Launcher.setScreen(mCurrentPage);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mIconCache = app.getIconCache();
    setWillNotDraw(false);
    setClipChildren(false);
    setClipToPadding(false);
    setChildrenDrawnWithCacheEnabled(true);

    setMinScale(mOverviewModeShrinkFactor);
    setupLayoutTransition();

    mWallpaperOffset = new WallpaperOffsetInterpolator();
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);

    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);

    // Set the wallpaper dimensions when Launcher starts up
    setWallpaperDimension();
}

From source file:xyz.klinker.blur.launcher3.Launcher.java

public View getOrCreateQsbBar() {
    if (launcherCallbacksProvidesSearch()) {
        return mLauncherCallbacks.getQsbBar();
    }/*  w  w w  .  j a v  a  2  s.  com*/

    if (mQsb == null) {
        AppWidgetProviderInfo searchProvider = Utilities.getSearchWidgetProvider(this);
        if (searchProvider == null) {
            return null;
        }

        Bundle opts = new Bundle();
        opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
                AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);

        // Determine the min and max dimensions of the widget.
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile portraitProfile = app.getInvariantDeviceProfile().portraitProfile;
        DeviceProfile landscapeProfile = app.getInvariantDeviceProfile().landscapeProfile;
        float density = getResources().getDisplayMetrics().density;
        Point searchDimens = portraitProfile.getSearchBarDimensForWidgetOpts(getResources());
        int maxHeight = (int) (searchDimens.y / density);
        int minHeight = maxHeight;
        int maxWidth = (int) ((searchDimens.x / density) / 5) * 3;
        int minWidth = maxWidth;
        if (!landscapeProfile.isVerticalBarLayout()) {
            searchDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(getResources());
            maxHeight = (int) Math.max(maxHeight, searchDimens.y / density);
            minHeight = (int) Math.min(minHeight, searchDimens.y / density);
            maxWidth = (int) Math.max(maxWidth, searchDimens.x / density);
            minWidth = (int) Math.min(minWidth, searchDimens.x / density);
        }
        opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight);
        opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight);
        opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth);
        opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth);
        if (LOGD) {
            Log.d(TAG, "QSB widget options: maxHeight=" + maxHeight + " minHeight=" + minHeight + " maxWidth="
                    + maxWidth + " minWidth=" + minWidth);
        }

        if (mLauncherCallbacks != null) {
            opts.putAll(mLauncherCallbacks.getAdditionalSearchWidgetOptions());
        }

        int widgetId = mSharedPrefs.getInt(QSB_WIDGET_ID, -1);
        AppWidgetProviderInfo widgetInfo = mAppWidgetManager.getAppWidgetInfo(widgetId);
        if (!searchProvider.provider.flattenToString().equals(mSharedPrefs.getString(QSB_WIDGET_PROVIDER, null))
                || (widgetInfo == null) || !widgetInfo.provider.equals(searchProvider.provider)) {
            // A valid widget is not already bound.
            if (widgetId > -1) {
                mAppWidgetHost.deleteAppWidgetId(widgetId);
                widgetId = -1;
            }

            // Try to bind a new widget
            widgetId = View.generateViewId();

            mSharedPrefs.edit().putInt(QSB_WIDGET_ID, widgetId)
                    .putString(QSB_WIDGET_PROVIDER, searchProvider.provider.flattenToString()).apply();
        }

        mAppWidgetHost.setQsbWidgetId(widgetId);

        if (widgetId != -1) {
            mQsb = mAppWidgetHost.createView(this, widgetId, searchProvider);
            mQsb.setId(R.id.qsb_widget);
            mQsb.updateAppWidgetOptions(opts);

            // on tablets, we don't need this widget taking up the whole screen. It looks better
            // with some padding on the sides
            if (getResources().getBoolean(R.bool.reduce_search_width)) {
                Display display = getWindowManager().getDefaultDisplay();
                Point size = new Point();
                display.getSize(size);
                mQsb.setPadding(size.x / 8, 0, size.x / 8, 0);
            } else {
                mQsb.setPadding(0, 0, 0, 0);
            }

            mSearchDropTargetBar.addView(mQsb);
            mSearchDropTargetBar.setQsbSearchBar(mQsb);

            if (AppSettings.getInstance(this).showSearchBar) {
                createClickableSearch(1);
            } else {
                mQsb.getLayoutParams().width = 0;
            }
        }
    }
    return mQsb;
}

From source file:xyz.klinker.blur.launcher3.Launcher.java

private void setupDrawer() {
    mWorkspace.setOnPageChangedListener(new Workspace.OnPageChangeListener() {
        @Override//  ww  w  .ja v a2 s  .  co  m
        public void onPageChanged(int page) {
            if (mLauncherDrawer == null) {
                return;
            }

            if (mLauncherDrawer.getDrawerLockMode(Gravity.LEFT) == LauncherDrawerLayout.LOCK_MODE_LOCKED_CLOSED
                    && !mWorkspace.isSmall()) {
                lockLauncherDrawer(false);
            }

            if (page == 0) {
                // on the first page
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, 1.0f);
            } else {
                // somewhere in the middle
                mLauncherDrawer.setDrawerLeftEdgeSize(Launcher.this, .07f);
            }
        }

        @Override
        public void onScrollStart() {
            lockLauncherDrawer(true);
        }

        @Override
        public void onScrollEnd() {

        }
    });

    mDrawerPager.setPageMargin(Utils.toDP(this, 15));
    mDrawerPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mLauncherDrawer.setCurrentDrawerPage(position);
        }
    });

    mLauncherDrawer.setDrawerListener(new LauncherDrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            mDragLayer.setTranslationX(getScreenWidth() * slideOffset);
            ((PagesFragmentAdapter) mDrawerPager.getAdapter())
                    .adjustFragmentBackgroundAlpha(mDrawerPager.getCurrentItem(), slideOffset);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (drawerView == mDrawerPager) {
                mDragLayer.setTranslationX(getScreenWidth());
            } else {
                mDragLayer.setTranslationX(getScreenWidth() * -1);
            }

            adapter.pagesOpened();

            if (Utilities.ATLEAST_MARSHMALLOW) {
                mLauncherDrawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            }

            if (Utilities.ATLEAST_LOLLIPOP) {
                ValueAnimator animator = ValueAnimator.ofArgb(Color.TRANSPARENT, Color.parseColor("#22000000"));
                animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        int color = (Integer) valueAnimator.getAnimatedValue();
                        getWindow().setNavigationBarColor(color);
                        getWindow().setStatusBarColor(color);
                    }
                });
                animator.setDuration(300);
                animator.start();
            }
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            mDragLayer.setTranslationX(0);

            adapter.pagesClosed();

            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mLauncherDrawer.getWindowToken(), 0);

            if (Utilities.ATLEAST_MARSHMALLOW) {
                mLauncherDrawer.setSystemUiVisibility(
                        mLauncherDrawer.getSystemUiVisibility() & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            }

            if (Utilities.ATLEAST_LOLLIPOP) {
                ValueAnimator animator = ValueAnimator.ofArgb(Color.parseColor("#22000000"), Color.TRANSPARENT);
                animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        int color = (Integer) valueAnimator.getAnimatedValue();
                        getWindow().setNavigationBarColor(color);
                        getWindow().setStatusBarColor(color);
                    }
                });
                animator.setDuration(300);
                animator.start();
            }
        }

        @Override
        public void onDrawerStateChanged(int newState) {
        }

        private int screenWidth = -1;

        private int getScreenWidth() {
            if (screenWidth == -1) {
                Display display = getWindowManager().getDefaultDisplay();
                Point size = new Point();
                display.getSize(size);
                screenWidth = size.x;
            }

            return screenWidth;
        }
    });

}