Java Code Examples for android.util.DisplayMetrics

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 agit, under directory /agit/src/main/java/com/madgag/android/notifications/.

Source file: StatusBarNotificationStyles.java

  32 
vote

private DisplayMetrics getDisplayMetrics(){
  DisplayMetrics metrics=new DisplayMetrics();
  WindowManager wm=(WindowManager)context.getSystemService(WINDOW_SERVICE);
  wm.getDefaultDisplay().getMetrics(metrics);
  return metrics;
}
 

Example 2

From project Amantech, under directory /Android/CloudAppStudioAndroid/src/com/cloudappstudio/activities/.

Source file: EntryDetailsActivity.java

  32 
vote

public void createImage(String imageUrl){
  DisplayMetrics metrics=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  int widthPixels=metrics.widthPixels;
  int heightPixels=(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,getResources().getDisplayMetrics());
  ImageLoaderView imageView=new ImageLoaderView(getApplicationContext(),imageUrl);
  imageView.setLayoutParams(new LayoutParams(widthPixels,heightPixels));
  scrollViewLayout.addView(imageView);
}
 

Example 3

From project android-joedayz, under directory /Proyectos/GreenDroid/src/greendroid/widget/.

Source file: PagedView.java

  32 
vote

private void initPagedView(){
  final Context context=getContext();
  mScroller=new Scroller(context,new DecelerateInterpolator());
  final ViewConfiguration conf=ViewConfiguration.get(context);
  mPagingTouchSlop=conf.getScaledTouchSlop() * 2;
  mMaximumVelocity=conf.getScaledMaximumFlingVelocity();
  final DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  mMinimumVelocity=(int)(metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
 

Example 4

From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.

Source file: Term.java

  32 
vote

private TermView createEmulatorView(TermSession session){
  DisplayMetrics metrics=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  TermView emulatorView=new TermView(this,session,metrics);
  emulatorView.setExtGestureListener(new EmulatorViewGestureListener(emulatorView));
  emulatorView.setOnKeyListener(mBackKeyListener);
  registerForContextMenu(emulatorView);
  return emulatorView;
}
 

Example 5

From project android_7, under directory /src/org/immopoly/android/helper/.

Source file: Settings.java

  32 
vote

public static float getScreenDensity(Activity activity){
  if (screenDesity == 0.0f) {
    DisplayMetrics metrics=new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    screenDesity=metrics.density;
  }
  return screenDesity;
}
 

Example 6

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

Source file: GridViewSpecial.java

  32 
vote

private void initCellSize(){
  Activity a=(Activity)getContext();
  DisplayMetrics metrics=new DisplayMetrics();
  a.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  mCellSizeChoices=new LayoutSpec[]{new LayoutSpec(67,67,8,0,metrics),new LayoutSpec(92,92,8,0,metrics)};
}
 

Example 7

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/util/.

Source file: GalleryUtils.java

  32 
vote

public static void initialize(Context context){
  if (sPixelDensity < 0) {
    DisplayMetrics metrics=new DisplayMetrics();
    WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);
    sPixelDensity=metrics.density;
  }
}
 

Example 8

From project BazaarUtils, under directory /src/com/congenialmobile/widget/.

Source file: LazyImageView.java

  32 
vote

private void initProgressBarLoadingView(Context context){
  WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  DisplayMetrics metrics=new DisplayMetrics();
  wm.getDefaultDisplay().getMetrics(metrics);
  int width=(int)((float)metrics.density * 36);
  ProgressBar pBar=new ProgressBar(context);
  pBar.setLayoutParams(new LayoutParams(width,width,Gravity.CENTER));
  addView(pBar);
}
 

Example 9

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

Source file: LocalLib.java

  32 
vote

/** 
 * click on screen, the point is on the right
 */
public void clickOnScreenRight(){
  DisplayMetrics dm;
  dm=new DisplayMetrics();
  mActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
  int x=dm.widthPixels;
  int y=dm.heightPixels;
  clickOnScreen(x / 4,y / 2);
}
 

Example 10

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/stage/.

Source file: NativeAppActivity.java

  32 
vote

@Override public void onCreate(Bundle savedInstanceState){
  ProjectManager manager=ProjectManager.getInstance();
  DisplayMetrics dm=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(dm);
  Values.SCREEN_WIDTH=dm.widthPixels;
  Values.SCREEN_HEIGHT=dm.heightPixels;
  context=this;
  manager.loadProject("project.xml",this,false);
  manager=ProjectManager.getInstance();
  super.onCreate(savedInstanceState);
}
 

Example 11

From project CineShowTime-Android, under directory /Libraries/GreenDroid/src/greendroid/widget/.

Source file: PagedView.java

  32 
vote

private void initPagedView(){
  final Context context=getContext();
  mScroller=new Scroller(context,new DecelerateInterpolator());
  final ViewConfiguration conf=ViewConfiguration.get(context);
  mPagingTouchSlop=conf.getScaledTouchSlop() * 2;
  mMaximumVelocity=conf.getScaledMaximumFlingVelocity();
  final DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  mMinimumVelocity=(int)(metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
 

Example 12

From project droid-fu, under directory /src/main/java/com/github/droidfu/support/.

Source file: DisplaySupport.java

  32 
vote

public static int getScreenDensity(Context context){
  if (screenDensity == -1) {
    DisplayMetrics displayMetrics=context.getResources().getDisplayMetrics();
    try {
      screenDensity=DisplayMetrics.class.getField("densityDpi").getInt(displayMetrics);
    }
 catch (    Exception e) {
      screenDensity=SCREEN_DENSITY_MEDIUM;
    }
  }
  return screenDensity;
}
 

Example 13

From project flexymind-alpha, under directory /src/com/flexymind/alpha/.

Source file: StartGameScreen.java

  32 
vote

private void setSettingsButtonSize(){
  settingsBitmap=BitmapFactory.decodeResource(getResources(),R.drawable.settings);
  DisplayMetrics metrics=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  settingsBitmap=Bitmap.createScaledBitmap(settingsBitmap,metrics.heightPixels / 6,metrics.heightPixels / 6,true);
  settingsButton.setImageBitmap(settingsBitmap);
}
 

Example 14

From project generic-store-for-android, under directory /src/com/wareninja/opensource/droidfu/support/.

Source file: DisplaySupport.java

  32 
vote

public static int getScreenDensity(Context context){
  if (screenDensity == -1) {
    DisplayMetrics displayMetrics=context.getResources().getDisplayMetrics();
    try {
      screenDensity=DisplayMetrics.class.getField("densityDpi").getInt(displayMetrics);
    }
 catch (    Exception e) {
      screenDensity=SCREEN_DENSITY_MEDIUM;
    }
  }
  return screenDensity;
}
 

Example 15

From project Gingerbread-Keyboard, under directory /src/com/android/inputmethod/latin/.

Source file: LatinIME.java

  32 
vote

@Override public boolean onEvaluateFullscreenMode(){
  DisplayMetrics dm=getResources().getDisplayMetrics();
  float displayHeight=dm.heightPixels;
  float dimen=getResources().getDimension(R.dimen.max_height_for_fullscreen);
  if (displayHeight > dimen) {
    return false;
  }
 else {
    return super.onEvaluateFullscreenMode();
  }
}
 

Example 16

From project GreenDroid, under directory /GreenDroid/src/greendroid/widget/.

Source file: PagedView.java

  32 
vote

private void initPagedView(){
  final Context context=getContext();
  mScroller=new Scroller(context,new DecelerateInterpolator());
  final ViewConfiguration conf=ViewConfiguration.get(context);
  mPagingTouchSlop=conf.getScaledTouchSlop() * 2;
  mMaximumVelocity=conf.getScaledMaximumFlingVelocity();
  final DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  mMinimumVelocity=(int)(metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
 

Example 17

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

Source file: Utilities.java

  32 
vote

private static void initStatics(Context context){
  final Resources resources=context.getResources();
  final DisplayMetrics metrics=resources.getDisplayMetrics();
  final float density=metrics.density;
  sIconWidth=sIconHeight=(int)resources.getDimension(R.dimen.app_icon_size);
  sIconTextureWidth=sIconTextureHeight=sIconWidth;
  sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density,BlurMaskFilter.Blur.NORMAL));
  sGlowColorPressedPaint.setColor(0xffffc300);
  sGlowColorFocusedPaint.setColor(0xffff8e00);
  ColorMatrix cm=new ColorMatrix();
  cm.setSaturation(0.2f);
  sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
  sDisabledPaint.setAlpha(0x88);
}
 

Example 18

From project ignition, under directory /ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/.

Source file: IgnitedScreens.java

  32 
vote

/** 
 * Provides a save (i.e. backwards compatible) of accessing the device's screen density.
 * @param context the current context
 * @return the screen density in dots-per-inch
 */
public static int getScreenDensity(Context context){
  if (screenDensity == -1) {
    DisplayMetrics displayMetrics=context.getResources().getDisplayMetrics();
    screenDensity=displayMetrics.densityDpi;
  }
  return screenDensity;
}
 

Example 19

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

Source file: ImageTagFactory.java

  32 
vote

private Display prepareDisplay(Context context){
  Display d=((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  DisplayMetrics dm=new DisplayMetrics();
  d.getMetrics(dm);
  return d;
}
 

Example 20

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

Source file: GetScreenInfoCommand.java

  32 
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 21

From project Monetizing-Android-Demo-Project, under directory /src/com/adwhirl/util/.

Source file: AdWhirlUtil.java

  32 
vote

/** 
 * Gets the screen density for the device.
 * @param activity is the current activity.
 * @return A double value representing the device's screen density.
 */
public static double getDensity(Activity activity){
  if (density == -1) {
    DisplayMetrics displayMetrics=new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    density=displayMetrics.density;
  }
  return density;
}
 

Example 22

From project OAK, under directory /oak-library/src/main/java/oak/external/com/github/droidfu/support/.

Source file: DisplaySupport.java

  32 
vote

public static int getScreenDensity(Context context){
  if (screenDensity == -1) {
    DisplayMetrics displayMetrics=context.getResources().getDisplayMetrics();
    try {
      screenDensity=DisplayMetrics.class.getField("densityDpi").getInt(displayMetrics);
    }
 catch (    Exception e) {
      screenDensity=SCREEN_DENSITY_MEDIUM;
    }
  }
  return screenDensity;
}
 

Example 23

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

Source file: Util.java

  32 
vote

public static void initialize(Context context){
  sIsTabletUI=(context.getResources().getConfiguration().smallestScreenWidthDp >= 600);
  DisplayMetrics metrics=new DisplayMetrics();
  WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  wm.getDefaultDisplay().getMetrics(metrics);
  sPixelDensity=metrics.density;
  sImageFileNamer=new ImageFileNamer(context.getString(R.string.image_file_name_format));
}
 

Example 24

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

Source file: Util.java

  32 
vote

public static void initialize(Context context){
  sIsTabletUI=(context.getResources().getConfiguration().smallestScreenWidthDp >= 600);
  DisplayMetrics metrics=new DisplayMetrics();
  WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  wm.getDefaultDisplay().getMetrics(metrics);
  sPixelDensity=metrics.density;
  sImageFileNamer=new ImageFileNamer(context.getString(R.string.image_file_name_format));
}
 

Example 25

From project PinDroid, under directory /src/com/pindroid/activity/.

Source file: Main.java

  32 
vote

public void onMyTagsSelected(){
  DisplayMetrics outMetrics=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
  if (findViewById(R.id.main_tablet_detect) != null) {
    startActivity(IntentHelper.ViewTabletTags(mAccount.name,this));
  }
 else {
    startActivity(IntentHelper.ViewTags(mAccount.name,this));
  }
}
 

Example 26

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

Source file: PixelArtEditor.java

  32 
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 27

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

Source file: Util.java

  32 
vote

public static void initialize(Context context){
  DisplayMetrics metrics=new DisplayMetrics();
  WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  wm.getDefaultDisplay().getMetrics(metrics);
  sPixelDensity=metrics.density;
  sImageFileNamer=new ImageFileNamer(context.getString(R.string.image_file_name_format));
}
 

Example 28

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

Source file: GridViewSpecial.java

  32 
vote

private void initCellSize(){
  Activity a=(Activity)getContext();
  DisplayMetrics metrics=new DisplayMetrics();
  a.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  mCellSizeChoices=new LayoutSpec[]{new LayoutSpec(67,67,8,0,metrics),new LayoutSpec(92,92,8,0,metrics)};
}
 

Example 29

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

Source file: MovieViewControl.java

  32 
vote

private int diptopx(int dipValue){
  DisplayMetrics metrics=new DisplayMetrics();
  ((Activity)mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
  float density=metrics.density;
  float pxValue=dipValue * density;
  return (int)pxValue;
}
 

Example 30

From project PowerTutor, under directory /src/edu/umich/PowerTutor/phone/.

Source file: PassionConstants.java

  32 
vote

public PassionConstants(Context context){
  super(context);
  DisplayMetrics metrics=new DisplayMetrics();
  WindowManager windowManager=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
  windowManager.getDefaultDisplay().getMetrics(metrics);
  screenWidth=metrics.widthPixels;
  screenHeight=metrics.heightPixels;
}
 

Example 31

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

Source file: GLRootView.java

  32 
vote

public synchronized static float dpToPixel(Context context,float dp){
  if (sPixelDensity < 0) {
    DisplayMetrics metrics=new DisplayMetrics();
    ((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
    sPixelDensity=metrics.density;
  }
  return sPixelDensity * dp;
}
 

Example 32

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

Source file: Utils.java

  32 
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 33

From project RA_Launcher, under directory /src/com/android/ra/launcher/.

Source file: Utilities.java

  32 
vote

private static void initStatics(Context context){
  final Resources resources=context.getResources();
  final DisplayMetrics metrics=resources.getDisplayMetrics();
  final float density=metrics.density;
  sIconWidth=sIconHeight=(int)resources.getDimension(android.R.dimen.app_icon_size);
  sIconTextureWidth=sIconTextureHeight=sIconWidth + 2;
  sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density,BlurMaskFilter.Blur.NORMAL));
  sGlowColorPressedPaint.setColor(0xffffc300);
  sGlowColorFocusedPaint.setColor(0xffff8e00);
  ColorMatrix cm=new ColorMatrix();
  cm.setSaturation(0.2f);
  sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
  sDisabledPaint.setAlpha(0x88);
}
 

Example 34

From project rbb, under directory /src/com/btmura/android/reddit/app/.

Source file: AbstractBrowserActivity.java

  32 
vote

private void refreshThingBodyWidthMeasurement(){
  int newWidth=hasSubredditList() ? subredditListWidth : 0;
  Resources r=getResources();
  DisplayMetrics dm=r.getDisplayMetrics();
  int padding=r.getDimensionPixelSize(R.dimen.element_padding);
  if (navContainer != null) {
    thingBodyWidth=dm.widthPixels / 2 - padding * 4;
  }
 else {
    thingBodyWidth=dm.widthPixels / 2 - padding * 3 - newWidth;
  }
}
 

Example 35

From project roman10-android-tutorial, under directory /pagedview/src/roman10/tutorial/ui/pagedview/.

Source file: PagedView.java

  32 
vote

private void initPagedView(){
  final Context context=getContext();
  mScroller=new Scroller(context,new DecelerateInterpolator());
  final ViewConfiguration conf=ViewConfiguration.get(context);
  mPagingTouchSlop=conf.getScaledTouchSlop() * 2;
  mMaximumVelocity=conf.getScaledMaximumFlingVelocity();
  final DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  mMinimumVelocity=(int)(metrics.density * MINIMUM_PAGE_CHANGE_VELOCITY + 0.5f);
}
 

Example 36

From project Schedule, under directory /libs/android/sherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  32 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 37

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 38

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 39

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 40

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 41

From project android-api-demos, under directory /src/com/mobeelizer/demos/adapters/.

Source file: FileSyncAdapter.java

  31 
vote

/** 
 * Constructor
 * @param context
 * @param objects
 */
public FileSyncAdapter(final Context context,final List<FileSyncEntity> objects){
  super(context,R.layout.itemized_list_item,R.id.listItemLowerText,objects);
  mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  mRes=context.getResources();
  mDisplayMetrics=new DisplayMetrics();
  ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(mDisplayMetrics);
}
 

Example 42

From project Android-automation, under directory /TmtsApp/src/com/taobao/tmts/framework/app/.

Source file: ScrollActivity.java

  31 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.scrollview_layout);
  scrollView=(ScrollView)findViewById(R.id.ScrollView);
  scrollButtonTop=(Button)findViewById(R.id.scroll_button);
  scrollButtonBottom=(Button)findViewById(R.id.scroll_button2);
  final DisplayMetrics dm=new DisplayMetrics();
  this.getWindowManager().getDefaultDisplay().getMetrics(dm);
  scrollButtonTop.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View v){
      Log.v(LOG_TAG,"scroll_button clicked");
      Log.v(LOG_TAG,String.valueOf(dm.widthPixels));
      Log.v(LOG_TAG,String.valueOf(dm.heightPixels));
      Log.v(LOG_TAG,String.valueOf(scrollView.getScrollX()));
      Log.v(LOG_TAG,String.valueOf(scrollView.getScrollY()));
      scrollView.fullScroll(View.FOCUS_DOWN);
    }
  }
);
}
 

Example 43

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

Source file: PreviewActivity.java

  31 
vote

private void updatePreviewSize(){
  DisplayMetrics dm=this.getResources().getDisplayMetrics();
  float viewScale=this.getResources().getDimension(R.dimen.gif_view_scale);
  viewScale=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,1,dm) * viewScale;
  int newWidth=(int)(GSSettings.getGifOutputSize().size() * viewScale);
  int newHeight=newWidth;
  if (this.mFirstFrameWidth > this.mFirstFrameHeight)   newHeight=(int)(this.mFirstFrameHeight * ((double)newWidth / this.mFirstFrameWidth));
 else   newWidth=(int)(this.mFirstFrameWidth * ((double)newHeight / this.mFirstFrameHeight));
  if (this.mPreviewHolder.getWidth() < newWidth) {
    newHeight=(int)(newHeight * ((double)this.mPreviewHolder.getWidth() / newWidth));
    newWidth=this.mPreviewHolder.getWidth();
  }
  if (this.mPreviewHolder.getHeight() < newHeight) {
    newWidth=(int)(newWidth * ((double)this.mPreviewHolder.getHeight() / newHeight));
    newHeight=this.mPreviewHolder.getHeight();
  }
  LayoutParams params=this.mPreviewImage.getLayoutParams();
  params.height=newHeight;
  params.width=newWidth;
  this.mPreviewImage.setLayoutParams(params);
  this.mPreviewImage.invalidate();
}
 

