Java Code Examples for android.util.TypedValue

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 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 2

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 3

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 4

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/.

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 5

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 6

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

Source file: ActionBarDrawable.java

  18 
vote

private static int getColorFromTheme(Context context,int attr,int defaultColor){
synchronized (sTypedValue) {
    final TypedValue value=sTypedValue;
    final Theme theme=context.getTheme();
    if (theme != null) {
      theme.resolveAttribute(attr,value,true);
      if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) {
        return value.data;
      }
    }
    return defaultColor;
  }
}
 

Example 7

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

Source file: KeyboardBuilder.java

  18 
vote

private static boolean matchTypedValue(TypedArray a,int index,int intValue,String strValue){
  final TypedValue v=a.peekValue(index);
  if (v == null)   return true;
  if (isIntegerValue(v)) {
    return intValue == a.getInt(index,0);
  }
 else   if (isStringValue(v)) {
    return stringArrayContains(a.getString(index).split("\\|"),strValue);
  }
  return false;
}
 

Example 8

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 9

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

Source file: BluetoothDevicePreference.java

  18 
vote

public BluetoothDevicePreference(Context context,CachedBluetoothDevice cachedDevice){
  super(context);
  if (sDimAlpha == Integer.MIN_VALUE) {
    TypedValue outValue=new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha,outValue,true);
    sDimAlpha=(int)(outValue.getFloat() * 255);
  }
  mCachedDevice=cachedDevice;
  setLayoutResource(R.layout.preference_bluetooth);
  cachedDevice.registerCallback(this);
  onDeviceAttributesChanged(cachedDevice);
}
 

Example 10

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

Source file: ScrollBarView.java

  18 
vote

public ScrollBarView(Context context,int gripHeight,int gripWidth){
  TypedValue outValue=new TypedValue();
  context.getTheme().resolveAttribute(android.R.attr.scrollbarThumbHorizontal,outValue,true);
  mScrollBarTexture=new NinePatchTexture(context,outValue.resourceId);
  mGripPosition=0;
  mGripWidth=0;
  mGivenGripWidth=gripWidth;
  mGripHeight=gripHeight;
}
 

Example 11

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

Source file: KeyboardBuilder.java

  18 
vote

private static boolean matchTypedValue(TypedArray a,int index,int intValue,String strValue){
  final TypedValue v=a.peekValue(index);
  if (v == null)   return true;
  if (isIntegerValue(v)) {
    return intValue == a.getInt(index,0);
  }
 else   if (isStringValue(v)) {
    return stringArrayContains(a.getString(index).split("\\|"),strValue);
  }
  return false;
}
 

Example 12

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/keyboards/.

Source file: Keyboard.java

  18 
vote

static int getDimensionOrFraction(TypedArray a,int index,int base,int defValue){
  TypedValue value=a.peekValue(index);
  if (value == null)   return defValue;
  if (value.type == TypedValue.TYPE_DIMENSION) {
    return a.getDimensionPixelOffset(index,defValue);
  }
 else   if (value.type == TypedValue.TYPE_FRACTION) {
    return Math.round(a.getFraction(index,base,base,defValue));
  }
  return defValue;
}
 

Example 13

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

Source file: ActionBarDrawable.java

  18 
vote

private static int getColorFromTheme(Context context,int attr,int defaultColor){
synchronized (sTypedValue) {
    final TypedValue value=sTypedValue;
    final Theme theme=context.getTheme();
    if (theme != null) {
      theme.resolveAttribute(attr,value,true);
      if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) {
        return value.data;
      }
    }
    return defaultColor;
  }
}
 

Example 14

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 15

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

Source file: BluetoothDevicePreference.java

  18 
vote

public BluetoothDevicePreference(Context context,CachedBluetoothDevice cachedDevice){
  super(context);
  if (sDimAlpha == Integer.MIN_VALUE) {
    TypedValue outValue=new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha,outValue,true);
    sDimAlpha=(int)(outValue.getFloat() * 255);
  }
  mCachedDevice=cachedDevice;
  if (cachedDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
    setWidgetLayoutResource(R.layout.preference_bluetooth);
  }
  mCachedDevice.registerCallback(this);
  onDeviceAttributesChanged();
}
 

Example 16

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 17

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 18

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 19

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 20

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 21

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 22

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 23

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 24

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 25

