Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/src/main/java/odoo/controls/OEditTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand All @@ -48,6 +49,7 @@ public class OEditTextField extends LinearLayout implements IOControlData,
private float textSize = -1;
private int appearance = -1;
private int textColor = Color.BLACK;
private int inputtype = -1;

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public OEditTextField(Context context, AttributeSet attrs,
Expand Down Expand Up @@ -102,6 +104,9 @@ public void initControl() {
if (appearance > -1) {
edtText.setTextAppearance(mContext, appearance);
}
if (inputtype > -1) {
edtText.setInputType(inputtype);
}
edtText.setTextColor(textColor);
addView(edtText);
} else {
Expand Down Expand Up @@ -185,6 +190,14 @@ public Boolean isEditable() {
return mEditable;
}

public void setInputType(int type) {
inputtype = type;
}

public int getInputType() {
return inputtype;
}

public void setHint(String hint) {
mHint = hint;
}
Expand Down
43 changes: 36 additions & 7 deletions app/src/main/java/odoo/controls/OField.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
Expand Down Expand Up @@ -111,7 +112,7 @@ public static WidgetType getWidgetType(int widget) {
}

public enum FieldType {
Text, Boolean, ManyToOne, Chips, Selection, Date, Time, DateTime, Blob, RelationType;
Text, Boolean, ManyToOne, Chips, Selection, Date, Time, DateTime, Blob, RelationType, Integer, Float;

public static FieldType getTypeValue(int type_val) {
switch (type_val) {
Expand All @@ -133,6 +134,10 @@ public static FieldType getTypeValue(int type_val) {
return FieldType.Blob;
case 8:
return FieldType.Time;
case 9:
return FieldType.Integer;
case 10:
return FieldType.Float;
}
return FieldType.Text;
}
Expand Down Expand Up @@ -267,6 +272,12 @@ public void initControl() {
case Blob:
controlView = initBlobControl();
break;
case Integer:
controlView = initIntegerControl();
break;
case Float:
controlView = initFloatControl();
break;
default:
return;
}
Expand Down Expand Up @@ -313,14 +324,21 @@ private <T> FieldType getType(Class<T> type_class) {
try {
// Varchar
if (type_class.isAssignableFrom(OVarchar.class)
|| type_class.isAssignableFrom(OInteger.class)
|| type_class.isAssignableFrom(OFloat.class)) {
|| type_class.isAssignableFrom(OText.class)) {
return FieldType.Text;
}
// boolean
if (type_class.isAssignableFrom(OBoolean.class)) {
return FieldType.Boolean;
}
// Integer
if (type_class.isAssignableFrom(OInteger.class)) {
return FieldType.Integer;
}
// Float
if (type_class.isAssignableFrom(OFloat.class)) {
return FieldType.Float;
}

// Blob
if (type_class.isAssignableFrom(OBlob.class)) {
Expand All @@ -335,10 +353,6 @@ private <T> FieldType getType(Class<T> type_class) {
if (type_class.isAssignableFrom(ODate.class)) {
return FieldType.Date;
}
// Text
if (type_class.isAssignableFrom(OText.class)) {
return FieldType.Text;
}
// FIXME: WebView type
if (type_class.isAssignableFrom(OHtml.class)) {
return FieldType.Text;
Expand Down Expand Up @@ -461,6 +475,21 @@ private View initBlobControl() {
return blob;
}

// EditText control (TextView, EditText)
private View initIntegerControl() {
OEditTextField edt = (OEditTextField) initTextControl();
edt.setInputType(EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD
| EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
return edt;
}

// EditText control (TextView, EditText)
private View initFloatControl() {
OEditTextField edt = (OEditTextField) initTextControl();
edt.setInputType(EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL);
return edt;
}

private TextView getLabelView() {
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<enum name="DateTime" value="6" />
<enum name="Blob" value="7" />
<enum name="Time" value="8" />
<enum name="Integer" value="9" />
<enum name="Float" value="10" />
</attr>
<attr name="widgetType">
<enum name="Switch" value="0" />
Expand Down