Example 44

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/keyboard/.

Source file: KeyboardSwitcher.java

  31 
vote

private KeyboardId getKeyboardId(EditorInfo editorInfo,final boolean isSymbols,final boolean isShift,Settings.Values settingsValues){
  final int mode=Utils.getKeyboardMode(editorInfo);
  final int xmlId;
switch (mode) {
case KeyboardId.MODE_PHONE:
    xmlId=(isSymbols && isShift) ? R.xml.kbd_phone_shift : R.xml.kbd_phone;
  break;
case KeyboardId.MODE_NUMBER:
xmlId=R.xml.kbd_number;
break;
default :
if (isSymbols) {
xmlId=isShift ? R.xml.kbd_symbols_shift : R.xml.kbd_symbols;
}
 else {
xmlId=R.xml.kbd_qwerty;
}
break;
}
final boolean settingsKeyEnabled=settingsValues.isSettingsKeyEnabled();
@SuppressWarnings("deprecation") final boolean noMicrophone=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_MICROPHONE,editorInfo) || Utils.inPrivateImeOptions(null,LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT,editorInfo);
final boolean voiceKeyEnabled=settingsValues.isVoiceKeyEnabled(editorInfo) && !noMicrophone;
final boolean voiceKeyOnMain=settingsValues.isVoiceKeyOnMain();
final boolean noSettingsKey=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_SETTINGS_KEY,editorInfo);
final boolean hasSettingsKey=settingsKeyEnabled && !noSettingsKey;
final int f2KeyMode=getF2KeyMode(settingsKeyEnabled,noSettingsKey);
final boolean hasShortcutKey=voiceKeyEnabled && (isSymbols != voiceKeyOnMain);
final boolean forceAscii=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_FORCE_ASCII,editorInfo);
final boolean asciiCapable=mSubtypeSwitcher.currentSubtypeContainsExtraValueKey(LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE);
final Locale locale=(forceAscii && !asciiCapable) ? Locale.US : mSubtypeSwitcher.getInputLocale();
final Configuration conf=mResources.getConfiguration();
final DisplayMetrics dm=mResources.getDisplayMetrics();
return new KeyboardId(mResources.getResourceEntryName(xmlId),xmlId,locale,conf.orientation,dm.widthPixels,mode,editorInfo,hasSettingsKey,f2KeyMode,noSettingsKey,voiceKeyEnabled,hasShortcutKey);
}
 