From project GreenDroid, under directory /GreenDroid/src/greendroid/graphics/drawable/.

Source file: ActionBarDrawable.java

  18 
vote

private static int getColorFromTheme(Context context,int attr,int defaultColor){
synchronized (sTypedValue) {
    final TypedValue value=sTypedValue;
    final Theme theme=context.getTheme();
    if (theme != null) {
      theme.resolveAttribute(attr,value,true);
      if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) {
        return value.data;
      }
    }
    return defaultColor;
  }
}
 

Example 26

From project GreenDroidQABar, under directory /src/greendroid/graphics/drawable/.

Source file: ActionBarDrawable.java

  18 
vote

private static int getColorFromTheme(Context context,int attr,int defaultColor){
synchronized (sTypedValue) {
    final TypedValue value=sTypedValue;
    final Theme theme=context.getTheme();
    if (theme != null) {
      theme.resolveAttribute(attr,value,true);
      if (value.type >= TypedValue.TYPE_FIRST_INT && value.type <= TypedValue.TYPE_LAST_INT) {
        return value.data;
      }
    }
    return defaultColor;
  }
}
 

Example 27

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/util/.

Source file: UnitsI18n.java

  18 
vote

/** 
 * Based on a given Locale prefetch the units conversions and names.
 * @param resources Resources initialized with a Locale
 */
private void init(Resources resources){
  TypedValue outValue=new TypedValue();
  needsUnitFlip=false;
  resources.getValue(R.raw.conversion_from_mps,outValue,false);
  mConversion_from_mps_to_speed=outValue.getFloat();
  resources.getValue(R.raw.conversion_from_meter,outValue,false);
  mConversion_from_meter_to_distance=outValue.getFloat();
  resources.getValue(R.raw.conversion_from_meter_to_height,outValue,false);
  mConversion_from_meter_to_height=outValue.getFloat();
  mSpeed_unit=resources.getString(R.string.speed_unitname);
  mDistance_unit=resources.getString(R.string.distance_unitname);
  mHeight_unit=resources.getString(R.string.distance_smallunitname);
}
 

Example 28

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

Source file: ActionBarSherlockNative.java

  18 
vote

@Override protected Context getThemedContext(){
  Context context=mActivity;
  TypedValue outValue=new TypedValue();
  mActivity.getTheme().resolveAttribute(android.R.attr.actionBarWidgetTheme,outValue,true);
  if (outValue.resourceId != 0) {
    context=new ContextThemeWrapper(context,outValue.resourceId);
  }
  return context;
}
 

Example 29

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

Source file: CustomIconContextMenu.java

  17 
vote

public View getView(int position,View convertView,ViewGroup parent){
  CustomContextMenuItem item=(CustomContextMenuItem)getItem(position);
  Resources resource=activity.getResources();
  if (convertView == null) {
    TextView tempTextView=new TextView(context);
    AbsListView.LayoutParams param=new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT,AbsListView.LayoutParams.WRAP_CONTENT);
    tempTextView.setLayoutParams(param);
    tempTextView.setPadding((int)toPixel(resource,15),0,(int)toPixel(resource,15),0);
    tempTextView.setGravity(android.view.Gravity.CENTER_VERTICAL);
    Theme theme=context.getTheme();
    TypedValue typedValue=new TypedValue();
    if (theme.resolveAttribute(android.R.attr.textAppearanceLargeInverse,typedValue,true)) {
      tempTextView.setTextAppearance(context,typedValue.resourceId);
    }
    tempTextView.setMinHeight(LIST_HEIGHT);
    tempTextView.setCompoundDrawablePadding((int)toPixel(resource,14));
    convertView=tempTextView;
  }
  TextView textView=(TextView)convertView;
  textView.setTextColor(Color.BLACK);
  textView.setTag(item);
  textView.setText(item.text);
  textView.setCompoundDrawablesWithIntrinsicBounds(item.icon,null,null,null);
  textView.setBackgroundResource(R.color.contextmenu_item_background);
  return textView;
}
 

Example 30

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

Source file: DimAnimator.java

  17 
vote

/** 
 * Set's the dim surface's layer and update dim parameters that will be used in {@link updateSurface} after all windows are examined.
 */
