Example usage for android.graphics LightingColorFilter LightingColorFilter

List of usage examples for android.graphics LightingColorFilter LightingColorFilter

Introduction

In this page you can find the example usage for android.graphics LightingColorFilter LightingColorFilter.

Prototype

public LightingColorFilter(@ColorInt int mul, @ColorInt int add) 

Source Link

Document

Create a colorfilter that multiplies the RGB channels by one color, and then adds a second color.

Usage

From source file:app.philm.in.fragments.SideMenuFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    View view = inflater.inflate(R.layout.fragment_drawer, container, false);

    mListView = (ListView) view.findViewById(android.R.id.list);
    mListView.setOnItemClickListener(this);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    mAdapter = new SideMenuItemAdapter();
    mListView.setAdapter(mAdapter);//  www.  j  a  va2s .c o  m

    mAddAccountLayout = view.findViewById(R.id.layout_add_account);
    mAddAccountLayout.setOnClickListener(this);

    mProfileInfoLayout = view.findViewById(R.id.layout_profile_inner);
    mProfileInfoLayout.setOnClickListener(this);
    mUsernameTextView = (TextView) view.findViewById(R.id.textview_username);
    mFullnameTextView = (TextView) view.findViewById(R.id.textview_fullname);
    mAvatarImageView = (ImageView) view.findViewById(R.id.imageview_account_avatar);

    mCheckinLayout = view.findViewById(R.id.layout_checkin);
    mCheckinLayout.setOnClickListener(this);

    mCheckinImageView = (PhilmImageView) view.findViewById(R.id.imageview_checkin_movie);
    mCheckinImageView.setAutoFade(false);
    mCheckinTitleTextView = (TextView) mCheckinLayout.findViewById(R.id.textview_title);

    final int darkenByte = Math.round(255 * CHECKIN_BACKDROP_DARKEN);
    mColorFilter = new LightingColorFilter(Color.rgb(darkenByte, darkenByte, darkenByte), 0);

    return view;
}

From source file:alexander.martinz.libs.materialpreferences.MaterialPreference.java

public boolean init(Context context, AttributeSet attrs) {
    if (mInit) {// w  w w.j  a va  2  s  .c  o  m
        return false;
    }
    mInit = true;

    if (attrs != null) {
        TypedArray typedArray = parseAttrs(context, attrs);
        recycleTypedArray(typedArray);
    }

    final int layoutResId = mPrefAsCard ? R.layout.material_prefs_card_preference
            : R.layout.material_prefs_preference;
    mView = getLayoutInflater().inflate(layoutResId, this, true);
    if (mPrefAsCard) {
        mCardView = (CardView) mView.findViewById(R.id.card_preference_root);
    }

    mIcon = (ImageView) mView.findViewById(android.R.id.icon);
    mTitle = (TextView) mView.findViewById(android.R.id.title);
    mSummary = (TextView) mView.findViewById(android.R.id.summary);
    mWidgetFrame = (LinearLayout) mView.findViewById(android.R.id.widget_frame);
    mWidgetFrameBottom = (LinearLayout) mView.findViewById(R.id.widget_frame_bottom);

    if (mResIdIcon != -1 && mIcon != null) {
        Drawable d = ContextCompat.getDrawable(context, mResIdIcon);
        if (d != null && mIconTintColor != Integer.MIN_VALUE) {
            d = d.mutate();
            d.setColorFilter(new LightingColorFilter(Color.BLACK, mIconTintColor));
        }
        mIcon.setImageDrawable(d);
        mIcon.setVisibility(View.VISIBLE);
    }
    if (mResIdTitle != -1) {
        mTitle.setText(mResIdTitle);
    }
    if (mResIdSummary != -1 && mSummary != null) {
        mSummary.setText(mResIdSummary);
        mSummary.setVisibility(View.VISIBLE);
    }

    if (mPrefAsCard && mCardBackgroundColor != Integer.MIN_VALUE) {
        setBackgroundColor(mCardBackgroundColor);
    }

    setSelectable(true);
    setOnClickListener(this);
    setOnTouchListener(this);
    setOrientation(LinearLayout.VERTICAL);

    return true;
}