Example 45

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 46

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: Display.java

  31 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.display);
  mFontSize=(Spinner)findViewById(R.id.fontSize);
  mFontSize.setOnItemSelectedListener(mFontSizeChanged);
  String[] states=new String[3];
  Resources r=getResources();
  states[0]=r.getString(R.string.small_font);
  states[1]=r.getString(R.string.medium_font);
  states[2]=r.getString(R.string.large_font);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,states);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mFontSize.setAdapter(adapter);
  mPreview=(TextView)findViewById(R.id.preview);
  mPreview.setText(r.getText(R.string.font_size_preview_text));
  Button save=(Button)findViewById(R.id.save);
  save.setText(r.getText(R.string.font_size_save));
  save.setOnClickListener(this);
  mTextSizeTyped=new TypedValue();
  TypedArray styledAttributes=obtainStyledAttributes(android.R.styleable.TextView);
  styledAttributes.getValue(android.R.styleable.TextView_textSize,mTextSizeTyped);
  DisplayMetrics metrics=getResources().getDisplayMetrics();
  mDisplayMetrics=new DisplayMetrics();
  mDisplayMetrics.density=metrics.density;
  mDisplayMetrics.heightPixels=metrics.heightPixels;
  mDisplayMetrics.scaledDensity=metrics.scaledDensity;
  mDisplayMetrics.widthPixels=metrics.widthPixels;
  mDisplayMetrics.xdpi=metrics.xdpi;
  mDisplayMetrics.ydpi=metrics.ydpi;
  styledAttributes.recycle();
}
 

