public ListPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListPreference, 0, 0);

    mKey = Util.checkNotNull(a.getString(R.styleable.ListPreference_key));

    // We allow the defaultValue attribute to be a string or an array of
    // strings. The reason we need multiple default values is that some
    // of them may be unsupported on a specific platform (for example,
    // continuous auto-focus). In that case the first supported value
    // in the array will be used.
    int attrDefaultValue = R.styleable.ListPreference_defaultValue;
    TypedValue tv = a.peekValue(attrDefaultValue);
    if (tv != null && tv.type == TypedValue.TYPE_REFERENCE) {
      mDefaultValues = a.getTextArray(attrDefaultValue);
    } else {
      mDefaultValues = new CharSequence[1];
      mDefaultValues[0] = a.getString(attrDefaultValue);
    }

    setEntries(a.getTextArray(R.styleable.ListPreference_entries));
    setEntryValues(a.getTextArray(R.styleable.ListPreference_entryValues));
    a.recycle();
  }
Esempio n. 2
0
 protected void initByAttributes(TypedArray attributes) {
   finishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_finished_color, default_finished_color);
   unfinishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_unfinished_color, default_unfinished_color);
   textColor = attributes.getColor(R.styleable.ArcProgress_arc_text_color, default_text_color);
   textSize = attributes.getDimension(R.styleable.ArcProgress_arc_text_size, default_text_size);
   arcAngle = attributes.getFloat(R.styleable.ArcProgress_arc_angle, default_arc_angle);
   setMax(attributes.getInt(R.styleable.ArcProgress_arc_max, default_max));
   setProgress(attributes.getInt(R.styleable.ArcProgress_arc_progress, 0));
   strokeWidth =
       attributes.getDimension(R.styleable.ArcProgress_arc_stroke_width, default_stroke_width);
   suffixTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_size, default_suffix_text_size);
   suffixText =
       TextUtils.isEmpty(attributes.getString(R.styleable.ArcProgress_arc_suffix_text))
           ? default_suffix_text
           : attributes.getString(R.styleable.ArcProgress_arc_suffix_text);
   suffixTextPadding =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_padding, default_suffix_padding);
   bottomTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_bottom_text_size, default_bottom_text_size);
   bottomText = attributes.getString(R.styleable.ArcProgress_arc_bottom_text);
 }
Esempio n. 3
0
  public ImageTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageTextView);

    mTextGravity = a.getString(R.styleable.ImageTextView_text_gravity);
    if (mTextGravity == null) {
      mTextGravity = GRAVITY_CENTER;
    }

    mImageGravity = a.getString(R.styleable.ImageTextView_image_gravity);
    if (mImageGravity == null) {
      mImageGravity = GRAVITY_CENTER;
    }

    mPosition = a.getString(R.styleable.ImageTextView_position);
    if (mPosition == null) {
      mPosition = POSITION_RIGHT;
    }

    mSpacing = a.getDimension(R.styleable.ImageTextView_spacing, 0f);
    mImageWidth = a.getDimension(R.styleable.ImageTextView_image_width, 0f);
    mImageHeight = a.getDimension(R.styleable.ImageTextView_image_height, 0f);

    a.recycle();

    mText = new TextView(context, attrs, defStyle);
    mImage = new ImageView(context, attrs, defStyle);

    addView(mImage);
    addView(mText);
  }
  @Override
  protected View createScreenletView(Context context, AttributeSet attributes) {
    TypedArray typedArray =
        context
            .getTheme()
            .obtainStyledAttributes(attributes, R.styleable.UserPortraitScreenlet, 0, 0);

    _autoLoad = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_autoLoad, true);
    _male = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_male, true);
    _portraitId = typedArray.getInt(R.styleable.UserPortraitScreenlet_portraitId, 0);
    _uuid = typedArray.getString(R.styleable.UserPortraitScreenlet_uuid);
    _editable = typedArray.getBoolean(R.styleable.UserPortraitScreenlet_editable, false);

    int offlinePolicy =
        typedArray.getInt(
            R.styleable.UserPortraitScreenlet_offlinePolicy, OfflinePolicy.REMOTE_ONLY.ordinal());
    _offlinePolicy = OfflinePolicy.values()[offlinePolicy];

    _userId =
        castToLongOrUseDefault(typedArray.getString(R.styleable.UserPortraitScreenlet_userId), 0L);

    if (SessionContext.hasUserInfo() && _portraitId == 0 && _uuid == null && _userId == 0) {
      _userId = SessionContext.getLoggedUser().getId();
    }

    int layoutId =
        typedArray.getResourceId(R.styleable.UserPortraitScreenlet_layoutId, getDefaultLayoutId());

    typedArray.recycle();

    return LayoutInflater.from(context).inflate(layoutId, null);
  }