From source file:com.dgmltn.ranger.internal.PinView.java

/**
 * The view is created empty with a default constructor. Use init to set all the initial
 * variables for the pin//from   www .j  a v  a2  s.  co  m
 *
 * @param position     The position of this point in its parent's view
 * @param pinRadiusDP  the initial size of the pin
 * @param pinColor     the color of the pin
 * @param textColor    the color of the value text in the pin
 * @param circleRadius the radius of the selector circle
 * @param circleColor  the color of the selector circle
 */
public void init(PointF position, float pinRadiusDP, int pinColor, int textColor, float circleRadius,
        int circleColor, float minFont, float maxFont) {

    mPin = ContextCompat.getDrawable(getContext(), R.drawable.rotate);

    mPosition = position;

    mDensity = getResources().getDisplayMetrics().density;
    mMinPinFont = minFont / mDensity;
    mMaxPinFont = maxFont / mDensity;

    mPinPadding = (int) (15f * mDensity);
    mCircleRadiusPx = circleRadius;
    mTextYPadding = (int) (3.5f * mDensity);
    mPinRadiusPx = (int) ((pinRadiusDP == -1 ? DEFAULT_THUMB_RADIUS_DP : pinRadiusDP) * mDensity);

    // Creates the paint and sets the Paint values
    mTextPaint = new TextPaint();
    mTextPaint.setTypeface(Typeface.MONOSPACE);
    mTextPaint.setColor(textColor);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(15f * mDensity);

    // Creates the paint and sets the Paint values
    mCirclePaint = new Paint();
    mCirclePaint.setColor(circleColor);
    mCirclePaint.setAntiAlias(true);

    // Color filter for the selection pin
    mPinFilter = new LightingColorFilter(pinColor, pinColor);

    // Sets the minimum touchable area, but allows it to expand based on image size
    mTargetRadiusPx = Math.max(MINIMUM_TARGET_RADIUS_DP * mDensity, mPinRadiusPx);
}

From source file:com.appyvet.rangebar.PinView.java

/**
 * The view is created empty with a default constructor. Use init to set all the initial
 * variables for the pin/*from  w ww  . java 2 s .  co m*/
 *
 * @param ctx          Context
 * @param y            The y coordinate to raw the pin (i.e. the bar location)
 * @param pinRadiusDP  the initial size of the pin
 * @param pinColor     the color of the pin
 * @param textColor    the color of the value text in the pin
 * @param circleRadius the radius of the selector circle
 * @param circleColor  the color of the selector circle
 */
public void init(Context ctx, float y, float pinRadiusDP, int pinColor, int textColor, float circleRadius,
        int circleColor, float minFont, float maxFont) {

    mRes = ctx.getResources();
    mPin = ContextCompat.getDrawable(ctx, R.drawable.rotate);

    mDensity = getResources().getDisplayMetrics().density;
    mMinPinFont = minFont / mDensity;
    mMaxPinFont = maxFont / mDensity;

    mPinPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, mRes.getDisplayMetrics());
    mCircleRadiusPx = circleRadius;
    mTextYPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3.5f,
            mRes.getDisplayMetrics());
    // If one of the attributes are set, but the others aren't, set the
    // attributes to default
    if (pinRadiusDP == -1) {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_THUMB_RADIUS_DP,
                mRes.getDisplayMetrics());
    } else {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pinRadiusDP,
                mRes.getDisplayMetrics());
    }
    //Set text size in px from dp
    int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 15, mRes.getDisplayMetrics());

    // Creates the paint and sets the Paint values
    mTextPaint = new Paint();
    mTextPaint.setColor(textColor);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(textSize);
    // Creates the paint and sets the Paint values
    mCirclePaint = new Paint();
    mCirclePaint.setColor(circleColor);
    mCirclePaint.setAntiAlias(true);

    //Color filter for the selection pin
    mPinFilter = new LightingColorFilter(pinColor, pinColor);

    // Sets the minimum touchable area, but allows it to expand based on
    // image size
    int targetRadius = (int) Math.max(MINIMUM_TARGET_RADIUS_DP, mPinRadiusPx);

    mTargetRadiusPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, targetRadius,
            mRes.getDisplayMetrics());
    mY = y;
}

