sk.baka.ambient.views
Class ButtonBar

java.lang.Object
  extended by android.view.View
      extended by sk.baka.ambient.views.ButtonBar
All Implemented Interfaces:
Drawable.Callback, KeyEvent.Callback

public final class ButtonBar
extends View

A very simple, naive and inefficient implementation of the apple-launchbar-like button bar.

Author:
Martin Vysny

Nested Class Summary
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
 AdapterView.OnItemClickListener listener
          The ONCLICK listener.
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
ButtonBar(Context context, AttributeSet attrs)
           
ButtonBar(Context context, AttributeSet attrs, int defStyle)
           
ButtonBar(Context context, int rootId, Integer textHintColor, Integer textHintBgColor, Boolean extendDown)
          Constructor.
 
Method Summary
 Interval getHighlight()
          Returns the highlight interval.
 void highlight(Interval interval)
          Highlights given buttons.
protected  void onAttachedToWindow()
           
protected  void onDetachedFromWindow()
           
protected  void onDraw(Canvas canvas)
           
protected  void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
           
 boolean onKeyDown(int keyCode, KeyEvent event)
           
 boolean onKeyUp(int keyCode, KeyEvent event)
           
protected  void onLayout(boolean changed, int left, int top, int right, int bottom)
           
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           
 boolean onTouchEvent(MotionEvent event)
           
 void setBitmaps(int[] bitmapResources, int[] activityName, Point bitmapSize, Point hoveredBitmapSize)
          Sets a new set of images to be shown.
 
Methods inherited from class android.view.View
addFocusables, addTouchables, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, clearFocus, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, destroyDrawingCache, dispatchDraw, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, draw, drawableStateChanged, finalize, findFocus, findViewById, findViewWithTag, fitSystemWindows, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasFocus, hasFocusable, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onCreateContextMenu, onCreateDrawableState, onFinishInflate, onKeyMultiple, onKeyShortcut, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onSizeChanged, onTrackballEvent, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPadding, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

public AdapterView.OnItemClickListener listener
The ONCLICK listener. Both the position and the id fields will hold index of image being clicked.

Constructor Detail

ButtonBar

public ButtonBar(Context context,
                 int rootId,
                 Integer textHintColor,
                 Integer textHintBgColor,
                 Boolean extendDown)
Constructor. This version is only needed if you will be instantiating the object manually (not from a layout XML file).

Parameters:
context -
rootId - Denotes root absolute layout id.
textHintColor - text hint color, default white.
textHintBgColor - text background color, default 50% transparent black.
extendDown - If true (the default) then hovered buttons are extended downwards. If false then buttons are extended upwards.

ButtonBar

public ButtonBar(Context context,
                 AttributeSet attrs,
                 int defStyle)
Parameters:
context -
attrs -
defStyle -

ButtonBar

public ButtonBar(Context context,
                 AttributeSet attrs)
Parameters:
context -
attrs -
Method Detail

onAttachedToWindow

protected void onAttachedToWindow()
Overrides:
onAttachedToWindow in class View

onDetachedFromWindow

protected void onDetachedFromWindow()
Overrides:
onDetachedFromWindow in class View

setBitmaps

public void setBitmaps(int[] bitmapResources,
                       int[] activityName,
                       Point bitmapSize,
                       Point hoveredBitmapSize)
Sets a new set of images to be shown.

Parameters:
bitmapResources - the drawables to show
activityName - the activity captions. If -1 then the caption is not shown for the item. May be null if no captions are required to be shown.
bitmapSize - the size of all bitmaps. Here the Point class is not used as a point, it denotes dimension instead.
hoveredBitmapSize - the size of hovered bitmap. Here the Point class is not used as a point, it denotes dimension instead.

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Overrides:
onMeasure in class View
See Also:
View.measure(int, int)

onDraw

protected void onDraw(Canvas canvas)
Overrides:
onDraw in class View

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)
Overrides:
onLayout in class View

onTouchEvent

public boolean onTouchEvent(MotionEvent event)
Overrides:
onTouchEvent in class View

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class View

onFocusChanged

protected void onFocusChanged(boolean gainFocus,
                              int direction,
                              Rect previouslyFocusedRect)
Overrides:
onFocusChanged in class View

onKeyUp

public boolean onKeyUp(int keyCode,
                       KeyEvent event)
Specified by:
onKeyUp in interface KeyEvent.Callback
Overrides:
onKeyUp in class View

highlight

public void highlight(Interval interval)
Highlights given buttons.

Parameters:
interval - highlighted buttons. May be null - in this case the interval is empty.

getHighlight

public Interval getHighlight()
Returns the highlight interval.

Returns:
the highlight interval, never null


Copyright © 2007-2008. All Rights Reserved.