Example 47

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/app/.

Source file: App.java

  31 
vote

public App(Context context){
  mMap.put(context,this);
  mContext=context;
  if (PIXEL_DENSITY == 0.0f) {
    DisplayMetrics metrics=new DisplayMetrics();
    ((Activity)mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
    PIXEL_DENSITY=metrics.density;
    PIXEL_DENSITY_DPI=metrics.densityDpi;
  }
  if (RESPATCH_FACTOR == 0) {
    RESPATCH_FACTOR=(int)(Runtime.getRuntime().maxMemory() / 1048576) / RESPATCH_DIVISOR;
  }
  mHandler=new Handler(Looper.getMainLooper());
  mReverseGeocoder=new ReverseGeocoder(mContext);
}
 

Example 48

From project android_packages_apps_TouchWiz30Launcher, under directory /src/com/sec/android/app/twlauncher/.

Source file: Utilities.java

  31 
vote

BubbleText(Context context){
  Resources resources=context.getResources();
  DisplayMetrics displaymetrics=resources.getDisplayMetrics();
  float f=displaymetrics.density;
  mDensity=displaymetrics.densityDpi;
  float f1=2.0F * f;
  float f2=2.0F * f;
  float f3=resources.getDimension(0x7f090000);
  RectF rectf=mBubbleRect;
  rectf.left=0.0F;
  rectf.top=0.0F;
  rectf.right=(int)f3;
  mTextWidth=f3 - f1 - f2;
  TextPaint textpaint=new TextPaint();
  mTextPaint=textpaint;
  textpaint.setTextSize(13F * f);
  textpaint.setColor(-1);
  textpaint.setAntiAlias(true);
  float f4=-textpaint.ascent();
  float f5=textpaint.descent();
  mFirstLineY=(int)(0.5F + (0.0F + f4));
  mLineHeight=(int)(0.5F + (f5 + (0.0F + f4)));
  mBitmapWidth=(int)(0.5F + mBubbleRect.width());
  mBitmapHeight=Utilities.roundToPow2((int)(0.5F + (0.0F + (float)(2 * mLineHeight))));
  mBubbleRect.offsetTo(((float)mBitmapWidth - mBubbleRect.width()) / 2.0F,0.0F);
}
 

Example 49

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/keyboard/.

Source file: KeyboardSwitcher.java

  31 
vote

private KeyboardId getKeyboardId(EditorInfo editorInfo,final boolean isSymbols,final boolean isShift,Settings.Values settingsValues){
  final int mode=Utils.getKeyboardMode(editorInfo);
  final int xmlId;
switch (mode) {
case KeyboardId.MODE_PHONE:
    xmlId=(isSymbols && isShift) ? R.xml.kbd_phone_shift : R.xml.kbd_phone;
  break;
case KeyboardId.MODE_NUMBER:
xmlId=R.xml.kbd_number;
break;
default :
if (isSymbols) {
xmlId=isShift ? R.xml.kbd_symbols_shift : R.xml.kbd_symbols;
}
 else {
xmlId=R.xml.kbd_qwerty;
}
break;
}
final boolean settingsKeyEnabled=settingsValues.isSettingsKeyEnabled();
@SuppressWarnings("deprecation") final boolean noMicrophone=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_MICROPHONE,editorInfo) || Utils.inPrivateImeOptions(null,LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT,editorInfo);
final boolean voiceKeyEnabled=settingsValues.isVoiceKeyEnabled(editorInfo) && !noMicrophone;
final boolean voiceKeyOnMain=settingsValues.isVoiceKeyOnMain();
final boolean noSettingsKey=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_SETTINGS_KEY,editorInfo);
final boolean hasSettingsKey=settingsKeyEnabled && !noSettingsKey;
final int f2KeyMode=getF2KeyMode(settingsKeyEnabled,noSettingsKey);
final boolean hasShortcutKey=voiceKeyEnabled && (isSymbols != voiceKeyOnMain);
final boolean forceAscii=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_FORCE_ASCII,editorInfo);
final boolean asciiCapable=mSubtypeSwitcher.currentSubtypeContainsExtraValueKey(LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE);
final Locale locale=(forceAscii && !asciiCapable) ? Locale.US : mSubtypeSwitcher.getInputLocale();
final Configuration conf=mResources.getConfiguration();
final DisplayMetrics dm=mResources.getDisplayMetrics();
return new KeyboardId(mResources.getResourceEntryName(xmlId),xmlId,locale,conf.orientation,dm.widthPixels,mode,editorInfo,hasSettingsKey,f2KeyMode,noSettingsKey,voiceKeyEnabled,hasShortcutKey);
}
 

Example 50

From project android_packages_wallpapers_basic, under directory /src/com/android/wallpaper/walkaround/.

Source file: WalkAroundWallpaper.java

  31 
vote

private void startPreview(){
  final Resources resources=getResources();
  final boolean portrait=resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
  final Camera.Parameters params=mCamera.getParameters();
  final DisplayMetrics metrics=resources.getDisplayMetrics();
  final List<Camera.Size> sizes=params.getSupportedPreviewSizes();
  boolean found=false;
  for (  Camera.Size size : sizes) {
    if ((portrait && size.width == metrics.heightPixels && size.height == metrics.widthPixels) || (!portrait && size.width == metrics.widthPixels && size.height == metrics.heightPixels)) {
      params.setPreviewSize(size.width,size.height);
      found=true;
    }
  }
  if (!found) {
    for (    Camera.Size size : sizes) {
      if (size.width >= metrics.widthPixels && size.height >= metrics.heightPixels) {
        params.setPreviewSize(size.width,size.height);
        found=true;
      }
    }
  }
  if (!found) {
    Canvas canvas=null;
    try {
      canvas=mHolder.lockCanvas();
      if (canvas != null)       canvas.drawColor(0);
    }
  finally {
      if (canvas != null)       mHolder.unlockCanvasAndPost(canvas);
    }
    Camera.Size size=sizes.get(0);
    params.setPreviewSize(size.width,size.height);
  }
  params.set("orientation",portrait ? "portrait" : "landscape");
  mCamera.setParameters(params);
  mCamera.startPreview();
}
 

Example 51

From project be.norio.twunch.android, under directory /src/com/koushikdutta/urlimageviewhelper/.

Source file: UrlImageViewHelper.java

  31 
vote

private static void prepareResources(Context context){
  if (mMetrics != null)   return;
  mMetrics=new DisplayMetrics();
  Activity act=(Activity)context;
  act.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
  AssetManager mgr=context.getAssets();
  mResources=new Resources(mgr,mMetrics,context.getResources().getConfiguration());
}
 

