List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:com.mukesh.OtpView.java
public OtpView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final Resources res = getResources(); paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.STROKE); animatorTextPaint.set(getPaint());//from ww w .j av a 2s .co m final Resources.Theme theme = context.getTheme(); TypedArray typedArray = theme.obtainStyledAttributes(attrs, R.styleable.OtpView, defStyleAttr, 0); viewType = typedArray.getInt(R.styleable.OtpView_viewType, VIEW_TYPE_RECTANGLE); otpViewItemCount = typedArray.getInt(R.styleable.OtpView_itemCount, DEFAULT_COUNT); otpViewItemHeight = (int) typedArray.getDimension(R.styleable.OtpView_itemHeight, res.getDimensionPixelSize(R.dimen.otp_view_item_size)); otpViewItemWidth = (int) typedArray.getDimension(R.styleable.OtpView_itemWidth, res.getDimensionPixelSize(R.dimen.otp_view_item_size)); otpViewItemSpacing = typedArray.getDimensionPixelSize(R.styleable.OtpView_itemSpacing, res.getDimensionPixelSize(R.dimen.otp_view_item_spacing)); otpViewItemRadius = (int) typedArray.getDimension(R.styleable.OtpView_itemRadius, 0); lineWidth = (int) typedArray.getDimension(R.styleable.OtpView_lineWidth, res.getDimensionPixelSize(R.dimen.otp_view_item_line_width)); lineColor = typedArray.getColorStateList(R.styleable.OtpView_lineColor); isCursorVisible = typedArray.getBoolean(R.styleable.OtpView_android_cursorVisible, true); cursorColor = typedArray.getColor(R.styleable.OtpView_cursorColor, getCurrentTextColor()); cursorWidth = typedArray.getDimensionPixelSize(R.styleable.OtpView_cursorWidth, res.getDimensionPixelSize(R.dimen.otp_view_cursor_width)); itemBackground = typedArray.getDrawable(R.styleable.OtpView_android_itemBackground); hideLineWhenFilled = typedArray.getBoolean(R.styleable.OtpView_hideLineWhenFilled, false); rtlTextDirection = typedArray.getBoolean(R.styleable.OtpView_rtlTextDirection, false); typedArray.recycle(); if (lineColor != null) { cursorLineColor = lineColor.getDefaultColor(); } updateCursorHeight(); checkItemRadius(); setMaxLength(otpViewItemCount); paint.setStrokeWidth(lineWidth); setupAnimator(); super.setCursorVisible(false); setTextIsSelectable(false); }
From source file:eu.faircode.netguard.AdapterLog.java
public AdapterLog(Context context, Cursor cursor, boolean resolve, boolean organization) { super(context, cursor, 0); this.resolve = resolve; this.organization = organization; colTime = cursor.getColumnIndex("time"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colFlags = cursor.getColumnIndex("flags"); colSAddr = cursor.getColumnIndex("saddr"); colSPort = cursor.getColumnIndex("sport"); colDAddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colDName = cursor.getColumnIndex("dname"); colUid = cursor.getColumnIndex("uid"); colData = cursor.getColumnIndex("data"); colAllowed = cursor.getColumnIndex("allowed"); colConnection = cursor.getColumnIndex("connection"); colInteractive = cursor.getColumnIndex("interactive"); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data;/*from ww w .j a v a 2s . c om*/ context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; iconSize = Util.dips2pixels(24, context); try { List<InetAddress> lstDns = ServiceSinkhole.getDns(context); dns1 = (lstDns.size() > 0 ? lstDns.get(0) : null); dns2 = (lstDns.size() > 1 ? lstDns.get(1) : null); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:com.master.metehan.filtereagle.AdapterLog.java
public AdapterLog(Context context, Cursor cursor, boolean resolve, boolean organization) { super(context, cursor, 0); this.resolve = resolve; this.organization = organization; colID = cursor.getColumnIndex("ID"); colTime = cursor.getColumnIndex("time"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colFlags = cursor.getColumnIndex("flags"); colSAddr = cursor.getColumnIndex("saddr"); colSPort = cursor.getColumnIndex("sport"); colDAddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colDName = cursor.getColumnIndex("dname"); colUid = cursor.getColumnIndex("uid"); colData = cursor.getColumnIndex("data"); colAllowed = cursor.getColumnIndex("allowed"); colConnection = cursor.getColumnIndex("connection"); colInteractive = cursor.getColumnIndex("interactive"); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data;//from www . j a v a 2s . com context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; iconSize = Util.dips2pixels(24, context); try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); dns = ServiceSinkhole.getDns(context).get(0); vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:com.github.cpmproto.categorystepfragment.base.GuidedStepListFragment.java
/** * {@inheritDoc}//from w w w . j a v a 2s. c om */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (DEBUG) Log.v(TAG, "onCreateView"); resolveTheme(); inflater = getThemeInflater(inflater); rootLayout = (GuidedStepRootLayout) inflater.inflate(R.layout.lb_guidedstep_fragment, container, false); rootLayout.setFocusOutStart(isFocusOutStartAllowed()); rootLayout.setFocusOutEnd(isFocusOutEndAllowed()); rootLayout.setBackgroundColor(Color.TRANSPARENT); rootLayout.setOnKeyPress(this); ViewGroup guidanceContainer = (ViewGroup) rootLayout.findViewById(R.id.content_fragment); guidanceContainer.setVisibility(View.INVISIBLE); ViewGroup actionContainer = (ViewGroup) rootLayout.findViewById(R.id.action_fragment); View actionsView = mActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(actionsView); View buttonActionsView = mButtonActionsStylist.onCreateView(inflater, actionContainer); actionContainer.addView(buttonActionsView); GuidedActionAdapter.EditListener editListener = new GuidedActionAdapter.EditListener() { @Override public void onImeOpen() { runImeAnimations(true); } @Override public void onImeClose() { runImeAnimations(false); } @Override public long onGuidedActionEditedAndProceed(GuidedAction action) { return GuidedStepListFragment.this.onGuidedActionEditedAndProceed(action); } @Override public void onGuidedActionEditCanceled(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionEditCanceled(action); } }; mAdapter = new GuidedActionAdapter(getActionsByKey(), new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionClicked(action); if (isSubActionsExpanded()) { collapseSubActions(); } else if (action.hasSubActions()) { expandSubActions(action); } } }, this, mActionsStylist, false); mButtonAdapter = new GuidedActionAdapter(mButtonActions, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { GuidedStepListFragment.this.onGuidedActionClicked(action); } }, this, mButtonActionsStylist, false); mSubAdapter = new GuidedActionAdapter(null, new GuidedActionAdapter.ClickListener() { @Override public void onGuidedActionClicked(GuidedAction action) { if (mActionsStylist.isInExpandTransition()) { return; } if (GuidedStepListFragment.this.onSubGuidedActionClicked(action)) { collapseSubActions(); } rootLayout.setOnSubcategoryfocus(false); setActions(mActions, action.toString()); } }, this, mActionsStylist, true); mAdapterGroup = new GuidedActionAdapterGroup(); mAdapterGroup.addAdpter(mAdapter, mButtonAdapter); mAdapterGroup.addAdpter(mSubAdapter, null); mAdapterGroup.setEditListener(editListener); mActionsStylist.setEditListener(editListener); mActionsStylist.getActionsGridView().setAdapter(mAdapter); if (mActionsStylist.getSubActionsGridView() != null) { mActionsStylist.getSubActionsGridView().setAdapter(mSubAdapter); } mButtonActionsStylist.getActionsGridView().setAdapter(mButtonAdapter); if (mButtonActions.size() == 0) { // when there is no button actions, we don't need show the second panel, but keep // the width zero to run ChangeBounds transition. LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) buttonActionsView.getLayoutParams(); lp.weight = 0; buttonActionsView.setLayoutParams(lp); } else { // when there are two actions panel, we need adjust the weight of action to // guidedActionContentWidthWeightTwoPanels. Context ctx = mThemeWrapper != null ? mThemeWrapper : getActivity(); TypedValue typedValue = new TypedValue(); if (ctx.getTheme().resolveAttribute(R.attr.guidedActionContentWidthWeightTwoPanels, typedValue, true)) { View actionsRoot = rootLayout.findViewById(R.id.action_fragment_root); float weight = typedValue.getFloat(); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionsRoot.getLayoutParams(); lp.weight = weight; actionsRoot.setLayoutParams(lp); } } int pos = (mSelectedIndex >= 0 && mSelectedIndex < mActions.size()) ? mSelectedIndex : getFirstCheckedAction(); setSelectedActionPosition(pos); setSelectedButtonActionPosition(0); return rootLayout; }
From source file:android_network.hetnet.vpn_service.AdapterLog.java
public AdapterLog(Context context, Cursor cursor, boolean resolve, boolean organization) { super(context, cursor, 0); this.resolve = resolve; this.organization = organization; colID = cursor.getColumnIndex("ID"); colTime = cursor.getColumnIndex("time"); colVersion = cursor.getColumnIndex("version"); colProtocol = cursor.getColumnIndex("protocol"); colFlags = cursor.getColumnIndex("flags"); colSAddr = cursor.getColumnIndex("saddr"); colSPort = cursor.getColumnIndex("sport"); colDAddr = cursor.getColumnIndex("daddr"); colDPort = cursor.getColumnIndex("dport"); colDName = cursor.getColumnIndex("dname"); colUid = cursor.getColumnIndex("uid"); colData = cursor.getColumnIndex("data"); colAllowed = cursor.getColumnIndex("allowed"); colConnection = cursor.getColumnIndex("connection"); colInteractive = cursor.getColumnIndex("interactive"); TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(R.attr.colorOn, tv, true); colorOn = tv.data;/*from w w w.j a v a 2 s . c o m*/ context.getTheme().resolveAttribute(R.attr.colorOff, tv, true); colorOff = tv.data; iconSize = Util.dips2pixels(24, context); try { List<InetAddress> lstDns = ServiceSinkhole.getDns(context); dns1 = (lstDns.size() > 0 ? lstDns.get(0) : null); dns2 = (lstDns.size() > 1 ? lstDns.get(1) : null); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1")); vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1")); } catch (UnknownHostException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
/** * Sets states of check mark view, called by {@link #onBindViewHolder(ViewHolder, GuidedAction)} * when action's checkset Id is other than {@link GuidedAction#NO_CHECK_SET}. Default * implementation assigns drawable loaded from theme attribute * {@link android.R.attr#listChoiceIndicatorMultiple} for checkbox or * {@link android.R.attr#listChoiceIndicatorSingle} for radio button. Subclass rarely needs * override the method, instead app can provide its own drawable that supports transition * animations, change theme attributes {@link android.R.attr#listChoiceIndicatorMultiple} and * {@link android.R.attr#listChoiceIndicatorSingle} in {android.support.v17.leanback.R. * styleable#LeanbackGuidedStepTheme}./*from w w w . jav a 2 s .c o m*/ * * @param vh The view holder associated with the relevant action. * @param action The GuidedAction object to bind to. * @see #onAnimateItemChecked(ViewHolder, boolean) */ public void onBindCheckMarkView(ViewHolder vh, GuidedAction action) { if (action.getCheckSetId() != GuidedAction.NO_CHECK_SET) { vh.mCheckmarkView.setVisibility(View.VISIBLE); int attrId = action.getCheckSetId() == GuidedAction.CHECKBOX_CHECK_SET_ID ? android.R.attr.listChoiceIndicatorMultiple : android.R.attr.listChoiceIndicatorSingle; final Context context = vh.mCheckmarkView.getContext(); Drawable drawable = null; TypedValue typedValue = new TypedValue(); if (context.getTheme().resolveAttribute(attrId, typedValue, true)) { drawable = ContextCompat.getDrawable(context, typedValue.resourceId); } vh.mCheckmarkView.setImageDrawable(drawable); if (vh.mCheckmarkView instanceof Checkable) { ((Checkable) vh.mCheckmarkView).setChecked(action.isChecked()); } } else { vh.mCheckmarkView.setVisibility(View.GONE); } }
From source file:com.roughike.bottombar.BottomBar.java
private void populateAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { primaryColor = MiscUtils.getColor(getContext(), R.attr.colorPrimary); screenWidth = MiscUtils.getScreenWidth(getContext()); tenDp = MiscUtils.dpToPixel(getContext(), 10); maxFixedItemWidth = MiscUtils.dpToPixel(getContext(), 168); TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BottomBar, defStyleAttr, defStyleRes);/* ww w .j a v a2s. c o m*/ try { tabXmlResource = ta.getResourceId(R.styleable.BottomBar_bb_tabXmlResource, 0); isTabletMode = ta.getBoolean(R.styleable.BottomBar_bb_tabletMode, false); behaviors = ta.getInteger(R.styleable.BottomBar_bb_behavior, BEHAVIOR_NONE); inActiveTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_inActiveTabAlpha, isShiftingMode() ? DEFAULT_INACTIVE_SHIFTING_TAB_ALPHA : 1); activeTabAlpha = ta.getFloat(R.styleable.BottomBar_bb_activeTabAlpha, 1); @ColorInt int defaultInActiveColor = isShiftingMode() ? Color.WHITE : ContextCompat.getColor(context, R.color.bb_inActiveBottomBarItemColor); int defaultActiveColor = isShiftingMode() ? Color.WHITE : primaryColor; longPressHintsEnabled = ta.getBoolean(R.styleable.BottomBar_bb_longPressHintsEnabled, true); inActiveTabColor = ta.getColor(R.styleable.BottomBar_bb_inActiveTabColor, defaultInActiveColor); activeTabColor = ta.getColor(R.styleable.BottomBar_bb_activeTabColor, defaultActiveColor); badgeBackgroundColor = ta.getColor(R.styleable.BottomBar_bb_badgeBackgroundColor, Color.RED); hideBadgeWhenActive = ta.getBoolean(R.styleable.BottomBar_bb_badgesHideWhenActive, true); titleTextAppearance = ta.getResourceId(R.styleable.BottomBar_bb_titleTextAppearance, 0); titleTypeFace = getTypeFaceFromAsset(ta.getString(R.styleable.BottomBar_bb_titleTypeFace)); showShadow = ta.getBoolean(R.styleable.BottomBar_bb_showShadow, true); } finally { ta.recycle(); } }
From source file:com.wit.and.dialog.internal.BaseDialog.java
/** *//* w w w. j av a 2 s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check bundle. if (savedInstanceState != null) { // Check if we should dismiss the dialog. if (savedInstanceState.getBoolean(BUNDLE_DISMISS_AFTER_RECREATE, false)) { this.dismissAllowingStateLoss(); } // Recreate dialog options. this.createOptions(savedInstanceState); // Restore dialog theme. if (savedInstanceState.containsKey(BUNDLE_DIALOG_THEME)) { mDialogTheme = savedInstanceState.getInt(BUNDLE_DIALOG_THEME); } } else { // Create dialog options from arguments. this.createOptions(this.getArguments()); /** * Dialog theme priority (from the highest to the lowest): * <ul> * <li>1) Custom theme (set by setStyle())</li> * <li>2) Custom theme (obtained form dialog options)</li> * <li>3) Custom theme (obtained from the activity/application theme)</li> * <li>4) Default theme</li> * </ul> */ if (bObtainOuterStyle) { // Style wasn't set by setStyle() method, check for theme in dialog options. mDialogTheme = mOptions.getDialogTheme(); if (mDialogTheme <= 0) { // Dialog options doesn't contains valid dialog theme. mDialogTheme = R.style.And_Theme_Dialog; // Get dialog theme from application theme. final Context context = getActivity(); final Resources.Theme theme = context.getTheme(); if (theme != null) { final TypedArray styleArray = theme .obtainStyledAttributes(new int[] { R.attr.dialogTheme }); if (styleArray != null) { mDialogTheme = styleArray.getResourceId(0, mDialogTheme); styleArray.recycle(); } } } } } // Set super theme. super.setStyle(Dialog.STYLE_NO_FRAME, mDialogTheme); this.bObtainOuterStyle = false; }
From source file:com.miz.functions.MizLib.java
public static int getActionBarHeight(Context c) { int actionBarHeight = 0; TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); else/*from w w w . j a va 2 s. c o m*/ actionBarHeight = 0; // No ActionBar style (pre-Honeycomb or ActionBar not in theme) return actionBarHeight; }
From source file:org.kde.necessitas.ministro.ExtractStyle.java
public ExtractStyle(Context context, String extractPath) { m_extractPath = extractPath;//ww w . ja v a 2 s. com new File(m_extractPath).mkdirs(); MinistroActivity.nativeChmode(m_extractPath, 0755); m_context = context; m_theme = context.getTheme(); JSONObject json = new JSONObject(); try { json.put("buttonStyle", extractTextAppearanceInformations("buttonStyle", "QPushButton", null, -1)); json.put("spinnerStyle", extractTextAppearanceInformations("spinnerStyle", "QComboBox", null, -1)); extractProgressBar(json, "progressBarStyleHorizontal", "QProgressBar"); extractAbsSeekBar(json, "seekBarStyle", "QSlider"); extractCompoundButton(json, "checkboxStyle", "QCheckBox"); json.put("editTextStyle", extractTextAppearanceInformations("editTextStyle", "QLineEdit", null, -1)); extractCompoundButton(json, "radioButtonStyle", "QRadioButton"); json.put("textViewStyle", extractTextAppearanceInformations("textViewStyle", "QWidget", null, -1)); extractItemsStyle(json); //extractCompoundButton(json, "buttonStyleToggle", null); //extractCompoundButton(json, "switchStyle", null); //json.put("imageButtonStyle", extractImageViewInformations("imageButtonStyle", null)); OutputStreamWriter jsonWriter; jsonWriter = new OutputStreamWriter(new FileOutputStream(m_extractPath + "style.json")); jsonWriter.write(json.toString(1)); jsonWriter.close(); MinistroActivity.nativeChmode(m_extractPath + "style.json", 0644); } catch (Exception e) { e.printStackTrace(); } }