Java Code Examples for android.view.Display

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android-gltron, under directory /GlTron/src/com/glTron/.

Source file: glTron.java

  22 
vote

@Override public void onCreate(Bundle savedInstanceState){
  WindowManager w=getWindowManager();
  Display d=w.getDefaultDisplay();
  int width=d.getWidth();
  int height=d.getHeight();
  super.onCreate(savedInstanceState);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  _View=new OpenGLView(this,width,height);
  setContentView(_View);
}
 

Example 2

From project android-joedayz, under directory /Proyectos/AndroidTwitter/src/com/mycompany/android/.

Source file: TwitterDialog.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mSpinner=new ProgressDialog(getContext());
  mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
  mSpinner.setMessage("Loading...");
  mContent=new LinearLayout(getContext());
  mContent.setOrientation(LinearLayout.VERTICAL);
  setUpTitle();
  setUpWebView();
  Display display=getWindow().getWindowManager().getDefaultDisplay();
  final float scale=getContext().getResources().getDisplayMetrics().density;
  float[] dimensions=(display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
  addContentView(mContent,new FrameLayout.LayoutParams((int)(dimensions[0] * scale + 0.5f),(int)(dimensions[1] * scale + 0.5f)));
}
 

Example 3

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/presentation/activity/.

Source file: HostSettingsActivity.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  final Display display=getWindowManager().getDefaultDisplay();
  ThumbSize.setScreenSize(display.getWidth(),display.getHeight());
  setTitle("XBMC Hosts");
  mSettingsController=new SettingsController(this,new Handler());
  mConfigurationManager=ConfigurationManager.getInstance(this);
  setPreferenceScreen(mSettingsController.createHostsPreferences(getPreferenceManager().createPreferenceScreen(this),this));
}
 

Example 4

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: OnScreenSettings.java

  22 
vote

public void updateLayout(){
  if (mOwnerView.getWindowToken() == null)   return;
  Display display=mWindowManager.getDefaultDisplay();
  mContainerLayoutParams.x=0;
  mContainerLayoutParams.y=0;
  mContainerLayoutParams.width=display.getWidth() / 2;
  mContainerLayoutParams.height=display.getHeight();
  if (mIsVisible) {
    mWindowManager.updateViewLayout(mContainer,mContainerLayoutParams);
  }
}
 

Example 5

From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.

Source file: AndroidNativeDriver.java

  22 
vote

/** 
 * Creates a  {@code Function} to get screen rotation information. This{@code Function} should always be run on the main application thread.
 */
private Function<Void,Integer> doGetOrientation(){
  return new Function<Void,Integer>(){
    @Override public Integer apply(    Void ignoredArgument){
      Display display=checkHasCurrentActivity().getWindowManager().getDefaultDisplay();
      return display.getOrientation();
    }
  }
;
}
 

Example 6

From project apps-for-android, under directory /BTClickLinkCompete/src/net/clc/bt/.

Source file: AirHockey.java

  22 
vote

public void OnIncomingConnection(String device){
  rivalDevice=device;
  WindowManager w=getWindowManager();
  Display d=w.getDefaultDisplay();
  int width=d.getWidth();
  int height=d.getHeight();
  mBall=new Demo_Ball(true,width,height - 60);
  mBall.putOnScreen(width / 2,(height / 2 + (int)(height * .05)),0,0,0,0,0);
}
 

Example 7

From project blokish, under directory /src/org/scoutant/blokish/.

Source file: ButtonsView.java

  22 
vote

public ButtonsView(Context context){
  super(context);
  this.context=context;
  setVisibility(INVISIBLE);
  Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int h=display.getHeight() - display.getWidth();
  setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,h,Gravity.BOTTOM));
  cancel=button(R.drawable.cancel,doCancel,0);
  addView(cancel);
  ok=button(R.drawable.checkmark,doOk,1);
  addView(ok);
  setOkState(false);
}
 

Example 8

From project Cafe, under directory /testrunner/src/com/baidu/cafe/remote/.

Source file: Armser.java

  22 
vote

public Armser(Context context){
  mContext=context;
  db=new Database(mContext.getContentResolver());
  Display display=((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  mScreenHeight=display.getHeight();
  mScreenWidth=display.getWidth();
  serviceConnection=new MyServiceConnection();
}
 

Example 9

From project daily-money, under directory /dailymoney/src/com/bottleworks/dailymoney/calculator2/.

Source file: Calculator.java

  22 
vote

/** 
 * The font sizes in the layout files are specified for a HVGA display. Adjust the font sizes accordingly if we are running on a different display.
 */
public void adjustFontSize(TextView view){
  float fontPixelSize=view.getTextSize();
  Display display=getWindowManager().getDefaultDisplay();
  int h=Math.min(display.getWidth(),display.getHeight());
  float ratio=0;
  if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
    ratio=(float)h / HVGA_WIDTH_PIXELS;
  }
 else {
    ratio=(float)h / HVGA_HEIGHT_PIXELS;
  }
  view.setTextSize(TypedValue.COMPLEX_UNIT_PX,fontPixelSize * ratio);
}
 

Example 10

From project droidgiro-android, under directory /src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
public void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 11

From project evodroid, under directory /src/com/sonorth/evodroid/.

Source file: ViewPosts.java

  22 
vote

@Override public void onActivityCreated(Bundle bundle){
  super.onActivityCreated(bundle);
  createSwitcher();
  Display display=((WindowManager)getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width > 480 || height > 480) {
    largeScreen=true;
  }
}
 

Example 12

From project God-Save-The-Bag, under directory /src/com/estudio/cheke/game/gstb/.

Source file: GstbActivity.java

  22 
vote

@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  pause=true;
  SoundManager.initSounds(this);
  SoundManager.playSound(0,true);
  Display display=((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
  Cache.setDimensions(display.getWidth(),display.getHeight());
}
 

Example 13

From project Hawksword, under directory /src/com/bw/hawksword/ocr/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution,true);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 14

From project HeLauncher, under directory /src/com/handlerexploit/launcher_reloaded/.

Source file: Launcher.java

  22 
vote

private void setWallpaperDimension(){
  WallpaperManager wpm=(WallpaperManager)getSystemService(WALLPAPER_SERVICE);
  Display display=getWindowManager().getDefaultDisplay();
  boolean isPortrait=display.getWidth() < display.getHeight();
  final int width=isPortrait ? display.getWidth() : display.getHeight();
  final int height=isPortrait ? display.getHeight() : display.getWidth();
  wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN,height);
}
 

Example 15

From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 16

From project ImageLoader, under directory /core/src/main/java/com/novoda/imageloader/core/model/.

Source file: ImageTagFactory.java

  22 
vote

public static ImageTagFactory getInstance(Context context,int defaultImageResId){
  ImageTagFactory imageTagFactory=getInstance();
  Display display=imageTagFactory.prepareDisplay(context);
  imageTagFactory.setInitialSizeParams(imageTagFactory,display.getWidth(),display.getHeight());
  imageTagFactory.setInitialImageId(imageTagFactory,defaultImageResId);
  return imageTagFactory;
}
 

Example 17

From project Krypsis, under directory /Android/src/org/krypsis/android/command/screen/.

Source file: GetScreenInfoCommand.java

  22 
vote

public void execute(Module module,Requestable request,ResponseDispatchable dispatchable){
  final Response response=new SuccessResponse(request);
  final Application application=(Application)module.getRootApplication();
  final Display display=application.getWindowManager().getDefaultDisplay();
  final DisplayMetrics metrics=new DisplayMetrics();
  display.getMetrics(metrics);
  final int orientation=display.getOrientation();
  response.setParameter(Screens.WIDTH,metrics.widthPixels);
  response.setParameter(Screens.HEIGHT,metrics.heightPixels);
  response.setParameter(Screens.ORIENTATION,orientation);
  dispatchable.dispatch(response);
}
 

Example 18

From project MIT-Mobile-for-Android, under directory /src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 19

From project mixare, under directory /src/org/mixare/.

Source file: Compatibility.java

  22 
vote

static public int getRotation(final Activity activity){
  int result=1;
  try {
    Display display=((WindowManager)activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    Object retObj=mDefaultDisplay_getRotation.invoke(display);
    if (retObj != null) {
      result=(Integer)retObj;
    }
  }
 catch (  Exception ex) {
  }
  return result;
}
 

Example 20

From project NFCShopping, under directory /nfc updater client/NFCUpdater/src/scut/bgooo/updater/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 21

From project PartyWare, under directory /android/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 22

From project Pixelesque, under directory /src/com/rj/pixelesque/.

Source file: PixelArtEditor.java

  22 
vote

public static void setIsHorizontal(Context context){
  DisplayMetrics metrics=new DisplayMetrics();
  Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  display.getMetrics(metrics);
  int size=(context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
  if (size == Configuration.SCREENLAYOUT_SIZE_LARGE || size == 4) {
    horizontal=true;
  }
}
 

Example 23

From project platform_packages_apps_launcher, under directory /src/com/android/launcher/.

Source file: Launcher.java

  22 
vote

private void setWallpaperDimension(){
  IBinder binder=ServiceManager.getService(WALLPAPER_SERVICE);
  IWallpaperService wallpaperService=IWallpaperService.Stub.asInterface(binder);
  Display display=getWindowManager().getDefaultDisplay();
  boolean isPortrait=display.getWidth() < display.getHeight();
  final int width=isPortrait ? display.getWidth() : display.getHeight();
  final int height=isPortrait ? display.getHeight() : display.getWidth();
  try {
    wallpaperService.setDimensionHints(width * WALLPAPER_SCREENS_SPAN,height);
  }
 catch (  RemoteException e) {
  }
}
 

Example 24

From project Playlist, under directory /src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 25

From project QuotaForAndroid, under directory /Quota/src/com/southfreo/quota/utils/.

Source file: Utils.java

  22 
vote

public static String DeviceInfo(Context c){
  Display display=((WindowManager)c.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  DisplayMetrics met=new DisplayMetrics();
  display.getMetrics(met);
  String di="Device   : " + Build.DEVICE + "\n"+ "Model    : "+ Build.MODEL+ "\n"+ "Firmware : "+ Build.VERSION.RELEASE+ "\n"+ "Display  : "+ met.toString();
  return di;
}
 

Example 26

From project rapidandroid, under directory /rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/.

Source file: ChartBroker.java

  22 
vote

protected void loadGraphFinish(){
  Display display=this.mParentActivity.getWindowManager().getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  Log.d("ChartBroker","getWidth: " + width);
  Log.d("ChartBroker","getHeight: " + height);
  height=height - 50;
  mAppView.loadUrl("javascript:SetGraph(\"" + width + "px\", \""+ height+ "px\")");
  Log.d("ChartBroker","javascript:SetGraph(\"" + width + "px\", \""+ height+ "px\")");
  mAppView.loadUrl("javascript:GotGraph(" + mGraphData.toString() + ","+ mGraphOptions.toString()+ ")");
  Log.d("ChartBroker","javascript:GotGraph(" + mGraphData.toString() + ","+ mGraphOptions.toString()+ ")");
}
 

Example 27

From project RC4A, under directory /src/org/rubychina/android/activity/.

Source file: RCActivity.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  DebugUtil.setupErrorHandler(this);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.rc_layout);
  WindowManager windowManager=getWindowManager();
  Display display=windowManager.getDefaultDisplay();
  ((RCApplication)getApplication()).setScreenWidth(display.getWidth());
  ((RCApplication)getApplication()).setScreenHeight(display.getHeight());
}
 

Example 28

From project RebeLauncher, under directory /src/com/dirtypepper/rebelauncher/.

Source file: Launcher.java

  22 
vote

private void setWallpaperDimension(){
  WallpaperManager wpm=(WallpaperManager)getSystemService(WALLPAPER_SERVICE);
  Display display=getWindowManager().getDefaultDisplay();
  boolean isPortrait=display.getWidth() < display.getHeight();
  final int width=isPortrait ? display.getWidth() : display.getHeight();
  final int height=isPortrait ? display.getHeight() : display.getWidth();
  wpm.suggestDesiredDimensions(width * WALLPAPER_SCREENS_SPAN,height);
}
 

Example 29

From project reddit-is-fun, under directory /src/com/andrewshu/android/reddit/comments/.

Source file: CommentClickDialog.java

  22 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.comment_click_dialog);
  Display display=((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  LayoutParams params=getWindow().getAttributes();
  params.width=LayoutParams.FILL_PARENT;
  if (display.getOrientation() == Configuration.ORIENTATION_LANDSCAPE)   params.height=LayoutParams.FILL_PARENT;
  getWindow().setAttributes((android.view.WindowManager.LayoutParams)params);
  setCanceledOnTouchOutside(true);
}
 

Example 30

From project Sketchy-Truck, under directory /src/se/treplex/sketchytruck/.

Source file: GameActivity.java

  22 
vote

public Engine onLoadEngine(){
  final Display display=getWindowManager().getDefaultDisplay();
  int CAMERA_WIDTH=display.getWidth();
  int CAMERA_HEIGHT=display.getHeight();
  cameraBound=new BoundCamera(0,0,CAMERA_WIDTH,CAMERA_HEIGHT,0,CAMERA_WIDTH,0,CAMERA_HEIGHT);
  cameraBound.setBoundsEnabled(true);
  final EngineOptions engineOptions=new EngineOptions(true,ScreenOrientation.LANDSCAPE,new RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT),cameraBound).setWakeLockOptions(WakeLockOptions.SCREEN_ON);
  engineOptions.getTouchOptions().setRunOnUpdateThread(true);
  engineOptions.setNeedsMusic(true);
  engineOptions.setNeedsSound(true);
  return new Engine(engineOptions);
}
 

Example 31

From project SMSSync, under directory /smssync/src/org/addhen/smssync/widget/.

Source file: SmsSyncAppWidgetProvider.java

  22 
vote

@Override public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds){
  for (int i=0; i < appWidgetIds.length; ++i) {
    final int id=appWidgetIds[i];
    Intent intent=new Intent(context,SmsSyncAppWidgetService.class);
    intent.putExtra("id",id);
    context.startService(intent);
  }
  mContext=context;
  CACHE_DIR=context.getCacheDir();
  Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  WIDTH=display.getWidth();
  WIDTH=WIDTH - (WIDTH / 16);
  HEIGHT=display.getHeight();
}
 

Example 32

From project SocialLib, under directory /src/com/facebook/android/.

Source file: FbDialog.java

  22 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mSpinner=new ProgressDialog(getContext());
  mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
  mSpinner.setMessage("Loading...");
  mContent=new LinearLayout(getContext());
  mContent.setOrientation(LinearLayout.VERTICAL);
  setUpTitle();
  setUpWebView();
  Display display=getWindow().getWindowManager().getDefaultDisplay();
  final float scale=getContext().getResources().getDisplayMetrics().density;
  float[] dimensions=display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
  addContentView(mContent,new FrameLayout.LayoutParams((int)(dimensions[0] * scale + 0.5f),(int)(dimensions[1] * scale + 0.5f)));
}
 

Example 33

From project SVQCOM, under directory /Core/src/com/ushahidi/android/app/util/.

Source file: PhotoUtils.java

  22 
vote

public static int getScreenOrientation(Activity context){
  Display display=context.getWindowManager().getDefaultDisplay();
  if (display.getWidth() == display.getHeight()) {
    return Configuration.ORIENTATION_SQUARE;
  }
 else {
    if (display.getWidth() < display.getHeight()) {
      return Configuration.ORIENTATION_PORTRAIT;
    }
 else {
      return Configuration.ORIENTATION_LANDSCAPE;
    }
  }
}
 

Example 34

From project tagin, under directory /experimental/apps/android-demo/src/com/komodo/tagin/.

Source file: Main.java

  22 
vote

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  tDb=new TagsDatabase(this);
  tDb.open();
  registerReceiver(mReceiver,new IntentFilter(TaginURN.ACTION_URN_READY));
  startURNFetchService();
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  Display display=getWindowManager().getDefaultDisplay();
  width=display.getWidth();
  height=display.getHeight();
  tagCloudCreated=false;
  startSplashScreen();
}
 

Example 35

From project titanium-barcode, under directory /src/com/mwaysolutions/barcode/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 36

From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/util/.

Source file: PhotoUtils.java

  22 
vote

public static int getScreenOrientation(Activity context){
  Display display=context.getWindowManager().getDefaultDisplay();
  if (display.getWidth() == display.getHeight()) {
    return Configuration.ORIENTATION_SQUARE;
  }
 else {
    if (display.getWidth() < display.getHeight()) {
      return Configuration.ORIENTATION_PORTRAIT;
    }
 else {
      return Configuration.ORIENTATION_LANDSCAPE;
    }
  }
}
 

Example 37

From project Wordpress-Android-App, under directory /src/org/wordpress/android/.

Source file: ViewPosts.java

  22 
vote

@Override public void onActivityCreated(Bundle bundle){
  super.onActivityCreated(bundle);
  createSwitcher();
  Display display=((WindowManager)getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width > 480 || height > 480) {
    largeScreen=true;
  }
}
 

Example 38

From project zxing-android, under directory /src/com/laundrylocker/barcodescanner/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 39

From project zxing-iphone, under directory /android/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  22 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  previewFormat=parameters.getPreviewFormat();
  previewFormatString=parameters.get("preview-format");
  Log.d(TAG,"Default preview format: " + previewFormat + '/'+ previewFormatString);
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  screenResolution=new Point(display.getWidth(),display.getHeight());
  Log.d(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=getCameraResolution(parameters,screenResolution);
  Log.d(TAG,"Camera resolution: " + screenResolution);
}
 

Example 40

From project Absolute-Android-RSS, under directory /src/com/AA/Activities/.

Source file: AAWidget.java

  21 
vote

/** 
 * Creates the activity; This themes up our activity to look like a dialog Also registers some UI action listeners to the UI elements
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.widget_settings);
  this.setTitle("Widget Settings");
  getWindow().setBackgroundDrawableResource(R.drawable.widget_dialog2);
  Display d=getWindow().getWindowManager().getDefaultDisplay();
  getWindow().setLayout(d.getWidth() * 15 / 16,LayoutParams.WRAP_CONTENT);
  this.setResult(RESULT_CANCELED);
  settings=this.getSharedPreferences("settings",0);
  btn_ok=(Button)this.findViewById(R.id.btn_ok);
  sb_freq=(SeekBar)this.findViewById(R.id.sb_freq);
  tv_freq=(TextView)this.findViewById(R.id.tv_freq);
  rg_layoutPicker=(RadioGroup)this.findViewById(R.id.rg_layoutPicker);
  rb_left=(RadioButton)this.findViewById(R.id.rb_left);
  rb_center=(RadioButton)this.findViewById(R.id.rb_center);
  btn_ok.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      acceptChanges();
    }
  }
);
  sb_freq.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
    @Override public void onStopTrackingTouch(    SeekBar seekBar){
    }
    @Override public void onStartTrackingTouch(    SeekBar seekBar){
    }
    /** 
 * When the user changes the position of the slider bar; display  the current progress in the textview below
 */
    @Override public void onProgressChanged(    SeekBar seekBar,    int progress,    boolean fromUser){
      tv_freq.setText((progress + 1) + " hour/s");
    }
  }
);
  sb_freq.setProgress((int)settings.getLong("freq",2) - 1);
}
 

Example 41

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/page/.

Source file: BibleGestureListener.java

  21 
vote

@Override public boolean onSingleTapConfirmed(MotionEvent e){
  boolean handled=false;
  if (sensePageDownTap) {
    Log.d(TAG,"onSingleTapConfirmed ");
    WindowManager window=(WindowManager)BibleApplication.getApplication().getSystemService(Context.WINDOW_SERVICE);
    Display display=window.getDefaultDisplay();
    int height=display.getHeight();
    if (e.getY() > height * 0.93) {
      Log.d(TAG,"scrolling down");
      mainBibleActivity.scrollScreenDown();
      handled=true;
    }
    Log.d(TAG,"finished onSingleTapConfirmed ");
  }
  if (!handled) {
    handled=super.onSingleTapConfirmed(e);
  }
  return handled;
}
 

Example 42

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/views/.

Source file: CameraSurface.java

  21 
vote