Esempio n. 5
0
  public DoubleProgress(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.DoubleProgress);
    try {
      stringHaut = styledAttrs.getString(R.styleable.DoubleProgress_texteHaut);
      stringBas = styledAttrs.getString(R.styleable.DoubleProgress_texteBas);
      max = styledAttrs.getFloat(R.styleable.DoubleProgress_max, 5);
      temps = styledAttrs.getInt(R.styleable.DoubleProgress_temps, 1000);
      attente = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textFromAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textToAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      styledAttrs.recycle();
    }

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mView = inflater.inflate(R.layout.double_progress, this, true); // ajoute la view

    charger();
    remplir();
  }
  /**
   * Setup the Animator to achieve path morphing.
   *
   * @param anim The target Animator which will be updated.
   * @param arrayAnimator TypedArray for the ValueAnimator.
   * @return the PathDataEvaluator.
   */
  private static TypeEvaluator setupAnimatorForPath(ValueAnimator anim, TypedArray arrayAnimator) {
    TypeEvaluator evaluator = null;
    String fromString = arrayAnimator.getString(R.styleable.Animator_vc_valueFrom);
    String toString = arrayAnimator.getString(R.styleable.Animator_vc_valueTo);
    PathParser.PathDataNode[] nodesFrom = PathParser.createNodesFromPathData(fromString);
    PathParser.PathDataNode[] nodesTo = PathParser.createNodesFromPathData(toString);

    if (nodesFrom != null) {
      if (nodesTo != null) {
        anim.setObjectValues(nodesFrom, nodesTo);
        if (!PathParser.canMorph(nodesFrom, nodesTo)) {
          throw new InflateException(
              arrayAnimator.getPositionDescription()
                  + " Can't morph from "
                  + fromString
                  + " to "
                  + toString);
        }
      } else {
        anim.setObjectValues((Object) nodesFrom);
      }
      evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesFrom));
    } else if (nodesTo != null) {
      anim.setObjectValues((Object) nodesTo);
      evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesTo));
    }

    if (DBG_ANIMATOR_INFLATER && evaluator != null) {
      Log.v(LOG_TAG, "create a new PathDataEvaluator here");
    }

    return evaluator;
  }
 public DashboardViewAttr(Context context, AttributeSet attrs, int defStyleAttr) {
   TypedArray ta =
       context.obtainStyledAttributes(attrs, R.styleable.DashboardView, defStyleAttr, 0);
   mTikeCount = ta.getInt(R.styleable.DashboardView_tikeCount, 48);
   mTextSize =
       ta.getDimensionPixelSize(
           PxUtils.spToPx(R.styleable.DashboardView_android_textSize, context), 24);
   mText = ta.getString(R.styleable.DashboardView_android_text);
   //        progressHeight =
   // ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_progressHeight,context), 20);
   unit = ta.getString(R.styleable.DashboardView_Unit);
   textColor =
       ta.getColor(
           R.styleable.DashboardView_textColor,
           context.getResources().getColor(R.color.textColor));
   background = ta.getColor(R.styleable.DashboardView_backgroundColor, 0);
   startColor = ta.getColor(R.styleable.DashboardView_startProgressColor, 0);
   endColor = ta.getColor(R.styleable.DashboardView_endProgressColor, 0);
   startNum = ta.getInt(R.styleable.DashboardView_startNumber, 0);
   maxNum = ta.getInt(R.styleable.DashboardView_maxNumber, 120);
   padding = ta.getInt(PxUtils.dpToPx(R.styleable.DashboardView_padding, context), 0);
   progressColor =
       ta.getColor(
           R.styleable.DashboardView_progressColor,
           context.getResources().getColor(R.color.skyblue));
   ta.recycle();
 }
