Skip to content

Commit

Permalink
Merge pull request #6 from ps-watchapp/dev_design
Browse files Browse the repository at this point in the history
Dev design
  • Loading branch information
PSTobias authored Aug 15, 2017
2 parents ddcc9eb + 3cf952f commit 91b4b60
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 26 deletions.
24 changes: 19 additions & 5 deletions de.wwu.md2.framework/src/de/wwu/md2/framework/MD2.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ SubViewContainer:
* A ListView for using a whole Activity as a List
*/
ListView:
'ListView' name = EID '{'
'ListView' name = EID ('(' params += ListViewLayoutParam (',' params += ListViewLayoutParam)* ')')? '{'
('connectedProvider' connectedProvider = ContentProviderPath)
('onClickAction' onClickAction = [Action | QUALIFIED_NAME])?
('leftSwipeAction' leftSwipeAction = [Action | QUALIFIED_NAME])?
Expand All @@ -558,6 +558,19 @@ ListViewParam:
{PlaceholderParam} 'placeholder' value = INT
;

ListViewLayoutParam:
//{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")?
{ViewIcon} 'icon' value = ViewIcon?
;

ViewIcon:
"close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light"|"preference_wrapped_icon" | "open_on_phone_animation" | "open_on_phone"
;

ViewIconActionDrawer:
"btn_star_big_on" | "arrow_up_float"
;