void updateParameters(Resources res,WindowState w,long currentTime){
  mDimSurface.setLayer(w.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM);
  final float target=w.mExiting ? 0 : w.mAttrs.dimAmount;
  if (WindowManagerService.SHOW_TRANSACTIONS)   Slog.i(WindowManagerService.TAG,"  DIM " + mDimSurface + ": layer="+ (w.mAnimLayer - 1)+ " target="+ target);
  if (mDimTargetAlpha != target) {
    mLastDimAnimTime=currentTime;
    long duration=(w.mAnimating && w.mAnimation != null) ? w.mAnimation.computeDurationHint() : WindowManagerService.DEFAULT_DIM_DURATION;
    if (target > mDimTargetAlpha) {
      TypedValue tv=new TypedValue();
      res.getValue(com.android.internal.R.fraction.config_dimBehindFadeDuration,tv,true);
      if (tv.type == TypedValue.TYPE_FRACTION) {
        duration=(long)tv.getFraction((float)duration,(float)duration);
      }
 else       if (tv.type >= TypedValue.TYPE_FIRST_INT && tv.type <= TypedValue.TYPE_LAST_INT) {
        duration=tv.data;
      }
    }
    if (duration < 1) {
      duration=1;
    }
    mDimTargetAlpha=target;
    mDimDeltaPerMs=(mDimTargetAlpha - mDimCurrentAlpha) / duration;
  }
}
 

Example 31

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

Source file: ActionBarSherlock.java

  17 
vote

/** 
 * Indicate that the menu should be recreated by calling {@link OnCreateOptionsMenuListener#onCreateOptionsMenu(com.actionbarsherlock.view.Menu)}.
 */
public void dispatchInvalidateOptionsMenu(){
  if (DEBUG)   Log.d(TAG,"[dispatchInvalidateOptionsMenu]");
  if (mMenu == null) {
    Context context=mActivity;
    if (mActionBar != null) {
      TypedValue outValue=new TypedValue();
      mActivity.getTheme().resolveAttribute(R.attr.actionBarWidgetTheme,outValue,true);
      if (outValue.resourceId != 0) {
        context=new ContextThemeWrapper(context,outValue.resourceId);
      }
    }
    mMenu=new MenuBuilder(context);
    mMenu.setCallback(mMenuBuilderCallback);
  }
  mMenu.stopDispatchingItemsChanged();
  mMenu.clear();
  if (!dispatchCreateOptionsMenu()) {
    if (mActionBar != null) {
      mActionBar.setMenu(null,mMenuPresenterCallback);
    }
    return;
  }
  if (!dispatchPrepareOptionsMenu()) {
    if (mActionBar != null) {
      mActionBar.setMenu(null,mMenuPresenterCallback);
    }
    mMenu.startDispatchingItemsChanged();
    return;
  }
  KeyCharacterMap kmap=KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
  mMenu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC);
  mMenu.startDispatchingItemsChanged();
  mActionBar.setMenu(mMenu,mMenuPresenterCallback);
}
 

Example 32

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

Source file: IconUtilities.java

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

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/helper/.

Source file: GaugeHelper.java

  15 
vote

private float findMinimumVisibleSize(TextView textView,String message){
  textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,15);
  long viewWidth=textView.getWidth();
  if (viewWidth < 1) {
    textView.measure(0,0);
    viewWidth=textView.getMeasuredWidth();
    if (viewWidth < 1)     return textView.getTextSize();
  }
  TextPaint textPaint=textView.getPaint();
  float textSize=textView.getTextSize();
  float paintWidth=textPaint.measureText(message) + 2 * MARGIN;
  while (paintWidth > viewWidth) {
    textSize--;
    textPaint.setTextSize(textSize);
    paintWidth=textPaint.measureText(message) + 2 * MARGIN;
  }
  return textSize;
}
 

Example 34

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

Source file: MyNoteEditTextView.java

  15 
vote

@Override public void applyPreferenceSettings(){
  changeBackgroundColour();
  SharedPreferences preferences=CommonUtils.getSharedPreferences();
  int fontSize=preferences.getInt("text_size_pref",16);
  setTextSize(TypedValue.COMPLEX_UNIT_DIP,fontSize);
}
 

Example 35

From project android-flash-cards, under directory /src/org/thomasamsler/android/flashcards/fragment/.

Source file: CardFragment.java

  15 
vote