Example 52

From project CHMI, under directory /src/org/kaldax/app/chmi/.

Source file: StandardLayoutProviderLegacy.java

  31 
vote

StandardLayoutProviderLegacy(CHMI activity){
  XPOS=null;
  YPOS=null;
  chmiActivity=activity;
  bZoomActive=false;
  Logger.global.log(Level.WARNING,new Date().toLocaleString() + " display metrics");
  DisplayMetrics dm=new DisplayMetrics();
  chmiActivity.getWindowManager().getDefaultDisplay().getMetrics(dm);
  iScreenMaxX=dm.widthPixels;
  iScreenMaxY=dm.heightPixels;
  try {
    iDensityDPI=dm.getClass().getField("densityDpi").getInt(dm);
  }
 catch (  java.lang.Throwable e) {
    Logger.getLogger(CHMI.class.getName()).log(Level.INFO,"Unable to determine DPI. Using default value 160");
    iDensityDPI=160;
  }
  bSmallDisplay=(dm.widthPixels * dm.heightPixels < 153600);
  if (bSmallDisplay) {
    Logger.getLogger(CHMI.class.getName()).log(Level.INFO,"small display mode activated");
  }
 else {
  }
}
 

Example 53

From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/app/.

Source file: MainActivity.java

  31 
vote

public void populateList(boolean all){
  try {
    List sts;
    if (all) {
      sts=mDbHelper.getMemory();
    }
 else {
      sts=mDbHelper.getMemory(hOverlay.getRadius());
    }
    DisplayMetrics dm=new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int height=dm.heightPixels;
    int calc=(sts.size() * CircleHelper.dip2px(50,scale) + CircleHelper.dip2px(45,scale));
    if (calc > height - CircleHelper.dip2px(145,scale))     calc=height - CircleHelper.dip2px(145,scale);
 else     if (sts.size() == 0)     calc=0;
    mSlidingDrawer.setStations(sts);
    mSlidingDrawer.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,calc));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 54

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 55

From project connectbot, under directory /src/sk/vx/connectbot/util/.

Source file: UberColorPickerDialog.java

  31 
vote

