List of usage examples for android.view Display getHeight
@Deprecated public int getHeight()
From source file:com.jp.miaulavirtual.DisplayMessageActivity.java
@SuppressWarnings("deprecation") public void setRestrictedOrientation() { /* We don't want change screen orientation */ //---get the current display info--- WindowManager wm = getWindowManager(); Display d = wm.getDefaultDisplay(); if (d.getWidth() > d.getHeight()) { //---change to landscape mode--- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else {//from www .j a va 2s.co m //---change to portrait mode--- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } }
From source file:com.google.android.apps.mytracks.TrackListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM); setContentView(R.layout.track_list); AnalyticsUtils.sendPageViews(this, this.getLocalClassName() + "/create"); ApiAdapterFactory.getApiAdapter().hideActionBar(this); Display display = getWindowManager().getDefaultDisplay(); boolean devicesZ = display.getWidth() > 720 || display.getHeight() > 720; if (devicesZ) { // Disable the Keyboard help link View v = findViewById(R.id.help_keyboard_q); if (v != null) v.setVisibility(View.GONE); v = findViewById(R.id.help_keyboard_a); if (v != null) v.setVisibility(View.GONE); }/* w w w.j a va2s.c o m*/ trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, bindChangedCallback); SharedPreferences sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); sharedPreferenceChangeListener.onSharedPreferenceChanged(sharedPreferences, null); trackController = new TrackController(this, trackRecordingServiceConnection, true, recordListener, stopListener); // START MOD ImageButton helpButton = (ImageButton) findViewById(R.id.listBtnBarHelp); if (helpButton != null) helpButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = IntentUtils.newIntent(TrackListActivity.this, HelpActivity.class); startActivity(intent); } }); /* * Record = Pause and Stop managed by track controller ImageButton * recordButton = (ImageButton) findViewById(R.id.listBtnBarRecord); * recordButton.setOnClickListener(recordListener); ImageButton stopButton = * (ImageButton) findViewById(R.id.listBtnBarStop); * stopButton.setOnClickListener(stopListener); */ ImageButton searchButton = (ImageButton) findViewById(R.id.listBtnBarSearch); if (searchButton != null) searchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onSearchRequested(); } }); ImageButton settingsButton = (ImageButton) findViewById(R.id.listBtnBarSettings); if (settingsButton != null) settingsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = IntentUtils.newIntent(TrackListActivity.this, SettingsActivity.class); startActivity(intent); } }); // END MOD listView = (ListView) findViewById(R.id.track_list); listView.setEmptyView(findViewById(R.id.track_list_empty_view)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = IntentUtils.newIntent(TrackListActivity.this, TrackDetailActivity.class) .putExtra(TrackDetailActivity.EXTRA_TRACK_ID, id); startActivity(intent); } }); resourceCursorAdapter = new ResourceCursorAdapter(this, R.layout.list_item, null, 0) { @Override public void bindView(View view, Context context, Cursor cursor) { int idIndex = cursor.getColumnIndex(TracksColumns._ID); int iconIndex = cursor.getColumnIndex(TracksColumns.ICON); int nameIndex = cursor.getColumnIndex(TracksColumns.NAME); int categoryIndex = cursor.getColumnIndex(TracksColumns.CATEGORY); int totalTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALTIME); int totalDistanceIndex = cursor.getColumnIndexOrThrow(TracksColumns.TOTALDISTANCE); int startTimeIndex = cursor.getColumnIndexOrThrow(TracksColumns.STARTTIME); int descriptionIndex = cursor.getColumnIndex(TracksColumns.DESCRIPTION); boolean isRecording = cursor.getLong(idIndex) == recordingTrackId; int iconId = TrackIconUtils.getIconDrawable(cursor.getString(iconIndex)); String name = cursor.getString(nameIndex); String totalTime = StringUtils.formatElapsedTime(cursor.getLong(totalTimeIndex)); String totalDistance = StringUtils.formatDistance(TrackListActivity.this, cursor.getDouble(totalDistanceIndex), metricUnits); long startTime = cursor.getLong(startTimeIndex); String startTimeDisplay = StringUtils.formatDateTime(context, startTime).equals(name) ? null : StringUtils.formatRelativeDateTime(context, startTime); ListItemUtils.setListItem(TrackListActivity.this, view, isRecording, recordingTrackPaused, iconId, R.string.icon_track, name, cursor.getString(categoryIndex), totalTime, totalDistance, startTimeDisplay, cursor.getString(descriptionIndex)); } }; listView.setAdapter(resourceCursorAdapter); ApiAdapterFactory.getApiAdapter().configureListViewContextualMenu(this, listView, contextualActionModeCallback); getSupportLoaderManager().initLoader(0, null, new LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { return new CursorLoader(TrackListActivity.this, TracksColumns.CONTENT_URI, PROJECTION, null, null, TracksColumns._ID + " DESC"); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { resourceCursorAdapter.swapCursor(cursor); } @Override public void onLoaderReset(Loader<Cursor> loader) { resourceCursorAdapter.swapCursor(null); } }); trackDataHub = TrackDataHub.newInstance(this); if (savedInstanceState != null) { startGps = savedInstanceState.getBoolean(START_GPS_KEY); } // Test repeated messaging if (!started) showStartupDialogs(); }
From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from www. j a v a 2s .c o m */ private void toggleZoomImage() { int animationDuration = 400; if (isInFullscreen()) { scrollView.smoothScrollTo(0, (Integer) scrollView.getTag()); photoViewAttacher.setScale(1.0f, true); } else { scrollView.setTag(scrollView.getScrollY()); scrollView.smoothScrollTo(0, 0); } if (getSupportActionBar() != null) { getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight()) .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f) .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start(); int minimumAllowedHeight = getToolbar().getMeasuredHeight() + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); if (imageSize.getHeight() < minimumAllowedHeight) { int topFrom; int topTo; if (isInFullscreen()) { topFrom = 0; topTo = getToolbar().getMeasuredHeight(); } else { topFrom = photoLayoutHolder.getPaddingTop(); topTo = 0; } ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo); topValueAnimator.setDuration(animationDuration); topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val, photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom()); } }); topValueAnimator.start(); } if (photoLayoutHolder.getTranslationY() > 0.0f) { photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator()) .setDuration(animationDuration).start(); } WindowManager win = getWindowManager(); Display d = win.getDefaultDisplay(); int from = photoView.getMeasuredHeight(); int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight(); ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to); valueAnimator.setDuration(animationDuration); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView .getLayoutParams(); toolbarParams.height = val; photoView.setLayoutParams(toolbarParams); } }); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { photoViewAttacher.setZoomable(true); photoView.setZoomable(true); photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { toggleZoomImage(); } }); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); valueAnimator.start(); int scrollTo = isInFullscreen() ? 0 : d.getHeight(); scrollView.animate().y(scrollTo).setDuration(animationDuration) .setInterpolator(new EaseInOutBezierInterpolator()).start(); isInFullscreen = !isInFullscreen; }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from w w w .j a v a 2s. co m */ private void toggleZoomImage() { int animationDuration = 400; if (isInFullscreen()) { scrollView.smoothScrollTo(0, (Integer) scrollView.getTag()); if (photoViewAttacher != null) { photoViewAttacher.cleanup(); photoViewAttacher = null; photoView.setScaleType(ImageView.ScaleType.CENTER_CROP); } } else { scrollView.setTag(scrollView.getScrollY()); scrollView.smoothScrollTo(0, 0); if (photoViewAttacher == null) { photoViewAttacher = new PhotoViewAttacher(photoView); photoViewAttacher.setZoomable(true); photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP); } } if (getSupportActionBar() != null) { getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight()) .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f) .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start(); int minimumAllowedHeight = getToolbar().getMeasuredHeight() + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); if (imageSize.getHeight() < minimumAllowedHeight) { int topFrom; int topTo; if (isInFullscreen()) { topFrom = 0; topTo = getToolbar().getMeasuredHeight(); } else { topFrom = photoLayoutHolder.getPaddingTop(); topTo = 0; } ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo); topValueAnimator.setDuration(animationDuration); topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val, photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom()); } }); topValueAnimator.start(); } if (photoLayoutHolder.getTranslationY() != 0.0f) { photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator()) .setDuration(animationDuration).start(); } WindowManager win = getWindowManager(); Display d = win.getDefaultDisplay(); int from = photoView.getMeasuredHeight(); int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight(); ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to); valueAnimator.setDuration(animationDuration); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView .getLayoutParams(); toolbarParams.height = val; photoView.setLayoutParams(toolbarParams); } }); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { if (photoViewAttacher != null) { photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { toggleZoomImage(); } }); } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); valueAnimator.start(); int scrollTo = isInFullscreen() ? 0 : d.getHeight(); scrollView.animate().y(scrollTo).setDuration(animationDuration) .setInterpolator(new EaseInOutBezierInterpolator()).start(); isInFullscreen = !isInFullscreen; }
From source file:io.selendroid.server.model.DefaultSelendroidDriver.java
@Override @SuppressWarnings("deprecation") public byte[] takeScreenshot() { ViewHierarchyAnalyzer viewAnalyzer = ViewHierarchyAnalyzer.getDefaultInstance(); // TODO ddary review later, but with getRecentDecorView() it seems to work better // long drawingTime = 0; // View container = null; // for (View view : viewAnalyzer.getTopLevelViews()) { // if (view != null && view.isShown() && view.hasWindowFocus() // && view.getDrawingTime() > drawingTime) { // container = view; // drawingTime = view.getDrawingTime(); // }/* w ww . ja v a 2 s . c o m*/ // } // final View mainView = container; final View mainView = viewAnalyzer.getRecentDecorView(); if (mainView == null) { throw new SelendroidException("No open windows."); } done = false; long end = System.currentTimeMillis() + serverInstrumentation.getAndroidWait().getTimeoutInMillis(); final byte[][] rawPng = new byte[1][1]; ServerInstrumentation.getInstance().getCurrentActivity().runOnUiThread(new Runnable() { public void run() { synchronized (syncObject) { Display display = serverInstrumentation.getCurrentActivity().getWindowManager() .getDefaultDisplay(); Point size = new Point(); try { display.getSize(size); } catch (NoSuchMethodError ignore) { // Older than api level 13 size.x = display.getWidth(); size.y = display.getHeight(); } // Get root view View view = mainView.getRootView(); // Create the bitmap to use to draw the screenshot final Bitmap bitmap = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); // Get current theme to know which background to use final Activity activity = serverInstrumentation.getCurrentActivity(); final Theme theme = activity.getTheme(); final TypedArray ta = theme .obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); final int res = ta.getResourceId(0, 0); final Drawable background = activity.getResources().getDrawable(res); // Draw background background.draw(canvas); // Draw views view.draw(canvas); ByteArrayOutputStream stream = new ByteArrayOutputStream(); if (!bitmap.compress(Bitmap.CompressFormat.PNG, 70, stream)) { throw new RuntimeException("Error while compressing screenshot image."); } try { stream.flush(); stream.close(); } catch (IOException e) { throw new RuntimeException("I/O Error while capturing screenshot: " + e.getMessage()); } finally { Closeable closeable = (Closeable) stream; try { if (closeable != null) { closeable.close(); } } catch (IOException ioe) { // ignore } } rawPng[0] = stream.toByteArray(); mainView.destroyDrawingCache(); done = true; syncObject.notify(); } } }); waitForDone(end, serverInstrumentation.getAndroidWait().getTimeoutInMillis(), "Failed to take screenshot."); return rawPng[0]; }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@SuppressWarnings("deprecation") public void displayStatus(final ParcelableStatus status) { mStatus = null;// w w w . ja v a 2s . c om mImagesPreviewFragment.clear(); if (status == null || getActivity() == null) return; mStatus = status; final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null); mMenuBar.inflate(R.menu.menu_status); final MenuItem bufferView = mMenuBar.getMenu().findItem(MENU_ADD_TO_BUFFER); if (bufferView != null) { if (buffer_authorised != null && !buffer_authorised.equals("")) { bufferView.setVisible(true); } else { bufferView.setVisible(false); } } setMenuForStatus(getActivity(), mMenuBar.getMenu(), status); mMenuBar.show(); final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1; updateUserColor(); mContentScroller .setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0); if (is_multiple_account_enabled) { final Drawable d = mContentScroller.getBackground(); if (d != null) { d.mutate().setColorFilter(getAccountColor(getActivity(), status.account_id), PorterDuff.Mode.MULTIPLY); mContentScroller.invalidate(); } } mNameView.setText(status.name); mScreenNameView.setText("@" + status.screen_name); mScreenNameView.setCompoundDrawablesWithIntrinsicBounds( getUserTypeIconRes(status.is_verified, status.is_protected), 0, 0, 0); mTextView.setText(status.text); final TwidereLinkify linkify = new TwidereLinkify(mTextView); linkify.setOnLinkClickListener(new OnLinkClickHandler(getActivity(), mAccountId)); linkify.addAllLinks(); final boolean is_reply = status.in_reply_to_status_id > 0; final String time = formatToLongTimeString(getActivity(), status.status_timestamp); final String strTime = "<a href=\"https://twitter.com/" + status.screen_name + "/status/" + String.valueOf(status.status_id) + "\">" + time + "</a>"; final String source_html = status.source; if (!isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.time_source, strTime, source_html))); } else if (isNullOrEmpty(time) && !isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.source, source_html))); } else if (!isNullOrEmpty(time) && isNullOrEmpty(source_html)) { mTimeAndSourceView.setText(time); } mTimeAndSourceView.setMovementMethod(LinkMovementMethod.getInstance()); mInReplyToView.setVisibility(is_reply ? View.VISIBLE : View.GONE); mConversationView.setVisibility(is_reply ? View.VISIBLE : View.GONE); if (is_reply) { mInReplyToView.setText(getString(R.string.in_reply_to, status.in_reply_to_screen_name)); Display display = getActivity().getWindowManager().getDefaultDisplay(); int width = display.getWidth(); // deprecated int height = display.getHeight(); // deprecated int heightOfConversation = (height / 2) - 48 - 44; ViewGroup.LayoutParams params = mConversationView.getLayoutParams(); params.height = heightOfConversation; mConversationView.setLayoutParams(params); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = null; ft = fragmentManager.beginTransaction(); final Fragment fragment = new ConversationFragment(); final Bundle args = new Bundle(); args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId); args.putLong(INTENT_KEY_STATUS_ID, status.in_reply_to_status_id); fragment.setArguments(args); ft.replace(R.id.conversation, fragment, getString(R.string.view_conversation)); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } if (status.play_package != null) { mMarketView.setVisibility(View.VISIBLE); mPlayInfoTask = new PlayStoreInfoTask(); mPlayInfoTask.execute(); } else { mMarketView.setVisibility(View.GONE); } final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image); final String preview_image = hires_profile_image ? getBiggerTwitterProfileImage(status.profile_image_url_string) : status.profile_image_url_string; mLazyImageLoader.displayProfileImage(mProfileImageView, preview_image); final List<ImageSpec> images = getImagesInStatus(status.text_html); mImagesPreviewContainer.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE); mImagesPreviewFragment.addAll(images); mImagesPreviewFragment.update(); if (mLoadMoreAutomatically == true) { mImagesPreviewFragment.show(); } mRetweetedStatusView.setVisibility(status.is_protected ? View.GONE : View.VISIBLE); if (status.retweet_id > 0) { final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String retweeted_by = display_name ? status.retweeted_by_name : status.retweeted_by_screen_name; mRetweetedStatusView.setText(status.retweet_count > 1 ? getString(R.string.retweeted_by_with_count, retweeted_by, status.retweet_count - 1) : getString(R.string.retweeted_by, retweeted_by)); mRetweetedStatusView.setVisibility(View.VISIBLE); } else { mRetweetedStatusView.setVisibility(View.GONE); mRetweetedStatusView.setText(R.string.users_retweeted_this); } mLocationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE); if (mLoadMoreAutomatically) { showFollowInfo(true); showLocationInfo(true); } else { mFollowIndicator.setVisibility(View.GONE); } }
From source file:com.tealeaf.TeaLeaf.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PluginManager.init(this); instance = this; setFullscreenFlag();// w w w . ja v a 2s. com configureActivity(); String appID = findAppID(); options = new TeaLeafOptions(this); PluginManager.callAll("onCreate", this, savedInstanceState); //check intent for test app info Bundle bundle = getIntent().getExtras(); boolean isTestApp = false; if (bundle != null) { isTestApp = bundle.getBoolean("isTestApp", false); if (isTestApp) { options.setAppID(appID); boolean isPortrait = bundle.getBoolean("isPortrait", false); if (isPortrait) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } options.setCodeHost(bundle.getString("hostValue")); options.setCodePort(bundle.getInt("portValue")); String simulateID = bundle.getString("simulateID"); options.setSimulateID(simulateID); } } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); group = new FrameLayout(this); setContentView(group); // TextEditViewHandler setup textEditView = new TextEditViewHandler(this); settings = new Settings(this); remoteLogger = (ILogger) getLoggerInstance(this); checkUpdate(); compareVersions(); setLaunchUri(); // defer building all of these things until we have the absolutely correct options logger.buildLogger(this, remoteLogger); resourceManager = new ResourceManager(this, options); contactList = new ContactList(this, resourceManager); soundQueue = new SoundQueue(this, resourceManager); localStorage = new LocalStorage(this, options); // start push notifications, but defer for 10 seconds to give us time to start up PushBroadcastReceiver.scheduleNext(this, 10); glView = new TeaLeafGLSurfaceView(this); glViewPaused = false; // default screen dimensions Display display = getWindow().getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); int orientation = getRequestedOrientation(); // gets real screen dimensions without nav bars on recent API versions if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { Point screenSize = new Point(); try { display.getRealSize(screenSize); width = screenSize.x; height = screenSize.y; } catch (NoSuchMethodError e) { } } // flip width and height based on orientation if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && height > width) || (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && width > height)) { int tempWidth = width; width = height; height = tempWidth; } final AbsoluteLayout absLayout = new AbsoluteLayout(this); absLayout.setLayoutParams(new android.view.ViewGroup.LayoutParams(width, height)); absLayout.addView(glView, new android.view.ViewGroup.LayoutParams(width, height)); group.addView(absLayout); editText = EditTextView.Init(this); if (isTestApp) { startGame(); } soundQueue.playSound(SoundQueue.LOADING_SOUND); doFirstRun(); remoteLogger.sendLaunchEvent(this); paused = false; menuButtonHandler = MenuButtonHandlerFactory.getButtonHandler(this); group.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { // get visible area of the view Rect r = new Rect(); group.getWindowVisibleDisplayFrame(r); int visibleHeight = r.bottom; // TODO // maybe this should be renamed if (visibleHeight != lastVisibleHeight) { lastVisibleHeight = visibleHeight; EventQueue.pushEvent(new KeyboardScreenResizeEvent(visibleHeight)); } } }); }
From source file:edu.pitt.gis.uniapp.UniApp.java
/** * Shows the splash screen over the full Activity *//*from w w w.j av a 2s.com*/ @SuppressWarnings("deprecation") protected void showSplashScreen(final int time) { final UniApp that = this; Runnable runnable = new Runnable() { public void run() { // Get reference to display Display display = getWindowManager().getDefaultDisplay(); // Create the layout for the dialog LinearLayout root = new LinearLayout(that.getActivity()); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F)); root.setBackgroundResource(that.splashscreen); // Create and show the dialog splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, time); } }; this.runOnUiThread(runnable); }
From source file:tw.com.sti.store.api.android.AndroidApiService.java
private AndroidApiService(Context context, Configuration config) { this.config = config; this.apiUrl = new ApiUrl(config); if (Logger.DEBUG) L.d("new ApiService()"); sdkVer = Build.VERSION.SDK;/*from w w w. java2 s. c o m*/ sdkRel = Build.VERSION.RELEASE; try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); storeId = pi.packageName; clientVer = "" + pi.versionCode; } catch (NameNotFoundException e) { } TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); deviceId = tm.getDeviceId() == null ? "0" : tm.getDeviceId(); macAddress = NetworkUtils.getDeviceMacAddress(context); subscriberId = tm.getSubscriberId() == null ? "0" : tm.getSubscriberId(); simSerialNumber = tm.getSimSerialNumber() == null ? "0" : tm.getSimSerialNumber(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); try { Class<Display> cls = Display.class; Method method = cls.getMethod("getRotation"); Object retobj = method.invoke(display); int rotation = Integer.parseInt(retobj.toString()); if (Surface.ROTATION_0 == rotation || Surface.ROTATION_180 == rotation) { wpx = "" + display.getWidth(); hpx = "" + display.getHeight(); } else { wpx = "" + display.getHeight(); hpx = "" + display.getWidth(); } } catch (Exception e) { if (display.getOrientation() == 1) { wpx = "" + display.getHeight(); hpx = "" + display.getWidth(); } else { wpx = "" + display.getWidth(); hpx = "" + display.getHeight(); } } SharedPreferences pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); // token = pref.getString(PREF_KEY_TOKEN, ""); // uid = pref.getString(PREF_KEY_UID, ""); // userId = pref.getString(PREF_KEY_USER_ID, ""); appFilter = pref.getInt(PREF_KEY_APP_FILTER, 0); // ipLoginEnable = pref.getBoolean(PREF_KEY_IP_LOGIN_ENABLE, true); // ??SIM? String pref_subscriberId = pref.getString(PREF_KEY_SUBSCRIBER_ID, "0"); String pref_simSerialNumber = pref.getString(PREF_KEY_SIM_SERIAL_NUMBER, "0"); if (!subscriberId.equals(pref_subscriberId) || !simSerialNumber.equals(pref_simSerialNumber)) { if (Logger.DEBUG) L.d("Change SIM card."); cleanCredential(context); } this.getCredential(context); }
From source file:paulscode.android.mupen64plusae.persistent.UserPrefs.java
/** * Instantiates a new user preferences wrapper. * /* www . j a v a2 s .c o m*/ * @param context The application context. */ @SuppressWarnings("deprecation") @SuppressLint("InlinedApi") @TargetApi(17) public UserPrefs(Context context) { AppData appData = new AppData(context); mPreferences = PreferenceManager.getDefaultSharedPreferences(context); // Locale mLocaleCode = mPreferences.getString(KEY_LOCALE_OVERRIDE, DEFAULT_LOCALE_OVERRIDE); mLocale = TextUtils.isEmpty(mLocaleCode) ? Locale.getDefault() : createLocale(mLocaleCode); Locale[] availableLocales = Locale.getAvailableLocales(); String[] values = context.getResources().getStringArray(R.array.localeOverride_values); String[] entries = new String[values.length]; for (int i = values.length - 1; i > 0; i--) { Locale locale = createLocale(values[i]); // Get intersection of languages (available on device) and (translated for Mupen) if (ArrayUtils.contains(availableLocales, locale)) { // Get the name of the language, as written natively entries[i] = WordUtils.capitalize(locale.getDisplayName(locale)); } else { // Remove the item from the list entries = (String[]) ArrayUtils.remove(entries, i); values = (String[]) ArrayUtils.remove(values, i); } } entries[0] = context.getString(R.string.localeOverride_entrySystemDefault); mLocaleNames = entries; mLocaleCodes = values; // Files userDataDir = mPreferences.getString("pathGameSaves", ""); galleryDataDir = userDataDir + "/GalleryData"; profilesDir = userDataDir + "/Profiles"; crashLogDir = userDataDir + "/CrashLogs"; coreUserDataDir = userDataDir + "/CoreConfig/UserData"; coreUserCacheDir = userDataDir + "/CoreConfig/UserCache"; hiResTextureDir = coreUserDataDir + "/mupen64plus/hires_texture/"; // MUST match what rice assumes natively romInfoCache_cfg = galleryDataDir + "/romInfoCache.cfg"; controllerProfiles_cfg = profilesDir + "/controller.cfg"; touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; emulationProfiles_cfg = profilesDir + "/emulation.cfg"; customCheats_txt = profilesDir + "/customCheats.txt"; // Plug-ins audioPlugin = new Plugin(mPreferences, appData.libsDir, "audioPlugin"); // Touchscreen prefs isTouchscreenFeedbackEnabled = mPreferences.getBoolean("touchscreenFeedback", false); touchscreenRefresh = getSafeInt(mPreferences, "touchscreenRefresh", 0); touchscreenScale = ((float) mPreferences.getInt("touchscreenScale", 100)) / 100.0f; touchscreenTransparency = (255 * mPreferences.getInt("touchscreenTransparency", 100)) / 100; touchscreenSkin = appData.touchscreenSkinsDir + "/" + mPreferences.getString("touchscreenStyle", "Outline"); touchscreenAutoHold = getSafeInt(mPreferences, "touchscreenAutoHold", 0); // Xperia PLAY touchpad prefs isTouchpadEnabled = appData.hardwareInfo.isXperiaPlay && mPreferences.getBoolean("touchpadEnabled", true); isTouchpadFeedbackEnabled = mPreferences.getBoolean("touchpadFeedback", false); touchpadSkin = appData.touchpadSkinsDir + "/Xperia-Play"; ConfigFile touchpad_cfg = new ConfigFile(appData.touchpadProfiles_cfg); ConfigSection section = touchpad_cfg.get(mPreferences.getString("touchpadLayout", "")); if (section != null) touchpadProfile = new Profile(true, section); else touchpadProfile = null; // Video prefs displayOrientation = getSafeInt(mPreferences, "displayOrientation", 0); displayPosition = getSafeInt(mPreferences, "displayPosition", Gravity.CENTER_VERTICAL); int transparencyPercent = mPreferences.getInt("displayActionBarTransparency", 50); displayActionBarTransparency = (255 * transparencyPercent) / 100; displayFpsRefresh = getSafeInt(mPreferences, "displayFpsRefresh", 0); isFpsEnabled = displayFpsRefresh > 0; videoHardwareType = getSafeInt(mPreferences, "videoHardwareType", -1); videoPolygonOffset = SafeMethods.toFloat(mPreferences.getString("videoPolygonOffset", "-0.2"), -0.2f); isImmersiveModeEnabled = mPreferences.getBoolean("displayImmersiveMode", false); // Audio prefs audioSwapChannels = mPreferences.getBoolean("audioSwapChannels", false); audioSecondaryBufferSize = getSafeInt(mPreferences, "audioBufferSize", 2048); if (audioPlugin.enabled) isFramelimiterEnabled = mPreferences.getBoolean("audioSynchronize", true); else isFramelimiterEnabled = !mPreferences.getString("audioPlugin", "").equals("nospeedlimit"); // User interface modes String navMode = mPreferences.getString("navigationMode", "auto"); if (navMode.equals("bigscreen")) isBigScreenMode = true; else if (navMode.equals("standard")) isBigScreenMode = false; else isBigScreenMode = AppData.IS_OUYA_HARDWARE; // TODO: Add other systems as they enter market isActionBarAvailable = AppData.IS_HONEYCOMB && !isBigScreenMode; // Peripheral share mode isControllerShared = mPreferences.getBoolean("inputShareController", false); // Determine the key codes that should not be mapped to controls boolean volKeysMappable = mPreferences.getBoolean("inputVolumeMappable", false); List<Integer> unmappables = new ArrayList<Integer>(); unmappables.add(KeyEvent.KEYCODE_MENU); if (AppData.IS_HONEYCOMB) { // Back key is needed to show/hide the action bar in HC+ unmappables.add(KeyEvent.KEYCODE_BACK); } if (!volKeysMappable) { unmappables.add(KeyEvent.KEYCODE_VOLUME_UP); unmappables.add(KeyEvent.KEYCODE_VOLUME_DOWN); unmappables.add(KeyEvent.KEYCODE_VOLUME_MUTE); } unmappableKeyCodes = Collections.unmodifiableList(unmappables); // Determine the pixel dimensions of the rendering context and view surface { // Screen size final WindowManager windowManager = (WindowManager) context .getSystemService(android.content.Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); int stretchWidth; int stretchHeight; if (display == null) { stretchWidth = stretchHeight = 0; } else if (AppData.IS_KITKAT && isImmersiveModeEnabled) { DisplayMetrics metrics = new DisplayMetrics(); display.getRealMetrics(metrics); stretchWidth = metrics.widthPixels; stretchHeight = metrics.heightPixels; } else { stretchWidth = display.getWidth(); stretchHeight = display.getHeight(); } float aspect = 0.75f; // TODO: Handle PAL boolean isLetterboxed = ((float) stretchHeight / (float) stretchWidth) > aspect; int zoomWidth = isLetterboxed ? stretchWidth : Math.round((float) stretchHeight / aspect); int zoomHeight = isLetterboxed ? Math.round((float) stretchWidth * aspect) : stretchHeight; int cropWidth = isLetterboxed ? Math.round((float) stretchHeight / aspect) : stretchWidth; int cropHeight = isLetterboxed ? stretchHeight : Math.round((float) stretchWidth * aspect); int hResolution = getSafeInt(mPreferences, "displayResolution", 0); String scaling = mPreferences.getString("displayScaling", "zoom"); if (hResolution == 0) { // Native resolution if (scaling.equals("stretch")) { videoRenderWidth = videoSurfaceWidth = stretchWidth; videoRenderHeight = videoSurfaceHeight = stretchHeight; } else if (scaling.equals("crop")) { videoRenderWidth = videoSurfaceWidth = cropWidth; videoRenderHeight = videoSurfaceHeight = cropHeight; } else // scaling.equals( "zoom") || scaling.equals( "none" ) { videoRenderWidth = videoSurfaceWidth = zoomWidth; videoRenderHeight = videoSurfaceHeight = zoomHeight; } } else { // Non-native resolution switch (hResolution) { case 720: videoRenderWidth = 960; videoRenderHeight = 720; break; case 600: videoRenderWidth = 800; videoRenderHeight = 600; break; case 480: videoRenderWidth = 640; videoRenderHeight = 480; break; case 360: videoRenderWidth = 480; videoRenderHeight = 360; break; case 240: videoRenderWidth = 320; videoRenderHeight = 240; break; case 120: videoRenderWidth = 160; videoRenderHeight = 120; break; default: videoRenderWidth = Math.round((float) hResolution / aspect); videoRenderHeight = hResolution; break; } if (scaling.equals("zoom")) { videoSurfaceWidth = zoomWidth; videoSurfaceHeight = zoomHeight; } else if (scaling.equals("crop")) { videoSurfaceWidth = cropWidth; videoSurfaceHeight = cropHeight; } else if (scaling.equals("stretch")) { videoSurfaceWidth = stretchWidth; videoSurfaceHeight = stretchHeight; } else // scaling.equals( "none" ) { videoSurfaceWidth = videoRenderWidth; videoSurfaceHeight = videoRenderHeight; } } } }