public void setFontSize(int size){
  mFontSize=size;
  if (null != mTextViewQuestion && null != mTextViewAnswer) {
    mTextViewQuestion.setTextSize(TypedValue.COMPLEX_UNIT_SP,mFontSize);
    mTextViewAnswer.setTextSize(TypedValue.COMPLEX_UNIT_SP,mFontSize);
  }
}
 

Example 36

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

Source file: PreviewActivity.java

  15 
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 37

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

Source file: CaptureActivity.java

  15 
vote

/** 
 * Displays information relating to the results of a successful real-time OCR request.
 * @param ocrResult Object representing successful OCR results
 */
void handleOcrContinuousDecode(OcrResult ocrResult){
  lastResult=ocrResult;
  viewfinderView.addResultText(new OcrResultText(ocrResult.getText(),ocrResult.getWordConfidences(),ocrResult.getMeanConfidence(),ocrResult.getBitmapDimensions(),ocrResult.getRegionBoundingBoxes(),ocrResult.getTextlineBoundingBoxes(),ocrResult.getStripBoundingBoxes(),ocrResult.getWordBoundingBoxes(),ocrResult.getCharacterBoundingBoxes()));
  Integer meanConfidence=ocrResult.getMeanConfidence();
  if (CONTINUOUS_DISPLAY_RECOGNIZED_TEXT) {
    statusViewTop.setText(ocrResult.getText());
    int scaledSize=Math.max(22,32 - ocrResult.getText().length() / 4);
    statusViewTop.setTextSize(TypedValue.COMPLEX_UNIT_SP,scaledSize);
    statusViewTop.setTextColor(Color.BLACK);
    statusViewTop.setBackgroundResource(R.color.status_top_text_background);
    statusViewTop.getBackground().setAlpha(meanConfidence * (255 / 100));
  }
  if (CONTINUOUS_DISPLAY_METADATA) {
    long recognitionTimeRequired=ocrResult.getRecognitionTimeRequired();
    statusViewBottom.setTextSize(14);
    statusViewBottom.setText("OCR: " + sourceLanguageReadable + " - Mean confidence: "+ meanConfidence.toString()+ " - Time required: "+ recognitionTimeRequired+ " ms");
  }
}
 

Example 38

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: SharedVipActivity.java

  15 
vote

private void displayRadioButtons(){
  for (  VirtualIp vip : vips) {
    RadioButton button=new RadioButton(getContext());
    button.setTextSize(TypedValue.COMPLEX_UNIT_DIP,14);
    button.setText(vip.getAddress() + "\n" + "Type: "+ vip.getType()+ "\n"+ "Load Balancer: "+ vip.getLoadBalancer().getName()+ "\n");
    if ((vip.getLoadBalancer().getPort().equals(loadBalancerPort) || !vip.getLoadBalancer().getRegion().equals(loadBalancerRegion))) {
      button.setEnabled(false);
    }
    vipGroup.addView(button);
    if (selectedVip != null && selectedVip.getId().equals(vip.getId())) {
      ((RadioButton)vipGroup.getChildAt(vipGroup.getChildCount() - 1)).toggle();
    }
  }
  vipGroup.setOnCheckedChangeListener(new OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    RadioGroup group,    int checkedId){
      View radioButton=group.findViewById(checkedId);
      int index=group.indexOfChild(radioButton);
      if (vips[index].getLoadBalancer().getPort().equals(loadBalancerPort)) {
        showToast("Cannot use this Virtual IP. The same port cannot be used on multiple load balancers for a Shared Virtual IP.");
      }
 else       if (!vips[index].getLoadBalancer().getRegion().equals(loadBalancerRegion)) {
        showToast("Cannot use this Virtual IP. The Shared Virtual IP must come the same region as the new load balancer.");
      }
 else {
        Log.d("info","the selected vip is " + vips[index].getAddress());
        selectedVip=vips[index];
      }
    }
  }
);
}
 

Example 39

From project AndroidLab, under directory /samples/AndroidLdapClient/src/com/unboundid/android/ldap/client/.

Source file: ViewEntry.java

  15 
vote

/** 
 * Generates the display for a generic entry.
 */