/** 
 * Activity entry point
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  OnColorChangedListener l=new OnColorChangedListener(){
    public void colorChanged(    int color){
      mListener.colorChanged(color);
      dismiss();
    }
  }
;
  DisplayMetrics dm=new DisplayMetrics();
  getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
  int screenWidth=dm.widthPixels;
  int screenHeight=dm.heightPixels;
  setTitle("Pick a color (try the trackball)");
  try {
    setContentView(new ColorPickerView(getContext(),l,screenWidth,screenHeight,mInitialColor));
  }
 catch (  Exception e) {
    dismiss();
  }
}
 

Example 56

From project creamed_glacier_app_settings, under directory /src/com/android/settings/.

Source file: Display.java

  31 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.display);
  mFontSize=(Spinner)findViewById(R.id.fontSize);
  mFontSize.setOnItemSelectedListener(mFontSizeChanged);
  String[] states=new String[3];
  Resources r=getResources();
  states[0]=r.getString(R.string.small_font);
  states[1]=r.getString(R.string.medium_font);
  states[2]=r.getString(R.string.large_font);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,states);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mFontSize.setAdapter(adapter);
  mPreview=(TextView)findViewById(R.id.preview);
  mPreview.setText(r.getText(R.string.font_size_preview_text));
  Button save=(Button)findViewById(R.id.save);
  save.setText(r.getText(R.string.font_size_save));
  save.setOnClickListener(this);
  mTextSizeTyped=new TypedValue();
  TypedArray styledAttributes=obtainStyledAttributes(android.R.styleable.TextView);
  styledAttributes.getValue(android.R.styleable.TextView_textSize,mTextSizeTyped);
  DisplayMetrics metrics=getResources().getDisplayMetrics();
  mDisplayMetrics=new DisplayMetrics();
  mDisplayMetrics.density=metrics.density;
  mDisplayMetrics.heightPixels=metrics.heightPixels;
  mDisplayMetrics.scaledDensity=metrics.scaledDensity;
  mDisplayMetrics.widthPixels=metrics.widthPixels;
  mDisplayMetrics.xdpi=metrics.xdpi;
  mDisplayMetrics.ydpi=metrics.ydpi;
  styledAttributes.recycle();
}
 

Example 57

From project cw-omnibus, under directory /external/ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 58

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 59

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 60

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 61

From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 62

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 63

From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/.

Source file: DictionaryUtil.java

  31 
vote

public static void openTextInDictionary(Activity activity,String text,boolean singleWord,int selectionTop,int selectionBottom){
  if (singleWord) {
    int start=0;
    int end=text.length();
    for (; start < end && !Character.isLetterOrDigit(text.charAt(start)); ++start)     ;
    for (; start < end && !Character.isLetterOrDigit(text.charAt(end - 1)); --end)     ;
    if (start == end) {
      return;
    }
    text=text.substring(start,end);
  }
  final PackageInfo info=getCurrentDictionaryInfo(singleWord);
  final Intent intent=getDictionaryIntent(info,text);
  try {
    if ("ColorDict".equals(info.Id)) {
      final DisplayMetrics metrics=new DisplayMetrics();
      activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
      final int screenHeight=metrics.heightPixels;
      final int topSpace=selectionTop;
      final int bottomSpace=metrics.heightPixels - selectionBottom;
      final boolean showAtBottom=bottomSpace >= topSpace;
      final int space=(showAtBottom ? bottomSpace : topSpace) - 20;
      final int maxHeight=Math.min(400,screenHeight * 2 / 3);
      final int minHeight=Math.min(200,screenHeight * 2 / 3);
      intent.putExtra(ColorDict3.HEIGHT,Math.max(minHeight,Math.min(maxHeight,space)));
      intent.putExtra(ColorDict3.GRAVITY,showAtBottom ? Gravity.BOTTOM : Gravity.TOP);
      final ZLAndroidLibrary zlibrary=(ZLAndroidLibrary)ZLAndroidLibrary.Instance();
      intent.putExtra(ColorDict3.FULLSCREEN,!zlibrary.ShowStatusBarOption.getValue());
    }
    activity.startActivity(intent);
  }
 catch (  ActivityNotFoundException e) {
    DictionaryUtil.installDictionaryIfNotInstalled(activity,singleWord);
  }
}
 

Example 64

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/library/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 65

From project framework_base_policy, under directory /src/com/android/internal/policy/impl/.

Source file: IconUtilities.java

  31 
vote

public IconUtilities(Context context){
  final Resources resources=context.getResources();
  DisplayMetrics metrics=mDisplayMetrics=resources.getDisplayMetrics();
  final float density=metrics.density;
  final float blurPx=5 * density;
  mIconWidth=mIconHeight=(int)resources.getDimension(android.R.dimen.app_icon_size);
  mIconTextureWidth=mIconTextureHeight=mIconWidth + (int)(blurPx * 2);
  mBlurPaint.setMaskFilter(new BlurMaskFilter(blurPx,BlurMaskFilter.Blur.NORMAL));
  TypedValue value=new TypedValue();
  mGlowColorPressedPaint.setColor(context.getTheme().resolveAttribute(android.R.attr.colorPressedHighlight,value,true) ? value.data : 0xffffc300);
  mGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0,30));
  mGlowColorFocusedPaint.setColor(context.getTheme().resolveAttribute(android.R.attr.colorFocusedHighlight,value,true) ? value.data : 0xffff8e00);
  mGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0,30));
  ColorMatrix cm=new ColorMatrix();
  cm.setSaturation(0.2f);
  mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,Paint.FILTER_BITMAP_FLAG));
}
 

Example 66

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 67

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 68

From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 69

From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/keyboard/.

Source file: KeyboardSwitcher.java

  31 
vote

private KeyboardId getKeyboardId(EditorInfo editorInfo,final boolean isSymbols,final boolean isShift,Settings.Values settingsValues){
  final int mode=Utils.getKeyboardMode(editorInfo);
  final int xmlId;
switch (mode) {
case KeyboardId.MODE_PHONE:
    xmlId=(isSymbols && isShift) ? R.xml.kbd_phone_shift : R.xml.kbd_phone;
  break;
case KeyboardId.MODE_NUMBER:
xmlId=R.xml.kbd_number;
break;
default :
if (isSymbols) {
xmlId=isShift ? R.xml.kbd_symbols_shift : R.xml.kbd_symbols;
}
 else {
xmlId=R.xml.kbd_qwerty;
}
break;
}
final boolean settingsKeyEnabled=settingsValues.isSettingsKeyEnabled();
@SuppressWarnings("deprecation") final boolean noMicrophone=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_MICROPHONE,editorInfo) || Utils.inPrivateImeOptions(null,LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT,editorInfo);
final boolean voiceKeyEnabled=settingsValues.isVoiceKeyEnabled(editorInfo) && !noMicrophone;
final boolean voiceKeyOnMain=settingsValues.isVoiceKeyOnMain();
final boolean noSettingsKey=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_NO_SETTINGS_KEY,editorInfo);
final boolean hasSettingsKey=settingsKeyEnabled && !noSettingsKey;
final int f2KeyMode=getF2KeyMode(settingsKeyEnabled,noSettingsKey);
final boolean hasShortcutKey=voiceKeyEnabled && (isSymbols != voiceKeyOnMain);
final boolean forceAscii=Utils.inPrivateImeOptions(mPackageName,LatinIME.IME_OPTION_FORCE_ASCII,editorInfo);
final boolean asciiCapable=mSubtypeSwitcher.currentSubtypeContainsExtraValueKey(LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE);
final Locale locale=(forceAscii && !asciiCapable) ? Locale.US : mSubtypeSwitcher.getInputLocale();
final Configuration conf=mResources.getConfiguration();
final DisplayMetrics dm=mResources.getDisplayMetrics();
return new KeyboardId(mResources.getResourceEntryName(xmlId),xmlId,locale,conf.orientation,dm.widthPixels,mode,editorInfo,hasSettingsKey,f2KeyMode,noSettingsKey,voiceKeyEnabled,hasShortcutKey);
}
 

Example 70

From project iosched_3, under directory /libprojects/abs/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 71

From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 72

From project K6nele, under directory /app/src/ee/ioc/phon/android/speak/.

Source file: RecognizerIntentActivity.java

  31 
vote

private void setGuiTranscribing(byte[] bytes){
  mChronometer.setBase(mService.getStartTime());
  stopChronometer();
  mHandlerBytes.removeCallbacks(mRunnableBytes);
  mHandlerStop.removeCallbacks(mRunnableStop);
  mHandlerVolume.removeCallbacks(mRunnableVolume);
  mTvBytes.setText(Utils.getSizeAsString(bytes.length));
  setRecorderStyle(mRes.getColor(R.color.grey2));
  mBStartStop.setVisibility(View.GONE);
  mTvPrompt.setVisibility(View.GONE);
  mIvVolume.setVisibility(View.GONE);
  mLlProgress.setVisibility(View.VISIBLE);
  mLlTranscribing.setVisibility(View.VISIBLE);
  DisplayMetrics metrics=mRes.getDisplayMetrics();
  float dp=250f;
  int waveformWidth=(int)(metrics.density * dp + 0.5f);
  int waveformHeight=(int)(waveformWidth / 2.5);
  mIvWaveform.setVisibility(View.VISIBLE);
  mIvWaveform.setImageBitmap(Utils.drawWaveform(bytes,waveformWidth,waveformHeight,0,bytes.length));
}
 

Example 73

From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/org/kevoree/library/android/osmdroid/.

Source file: MapComponent.java

  31 
vote

@Start public void start(){
  uiService=UIServiceHandler.getUIService();
  layout=new LinearLayout(uiService.getRootActivity());
  lowMemory.setLowMemory();
  uiService.addToGroup("Map",layout);
  uiService.getRootActivity().runOnUiThread(new Runnable(){
    @Override public void run(){
      mMapView=new MapView(uiService.getRootActivity(),sizeTitle);
      mMapView.setBuiltInZoomControls(true);
      mMapController=mMapView.getController();
      mMapController.setZoom(16);
      GeoPoint gPt=new GeoPoint(48085419,-1658936);
      mMapController.setCenter(gPt);
      mMapView.setTileSource(TileSourceFactory.MAPNIK);
      mMapView.setActivated(true);
      track=new TrackMap(uiService.getRootActivity(),mMapView);
      DisplayMetrics dm=new DisplayMetrics();
      uiService.getRootActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
      mMapView.setMinimumHeight(dm.heightPixels);
      mMapView.setMinimumWidth(dm.widthPixels);
      layout.addView(mMapView);
    }
  }
);
}
 

Example 74

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

Source file: TerminalView.java

  31 
vote

public TerminalView(TerminalActivity context,AttributeSet attrs){
  super(context,attrs);
  this.terminalActivity=context;
  setFocusable(true);
  setFocusableInTouchMode(true);
  DisplayMetrics metrics=new DisplayMetrics();
  context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  xdpi=metrics.xdpi;
  ydpi=metrics.ydpi;
  resetColors();
  buffer=new vt320(){
    public void beep(){
      Log.i(TAG,"beep");
    }
    public void write(    byte[] b){
      try {
        connection.write(b);
      }
 catch (      Exception e) {
        terminalActivity.disconnect(e);
      }
    }
  }
;
  buffer.setBufferSize(SCROLLBACK);
  buffer.setDisplay(this);
  buffer.setScreenSize(TERM_WIDTH,TERM_HEIGHT,true);
  defaultPaint.setFlags(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
  defaultPaint.setTypeface(Typeface.MONOSPACE);
  specialTypeface=Typeface.createFromAsset(this.getResources().getAssets(),"SpecialChar.ttf");
  urls=(ArrayList<Url>[])Array.newInstance(ArrayList.class,TERM_HEIGHT);
}
 

Example 75

From project madvertise-android-sdk, under directory /madvertiseSDK/src/de/madvertise/android/sdk/.

Source file: MadvertiseView.java

  31 
vote

/** 
 * Constructor
 * @param context
 * @param attrs
 */
