List of usage examples for android.view Display getSize
public void getSize(Point outSize)
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
private void guideQuickSearch() { Activity activity = getActivity2();/*w ww . j av a2 s . co m*/ if (null == activity || !Settings.getGuideQuickSearch()) { return; } Display display = activity.getWindowManager().getDefaultDisplay(); Point point = new Point(); display.getSize(point); mShowcaseView = new ShowcaseView.Builder(activity).withMaterialShowcase().setStyle(R.style.Guide) .setTarget(new PointTarget(point.x, point.y / 3)).blockAllTouches() .setContentTitle(R.string.guide_quick_search_title).setContentText(R.string.guide_quick_search_text) .replaceEndButton(R.layout.button_guide) .setShowcaseEventListener(new SimpleShowcaseEventListener() { @Override public void onShowcaseViewDidHide(ShowcaseView showcaseView) { mShowcaseView = null; ViewUtils.removeFromParent(showcaseView); Settings.putGuideQuickSearch(false); openDrawer(Gravity.RIGHT); } }).build(); }
From source file:com.playhaven.android.req.PlayHavenRequest.java
@SuppressWarnings("deprecation") protected UriComponentsBuilder createUrl(Context context) throws PlayHavenException { try {//from w w w. jav a 2s . c o m SharedPreferences pref = PlayHaven.getPreferences(context); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getString(pref, APIServer)); builder.path(context.getResources().getString(getApiPath(context))); builder.queryParam("app", getString(pref, AppPkg)); builder.queryParam("opt_out", getString(pref, OptOut, "0")); builder.queryParam("app_version", getString(pref, AppVersion)); builder.queryParam("os", getInt(pref, OSVersion, 0)); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); builder.queryParam("orientation", display.getRotation()); builder.queryParam("hardware", getString(pref, DeviceModel)); PlayHaven.ConnectionType connectionType = getConnectionType(context); builder.queryParam("connection", connectionType.ordinal()); builder.queryParam("idiom", context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK); /** * For height/width we will use getSize(Point) not getRealSize(Point) as this will allow us to automatically * account for rotation and screen decorations like the status bar. We only want to know available space. * * @playhaven.apihack for SDK_INT < 13, have to use getHeight and getWidth! */ Point size = new Point(); if (Build.VERSION.SDK_INT >= 13) { display.getSize(size); } else { size.x = display.getWidth(); size.y = display.getHeight(); } builder.queryParam("width", size.x); builder.queryParam("height", size.y); /** * SDK Version needs to be reported as a dotted numeric value * So, if it is a -SNAPSHOT build, we will replace -SNAPSHOT with the date of the build * IE: 2.0.0.20130201 * as opposed to an actual released build, which would be like 2.0.0 */ String sdkVersion = getString(pref, SDKVersion); String[] date = Version.PLUGIN_BUILD_TIME.split("[\\s]"); sdkVersion = sdkVersion.replace("-SNAPSHOT", "." + date[0].replaceAll("-", "")); builder.queryParam("sdk_version", sdkVersion); builder.queryParam("plugin", getString(pref, PluginIdentifer)); Locale locale = context.getResources().getConfiguration().locale; builder.queryParam("languages", String.format("%s,%s", locale.toString(), locale.getLanguage())); builder.queryParam("token", getString(pref, Token)); builder.queryParam("device", getString(pref, DeviceId)); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); builder.queryParam("dpi", metrics.densityDpi); String uuid = UUID.randomUUID().toString(); String nonce = base64Digest(uuid); builder.queryParam("nonce", nonce); ktsid = KontagentUtil.getSenderId(context); if (ktsid != null) builder.queryParam("sid", ktsid); addSignature(builder, pref, nonce); // Setup for signature verification String secret = getString(pref, Secret); SecretKeySpec key = new SecretKeySpec(secret.getBytes(UTF8), HMAC); sigMac = Mac.getInstance(HMAC); sigMac.init(key); sigMac.update(nonce.getBytes(UTF8)); return builder; } catch (Exception e) { throw new PlayHavenException(e); } }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
public void runExpansionAnimation() { final Interpolator interpolator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in); } else {// ww w .ja v a2 s .c o m interpolator = new DecelerateInterpolator(); } WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int screenHeight = size.y; int screenWidth = size.x; final ValueAnimator heightExpansion = ValueAnimator.ofInt(expansionViewHeight, getHeight()); heightExpansion.setInterpolator(interpolator); heightExpansion.setDuration(ANIMATION_DURATION); heightExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.height = val; setLayoutParams(params); } }); heightExpansion.start(); final ValueAnimator widthExpansion = ValueAnimator.ofInt(expansionViewWidth, getWidth()); widthExpansion.setInterpolator(interpolator); widthExpansion.setDuration(ANIMATION_DURATION); widthExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.width = val; setLayoutParams(params); } }); widthExpansion.start(); ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, expansionLeftOffset, 0f); translationX.setInterpolator(interpolator); translationX.setDuration(ANIMATION_DURATION); translationX.start(); ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, expansionTopOffset, 0f); translationY.setInterpolator(interpolator); translationY.setDuration(ANIMATION_DURATION); translationY.start(); }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
public void reverseExpansionAnimation() { final Interpolator interpolator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in); } else {/*w w w.j av a 2 s . c om*/ interpolator = new DecelerateInterpolator(); } WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int screenHeight = size.y; int screenWidth = size.x; final ValueAnimator heightExpansion = ValueAnimator.ofInt(screenHeight, expansionViewHeight); heightExpansion.setInterpolator(interpolator); heightExpansion.setDuration(ANIMATION_DURATION); heightExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.height = val; setLayoutParams(params); } }); heightExpansion.start(); final ValueAnimator widthExpansion = ValueAnimator.ofInt(getWidth(), expansionViewWidth); widthExpansion.setInterpolator(interpolator); widthExpansion.setDuration(ANIMATION_DURATION); widthExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.width = val; setLayoutParams(params); } }); widthExpansion.start(); ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, 0f, expansionLeftOffset); translationX.setInterpolator(interpolator); translationX.setDuration(ANIMATION_DURATION); translationX.start(); ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0f, expansionTopOffset); translationY.setInterpolator(interpolator); translationY.setDuration(ANIMATION_DURATION); translationY.addListener(exitAnimationListner); translationY.start(); }
From source file:net.toload.main.hd.candidate.CandidateView.java
public CandidateView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context;//w w w . j av a2 s . com mCandidateView = this; embeddedComposing = null; // Jeremy '15,6,4 for embedded composing view in candidateView when floating candidateView (not fixed) mLIMEPref = new LIMEPreferenceManager(context); //Jeremy '16,7,24 get themed objects TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.LIMECandidateView, defStyle, R.style.LIMECandidateView); int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); switch (attr) { case R.styleable.LIMECandidateView_suggestHighlight: mDrawableSuggestHighlight = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_voiceInputIcon: mDrawableVoiceInput = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_ExpandButtonIcon: mDrawableExpandButton = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_closeButtonIcon: mDrawableCloseButton = a.getDrawable(attr); break; case R.styleable.LIMECandidateView_candidateBackground: mColorBackground = a.getColor(attr, ContextCompat.getColor(context, R.color.third_background_light)); break; case R.styleable.LIMECandidateView_composingTextColor: mColorComposingText = a.getColor(attr, ContextCompat.getColor(context, R.color.second_foreground_light)); break; case R.styleable.LIMECandidateView_composingBackgroundColor: mColorComposingBackground = a.getColor(attr, ContextCompat.getColor(context, R.color.composing_background_light)); break; case R.styleable.LIMECandidateView_candidateNormalTextColor: mColorNormalText = a.getColor(attr, ContextCompat.getColor(context, R.color.foreground_light)); break; case R.styleable.LIMECandidateView_candidateNormalTextHighlightColor: mColorNormalTextHighlight = a.getColor(attr, ContextCompat.getColor(context, R.color.foreground_light)); break; case R.styleable.LIMECandidateView_composingCodeColor: mColorComposingCode = a.getColor(attr, ContextCompat.getColor(context, R.color.color_common_green_hl)); break; case R.styleable.LIMECandidateView_composingCodeHighlightColor: mColorComposingCodeHighlight = a.getColor(attr, ContextCompat.getColor(context, R.color.third_background_light)); break; case R.styleable.LIMECandidateView_spacerColor: mColorSpacer = a.getColor(attr, ContextCompat.getColor(context, R.color.candidate_spacer)); break; case R.styleable.LIMECandidateView_selKeyColor: mColorSelKey = a.getColor(attr, ContextCompat.getColor(context, R.color.candidate_selection_keys)); break; case R.styleable.LIMECandidateView_selKeyShiftedColor: mColorSelKeyShifted = a.getColor(attr, ContextCompat.getColor(context, R.color.color_common_green_hl)); break; } } a.recycle(); final Resources r = context.getResources(); Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point screenSize = new Point(); display.getSize(screenSize); mScreenWidth = screenSize.x; mScreenHeight = screenSize.y; mVerticalPadding = (int) (r.getDimensionPixelSize(R.dimen.candidate_vertical_padding) * mLIMEPref.getFontSize()); configHeight = (int) (r.getDimensionPixelSize(R.dimen.candidate_stripe_height) * mLIMEPref.getFontSize()); mHeight = configHeight + mVerticalPadding; mExpandButtonWidth = r.getDimensionPixelSize(R.dimen.candidate_expand_button_width);// *mLIMEPref.getFontSize()); mCandidatePaint = new Paint(); mCandidatePaint.setColor(mColorNormalText); mCandidatePaint.setAntiAlias(true); mCandidatePaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_size) * mLIMEPref.getFontSize()); mCandidatePaint.setStrokeWidth(0); mSelKeyPaint = new Paint(); mSelKeyPaint.setColor(mColorSelKey); mSelKeyPaint.setAntiAlias(true); mSelKeyPaint .setTextSize(r.getDimensionPixelSize(R.dimen.candidate_number_font_size) * mLIMEPref.getFontSize()); mSelKeyPaint.setStyle(Paint.Style.FILL_AND_STROKE); //final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); //Jeremy '12,4,23 add mContext parameter. The constructor without context is deprecated mGestureDetector = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (DEBUG) Log.i(TAG, "onScroll(): distanceX = " + distanceX + "; distanceY = " + distanceY); //Jeremy '12,4,8 filter out small scroll which is actually candidate selection. if (Math.abs(distanceX) < mHeight / 5 && Math.abs(distanceY) < mHeight / 5) return true; mScrolled = true; // Update full candidate list before scroll checkHasMoreRecords(); int sx = getScrollX(); sx += distanceX; if (sx < 0) { sx = 0; } if (sx + getWidth() > mTotalWidth) { sx -= distanceX; } if (mLIMEPref.getParameterBoolean("candidate_switch", false)) { hasSlide = true; mTargetScrollX = sx; scrollTo(sx, getScrollY()); currentX = getScrollX(); //Jeremy '12,7,6 set currentX to the left edge of current scrollview after scrolled } else { hasSlide = false; if (distanceX < 0) { goLeft = true; goRight = false; } else if (distanceX > 0) { goLeft = false; goRight = true; } else { mTargetScrollX = sx; } } return true; } }); }
From source file:com.segma.trim.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MobileAds.initialize(getApplicationContext(), ADMOB_KEY); setContentView(R.layout.activity_main); loadAds();//from www .ja v a2s.c o m MEMORY_SIZE = ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).getMemoryClass(); MAX_BITMAP_PIXELS = calculateMaxBitmapPixels(); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); ipv = (ImageProcessingView) findViewById(R.id.ipv); loadLicense(); loadUserSetting(); final Runnable runnableOnTextView = new Runnable() { @Override public void run() { ipv.setVisibility(View.VISIBLE); // TODO: update pending: the image enlarges due to larger space rawBitmap = getSampleImage(); rawBitmapWidth = rawBitmap.getWidth(); rawBitmapHeight = rawBitmap.getHeight(); STATE = STATE_PROCESSING_IMAGE; textView.setVisibility(View.GONE); ipv.process(rawBitmap); } }; Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); screenWidth = size.x; screenHeight = size.y; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); screenWidth = display.getWidth(); screenHeight = display.getHeight(); } initControls(); textView = (TextView) findViewById(R.id.tv_message); textView.setEnabled(false); ViewTreeObserver viewTreeObserver = ipv.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ImageProcessingViewWidth = ipv.getWidth(); ImageProcessingViewHeight = ipv.getHeight(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ipv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { ipv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } if (ImageProcessingViewHeight != 0) textView.setEnabled(true); } }); } textView.setText(MESSAGE_STARTUP); textView.setOnTouchListener(new View.OnTouchListener() { float original_text_size; @Override public boolean onTouch(View v, final MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: original_text_size = textView.getTextSize(); //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Math.round(original_text_size * 1.15)); handlerOnTextView.postDelayed(runnableOnTextView, LONG_PRESS_TIME_ON_TEXTVIEW); textView.setEnabled(false); break; case MotionEvent.ACTION_MOVE: handlerOnTextView.removeCallbacks(runnableOnTextView); break; case MotionEvent.ACTION_UP: //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, original_text_size); handlerOnTextView.removeCallbacks(runnableOnTextView); v.setEnabled(true); break; } return false; } }); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); actionBar = getSupportActionBar(); //actionBar.setDisplayHomeAsUpEnabled(true); ipv.setVisibility(View.INVISIBLE); if (MODE_DEBUG) { LICENSE = LICENSE_PREMIUM; getPackageManager().clearPackagePreferredActivities(getApplicationContext().getPackageName()); } }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragDown(int start) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int height = size.y; if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sliderStartDrag = height - start - params.height; sliderHeightStart = params.height; }/*from ww w . j a v a 2s .c om*/ }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragDragging(int whereY) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int height = size.y; if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if ((height - whereY - sliderStartDrag) > 0) { params.height = height - whereY - sliderStartDrag; } else {/*from ww w .j a v a2 s. com*/ params.height = 0; } sv.setLayoutParams(params); } }
From source file:com.openatk.planting.MainActivity.java
private void SliderShrink() { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int oneThirdHeight = (size.y / 3); if (fragmentEditField != null) { ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if (sliderPosition == 1) { //Middle -> Small DropDownAnim an = new DropDownAnim(sv, params.height, 0); an.setDuration(300);/* ww w . j av a2s . c o m*/ sv.startAnimation(an); sliderPosition = 0; } else if (sliderPosition == 2) { //Fullscreen -> Middle if has notes //Fullscreen -> Small if no notes if (false) { DropDownAnim an = new DropDownAnim(sv, params.height, oneThirdHeight); an.setDuration(300); sv.startAnimation(an); sliderPosition = 1; } else { DropDownAnim an = new DropDownAnim(sv, params.height, 0); an.setDuration(300); sv.startAnimation(an); sliderPosition = 0; } } sv.setLayoutParams(params); } }
From source file:com.openatk.planting.MainActivity.java
@Override public void SliderDragUp(int whereY) { //Slider done dragging snap to 1 of 3 positions Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int oneThirdHeight = size.y / 3; if (whereY < oneThirdHeight) { //Fullscreen Log.d("SliderDragUp", "fullscreen"); } else if (whereY < oneThirdHeight * 2) { //Middle//w w w. j av a2 s .co m Log.d("SliderDragUp", "middle"); } else { //Closed Log.d("SliderDragUp", "closed"); } //Find end height if (fragmentEditField != null) { Log.d("slider", "not null"); ScrollView sv = (ScrollView) fragmentEditField.getView().findViewById(R.id.slider_scrollView); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv.getLayoutParams(); if (params.height > sliderHeightStart) { //Make bigger SliderGrow(); } else { //Make smaller SliderShrink(); } } else { Log.d("slider", "null"); } }