List of usage examples for android.content.res Resources getBoolean
public boolean getBoolean(@BoolRes int id) throws NotFoundException
From source file:com.ruesga.timelinechart.TimelineChartView.java
private void init(Context ctx, AttributeSet attrs, int defStyleAttr, int defStyleRes) { mUiHandler = new Handler(Looper.getMainLooper(), mMessenger); if (!isInEditMode()) { mAudioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); }//from w ww. j a v a 2 s. c o m final Resources res = getResources(); final Resources.Theme theme = ctx.getTheme(); mTickFormats = getResources().getStringArray(R.array.tlcDefTickLabelFormats); mTickLabels = getResources().getStringArray(R.array.tlcDefTickLabelValues); final DisplayMetrics dp = getResources().getDisplayMetrics(); mSize8 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 8, dp); mSize12 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dp); mSize20 = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, dp); final ViewConfiguration vc = ViewConfiguration.get(ctx); mLongPressTimeout = ViewConfiguration.getLongPressTimeout(); mTouchSlop = vc.getScaledTouchSlop() / 2; mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mScroller = new OverScroller(ctx); int graphBgColor = ContextCompat.getColor(ctx, R.color.tlcDefGraphBackgroundColor); int footerBgColor = ContextCompat.getColor(ctx, R.color.tlcDefFooterBackgroundColor); mDefFooterBarHeight = mFooterBarHeight = res.getDimension(R.dimen.tlcDefFooterBarHeight); mShowFooter = res.getBoolean(R.bool.tlcDefShowFooter); mGraphMode = res.getInteger(R.integer.tlcDefGraphMode); mPlaySelectionSoundEffect = res.getBoolean(R.bool.tlcDefPlaySelectionSoundEffect); mSelectionSoundEffectSource = res.getInteger(R.integer.tlcDefSelectionSoundEffectSource); mAnimateCursorTransition = res.getBoolean(R.bool.tlcDefAnimateCursorTransition); mFollowCursorPosition = res.getBoolean(R.bool.tlcDefFollowCursorPosition); mAlwaysEnsureSelection = res.getBoolean(R.bool.tlcDefAlwaysEnsureSelection); mGraphAreaBgPaint = new Paint(); mGraphAreaBgPaint.setColor(graphBgColor); mFooterAreaBgPaint = new Paint(); mFooterAreaBgPaint.setColor(footerBgColor); mTickLabelFgPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG); mTickLabelFgPaint.setFakeBoldText(true); mTickLabelFgPaint.setColor(MaterialPaletteHelper.isDarkColor(footerBgColor) ? Color.LTGRAY : Color.DKGRAY); mBarItemWidth = res.getDimension(R.dimen.tlcDefBarItemWidth); mBarItemSpace = res.getDimension(R.dimen.tlcDefBarItemSpace); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.tlcTimelineChartView, defStyleAttr, defStyleRes); try { int n = a.getIndexCount(); for (int i = 0; i < n; i++) { int attr = a.getIndex(i); if (attr == R.styleable.tlcTimelineChartView_tlcGraphBackground) { graphBgColor = a.getColor(attr, graphBgColor); mGraphAreaBgPaint.setColor(graphBgColor); } else if (attr == R.styleable.tlcTimelineChartView_tlcShowFooter) { mShowFooter = a.getBoolean(attr, mShowFooter); } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBackground) { footerBgColor = a.getColor(attr, footerBgColor); mFooterAreaBgPaint.setColor(footerBgColor); } else if (attr == R.styleable.tlcTimelineChartView_tlcFooterBarHeight) { mFooterBarHeight = a.getDimension(attr, mFooterBarHeight); } else if (attr == R.styleable.tlcTimelineChartView_tlcGraphMode) { mGraphMode = a.getInt(attr, mGraphMode); } else if (attr == R.styleable.tlcTimelineChartView_tlcAnimateCursorTransition) { mAnimateCursorTransition = a.getBoolean(attr, mAnimateCursorTransition); } else if (attr == R.styleable.tlcTimelineChartView_tlcFollowCursorPosition) { mFollowCursorPosition = a.getBoolean(attr, mFollowCursorPosition); } else if (attr == R.styleable.tlcTimelineChartView_tlcAlwaysEnsureSelection) { mAlwaysEnsureSelection = a.getBoolean(attr, mAlwaysEnsureSelection); } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemWidth) { mBarItemWidth = a.getDimension(attr, mBarItemWidth); } else if (attr == R.styleable.tlcTimelineChartView_tlcBarItemSpace) { mBarItemSpace = a.getDimension(attr, mBarItemSpace); } else if (attr == R.styleable.tlcTimelineChartView_tlcPlaySelectionSoundEffect) { mPlaySelectionSoundEffect = a.getBoolean(attr, mPlaySelectionSoundEffect); } else if (attr == R.styleable.tlcTimelineChartView_tlcSelectionSoundEffectSource) { mSelectionSoundEffectSource = a.getInt(attr, mSelectionSoundEffectSource); } } } finally { a.recycle(); } // SurfaceView requires a background if (getBackground() == null) { setBackgroundColor(ContextCompat.getColor(ctx, android.R.color.transparent)); } // Minimize the impact of create dynamic layouts by assume that in most case // we will have a day formatter mTickHasDayFormat = true; // Initialize stuff setupBackgroundHandler(); setupTickLabels(); if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) { setupEdgeEffects(); } setupAnimators(); setupSoundEffects(); // Initialize the drawing refs (this will be update when we have // the real size of the canvas) computeBoundAreas(); // Create a fake data for the edit mode if (isInEditMode()) { setupViewInEditMode(); } }
From source file:org.pocketworkstation.pckeyboard.LatinIME.java
@Override public void onCreate() { Log.i("PCKeyboard", "onCreate(), os.version=" + System.getProperty("os.version")); KeyboardSwitcher.init(this); super.onCreate(); sInstance = this; // setStatusIcon(R.drawable.ime_qwerty); mResources = getResources();/*from w ww.j av a2s . c om*/ final Configuration conf = mResources.getConfiguration(); mOrientation = conf.orientation; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLanguageSwitcher = new LanguageSwitcher(this); mLanguageSwitcher.loadLocales(prefs); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); mLanguageSwitcher.setSystemLocale(conf.locale); String inputLanguage = mLanguageSwitcher.getInputLanguage(); if (inputLanguage == null) { inputLanguage = conf.locale.toString(); } Resources res = getResources(); mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED, res.getBoolean(R.bool.default_recorrection_enabled)); mConnectbotTabHack = prefs.getBoolean(PREF_CONNECTBOT_TAB_HACK, res.getBoolean(R.bool.default_connectbot_tab_hack)); mFullscreenOverride = prefs.getBoolean(PREF_FULLSCREEN_OVERRIDE, res.getBoolean(R.bool.default_fullscreen_override)); mForceKeyboardOn = prefs.getBoolean(PREF_FORCE_KEYBOARD_ON, res.getBoolean(R.bool.default_force_keyboard_on)); mKeyboardNotification = prefs.getBoolean(PREF_KEYBOARD_NOTIFICATION, res.getBoolean(R.bool.default_keyboard_notification)); mSuggestionsInLandscape = prefs.getBoolean(PREF_SUGGESTIONS_IN_LANDSCAPE, res.getBoolean(R.bool.default_suggestions_in_landscape)); mHeightPortrait = getHeight(prefs, PREF_HEIGHT_PORTRAIT, res.getString(R.string.default_height_portrait)); mHeightLandscape = getHeight(prefs, PREF_HEIGHT_LANDSCAPE, res.getString(R.string.default_height_landscape)); LatinIME.sKeyboardSettings.hintMode = Integer .parseInt(prefs.getString(PREF_HINT_MODE, res.getString(R.string.default_hint_mode))); LatinIME.sKeyboardSettings.longpressTimeout = getPrefInt(prefs, PREF_LONGPRESS_TIMEOUT, res.getString(R.string.default_long_press_duration)); LatinIME.sKeyboardSettings.renderMode = getPrefInt(prefs, PREF_RENDER_MODE, res.getString(R.string.default_render_mode)); mSwipeUpAction = prefs.getString(PREF_SWIPE_UP, res.getString(R.string.default_swipe_up)); mSwipeDownAction = prefs.getString(PREF_SWIPE_DOWN, res.getString(R.string.default_swipe_down)); mSwipeLeftAction = prefs.getString(PREF_SWIPE_LEFT, res.getString(R.string.default_swipe_left)); mSwipeRightAction = prefs.getString(PREF_SWIPE_RIGHT, res.getString(R.string.default_swipe_right)); mVolUpAction = prefs.getString(PREF_VOL_UP, res.getString(R.string.default_vol_up)); mVolDownAction = prefs.getString(PREF_VOL_DOWN, res.getString(R.string.default_vol_down)); sKeyboardSettings.initPrefs(prefs, res); mVoiceRecognitionTrigger = new VoiceRecognitionTrigger(this); updateKeyboardOptions(); PluginManager.getPluginDictionaries(getApplicationContext()); mPluginManager = new PluginManager(this); final IntentFilter pFilter = new IntentFilter(); pFilter.addDataScheme("package"); pFilter.addAction("android.intent.action.PACKAGE_ADDED"); pFilter.addAction("android.intent.action.PACKAGE_REPLACED"); pFilter.addAction("android.intent.action.PACKAGE_REMOVED"); registerReceiver(mPluginManager, pFilter); LatinIMEUtil.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < LatinIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(inputLanguage); tryGC = false; } catch (OutOfMemoryError e) { tryGC = LatinIMEUtil.GCUtils.getInstance().tryGCOrWait(inputLanguage, e); } } mOrientation = conf.orientation; // register to receive ringer mode changes for silent mode IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mReceiver, filter); prefs.registerOnSharedPreferenceChangeListener(this); setNotification(mKeyboardNotification); }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
@Override public void onCreate() { Log.i("PCKeyboard", "onCreate(), os.version=" + System.getProperty("os.version")); TKIMELogger.init(this); KeyboardSwitcher.init(this); super.onCreate(); sInstance = this; // setStatusIcon(R.drawable.ime_qwerty); mResources = getResources();/*w w w. j a v a 2s .co m*/ final Configuration conf = mResources.getConfiguration(); mOrientation = conf.orientation; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mLanguageSwitcher = new LanguageSwitcher(this); mLanguageSwitcher.loadLocales(prefs); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher); mSystemLocale = conf.locale.toString(); mLanguageSwitcher.setSystemLocale(conf.locale); String inputLanguage = mLanguageSwitcher.getInputLanguage(); if (inputLanguage == null) { inputLanguage = conf.locale.toString(); } Resources res = getResources(); mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED, res.getBoolean(R.bool.default_recorrection_enabled)); mConnectbotTabHack = prefs.getBoolean(PREF_CONNECTBOT_TAB_HACK, res.getBoolean(R.bool.default_connectbot_tab_hack)); mFullscreenOverride = prefs.getBoolean(PREF_FULLSCREEN_OVERRIDE, res.getBoolean(R.bool.default_fullscreen_override)); mForceKeyboardOn = prefs.getBoolean(PREF_FORCE_KEYBOARD_ON, res.getBoolean(R.bool.default_force_keyboard_on)); mKeyboardNotification = prefs.getBoolean(PREF_KEYBOARD_NOTIFICATION, res.getBoolean(R.bool.default_keyboard_notification)); mSuggestionsInLandscape = prefs.getBoolean(PREF_SUGGESTIONS_IN_LANDSCAPE, res.getBoolean(R.bool.default_suggestions_in_landscape)); mHeightPortrait = getHeight(prefs, PREF_HEIGHT_PORTRAIT, res.getString(R.string.default_height_portrait)); mHeightLandscape = getHeight(prefs, PREF_HEIGHT_LANDSCAPE, res.getString(R.string.default_height_landscape)); LatinIME.sKeyboardSettings.hintMode = Integer .parseInt(prefs.getString(PREF_HINT_MODE, res.getString(R.string.default_hint_mode))); LatinIME.sKeyboardSettings.longpressTimeout = getPrefInt(prefs, PREF_LONGPRESS_TIMEOUT, res.getString(R.string.default_long_press_duration)); LatinIME.sKeyboardSettings.renderMode = getPrefInt(prefs, PREF_RENDER_MODE, res.getString(R.string.default_render_mode)); mSwipeUpAction = prefs.getString(PREF_SWIPE_UP, res.getString(R.string.default_swipe_up)); mSwipeDownAction = prefs.getString(PREF_SWIPE_DOWN, res.getString(R.string.default_swipe_down)); mSwipeLeftAction = prefs.getString(PREF_SWIPE_LEFT, res.getString(R.string.default_swipe_left)); mSwipeRightAction = prefs.getString(PREF_SWIPE_RIGHT, res.getString(R.string.default_swipe_right)); mVolUpAction = prefs.getString(PREF_VOL_UP, res.getString(R.string.default_vol_up)); mVolDownAction = prefs.getString(PREF_VOL_DOWN, res.getString(R.string.default_vol_down)); sKeyboardSettings.initPrefs(prefs, res); // mVoiceRecognitionTrigger = new VoiceRecognitionTrigger(this); updateKeyboardOptions(); PluginManager.getPluginDictionaries(getApplicationContext()); mPluginManager = new PluginManager(this); final IntentFilter pFilter = new IntentFilter(); pFilter.addDataScheme("package"); pFilter.addAction("android.intent.action.PACKAGE_ADDED"); pFilter.addAction("android.intent.action.PACKAGE_REPLACED"); pFilter.addAction("android.intent.action.PACKAGE_REMOVED"); registerReceiver(mPluginManager, pFilter); TKIMEUtil.GCUtils.getInstance().reset(); boolean tryGC = true; for (int i = 0; i < TKIMEUtil.GCUtils.GC_TRY_LOOP_MAX && tryGC; ++i) { try { initSuggest(inputLanguage); tryGC = false; } catch (OutOfMemoryError e) { tryGC = TKIMEUtil.GCUtils.getInstance().tryGCOrWait(inputLanguage, e); } } mOrientation = conf.orientation; // register to receive ringer mode changes for silent mode IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); registerReceiver(mReceiver, filter); prefs.registerOnSharedPreferenceChangeListener(this); setNotification(mKeyboardNotification); }
From source file:com.tandong.sa.vpic.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w. j a v a 2 s . co m // Load defaults from resources final Resources res = getResources(); final int defaultFooterColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_footer_color", "color", context.getPackageName())); // final int defaultFooterColor = res // .getColor(R.color.default_title_indicator_footer_color); final float defaultFooterLineHeight = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_footer_line_height", "dimen", context.getPackageName())); // final float defaultFooterLineHeight = res // .getDimension(R.dimen.default_title_indicator_footer_line_height); final int defaultFooterIndicatorStyle = res.getInteger(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_style", "integer", context.getPackageName())); // final int defaultFooterIndicatorStyle = res // .getInteger(R.integer.default_title_indicator_footer_indicator_style); final float defaultFooterIndicatorHeight = res.getDimension(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_height", "dimen", context.getPackageName())); // final float defaultFooterIndicatorHeight = res // .getDimension(R.dimen.default_title_indicator_footer_indicator_height); final float defaultFooterIndicatorUnderlinePadding = res.getDimension(context.getResources().getIdentifier( "default_title_indicator_footer_indicator_underline_padding", "dimen", context.getPackageName())); // final float defaultFooterIndicatorUnderlinePadding = res // .getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding); final float defaultFooterPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_footer_padding", "dimen", context.getPackageName())); // final float defaultFooterPadding = res // .getDimension(R.dimen.default_title_indicator_footer_padding); final int defaultLinePosition = res.getInteger(context.getResources() .getIdentifier("default_title_indicator_line_position", "integer", context.getPackageName())); // final int defaultLinePosition = res // .getInteger(R.integer.default_title_indicator_line_position); final int defaultSelectedColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_selected_color", "color", context.getPackageName())); // final int defaultSelectedColor = res // .getColor(R.color.default_title_indicator_selected_color); final boolean defaultSelectedBold = res.getBoolean(context.getResources() .getIdentifier("default_title_indicator_selected_bold", "bool", context.getPackageName())); // final boolean defaultSelectedBold = res // .getBoolean(R.bool.default_title_indicator_selected_bold); final int defaultTextColor = res.getColor(context.getResources() .getIdentifier("default_title_indicator_text_color", "color", context.getPackageName())); // final int defaultTextColor = res // .getColor(R.color.default_title_indicator_text_color); final float defaultTextSize = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_text_size", "dimen", context.getPackageName())); // final float defaultTextSize = res // .getDimension(R.dimen.default_title_indicator_text_size); final float defaultTitlePadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_title_padding", "dimen", context.getPackageName())); // final float defaultTitlePadding = res // .getDimension(R.dimen.default_title_indicator_title_padding); final float defaultClipPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_clip_padding", "dimen", context.getPackageName())); // final float defaultClipPadding = res // .getDimension(R.dimen.default_title_indicator_clip_padding); final float defaultTopPadding = res.getDimension(context.getResources() .getIdentifier("default_title_indicator_top_padding", "dimen", context.getPackageName())); // final float defaultTopPadding = res // .getDimension(R.dimen.default_title_indicator_top_padding); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, new int[] { getResources().getIdentifier("TitlePageIndicator", "styleable", context.getPackageName()) }, defStyle, 0); // TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.TitlePageIndicator, defStyle, 0); // Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerLineHeight", "styleable", context.getPackageName()), defaultFooterLineHeight); // mFooterLineHeight = a.getDimension( // R.styleable.TitlePageIndicator_footerLineHeight, // defaultFooterLineHeight); mFooterIndicatorStyle = IndicatorStyle .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_footerIndicatorStyle", "styleable", context.getPackageName()), defaultFooterIndicatorStyle)); // mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger( // R.styleable.TitlePageIndicator_footerIndicatorStyle, // defaultFooterIndicatorStyle)); mFooterIndicatorHeight = a.getDimension(getResources() .getIdentifier("TitlePageIndicator_footerIndicatorHeight", "styleable", context.getPackageName()), defaultFooterIndicatorHeight); // mFooterIndicatorHeight = a.getDimension( // R.styleable.TitlePageIndicator_footerIndicatorHeight, // defaultFooterIndicatorHeight); mFooterIndicatorUnderlinePadding = a .getDimension(getResources().getIdentifier("TitlePageIndicator_footerIndicatorUnderlinePadding", "styleable", context.getPackageName()), defaultFooterIndicatorUnderlinePadding); // mFooterIndicatorUnderlinePadding = a.getDimension( // R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, // defaultFooterIndicatorUnderlinePadding); mFooterPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_footerPadding", "styleable", context.getPackageName()), defaultFooterPadding); // mFooterPadding = a.getDimension( // R.styleable.TitlePageIndicator_footerPadding, // defaultFooterPadding); mLinePosition = LinePosition .fromValue(a.getInteger(getResources().getIdentifier("TitlePageIndicator_linePosition", "styleable", context.getPackageName()), defaultLinePosition)); // mLinePosition = LinePosition.fromValue(a.getInteger( // R.styleable.TitlePageIndicator_linePosition, // defaultLinePosition)); mTopPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_topPadding", "styleable", context.getPackageName()), defaultTopPadding); // mTopPadding = // a.getDimension(R.styleable.TitlePageIndicator_topPadding, // defaultTopPadding); mTitlePadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_titlePadding", "styleable", context.getPackageName()), defaultTitlePadding); // mTitlePadding = a.getDimension( // R.styleable.TitlePageIndicator_titlePadding, // defaultTitlePadding); mClipPadding = a.getDimension(getResources().getIdentifier("TitlePageIndicator_clipPadding", "styleable", context.getPackageName()), defaultClipPadding); // mClipPadding = a.getDimension( // R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); mColorSelected = a.getColor(getResources().getIdentifier("TitlePageIndicator_selectedColor", "styleable", context.getPackageName()), defaultSelectedColor); // mColorSelected = a.getColor( // R.styleable.TitlePageIndicator_selectedColor, // defaultSelectedColor); mColorText = a.getColor(getResources().getIdentifier("TitlePageIndicator_android_textColor", "styleable", context.getPackageName()), defaultTextColor); // mColorText = a.getColor( // R.styleable.TitlePageIndicator_android_textColor, // defaultTextColor); mBoldText = a.getBoolean(getResources().getIdentifier("TitlePageIndicator_selectedBold", "styleable", context.getPackageName()), defaultSelectedBold); // mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, // defaultSelectedBold); final float textSize = a.getDimension(getResources().getIdentifier("TitlePageIndicator_android_textSize", "styleable", context.getPackageName()), defaultTextSize); // final float textSize = a.getDimension( // R.styleable.TitlePageIndicator_android_textSize, // defaultTextSize); final int footerColor = a.getColor(getResources().getIdentifier("TitlePageIndicator_footerColor", "styleable", context.getPackageName()), defaultFooterColor); // final int footerColor = a.getColor( // R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); Drawable background = a.getDrawable(getResources().getIdentifier("TitlePageIndicator_android_background", "styleable", context.getPackageName())); // Drawable background = a // .getDrawable(R.styleable.TitlePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
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./*from w ww . j a v a2 s .c o m*/ */ 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); } }
From source file:com.androzic.MapActivity.java
@Override protected void onResume() { super.onResume(); Log.e(TAG, "onResume()"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); Resources resources = getResources(); // update some preferences int speedIdx = Integer.parseInt(settings.getString(getString(R.string.pref_unitspeed), "0")); speedFactor = Double.parseDouble(resources.getStringArray(R.array.speed_factors)[speedIdx]); speedAbbr = resources.getStringArray(R.array.speed_abbrs)[speedIdx]; speedUnit.setText(speedAbbr);// w ww .ja v a2 s.c o m int distanceIdx = Integer.parseInt(settings.getString(getString(R.string.pref_unitdistance), "0")); StringFormatter.distanceFactor = Double .parseDouble(resources.getStringArray(R.array.distance_factors)[distanceIdx]); StringFormatter.distanceAbbr = resources.getStringArray(R.array.distance_abbrs)[distanceIdx]; StringFormatter.distanceShortFactor = Double .parseDouble(resources.getStringArray(R.array.distance_factors_short)[distanceIdx]); StringFormatter.distanceShortAbbr = resources.getStringArray(R.array.distance_abbrs_short)[distanceIdx]; int elevationIdx = Integer.parseInt(settings.getString(getString(R.string.pref_unitelevation), "0")); elevationFactor = Double.parseDouble(resources.getStringArray(R.array.elevation_factors)[elevationIdx]); elevationAbbr = resources.getStringArray(R.array.elevation_abbrs)[elevationIdx]; elevationUnit.setText(elevationAbbr); application.angleType = Integer.parseInt(settings.getString(getString(R.string.pref_unitangle), "0")); trackUnit.setText((application.angleType == 0 ? "deg" : getString(R.string.degmag))); bearingUnit.setText((application.angleType == 0 ? "deg" : getString(R.string.degmag))); application.coordinateFormat = Integer .parseInt(settings.getString(getString(R.string.pref_unitcoordinate), "0")); application.sunriseType = Integer.parseInt(settings.getString(getString(R.string.pref_unitsunrise), "0")); renderInterval = settings.getInt(getString(R.string.pref_maprenderinterval), resources.getInteger(R.integer.def_maprenderinterval)) * 100; followOnLocation = settings.getBoolean(getString(R.string.pref_mapfollowonloc), resources.getBoolean(R.bool.def_mapfollowonloc)); magInterval = resources.getInteger(R.integer.def_maginterval) * 1000; showDistance = Integer.parseInt(settings.getString(getString(R.string.pref_showdistance_int), getString(R.string.def_showdistance))); showAccuracy = settings.getBoolean(getString(R.string.pref_showaccuracy), true); autoDim = settings.getBoolean(getString(R.string.pref_mapdim), resources.getBoolean(R.bool.def_mapdim)); dimInterval = settings.getInt(getString(R.string.pref_mapdiminterval), resources.getInteger(R.integer.def_mapdiminterval)) * 1000; dimValue = settings.getInt(getString(R.string.pref_mapdimvalue), resources.getInteger(R.integer.def_mapdimvalue)); map.setHideOnDrag(settings.getBoolean(getString(R.string.pref_maphideondrag), resources.getBoolean(R.bool.def_maphideondrag))); map.setStrictUnfollow(!settings.getBoolean(getString(R.string.pref_unfollowontap), resources.getBoolean(R.bool.def_unfollowontap))); map.setLookAhead( settings.getInt(getString(R.string.pref_lookahead), resources.getInteger(R.integer.def_lookahead))); map.setBestMapEnabled( settings.getBoolean(getString(R.string.pref_mapbest), resources.getBoolean(R.bool.def_mapbest))); map.setBestMapInterval(settings.getInt(getString(R.string.pref_mapbestinterval), resources.getInteger(R.integer.def_mapbestinterval)) * 1000); map.setCursorVector( Integer.parseInt(settings.getString(getString(R.string.pref_cursorvector), getString(R.string.def_cursorvector))), settings.getInt(getString(R.string.pref_cursorvectormlpr), resources.getInteger(R.integer.def_cursorvectormlpr))); map.setProximity(Integer.parseInt(settings.getString(getString(R.string.pref_navigation_proximity), getString(R.string.def_navigation_proximity)))); // prepare views customizeLayout(settings); findViewById(R.id.editroute).setVisibility(application.editingRoute != null ? View.VISIBLE : View.GONE); if (application.editingTrack != null) { startEditTrack(application.editingTrack); } updateGPSStatus(); updateNavigationStatus(); // prepare overlays updateOverlays(settings, false); if (settings.getBoolean(getString(R.string.ui_drawer_open), false)) { Panel panel = (Panel) findViewById(R.id.panel); panel.setOpen(true, false); } onSharedPreferenceChanged(settings, getString(R.string.pref_wakelock)); map.setKeepScreenOn(keepScreenOn); // TODO move into application if (lastKnownLocation != null) { if (lastKnownLocation.getProvider().equals(LocationManager.GPS_PROVIDER)) { updateMovingInfo(lastKnownLocation, true); updateNavigationInfo(); dimScreen(lastKnownLocation); } else if (lastKnownLocation.getProvider().equals(LocationManager.NETWORK_PROVIDER)) { dimScreen(lastKnownLocation); } } bindService(new Intent(this, LocationService.class), locationConnection, BIND_AUTO_CREATE); bindService(new Intent(this, NavigationService.class), navigationConnection, BIND_AUTO_CREATE); registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATUS)); registerReceiver(broadcastReceiver, new IntentFilter(NavigationService.BROADCAST_NAVIGATION_STATE)); registerReceiver(broadcastReceiver, new IntentFilter(LocationService.BROADCAST_LOCATING_STATUS)); registerReceiver(broadcastReceiver, new IntentFilter(LocationService.BROADCAST_TRACKING_STATUS)); registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(broadcastReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); if (application.hasEnsureVisible()) { setFollowing(false); double[] loc = application.getEnsureVisible(); application.setMapCenter(loc[0], loc[1], true, false); application.clearEnsureVisible(); } else { application.updateLocationMaps(true, map.isBestMapEnabled()); } updateMapViewArea(); map.resume(); map.updateMapInfo(); map.update(); map.requestFocus(); }
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 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(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.//from ww w .j a v a 2 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(View.IMPORTANT_FOR_ACCESSIBILITY_YES); }
From source file:com.androzic.MapActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Resources resources = getResources(); // application preferences if (getString(R.string.pref_folder_data).equals(key)) { application.setDataPath(Androzic.PATH_DATA, sharedPreferences.getString(key, resources.getString(R.string.def_folder_data))); } else if (getString(R.string.pref_folder_icon).equals(key)) { application.setDataPath(Androzic.PATH_ICONS, sharedPreferences.getString(key, resources.getString(R.string.def_folder_icon))); } else if (getString(R.string.pref_orientation).equals(key)) { setRequestedOrientation(Integer.parseInt(sharedPreferences.getString(key, "-1"))); } else if (getString(R.string.pref_grid_mapshow).equals(key)) { application.mapGrid = sharedPreferences.getBoolean(key, false); application.initGrids();// w w w.jav a2s . c o m } else if (getString(R.string.pref_grid_usershow).equals(key)) { application.userGrid = sharedPreferences.getBoolean(key, false); application.initGrids(); } else if (getString(R.string.pref_grid_preference).equals(key)) { application.gridPrefer = Integer.parseInt(sharedPreferences.getString(key, "0")); application.initGrids(); } else if (getString(R.string.pref_grid_userscale).equals(key) || getString(R.string.pref_grid_userunit).equals(key) || getString(R.string.pref_grid_usermpp).equals(key)) { application.initGrids(); } else if (getString(R.string.pref_useonlinemap).equals(key) && sharedPreferences.getBoolean(key, false)) { application.setOnlineMap(sharedPreferences.getString(getString(R.string.pref_onlinemap), resources.getString(R.string.def_onlinemap))); } else if (getString(R.string.pref_onlinemap).equals(key) || getString(R.string.pref_onlinemapscale).equals(key)) { application.setOnlineMap(sharedPreferences.getString(getString(R.string.pref_onlinemap), resources.getString(R.string.def_onlinemap))); } else if (getString(R.string.pref_mapadjacent).equals(key)) { application.adjacentMaps = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapadjacent)); } else if (getString(R.string.pref_mapcropborder).equals(key)) { application.cropMapBorder = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapcropborder)); } else if (getString(R.string.pref_mapdrawborder).equals(key)) { application.drawMapBorder = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_mapdrawborder)); } // activity preferences else if (getString(R.string.pref_wakelock).equals(key)) { keepScreenOn = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_wakelock)); android.view.Window wnd = getWindow(); if (wnd != null) { if (keepScreenOn) wnd.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); else wnd.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } } else if (getString(R.string.pref_exit).equals(key)) { exitConfirmation = Integer.parseInt(sharedPreferences.getString(key, "0")); secondBack = false; } else if (getString(R.string.pref_unitprecision).equals(key)) { boolean precision = sharedPreferences.getBoolean(key, resources.getBoolean(R.bool.def_unitprecision)); precisionFormat = precision ? "%.1f" : "%.0f"; } // map preferences else if (getString(R.string.pref_cursorcolor).equals(key)) { map.setCursorColor(sharedPreferences.getInt(key, resources.getColor(R.color.cursor))); } else if (getString(R.string.pref_panelactions).equals(key)) { String pa = sharedPreferences.getString(key, resources.getString(R.string.def_panelactions)); activeActions = Arrays.asList(pa.split(",")); } }
From source file:me.lizheng.deckview.helpers.DeckViewConfig.java
/** * Updates the state, given the specified context *///from w w w . j a va 2 s .c o m void update(Context context) { Resources res = context.getResources(); DisplayMetrics dm = res.getDisplayMetrics(); // Debug mode debugModeEnabled = false; // Layout isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; // Insets displayRect.set(0, 0, dm.widthPixels, dm.heightPixels); // Animations animationPxMovementPerSecond = res.getDimensionPixelSize(R.dimen.animation_movement_in_dps_per_second); // Filtering filteringCurrentViewsAnimDuration = res.getInteger(R.integer.filter_animate_current_views_duration); filteringNewViewsAnimDuration = res.getInteger(R.integer.filter_animate_new_views_duration); // Task stack taskStackScrollDuration = res.getInteger(R.integer.animate_deck_scroll_duration); TypedValue widthPaddingPctValue = new TypedValue(); res.getValue(R.dimen.deck_width_padding_percentage, widthPaddingPctValue, true); taskStackWidthPaddingPct = widthPaddingPctValue.getFloat(); TypedValue stackOverscrollPctValue = new TypedValue(); res.getValue(R.dimen.deck_overscroll_percentage, stackOverscrollPctValue, true); taskStackOverscrollPct = stackOverscrollPctValue.getFloat(); taskStackMaxDim = res.getInteger(R.integer.max_deck_view_dim); taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.deck_top_padding); // Transition transitionEnterFromAppDelay = res.getInteger(R.integer.enter_from_app_transition_duration); transitionEnterFromHomeDelay = res.getInteger(R.integer.enter_from_home_transition_duration); // Task view animation and styles taskViewEnterFromAppDuration = res.getInteger(R.integer.task_enter_from_app_duration); taskViewEnterFromHomeDuration = res.getInteger(R.integer.task_enter_from_home_duration); taskViewEnterFromHomeStaggerDelay = res.getInteger(R.integer.task_enter_from_home_stagger_delay); taskViewExitToAppDuration = res.getInteger(R.integer.task_exit_to_app_duration); taskViewExitToHomeDuration = res.getInteger(R.integer.task_exit_to_home_duration); taskViewRemoveAnimDuration = res.getInteger(R.integer.animate_task_view_remove_duration); taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(R.dimen.task_view_remove_anim_translation_x); taskViewRoundedCornerRadiusPx = res.getDimensionPixelSize(R.dimen.task_view_rounded_corners_radius); taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.task_view_highlight); taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.task_view_z_min); taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.task_view_z_max); taskViewAffiliateGroupEnterOffsetPx = res .getDimensionPixelSize(R.dimen.task_view_affiliate_group_enter_offset); TypedValue thumbnailAlphaValue = new TypedValue(); res.getValue(R.dimen.task_view_thumbnail_alpha, thumbnailAlphaValue, true); taskViewThumbnailAlpha = thumbnailAlphaValue.getFloat(); // Task bar colors taskBarViewDefaultBackgroundColor = ContextCompat.getColor(context, R.color.task_bar_default_background_color); taskBarViewLightTextColor = ContextCompat.getColor(context, R.color.task_bar_light_text_color); taskBarViewDarkTextColor = ContextCompat.getColor(context, R.color.task_bar_dark_text_color); taskBarViewHighlightColor = ContextCompat.getColor(context, R.color.task_bar_highlight_color); TypedValue affMinAlphaPctValue = new TypedValue(); res.getValue(R.dimen.task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true); taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat(); // Task bar size & animations taskBarHeight = res.getDimensionPixelSize(R.dimen.deck_child_header_bar_height); taskBarDismissDozeDelaySeconds = res.getInteger(R.integer.task_bar_dismiss_delay_seconds); // Nav bar scrim navBarScrimEnterDuration = res.getInteger(R.integer.nav_bar_scrim_enter_duration); // Misc useHardwareLayers = res.getBoolean(R.bool.config_use_hardware_layers); altTabKeyDelay = res.getInteger(R.integer.deck_alt_tab_key_delay); fakeShadows = res.getBoolean(R.bool.config_fake_shadows); svelteLevel = res.getInteger(R.integer.deck_svelte_level); }