List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:android_network.hetnet.vpn_service.AdapterAccess.java
public AdapterAccess(Context context, Cursor cursor) { super(context, cursor, 0); colID = cursor.getColumnIndex("ID"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colDaddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colTime = cursor.getColumnIndex("time"); colAllowed = cursor.getColumnIndex("allowed"); colBlock = cursor.getColumnIndex("block"); colSent = cursor.getColumnIndex("sent"); colReceived = cursor.getColumnIndex("received"); colConnections = cursor.getColumnIndex("connections"); TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorSecondary }); try {/*from www. ja v a 2 s. c o m*/ colorText = ta.getColor(0, 0); } finally { ta.recycle(); } TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data; context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; }
From source file:eu.faircode.netguard.AdapterAccess.java
public AdapterAccess(Context context, Cursor cursor) { super(context, cursor, 0); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colDaddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colTime = cursor.getColumnIndex("time"); colAllowed = cursor.getColumnIndex("allowed"); colBlock = cursor.getColumnIndex("block"); colCount = cursor.getColumnIndex("count"); colSent = cursor.getColumnIndex("sent"); colReceived = cursor.getColumnIndex("received"); colConnections = cursor.getColumnIndex("connections"); TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorSecondary }); try {//from ww w. j av a 2 s .c o m colorText = ta.getColor(0, 0); } finally { ta.recycle(); } TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data; context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; }
From source file:android.support.v7.app.ToolbarActionBar.java
private void ensureListMenuPresenter(Menu menu) { if (mListMenuPresenter == null && (menu instanceof MenuBuilder)) { MenuBuilder mb = (MenuBuilder) menu; Context context = mDecorToolbar.getContext(); final TypedValue outValue = new TypedValue(); final Resources.Theme widgetTheme = context.getResources().newTheme(); widgetTheme.setTo(context.getTheme()); // First apply the actionBarPopupTheme widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); }/* w w w .j a v a2s . c om*/ // Apply the panelMenuListTheme widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); } else { widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true); } context = new ContextThemeWrapper(context, 0); context.getTheme().setTo(widgetTheme); // Finally create the list menu presenter mListMenuPresenter = new ListMenuPresenter(context, R.layout.abc_list_menu_item_layout); mListMenuPresenter.setCallback(new PanelMenuPresenterCallback()); mb.addMenuPresenter(mListMenuPresenter); } }
From source file:android.support.v7ox.app.ToolbarActionBar.java
private void ensureListMenuPresenter(Menu menu) { if (mListMenuPresenter == null && (menu instanceof MenuBuilder)) { MenuBuilder mb = (MenuBuilder) menu; Context context = mDecorToolbar.getContext(); final TypedValue outValue = new TypedValue(); final Resources.Theme widgetTheme = context.getResources().newTheme(); widgetTheme.setTo(context.getTheme()); // First apply the actionBarPopupTheme widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme_ox, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); }/*from w ww. j av a 2 s .co m*/ // Apply the panelMenuListTheme widgetTheme.resolveAttribute(R.attr.panelMenuListTheme_ox, outValue, true); if (outValue.resourceId != 0) { widgetTheme.applyStyle(outValue.resourceId, true); } else { widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true); } context = new ContextThemeWrapper(context, 0); context.getTheme().setTo(widgetTheme); // Finally create the list menu presenter mListMenuPresenter = new ListMenuPresenter(context, R.layout.abc_list_menu_item_layout); mListMenuPresenter.setCallback(new PanelMenuPresenterCallback()); mb.addMenuPresenter(mListMenuPresenter); } }
From source file:com.osacky.umbrella.widget.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//w w w .j a v a 2 s. co m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTextColor(getResources().getColorStateList(R.color.tabs_color)); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); Utils.setMediumTypeface(textView); TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } final float density = getResources().getDisplayMetrics().density; int paddingVertical = (int) (TAB_VIEW_PADDING_VERTICAL_DIPS * density); int paddingHorizontal = (int) (TAB_VIEW_PADDING_HORIZONTAL_DIPS * density); textView.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical); return textView; }
From source file:com.appsummary.luoxf.myappsummary.recyclerView.fastscroll.Views.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w ww .ja v a 2s . co m mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = Utils.toPixels(resources, 48); mWidth = Utils.toPixels(resources, 8); mTouchInset = Utils.toPixels(resources, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:life.knowledge4.videotrimmer.K4LVideoTrimmer.java
public K4LVideoTrimmer(@NonNull Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.trimmer, 0, 0); mProgressDrawable = a.getResourceId(R.styleable.trimmer_seek_drawable, 0); mRangeDrawableLeft = a.getResourceId(R.styleable.trimmer_range_drawableLeft, 0); mRangeDrawableRight = a.getResourceId(R.styleable.trimmer_range_drawableRight, 0); mMaxWidthRangeDrawable = a.getDimensionPixelSize(R.styleable.trimmer_range_drawable_width, context.getResources().getDimensionPixelSize(R.dimen.default_width)); mSeekThumbWidth = a.getDimensionPixelSize(R.styleable.trimmer_seek_drawable_width, context.getResources().getDimensionPixelSize(R.dimen.default_width)); init(context);// w ww . j av a 2s . co m }
From source file:com.bhatworks.android.slidingtab.SlidingTabLayout.java
public SlidingTabLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);//w w w.j ava 2s . c o m mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SlidingTabStrip, 0, 0); try { final int indicatorColor = a.getColor(R.styleable.SlidingTabStrip_indicatorColor, 0); if (indicatorColor != 0) { setSelectedIndicatorColors(new int[] { indicatorColor }); } final ColorStateList textColor = a.getColorStateList(R.styleable.SlidingTabStrip_textColor); if (textColor != null) { setTextColor(textColor); } } finally { a.recycle(); } } }
From source file:com.doodle.android.chips.ChipsView.java
private void initAttr(Context context, AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ChipsView, 0, 0); try {/* ww w. j a va 2s . c o m*/ mMaxHeight = a.getDimensionPixelSize(R.styleable.ChipsView_cv_max_height, DEFAULT_MAX_HEIGHT); mVerticalSpacing = a.getDimensionPixelSize(R.styleable.ChipsView_cv_vertical_spacing, (int) (DEFAULT_VERTICAL_SPACING * mDensity)); mChipsColor = a.getColor(R.styleable.ChipsView_cv_color, ContextCompat.getColor(context, R.color.base30)); mChipsColorClicked = a.getColor(R.styleable.ChipsView_cv_color_clicked, ContextCompat.getColor(context, R.color.colorPrimaryDark)); mChipsColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_color_error_clicked, ContextCompat.getColor(context, R.color.color_error)); mChipsBgColor = a.getColor(R.styleable.ChipsView_cv_bg_color, ContextCompat.getColor(context, R.color.base10)); mChipsBgColorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked, ContextCompat.getColor(context, R.color.blue)); mChipsBgColorIndelible = a.getColor(R.styleable.ChipsView_cv_bg_color_indelible, mChipsBgColor); mChipsBgColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked, ContextCompat.getColor(context, R.color.color_error)); mChipsTextColor = a.getColor(R.styleable.ChipsView_cv_text_color, Color.BLACK); mChipsTextColorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE); mChipsTextColorErrorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE); mChipsTextColorIndelible = a.getColor(R.styleable.ChipsView_cv_text_color_indelible, mChipsTextColor); mChipsPlaceholderResId = a.getResourceId(R.styleable.ChipsView_cv_icon_placeholder, R.drawable.ic_person_24dp); mChipsPlaceholderTint = a.getColor(R.styleable.ChipsView_cv_icon_placeholder_tint, 0); mChipsDeleteResId = a.getResourceId(R.styleable.ChipsView_cv_icon_delete, R.drawable.ic_close_24dp); mChipsHintText = a.getString(R.styleable.ChipsView_cv_text_hint); mChipsMargin = a.getDimensionPixelSize(R.styleable.ChipsView_cv_chips_margin, 0); } finally { a.recycle(); } }
From source file:com.development.jaba.view.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Setup the defaults for the colors. mTitleColor = R.color.slidingTabTitleColor; int titleSelectedColor = R.color.slidingTabSelectedTitleColor; int dividerColor = R.color.slidingTabDividerColor; int indicatorColor = R.color.slidingTabIndicatorColor; // Dig through the attributes to find the colors that were // set through the XML. if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout, 0, 0); try {/*from w w w . j av a2s.co m*/ mTitleColor = a.getColor(R.styleable.SlidingTabLayout_stlTitleColor, mTitleColor); titleSelectedColor = a.getColor(R.styleable.SlidingTabLayout_stlTitleColorSelected, titleSelectedColor); dividerColor = a.getColor(R.styleable.SlidingTabLayout_stlDividerColor, dividerColor); indicatorColor = a.getColor(R.styleable.SlidingTabLayout_stlIndicatorColor, indicatorColor); } catch (Exception e) { Log.e("SlidingTabLayout", "Unable to load attributes"); } finally { a.recycle(); } } // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); mTabStrip.setDividerColors(dividerColor); mTabStrip.setSelectedIndicatorColors(indicatorColor); mTabStrip.setTitleColors(mTitleColor); mTabStrip.setSelectedTitleColors(titleSelectedColor); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }