Skip to content

Commit

Permalink
Making progress on TwoPaneController -- onMeasure method still needs …
Browse files Browse the repository at this point in the history
…work
  • Loading branch information
bishopmatthew committed Dec 13, 2012
1 parent e3fc276 commit a7b0bf7
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/jarlist.cache
bin/*
gen/*
11 changes: 9 additions & 2 deletions bin/R.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ int color background_holo_dark 0x7f070021
int color background_holo_light 0x7f070022
int color black 0x7f07000f
int color black_50_opacity 0x7f070010
int color blue 0x7f07004c
int color bright_accent 0x7f070020
int color bright_foreground_disabled_holo_dark 0x7f070025
int color bright_foreground_disabled_holo_light 0x7f070026
Expand All @@ -141,6 +142,7 @@ int color dim_foreground_inverse_disabled_holo_dark 0x7f07002c
int color dim_foreground_inverse_disabled_holo_light 0x7f070031
int color dim_foreground_inverse_holo_dark 0x7f07002b
int color dim_foreground_inverse_holo_light 0x7f070030
int color green 0x7f07004b
int color grey_10 0x7f07000c
int color grey_15 0x7f07000b
int color grey_20 0x7f07000a
Expand Down Expand Up @@ -172,11 +174,14 @@ int color holo_orange_light 0x7f070045
int color holo_purple 0x7f070044
int color holo_red_dark 0x7f070043
int color holo_red_light 0x7f070040
int color indigo 0x7f07004d
int color legacy_long_pressed_highlight 0x7f07003d
int color legacy_pressed_highlight 0x7f07003b
int color legacy_selected_highlight 0x7f07003c
int color link_text_holo_dark 0x7f070035
int color link_text_holo_light 0x7f070036
int color orange 0x7f070049
int color red 0x7f070048
int color tab_bg_check_off 0x7f070015
int color tab_bg_check_on 0x7f070016
int color tab_top 0x7f070014
Expand All @@ -185,10 +190,12 @@ int color textColorHint 0x7f070019
int color textColorLink 0x7f07001a
int color textColorPrimary 0x7f070017
int color transparent 0x7f07000d
int color violet 0x7f07004e
int color white 0x7f07000e
int color white_20_opacity 0x7f070013
int color white_33_opacity 0x7f070012
int color white_50_opacity 0x7f070011
int color yellow 0x7f07004a
int dimen actionbar_height 0x7f080000
int dimen actionbar_underline_height 0x7f080002
int dimen actionbar_underline_offset 0x7f080001
Expand Down Expand Up @@ -312,7 +319,7 @@ int id checkable_group 0x7f060063
int id cnt_actionbar_buttons 0x7f06003a
int id cnt_actionbar_controller 0x7f060039
int id cnt_btns_left 0x7f060040
int id cnt_btns_right 0x7f060043
int id cnt_btns_right 0x7f060042
int id cnt_buttons 0x7f060036
int id cnt_custom_views 0x7f06003b
int id cnt_sharelist_item 0x7f06005e
Expand Down Expand Up @@ -403,7 +410,7 @@ int id two_pane 0x7f060007
int id txt 0x7f06003c
int id txt_actionbar_title 0x7f060035
int id txt_title_left 0x7f06003f
int id txt_title_right 0x7f060042
int id txt_title_right 0x7f060043
int id wed 0x7f060053
int id year 0x7f060049
int layout act_actionbar 0x7f030000
Expand Down
26 changes: 16 additions & 10 deletions res/layout/vw_actionbar_twopane.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

<RelativeLayout
android:id="@+id/cnt_title_left"
android:layout_width="wrap_content"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/cnt_up" >
android:layout_alignParentLeft="true"
android:background="@color/red" >

<com.airlocksoftware.holo.type.FontText
android:id="@+id/txt_title_left"
Expand All @@ -20,16 +21,19 @@

<LinearLayout
android:id="@+id/cnt_btns_left"
android:layout_width="wrap_content"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/icv_overflow" />
android:layout_toRightOf="@+id/cnt_title_left"
android:background="@color/orange"
android:orientation="horizontal" />

<RelativeLayout
android:id="@+id/cnt_title_right"
android:layout_width="wrap_content"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/cnt_up" >
android:layout_toLeftOf="@+id/cnt_btns_right"
android:layout_toRightOf="@+id/cnt_btns_left"
android:background="@color/yellow" >

<com.airlocksoftware.holo.type.FontText
android:id="@+id/txt_title_right"
Expand All @@ -43,10 +47,12 @@

<LinearLayout
android:id="@+id/cnt_btns_right"
android:layout_width="wrap_content"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_alignWithParentIfMissing="true"
android:layout_toLeftOf="@+id/icv_overflow" />
android:layout_toLeftOf="@+id/icv_overflow"
android:background="@color/green"
android:orientation="horizontal" />

<com.airlocksoftware.holo.image.IconView
android:id="@+id/icv_overflow"
Expand All @@ -57,7 +63,7 @@
android:layout_weight="0"
android:background="?actionBarButtonBg"
android:clickable="true"
android:visibility="gone"
android:visibility="visible"
holo:icon_src="@drawable/ic_action_overflow" />

</merge>
42 changes: 22 additions & 20 deletions res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,32 @@
<color name="grey_20">#333333</color>
<color name="grey_15">#262626</color>
<color name="grey_10">#1a1a1a</color>

<color name="transparent">#00000000</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>

<color name="black_50_opacity">#80000000</color>
<color name="white_50_opacity">#80FFFFFF</color>
<color name="white_33_opacity">#54FFFFFF</color>
<color name="white_20_opacity">#33FFFFFF</color>


<color name="tab_top">@color/bright_accent</color>
<color name="tab_bg_check_off">@color/background_default</color>
<color name="tab_bg_check_on">@color/background_highlight</color>

<color name="tab_top">@color/bright_accent</color>
<color name="tab_bg_check_off">@color/background_default</color>
<color name="tab_bg_check_on">@color/background_highlight</color>
<color name="textColorPrimary">@color/grey_90</color>
<color name="textColorHighlight">@color/white</color>
<color name="textColorHint">@color/grey_60</color>
<color name="textColorLink">@color/bright_accent</color>

<color name="ab_top">@color/grey_40</color>
<color name="ab_bottom">@color/grey_20</color>
<color name="ab_underline">@color/bright_accent</color>

<color name="background_default">@color/grey_20</color>
<color name="background_highlight">@color/grey_30</color>

<color name="ab_top">@color/grey_40</color>
<color name="ab_bottom">@color/grey_20</color>
<color name="ab_underline">@color/bright_accent</color>
<color name="background_default">@color/grey_20</color>
<color name="background_highlight">@color/grey_30</color>
<color name="bright_accent">@color/holo_blue_light</color>

<!-- FROM ANDROID SDK SOURCE -->
<!-- For holo theme -->
<drawable name="screen_background_holo_light">#fff3f3f3</drawable>
<drawable name="screen_background_holo_dark">#ff000000</drawable>

<color name="background_holo_dark">#ff000000</color>
<color name="background_holo_light">#fff3f3f3</color>
<color name="bright_foreground_holo_dark">@color/background_holo_light</color>
Expand All @@ -70,17 +63,17 @@
<color name="link_text_holo_dark">#5c5cff</color>
<color name="link_text_holo_light">#0000ee</color>


<!-- Group buttons -->
<eat-comment />

<color name="group_button_dialog_pressed_holo_dark">#46c5c1ff</color>
<color name="group_button_dialog_focused_holo_dark">#2699cc00</color>

<color name="group_button_dialog_pressed_holo_light">#ffffffff</color>
<color name="group_button_dialog_focused_holo_light">#4699cc00</color>

<!-- Highlight colors for the legacy themes -->
<eat-comment />

<color name="legacy_pressed_highlight">#fffeaa0c</color>
<color name="legacy_selected_highlight">#fff17a0a</color>
<color name="legacy_long_pressed_highlight">#ffffffff</color>
Expand Down Expand Up @@ -108,5 +101,14 @@
<color name="holo_orange_dark">#ffff8800</color>
<!-- A really bright Holo shade of blue -->
<color name="holo_blue_bright">#ff00ddff</color>


<!-- RAINBOW -->
<color name="red">#FF0000</color>
<color name="orange">#FF7F00</color>
<color name="yellow">#FFFF00</color>
<color name="green">#00FF00</color>
<color name="blue">#0000FF</color>
<color name="indigo">#4B0082</color>
<color name="violet">#8F00FF</color>

</resources>
10 changes: 10 additions & 0 deletions src/com/airlocksoftware/holo/actionbar/ActionBarButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ public ActionBarButton(Context context, AttributeSet attrs) {
this.setClickable(true);
}

// OVERRIDEN METHODS
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();

// check to make sure drawmode is set
if (mDrawMode == null) throw new RuntimeException("You forgot to set the DrawMode for the ActionBarButton"
+ toString());
}

// PUBLIC API
/** Set the mode of this button. **/
public ActionBarButton priority(Priority priority) {
Expand Down
15 changes: 10 additions & 5 deletions src/com/airlocksoftware/holo/actionbar/ActionBarView.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ActionBarView extends RelativeLayout {
OverlayManager mOverlayManager;

private boolean mLayoutFinished = false;
// private boolean mNeedsLayout = false;
private boolean mNeedsLayout = false;

// CONSTANTS
private static final String TAG = ActionBarView.class.getSimpleName();
Expand Down Expand Up @@ -65,8 +65,8 @@ public ActionBarView(Context context, AttributeSet attrs) {
mUpIndicator = (IconView) findViewById(R.id.icv_up_indicator);
mUpIcon = findViewById(R.id.img_up_icon);

// TODO get the proper background resource

// get the background drawable & make sure it repeats properly
TypedValue typedValue = new TypedValue();
mContext.getTheme()
.resolveAttribute(R.attr.actionBarBg, typedValue, true);
Expand Down Expand Up @@ -140,11 +140,16 @@ public View findView(int id) {
* If any buttons won't fit, move them to the OverflowMenu. **/
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mLayoutFinished) {
// TODO get width and height of mControllerContainer instead
mController.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mLayoutFinished && mNeedsLayout) {
mController.onMeasure(mControllerContainer.getMeasuredWidth(), mControllerContainer.getMeasuredHeight());
mNeedsLayout = false;
}
}

public void requestNeedsLayout() {
mNeedsLayout = true;
requestLayout();
}

public ViewGroup getControllerContainer() {
return mControllerContainer;
Expand Down
6 changes: 2 additions & 4 deletions src/com/airlocksoftware/holo/actionbar/OnePaneController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class OnePaneController implements ActionBarController {
private List<ActionBarButton> mLowButtons = new ArrayList<ActionBarButton>();

// STATE
private boolean mNeedsLayout = false;

// CONSTANTS
private static final int ONE_PANE_LAYOUT_RES = R.layout.vw_actionbar_onepane;
Expand Down Expand Up @@ -71,8 +70,7 @@ public OnePaneController(Context context, ActionBarView actionBar) {
public void addButton(ActionBarButton button) {
if (button.priority() == Priority.HIGH) mHighButtons.add(button);
else mLowButtons.add(button);
mNeedsLayout = true;
mControllerContainer.requestLayout();
mActionBar.requestNeedsLayout();
}

@Override
Expand All @@ -99,7 +97,7 @@ public void addOverflowView(View toAdd) {
@Override
public void removeOverflowView(View toRemove) {
mOverflow.removeView(toRemove);
mControllerContainer.requestLayout();
mActionBar.requestNeedsLayout();
}

@Override
Expand Down
Loading

0 comments on commit a7b0bf7

Please sign in to comment.