private void setCameraParameters(){
  this.mParameters=this.mCameraDevice.getParameters();
  List<Integer> frameRates=this.mParameters.getSupportedPreviewFrameRates();
  if (frameRates != null) {
    Integer max=Collections.max(frameRates);
    this.mParameters.setPreviewFrameRate(max);
  }
  double ratio=(double)8 / 3;
  Display display=this.mActivity.getWindowManager().getDefaultDisplay();
  if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)   ratio=(double)display.getWidth() / display.getHeight();
 else   ratio=(double)display.getHeight() / display.getWidth();
  int optPicWidth=(int)this.getResources().getDimension(R.dimen.camera_pic_size);
  int optPicHeight=(int)(optPicWidth / ratio);
  Size optPicSize=this.getOptimalSize(this.mParameters.getSupportedPictureSizes(),optPicWidth,optPicHeight);
  Size optPreviewSize=this.getOptimalSize(this.mParameters.getSupportedPreviewSizes(),optPicSize.width,optPicSize.height);
  this.mParameters.setPictureSize(optPicSize.width,optPicSize.height);
  this.mParameters.setPreviewSize(optPreviewSize.width,optPreviewSize.height);
  this.mParameters.setPictureFormat(ImageFormat.JPEG);
  this.mParameters.setJpegQuality(JPEGQUALITY);
  if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    this.mParameters.setRotation(0);
  }
 else {
    this.mParameters.setRotation(90);
  }
  String focusmode=GSSettings.getShouldAutoFocus() ? ENABLEDAUTOFOCUSSETTING : DISABLEDAUTOFOCUSSETTING;
  if (this.isSupported(focusmode,this.mParameters.getSupportedFocusModes()))   this.mParameters.setFocusMode(focusmode);
  this.mCameraDevice.setParameters(this.mParameters);
}
 

Example 43

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/camera/.

Source file: CameraConfigurationManager.java

  21 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width < height) {
    Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
    int temp=width;
    width=height;
    height=temp;
  }
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 44

From project androlog, under directory /androlog/src/main/java/de/akquinet/android/androlog/reporter/.

Source file: Report.java

  21 
vote

/** 
 * Adds the device data to the report.
 * @param report the report
 * @throws JSONException if the device data cannot be added
 */
private void addDeviceData(JSONObject report) throws JSONException {
  JSONObject device=new JSONObject();
  device.put("device",Build.DEVICE);
  device.put("brand",Build.BRAND);
  Object windowService=context.getSystemService(Context.WINDOW_SERVICE);
  if (windowService instanceof WindowManager) {
    Display display=((WindowManager)windowService).getDefaultDisplay();
    device.put("resolution",display.getWidth() + "x" + display.getHeight());
    device.put("orientation",display.getOrientation());
  }
  device.put("display",Build.DISPLAY);
  device.put("manufacturer",Build.MANUFACTURER);
  device.put("model",Build.MODEL);
  device.put("product",Build.PRODUCT);
  device.put("build.type",Build.TYPE);
  device.put("android.version",Build.VERSION.SDK_INT);
  report.put("device",device);
}
 

Example 45

From project DateSlider, under directory /src/com/googlecode/android/widgets/DateSlider/.

Source file: ScrollLayout.java

  21 
vote

@Override protected void onFinishInflate(){
  super.onFinishInflate();
  final Display display=((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  final int displayWidth=display.getWidth();
  int childCount=displayWidth / objWidth;
  if (displayWidth % objWidth != 0) {
    childCount++;
  }
  if (childCount % 2 == 0) {
    childCount++;
  }
  final int centerIndex=(childCount / 2);
  removeAllViews();
  for (int i=0; i < childCount; i++) {
    LayoutParams lp=new LayoutParams(objWidth,objHeight);
    TimeView ttv=mLabeler.createView(getContext(),i == centerIndex);
    addView((View)ttv,lp);
  }
  mCenterView=(TimeView)getChildAt(centerIndex);
  mCenterView.setVals(mLabeler.getElem(currentTime));
  Log.v(TAG,"mCenter: " + mCenterView.getTimeText() + " minInterval "+ minuteInterval);
  for (int i=centerIndex + 1; i < childCount; i++) {
    TimeView lastView=(TimeView)getChildAt(i - 1);
    TimeView thisView=(TimeView)getChildAt(i);
    thisView.setVals(mLabeler.add(lastView.getEndTime(),1));
  }
  for (int i=centerIndex - 1; i >= 0; i--) {
    TimeView lastView=(TimeView)getChildAt(i + 1);
    TimeView thisView=(TimeView)getChildAt(i);
    thisView.setVals(mLabeler.add(lastView.getEndTime(),-1));
  }
  childrenWidth=childCount * objWidth;
}
 

Example 46

From project dungbeetle, under directory /src/com/facebook/android/.

Source file: FbDialog.java

  21 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mSpinner=new ProgressDialog(getContext());
  mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
  mSpinner.setMessage("Loading...");
  mContent=new LinearLayout(getContext());
  mContent.setOrientation(LinearLayout.VERTICAL);
  setUpTitle();
  setUpWebView();
  Display display=getWindow().getWindowManager().getDefaultDisplay();
  final float scale=getContext().getResources().getDisplayMetrics().density;
  int orientation=getContext().getResources().getConfiguration().orientation;
  float[] dimensions=(orientation == Configuration.ORIENTATION_LANDSCAPE) ? DIMENSIONS_DIFF_LANDSCAPE : DIMENSIONS_DIFF_PORTRAIT;
  addContentView(mContent,new LinearLayout.LayoutParams(display.getWidth() - ((int)(dimensions[0] * scale + 0.5f)),display.getHeight() - ((int)(dimensions[1] * scale + 0.5f))));
}
 

Example 47

From project GeekAlarm, under directory /android/src/com/geek_alarm/android/activities/.

Source file: TaskActivity.java

  21 
vote

private void displayTask(Task task){
  toggleSpinner(false);
  showErrorMessage(task.getErrorMessageId());
  ImageView question=(ImageView)findViewById(R.id.task_question);
  int choiceWidth=task.getChoice(0).getWidth();
  Display display=getWindowManager().getDefaultDisplay();
  boolean isTable=choiceWidth * 2 + 10 < display.getWidth();
  float weight=0.55f;
  int minHeight=(int)(layout.getBottom() * (1 - weight) / 4);
  layout.addView(inflater.inflate(isTable ? R.layout.choices_table : R.layout.choices_list,null),new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT,weight));
  question.setImageBitmap(task.getQuestion());
  int choicesIds[]={R.id.task_choice_1,R.id.task_choice_2,R.id.task_choice_3,R.id.task_choice_4};
  correctChoiceId=choicesIds[task.getCorrect()];
  currentTask=task;
  for (int i=0; i < 4; i++) {
    ImageView choiceView=(ImageView)findViewById(choicesIds[i]);
    choiceView.setOnClickListener(choiceListener);
    choiceView.setImageBitmap(task.getChoice(i));
    if (!isTable) {
      choiceView.getLayoutParams().height=Math.max(minHeight,task.getChoice(i).getHeight());
    }
  }
}
 

Example 48

From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.

Source file: Launcher.java

  21 
vote