From source file:br.com.mauker.materialseekbar.PinView.java

/**
 * The view is created empty with a default constructor. Use init to set all the initial
 * variables for the pin// w  w w  .ja va  2s . c  om
 *
 * @param ctx          Context
 * @param y            The y coordinate to raw the pin (i.e. the bar location)
 * @param pinRadiusDP  the initial size of the pin
 * @param pinColor     the color of the pin
 * @param textColor    the color of the value text in the pin
 * @param circleRadius the radius of the selector circle
 * @param minFont  the minimum font size for the pin text
 * @param maxFont  the maximum font size for the pin text
 * @param pinsAreTemporary  whether to show the pin initially or just the circle
 */
public void init(Context ctx, float y, float pinRadiusDP, int pinColor, int textColor, float circleRadius,
        int circleColor, float minFont, float maxFont, boolean pinsAreTemporary) {

    Resources res = ctx.getResources();
    mPin = ContextCompat.getDrawable(ctx, R.drawable.rotate);

    mDensity = getResources().getDisplayMetrics().density;
    mMinPinFont = minFont / mDensity;
    mMaxPinFont = maxFont / mDensity;
    mIsTemporary = pinsAreTemporary;

    mPinPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, res.getDisplayMetrics());
    mCircleRadiusPx = circleRadius;
    mTextYPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, res.getDisplayMetrics());
    // If one of the attributes are set, but the others aren't, set the
    // attributes to default
    if (pinRadiusDP == -1) {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_THUMB_RADIUS_DP,
                res.getDisplayMetrics());
    } else {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pinRadiusDP,
                res.getDisplayMetrics());
    }

    //Set text size in px from dp
    int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 5, res.getDisplayMetrics());

    // Creates the paint and sets the Paint values
    mTextPaint = new Paint();
    mTextPaint.setColor(textColor);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(textSize);
    // Creates the paint and sets the Paint values
    mCirclePaint = new Paint();
    mCirclePaint.setColor(circleColor);
    mCirclePaint.setAntiAlias(true);

    //Color filter for the selection pin
    mPinFilter = new LightingColorFilter(pinColor, pinColor);

    // Sets the minimum touchable area, but allows it to expand based on
    // image size
    int targetRadius = (int) Math.max(MINIMUM_TARGET_RADIUS_DP, mPinRadiusPx);

    mTargetRadiusPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, targetRadius,
            res.getDisplayMetrics());
    mY = y;
}

From source file:airfree.xprojets.airfree.PinView.java

/**
 * The view is created empty with a default constructor. Use init to set all the initial
 * variables for the pin//from w  w  w .j a v  a2  s  .c  o  m
 *
 * @param ctx          Context
 * @param y            The y coordinate to raw the pin (i.e. the bar location)
 * @param pinRadiusDP  the initial size of the pin
 * @param pinColor     the color of the pin
 * @param textColor    the color of the value text in the pin
 * @param circleRadius the radius of the selector circle
 * @param minFont  the minimum font size for the pin text
 * @param maxFont  the maximum font size for the pin text
 * @param pinsAreTemporary  whether to show the pin initially or just the circle
 */
public void init(Context ctx, float y, float pinRadiusDP, int pinColor, int textColor, float circleRadius,
        int circleColor, float minFont, float maxFont, boolean pinsAreTemporary) {

    mRes = ctx.getResources();
    mPin = ContextCompat.getDrawable(ctx, R.drawable.rotate);

    mDensity = getResources().getDisplayMetrics().density;
    mMinPinFont = minFont / mDensity;
    mMaxPinFont = maxFont / mDensity;
    mPinsAreTemporary = pinsAreTemporary;

    mPinPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15, mRes.getDisplayMetrics());
    mCircleRadiusPx = circleRadius;
    mTextYPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3.5f,
            mRes.getDisplayMetrics());
    // If one of the attributes are set, but the others aren't, set the
    // attributes to default
    if (pinRadiusDP == -1) {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_THUMB_RADIUS_DP,
                mRes.getDisplayMetrics());
    } else {
        mPinRadiusPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pinRadiusDP,
                mRes.getDisplayMetrics());
    }
    //Set text size in px from dp
    int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 15, mRes.getDisplayMetrics());

    // Creates the paint and sets the Paint values
    mTextPaint = new Paint();
    mTextPaint.setColor(textColor);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(textSize);
    // Creates the paint and sets the Paint values
    mCirclePaint = new Paint();
    mCirclePaint.setColor(circleColor);
    mCirclePaint.setAntiAlias(true);

    //Color filter for the selection pin
    mPinFilter = new LightingColorFilter(pinColor, pinColor);

    // Sets the minimum touchable area, but allows it to expand based on
    // image size
    int targetRadius = (int) Math.max(MINIMUM_TARGET_RADIUS_DP, mPinRadiusPx);

    mTargetRadiusPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, targetRadius,
            mRes.getDisplayMetrics());
    mY = y;
}

From source file:com.ofalvai.bpinfo.util.UiUtils.java

/**
 * Adds a rectangular icon for the affected route.
 *
 * First it creates a TextView, then sets the style properties of the view.
 * The custom colored rounded background is achieved by a Drawable and a ColorFilter on top of that.
 *///from w  w  w  . ja v  a2  s .  c om
public static void addRouteIcon(Context context, @NonNull ViewGroup root, @NonNull Route route) {
    ContextThemeWrapper iconContextTheme = new ContextThemeWrapper(context, R.style.RouteIcon);
    TextView iconView = new TextView(iconContextTheme);

    iconView.setText(route.getShortName());
    iconView.setTextColor(route.getTextColor());
    iconView.setContentDescription(Utils.getContentDescriptionForRoute(context, route));
    root.addView(iconView);

    // Layout attributes defined in R.style.RouteIcon were ignored before attaching the view to
    // a parent, so we need to manually set them
    ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    int margin = (int) context.getResources().getDimension(R.dimen.route_icon_margin);
    params.rightMargin = margin;
    params.topMargin = margin;
    // A requestLayout() call is not necessary here because the setBackground() method below
    // will call that anyway.
    //iconView.requestLayout();

    // Setting a custom colored rounded background drawable as background
    Drawable iconBackground = context.getResources().getDrawable(R.drawable.rounded_corner_5dp);
    if (iconBackground != null) {
        ColorFilter colorFilter = new LightingColorFilter(Color.rgb(1, 1, 1), route.getColor());
        iconBackground.mutate().setColorFilter(colorFilter);
        iconView.setBackground(iconBackground);
    }
}

From source file:org.mozilla.mozstumbler.client.navdrawer.MetricsView.java

