List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.klinker.android.launcher.launcher3.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused./*from www .ja v a 2 s . c o m*/ */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mOutlineHelper = HolographicOutlineHelper.obtain(context); mLauncher = (Launcher) context; mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this); final Resources res = getResources(); DeviceProfile grid = mLauncher.getDeviceProfile(); mWorkspaceFadeInAdjacentScreens = grid.shouldFadeAdjacentWorkspaceScreens(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(mIsRtl); mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); mDetector = new GestureDetectorCompat(context, new MyGestureListener()); }
From source file:com.commonsware.cwac.crossport.design.widget.TabLayout.java
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); super.addView(mTabStrip, 0, new HorizontalScrollView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight(a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart); mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, R.styleable.TextAppearance); try {/* w ww . j av a 2 s . c o m*/ mTabTextSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta.getColorStateList(R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); // TODO add attr for these final Resources res = getResources(); mTabTextMultiLineSize = res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:com.bang.launcher3.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused.//from w w w . j a v a2 s .c o m */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOutlineHelper = HolographicOutlineHelper.obtain(context); mDragEnforcer = new DropTarget.DragEnforcer(context); // With workspace, data is available straight from the get-go setDataIsReady(); mLauncher = (Launcher) context; final Resources res = getResources(); mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f; mOverviewModePageOffset = res.getDimensionPixelSize(R.dimen.overview_mode_page_offset); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); }
From source file:cc.flydev.launcher.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused./* ww w. j a v a 2 s . c om*/ */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOutlineHelper = HolographicOutlineHelper.obtain(context); mDragEnforcer = new DropTarget.DragEnforcer(context); // With workspace, data is available straight from the get-go setDataIsReady(); mLauncher = (Launcher) context; final Resources res = getResources(); mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = res.getInteger(R.integer.config_workspaceOverviewShrinkPercentage) / 100.0f; mOverviewModePageOffset = res.getDimensionPixelSize(R.dimen.overview_mode_page_offset); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); mOriginalDefaultPage = mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); }
From source file:android.support.design.widget.TabLayout.java
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Add the TabStrip mTabStrip = new SlidingTabStrip(context); super.addView(mTabStrip, 0, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout, defStyleAttr, R.style.Widget_Design_TabLayout); mTabStrip.setSelectedIndicatorHeight(a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0)); mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0)); mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a .getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0); mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart, mTabPaddingStart); mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop, mTabPaddingTop); mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd, mTabPaddingEnd); mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom, mTabPaddingBottom); mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab); // Text colors/sizes come from the text appearance first final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance, android.support.v7.appcompat.R.styleable.TextAppearance); try {// ww w .jav a 2s . c om mTabTextSize = ta.getDimensionPixelSize( android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, 0); mTabTextColors = ta .getColorStateList(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor); } finally { ta.recycle(); } if (a.hasValue(R.styleable.TabLayout_tabTextColor)) { // If we have an explicit text color set, use it instead mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor); } if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) { // We have an explicit selected text color set, so we need to make merge it with the // current colors. This is exposed so that developers can use theme attributes to set // this (theme attrs in ColorStateLists are Lollipop+) final int selected = a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0); mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected); } mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth, INVALID_WIDTH); mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth, INVALID_WIDTH); mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0); mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0); mMode = a.getInt(R.styleable.TabLayout_tabMode, MODE_FIXED); mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, GRAVITY_FILL); a.recycle(); // TODO add attr for these final Resources res = getResources(); mTabTextMultiLineSize = res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line); mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width); // Now apply the tab mode and gravity applyModeAndGravity(); }
From source file:android.content.pm.PackageParser.java
private boolean parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs, boolean allowGlobs, boolean allowAutoVerify, IntentInfo outInfo, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestIntentFilter); int priority = sa.getInt(com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0); outInfo.setPriority(priority);//from w ww .j a v a 2 s .c o m TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestIntentFilter_label); if (v != null && (outInfo.labelRes = v.resourceId) == 0) { outInfo.nonLocalizedLabel = v.coerceToString(); } outInfo.icon = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_icon, 0); outInfo.logo = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0); outInfo.banner = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_banner, 0); if (allowAutoVerify) { outInfo.setAutoVerify( sa.getBoolean(com.android.internal.R.styleable.AndroidManifestIntentFilter_autoVerify, false)); } sa.recycle(); int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } String nodeName = parser.getName(); if (nodeName.equals("action")) { String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name"); if (value == null || value == "") { outError[0] = "No value supplied for <android:name>"; return false; } XmlUtils.skipCurrentTag(parser); outInfo.addAction(value); } else if (nodeName.equals("category")) { String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name"); if (value == null || value == "") { outError[0] = "No value supplied for <android:name>"; return false; } XmlUtils.skipCurrentTag(parser); outInfo.addCategory(value); } else if (nodeName.equals("data")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestData); String str = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestData_mimeType, 0); if (str != null) { try { outInfo.addDataType(str); } catch (IntentFilter.MalformedMimeTypeException e) { outError[0] = e.toString(); sa.recycle(); return false; } } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_scheme, 0); if (str != null) { outInfo.addDataScheme(str); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_ssp, 0); if (str != null) { outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_LITERAL); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPrefix, 0); if (str != null) { outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_PREFIX); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPattern, 0); if (str != null) { if (!allowGlobs) { outError[0] = "sspPattern not allowed here; ssp must be literal"; return false; } outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_SIMPLE_GLOB); } String host = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_host, 0); String port = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_port, 0); if (host != null) { outInfo.addDataAuthority(host, port); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_path, 0); if (str != null) { outInfo.addDataPath(str, PatternMatcher.PATTERN_LITERAL); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPrefix, 0); if (str != null) { outInfo.addDataPath(str, PatternMatcher.PATTERN_PREFIX); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPattern, 0); if (str != null) { if (!allowGlobs) { outError[0] = "pathPattern not allowed here; path must be literal"; return false; } outInfo.addDataPath(str, PatternMatcher.PATTERN_SIMPLE_GLOB); } sa.recycle(); XmlUtils.skipCurrentTag(parser); } else if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <intent-filter>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); } else { outError[0] = "Bad element under <intent-filter>: " + parser.getName(); return false; } } outInfo.hasDefault = outInfo.hasCategory(Intent.CATEGORY_DEFAULT); if (DEBUG_PARSER) { final StringBuilder cats = new StringBuilder("Intent d="); cats.append(outInfo.hasDefault); cats.append(", cat="); final Iterator<String> it = outInfo.categoriesIterator(); if (it != null) { while (it.hasNext()) { cats.append(' '); cats.append(it.next()); } } Slog.d(TAG, cats.toString()); } return true; }
From source file:com.facebook.litho.InternalNode.java
void applyAttributes(TypedArray a) { for (int i = 0, size = a.getIndexCount(); i < size; i++) { final int attr = a.getIndex(i); if (attr == R.styleable.ComponentLayout_android_layout_width) { int width = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (width >= 0) { widthPx(width);// w w w.j a va2 s . c om } } else if (attr == R.styleable.ComponentLayout_android_layout_height) { int height = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (height >= 0) { heightPx(height); } } else if (attr == R.styleable.ComponentLayout_android_paddingLeft) { paddingPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingTop) { paddingPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingRight) { paddingPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingBottom) { paddingPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingStart && SUPPORTS_RTL) { paddingPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingEnd && SUPPORTS_RTL) { paddingPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_padding) { paddingPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginLeft) { marginPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginTop) { marginPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginRight) { marginPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginBottom) { marginPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginStart && SUPPORTS_RTL) { marginPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginEnd && SUPPORTS_RTL) { marginPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_margin) { marginPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_importantForAccessibility && SDK_INT >= JELLY_BEAN) { importantForAccessibility(a.getInt(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_duplicateParentState) { duplicateParentState(a.getBoolean(attr, false)); } else if (attr == R.styleable.ComponentLayout_android_background) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_background)) { backgroundColor(a.getColor(attr, 0)); } else { backgroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_foreground) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_foreground)) { foregroundColor(a.getColor(attr, 0)); } else { foregroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_contentDescription) { contentDescription(a.getString(attr)); } else if (attr == R.styleable.ComponentLayout_flex_direction) { flexDirection(YogaFlexDirection.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_wrap) { wrap(YogaWrap.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_justifyContent) { justifyContent(YogaJustify.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignItems) { alignItems(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignSelf) { alignSelf(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_positionType) { positionType(YogaPositionType.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex) { final float flex = a.getFloat(attr, -1); if (flex >= 0f) { flex(flex); } } else if (attr == R.styleable.ComponentLayout_flex_left) { positionPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_top) { positionPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_right) { positionPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_bottom) { positionPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_layoutDirection) { final int layoutDirection = a.getInteger(attr, -1); layoutDirection(YogaDirection.fromInt(layoutDirection)); } } }
From source file:com.phonemetra.turbo.launcher.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused./*from w ww. j a v a 2s .co m*/ */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOutlineHelper = HolographicOutlineHelper.obtain(context); mDragEnforcer = new DropTarget.DragEnforcer(context); // With workspace, data is available straight from the get-go setDataIsReady(); mShowSearchBar = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH, R.bool.preferences_interface_homescreen_search_default); mShowOutlines = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_PAGE_OUTLINES, R.bool.preferences_interface_homescreen_scrolling_page_outlines_default); mHideIconLabels = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, R.bool.preferences_interface_homescreen_hide_icon_labels_default); mWorkspaceFadeInAdjacentScreens = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_FADE_ADJACENT, R.bool.preferences_interface_homescreen_scrolling_fade_adjacent_default); TransitionEffect.setFromString(this, SettingsProvider.getString(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_TRANSITION_EFFECT, R.string.preferences_interface_homescreen_scrolling_transition_effect)); mLauncher = (Launcher) context; final Resources res = getResources(); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mOverviewModeShrinkFactor = grid.getOverviewModeScale(); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); mDefaultScreenId = SettingsProvider.getLongCustomDefault(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, -1); a.recycle(); setOnHierarchyChangeListener(this); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); }
From source file:android.content.pm.PackageParser.java
private FeatureInfo parseUsesFeature(Resources res, AttributeSet attrs) throws XmlPullParserException, IOException { FeatureInfo fi = new FeatureInfo(); TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesFeature); // Note: don't allow this value to be a reference to a resource // that may change. fi.name = sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesFeature_name); if (fi.name == null) { fi.reqGlEsVersion = sa.getInt(com.android.internal.R.styleable.AndroidManifestUsesFeature_glEsVersion, FeatureInfo.GL_ES_VERSION_UNDEFINED); }//from w w w . ja v a2s. co m if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesFeature_required, true)) { fi.flags |= FeatureInfo.FLAG_REQUIRED; } sa.recycle(); return fi; }
From source file:com.android.launcher2.Workspace.java
/** * Used to inflate the Workspace from XML. * * @param context The application's context. * @param attrs The attributes set containing the Workspace's customization values. * @param defStyle Unused./*ww w. j a va2s .com*/ */ public Workspace(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContentIsRefreshable = false; mOriginalPageSpacing = mPageSpacing; mDragEnforcer = new DropTarget.DragEnforcer(context); // With workspace, data is available straight from the get-go setDataIsReady(); mLauncher = (Launcher) context; final Resources res = getResources(); mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens); mFadeInAdjacentScreens = false; mWallpaperManager = WallpaperManager.getInstance(context); int cellCountX = DEFAULT_CELL_COUNT_X; int cellCountY = DEFAULT_CELL_COUNT_Y; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Workspace, defStyle, 0); if (LauncherApplication.isScreenLarge()) { // Determine number of rows/columns dynamically // TODO: This code currently fails on tablets with an aspect ratio < 1.3. // Around that ratio we should make cells the same size in portrait and // landscape TypedArray actionBarSizeTypedArray = context .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); final float actionBarHeight = actionBarSizeTypedArray.getDimension(0, 0f); Point minDims = new Point(); Point maxDims = new Point(); DisplayCompt.getCurrentSizeRange(mLauncher.getWindowManager().getDefaultDisplay(), minDims, maxDims); cellCountX = 1; while (CellLayout.widthInPortrait(res, cellCountX + 1) <= minDims.x) { cellCountX++; } cellCountY = 1; while (actionBarHeight + CellLayout.heightInLandscape(res, cellCountY + 1) <= minDims.y) { cellCountY++; } } mSpringLoadedShrinkFactor = res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; mSpringLoadedPageSpacing = res.getDimensionPixelSize(R.dimen.workspace_spring_loaded_page_spacing); mCameraDistance = res.getInteger(R.integer.config_cameraDistance); // if the value is manually specified, use that instead cellCountX = a.getInt(R.styleable.Workspace_cellCountX, cellCountX); cellCountY = a.getInt(R.styleable.Workspace_cellCountY, cellCountY); mDefaultPage = a.getInt(R.styleable.Workspace_defaultScreen, 1); a.recycle(); setOnHierarchyChangeListener(this); LauncherModel.updateWorkspaceLayoutCells(cellCountX, cellCountY); setHapticFeedbackEnabled(false); initWorkspace(); // Disable multitouch across the workspace/all apps/customize tray setMotionEventSplittingEnabled(true); // Unless otherwise specified this view is important for accessibility. if (ViewCompat.getImportantForAccessibility(this) == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, View.IMPORTANT_FOR_ACCESSIBILITY_YES); } }