Skip to content

Commit

Permalink
Merge branch 'master' into update_analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews committed Jun 21, 2018
2 parents 10090bc + d03b8f6 commit d45d9b1
Show file tree
Hide file tree
Showing 36 changed files with 348 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void updateRowAt(int index, TableViewRowProxy row)
if (index > -1 && index < rows.size()) {
rows.set(index, row);
row.setParent(this);
if (oldRow.getParent() == this) {
if (oldRow.getParent() == this && !rows.contains(oldRow)) {
oldRow.setParent(null);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*/
package ti.modules.titanium.ui.widget;

import java.lang.CharSequence;
import java.util.HashMap;

import android.text.TextUtils;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.proxy.TiViewProxy;
Expand All @@ -20,9 +21,13 @@
import org.appcelerator.titanium.view.TiDrawableReference;
import org.appcelerator.titanium.view.TiUIView;

import ti.modules.titanium.ui.AttributedStringProxy;

import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.support.v7.widget.AppCompatButton;

Expand Down Expand Up @@ -85,6 +90,12 @@ public void processProperties(KrollDict d)
if (d.containsKey(TiC.PROPERTY_TITLE)) {
btn.setText(d.getString(TiC.PROPERTY_TITLE));
}
if (d.containsKey(TiC.PROPERTY_ATTRIBUTED_STRING)) {
Object attributedString = d.get(TiC.PROPERTY_ATTRIBUTED_STRING);
if (attributedString instanceof AttributedStringProxy) {
setAttributedStringText((AttributedStringProxy) attributedString);
}
}
if (d.containsKey(TiC.PROPERTY_COLOR)) {
Object color = d.get(TiC.PROPERTY_COLOR);
if (color == null) {
Expand Down Expand Up @@ -144,6 +155,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
AppCompatButton btn = (AppCompatButton) getNativeView();
if (key.equals(TiC.PROPERTY_TITLE)) {
btn.setText((String) newValue);
} else if (key.equals(TiC.PROPERTY_ATTRIBUTED_STRING) && newValue instanceof AttributedStringProxy) {
setAttributedStringText((AttributedStringProxy) newValue);
} else if (key.equals(TiC.PROPERTY_COLOR)) {
btn.setTextColor(TiConvert.toColor(TiConvert.toString(newValue)));
} else if (key.equals(TiC.PROPERTY_FONT)) {
Expand Down Expand Up @@ -188,4 +201,20 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
super.propertyChanged(key, oldValue, newValue, proxy);
}
}

private void setAttributedStringText(AttributedStringProxy attrString)
{
AppCompatButton btn = (AppCompatButton) getNativeView();

if (btn == null) {
return;
}

CharSequence text = AttributedStringProxy.toSpannable(attrString, TiApplication.getAppCurrentActivity());
if (text == null) {
text = "";
}

btn.setText(text);
}
}
4 changes: 2 additions & 2 deletions android/runtime/v8/tools/genBootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
thisDir = os.path.abspath(os.path.dirname(__file__))
androidDir = os.path.abspath(os.path.join(thisDir, "..", "..", ".."))

# We package simplejson in the support/common directory.
commonSupportDir = os.path.abspath(os.path.join(androidDir, "..", "support", "common"))
# We package simplejson in our directory.
commonSupportDir = os.path.abspath(os.path.join(thisDir))
sys.path.append(commonSupportDir)

try:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 16 additions & 3 deletions apidoc/Titanium/UI/Button.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ excludes:
methods: [add, remove, removeAllChildren, replaceAt]
since: "0.8"
properties:
- name: attributedString
summary: Specify an attributed string for the label.
description: |
The underlying attributed string drawn by the label. If set, avoid setting common attributes
in the label, such as `color` and `font`, as unexpected behaviors may result.
iOS Note: This property can also be used to supress the underline style when accessibility
is enabled. To do so, set the `type` to <Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE> and the
`value` to <Titanium.UI.ATTRIBUTE_UNDERLINE_STYLE_NONE>.
type: Titanium.UI.AttributedString
platforms: [android, iphone, ipad]
since:
android: 7.4.0
iphone: 7.4.0
ipad: 7.4.0

- name: backgroundImage
summary: |
Background image for the button in its normal state, specified as a local file path or URL.
Expand All @@ -148,7 +164,6 @@ properties:
is unset, the image will be darkened to indicate being selected.
type: String


- name: backgroundDisabledImage
summary: |
Background image for the button in its disabled state, specified as a local file path
Expand Down Expand Up @@ -194,7 +209,6 @@ properties:
For information about color values, see the "Colors" section of <Titanium.UI>.
type: String


- name: disabledColor
summary: Text color of the button in its disabled state, as a color name or hex triplet.
type: String
Expand All @@ -211,7 +225,6 @@ properties:
summary: Font to use for the button text.
type: Font


- name: image
summary: Image to display on the button, specified as a local
path, URL or a `Blob`.
Expand Down
14 changes: 14 additions & 0 deletions iphone/Classes/TiUIButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#import "TiUIView.h"
#import "TiUtils.h"

#ifdef USE_TI_UIATTRIBUTEDSTRING
#import "TiUIAttributedStringProxy.h"
#endif

@implementation TiUIButton

#pragma mark Internal
Expand Down Expand Up @@ -252,6 +256,16 @@ - (void)setTitle_:(id)value
[[self button] setTitle:[TiUtils stringValue:value] forState:UIControlStateNormal];
}

- (void)setAttributedString_:(id)arg
{
#ifdef USE_TI_UIATTRIBUTEDSTRING
ENSURE_SINGLE_ARG(arg, TiUIAttributedStringProxy);
[[self proxy] replaceValue:arg forKey:@"attributedString" notification:NO];
[[self button] setAttributedTitle:[arg attributedString] forState:UIControlStateNormal];
[(TiViewProxy *)[self proxy] contentsWillChange];
#endif
}

- (void)setBackgroundImage_:(id)value
{
[backgroundImageCache release];
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUILabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ - (void)setMinimumFontSize_:(id)size
[label setAdjustsFontSizeToFitWidth:YES];
CGFloat ratio = minFontSize / label.font.pointSize;
[label setMinimumScaleFactor:ratio];
[label setBaselineAdjustment:UIBaselineAdjustmentNone];
}
}

Expand Down
102 changes: 88 additions & 14 deletions iphone/Classes/TiUISearchBarProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,17 @@ - (UISearchBar *)searchBar

- (void)setSearchBar:(UISearchBar *)searchBar
{
// We need to manually handle this property as it will be overwritten
// by the search controller otherwise (TIMOB-10368)
if ([self valueForKey:@"color"] != nil) {
UIView *searchContainerView = [[searchBar subviews] firstObject];
UIColor *color = [TiUtils colorValue:[self valueForKey:@"color"]].color;

[[searchContainerView subviews] enumerateObjectsUsingBlock:^(__kindof UIView *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) {
if ([obj isKindOfClass:[UITextField class]]) {
[(UITextField *)obj setTextColor:color];
*stop = YES;
}
}];
}

// In UISearchController searchbar is readonly. We have to replace that search bar with existing search bar of proxy.
[(TiUISearchBar *)[self view] setSearchBar:searchBar];

// Set search bar properties to new search bar
NSDictionary *properties = [self allProperties];
for (NSString *key in properties.allKeys) {
SEL selector = SetterForKrollProperty(key);
if ([(TiUISearchBar *)[self view] respondsToSelector:selector]) {
[(TiUISearchBar *)[self view] performSelector:selector withObject:[properties objectForKey:key]];
}
}
}

- (void)ensureSearchBarHierarchy
Expand All @@ -113,6 +108,85 @@ - (TiDimension)defaultAutoHeightBehavior:(id)unused
return TiDimensionAutoSize;
}