private int mapConfigurationOriActivityInfoOri(int configOri){
  final Display d=getWindowManager().getDefaultDisplay();
  int naturalOri=Configuration.ORIENTATION_LANDSCAPE;
switch (d.getRotation()) {
case Surface.ROTATION_0:
case Surface.ROTATION_180:
    naturalOri=configOri;
  break;
case Surface.ROTATION_90:
case Surface.ROTATION_270:
naturalOri=(configOri == Configuration.ORIENTATION_LANDSCAPE) ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
break;
}
int[] oriMap={ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE};
int indexOffset=0;
if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
indexOffset=1;
}
return oriMap[(d.getRotation() + indexOffset) % 4];
}
 

Example 49

From project incubator-cordova-android, under directory /framework/src/org/apache/cordova/.

Source file: DroidGap.java

  21 
vote

/** 
 * Called when the activity is first created.
 * @param savedInstanceState
 */
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState){
  LOG.d(TAG,"DroidGap.onCreate()");
  super.onCreate(savedInstanceState);
  if (!this.getBooleanProperty("showTitle",false)) {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  }
  if (this.getBooleanProperty("setFullscreen",false)) {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
 else {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  }
  Display display=getWindowManager().getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  root=new LinearLayoutSoftKeyboardDetect(this,width,height);
  root.setOrientation(LinearLayout.VERTICAL);
  root.setBackgroundColor(this.backgroundColor);
  root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT,0.0F));
  setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
 

Example 50

From project iPhoroidUI, under directory /src/org/klab/iphoroid/util/.

Source file: ActivityUtil.java

  21 
vote

/** 
 * ?????????????????????????
 * @see "http://stackoverflow.com/questions/2795833/check-orientation-on-android-phone"
 */
public static int getScreenOrientation(Activity activity){
  Display getOrient=activity.getWindowManager().getDefaultDisplay();
  int orientation=Configuration.ORIENTATION_UNDEFINED;
  if (getOrient.getWidth() == getOrient.getHeight()) {
    orientation=Configuration.ORIENTATION_SQUARE;
  }
 else {
    if (getOrient.getWidth() < getOrient.getHeight()) {
      orientation=Configuration.ORIENTATION_PORTRAIT;
    }
 else {
      orientation=Configuration.ORIENTATION_LANDSCAPE;
    }
  }
  return orientation;
}
 

Example 51

From project Juggernaut_SystemUI, under directory /src/com/android/systemui/ui/.

Source file: SwipeView.java

  21 
vote