Esempio n. 8
0
    private boolean addAppWidget(
        SQLiteDatabase db, ContentValues values, TypedArray a, PackageManager packageManager) {

      String packageName = a.getString(R.styleable.Favorite_packageName);
      String className = a.getString(R.styleable.Favorite_className);

      if (packageName == null || className == null) {
        return false;
      }

      boolean hasPackage = true;
      ComponentName cn = new ComponentName(packageName, className);
      try {
        packageManager.getReceiverInfo(cn, 0);
      } catch (Exception e) {
        String[] packages =
            packageManager.currentToCanonicalPackageNames(new String[] {packageName});
        cn = new ComponentName(packages[0], className);
        try {
          packageManager.getReceiverInfo(cn, 0);
        } catch (Exception e1) {
          hasPackage = false;
        }
      }

      if (hasPackage) {
        int spanX = a.getInt(R.styleable.Favorite_spanX, 0);
        int spanY = a.getInt(R.styleable.Favorite_spanY, 0);
        return addAppWidget(db, values, cn, spanX, spanY);
      }

      return false;
    }
Esempio n. 9
0
  private void init(AttributeSet attrs) {
    if (attrs != null) {
      TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MyTextView);

      String fontName = a.getString(R.styleable.MyTextView_fontName);
      String fontStyle = a.getString(R.styleable.MyTextView_fontStyle);
      int fontColor = a.getColor(R.styleable.MyTextView_fontColor, Color.BLACK);

      if (fontName != null) {
        Typeface myTypeface =
            Typeface.createFromAsset(getContext().getAssets(), "fonts/" + fontName);

        if (fontStyle != null) {
          if (fontStyle.equalsIgnoreCase("normal")) {
            setTypeface(myTypeface, Typeface.NORMAL);
          } else if (fontStyle.equalsIgnoreCase("bold")) {
            setTypeface(myTypeface, Typeface.BOLD);
          } else if (fontStyle.equalsIgnoreCase("italics")) {
            setTypeface(myTypeface, Typeface.ITALIC);
          } else if (fontStyle.equalsIgnoreCase("bold_italics")) {
            setTypeface(myTypeface, Typeface.BOLD_ITALIC);
          } else {
            setTypeface(myTypeface, Typeface.NORMAL);
          }
        } else {
          setTypeface(myTypeface, Typeface.NORMAL);
        }
      }
      setTextColor(fontColor);
      a.recycle();
    }
  }
Esempio n. 10
0
 private void parseLoginButtonAttributes(
     final Context context,
     final AttributeSet attrs,
     final int defStyleAttr,
     final int defStyleRes) {
   this.toolTipMode = ToolTipMode.DEFAULT;
   final TypedArray a =
       context
           .getTheme()
           .obtainStyledAttributes(
               attrs, R.styleable.com_facebook_login_view, defStyleAttr, defStyleRes);
   try {
     confirmLogout =
         a.getBoolean(R.styleable.com_facebook_login_view_com_facebook_confirm_logout, true);
     loginText = a.getString(R.styleable.com_facebook_login_view_com_facebook_login_text);
     logoutText = a.getString(R.styleable.com_facebook_login_view_com_facebook_logout_text);
     toolTipMode =
         ToolTipMode.fromInt(
             a.getInt(
                 R.styleable.com_facebook_login_view_com_facebook_tooltip_mode,
                 ToolTipMode.DEFAULT.getValue()));
   } finally {
     a.recycle();
   }
 }