#pragma mark getters

- (NSString *)value
{
return [[self searchBar] text];
}

- (NSNumber *)showBookmark
{
return NUMBOOL([[self searchBar] showsBookmarkButton]);
}

- (NSNumber *)showCancel
{
return NUMBOOL([[self searchBar] showsCancelButton]);
}

- (NSString *)hintText
{
return [[self searchBar] placeholder];
}

- (id)hintTextColor
{
return [self valueForUndefinedKey:@"hintTextColor"];
}

- (id)color
{
return [self valueForUndefinedKey:@"color"];
}

- (NSNumber *)keyboardType
{
return NUMINT([[self searchBar] keyboardType]);
}

- (NSNumber *)keyboardAppearance
{
return NUMINT([[self searchBar] keyboardAppearance]);
}

- (NSString *)prompt
{
return [[self searchBar] prompt];
}

- (NSNumber *)autocorrect
{
UITextAutocorrectionType autocorrectionType = [[self searchBar] autocorrectionType];
if (autocorrectionType == UITextAutocorrectionTypeYes) {
return NUMBOOL(YES);
} else if (autocorrectionType == UITextAutocorrectionTypeNo) {
return NUMBOOL(NO);
} else {
return nil;
}
}

- (NSNumber *)autocapitalization
{
return NUMINT([[self searchBar] autocapitalizationType]);
}

- (id)tintColor
{
return [self valueForUndefinedKey:@"tintColor"];
}