/*
* A GridLayoutPane allows the arrangement of ViewGUIElements in a grid structure. The user can specify the
* number of columns or the number of rows. If one of those is specified the other one will be calculated by
Expand All @@ -575,7 +588,7 @@ GridLayoutPane:
* These are besides the number of columns and rows all TabSpecificParams.
*/
GridLayoutPaneParam:
{GridLayoutPaneColumnsParam} 'columns' value = INT | {GridLayoutPaneRowsParam} 'rows' value = INT | CommonContainerParam | {GridLayoutPaneIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")?
{GridLayoutPaneColumnsParam} 'columns' value = INT | {GridLayoutPaneRowsParam} 'rows' value = INT | CommonContainerParam | {ViewIcon} 'icon' value = ViewIcon? //{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")?
;

/*
Expand All @@ -592,7 +605,7 @@ FlowLayoutPane:
* These are besides the flowDirection all TabSpecificParams.
*/
FlowLayoutPaneParam:
{FlowLayoutPaneFlowDirectionParam} flowDirection = FlowDirection | CommonContainerParam
{FlowLayoutPaneFlowDirectionParam} flowDirection = FlowDirection | CommonContainerParam | {ViewIcon} 'icon' value = ViewIcon? //{ViewIcon} 'icon' value = ("close_button"|"common_full_open_on_phone"|"common_google_signin_btn_icon_light")?
;

/*
Expand All @@ -607,7 +620,7 @@ enum FlowDirection:
* or Labels in a single-column view structure.
*/
ActionDrawer:
'ActionDrawer' name = EID '(' params += ActionDrawerParam ')' '{'
'ActionDrawer' name = EID ('('(params += ActionDrawerParam (',' params += ActionDrawerParam)*)?')')? '{'

'Actions' '{'
onItemClickAction += [Action | QUALIFIED_NAME] (',' onItemClickAction += [Action | QUALIFIED_NAME ])*
Expand All @@ -618,7 +631,8 @@ ActionDrawer:
;

ActionDrawerParam:
{ActionDrawerTitleParam} 'title' value = STRING
{ActionDrawerTitleParam} 'titles' ('('(values += STRING (',' values += STRING)*)?')') | //STRING |
{ViewIconActionDrawer} 'icons' ('('(values += ViewIconActionDrawer(',' values += ViewIconActionDrawer)*)?')')
;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import de.wwu.md2.framework.mD2.WorkflowElementReference
import de.wwu.md2.framework.mD2.ContentContainer
import de.wwu.md2.framework.mD2.Entity
import de.wwu.md2.framework.mD2.SensorType
import de.wwu.md2.framework.mD2.GridLayoutPaneIcon
import de.wwu.md2.framework.mD2.impl.GridLayoutPaneImpl
import de.wwu.md2.framework.mD2.impl.GridLayoutPaneIconImpl
import de.wwu.md2.framework.generator.android.wearable.view.ValueGen

import de.wwu.md2.framework.mD2.ListView
Expand All @@ -36,6 +34,12 @@ import java.util.LinkedHashSet
import java.util.LinkedList
import java.util.Map
import de.wwu.md2.framework.mD2.IntegerInput
import java.awt.GridBagLayout
import de.wwu.md2.framework.mD2.FlowLayoutPane
import de.wwu.md2.framework.mD2.impl.FlowLayoutPaneImpl
import de.wwu.md2.framework.mD2.impl.ListViewImpl
import de.wwu.md2.framework.mD2.ViewIcon
import de.wwu.md2.framework.mD2.ListViewLayoutParam

class ActivityGen {

Expand Down Expand Up @@ -258,10 +262,7 @@ class ActivityGen {

@Override
public Drawable getItemDrawable(int position) {
String activity_name=Md2ViewManager.getInstance().getActiveView().getTitle().toString();

return Md2ViewManager.getInstance().getActiveView().getDrawable(R.mipmap.ic_launcher);

«println(generateIcons(rootViews))»
}

public int getActive(){
Expand Down Expand Up @@ -292,6 +293,52 @@ class ActivityGen {
}

'''
def private static String generateIcons(Iterable<ContainerElement> rootViews){
var String result = "switch(position){"
var viewnumber = 0;
for (rv : rootViews) {
println(rv)
switch (rv) {
GridLayoutPaneImpl: {
for (rve : (rv as GridLayoutPaneImpl).params) {
if(rve instanceof ViewIcon){
result += "\r\n case " + viewnumber + ":";
result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");"
}
}
}
FlowLayoutPaneImpl: {
println("FlowLAyoutPane")
for (rve : (rv as FlowLayoutPaneImpl).params) {
if(rve instanceof ViewIcon){
result += "\r\n case " + viewnumber + ":";
result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");"
}
}
}
ListViewImpl: {
println("ListView gefunden" + rv);
for (rve : rv.params) {
println("RVE ListView:" + rve);
if(rve instanceof ViewIcon){
result += "\r\n case " + viewnumber + ":";
result += "\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.drawable."+(rve as ViewIcon).value+");"
}
}
}
default: {
println("Kein GridLayoutPAne")
}
}
viewnumber++;
}
result+="\r\ndefault:\r\n return Md2ViewManager.getInstance().getActiveView().getDrawable(R.mipmap.ic_launcher);}"
return result;
}
def static generateStartActivity(String mainPackage, Iterable<WorkflowElementReference> startableWorkflowElements, Iterable<Entity> entities)'''
// generated in de.wwu.md2.framework.generator.android.wearable.controller.Activity.generateStartActivity()
package «mainPackage»;
Expand Down Expand Up @@ -397,6 +444,8 @@ class ActivityGen {
«MD2AndroidLollipopUtil.generateImportAllWidgets»
«MD2AndroidLollipopUtil.generateImportAllTypes»
«MD2AndroidLollipopUtil.generateImportAllEventHandler»

import de.uni_muenster.wi.md2library.controller.action.interfaces.Md2Action;

«FOR viewElement: rv.eAllContents.toIterable»
«IF viewElement instanceof ActionDrawer»
Expand Down Expand Up @@ -527,7 +576,8 @@ class ActivityGen {

@Override
public boolean onMenuItemClick(MenuItem menuItem) {

//TODO
return true;

«FOR viewElement: rv.eAllContents.toIterable»
«IF viewElement instanceof ActionDrawer»
Expand All @@ -538,8 +588,9 @@ class ActivityGen {
final int itemId = menuItem.getItemId();

switch(itemId) {
«var ElementCounter = 0»
«FOR itemClickAction: viewElement.onItemClickAction»
case R.id.«itemClickAction.name»_item:
case R.id.«itemClickAction.name»_item«ElementCounter++»:
ca = new «MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "_").toFirstUpper»_Action();
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class ApplicationGen {
import «Settings.MD2LIBRARY_TASKQUEUE_PACKAGE_NAME»;
import «Settings.MD2LIBRARY_VIEWMANAGER_PACKAGE_NAME»;
import «Settings.MD2LIBRARY_WIDGETREGISTRY_PACKAGE_NAME»;
import «Settings.MD2LIBRARY_PACKAGE»model.contentProvider.implementation.Polling;


public class «app.name.toFirstUpper» extends Application {

Expand All @@ -40,6 +42,9 @@ class ApplicationGen {
wr = Md2WidgetRegistry.getInstance();
context = getApplicationContext();
Controller.getInstance().run();
Thread t = new Thread(new Polling(cpr));
t.start();

}

public static Context getAppContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ import «Settings.MD2LIBRARY_PACKAGE»controller.eventhandler.implementation.Md2
public void newEntity(){
content = new «(content.entity as Entity).name»();
}
public void update() {
System.out.println("single wurde geupdated");
}
}
'''}


Expand Down Expand Up @@ -319,7 +322,10 @@ import de.uni_muenster.wi.md2library.model.contentProvider.implementation.Abstra
}
}
}
public void update() {
System.out.println("multi wurde geupdated");
}
'''
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class «entity.name.toFirstUpper» extends AbstractMd2Entity {
@DatabaseTable(tableName = "«entity.name.toFirstLower»")
public class «entity.name.toFirstUpper» implements Serializable,Md2Entity{
@SerializedName("__internalId")
««« @SerializedName("__internalId")
@DatabaseField(generatedId = true, columnName = "id")
private long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ import de.wwu.md2.framework.mD2.Action

import de.wwu.md2.framework.mD2.ListView
import de.wwu.md2.framework.mD2.IntegerInput

import de.wwu.md2.framework.mD2.ActionDrawerParam
import de.wwu.md2.framework.mD2.ActionDrawerTitleParam
import de.wwu.md2.framework.mD2.impl.ActionDrawerImpl
import de.wwu.md2.framework.mD2.ViewIcon
import de.wwu.md2.framework.mD2.ViewIconActionDrawer
import java.util.List

class LayoutGen {

Expand Down Expand Up @@ -156,7 +161,7 @@ class LayoutGen {
navElement.setAttribute("android:id", "@+id/navigation_drawer_"+rv.name)
navElement.setAttribute("android:layout_height", "match_parent")
navElement.setAttribute("android:layout_width", "match_parent")
navElement.setAttribute("android:background", "@android:color/holo_blue_bright")
navElement.setAttribute("android:background", "@color/PSWatchappSemiTransparentDarkBlue")
//create WearableRecyclerView für Listendarstellung
var Element listElement = doc.createElement("android.support.wearable.view.WearableRecyclerView")
listElement.setAttribute("android:id","@+id/wearable_recycler_view_"+rv.name)
Expand Down Expand Up @@ -189,15 +194,15 @@ class LayoutGen {
navElement.setAttribute("android:layout_height", "match_parent")
navElement.setAttribute("android:layout_width", "match_parent")

navElement.setAttribute("android:background", "@color/PSWatchappSemiTransperentDarkBlue")
navElement.setAttribute("android:background", "@color/PSWatchappSemiTransparentDarkBlue")

//create ActionDrawer
var Element drawerElement = doc.createElement("android.support.wearable.view.drawer.WearableActionDrawer")
drawerElement.setAttribute("android:id", "@+id/bottom_action_drawer_" + rv.name)
drawerElement.setAttribute("android:layout_height", "match_parent")
drawerElement.setAttribute("android:layout_width", "match_parent")
drawerElement.setAttribute("app:action_menu", "@menu/" + rv.name.toLowerCase + "_action_drawer_menu")

drawerElement.setAttribute("android:theme","@style/PSWatchappActionDrawer")

// create BoxInsetLayout
var Element boxElement = doc.createElement("android.support.wearable.view.BoxInsetLayout")
Expand Down Expand Up @@ -297,20 +302,47 @@ class LayoutGen {
rootElement.setAttribute("android:layout_width", "match_parent")
rootElement.setAttribute("tools:deviceIds", "wear")

val ActionsIcons = newArrayList()
val ActionTitel = newArrayList()

//Generate menu items in the menu
for(viewElement: rv.eAllContents.toIterable) {
if(viewElement instanceof ActionDrawer) {
//Titel für die Beschriftung im ActionDrawer
var ActionDrawerTitel = "";
var iconAction = "ic_dialog_info"; //default Icon

for (acd : (viewElement as ActionDrawerImpl).params) {
if(acd instanceof ActionDrawerTitleParam){
for (title : acd.values) {
ActionTitel.add(title.toString);
}
}
if(acd instanceof ViewIconActionDrawer){
for (icon : acd.values) {
iconAction = icon.toString; //falls ein anderes Icon angegeben wurde wird dies verwendet
ActionsIcons.add(iconAction);
}
}

}


if(!(viewElement.onItemClickAction === null)) {
var ElementCounter = 0;
for(itemClickAction: viewElement.onItemClickAction) {
println("ActionDrawer itemClickAction:" + itemClickAction)
var Element item = doc.createElement("item")
item.setAttribute("android:id", "@+id/" + itemClickAction.name + "_item")
item.setAttribute("android:icon", "@android:drawable/ic_dialog_info") // TODO: Icons auswählen können
item.setAttribute("android:title", MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "").toFirstUpper)
item.setAttribute("android:id", ("@+id/" + (itemClickAction.name + "_item" + (ElementCounter++).toString)))
item.setAttribute("android:icon", ("@android:drawable/" + ActionsIcons.get(ElementCounter-1))) // TODO: Icons auswählen können
item.setAttribute("android:title", ActionTitel.get(ElementCounter-1));//MD2AndroidLollipopUtil.getQualifiedNameAsString(itemClickAction, "").toFirstUpper)
rootElement.appendChild(item)
}
}
}
}



//Append
doc.appendChild(rootElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import de.wwu.md2.framework.mD2.ContentContainer
import de.wwu.md2.framework.mD2.GridLayoutPane
import de.wwu.md2.framework.mD2.FlowLayoutPane
import org.apache.log4j.Layout
import de.wwu.md2.framework.mD2.GridLayoutPaneIcon

class ValueGen {

Expand Down Expand Up @@ -143,7 +142,7 @@ class ValueGen {
<style name="PSWatchapp" parent="android:Theme.Material.Light.NoActionBar" >
<item name="android:colorAccent">@color/PSWatchappBlueLight</item>
<item name="android:colorPrimary">@color/PSWatchappSemiTransperentDarkBlue</item>
<item name="android:colorPrimary">@color/PSWatchappSemiTransparentDarkBlue</item>
<item name="android:colorPrimaryDark">@color/blue</item>
<item name="android:colorBackground">@color/PSWatchappBackgroundBlue</item>
<item name="android:textColorPrimary">@android:color/white</item>
Expand All @@ -155,6 +154,11 @@ class ValueGen {
<item name="android:textColorPrimaryInverse">@color/black</item>
<item name="android:button">@color/PSWatchappBlueLight</item>
</style>
<style name="PSWatchappActionDrawer" parent="PSWatchapp" >
//Action Drawer
<item name="android:background">@color/PSWatchappSemiTransparentDarkBlue</item>
</style>
</resources>
'''

Expand All @@ -174,7 +178,7 @@ class ValueGen {
<color name="PSWatchappBackgroundBlue">#0d568f</color>
<color name="PSWatchappBlueLight">#00a2d3</color>
<color name="foreground_material_light">#ff0909</color>
<color name="PSWatchappSemiTransperentDarkBlue">#bd00a2d3</color>
<color name="PSWatchappSemiTransparentDarkBlue">#bd00a2d3</color>
</resources>
'''
}

0 comments on commit 91b4b60

Please sign in to comment.