Esempio n. 11
0
    /** Called when the parser is pointing to an item tag. */
    public void readItem(AttributeSet attrs) {
      TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SherlockMenuItem);

      // Inherit attributes from the group as default value
      itemId = a.getResourceId(R.styleable.SherlockMenuItem_android_id, defaultItemId);
      final int category =
          a.getInt(R.styleable.SherlockMenuItem_android_menuCategory, groupCategory);
      final int order = a.getInt(R.styleable.SherlockMenuItem_android_orderInCategory, groupOrder);
      itemCategoryOrder = (category & Menu.CATEGORY_MASK) | (order & Menu.USER_MASK);
      itemTitle = a.getText(R.styleable.SherlockMenuItem_android_title);
      itemTitleCondensed = a.getText(R.styleable.SherlockMenuItem_android_titleCondensed);
      itemIconResId = a.getResourceId(R.styleable.SherlockMenuItem_android_icon, 0);
      itemAlphabeticShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_alphabeticShortcut));
      itemNumericShortcut =
          getShortcut(a.getString(R.styleable.SherlockMenuItem_android_numericShortcut));
      if (a.hasValue(R.styleable.SherlockMenuItem_android_checkable)) {
        // Item has attribute checkable, use it
        itemCheckable = a.getBoolean(R.styleable.SherlockMenuItem_android_checkable, false) ? 1 : 0;
      } else {
        // Item does not have attribute, use the group's (group can have one more state
        // for checkable that represents the exclusive checkable)
        itemCheckable = groupCheckable;
      }

      itemChecked = a.getBoolean(R.styleable.SherlockMenuItem_android_checked, defaultItemChecked);
      itemVisible = a.getBoolean(R.styleable.SherlockMenuItem_android_visible, groupVisible);
      itemEnabled = a.getBoolean(R.styleable.SherlockMenuItem_android_enabled, groupEnabled);

      TypedValue value = new TypedValue();
      a.getValue(R.styleable.SherlockMenuItem_android_showAsAction, value);
      itemShowAsAction = value.type == TypedValue.TYPE_INT_HEX ? value.data : -1;

      itemListenerMethodName = a.getString(R.styleable.SherlockMenuItem_android_onClick);
      itemActionViewLayout = a.getResourceId(R.styleable.SherlockMenuItem_android_actionLayout, 0);
      itemActionViewClassName = a.getString(R.styleable.SherlockMenuItem_android_actionViewClass);
      itemActionProviderClassName =
          a.getString(R.styleable.SherlockMenuItem_android_actionProviderClass);

      final boolean hasActionProvider = itemActionProviderClassName != null;
      if (hasActionProvider && itemActionViewLayout == 0 && itemActionViewClassName == null) {
        itemActionProvider =
            newInstance(
                itemActionProviderClassName,
                ACTION_PROVIDER_CONSTRUCTOR_SIGNATURE,
                mActionProviderConstructorArguments);
      } else {
        if (hasActionProvider) {
          Log.w(
              LOG_TAG,
              "Ignoring attribute 'actionProviderClass'." + " Action view already specified.");
        }
        itemActionProvider = null;
      }

      a.recycle();

      itemAdded = false;
    }