- (id)barColor
{
return [self valueForUndefinedKey:@"barColor"];
}

- (NSNumber *)style
{
return NUMINT([[self searchBar] searchBarStyle]);
}

USE_VIEW_FOR_CONTENT_HEIGHT
@end

Expand Down
5 changes: 3 additions & 2 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4678,7 +4678,7 @@ iOSBuilder.prototype.cleanXcodeDerivedData = function cleanXcodeDerivedData(next
}

const exe = this.xcodeEnv.executables.xcodebuild,
args = [ 'clean' ];
args = [ 'clean', '-UseNewBuildSystem=NO' ]; // Use old build system until www.openradar.me/40906897 is fixed
let tries = 0,
lastErr = null,
done = false;
Expand Down Expand Up @@ -6530,7 +6530,8 @@ iOSBuilder.prototype.invokeXcodeBuild = function invokeXcodeBuild(next) {
'-derivedDataPath', path.join(this.buildDir, 'DerivedData'),
'OBJROOT=' + path.join(this.buildDir, 'build', 'Intermediates'),
'SHARED_PRECOMPS_DIR=' + path.join(this.buildDir, 'build', 'Intermediates', 'PrecompiledHeaders'),
'SYMROOT=' + path.join(this.buildDir, 'build', 'Products')
'SYMROOT=' + path.join(this.buildDir, 'build', 'Products'),
'-UseNewBuildSystem=NO' // Use old build system until www.openradar.me/40906897 is fixed
];

if (this.simHandle) {
Expand Down
12 changes: 8 additions & 4 deletions iphone/cli/commands/_buildModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const appc = require('node-appc'),
iosPackageJson = appc.pkginfo.package(module),
jsanalyze = require('node-titanium-sdk/lib/jsanalyze'),
ejs = require('ejs'),
fs = require('fs'),
fs = require('fs-extra'),
markdown = require('markdown').markdown,
path = require('path'),
spawn = require('child_process').spawn, // eslint-disable-line security/detect-child-process
Expand Down Expand Up @@ -151,6 +151,7 @@ iOSModuleBuilder.prototype.initialize = function initialize() {
this.metaData = [];
this.metaDataFile = path.join(this.projectDir, 'metadata.json');
this.manifestFile = path.join(this.projectDir, 'manifest');
this.distDir = path.join(this.projectDir, 'dist');
this.templatesDir = path.join(this.platformPath, 'templates');
this.assetsTemplateFile = path.join(this.templatesDir, 'module', 'default', 'template', 'ios', 'Classes', '{{ModuleIdAsIdentifier}}ModuleAssets.m.ejs');
this.universalBinaryDir = path.join(this.projectDir, 'build');
Expand Down Expand Up @@ -455,13 +456,15 @@ iOSModuleBuilder.prototype.buildModule = function buildModule(next) {
// Create a build for the device
xcodebuildHook(this.xcodeEnv.executables.xcodebuild, [
'-configuration', 'Release',
'-sdk', 'iphoneos'
'-sdk', 'iphoneos',
'-UseNewBuildSystem=NO',
], opts, 'xcode-dist', done);

// Create a build for the simulator
xcodebuildHook(this.xcodeEnv.executables.xcodebuild, [
'-configuration', 'Release',
'-sdk', 'iphonesimulator'
'-sdk', 'iphonesimulator',
'-UseNewBuildSystem=NO',
], opts, 'xcode-sim', done);
};

Expand Down Expand Up @@ -555,7 +558,7 @@ iOSModuleBuilder.prototype.packageModule = function packageModule(next) {
moduleId = this.moduleId,
version = this.moduleVersion,
moduleZipName = [ moduleId, '-iphone-', version, '.zip' ].join(''),
moduleZipFullPath = path.join(this.projectDir, moduleZipName),
moduleZipFullPath = path.join(this.distDir, moduleZipName),
moduleFolders = path.join('modules', 'iphone', moduleId, version),
binarylibName = 'lib' + moduleId + '.a',
binarylibFile = path.join(this.projectDir, 'build', binarylibName);
Expand All @@ -567,6 +570,7 @@ iOSModuleBuilder.prototype.packageModule = function packageModule(next) {

try {
// if the zip file is there, remove it
fs.ensureDirSync(this.distDir);
fs.existsSync(moduleZipFullPath) && fs.unlinkSync(moduleZipFullPath);
const zipStream = fs.createWriteStream(moduleZipFullPath);
zipStream.on('close', function () {
Expand Down
3 changes: 0 additions & 3 deletions support/common/README.md

This file was deleted.

0 comments on commit d45d9b1

Please sign in to comment.