package com.sometrik.framework;

import android.app.Dialog;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

public class FWDialog extends Dialog implements NativeCommandHandler{

  FrameWork frame;
  ViewGroup baseView;
  ScrollView scrollView;
  int id;
  
  public FWDialog(FrameWork frame, int id) {
    super(frame);
    this.frame = frame;
    this.id = id;
    scrollView = new ScrollView(frame);
    setContentView(scrollView);
  }

  @Override
  public void onScreenOrientationChange(boolean isLandscape) {
  }

  @Override
  public void addChild(View view) {
    if (baseView == null){
      baseView = (ViewGroup) view;
      scrollView.addView(baseView);
    } else {
      baseView.addView(view);
    }
  }

  @Override
  public void addOption(int optionId, String text) {
    System.out.println("FWDialog couldn't handle the command");
  }

  @Override
  public void addData(String text, int row, int column, int sheet) {
    System.out.println("FWDialog couldn't handle the command");
  }

  @Override
  public void setValue(String v) {
    setTitle(v);
  }

  @Override
  public void setValue(int v) {
    if (v > 0){
      show();
    } else {
      dismiss();
    }
  }

  @Override
  public void setViewEnabled(Boolean enabled) {
    if (enabled){
      show();
    } else {
      dismiss();
    }
  }

  @Override
  public void setViewVisibility(boolean visible) {
    if (visible){
      show();
    } else {
      dismiss();
    }
  }

  @Override
  public void setStyle(String key, String value) {
    System.out.println("FWDialog couldn't handle the command");
  }

  @Override
  public void setError(boolean hasError, String errorText) {
    System.out.println("FWDialog couldn't handle the command");
  }

  @Override
  public void clear() {
    dismiss();
  }

  @Override
  public int getElementId() {
    return id;
  }

}

@@ -53,16 +53,45 @@
 Dialog;%0A
+import android.view.Gravity;%0A
 import a
@@ -139,16 +139,96 @@
 wGroup;%0A
+import android.view.ViewGroup.LayoutParams;%0Aimport android.widget.LinearLayout;%0A
 import a
@@ -581,16 +581,251 @@
 lView);%0A
+    %0A%0A    LayoutParams params = getWindow().getAttributes();%0A    params.height = LayoutParams.WRAP_CONTENT;%0A    params.width = LayoutParams.MATCH_PARENT;%0A    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);%0A
   %7D%0A%0A  @
@@ -896,16 +896,21 @@
 cape) %7B%0A
+    %0A
   %7D%0A%0A  @
@@ -1227,32 +1227,111 @@
  the command%22);%0A
+    switch (optionId)%7B%0A    case 0:%0A      break;%0A    case 1:%0A      break;%0A    %7D%0A
   %7D%0A%0A  @Override
@@ -1993,67 +1993,803 @@
     
-System.out.println(%22FWDialog couldn't handle the command%22);
+if (key.equals(%22width%22)) %7B%0A      ViewGroup.LayoutParams params = getWindow().getAttributes();%0A      if (value.equals(%22wrap_content%22)) %7B%0A%09params.width = LinearLayout.LayoutParams.WRAP_CONTENT;%0A      %7D else if (value.equals(%22match_parent%22)) %7B%0A%09params.width = LinearLayout.LayoutParams.MATCH_PARENT;%0A      %7D%0A      getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);%0A    %7D else if (key.equals(%22height%22)) %7B%0A      ViewGroup.LayoutParams params = getWindow().getAttributes();%0A      if (value.equals(%22wrap_content%22)) %7B%0A%09params.height = LinearLayout.LayoutParams.WRAP_CONTENT;%0A      %7D else if (value.equals(%22match_parent%22)) %7B%0A%09params.height = LinearLayout.LayoutParams.MATCH_PARENT;%0A      %7D%0A      getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);%0A    %7D
 %0A  %7D

Add setStyle options to FWDialog