Esempio n. 12
0
 private void getAttrs(AttributeSet attr) {
   TypedArray a = getContext().obtainStyledAttributes(attr, R.styleable.ActionEditText);
   optionOneString = a.getString(R.styleable.ActionEditText_optionOneString);
   optionTwoString = a.getString(R.styleable.ActionEditText_optionTwoString);
   optionOneColor = a.getColor(R.styleable.ActionEditText_optionOneColor, 0x00ff00);
   optionTwoColor = a.getColor(R.styleable.ActionEditText_optionTwoColor, 0xff0000);
   badgeClickCallback = a.getString(R.styleable.ActionEditText_onBadgeClick);
 }
 private void parseAttributes(AttributeSet attrs) {
   TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.com_facebook_login_view);
   confirmLogout = a.getBoolean(R.styleable.com_facebook_login_view_confirm_logout, true);
   fetchUserInfo = a.getBoolean(R.styleable.com_facebook_login_view_fetch_user_info, true);
   loginText = a.getString(R.styleable.com_facebook_login_view_login_text);
   logoutText = a.getString(R.styleable.com_facebook_login_view_logout_text);
   a.recycle();
 }
  public DeveloperPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DeveloperPreference);
    twitterHandle = a.getString(R.styleable.DeveloperPreference_twitterHandle);
    profileLink = a.getString(R.styleable.DeveloperPreference_profileLink);
    a.recycle();
  }
  private void init(Context context, AttributeSet attrs) {
    mDisplayMetrics = context.getResources().getDisplayMetrics();

    mStrokeWidth = mStrokeWidth * mDisplayMetrics.density;
    mTextSize = mTextSize * mDisplayMetrics.scaledDensity;

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressPieView);
    final Resources res = getResources();

    mMax = a.getInteger(R.styleable.ProgressPieView_max1, mMax);
    mProgress = a.getInteger(R.styleable.ProgressPieView_progress1, mProgress);
    mStartAngle = a.getInt(R.styleable.ProgressPieView_startAngle, mStartAngle);
    mStrokeWidth = a.getDimension(R.styleable.ProgressPieView_strokeWidth, mStrokeWidth);
    mTypeface = a.getString(R.styleable.ProgressPieView_typeface);
    mTextSize = a.getDimension(R.styleable.ProgressPieView_android_textSize, mTextSize);
    mText = a.getString(R.styleable.ProgressPieView_android_text);

    mShowStroke = a.getBoolean(R.styleable.ProgressPieView_showStroke, mShowStroke);
    mShowText = a.getBoolean(R.styleable.ProgressPieView_showText, mShowText);
    mImage = a.getDrawable(R.styleable.ProgressPieView_image);

    int backgroundColor = res.getColor(R.color.default_background_color);
    backgroundColor = a.getColor(R.styleable.ProgressPieView_backgroundColor, backgroundColor);
    int progressColor = res.getColor(R.color.default_progress_color);
    progressColor = a.getColor(R.styleable.ProgressPieView_progressColor1, progressColor);
    int strokeColor = res.getColor(R.color.default_stroke_color);
    strokeColor = a.getColor(R.styleable.ProgressPieView_strokeColor, strokeColor);
    int textColor = res.getColor(R.color.default_text_color);
    textColor = a.getColor(R.styleable.ProgressPieView_android_textColor, textColor);

    mProgressFillType =
        a.getInteger(R.styleable.ProgressPieView_progressFillType, mProgressFillType);

    a.recycle();

    mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBackgroundPaint.setColor(backgroundColor);
    mBackgroundPaint.setStyle(Paint.Style.FILL);

    mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mProgressPaint.setColor(progressColor);
    mProgressPaint.setStyle(Paint.Style.FILL);

    mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mStrokePaint.setColor(strokeColor);
    mStrokePaint.setStyle(Paint.Style.STROKE);
    mStrokePaint.setStrokeWidth(mStrokeWidth);

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setColor(textColor);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);

    mInnerRectF = new RectF();
    mImageRect = new Rect();
  }
  @Override
  public boolean init(final Context context, final AttributeSet attrs) {
    if (!super.init(context, attrs)) {
      return false;
    }

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AwesomePreference);

    int filePath = -1, filePathList = -1, fileValue = -1;
    if (a != null) {
      filePath = a.getResourceId(R.styleable.AwesomePreference_filePath, -1);
      filePathList = a.getResourceId(R.styleable.AwesomePreference_filePathList, -1);
      fileValue = a.getResourceId(R.styleable.AwesomePreference_fileValue, -1);
      mStartup = a.getBoolean(R.styleable.AwesomePreference_startup, mStartup);
      mMultiFile = a.getBoolean(R.styleable.AwesomePreference_multifile, mMultiFile);
      mValueChecked = a.getString(R.styleable.AwesomePreference_valueChecked);
      mValueNotChecked = a.getString(R.styleable.AwesomePreference_valueNotChecked);
      a.recycle();
    }

    final Resources res = context.getResources();
    if (filePath != -1) {
      mPath = Utils.checkPath(res.getString(filePath));
      mPaths = null;
    } else if (filePathList != -1) {
      mPaths = res.getStringArray(filePathList);
      mPath = Utils.checkPaths(mPaths);
      if (mPath.isEmpty() || !mMultiFile) {
        mPaths = null;
      }
    } else {
      mPath = "";
      mPaths = null;
    }

    if (!TextUtils.isEmpty(mPath) && filePathList != -1 && fileValue != -1) {
      final int index = Arrays.asList(res.getStringArray(filePathList)).indexOf(mPath);
      final String[] values = res.getStringArray(fileValue)[index].split(";");
      mValueChecked = values[0];
      mValueNotChecked = values[1];
      Logger.d(
          this, "mValueChecked -> %s\nmValueNotChecked -> %s", mValueChecked, mValueNotChecked);
    }

    if (TextUtils.isEmpty(mValueChecked)) {
      mValueChecked = "1";
    }
    if (TextUtils.isEmpty(mValueNotChecked)) {
      mValueNotChecked = "0";
    }

    handleSelf(true);

    return true;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    Resources res = getResources();
    TypedArray ta = res.obtainTypedArray(R.array.movies);
    int n = ta.length();

    for (int i = 0; i < n; i++) {
      TypedArray movieData = res.obtainTypedArray(ta.getResourceId(i, 0));
      Movie movie =
          new Movie(
              movieData.getString(0),
              movieData.getString(1),
              movieData.getString(2),
              movieData.getResourceId(4, 0),
              movieData.getResourceId(3, 0));
      mMovieList.add(movie);
      movieData.recycle();
    }

    ta.recycle();

    View v = inflater.inflate(R.layout.fragment_master, container, false);
    GridView gridview = (GridView) v.findViewById(R.id.gridview);
    gridview.setAdapter(new GridAdapter(v.getContext(), mMovieList));

    gridview.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            // Create new fragment and bundle
            DetailFragment newFragment = new DetailFragment();
            Bundle bundle = new Bundle();
            Movie movie = mMovieList.get(position);
            if (movie != null) {
              bundle.putSerializable(FRAGMENT_BUNDLE_KEY, movie);
              newFragment.setArguments(bundle);
            } else {
              Log.e("Movie", "Is null");
            }

            // Set transaction.
            android.support.v4.app.FragmentTransaction transaction =
                getFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container, newFragment);
            transaction.addToBackStack(null);

            // Commit the transaction
            transaction.commit();
          }
        });
    return v;
  }
  /**
   * Construct a new SwitchPreference with the given style options.
   *
   * @param context The Context that will style this preference
   * @param attrs Style attributes that differ from the default
   * @param defStyle Theme attribute defining the default style options
   */
  public SwitchPreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyle, 0);
    setSummaryOn(a.getString(R.styleable.SwitchPreference_summaryOn));
    setSummaryOff(a.getString(R.styleable.SwitchPreference_summaryOff));
    setSwitchTextOn(a.getString(R.styleable.SwitchPreference_switchTextOn));
    setSwitchTextOff(a.getString(R.styleable.SwitchPreference_switchTextOff));
    setDisableDependentsState(
        a.getBoolean(R.styleable.SwitchPreference_disableDependentsState, false));
    a.recycle();
  }
  private void testing(Context context, AttributeSet attrs) {
    if (!isInEditMode()) {
      this.setBackgroundDrawable(getResources().getDrawable(R.drawable.background));

      if (attrs != null) {
        TypedArray tA = context.obtainStyledAttributes(attrs, R.styleable.wingokuflatui);

        normalStatecolor = tA.getString(R.styleable.wingokuflatui_normalStateColor);

        pressedStateColor = tA.getString(R.styleable.wingokuflatui_pressedStateColor);

        tA.recycle();
      } else {
        normalStatecolor = pressedStateColor = "#426689";
      }
      this.getBackground()
          .setColorFilter(Color.parseColor(normalStatecolor), PorterDuff.Mode.DARKEN);

      this.setOnTouchListener(
          new OnTouchListener() {

            @Override
            public boolean onTouch(View arg0, MotionEvent event) {

              final String color;

              if (event.getAction() == MotionEvent.ACTION_UP) {
                color = normalStatecolor;

              } else color = pressedStateColor;

              new Handler()
                  .postDelayed(
                      new Runnable() {

                        @Override
                        public void run() {

                          // color change when the button is pressed

                          WinGokuFlatButton.this
                              .getBackground()
                              .setColorFilter(Color.parseColor(color), PorterDuff.Mode.DARKEN);
                        }
                      },
                      30);

              return false;
            }
          });
    }
  }