public MadvertiseView(final Context context,final AttributeSet attrs){
  super(context,attrs);
  MadvertiseUtil.logMessage(null,Log.DEBUG,"** Constructor for mad view called **");
  if (reportLauch) {
    MadvertiseTracker.getInstance(context).reportLaunch();
    reportLauch=false;
  }
  setVisibility(GONE);
  if (!MadvertiseUtil.checkPermissionGranted(android.Manifest.permission.INTERNET,context)) {
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** ----------------------------- *** ");
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** Missing internet permissions! *** ");
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** ----------------------------- *** ");
    throw new IllegalArgumentException("Missing internet permission!");
  }
  if (!MadvertiseUtil.checkForBrowserDeclaration(getContext())) {
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** ----------------------------- *** ");
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** You must declare the activity de.madvertise.android.sdk.MadvertiseActivity in your manifest! *** ");
    MadvertiseUtil.logMessage(null,Log.DEBUG," *** ----------------------------- *** ");
    throw new IllegalArgumentException("Missing Activity declaration!");
  }
  initParameters(attrs);
  final DisplayMetrics displayMetrics=context.getApplicationContext().getResources().getDisplayMetrics();
  MadvertiseUtil.logMessage(null,Log.DEBUG,"Display values: Width = " + displayMetrics.widthPixels + " ; Height = "+ displayMetrics.heightPixels);
  mInitialBackground=this.getBackground();
  Rect r=new Rect(0,0,displayMetrics.widthPixels,displayMetrics.heightPixels);
  if (sTextBannerBackground == null) {
    sTextBannerBackground=generateBackgroundDrawable(r,mBackgroundColor,0xffffff);
  }
  setClickable(true);
  setFocusable(true);
  setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
  if (mRequestThread == null || !mRequestThread.isAlive()) {
    requestNewAd(false);
  }
  if (mBannerType.contains(MadvertiseUtil.BANNER_TYPE_RICH_MEDIA) || mBannerType.contains(MadvertiseUtil.BANNER_TYPE_RICH_MEDIA_SHORT)) {
    this.setFetchingAdsEnabled(false);
    MadvertiseUtil.logMessage(null,Log.DEBUG,"No ad reloading, since banner_type=[rich_media|rm] was requested");
  }
}
 

Example 76

From project MensaUPB, under directory /libs/ActionbarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 77

From project mWater-Android-App, under directory /android/actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 78

From project MyHeath-Android, under directory /actionbarlib/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 79

From project onebusaway-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 80

From project open311-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ResourcesCompat.java

  31 
vote

/** 
 * Support implementation of  {@code getResources().getBoolean()} that wecan use to simulate filtering based on width and smallest width qualifiers on pre-3.2.
 * @param context Context to load booleans from on 3.2+ and to fetch thedisplay metrics.
 * @param id Id of boolean to load.
 * @return Associated boolean value as reflected by the current displaymetrics.
 */
public static boolean getResources_getBoolean(Context context,int id){
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
    return context.getResources().getBoolean(id);
  }
  DisplayMetrics metrics=context.getResources().getDisplayMetrics();
  float widthDp=metrics.widthPixels / metrics.density;
  float heightDp=metrics.heightPixels / metrics.density;
  float smallestWidthDp=(widthDp < heightDp) ? widthDp : heightDp;
  if (id == R.bool.abs__action_bar_embed_tabs) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  if (id == R.bool.abs__split_action_bar_is_narrow) {
    if (widthDp >= 480) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__action_bar_expanded_action_views_exclusive) {
    if (smallestWidthDp >= 600) {
      return false;
    }
    return true;
  }
  if (id == R.bool.abs__config_allowActionMenuItemTextWithIcon) {
    if (widthDp >= 480) {
      return true;
    }
    return false;
  }
  throw new IllegalArgumentException("Unknown boolean resource ID " + id);
}
 

Example 81

From project packages_apps_ROMControl, under directory /src/com/koushikdutta/urlimageviewhelper/.

Source file: UrlImageViewHelper.java

  31 
vote

private static void prepareResources(Context context){
  if (mMetrics != null)   return;
  mMetrics=new DisplayMetrics();
  Activity act=(Activity)context;
  act.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
  AssetManager mgr=context.getAssets();
  mResources=new Resources(mgr,mMetrics,context.getResources().getConfiguration());
}
 

Example 82

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

Source file: IconUtilities.java

  31 
vote

public IconUtilities(Context context){
  final Resources resources=context.getResources();
  DisplayMetrics metrics=mDisplayMetrics=resources.getDisplayMetrics();
  final float density=metrics.density;
  final float blurPx=5 * density;
  mIconWidth=mIconHeight=(int)resources.getDimension(android.R.dimen.app_icon_size);
  mIconTextureWidth=mIconTextureHeight=mIconWidth + (int)(blurPx * 2);
  mBlurPaint.setMaskFilter(new BlurMaskFilter(blurPx,BlurMaskFilter.Blur.NORMAL));
  mGlowColorPressedPaint.setColor(0xffffc300);
  mGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0,30));
  mGlowColorFocusedPaint.setColor(0xffff8e00);
  mGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0,30));
  ColorMatrix cm=new ColorMatrix();
  cm.setSaturation(0.2f);
  mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,Paint.FILTER_BITMAP_FLAG));
}
 

Example 83

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: BrowserSettings.java

  31 
vote

@Override public void run(){
  DisplayMetrics metrics=mContext.getResources().getDisplayMetrics();
  mFontSizeMult=metrics.scaledDensity / metrics.density;
  if (ActivityManager.staticGetMemoryClass() > 16) {
    mPageCacheCapacity=5;
  }
  mWebStorageSizeManager=new WebStorageSizeManager(mContext,new WebStorageSizeManager.StatFsDiskInfo(getAppCachePath()),new WebStorageSizeManager.WebKitAppCacheInfo(getAppCachePath()));
  mPrefs.registerOnSharedPreferenceChangeListener(BrowserSettings.this);
  if (Build.VERSION.CODENAME.equals("REL")) {
    setDebugEnabled(false);
  }
  if (mPrefs.contains(PREF_TEXT_SIZE)) {
switch (getTextSize()) {
case SMALLEST:
      setTextZoom(50);
    break;
case SMALLER:
  setTextZoom(75);
break;
case LARGER:
setTextZoom(150);
break;
case LARGEST:
setTextZoom(200);
break;
}
mPrefs.edit().remove(PREF_TEXT_SIZE).apply();
}
sFactoryResetUrl=mContext.getResources().getString(R.string.homepage_base);
if (sFactoryResetUrl.indexOf("{CID}") != -1) {
sFactoryResetUrl=sFactoryResetUrl.replace("{CID}",BrowserProvider.getClientId(mContext.getContentResolver()));
}
synchronized (BrowserSettings.class) {
sInitialized=true;
BrowserSettings.class.notifyAll();
}
}
 

Example 84

From project platform_packages_apps_settings, under directory /src/com/android/settings/.

Source file: Display.java

  31 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.display);
  mFontSize=(Spinner)findViewById(R.id.fontSize);
  mFontSize.setOnItemSelectedListener(mFontSizeChanged);
  String[] states=new String[3];
  Resources r=getResources();
  states[0]=r.getString(R.string.small_font);
  states[1]=r.getString(R.string.medium_font);
  states[2]=r.getString(R.string.large_font);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,states);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  mFontSize.setAdapter(adapter);
  mPreview=(TextView)findViewById(R.id.preview);
  mPreview.setText(r.getText(R.string.font_size_preview_text));
  Button save=(Button)findViewById(R.id.save);
  save.setText(r.getText(R.string.font_size_save));
  save.setOnClickListener(this);
  mTextSizeTyped=new TypedValue();
  TypedArray styledAttributes=obtainStyledAttributes(android.R.styleable.TextView);
  styledAttributes.getValue(android.R.styleable.TextView_textSize,mTextSizeTyped);
  DisplayMetrics metrics=getResources().getDisplayMetrics();
  mDisplayMetrics=new DisplayMetrics();
  mDisplayMetrics.density=metrics.density;
  mDisplayMetrics.heightPixels=metrics.heightPixels;
  mDisplayMetrics.scaledDensity=metrics.scaledDensity;
  mDisplayMetrics.widthPixels=metrics.widthPixels;
  mDisplayMetrics.xdpi=metrics.xdpi;
  mDisplayMetrics.ydpi=metrics.ydpi;
  styledAttributes.recycle();
}
 

