Skip to content

Commit

Permalink
Adjusting all views and the generation of ui to have eveything styllable
Browse files Browse the repository at this point in the history
  • Loading branch information
shehabic committed Mar 8, 2015
1 parent 4ca01cd commit 299aeaa
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public DroppyMenuContainer(Context context, AttributeSet attrs, int defStyleAttr
this.setOrientation(VERTICAL);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DroppyMenuPopup, defStyleAttr, 0);
ViewGroup.LayoutParams lp = getLayoutParams();
int height = a.getInteger(R.styleable.DroppyMenuContainer_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = a.getInteger(R.styleable.DroppyMenuContainer_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = (int) a.getDimension(R.styleable.DroppyMenuContainer_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = (int) a.getDimension(R.styleable.DroppyMenuContainer_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);

if (lp == null) {
lp = new ViewGroup.LayoutParams(width, height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public DroppyMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
ViewGroup.LayoutParams lp = getLayoutParams();
setMinimumWidth((int) minWidth);
setMinimumHeight((int) minHeight);
int width = a.getInteger(R.styleable.DroppyMenuItem_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = a.getInteger(R.styleable.DroppyMenuItem_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = (int) a.getDimension(R.styleable.DroppyMenuItem_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = (int) a.getDimension(R.styleable.DroppyMenuItem_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
if (lp == null) {
lp = new ViewGroup.LayoutParams(width, height);
} else {
Expand All @@ -50,10 +50,10 @@ public DroppyMenuItem(Context context, AttributeSet attrs, int defStyleAttr) {
setClickable(a.getBoolean(R.styleable.DroppyMenuItem_android_clickable, defaultIsClickable));
setOrientation(LinearLayout.HORIZONTAL);
setGravity(a.getInteger(R.styleable.DroppyMenuItem_android_gravity, Gravity.CENTER_VERTICAL));
int paddingTop = a.getInteger(R.styleable.DroppyMenuItem_android_paddingTop, (int) getResources().getDimension(R.dimen.default_menu_item_paddingTop));
int paddingBottom = a.getInteger(R.styleable.DroppyMenuItem_android_paddingBottom, (int) getResources().getDimension(R.dimen.default_menu_item_paddingBottom));
int paddingLeft = a.getInteger(R.styleable.DroppyMenuItem_android_paddingLeft, (int) getResources().getDimension(R.dimen.default_menu_item_paddingLeft));
int paddingRight = a.getInteger(R.styleable.DroppyMenuItem_android_paddingRight, (int) getResources().getDimension(R.dimen.default_menu_item_paddingRight));
int paddingTop = (int) a.getDimension(R.styleable.DroppyMenuItem_android_paddingTop, (int) getResources().getDimension(R.dimen.default_menu_item_paddingTop));
int paddingBottom = (int) a.getDimension(R.styleable.DroppyMenuItem_android_paddingBottom, (int) getResources().getDimension(R.dimen.default_menu_item_paddingBottom));
int paddingLeft = (int) a.getDimension(R.styleable.DroppyMenuItem_android_paddingLeft, (int) getResources().getDimension(R.dimen.default_menu_item_paddingLeft));
int paddingRight = (int) a.getDimension(R.styleable.DroppyMenuItem_android_paddingRight, (int) getResources().getDimension(R.dimen.default_menu_item_paddingRight));
setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);

Drawable background = a.getDrawable(R.styleable.DroppyMenuItem_android_background);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public DroppyMenuItemIcon(Context context, AttributeSet attrs, int defStyleAttr)
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DroppyMenuItemIcon, defStyleAttr, 0);
int maxWidth = (int) a.getDimension(R.styleable.DroppyMenuItemIcon_android_maxWidth, defaultMaxWidth);
int maxHeight = (int) a.getDimension(R.styleable.DroppyMenuItemIcon_android_maxHeight, defaultMaxHeight);
int width = a.getInteger(R.styleable.DroppyMenuItemIcon_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = a.getInteger(R.styleable.DroppyMenuItemIcon_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = (int) a.getDimension(R.styleable.DroppyMenuItemIcon_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = (int) a.getDimension(R.styleable.DroppyMenuItemIcon_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
lp.width = width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DroppyMenuItemTitle(Context context, AttributeSet attrs) {
public DroppyMenuItemTitle(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);

final int defaultWidth = (int) getResources().getDimension(R.dimen.default_menu_item_title_layout_width);
final int defaultWidth = ViewGroup.LayoutParams.MATCH_PARENT;
final int defaultMinWidth = (int) getResources().getDimension(R.dimen.default_menu_item_title_minWidth);
final int defaultMinHeight = (int) getResources().getDimension(R.dimen.default_menu_item_title_minHeight);
final float defaultWeight = 1;
Expand All @@ -37,8 +37,8 @@ public DroppyMenuItemTitle(Context context, AttributeSet attrs, int defStyleAttr
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DroppyMenuItemTitle, defStyleAttr, 0);
int minWidth = (int) a.getDimension(R.styleable.DroppyMenuItemTitle_android_minWidth, defaultMinWidth);
int minHeight = (int) a.getDimension(R.styleable.DroppyMenuItemTitle_android_minHeight, defaultMinHeight);
int width = a.getInteger(R.styleable.DroppyMenuItemTitle_android_layout_width, defaultWidth);
int height = a.getInteger(R.styleable.DroppyMenuItemTitle_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = (int) a.getDimension(R.styleable.DroppyMenuItemTitle_android_layout_width, defaultWidth);
int height = a.getInt(R.styleable.DroppyMenuItemTitle_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int color = a.getColor(R.styleable.DroppyMenuItemTitle_android_textColor, defaultColor);

setGravity(a.getInt(R.styleable.DroppyMenuItemTitle_android_gravity, defaultGravity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public DroppyMenuPopup(Context context, AttributeSet attrs, int defStyleAttr) {

TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DroppyMenuPopup, defStyleAttr, 0);
Drawable background = a.getDrawable(R.styleable.DroppyMenuPopup_android_background);
int height = a.getInteger(R.styleable.DroppyMenuPopup_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = a.getInteger(R.styleable.DroppyMenuPopup_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
int height = (int) a.getDimension(R.styleable.DroppyMenuPopup_android_layout_height, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = (int) a.getDimension(R.styleable.DroppyMenuPopup_android_layout_width, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewGroup.LayoutParams lp = getLayoutParams();
if (lp == null) {
lp = new ViewGroup.LayoutParams(width, height);
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/droppy__styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

<style name="Droppy.DroppyMenuItemTitle">
<item name="android:textColor">@color/darkgrey</item>
<item name="android:minWidth">100dp</item>
<item name="android:minWidth">128dp</item>
<item name="android:minHeight">30dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">0dp</item>
Expand Down
4 changes: 4 additions & 0 deletions samples/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blau">#3070CC</color>
</resources>
5 changes: 3 additions & 2 deletions samples/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<!--<item name="droppyPopupStyle">@style/Droppy.DroppyPopup</item>-->
<!--<item name="droppyMenuStyle">@style/Droppy.DroppyMenu</item>-->
<!--<item name="droppyMenuItemStyle">@style/Droppy.DroppyMenuItem</item>-->
<!--<item name="droppyMenuItemTitleStyle">@style/customMenuItemTitle</item>-->
<item name="droppyMenuItemTitleStyle">@style/customMenuItemTitle</item>
<!--<item name="droppyMenuItemIconStyle">@style/Droppy.DroppyMenuItemIcon</item>-->
</style>


<style name="customMenuItemTitle" parent="Droppy.DroppyMenuItemTitle">
<item name="android:textColor">#FFAA3300</item>
<item name="android:textColor">@color/blau</item>
<item name="android:layout_height">20dp</item>
</style>
</resources>

0 comments on commit 299aeaa

Please sign in to comment.