Esempio n. 20
0
 public BCommonTitle(Context context, AttributeSet attrs, int style) {
   super(context, attrs, style);
   if (attrs != null) {
     TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.BCommonTitle);
     title = styledAttrs.getString(R.styleable.BCommonTitle_common_title);
     rightText = styledAttrs.getString(R.styleable.BCommonTitle_right_text);
     leftText = styledAttrs.getString(R.styleable.BCommonTitle_left_text);
     leftDrawable = styledAttrs.getDrawable(R.styleable.BCommonTitle_left_img);
     rightDrawable = styledAttrs.getDrawable(R.styleable.BCommonTitle_right_img);
     styledAttrs.recycle();
   }
   init(context);
 }
Esempio n. 21
0
  public ImageSizes getImageSizes() {
    if (mImageSizes == null) {
      TypedArray imageSizes = getResources().obtainTypedArray(R.array.image_sizes);
      mImageSizes =
          new ImageSizes(
              imageSizes.getString(0),
              imageSizes.getString(1),
              imageSizes.getString(2),
              imageSizes.getString(3));
    }

    return mImageSizes;
  }
Esempio n. 22
0
  private void loadUnreadSupportShortcuts() {
    long start = System.currentTimeMillis();
    if (LauncherLog.DEBUG_PERFORMANCE) {
      LauncherLog.d(TAG, "loadUnreadSupportShortcuts begin: start = " + start);
    }

    // Clear all previous parsed unread shortcuts.
    UNREAD_SUPPORT_SHORTCUTS.clear();

    try {
      XmlResourceParser parser = mContext.getResources().getXml(R.xml.unread_support_shortcuts);
      AttributeSet attrs = Xml.asAttributeSet(parser);
      XmlUtils.beginDocument(parser, TAG_UNREADSHORTCUTS);

      final int depth = parser.getDepth();

      int type = -1;
      while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
          && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
          continue;
        }

        TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.UnreadShortcut);
        synchronized (LOG_LOCK) {
          UNREAD_SUPPORT_SHORTCUTS.add(
              new UnreadSupportShortcut(
                  a.getString(R.styleable.UnreadShortcut_unreadPackageName),
                  a.getString(R.styleable.UnreadShortcut_unreadClassName),
                  a.getString(R.styleable.UnreadShortcut_unreadKey),
                  a.getInt(R.styleable.UnreadShortcut_unreadType, 0)));
        }
        a.recycle();
      }
    } catch (XmlPullParserException e) {
      LauncherLog.w(TAG, "Got XmlPullParserException while parsing unread shortcuts.", e);
    } catch (IOException e) {
      LauncherLog.w(TAG, "Got IOException while parsing unread shortcuts.", e);
    }
    sUnreadSupportShortcutsNum = UNREAD_SUPPORT_SHORTCUTS.size();
    if (LauncherLog.DEBUG_PERFORMANCE) {
      LauncherLog.d(
          TAG,
          "loadUnreadSupportShortcuts end: time used = "
              + (System.currentTimeMillis() - start)
              + ",sUnreadSupportShortcutsNum = "
              + sUnreadSupportShortcutsNum
              + getUnreadSupportShortcutInfo());
    }
  }
 public ValueDependencySeekBarDialogPreference(
     final Context context, final AttributeSet attrs, final int defStyle) {
   super(context, attrs, defStyle);
   final Resources res = context.getResources();
   final TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle, 0);
   mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey);
   final int dependencyValueRes =
       a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0);
   mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null;
   mDependencyValueDefault =
       a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault);
   a.recycle();
 }
  public ExtendImageButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextImageView);

    _color = a.getColor(R.styleable.TextImageView_textColor, 0XFFFFFFFF);
    _textsize = a.getDimension(R.styleable.TextImageView_textSize, 50);

    _text =
        a.getString(R.styleable.TextImageView_text) == null
            ? ""
            : a.getString(R.styleable.TextImageView_text);

    paint = new Paint();
    a.recycle();
  }
