-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusting all views and the generation of ui to have eveything styllable
- Loading branch information
Showing
17 changed files
with
429 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
library/src/main/java/com/shehabic/droppy/views/DroppyMenuContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.shehabic.droppy.views; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
|
||
import com.shehabic.droppy.R; | ||
|
||
/** | ||
* Created by shehabic on 3/6/15. | ||
*/ | ||
public class DroppyMenuContainer extends LinearLayout | ||
{ | ||
public DroppyMenuContainer(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DroppyMenuContainer(Context context, AttributeSet attrs) { | ||
this(context, attrs, R.attr.droppyMenuStyle); | ||
} | ||
|
||
public DroppyMenuContainer(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, 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); | ||
|
||
if (lp == null) { | ||
lp = new ViewGroup.LayoutParams(width, height); | ||
} else { | ||
lp.width = width; | ||
lp.height = height; | ||
} | ||
setLayoutParams(lp); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
library/src/main/java/com/shehabic/droppy/views/DroppyMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.shehabic.droppy.views; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.graphics.drawable.Drawable; | ||
import android.util.AttributeSet; | ||
import android.view.Gravity; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
|
||
import com.shehabic.droppy.R; | ||
|
||
/** | ||
* Created by shehabic on 3/7/15. | ||
*/ | ||
public class DroppyMenuItem extends LinearLayout { | ||
|
||
public DroppyMenuItem(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DroppyMenuItem(Context context, AttributeSet attrs) { | ||
this(context, attrs, R.attr.droppyMenuItemStyle); | ||
} | ||
|
||
public DroppyMenuItem(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
|
||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DroppyMenuItem, defStyleAttr, 0); | ||
|
||
final Drawable defaultDrawable = getResources().getDrawable(R.drawable.default_menu_item_background); | ||
final float defaultMinWidth = getResources().getDimension(R.dimen.default_menu_item_minWidth); | ||
final float defaultMinHeight = getResources().getDimension(R.dimen.default_menu_item_minHeight); | ||
final boolean defaultIsClickable = getResources().getBoolean(R.bool.default_menu_item_clickable); | ||
|
||
float minWidth = a.getDimension(R.styleable.DroppyMenuItem_android_minWidth, defaultMinWidth); | ||
float minHeight = a.getDimension(R.styleable.DroppyMenuItem_android_minHeight, defaultMinHeight); | ||
|
||
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); | ||
if (lp == null) { | ||
lp = new ViewGroup.LayoutParams(width, height); | ||
} else { | ||
lp.width = width; | ||
lp.height = height; | ||
} | ||
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)); | ||
setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); | ||
|
||
Drawable background = a.getDrawable(R.styleable.DroppyMenuItem_android_background); | ||
if (background != null) { | ||
setBackgroundDrawable(background); | ||
} else { | ||
setBackgroundDrawable(defaultDrawable); | ||
} | ||
|
||
this.setLayoutParams(lp); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
library/src/main/java/com/shehabic/droppy/views/DroppyMenuItemIcon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.shehabic.droppy.views; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.view.Gravity; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
|
||
import com.shehabic.droppy.R; | ||
|
||
/** | ||
* Created by shehabic on 3/7/15. | ||
*/ | ||
public class DroppyMenuItemIcon extends ImageView { | ||
|
||
public DroppyMenuItemIcon(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DroppyMenuItemIcon(Context context, AttributeSet attrs) { | ||
this(context, attrs, R.attr.droppyMenuItemIconStyle); | ||
} | ||
|
||
public DroppyMenuItemIcon(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
|
||
final int defaultMaxWidth = (int) getResources().getDimension(R.dimen.default_menu_item_icon_maxWidth); | ||
final int defaultMaxHeight = (int) getResources().getDimension(R.dimen.default_menu_item_icon_maxHeight); | ||
final float defaultWeight = 0; | ||
final int defaultLayoutGravity = Gravity.START | Gravity.CENTER_VERTICAL; | ||
|
||
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); | ||
|
||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height); | ||
lp.width = width; | ||
lp.height = height; | ||
lp.weight = a.getFloat(R.styleable.DroppyMenuItemIcon_android_layout_weight, defaultWeight); | ||
lp.gravity = a.getInteger(R.styleable.DroppyMenuItemIcon_android_layout_gravity, defaultLayoutGravity); | ||
|
||
setMaxHeight(maxWidth); | ||
setMaxHeight(maxHeight); | ||
setLayoutParams(lp); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
library/src/main/java/com/shehabic/droppy/views/DroppyMenuItemTitle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.shehabic.droppy.views; | ||
|
||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.util.AttributeSet; | ||
import android.view.Gravity; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import com.shehabic.droppy.R; | ||
|
||
/** | ||
* Created by shehabic on 3/7/15. | ||
*/ | ||
public class DroppyMenuItemTitle extends TextView { | ||
|
||
public DroppyMenuItemTitle(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public DroppyMenuItemTitle(Context context, AttributeSet attrs) { | ||
this(context, attrs, R.attr.droppyMenuItemTitleStyle); | ||
} | ||
|
||
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 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; | ||
final int defaultColor = getResources().getColor(R.color.default_menu_item_title_textColor); | ||
final int defaultGravity = Gravity.CENTER_VERTICAL; | ||
final int defaultLayoutGravity = Gravity.END | Gravity.CENTER_VERTICAL; | ||
|
||
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 color = a.getColor(R.styleable.DroppyMenuItemTitle_android_textColor, defaultColor); | ||
|
||
setGravity(a.getInt(R.styleable.DroppyMenuItemTitle_android_gravity, defaultGravity)); | ||
|
||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height); | ||
lp.width = width; | ||
lp.height = height; | ||
lp.weight = a.getFloat(R.styleable.DroppyMenuItemTitle_android_layout_weight, defaultWeight); | ||
lp.gravity = a.getInteger(R.styleable.DroppyMenuItemTitle_android_layout_gravity, defaultLayoutGravity); | ||
|
||
setLayoutParams(lp); | ||
setMinHeight(minWidth); | ||
setMinHeight(minHeight); | ||
|
||
setTextColor(color); | ||
} | ||
} |
Oops, something went wrong.