Example 85

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

Source file: MediaItemView.java

  31 
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 86

From project platform_packages_wallpapers_Basic, under directory /src/com/android/wallpaper/walkaround/.

Source file: WalkAroundWallpaper.java

  31 
vote

private void startPreview(){
  final Resources resources=getResources();
  final boolean portrait=resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
  final Camera.Parameters params=mCamera.getParameters();
  final DisplayMetrics metrics=resources.getDisplayMetrics();
  final List<Camera.Size> sizes=params.getSupportedPreviewSizes();
  boolean found=false;
  for (  Camera.Size size : sizes) {
    if ((portrait && size.width == metrics.heightPixels && size.height == metrics.widthPixels) || (!portrait && size.width == metrics.widthPixels && size.height == metrics.heightPixels)) {
      params.setPreviewSize(size.width,size.height);
      found=true;
    }
  }
  if (!found) {
    for (    Camera.Size size : sizes) {
      if (size.width >= metrics.widthPixels && size.height >= metrics.heightPixels) {
        params.setPreviewSize(size.width,size.height);
        found=true;
      }
    }
  }
  if (!found) {
    Canvas canvas=null;
    try {
      canvas=mHolder.lockCanvas();
      if (canvas != null)       canvas.drawColor(0);
    }
  finally {
      if (canvas != null)       mHolder.unlockCanvasAndPost(canvas);
    }
    Camera.Size size=sizes.get(0);
    params.setPreviewSize(size.width,size.height);
  }
  params.set("orientation",portrait ? "portrait" : "landscape");
  mCamera.setParameters(params);
  mCamera.startPreview();
}
 

Example 87

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

Source file: UserIndexActivity.java

  31 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  DebugUtil.setupErrorHandler(this);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.user_index_tabs_pager_layout);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  metrics=new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(metrics);
  user=getIntent().getExtras().getParcelable(VIEW_PROFILE);
  setTitle(user.getLogin());
  Intent intent=new Intent(this,RCService.class);
  bindService(intent,mConnection,Context.BIND_AUTO_CREATE);
}
 

Example 88

From project Sage-Mobile-Calc, under directory /src/org/connectbot/util/.

Source file: UberColorPickerDialog.java

  31 
vote

/** 
 * Activity entry point
 */
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  OnColorChangedListener l=new OnColorChangedListener(){
    public void colorChanged(    int color){
      mListener.colorChanged(color);
      dismiss();
    }
  }
;
  DisplayMetrics dm=new DisplayMetrics();
  getWindow().getWindowManager().getDefaultDisplay().getMetrics(dm);
  int screenWidth=dm.widthPixels;
  int screenHeight=dm.heightPixels;
  setTitle("Pick a color (try the trackball)");
  try {
    setContentView(new ColorPickerView(getContext(),l,screenWidth,screenHeight,mInitialColor));
  }
 catch (  Exception e) {
    dismiss();
  }
}
 

Example 89

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

Source file: WindowManagerService.java

  29 
vote

private int reduceCompatConfigWidthSize(int curSize,int rotation,DisplayMetrics dm,int dw,int dh){
  dm.noncompatWidthPixels=mPolicy.getNonDecorDisplayWidth(dw,dh,rotation);
  dm.noncompatHeightPixels=mPolicy.getNonDecorDisplayHeight(dw,dh,rotation);
  float scale=CompatibilityInfo.computeCompatibleScaling(dm,null);
  int size=(int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
  if (curSize == 0 || size < curSize) {
    curSize=size;
  }
  return curSize;
}
 

Example 90

From project GreenDroidQABar, under directory /src/greendroid/image/.

Source file: ImageLoader.java

  29 
vote

public ImageLoader(Context context){
  if (sImageCache == null) {
    sImageCache=GDUtils.getImageCache(context);
  }
  if (sExecutor == null) {
    sExecutor=GDUtils.getExecutor(context);
  }
  if (sDefaultOptions == null) {
    sDefaultOptions=new BitmapFactory.Options();
    sDefaultOptions.inDither=true;
    sDefaultOptions.inScaled=true;
    sDefaultOptions.inDensity=DisplayMetrics.DENSITY_MEDIUM;
    sDefaultOptions.inTargetDensity=context.getResources().getDisplayMetrics().densityDpi;
  }
}
 

Example 91

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/.

Source file: ActivityPicker.java

  29 
vote

public IconResizer(int width,int height,DisplayMetrics metrics){
  mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,Paint.FILTER_BITMAP_FLAG));
  mMetrics=metrics;
  mIconWidth=width;
  mIconHeight=height;
}
 

Example 92

From project packages_apps_God_Mode, under directory /src/com/t3hh4xx0r/addons/utils/.

Source file: DeviceType.java

  29 
vote

/** 
 * @param density the density as a specified int from DisplayMetrics
 * @return true if the density was set, else return false
 */
@SuppressWarnings("unused") public static boolean determineDeviceDensity(int density){
switch (density) {
case DisplayMetrics.DENSITY_XHIGH:
    if (DBG)     Log.i(TAG,"Device density is xhdpi");
  setDensity("xhdpi");
return true;
case DisplayMetrics.DENSITY_HIGH:
if (DBG) Log.i(TAG,"Device density is hdpi");
setDensity("hdpi");
return true;
case DisplayMetrics.DENSITY_MEDIUM:
if (DBG) Log.i(TAG,"Device density is mdpi");
setDensity("mdpi");
return true;
case DisplayMetrics.DENSITY_LOW:
if (DBG) Log.i(TAG,"Device density is ldpi");
setDensity("ldpi");
return true;
}
return false;
}
 

Example 93

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

Source file: DragLayer.java

  29 
vote

/** 
 * Used to create a new DragLayer from XML.
 * @param context The application's context.
 * @param attrs The attribtues set containing the Workspace's customization values.
 */
public DragLayer(Context context,AttributeSet attrs){
  super(context,attrs);
  final int srcColor=context.getResources().getColor(R.color.delete_color_filter);
  mTrashPaint.setColorFilter(new PorterDuffColorFilter(srcColor,PorterDuff.Mode.SRC_ATOP));
  int snagColor=context.getResources().getColor(R.color.snag_callout_color);
  Paint estimatedPaint=new Paint();
  estimatedPaint.setColor(snagColor);
  estimatedPaint.setStrokeWidth(3);
  estimatedPaint.setAntiAlias(true);
  mRectPaint=new Paint();
  mRectPaint.setColor(COLOR_NORMAL);
  activityManager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  if (AlmostNexusSettingsHelper.getDebugShowMemUsage(context))   pids=new int[]{android.os.Process.myPid()};
 else   pids=new int[]{};
  debugTextSize=DisplayMetrics.DENSITY_DEFAULT / 10;
}