Esempio n. 25
0
  /**
   * Parse the attributes passed to the view from the XML
   *
   * @param a the attributes to parse
   */
  private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_pwRimWidth, rimWidth);
    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_pwSpinSpeed, spinSpeed);
    barLength = (int) a.getDimension(R.styleable.ProgressWheel_pwBarLength, barLength);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_pwDelayMillis, delayMillis);
    if (delayMillis < 0) {
      delayMillis = 10;
    }

    // Only set the text if it is explicitly defined
    if (a.hasValue(R.styleable.ProgressWheel_pwText)) {
      setText(a.getString(R.styleable.ProgressWheel_pwText));
    }

    barColor = a.getColor(R.styleable.ProgressWheel_pwBarColor, barColor);
    textColor = a.getColor(R.styleable.ProgressWheel_pwTextColor, textColor);
    rimColor = a.getColor(R.styleable.ProgressWheel_pwRimColor, rimColor);
    circleColor = a.getColor(R.styleable.ProgressWheel_pwCircleColor, circleColor);
    contourColor = a.getColor(R.styleable.ProgressWheel_pwContourColor, contourColor);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_pwTextSize, textSize);
    contourSize = a.getDimension(R.styleable.ProgressWheel_pwContourSize, contourSize);

    a.recycle();
  }
Esempio n. 26
0
  private void init(AttributeSet attrs, int defStyle) {
    if (isInEditMode()) return;
    TypedArray a =
        getContext()
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.SVGImageView, defStyle, 0);
    try {
      int resourceId = a.getResourceId(R.styleable.SVGImageView_svg, -1);
      if (resourceId != -1) {
        setImageResource(resourceId);
        return;
      }

      String url = a.getString(R.styleable.SVGImageView_svg);
      if (url != null) {
        Uri uri = Uri.parse(url);
        if (internalSetImageURI(uri, false)) return;

        // Last chance, try loading it as an asset filename
        setImageAsset(url);
      }

    } finally {
      a.recycle();
    }
  }
