Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-24967
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Aug 8, 2017
2 parents 9d4ea17 + 3b482b1 commit 3e14c9d
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ see the LICENSE file for specific details.
* [Commercial Support, Licensing](#commercial-support-licensing)
5. [Contributing](#contributing)
6. [Building Locally](#building-locally)
* [Unit tests](#unit-tests)
* [Unit Tests](#unit-tests)
7. [Legal Stuff](#legal-stuff)

## Features
Expand Down
2 changes: 1 addition & 1 deletion android/cli/lib/AndroidManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var appc = require('node-appc'),

tagAttrs = {
'application': /^(allowTaskReparenting|allowBackup|backupAgent|backupInForeground|banner|debuggable|description|directBootAware|enabled|extractNativeLibs|fullBackupContent|fullBackupOnly|hasCode|hardwareAccelerated|icon|isGame|killAfterRestore|largeHeap|label|logo|manageSpaceActivity|name|networkSecurityConfig|permission|persistent|process|restoreAnyVersion|requiredAccountType|resizeableActivity|restrictedAccountType|supportsRtl|taskAffinity|testOnly|theme|uiOptions|usesCleartextTraffic|vmSafeMode)$/,
'activity': /^(allowEmbedded|allowTaskReparenting|alwaysRetainTaskState|autoRemoveFromRecents|banner|clearTaskOnLaunch|configChanges|directBootAware|documentLaunchMode|enabled|excludeFromRecents|exported|finishOnTaskLaunch|hardwareAccelerated|icon|label|launchMode|maxRecents|multiprocess|name|noHistory|parentActivityName|permission|persistableMode|process|relinquishTaskIdentity|resizeableActivity|screenOrientation|showForAllUsers|stateNotNeeded|supportsPictureInPicture|taskAffinity|theme|uiOptions|windowSoftInputMode)$/,
'activity': /^(allowEmbedded|allowTaskReparenting|alwaysRetainTaskState|autoRemoveFromRecents|banner|clearTaskOnLaunch|configChanges|density|directBootAware|documentLaunchMode|enabled|excludeFromRecents|exported|finishOnTaskLaunch|hardwareAccelerated|icon|label|launchMode|maxRecents|multiprocess|name|noHistory|parentActivityName|permission|persistableMode|process|relinquishTaskIdentity|resizeableActivity|screenOrientation|showForAllUsers|stateNotNeeded|supportsPictureInPicture|taskAffinity|theme|uiOptions|windowSoftInputMode)$/,
'activity-alias': /^(enabled|exported|icon|label|name|permission|targetActivity)$/,
'data': /^(host|mimeType|path|pathPattern|pathPrefix|port|scheme)$/,
'intent-filter': /^(icon|label|priority)$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
TiC.PROPERTY_HINT_TEXT,
TiC.PROPERTY_HINT_TEXT_ID,
TiC.PROPERTY_HINT_TEXT_COLOR,
TiC.PROPERTY_HINT_TYPE,
TiC.PROPERTY_INPUT_TYPE,
TiC.PROPERTY_KEYBOARD_TYPE,
TiC.PROPERTY_MAX_LENGTH,
Expand All @@ -59,6 +60,7 @@ public TextFieldProxy()
defaultValues.put(TiC.PROPERTY_VALUE, "");
defaultValues.put(TiC.PROPERTY_MAX_LENGTH, -1);
defaultValues.put(TiC.PROPERTY_FULLSCREEN, true);
defaultValues.put(TiC.PROPERTY_HINT_TYPE, UIModule.HINT_TYPE_STATIC);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public class UIModule extends KrollModule implements Handler.Callback
@Kroll.constant public static final int INPUT_TYPE_CLASS_NUMBER = InputType.TYPE_CLASS_NUMBER;
@Kroll.constant public static final int INPUT_TYPE_CLASS_TEXT = InputType.TYPE_CLASS_TEXT;

@Kroll.constant public static final int HINT_TYPE_STATIC = 0;
@Kroll.constant public static final int HINT_TYPE_ANIMATED = 1;

@Kroll.constant public static final int HIDDEN_BEHAVIOR_GONE = View.GONE;
@Kroll.constant public static final int HIDDEN_BEHAVIOR_INVISIBLE = View.INVISIBLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.AttributedStringProxy;
import ti.modules.titanium.ui.UIModule;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.TextInputLayout;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType;
Expand All @@ -45,6 +48,7 @@
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

Expand Down Expand Up @@ -88,6 +92,7 @@ public class TiUIText extends TiUIView
private boolean disableChangeEvent = false;

protected TiUIEditText tv;
protected TextInputLayout textInputLayout;

public TiUIText(final TiViewProxy proxy, boolean field)
{
Expand Down Expand Up @@ -130,7 +135,10 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int
} else {
tv.setGravity(Gravity.TOP | Gravity.LEFT);
}
setNativeView(tv);

textInputLayout = new TextInputLayout(proxy.getActivity());
textInputLayout.addView(tv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
setNativeView(textInputLayout);
}

@Override
Expand Down Expand Up @@ -159,7 +167,15 @@ public void processProperties(KrollDict d)
}

if (d.containsKey(TiC.PROPERTY_HINT_TEXT)) {
tv.setHint(d.getString(TiC.PROPERTY_HINT_TEXT));
String hintText = d.getString(TiC.PROPERTY_HINT_TEXT);
if (hintText != null) {
int type = TiConvert.toInt(d.get(TiC.PROPERTY_HINT_TYPE), UIModule.HINT_TYPE_STATIC);
if (type == UIModule.HINT_TYPE_STATIC) {
tv.setHint(hintText);
} else if (type == UIModule.HINT_TYPE_ANIMATED) {
textInputLayout.setHint(hintText);
}
}
}

if (d.containsKey(TiC.PROPERTY_HINT_TEXT_COLOR)) {
Expand Down Expand Up @@ -285,6 +301,18 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
tv.setHint(TiConvert.toString(newValue));
} else if (key.equals(TiC.PROPERTY_HINT_TEXT_COLOR)) {
tv.setHintTextColor(TiConvert.toColor((String) newValue));
} else if (key.equals(TiC.PROPERTY_HINT_TYPE)) {
String hintText = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_HINT_TEXT));
if (hintText != null) {
int type = TiConvert.toInt(newValue);
if (type == UIModule.HINT_TYPE_STATIC) {
textInputLayout.setHint("");
tv.setHint(hintText);
} else if (type == UIModule.HINT_TYPE_ANIMATED) {
tv.setHint("");
textInputLayout.setHint(hintText);
}
}
} else if (key.equals(TiC.PROPERTY_ELLIPSIZE)) {
if (TiConvert.toBoolean(newValue)) {
tv.setEllipsize(TruncateAt.END);
Expand Down
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,11 @@ public class TiC
*/
public static final String PROPERTY_HINT_TEXT_COLOR = "hintTextColor";

/**
* @module.api
*/
public static final String PROPERTY_HINT_TYPE = "hintType";

/**
* @module.api
*/
Expand Down
10 changes: 10 additions & 0 deletions apidoc/Titanium/UI/TextField.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ properties:
type: String
since: "6.2.0"

- name: hintType
summary: Hint type to display on the text field.
platforms: [android]
since: {android: "6.2.0"}
description: |
Setting this to <Titanium.UI.HINT_TYPE_ANIMATED> will use the animated TextInputLayout on Android.
type: Number
constants: [Titanium.UI.HINT_TYPE_*]
default: <Titanium.UI.HINT_TYPE_STATIC>

- name: inputType
summary: Input type to accept in the text field. Also influences the Keyboard type to display.
description: |
Expand Down
18 changes: 18 additions & 0 deletions apidoc/Titanium/UI/UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,24 @@ properties:
type: Number
permission: read-only
platforms: [iphone, ipad]

- name: HINT_TYPE_STATIC
deprecated:
since: "6.2.0"
summary: |
Use when creating a TextField to specify the hintType as static.
type: Number
permission: read-only
platforms: [android]

- name: HINT_TYPE_ANIMATED
deprecated:
since: "6.2.0"
summary: |
Use when creating a TextField to specify the hintType as animated.
type: Number
permission: read-only
platforms: [android]

- name: TEXT_ELLIPSIZE_TRUNCATE_WORD_WRAP
summary: Add ellipses at word boundaries, unless the word itself doesn't fit on a single line.
Expand Down

0 comments on commit 3e14c9d

Please sign in to comment.