private void displayGeneric(){
  logEnter(LOG_TAG,"displayGeneric");
  setTitle("Entry " + entry.getDN());
  final LinearLayout layout=(LinearLayout)findViewById(R.id.layout_view_entry_panel);
  final HeaderClickListener hdrListener=new HeaderClickListener(this,entry);
  final LinearLayout l=new LinearLayout(this);
  l.setPadding(0,5,0,20);
  l.setOrientation(LinearLayout.VERTICAL);
  final TextView dnNameView=new TextView(this);
  dnNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP,12.0f);
  dnNameView.setText(getDisplayName(this,"DN"));
  dnNameView.setGravity(Gravity.LEFT);
  dnNameView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.FILL_PARENT));
  l.addView(dnNameView);
  final TextView dnValueView=new TextView(this);
  dnValueView.setTextSize(TypedValue.COMPLEX_UNIT_SP,16.0f);
  dnValueView.setText(entry.getDN());
  dnValueView.setGravity(Gravity.RIGHT);
  dnValueView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.FILL_PARENT));
  l.addView(dnValueView);
  l.setOnClickListener(hdrListener);
  layout.addView(l);
  for (  final Attribute a : entry.getAttributes()) {
    if (a.hasValue()) {
      addGenericAttribute(a,layout);
    }
  }
}
 

Example 40

From project Android_1, under directory /Fragments/simple/src/novoda/demo/fragments/list/frags/.

Source file: Detail.java

  15 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  if (container == null) {
    return null;
  }
  ScrollView scroller=new ScrollView(getActivity());
  TextView text=new TextView(getActivity());
  int padding=(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,4,getActivity().getResources().getDisplayMetrics());
  text.setPadding(padding,padding,padding,padding);
  scroller.addView(text);
  text.setText(Constants.DETAILS[getArguments().getInt("index",0)]);
  return scroller;
}
 

Example 41

From project apps-for-android, under directory /DivideAndConquer/src/com/google/android/divideandconquer/.

Source file: DivideAndConquerView.java

  15 
vote

/** 
 * Pain the text instructing the user how to unpause the game.
 */
private void drawPausedText(Canvas canvas){
  mPaint.setColor(Color.BLACK);
  mPaint.setAntiAlias(true);
  mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,20,getResources().getDisplayMetrics()));
  final String unpauseInstructions=getContext().getString(R.string.unpause_instructions);
  canvas.drawText(unpauseInstructions,getWidth() / 5,getHeight() / 2,mPaint);
  mPaint.setAntiAlias(false);
}
 

Example 42

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: BooksMultitypeListHandler.java

  15 
vote

private void scaleViewText(BooklistRowView rowView,View root){
  final float scale=0.8f;
  if (root instanceof TextView) {
    TextView txt=(TextView)root;
    float px=txt.getTextSize();
    txt.setTextSize(TypedValue.COMPLEX_UNIT_PX,px * scale);
  }
  root.setPadding((int)(scale * root.getPaddingLeft()),(int)(scale * root.getPaddingTop()),(int)(scale * root.getPaddingRight()),(int)(scale * root.getPaddingBottom()));
  root.getPaddingBottom();
  if (root instanceof ViewGroup) {
    ViewGroup grp=(ViewGroup)root;
    for (int i=0; i < grp.getChildCount(); i++) {
      View v=grp.getChildAt(i);
      scaleViewText(rowView,v);
    }
  }
}
 

Example 43

From project brut.apktool, under directory /apktool-lib/src/main/java/brut/androlib/res/data/value/.

Source file: ResValueFactory.java

  15 
vote

public ResScalarValue factory(int type,int value,String rawValue) throws AndrolibException {
switch (type) {
case TypedValue.TYPE_REFERENCE:
    return newReference(value,rawValue);
case TypedValue.TYPE_ATTRIBUTE:
  return newReference(value,rawValue,true);
case TypedValue.TYPE_STRING:
return new ResStringValue(rawValue);
case TypedValue.TYPE_FLOAT:
return new ResFloatValue(Float.intBitsToFloat(value),rawValue);
case TypedValue.TYPE_DIMENSION:
return new ResDimenValue(value,rawValue);
case TypedValue.TYPE_FRACTION:
return new ResFractionValue(value,rawValue);
case TypedValue.TYPE_INT_BOOLEAN:
return new ResBoolValue(value != 0,rawValue);
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return new ResColorValue(value,rawValue);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return new ResIntValue(value,rawValue);
}
throw new AndrolibException("Invalid value type: " + type);
}
 

Example 44

From project buzzwords, under directory /src/com/buzzwords/.

Source file: TeamSelectLayout.java

  15 