private void initSwipeView(){
  Log.i("uk.co.jasonfry.android.tools.ui.SwipeView","Initialising SwipeView");
  mLinearLayout=new LinearLayout(mContext);
  mLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
  super.addView(mLinearLayout,-1,new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
  setSmoothScrollingEnabled(true);
  setHorizontalFadingEdgeEnabled(false);
  setHorizontalScrollBarEnabled(false);
  Display display=((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  SCREEN_WIDTH=(int)(display.getWidth());
  mPageWidth=SCREEN_WIDTH;
  mCurrentPage=0;
  mSwipeOnTouchListener=new SwipeOnTouchListener();
  super.setOnTouchListener(mSwipeOnTouchListener);
}
 

Example 52

From project KeyboardTerm, under directory /src/tw/kenshinn/keyboardTerm/.

Source file: GestureView.java

  21 
vote

public void setMagnifierParms(int fwidth,int fheight,int zoom){
  final Display display=((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  final float rate=1 + (zoom / 100f) * 3;
  if ((TerminalActivity.termActFlags & TerminalActivity.FLAG_MAGNIFIER_FULLSCREEN) != 0) {
    MAGNIFIER_WIDTH=display.getWidth();
    MAGNIFIER_HEIGHT=display.getHeight();
    MAGNIFIER_FOCUS_WIDTH=Math.round(MAGNIFIER_WIDTH / rate);
    MAGNIFIER_FOCUS_HEIGHT=Math.round(MAGNIFIER_HEIGHT / rate);
  }
 else {
    MAGNIFIER_FOCUS_WIDTH=(int)((float)fwidth / 100 * display.getWidth());
    MAGNIFIER_FOCUS_HEIGHT=(int)((float)fheight / 100 * display.getHeight());
    MAGNIFIER_WIDTH=(int)Math.ceil(rate * MAGNIFIER_FOCUS_WIDTH);
    MAGNIFIER_HEIGHT=(int)Math.ceil(rate * MAGNIFIER_FOCUS_HEIGHT);
  }
}
 

Example 53

From project LunaTerm, under directory /src/tw/loli/lunaTerm/.

Source file: GestureView.java

  21 
vote

public void setMagnifierParms(int fwidth,int fheight,int zoom){
  final Display display=((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  final float rate=1 + (zoom / 100f) * 3;
  if ((TerminalActivity.termActFlags & TerminalActivity.FLAG_MAGNIFIER_FULLSCREEN) != 0) {
    MAGNIFIER_WIDTH=display.getWidth();
    MAGNIFIER_HEIGHT=display.getHeight();
    MAGNIFIER_FOCUS_WIDTH=Math.round(MAGNIFIER_WIDTH / rate);
    MAGNIFIER_FOCUS_HEIGHT=Math.round(MAGNIFIER_HEIGHT / rate);
  }
 else {
    MAGNIFIER_FOCUS_WIDTH=(int)((float)fwidth / 100 * display.getWidth());
    MAGNIFIER_FOCUS_HEIGHT=(int)((float)fheight / 100 * display.getHeight());
    MAGNIFIER_WIDTH=(int)Math.ceil(rate * MAGNIFIER_FOCUS_WIDTH);
    MAGNIFIER_HEIGHT=(int)Math.ceil(rate * MAGNIFIER_FOCUS_HEIGHT);
  }
}
 

Example 54

From project mediaphone, under directory /src/ac/robinson/mediaphone/activity/.

Source file: CameraActivity.java

  21 
vote

@Override public void onOrientationChanged(int newScreenOrientationDegrees){
  if (newScreenOrientationDegrees == OrientationEventListener.ORIENTATION_UNKNOWN) {
    return;
  }
  mScreenOrientation=newScreenOrientationDegrees;
  Display display=((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
  int displayRotation=OrientationManager.getDisplayRotationDegrees(display.getRotation());
  int correctedRotation=((newScreenOrientationDegrees - displayRotation + 360) % 360);
  if (correctedRotation == 180) {
    newScreenOrientationDegrees=displayRotation;
    correctedRotation=0;
  }
  mDisplayOrientation=CameraUtilities.getPreviewOrientationDegrees(newScreenOrientationDegrees,mCameraConfiguration.cameraOrientationDegrees,mCameraConfiguration.usingFrontCamera);
  if (mCameraView != null) {
    mCameraView.setRotation(mDisplayOrientation,mDisplayOrientation);
  }
  Resources res=getResources();
  Bitmap currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_revert);
  ((CenteredImageTextButton)findViewById(R.id.button_cancel_camera)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null);
  currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_camera);
  ((CenteredImageTextButton)findViewById(R.id.button_take_picture)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null);
  if (mCameraConfiguration.hasFrontCamera) {
    currentBitmap=BitmapFactory.decodeResource(res,android.R.drawable.ic_menu_rotate);
    ((CenteredImageTextButton)findViewById(R.id.button_switch_camera)).setCompoundDrawablesWithIntrinsicBounds(null,new BitmapDrawable(res,BitmapUtilities.rotate(currentBitmap,correctedRotation,currentBitmap.getWidth() / 2,currentBitmap.getHeight() / 2)),null,null);
  }
}
 

Example 55

From project mediautilities, under directory /src/ac/robinson/util/.

Source file: UIUtilities.java

  21 
vote

public static int getNaturalScreenOrientation(WindowManager windowManager){
  Display display=windowManager.getDefaultDisplay();
  int width=0;
  int height=0;
switch (display.getRotation()) {
case Surface.ROTATION_0:
case Surface.ROTATION_180:
    width=display.getWidth();
  height=display.getHeight();
break;
case Surface.ROTATION_90:
case Surface.ROTATION_270:
width=display.getHeight();
height=display.getWidth();
break;
default :
break;
}
if (width > height) {
return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}
return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
 

Example 56

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  21 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width < height) {
    Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
    int temp=width;
    width=height;
    height=temp;
  }
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution,false);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 57

From project packages_apps_Camera_1, under directory /src/com/android/camera/.

Source file: Util.java

  21 
vote

public static Size getOptimalPreviewSize(Activity currentActivity,List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.001;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=currentActivity.getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    targetHeight=display.getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.w(TAG,"No preview size match the aspect ratio");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  return optimalSize;
}
 

Example 58

From project packages_apps_Camera_2, under directory /src/com/android/camera/.

Source file: Util.java

  21 
vote

public static Size getOptimalPreviewSize(Activity currentActivity,List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.001;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=currentActivity.getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    targetHeight=display.getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.w(TAG,"No preview size match the aspect ratio");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  return optimalSize;
}
 

Example 59

From project PinyinIME, under directory /src/com/android/inputmethod/pinyin/.

Source file: Environment.java

  21 
vote

public void onConfigurationChanged(Configuration newConfig,Context context){
  if (mConfig.orientation != newConfig.orientation) {
    WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
    Display d=wm.getDefaultDisplay();
    mScreenWidth=d.getWidth();
    mScreenHeight=d.getHeight();
    int scale;
    if (mScreenHeight > mScreenWidth) {
      mKeyHeight=(int)(mScreenHeight * KEY_HEIGHT_RATIO_PORTRAIT);
      mCandidatesAreaHeight=(int)(mScreenHeight * CANDIDATES_AREA_HEIGHT_RATIO_PORTRAIT);
      scale=mScreenWidth;
    }
 else {
      mKeyHeight=(int)(mScreenHeight * KEY_HEIGHT_RATIO_LANDSCAPE);
      mCandidatesAreaHeight=(int)(mScreenHeight * CANDIDATES_AREA_HEIGHT_RATIO_LANDSCAPE);
      scale=mScreenHeight;
    }
    mNormalKeyTextSize=(int)(scale * NORMAL_KEY_TEXT_SIZE_RATIO);
    mFunctionKeyTextSize=(int)(scale * FUNCTION_KEY_TEXT_SIZE_RATIO);
    mNormalBalloonTextSize=(int)(scale * NORMAL_BALLOON_TEXT_SIZE_RATIO);
    mFunctionBalloonTextSize=(int)(scale * FUNCTION_BALLOON_TEXT_SIZE_RATIO);
    mKeyBalloonWidthPlus=(int)(scale * KEY_BALLOON_WIDTH_PLUS_RATIO);
    mKeyBalloonHeightPlus=(int)(scale * KEY_BALLOON_HEIGHT_PLUS_RATIO);
  }
  mConfig.updateFrom(newConfig);
}
 

Example 60

From project platform_frameworks_policies_base, under directory /phone/com/android/internal/policy/impl/.

Source file: PhoneWindowManager.java

  21 
vote

public int rotationForOrientationLw(int orientation,int lastRotation,boolean displayEnabled){
  if (mPortraitRotation < 0) {
    Display d=((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    if (d.getWidth() > d.getHeight()) {
      mPortraitRotation=Surface.ROTATION_90;
      mLandscapeRotation=Surface.ROTATION_0;
    }
 else {
      mPortraitRotation=Surface.ROTATION_0;
      mLandscapeRotation=Surface.ROTATION_90;
    }
  }
synchronized (mLock) {
switch (orientation) {
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
      return mLandscapeRotation;
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
    return mPortraitRotation;
}
if (mLidOpen) {
  return mLidOpenRotation;
}
 else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR && mCarDockRotation >= 0) {
  return mCarDockRotation;
}
 else if (mDockMode == Intent.EXTRA_DOCK_STATE_DESK && mDeskDockRotation >= 0) {
  return mDeskDockRotation;
}
 else {
  if (useSensorForOrientationLp(orientation)) {
    int curRotation=mOrientationListener.getCurrentRotation();
    return curRotation >= 0 ? curRotation : lastRotation;
  }
  return Surface.ROTATION_0;
}
}
}
 

Example 61

From project platform_packages_apps_camera, under directory /src/com/android/camera/.

Source file: Util.java

  21 
vote

public static Size getOptimalPreviewSize(Activity currentActivity,List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.001;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=currentActivity.getWindowManager().getDefaultDisplay();
  Point point=new Point();
  display.getSize(point);
  int targetHeight=Math.min(point.x,point.y);
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.w(TAG,"No preview size match the aspect ratio");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  return optimalSize;
}
 

Example 62

From project platform_packages_apps_Gallery2_1, under directory /src/com/android/gallery3d/app/.

Source file: Wallpaper.java

  21 
vote

@SuppressWarnings("fallthrough") @Override protected void onResume(){
  super.onResume();
  Intent intent=getIntent();
switch (mState) {
case STATE_INIT:
{
      mPickedItem=intent.getData();
      if (mPickedItem == null) {
        Intent request=new Intent(Intent.ACTION_GET_CONTENT).setClass(this,DialogPicker.class).setType(IMAGE_TYPE);
        startActivityForResult(request,STATE_PHOTO_PICKED);
        return;
      }
      mState=STATE_PHOTO_PICKED;
    }
case STATE_PHOTO_PICKED:
{
    int width=getWallpaperDesiredMinimumWidth();
    int height=getWallpaperDesiredMinimumHeight();
    Display display=getWindowManager().getDefaultDisplay();
    float spotlightX=(float)display.getWidth() / width;
    float spotlightY=(float)display.getHeight() / height;
    Intent request=new Intent(CropImage.ACTION_CROP).setDataAndType(mPickedItem,IMAGE_TYPE).addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).putExtra(CropImage.KEY_OUTPUT_X,width).putExtra(CropImage.KEY_OUTPUT_Y,height).putExtra(CropImage.KEY_ASPECT_X,width).putExtra(CropImage.KEY_ASPECT_Y,height).putExtra(CropImage.KEY_SPOTLIGHT_X,spotlightX).putExtra(CropImage.KEY_SPOTLIGHT_Y,spotlightY).putExtra(CropImage.KEY_SCALE,true).putExtra(CropImage.KEY_NO_FACE_DETECTION,true).putExtra(CropImage.KEY_SET_AS_WALLPAPER,true);
    startActivity(request);
    finish();
  }
}
}
 

Example 63

From project platform_packages_apps_VideoEditor, under directory /src/com/android/videoeditor/widgets/.

Source file: MediaItemView.java

  21 
vote

public MediaItemView(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  if (sAddTransitionDrawable == null) {
    sAddTransitionDrawable=getResources().getDrawable(R.drawable.add_transition_selector);
    sEmptyFrameDrawable=getResources().getDrawable(R.drawable.timeline_loading);
    sThumbnailCache=new ThumbnailCache(3 * 1024 * 1024);
  }
  final Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  final DisplayMetrics metrics=new DisplayMetrics();
  display.getMetrics(metrics);
  mScreenWidth=metrics.widthPixels;
  mGestureDetector=new GestureDetector(context,new MyGestureListener());
  mScrollListener=new MyScrollViewListener();
  final ProgressBar progressBar=ProgressBar.getProgressBar(context);
  final int layoutHeight=(int)(getResources().getDimension(R.dimen.media_layout_height) - getResources().getDimension(R.dimen.media_layout_padding));
  mGeneratingEffectProgressDestRect=new Rect(getPaddingLeft(),layoutHeight - progressBar.getHeight() - getPaddingBottom(),0,layoutHeight - getPaddingBottom());
  mGeneratingEffectProgress=-1;
  mLeftState=View.EMPTY_STATE_SET;
  mRightState=View.EMPTY_STATE_SET;
  mWantThumbnails=new ArrayList<Integer>();
  mPending=new HashSet<Integer>();
  mGeneration=sGenerationCounter++;
}
 

Example 64

From project QuickSnap, under directory /Camera/src/com/lightbox/android/camera/activities/.

Source file: Camera.java

  21 
vote

private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"No preview size match the aspect ratio");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  return optimalSize;
}
 

Example 65

From project Schedule, under directory /android/src/com/googlecode/android/widgets/DateSlider/.

Source file: ScrollLayout.java

  21 
vote

/** 
 * This method is called usually after a ScrollLayout is instanciated, it provides the scroller with all necessary information
 * @param labeler the labeler instance which will provide the ScrollLayout with time unit information 
 * @param time the start time as timestamp representation
 * @param objwidth the width of an TimeTextView in dps
 * @param objheight the height of an TimeTextView in dps
 */
public void setLabeler(DateSlider.Labeler labeler,long time,int objwidth,int objheight){
  this.labeler=labeler;
  currentTime=time;
  objWidth=(int)(objwidth * getContext().getResources().getDisplayMetrics().density);
  objHeight=(int)(objheight * getContext().getResources().getDisplayMetrics().density);
  Display display=((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int displayWidth=display.getWidth();
  while (displayWidth > childrenWidth - 0 * objWidth && labeler != null) {
    LayoutParams lp=new LayoutParams(objWidth,objHeight);
    if (childrenWidth == 0) {
      TimeView ttv=labeler.createView(getContext(),true);
      ttv.setVals(labeler.getElem(currentTime));
      addView((View)ttv,lp);
      mCenterView=ttv;
      childrenWidth+=objWidth;
    }
    TimeView ttv=labeler.createView(getContext(),false);
    ttv.setVals(labeler.add(((TimeView)getChildAt(getChildCount() - 1)).getEndTime(),1));
    addView((View)ttv,lp);
    ttv=labeler.createView(getContext(),false);
    ttv.setVals(labeler.add(((TimeView)getChildAt(0)).getEndTime(),-1));
    addView((View)ttv,0,lp);
    childrenWidth+=objWidth + objWidth;
  }
}
 

Example 66

From project SimpleMoney-Android, under directory /Zxing/bin/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  21 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width < height) {
    Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
    int temp=width;
    width=height;
    height=temp;
  }
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution,false);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 67

From project SoundFuse, under directory /src/org/androidaalto/soundfuse/.

Source file: BoardActivity.java

  21 
vote

private void createBoardButtons(){
  Display display=((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int buttonWidth=display.getWidth() / TOTAL_BEATS;
  int buttonHeight=display.getHeight() / TOTAL_SAMPLES;
  progressBarView=new ProgressBarView(this,display.getWidth(),display.getHeight(),buttonWidth,sequencer.getBpm());
  sequencer.setOnBPMListener(progressBarView);
  rootLayout.addView(progressBarView);
  SamplerToggleListener samplerListener=new SamplerToggleListener(sequencer,this,TOTAL_SAMPLES,TOTAL_BEATS);
  for (int samplePos=0; samplePos < TOTAL_SAMPLES; samplePos++) {
    Log.d("Board","Button width: " + buttonWidth);
    for (int beatPos=0; beatPos < TOTAL_BEATS; beatPos++) {
      samplersButtons[samplePos][beatPos]=new ToggleButton(this);
      samplersButtons[samplePos][beatPos].setTextOff("");
      samplersButtons[samplePos][beatPos].setTextOn("");
      samplersButtons[samplePos][beatPos].setText("");
      samplersButtons[samplePos][beatPos].setWidth(buttonWidth);
      samplersButtons[samplePos][beatPos].setHeight(buttonHeight);
      samplersButtons[samplePos][beatPos].setId(TOTAL_BEATS * samplePos + beatPos);
      samplersButtons[samplePos][beatPos].setOnClickListener(samplerListener);
      boardLayouts[samplePos].addView(samplersButtons[samplePos][beatPos]);
    }
  }
}
 

Example 68

From project SouthamptonUniversityMap, under directory /src/net/cbaines/suma/.

Source file: POIView.java

  21 
vote

public POIView(Context context,POI poi,int distInM){
  super(context);
  identifiersEnabled=PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SHOW_IDENTIFIERS,SHOW_IDENTIFIERS_ENABLED_BY_DEFAULT);
  Display display=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  width=display.getWidth();
  this.setOrientation(HORIZONTAL);
  name=new TextView(context);
  name.setTextSize(16f);
  name.setGravity(Gravity.LEFT);
  dist=new TextView(context);
  dist.setTextSize(16f);
  dist.setGravity(Gravity.RIGHT);
  routes=new BusRoutesView(context,(byte)0);
  textLayoutParams=new LayoutParams(width - (width / 4),LayoutParams.WRAP_CONTENT);
  LayoutParams distLayoutParams=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
  LayoutParams busRouteLayoutParams=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  setPOIAndDist(poi,distInM);
  addView(routes,busRouteLayoutParams);
  addView(name,textLayoutParams);
  addView(dist,distLayoutParams);
}
 

Example 69

From project SWADroid, under directory /SWADroid/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  21 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width < height) {
    Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
    int temp=width;
    width=height;
    height=temp;
  }
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution,false);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 70

From project TeclaAccess, under directory /source/src/ca/idi/tekla/ime/.

Source file: TeclaIME.java

  21 
vote

@Override public void onConfigurationChanged(Configuration conf){
  if (!TextUtils.equals(conf.locale.toString(),mLocale)) {
    initSuggest(conf.locale.toString());
  }
  if (conf.orientation != mOrientation) {
    commitTyped(getCurrentInputConnection());
    mOrientation=conf.orientation;
    if (isFullScreenShowing()) {
      if (TeclaApp.DEBUG)       Log.d(TeclaApp.TAG,"Changing size of fullscreen overlay.");
      Display display=getDisplay();
      mSwitchPopup.update(display.getWidth(),display.getHeight());
    }
  }
  if (mKeyboardSwitcher == null) {
    mKeyboardSwitcher=new KeyboardSwitcher(this);
  }
  mKeyboardSwitcher.makeKeyboards(true);
  super.onConfigurationChanged(conf);
  if (mKeyboardSwitcher.isMorseMode()) {
    mTeclaMorse.getMorseChart().configChanged(conf);
    mIMEView.invalidate();
    updateSpaceKey(true);
    updateCapsLockKey(true);
  }
}
 

Example 71

From project ThreadPaint, under directory /src/at/droidcode/threadpaint/.

Source file: Utils.java

  21 
vote

public static void lockScreenOrientation(boolean lock,Activity activity){
  int screenOrientation=ActivityInfo.SCREEN_ORIENTATION_SENSOR;
  if (lock) {
    Display display=((WindowManager)activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
switch (display.getRotation()) {
case Surface.ROTATION_0:
      screenOrientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    break;
case Surface.ROTATION_90:
  screenOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case Surface.ROTATION_270:
screenOrientation=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
}
}
activity.setRequestedOrientation(screenOrientation);
}
 

Example 72

From project vlc-android, under directory /vlc-android/src/org/videolan/vlc/android/.

Source file: VideoPlayerActivity.java

  21 
vote

/** 
 * Lock screen rotation
 */
private void lockScreen(){
  WindowManager wm=(WindowManager)getSystemService(WINDOW_SERVICE);
  Display display=wm.getDefaultDisplay();
  int rotation=display.getOrientation();
  if (Build.VERSION.SDK_INT >= 8) {
    try {
      Method m=display.getClass().getDeclaredMethod("getRotation");
      rotation=(Integer)m.invoke(display);
    }
 catch (    Exception e) {
      rotation=Surface.ROTATION_0;
    }
  }
 else {
    rotation=display.getOrientation();
  }
switch (rotation) {
case Surface.ROTATION_0:
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  break;
case Surface.ROTATION_90:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
break;
case Surface.ROTATION_270:
setRequestedOrientation(8);
break;
}
showInfo(R.string.locked,500);
}
 

Example 73

From project zxing, under directory /android/src/com/google/zxing/client/android/camera/.

Source file: CameraConfigurationManager.java

  21 
vote

/** 
 * Reads, one time, values from the camera that are needed by the app.
 */
void initFromCameraParameters(Camera camera){
  Camera.Parameters parameters=camera.getParameters();
  WindowManager manager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  Display display=manager.getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (width < height) {
    Log.i(TAG,"Display reports portrait orientation; assuming this is incorrect");
    int temp=width;
    width=height;
    height=temp;
  }
  screenResolution=new Point(width,height);
  Log.i(TAG,"Screen resolution: " + screenResolution);
  cameraResolution=findBestPreviewSizeValue(parameters,screenResolution);
  Log.i(TAG,"Camera resolution: " + cameraResolution);
}
 

Example 74

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/wm/.

Source file: WindowManagerService.java

  19 
vote

public void displayReady(){
synchronized (mWindowMap) {
    if (mDisplay != null) {
      throw new IllegalStateException("Display already initialized");
    }
    WindowManager wm=(WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
    mDisplay=wm.getDefaultDisplay();
synchronized (mDisplaySizeLock) {
      mInitialDisplayWidth=mDisplay.getRawWidth();
      mInitialDisplayHeight=mDisplay.getRawHeight();
      int rot=mDisplay.getRotation();
      if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) {
        int tmp=mInitialDisplayWidth;
        mInitialDisplayWidth=mInitialDisplayHeight;
        mInitialDisplayHeight=tmp;
      }
      mBaseDisplayWidth=mCurDisplayWidth=mAppDisplayWidth=mInitialDisplayWidth;
      mBaseDisplayHeight=mCurDisplayHeight=mAppDisplayHeight=mInitialDisplayHeight;
    }
    mInputManager.setDisplaySize(Display.DEFAULT_DISPLAY,mDisplay.getRawWidth(),mDisplay.getRawHeight(),mDisplay.getRawExternalWidth(),mDisplay.getRawExternalHeight());
    mPolicy.setInitialDisplaySize(mInitialDisplayWidth,mInitialDisplayHeight);
  }
  try {
    mActivityManager.updateConfiguration(null);
  }
 catch (  RemoteException e) {
  }
synchronized (mWindowMap) {
    readForcedDisplaySizeLocked();
  }
}
 

Example 75

From project mobilis, under directory /MobilisXHunt/MobilisXHunt_Android/src/de/tudresden/inf/rn/mobilis/android/xhunt/ui/.

Source file: DialogDepartures.java

  19 
vote

/** 
 * Instantiates a new DialogDepartures.
 * @param context the context of the application
 * @param display the display of the players device
 */
public DialogDepartures(Context context,Display display){
  super(context);
  mContext=context;
  this.mDisplay=display;
  this.setContentView(R.layout.dialog_body);
  this.setTitle("Departures At: ");
  mTableLayout=(TableLayout)findViewById(R.id.dialog_list);
}
 

Example 76

From project wheelmap-android, under directory /wheelmap/wheelmap/src/main/java/org/wheelmap/android/utils/.

Source file: UtilsMisc.java

  19 
vote

public static int calcRotationOffset(Display display){
  int rotation;
  try {
    Method method;
    if (hasFroyo()) {
      method=Display.class.getDeclaredMethod("getRotation",new Class[0]);
    }
 else {
      method=Display.class.getDeclaredMethod("getOrientation",new Class[0]);
    }
    rotation=(Integer)method.invoke(display,new Object[0]);
  }
 catch (  NoSuchMethodException e) {
    return 0;
  }
catch (  IllegalArgumentException e) {
    return 0;
  }
catch (  IllegalAccessException e) {
    return 0;
  }
catch (  InvocationTargetException e) {
    return 0;
  }
switch (rotation) {
case Surface.ROTATION_0:
    return 0;
case Surface.ROTATION_90:
  return 90;
case Surface.ROTATION_180:
return 180;
case Surface.ROTATION_270:
return -90;
default :
return 0;
}
}