Beispiel #1
0
  /** @see Widget.setProperty. */
  @Override
  public boolean setProperty(String property, String value)
      throws PropertyConversionException, InvalidPropertyValueException {
    if (super.setProperty(property, value)) {
      return true;
    }

    TimePicker timePicker = (TimePicker) getView();

    if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_HOUR)) {
      int hour = IntConverter.convert(value);
      if (hour < 0 || hour > 23) {
        throw new InvalidPropertyValueException(property, value);
      }
      timePicker.setCurrentHour(IntConverter.convert(value));
    } else if (property.equals(IX_WIDGET.MAW_TIME_PICKER_CURRENT_MINUTE)) {
      int minute = IntConverter.convert(value);
      if (minute < 0 || minute > 59) {
        throw new InvalidPropertyValueException(property, value);
      }
      timePicker.setCurrentMinute(IntConverter.convert(value));
    } else {
      return false;
    }
    return true;
  }
  /** @see Widget.setProperty. */
  @Override
  public boolean setProperty(String property, String value)
      throws PropertyConversionException, InvalidPropertyValueException {
    if (super.setProperty(property, value)) {
      return true;
    }

    TextView textView = (TextView) getView();
    if (property.equals(IX_WIDGET.MAW_LABEL_TEXT)) {
      textView.setText(value);
    } else if (property.equals(IX_WIDGET.MAW_EDIT_BOX_PLACEHOLDER)) {
      textView.setHint(value);
    } else if (property.equals(IX_WIDGET.MAW_LABEL_FONT_COLOR)) {
      textView.setTextColor(ColorConverter.convert(value));
    } else if (property.equals(IX_WIDGET.MAW_LABEL_FONT_SIZE)) {
      textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, FloatConverter.convert(value));
    } else if (property.equals(Types.WIDGET_PROPERTY_TEXT_HORIZONTAL_ALIGNMENT)) {
      mHorizontalGravity = HorizontalAlignment.convert(value);
      textView.setGravity(mHorizontalGravity | mVerticalGravity);
    } else if (property.equals(Types.WIDGET_PROPERTY_TEXT_VERTICAL_ALIGNMENT)) {
      mVerticalGravity = VerticalAlignment.convert(value);
      textView.setGravity(mHorizontalGravity | mVerticalGravity);
    } else if (property.equals(IX_WIDGET.MAW_LABEL_MAX_NUMBER_OF_LINES)) {
      if (IntConverter.convert(value) < 0) {
        throw new InvalidPropertyValueException(property, value);
      }
      // This overrides any height setting.
      // Makes the TextView be at most this many lines tall.
      m_maxNrLines = IntConverter.convert(value);
      if (m_maxNrLines == 0) {
        textView.setMaxLines(Integer.MAX_VALUE);

      } else {
        textView.setMaxLines(m_maxNrLines);
      }
    } else if (property.equals(IX_WIDGET.MAW_LABEL_FONT_HANDLE)) {
      MoSyncFontHandle currentFont = null;

      // Search the handle in the list of fonts.
      currentFont = MoSyncThread.getMoSyncFont(IntConverter.convert(value));

      if (currentFont != null) {
        setFontTypeface(currentFont.getTypeface(), currentFont.getFontSize());
      } else throw new InvalidPropertyValueException(property, value);
    } else {
      return false;
    }

    return true;
  }
Beispiel #3
0
  /**
   * Internal function for the maWidgetSetProperty system call. Sets a property on the given widget,
   * by accessing it from the widget table and calling its setProperty method.
   *
   * <p>Note: Should only be called on the UI thread.
   */
  public int maWidgetSetProperty(int widgetHandle, String key, String value) {
    Widget widget = m_widgetTable.get(widgetHandle);
    if (widget == null) {
      Log.e("MoSync", "maWidgetSetProperty: Invalid child widget handle: " + widgetHandle);
      return IX_WIDGET.MAW_RES_INVALID_HANDLE;
    }

    boolean result;

    try {
      result = widget.setProperty(key, value);
    } catch (PropertyConversionException pce) {
      Log.e("MoSync", "Error while converting property value '" + value + "': " + pce.getMessage());
      return IX_WIDGET.MAW_RES_INVALID_PROPERTY_VALUE;
    } catch (InvalidPropertyValueException ipve) {
      Log.e("MoSync", "Error while setting property: " + ipve.getMessage());
      return IX_WIDGET.MAW_RES_INVALID_PROPERTY_VALUE;
    } catch (FeatureNotAvailableException fnae) {
      Log.e("MoSync", "Feature not available exception: " + fnae.getMessage());
      return IX_WIDGET.MAW_RES_FEATURE_NOT_AVAILABLE;
    }

    if (result) {
      return IX_WIDGET.MAW_RES_OK;
    } else if (key.equals(IX_WIDGET.MAW_RADIO_GROUP_ADD_VIEW)) {
      // Add a RadioButton to a RadioGroup.
      Widget child = getWidget(IntConverter.convert(value));
      if (child != null
          && child instanceof RadioButtonWidget
          && widget instanceof RadioGroupWidget) {
        ((RadioGroupWidget) widget).addButton((RadioButtonWidget) child);
        return IX_WIDGET.MAW_RES_OK;
      }

      Log.e(
          "MoSync",
          "maWidgetSetProperty: Invalid Radio Button handle: "
              + IntConverter.convert(value)
              + " for Radio Group: "
              + widgetHandle);
      return IX_WIDGET.MAW_RES_INVALID_PROPERTY_VALUE;
    } else {
      Log.e(
          "MoSync",
          "maWidgetSetProperty: Invalid property '" + key + "' on widget: " + widgetHandle);
      return IX_WIDGET.MAW_RES_INVALID_PROPERTY_NAME;
    }
  }
Beispiel #4
0
 /**
  * Constructor Purchase API.
  *
  * @param thread The underlying MoSync thread.
  */
 public MoSyncPurchase(MoSyncThread thread) {
   mMoSyncThread = thread;
   // In-app purchase is supported only from Android 1.6 and higher.
   try {
     int target = IntConverter.convert(Build.VERSION.SDK);
     if (target >= 4) {
       SYSLOG("PurchaseManager is available, android sdk version > 4");
       mPurchaseManager = new PurchaseManager(thread);
     }
   } catch (PropertyConversionException pce) {
     return;
   }
 }
Beispiel #5
0
  @Override
  public boolean setProperty(String property, String value)
      throws PropertyConversionException, InvalidPropertyValueException {
    if (super.setProperty(property, value)) {
      return true;
    }

    TabHost tabHost = (TabHost) getView();
    if (property.equals(IX_WIDGET.MAW_TAB_SCREEN_CURRENT_TAB)) {
      int currentTabIndex = IntConverter.convert(value);
      tabHost.setCurrentTab(currentTabIndex);
    }

    return true;
  }