public MetricsView(View view) {
    mView = view;//from   w  ww.ja  va 2  s  .c om

    LocalBroadcastManager.getInstance(mView.getContext()).registerReceiver(new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            Bundle bundle = intent.getExtras();
            mPersistedStats = (Properties) bundle.get(PersistedStats.EXTRAS_PERSISTENT_SYNC_STATUS_UPDATED);
            updateSentStats();
        }
    }, new IntentFilter(PersistedStats.ACTION_PERSISTENT_SYNC_STATUS_UPDATED));

    mOnMapShowMLS = (CheckBox) mView.findViewById(R.id.checkBox_show_mls);
    mOnMapShowMLS.setVisibility(View.GONE);
    mOnMapShowMLS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ClientPrefs.getInstance(mView.getContext()).setOnMapShowMLS(mOnMapShowMLS.isChecked());
            if (mMapLayerToggleListener.get() != null) {
                mMapLayerToggleListener.get().setShowMLS(mOnMapShowMLS.isChecked());
            }
        }
    });

    mLastUpdateTimeView = (TextView) mView.findViewById(R.id.last_upload_time_value);
    mAllTimeObservationsSentView = (TextView) mView.findViewById(R.id.observations_sent_value);
    mQueuedObservationsView = (TextView) mView.findViewById(R.id.observations_queued_value);
    mThisSessionObservationsView = (TextView) mView.findViewById(R.id.this_session_observations_value);
    mThisSessionUniqueCellsView = (TextView) mView.findViewById(R.id.cells_unique_value);
    mThisSessionUniqueAPsView = (TextView) mView.findViewById(R.id.wifis_unique_value);

    mUploadButton = (ImageButton) mView.findViewById(R.id.upload_observations_button);
    mUploadButton.setEnabled(false);
    mUploadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mHasQueuedObservations) {
                return;
            }

            AsyncUploader uploader = new AsyncUploader();
            AsyncUploadParam param = new AsyncUploadParam(false /* useWifiOnly */,
                    Prefs.getInstance(mView.getContext()).getNickname(),
                    Prefs.getInstance(mView.getContext()).getEmail());
            uploader.execute(param);

            setUploadButtonToSyncing(true);
        }
    });

    mSettingsButton = (ImageButton) mView.findViewById(R.id.metrics_settings_button);
    mSettingsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Activity mainDrawer = (Activity) v.getContext();
            assert (mainDrawer instanceof MainDrawerActivity);
            mainDrawer.startActivityForResult(new Intent(v.getContext(), PreferencesScreen.class), 1);
        }
    });

    // Remove click listener of the Drawer buttons container to avoid to get it triggered on the Map view
    mButtonsContainer = (RelativeLayout) mView.findViewById(R.id.metrics_buttons_container);
    mButtonsContainer.setOnClickListener(null);

    mHandler.postDelayed(mUpdateLastUploadedLabel, FREQ_UPDATE_UPLOADTIME);

    Button showPowerButton = (Button) mView.findViewById(R.id.button_change_power_setting);
    if (Build.VERSION.SDK_INT >= 16) {
        Drawable clone = showPowerButton.getBackground().getConstantState().newDrawable();
        clone.setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFF106E99));
        showPowerButton.setBackground(clone);
    }
    showPowerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Activity mainDrawer = (Activity) v.getContext();
            assert (mainDrawer instanceof MainDrawerActivity);
            mainDrawer.startActivityForResult(new Intent(v.getContext(), PowerSavingScreen.class), 1);
        }
    });
}

From source file:br.com.mauker.materialseekbar.PinView.java

public void setColor(int circleColor) {
    mCirclePaint.setColor(circleColor);
    mPinFilter = new LightingColorFilter(circleColor, circleColor);
}

From source file:com.paranoid.ParanoidWallpapers.Wallpaper.java

private Bitmap getColoredBitmap(Bitmap src, int color) {
    int width = src.getWidth();
    int height = src.getHeight();

    Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);

    Canvas canvas = new Canvas(dest);
    Paint paint = new Paint();

    try {/*from  ww  w .  j ava 2  s . com*/
        Mode m = (Mode) Mode.class.getField("OVERLAY").get(null);
        paint.setColorFilter(new PorterDuffColorFilter(color, m));
    } catch (Exception e) {
        paint = new Paint();
        ColorFilter filter = new LightingColorFilter(color, 1);
        paint.setColorFilter(filter);
    }
    canvas.drawBitmap(src, 0, 0, paint);

    return dest;
}