vote

@Override public void onFinishInflate(){
  super.onFinishInflate();
  this.setFocusable(true);
  final float DENSITY=this.getResources().getDisplayMetrics().density;
  mFrame=new FrameLayout(mContext);
  mFrame.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  int padding=(int)(DENSITY * 1 + 0.5f);
  mFrame.setPadding(0,padding,0,padding);
  mFrame.setBackgroundColor(R.color.black);
  mFrameForeground=new View(mContext);
  mFrameForeground.setBackgroundColor(this.getResources().getColor(R.color.genericBG));
  mFrameForeground.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  mTeamText=new TextView(mContext);
  mTeamText.setText("No team assigned");
  mTeamText.setLayoutParams(new LayoutParams((int)(DENSITY * INITIAL_TEXTWIDTH + 0.5f),LayoutParams.FILL_PARENT));
  mTeamText.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
  mTeamText.setIncludeFontPadding(false);
  mTeamText.setPadding((int)(DENSITY * 15 + 0.5f),0,0,0);
  mTeamText.setTextSize(TypedValue.COMPLEX_UNIT_DIP,INITIAL_TEXTSIZE);
  mFrame.addView(mFrameForeground);
  mFrame.addView(mTeamText);
  mButtons=new LinearLayout(mContext);
  mButtons.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  mButtons.setOrientation(LinearLayout.HORIZONTAL);
  mButtonAddTeam=new View(mContext);
  mButtonAddTeam.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1f));
  mButtonAddTeam.setOnClickListener(mAddTeamListener);
  mButtonEditTeamName=new ImageButton(mContext);
  LinearLayout.LayoutParams buttonParams=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
  buttonParams.gravity=(Gravity.CENTER_VERTICAL);
  buttonParams.rightMargin=(int)(DENSITY * 10 + 0.5f);
  mButtonEditTeamName.setLayoutParams(buttonParams);
  mButtonEditTeamName.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.gamesetup_editicon_selector));
  mButtonEditTeamName.setOnClickListener(mEditTeamListener);
  mButtons.addView(mButtonAddTeam);
  mButtons.addView(mButtonEditTeamName);
  this.addView(mFrame);
  this.addView(mButtons);
}
 

Example 45

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

Source file: Calculator.java

  15 
vote

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

Example 46

From project danbo, under directory /src/us/donmai/danbooru/danbo/.

Source file: TagListAdapter.java

  15 
vote

public View getView(int position,View convertView,ViewGroup parent){
  TextView tv=null;
  Tag t=_tags.get(position);
  if (convertView == null) {
    tv=new TextView(this._context);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PT,18);
  }
 else {
    tv=(TextView)convertView;
  }
  tv.setText(t.getName());
  tv.setOnClickListener(new TagClick(t));
  return tv;
}
 

Example 47

From project date-slider, under directory /src/com/codeslap/dateslider/.

Source file: WeekLabeler.java

  15 
vote

/** 
 * Here we set up the text characteristics for the TextView, i.e. red colour, serif font and semi-transparent white background for the centerView... and shadow!!!
 */
@Override protected void setupView(boolean isCenterView,float textSize){
  setGravity(Gravity.CENTER);
  setTextColor(0xFF883333);
  setTextSize(TypedValue.COMPLEX_UNIT_DIP,textSize);
  setTypeface(Typeface.SERIF);
  if (isCenterView) {
    setTypeface(Typeface.create(Typeface.SERIF,Typeface.BOLD));
    setBackgroundColor(0x55FFFFFF);
    setShadowLayer(2.5f,3,3,0xFF999999);
  }
}
 

Example 48

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

Source file: WeekLabeler.java

  15 
vote

/** 
 * Here we set up the text characteristics for the TextView, i.e. red colour, serif font and semi-transparent white background for the centerView... and shadow!!!
 */
@Override protected void setupView(boolean isCenterView,int textSize){
  setGravity(Gravity.CENTER);
  setTextColor(0xFF883333);
  setTextSize(TypedValue.COMPLEX_UNIT_DIP,textSize);
  setTypeface(Typeface.SERIF);
  if (isCenterView) {
    setTypeface(Typeface.create(Typeface.SERIF,Typeface.BOLD));
    setBackgroundColor(0x55FFFFFF);
    setShadowLayer(2.5f,3,3,0xFF999999);
  }
}
 