Esempio n. 27
0
  public VerticalCardView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.com_gabm_fancyplaces_VerticalCardView, 0, 0);

    try {
      title = a.getString(R.styleable.com_gabm_fancyplaces_VerticalCardView_card_title);
    } finally {
      a.recycle();
    }

    // own settings
    this.setOrientation(VERTICAL);
    this.setPadding(30, 30, 30, 30);

    // text view as title
    TextView textView = new TextView(context);
    textView.setText(title);
    textView.setTextAppearance(context, R.style.TextAppearance_AppCompat_Large);
    textView.setTypeface(null, Typeface.BOLD);
    textView.setPadding(0, 20, 0, 10);
    this.addView(textView);
  }
  @Override
  protected Object onGetDefaultValue(TypedArray a, int index) {
    String defaultDateSpecifiedInPref = a.getString(index);

    if (defaultDateSpecifiedInPref != null) // if the default date is
    // specified in the preferences
    {
      if (defaultDateSpecifiedInPref.equals(DATE_TIME_NOW)) // if todays
        // date should
        // be as
        // default
        this.mDefaultDate = DateTime.now();
      else // given date is specificed in the preferences
      {
        try // try to parse it
        {
          this.mDefaultDate =
              DateTime.parse(defaultDateSpecifiedInPref, DateUtils.SHORT_DATE_FORMAT);
        } catch (Exception e) // if the parsing fails, just initiate the
        // defafult date variable
        {
          this.mDefaultDate = new DateTime();
        }
      }
    } else // no default date is specified in the preferences
    {
      this.mDefaultDate = new DateTime();
    }

    return this.mDefaultDate.getMillis(); // return the date in millisecunds
  }
  /**
   * Last but not least, try to pull the Font Path from the Theme, which is defined.
   *
   * @param context Activity Context
   * @param styleAttrId Theme style id
   * @param subStyleAttrId the sub style from the theme to look up after the first style
   * @param attributeId if -1 returns null.
   * @return null if no theme or attribute defined.
   */
  static String pullFontPathFromTheme(
      Context context, int styleAttrId, int subStyleAttrId, int attributeId) {
    if (styleAttrId == -1 || attributeId == -1) return null;

    final Resources.Theme theme = context.getTheme();
    final TypedValue value = new TypedValue();

    theme.resolveAttribute(styleAttrId, value, true);
    int subStyleResId = -1;
    final TypedArray parentTypedArray =
        theme.obtainStyledAttributes(value.resourceId, new int[] {subStyleAttrId});
    try {
      subStyleResId = parentTypedArray.getResourceId(0, -1);
    } catch (Exception ignore) {
      // Failed for some reason.
      return null;
    } finally {
      parentTypedArray.recycle();
    }

    if (subStyleResId == -1) return null;
    final TypedArray subTypedArray =
        context.obtainStyledAttributes(subStyleResId, new int[] {attributeId});
    if (subTypedArray != null) {
      try {
        return subTypedArray.getString(0);
      } catch (Exception ignore) {
        // Failed for some reason.
        return null;
      } finally {
        subTypedArray.recycle();
      }
    }
    return null;
  }
  /**
   * Tries to pull the Font Path from the Text Appearance.
   *
   * @param context Activity Context
   * @param attrs View Attributes
   * @param attributeId if -1 returns null.
   * @return returns null if attribute is not defined or if no TextAppearance is found.
   */
  static String pullFontPathFromTextAppearance(
      final Context context, AttributeSet attrs, int attributeId) {
    if (attributeId == -1 || attrs == null) {
      return null;
    }

    int textAppearanceId = -1;
    final TypedArray typedArrayAttr =
        context.obtainStyledAttributes(attrs, new int[] {android.R.attr.textAppearance});
    if (typedArrayAttr != null) {
      try {
        textAppearanceId = typedArrayAttr.getResourceId(0, -1);
      } catch (Exception ignored) {
        // Failed for some reason
        return null;
      } finally {
        typedArrayAttr.recycle();
      }
    }

    final TypedArray textAppearanceAttrs =
        context.obtainStyledAttributes(textAppearanceId, new int[] {attributeId});
    if (textAppearanceAttrs != null) {
      try {
        return textAppearanceAttrs.getString(0);
      } catch (Exception ignore) {
        // Failed for some reason.
        return null;
      } finally {
        textAppearanceAttrs.recycle();
      }
    }
    return null;
  }