Example 49

From project droidkit, under directory /src/org/droidkit/widget/.

Source file: TabBar.java

  15 
vote

private void init(){
  mTabItems=new Vector<TabItem>();
  float height=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,64.0f,getContext().getResources().getDisplayMetrics());
  float margin=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,-3.0f,getContext().getResources().getDisplayMetrics());
  mItemParams=new LayoutParams(0,new Float(height).intValue(),1.0f);
  mItemParams.leftMargin=new Float(margin).intValue();
  mItemParams.rightMargin=new Float(margin).intValue();
}
 

Example 50

From project eoit, under directory /EOIT/src/fr/eoit/activity/fragment/.

Source file: ItemListFragment.java

  15 
vote

protected int getListWidth(){
  if (numberOfRow % numberOfColumn == 0) {
    return (numberOfRow / numberOfColumn) * ((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,rowHeight,getResources().getDisplayMetrics()));
  }
 else {
    return ((numberOfRow / numberOfColumn) + 1) * ((int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,rowHeight,getResources().getDisplayMetrics()));
  }
}
 

Example 51

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/.

Source file: ThumbnailLoader.java

  15 
vote

private Drawable getScaledDrawableForMimetype(FileHolder holder,Context context){
  Drawable d=getDrawableForMimetype(holder,context);
  if (d == null) {
    return new BitmapDrawable(context.getResources(),BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_launcher_file));
  }
 else {
    int size=(int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,48,context.getResources().getDisplayMetrics());
    return ImageUtils.resizeDrawable(d,size,size);
  }
}
 

Example 52

From project FlipDroid, under directory /app/src/com/goal98/flipdroid2/model/.

Source file: ContentPagerAdapter.java

  15 
vote

private TextView cloneTextView(LinearLayout.LayoutParams textLayoutParams,int txtSize,TikaUIObject uiObject,Spannable spannable){
  TextView tv;
  tv=new TextView(activity);
  tv.setLineSpacing(1,getLineSpacing());
  tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,txtSize);
  tv.setTextColor(Constants.LOADED_TEXT_COLOR);
  tv.setGravity(Gravity.LEFT | Gravity.TOP);
  if (uiObject.getObjectBody().startsWith("<p><blockquote>")) {
    tv.setPadding(2 + txtSize * 2,3,2 + txtSize * 2,3);
    tv.setBackgroundColor(Color.parseColor("#DDDDDD"));
    textLayoutParams.setMargins(0,(int)tv.getTextSize(),0,0);
  }
 else {
    tv.setPadding(2 + txtSize,3,2 + txtSize,3);
  }
  tv.setText(spannable);
  tv.setAutoLinkMask(Linkify.WEB_URLS);
  tv.setLinkTextColor(Constants.COLOR_LINK_TEXT);
  return tv;
}
 

Example 53

From project gh4a, under directory /src/com/gh4a/adapter/.

Source file: BookmarkAdapter.java

  15 
vote

@Override public View doGetView(int position,View convertView,ViewGroup parent){
  View v=convertView;
  if (v == null) {
    LayoutInflater vi=(LayoutInflater)LayoutInflater.from(mContext);
    v=vi.inflate(R.layout.row_bookmark,null);
  }
  Bookmark bookmark=mObjects.get(position);
  if (bookmark != null) {
    TextView tvFormattedName=(TextView)v.findViewById(R.id.tv_title);
    ImageView buttonAdd=(ImageView)v.findViewById(R.id.iv_add);
    if (position == 0) {
      if (!mHideAdd) {
        tvFormattedName.setText("Add " + bookmark.getName());
        tvFormattedName.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18);
        tvFormattedName.setTypeface(Typeface.DEFAULT_BOLD);
        LinearLayout.LayoutParams para=new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
        para.setMargins(0,0,0,0);
        para.gravity=Gravity.CENTER_VERTICAL;
        tvFormattedName.setLayoutParams(para);
        buttonAdd.setVisibility(View.VISIBLE);
      }
 else {
        buttonAdd.setVisibility(View.GONE);
        tvFormattedName.setVisibility(View.GONE);
        v.setVisibility(View.GONE);
      }
    }
 else {
      tvFormattedName.setText("[" + bookmark.getObjectType() + "] "+ bookmark.getName());
      buttonAdd.setVisibility(View.GONE);
    }
  }
  return v;
}